⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listpanel.cpp

📁 LINUX 下, 以 QT/KDE 写的档案管理员
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************                         listpanel.cpp                      -------------------copyright            : (C) 2000 by Shie Erlich & Rafi Yanaie-mail               : krusader@users.sourceforge.netweb site             : http://krusader.sourceforge.net---------------------------------------------------------------------------Description ***************************************************************************A db   dD d8888b. db    db .d8888.  .d8b.  d8888b. d88888b d8888b.88 ,8P' 88  `8D 88    88 88'  YP d8' `8b 88  `8D 88'     88  `8D88,8P   88oobY' 88    88 `8bo.   88ooo88 88   88 88ooooo 88oobY'88`8b   88`8b   88    88   `Y8b. 88~~~88 88   88 88~~~~~ 88`8b88 `88. 88 `88. 88b  d88 db   8D 88   88 88  .8D 88.     88 `88.YP   YD 88   YD ~Y8888P' `8888Y' YP   YP Y8888D' Y88888P 88   YD                                              S o u r c e    F i l e****************************************************************************                                                                         **   This program is free software; you can redistribute it and/or modify  **   it under the terms of the GNU General Public License as published by  **   the Free Software Foundation; either version 2 of the License, or     **   (at your option) any later version.                                   **                                                                         ****************************************************************************/#include <unistd.h>#include <sys/param.h>// QT includes#include <qbitmap.h>#include <qwhatsthis.h>#include <qstringlist.h>#include <qstrlist.h>#include <kurldrag.h>#include <qheader.h>#include <qtimer.h>#include <qregexp.h> #include <qsplitter.h>// KDE includes#include <kpopupmenu.h>#include <kprocess.h>#include <kmessagebox.h>#include <klocale.h>#include <kmimetype.h>#include <kurl.h>#include <ktrader.h>#include <kopenwith.h>#include <kuserprofile.h>#include <kiconloader.h>#include <kcursor.h>#include <kmessagebox.h>#include <kstandarddirs.h>#include <kglobalsettings.h>#include <qtooltip.h>#include <kdeversion.h>#include <qimage.h>#include <qtabbar.h>#include <kdebug.h>#include <kurlrequester.h>#include <kurl.h> #include <kmountpoint.h>// Krusader includes#include "../krusader.h"#include "../krslots.h"#include "panelfunc.h"#include "../kicons.h"#include "../VFS/krpermhandler.h"#include "listpanel.h"#include "../krusaderview.h"#include "../panelmanager.h"#include "../defaults.h"#include "../resources.h"#include "../MountMan/kmountman.h"#include "../Dialogs/krdialogs.h"#include "../BookMan/krbookmarkbutton.h"#include "../Dialogs/krspwidgets.h"#include "../Dialogs/krspecialwidgets.h"#include "../GUI/kcmdline.h"#include "../Dialogs/percentalsplitter.h"#include "krdetailedview.h"#include "krbriefview.h"#include "krpreviewpopup.h"#include "../GUI/dirhistorybutton.h"#include "../GUI/dirhistoryqueue.h"#include "../GUI/mediabutton.h"#include "../GUI/syncbrowsebutton.h"#include "../krservices.h"#include "panelpopup.h" #include "../UserAction/useractionpopupmenu.h"#include "../Dialogs/popularurls.h"#include "krpopupmenu.h"#ifdef __LIBKONQ__#include <konq_popupmenu.h>#include <konqbookmarkmanager.h>#endiftypedef QValueList<KServiceOffer> OfferList;#define URL(X) KURL::fromPathOrURL(X)/////////////////////////////////////////////////////// 					The list panel constructor       ///////////////////////////////////////////////////////ListPanel::ListPanel( QString typeIn, QWidget *parent, bool &left, const char *name ) :      QWidget( parent, name ), panelType( typeIn ), colorMask( 255 ), compareMode( false ), currDragItem( 0 ), statsAgent( 0 ), 		quickSearch( 0 ), cdRootButton( 0 ), cdUpButton( 0 ), popupBtn(0), popup(0),inlineRefreshJob(0), _left( left ) {   func = new ListPanelFunc( this );   setAcceptDrops( true );   layout = new QGridLayout( this, 3, 3 );   mediaButton = new MediaButton( this, "mediaButton" );   connect( mediaButton, SIGNAL( pressed() ), this, SLOT( slotFocusOnMe() ) );   connect( mediaButton, SIGNAL( openUrl( const KURL& ) ), func, SLOT( openUrl( const KURL& ) ) );   status = new KrSqueezedTextLabel( this );   krConfig->setGroup( "Look&Feel" );   status->setFont( krConfig->readFontEntry( "Filelist Font", _FilelistFont ) );   status->setBackgroundMode( PaletteBackground );   status->setFrameStyle( QFrame::Box | QFrame::Raised );   status->setLineWidth( 1 );		// a nice 3D touch :-)   status->setText( "" );        // needed for initialization code!   status->enableDrops( true );   int sheight = QFontMetrics( status->font() ).height() + 4;   status->setMaximumHeight( sheight );   QWhatsThis::add      ( status, i18n( "The statusbar displays information about the FILESYSTEM "                      "which holds your current directory: Total size, free space, "                      "type of filesystem, etc." ) );   connect( status, SIGNAL( clicked() ), this, SLOT( slotFocusOnMe() ) );   connect( status, SIGNAL( dropped( QDropEvent *) ), this, SLOT( handleDropOnStatus(QDropEvent *) ) );   // ... create the history button   dirHistoryQueue = new DirHistoryQueue( this );   historyButton = new DirHistoryButton( dirHistoryQueue, this, "historyButton" );   connect( historyButton, SIGNAL( pressed() ), this, SLOT( slotFocusOnMe() ) );   connect( historyButton, SIGNAL( openUrl( const KURL& ) ), func, SLOT( openUrl( const KURL& ) ) );	bookmarksButton = new KrBookmarkButton(this);	connect( bookmarksButton, SIGNAL( pressed() ), this, SLOT( slotFocusOnMe() ) );   connect( bookmarksButton, SIGNAL( openUrl( const KURL& ) ), func, SLOT( openUrl( const KURL& ) ) );	QWhatsThis::add      ( bookmarksButton, i18n( "Open menu with bookmarks. You can also add "                               "current location to the list, edit bookmarks "                               "or add subfolder to the list." ) );										    QHBoxLayout *totalsLayout = new QHBoxLayout;	totals = new KrSqueezedTextLabel( this );   krConfig->setGroup( "Look&Feel" );   totals->setFont( krConfig->readFontEntry( "Filelist Font", _FilelistFont ) );   totals->setFrameStyle( QFrame::Box | QFrame::Raised );   totals->setBackgroundMode( PaletteBackground );   totals->setLineWidth( 1 );		// a nice 3D touch :-)   totals->setMaximumHeight( sheight );   totals->enableDrops( true );   QWhatsThis::add      ( totals, i18n( "The totals bar shows how many files exist, "                      "how many selected and the bytes math" ) );   connect( totals, SIGNAL( clicked() ), this, SLOT( slotFocusOnMe() ) );   connect( totals, SIGNAL( dropped( QDropEvent *) ), this, SLOT( handleDropOnTotals(QDropEvent *) ) );     	// a cancel button for the inplace refresh mechanism	inlineRefreshCancelButton = new KPushButton(this);	inlineRefreshCancelButton->setFixedSize( 22, 20 );	inlineRefreshCancelButton->setPixmap(krLoader->loadIcon("cancel", KIcon::Toolbar, 16));	connect(inlineRefreshCancelButton, SIGNAL(clicked()), this, SLOT(inlineRefreshCancel()));	// a quick button to open the popup panel	popupBtn = new QToolButton( this, "popupbtn" );	popupBtn->setFixedSize( 22, 20 );	popupBtn->setPixmap(krLoader->loadIcon("1uparrow", KIcon::Toolbar, 16));	connect(popupBtn, SIGNAL(clicked()), this, SLOT(togglePanelPopup()));	QToolTip::add(  popupBtn, i18n( "Open the popup panel" ) );	totalsLayout->addWidget(totals);	totalsLayout->addWidget(inlineRefreshCancelButton); inlineRefreshCancelButton->hide();	totalsLayout->addWidget(popupBtn);      quickSearch = new KrQuickSearch( this );   krConfig->setGroup( "Look&Feel" );   quickSearch->setFont( krConfig->readFontEntry( "Filelist Font", _FilelistFont ) );   quickSearch->setFrameStyle( QFrame::Box | QFrame::Raised );   quickSearch->setLineWidth( 1 );		// a nice 3D touch :-)   quickSearch->setMaximumHeight( sheight );   QHBox * hbox = new QHBox( this );	// clear-origin button	bool clearButton = krConfig->readBoolEntry("Clear Location Bar Visible", _ClearLocation);	if (clearButton){		clearOrigin = new QToolButton(hbox, "clearorigin");		clearOrigin->setPixmap(krLoader->loadIcon("locationbar_erase", KIcon::Toolbar, 16));		QToolTip::add(  clearOrigin, i18n( "Clear the location bar" ) );	}		QuickNavLineEdit *qnle = new QuickNavLineEdit(this);   origin = new KURLRequester( qnle, hbox );   QPixmap pixMap = origin->button() ->iconSet() ->pixmap( QIconSet::Small, QIconSet::Normal );   origin->button() ->setFixedSize( pixMap.width() + 4, pixMap.height() + 4 );   QWhatsThis::add      ( origin, i18n( "Use superb KDE file dialog to choose location. " ) );   origin->setShowLocalProtocol( false );   origin->lineEdit() ->setURLDropsEnabled( true );   origin->lineEdit() ->installEventFilter( this );   QWhatsThis::add      ( origin->lineEdit(), i18n( "Name of directory where you are. You can also "                                  "enter name of desired location to move there. "                                  "Use of Net protocols like ftp or fish is possible." ) );   origin->setMode( KFile::Directory | KFile::ExistingOnly );   connect( origin, SIGNAL( returnPressed( const QString& ) ), func, SLOT( openUrl( const QString& ) ) );   connect( origin, SIGNAL( returnPressed( const QString& ) ), this, SLOT( slotFocusOnMe() ) );   connect( origin, SIGNAL( urlSelected( const QString& ) ), func, SLOT( openUrl( const QString& ) ) );   connect( origin, SIGNAL( urlSelected( const QString& ) ), this, SLOT( slotFocusOnMe() ) );   	// this is here on purpose, do not move up!	if (clearButton) {		clearOrigin->setFixedSize( 20, origin->button() ->height() );		connect(clearOrigin, SIGNAL(clicked()), origin->lineEdit(), SLOT(clear()));		connect(clearOrigin, SIGNAL(clicked()), origin->lineEdit(), SLOT(setFocus()));	}	//      cdOtherButton = new QToolButton( hbox, "cdOtherButton" );   cdOtherButton->setFixedSize( 20, origin->button() ->height() );   cdOtherButton->setText( i18n( "=" ) );	QToolTip::add(  cdOtherButton, i18n( "Equal" ) );   connect( cdOtherButton, SIGNAL( clicked() ), this, SLOT( slotFocusAndCDOther() ) );   cdUpButton = new QToolButton( hbox, "cdUpButton" );   cdUpButton->setFixedSize( 20, origin->button() ->height() );   cdUpButton->setText( i18n( ".." ) );	QToolTip::add(  cdUpButton, i18n( "Up" ) );   connect( cdUpButton, SIGNAL( clicked() ), this, SLOT( slotFocusAndCDup() ) );   cdHomeButton = new QToolButton( hbox, "cdHomeButton" );   cdHomeButton->setFixedSize( 20, origin->button() ->height() );   cdHomeButton->setText( i18n( "~" ) );	QToolTip::add(  cdHomeButton, i18n( "Home" ) );   connect( cdHomeButton, SIGNAL( clicked() ), this, SLOT( slotFocusAndCDHome() ) );   cdRootButton = new QToolButton( hbox, "cdRootButton" );   cdRootButton->setFixedSize( 20, origin->button() ->height() );   cdRootButton->setText( i18n( "/" ) );	QToolTip::add(  cdRootButton, i18n( "Root" ) );   connect( cdRootButton, SIGNAL( clicked() ), this, SLOT( slotFocusAndCDRoot() ) );   // ... creates the button for sync-browsing   syncBrowseButton = new SyncBrowseButton( hbox );   setPanelToolbar();   header = new QHeader( this );   header->hide();	// create a splitter to hold the view and the popup	splt = new PercentalSplitter(this);	splt->setChildrenCollapsible(true);	splt->setOrientation(QObject::Vertical);	createView();	   // make sure that a focus/path change reflects in the command line and activePanel   connect( this, SIGNAL( cmdLineUpdate( QString ) ), SLOTS, SLOT( slotCurrentChanged( QString ) ) );   connect( this, SIGNAL( activePanelChanged( ListPanel * ) ), SLOTS, SLOT( slotSetActivePanel( ListPanel * ) ) );		// add a popup	popup = new PanelPopup(splt, left);	connect(popup, SIGNAL(selection(const KURL&)), SLOTS, SLOT(refresh(const KURL&)));	connect(popup, SIGNAL(hideMe()), this, SLOT(togglePanelPopup()));	popup->hide();	   // finish the layout	layout->addMultiCellWidget( hbox, 0, 0, 0, 3 );   layout->addWidget( mediaButton, 1, 0 );   layout->addWidget( status, 1, 1 );   layout->addWidget( historyButton, 1, 2 );   layout->addWidget( bookmarksButton, 1, 3 );   layout->addMultiCellWidget( header, 2, 2, 0, 3 );   layout->addMultiCellWidget( splt, 3, 3, 0, 3 );   layout->addMultiCellWidget( quickSearch, 4, 4, 0, 3 );   quickSearch->hide();   layout->addMultiCellLayout( totalsLayout, 5, 5, 0, 3 );   //filter = ALL;}void ListPanel::createView(){	header->hide();	if( panelType == "Brief" )	{		view = new KrBriefView( header, splt, _left, krConfig );		view->init();				connect( dynamic_cast<KrBriefView*>( view ), SIGNAL( middleButtonClicked( KrViewItem * ) ), SLOTS, SLOT( newTab( KrViewItem * ) ) );		connect( dynamic_cast<KrBriefView*>( view ), SIGNAL( currentChanged( KrViewItem * ) ), 			SLOTS, SLOT( updatePopupPanel( KrViewItem* ) ) );		// connect quicksearch		connect( quickSearch, SIGNAL( textChanged( const QString& ) ),			dynamic_cast<KrBriefView*>( view ), SLOT( quickSearch( const QString& ) ) );		connect( quickSearch, SIGNAL( otherMatching( const QString&, int ) ),			dynamic_cast<KrBriefView*>( view ), SLOT( quickSearch( const QString& , int ) ) );		connect( quickSearch, SIGNAL( stop( QKeyEvent* ) ),			dynamic_cast<KrBriefView*>( view ), SLOT( stopQuickSearch( QKeyEvent* ) ) );		connect( quickSearch, SIGNAL( process( QKeyEvent* ) ),			dynamic_cast<KrBriefView*>( view ), SLOT( handleQuickSearchEvent( QKeyEvent* ) ) );	} else { /* Detailed */		panelType = "Detailed";		view = new KrDetailedView( splt, _left, krConfig );		view->init();		connect( dynamic_cast<KrDetailedView*>( view ), SIGNAL( middleButtonClicked( KrViewItem * ) ), SLOTS, SLOT( newTab( KrViewItem * ) ) );		connect( dynamic_cast<KrDetailedView*>( view ), SIGNAL( currentChanged( KrViewItem * ) ), 			SLOTS, SLOT( updatePopupPanel( KrViewItem * ) ) );		// connect quicksearch		connect( quickSearch, SIGNAL( textChanged( const QString& ) ),			dynamic_cast<KrDetailedView*>( view ), SLOT( quickSearch( const QString& ) ) );		connect( quickSearch, SIGNAL( otherMatching( const QString&, int ) ),			dynamic_cast<KrDetailedView*>( view ), SLOT( quickSearch( const QString& , int ) ) );		connect( quickSearch, SIGNAL( stop( QKeyEvent* ) ),			dynamic_cast<KrDetailedView*>( view ), SLOT( stopQuickSearch( QKeyEvent* ) ) );		connect( quickSearch, SIGNAL( process( QKeyEvent* ) ),			dynamic_cast<KrDetailedView*>( view ), SLOT( handleQuickSearchEvent( QKeyEvent* ) ) );	}   connect( view->op(), SIGNAL( renameItem( const QString &, const QString & ) ),            func, SLOT( rename( const QString &, const QString & ) ) );   connect( view->op(), SIGNAL( executed( QString& ) ), func, SLOT( execute( QString& ) ) );   connect( view->op(), SIGNAL( needFocus() ), this, SLOT( slotFocusOnMe() ) );   connect( view->op(), SIGNAL( selectionChanged() ), this, SLOT( slotUpdateTotals() ) );   connect( view->op(), SIGNAL( itemDescription( QString& ) ), krApp, SLOT( statusBarUpdate( QString& ) ) );   connect( view->op(), SIGNAL( contextMenu( const QPoint & ) ), this, SLOT( popRightClickMenu( const QPoint & ) ) );   connect( view->op(), SIGNAL( emptyContextMenu( const QPoint &) ),    	this, SLOT( popEmptyRightClickMenu( const QPoint & ) ) );   connect( view->op(), SIGNAL( letsDrag( QStringList, QPixmap ) ), this, SLOT( startDragging( QStringList, QPixmap ) ) );   connect( view->op(), SIGNAL( gotDrop( QDropEvent * ) ), this, SLOT( handleDropOnView( QDropEvent * ) ) );}void ListPanel::changeType( const QString & type ){   if( panelType != type )   {      panelType = type;      delete view;      createView();      slotStartUpdate();      if( panelType == "Brief" )         dynamic_cast<KrBriefView*>( view )->show();      else /* Detailed */         dynamic_cast<KrDetailedView*>( view )->show();   }}ListPanel::~ListPanel() {   delete func;   delete view;   delete status;   delete bookmarksButton;   delete totals;   delete quickSearch;   delete origin;   delete cdRootButton;   delete cdHomeButton;   delete cdUpButton;   delete cdOtherButton;   delete syncBrowseButton;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -