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

📄 listpanel.cpp

📁 LINUX 下, 以 QT/KDE 写的档案管理员
💻 CPP
📖 第 1 页 / 共 3 页
字号:
   delete layout;}int ListPanel::getProperties(){   int props = 0;   if( syncBrowseButton->state() == SYNCBROWSE_CD )      props |= PROP_SYNC_BUTTON_ON;   return props;}void ListPanel::setProperties( int prop ){   if( prop & PROP_SYNC_BUTTON_ON )       syncBrowseButton->setOn( true );   else       syncBrowseButton->setOn( false );}bool ListPanel::eventFilter ( QObject * watched, QEvent * e ) {	if( e->type() == QEvent::KeyPress && origin->lineEdit() == watched ) {		QKeyEvent *ke = (QKeyEvent *)e;				if( ( ke->key() ==  Key_Down ) && ( ke->state() == ControlButton ) ) {			slotFocusOnMe();			return true;		}	}	return false;}void ListPanel::togglePanelPopup() {	if (popup->isHidden()) {		if (popupSizes.count() > 0) {			dynamic_cast<QSplitter*>(popup->parent())->setSizes(popupSizes);		} else { // on the first time, resize to 50%			QValueList<int> lst;			lst << height()/2 << height()/2;			dynamic_cast<QSplitter*>(popup->parent())->setSizes(lst);		}				popup->show();		popupBtn->setPixmap(krLoader->loadIcon("1downarrow", KIcon::Toolbar, 16));		QToolTip::add(  popupBtn, i18n( "Close the popup panel" ) );	} else {		popupSizes.clear();		popupSizes = dynamic_cast<QSplitter*>(popup->parent())->sizes();		popup->hide();		popupBtn->setPixmap(krLoader->loadIcon("1uparrow", KIcon::Toolbar, 16));		QToolTip::add(  popupBtn, i18n( "Open the popup panel" ) );				QValueList<int> lst;		lst << height() << 0;		dynamic_cast<QSplitter*>(popup->parent())->setSizes(lst);		if( ACTIVE_PANEL )			ACTIVE_PANEL->slotFocusOnMe();	}}KURL ListPanel::virtualPath() const {	return func->files()->vfs_getOrigin(); }QString ListPanel::realPath() const { 	return _realPath.path(); }void ListPanel::setPanelToolbar() {   krConfig->setGroup( "Look&Feel" );   bool panelToolBarVisible = krConfig->readBoolEntry( "Panel Toolbar visible", _PanelToolBar );   if ( panelToolBarVisible && ( krConfig->readBoolEntry( "Root Button Visible", _cdRoot ) ) )      cdRootButton->show();   else      cdRootButton->hide();   if ( panelToolBarVisible && ( krConfig->readBoolEntry( "Home Button Visible", _cdHome ) ) )      cdHomeButton->show();   else      cdHomeButton->hide();   if ( panelToolBarVisible && ( krConfig->readBoolEntry( "Up Button Visible", _cdUp ) ) )      cdUpButton->show();   else      cdUpButton->hide();   if ( panelToolBarVisible && ( krConfig->readBoolEntry( "Equal Button Visible", _cdOther ) ) )      cdOtherButton->show();   else      cdOtherButton->hide();   if ( !panelToolBarVisible || ( krConfig->readBoolEntry( "Open Button Visible", _Open ) ) )      origin->button() ->show();   else      origin->button() ->hide();   if ( panelToolBarVisible && ( krConfig->readBoolEntry( "SyncBrowse Button Visible", _syncBrowseButton ) ) )      syncBrowseButton->show();   else      syncBrowseButton->hide();}void ListPanel::slotUpdateTotals() {   totals->setText( view->statistics() );}void ListPanel::slotFocusAndCDOther() {   slotFocusOnMe();   func->openUrl( otherPanel->func->files() ->vfs_getOrigin() );}void ListPanel::slotFocusAndCDHome() {   slotFocusOnMe();   func->openUrl( QString( "~" ), QString::null );}void ListPanel::slotFocusAndCDup() {   slotFocusOnMe();   func->dirUp();}void ListPanel::slotFocusAndCDRoot() {   slotFocusOnMe();   func->openUrl( QString( "/" ), QString::null );}void ListPanel::select( KRQuery query, bool select) {   if ( !query.isNull() ) {      if ( select )         view->select( query );      else         view->unselect( query );   }}void ListPanel::select( bool select, bool all ) {   if ( all )   {      if ( select )         view->select( KRQuery( "*" ) );      else         view->unselect( KRQuery( "*" ) );   }   else {      KRQuery query = KRSpWidgets::getMask( ( select ? i18n( " Select Files " ) : i18n( " Unselect Files " ) ) );      // if the user canceled - quit      if ( query.isNull() )         return ;      if ( select )         view->select( query );      else         view->unselect( query );   }}void ListPanel::invertSelection() {   view->invertSelection();}void ListPanel::compareDirs() {   krConfig->setGroup( "Private" );   int compareMode = krConfig->readNumEntry( "Compare Mode", 0 );   krConfig->setGroup( "Look&Feel" );   bool selectDirs = krConfig->readBoolEntry( "Mark Dirs", false );     KrViewItem *item, *otherItem;     for( item = view->getFirst(); item != 0; item = view->getNext( item ) )   {      if( item->name() == ".." )         continue;            for( otherItem = otherPanel->view->getFirst(); otherItem != 0 && otherItem->name() != item->name() ;         otherItem = otherPanel->view->getNext( otherItem ) );                 bool isSingle = ( otherItem == 0 ), isDifferent = false, isNewer = false;         if( func->getVFile(item)->vfile_isDir() && !selectDirs )      {         item->setSelected( false );         continue;      }            if( otherItem )      {         if( !func->getVFile(item)->vfile_isDir() )            isDifferent = ITEM2VFILE(otherPanel,otherItem)->vfile_getSize() != func->getVFile(item)->vfile_getSize();         isNewer = func->getVFile(item)->vfile_getTime_t() > ITEM2VFILE(otherPanel, otherItem)->vfile_getTime_t();      }      switch( compareMode )      {      case 0:         item->setSelected( isNewer || isSingle );         break;      case 1:         item->setSelected( isNewer );         break;      case 2:         item->setSelected( isSingle );         break;      case 3:         item->setSelected( isDifferent || isSingle );         break;      case 4:         item->setSelected( isDifferent );         break;      }   }      view->updateView();}void ListPanel::slotFocusOnMe() {   // give this VFS the focus (the path bar)   // we start by calling the KVFS function   krConfig->setGroup( "Look&Feel" );   // take care of the 'otherpanel'   QPalette q( otherPanel->status->palette() );   q.setColor( QColorGroup::Foreground, KGlobalSettings::textColor() );   q.setColor( QColorGroup::Background, KGlobalSettings::baseColor() );   otherPanel->status->setPalette( q );   otherPanel->totals->setPalette( q );   otherPanel->view->prepareForPassive();   // now, take care of this panel   QPalette p( status->palette() );   p.setColor( QColorGroup::Foreground, KGlobalSettings::highlightedTextColor() );   p.setColor( QColorGroup::Background, KGlobalSettings::highlightColor() );   status->setPalette( p );   totals->setPalette( p );   view->prepareForActive();   emit cmdLineUpdate( realPath() );   emit activePanelChanged( this );   func->refreshActions();      Krusader::actDetailedView->setEnabled( panelType != "Detailed" ); // enable/disable the detailed view action   Krusader::actBriefView->setEnabled( panelType != "Brief" );       // enable/disable the brief view action   if( panelType == "Brief" )   {      KrBriefView * v = dynamic_cast<KrBriefView *>( view );      if ( v )         v->refreshColors();   }   else /* detailed */   {      KrDetailedView * v = dynamic_cast<KrDetailedView *>( view );      if ( v )         v->refreshColors();   }      if( otherPanel->panelType == "Brief" )   {      KrBriefView * v = dynamic_cast<KrBriefView *>( otherPanel->view );      if ( v )         v->refreshColors();   }   else /* detailed */   {         KrDetailedView *v = dynamic_cast<KrDetailedView *>( otherPanel->view );      if ( v )         v->refreshColors();   }}// this is used to start the panel, AFTER setOther() has been used//////////////////////////////////////////////////////////////////void ListPanel::start( KURL url, bool immediate ) {   KURL virt;      virt = url;      if ( !virt.isValid() )      virt = URL("/");   if( virt.isLocalFile() ) _realPath = virt;   else _realPath = URL("/");   if( immediate )     func->immediateOpenUrl( virt );   else     func->openUrl( virt );   slotFocusOnMe();   setJumpBack( virt );}void ListPanel::slotStartUpdate() {   while ( func->inRefresh )      ; // wait until the last refresh finish   func->inRefresh = true;  // make sure the next refresh wait for this one	if (inlineRefreshJob)		inlineRefreshListResult(0);	if( this == ACTIVE_PANEL ){		slotFocusOnMe();	}   setCursor( KCursor::workingCursor() );   view->clear();   if ( func->files() ->vfs_getType() == vfs::NORMAL )      _realPath = virtualPath();   this->origin->setURL( vfs::pathOrURL( virtualPath() ) );   emit pathChanged( this );   emit cmdLineUpdate( realPath() );	// update the command line   slotGetStats( virtualPath() );   slotUpdate();   if ( compareMode ) {      otherPanel->view->clear();      otherPanel->slotUpdate();   }   // return cursor to normal arrow   setCursor( KCursor::arrowCursor() );   slotUpdateTotals();	krApp->popularUrls->addUrl(virtualPath());}void ListPanel::slotUpdate() {   // if we are not at the root add the ".." entery   QString protocol = func->files() ->vfs_getOrigin().protocol();   bool isFtp = ( protocol == "ftp" || protocol == "smb" || protocol == "sftp" || protocol == "fish" );   QString origin = virtualPath().prettyURL(-1);   if ( origin.right( 1 ) != "/" && !( ( func->files() ->vfs_getType() == vfs::FTP ) && isFtp &&                                       origin.find( '/', origin.find( ":/" ) + 3 ) == -1 ) ) {      view->addItems( func->files() );   } else      view->addItems( func->files(), false );   func->inRefresh = false;}void ListPanel::slotGetStats( const KURL& url ) {   if ( !url.isLocalFile() ) {      status->setText( i18n( "No space information on non-local filesystems" ) );      return ;   }	// check for special filesystems;	QString path = url.path(); // must be local url	if ( path.left(4) == "/dev") {		status->setText(i18n( "No space information on [dev]" ));		return;	}#if defined(BSD)	if ( path.left( 5 ) == "/procfs" ) { // /procfs is a special case - no volume information		status->setText(i18n( "No space information on [procfs]" ));		return;	}#else	if ( path.left( 5 ) == "/proc" ) { // /proc is a special case - no volume information		status->setText(i18n( "No space information on [proc]" ));		return;	}#endif   status->setText( i18n( "Mt.Man: working ..." ) );	statsAgent = KDiskFreeSp::findUsageInfo( path );   connect( statsAgent, SIGNAL( foundMountPoint( const QString &, unsigned long, unsigned long, unsigned long ) ),            this, SLOT( gotStats( const QString &, unsigned long, unsigned long, unsigned long ) ) );}

⌨️ 快捷键说明

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