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

📄 listpanel.cpp

📁 LINUX 下, 以 QT/KDE 写的档案管理员
💻 CPP
📖 第 1 页 / 共 3 页
字号:
void ListPanel::gotStats( const QString &mountPoint, unsigned long kBSize,                          unsigned long,  unsigned long kBAvail ) {	int perc = 0;	if (kBSize != 0) { // make sure that if totalsize==0, then perc=0		perc = (int)(((float)kBAvail / (float)kBSize)*100.0);	}	// mount point information - find it in the list first	KMountPoint::List lst = KMountPoint::currentMountPoints();	QString fstype = i18n("unknown");   for (KMountPoint::List::iterator it = lst.begin(); it != lst.end(); ++it) {		if ((*it)->mountPoint() == mountPoint) {			fstype = (*it)->mountType();			break;		}	}		QString stats = i18n( "%1 free out of %2 (%3%) on %4 [ (%5) ]" )        .arg( KIO::convertSizeFromKB( kBAvail ) )        .arg( KIO::convertSizeFromKB( kBSize ) ).arg( perc )        .arg( mountPoint ).arg( fstype );	status->setText( stats );}void ListPanel::handleDropOnTotals( QDropEvent *e ) {  handleDropOnView( e, totals );}void ListPanel::handleDropOnStatus( QDropEvent *e ) {  handleDropOnView( e, status );}void ListPanel::handleDropOnView( QDropEvent *e, QWidget *widget ) {   // if copyToPanel is true, then we call a simple vfs_addfiles   bool copyToDirInPanel = false;   bool dragFromOtherPanel = false;   bool dragFromThisPanel = false;   bool isWritable = func->files() ->vfs_isWritable();   vfs* tempFiles = func->files();   vfile *file;   KrViewItem *i = 0;   if( widget == 0 )   {      i = view->getKrViewItemAt( e->pos() );      widget = this;   }   if ( e->source() == otherPanel )      dragFromOtherPanel = true;   if ( e->source() == this )      dragFromThisPanel = true;   if ( i ) {      file = func->files() ->vfs_search( i->name() );      if ( !file ) { // trying to drop on the ".."            copyToDirInPanel = true;      } else {         if ( file->vfile_isDir() ) {            copyToDirInPanel = true;            isWritable = file->vfile_isWriteable();            if ( isWritable ) {               // keep the folder_open icon until we're finished, do it only               // if the folder is writeable, to avoid flicker            }         } else            if ( e->source() == this )               return ; // no dragging onto ourselves      }   } else    // if dragged from this panel onto an empty spot in the panel...      if ( dragFromThisPanel ) {  // leave!         e->ignore();         return ;      }   if ( !isWritable && getuid() != 0 ) {      e->ignore();      KMessageBox::sorry( 0, i18n( "Can't drop here, no write permissions." ) );      return ;   }   //////////////////////////////////////////////////////////////////////////////   // decode the data   KURL::List URLs;   if ( !KURLDrag::decode( e, URLs ) ) {      e->ignore(); // not for us to handle!      return ;   }   bool isLocal = true;   for( unsigned u = 0; u != URLs.count(); u++ )     if( !URLs[ u ].isLocalFile() ) {       isLocal = false;       break;     }   KIO::CopyJob::CopyMode mode = KIO::CopyJob::Copy;   // the KURL::List is finished, let's go   // --> display the COPY/MOVE/LINK menu   QPopupMenu popup( this );   popup.insertItem( i18n( "Copy Here" ), 1 );   if ( func->files() ->vfs_isWritable() )      popup.insertItem( i18n( "Move Here" ), 2 );   if ( func->files() ->vfs_getType() == vfs::NORMAL &&         isLocal )      popup.insertItem( i18n( "Link Here" ), 3 );   popup.insertItem( i18n( "Cancel" ), 4 );   QPoint tmp = widget->mapToGlobal( e->pos() );   int result = popup.exec( tmp );   switch ( result ) {         case 1 :         mode = KIO::CopyJob::Copy;         break;         case 2 :         mode = KIO::CopyJob::Move;         break;         case 3 :         mode = KIO::CopyJob::Link;         break;         case - 1 :         // user pressed outside the menu         case 4:         return ; // cancel was pressed;   }   QString dir = "";   if ( copyToDirInPanel ) {      dir = i->name();   }   QWidget *notify = ( !e->source() ? 0 : e->source() );   tempFiles->vfs_addFiles( &URLs, mode, notify, dir );}void ListPanel::startDragging( QStringList names, QPixmap px ) {   KURL::List * urls = func->files() ->vfs_getFiles( &names );   if ( urls->isEmpty() ) { // avoid draging empty urls      delete urls;      return ;   }	KURLDrag *d = new KURLDrag(*urls, this);   d->setPixmap( px, QPoint( -7, 0 ) );   d->dragCopy();   delete urls; // free memory}// pops a right-click menu for itemsvoid ListPanel::popRightClickMenu( const QPoint &loc ) {   // run it, on the mouse location   int j = QFontMetrics( font() ).height() * 2;   KrPopupMenu::run(QPoint( loc.x() + 5, loc.y() + j ), this);}void ListPanel::popEmptyRightClickMenu( const QPoint &loc ) {	KrPopupMenu::run(loc, this);}void ListPanel::setFilter( KrViewProperties::FilterSpec f ) {   switch ( f ) {         case KrViewProperties::All :         //case KrView::EXEC:         break;         case KrViewProperties::Custom :         filterMask = KRSpWidgets::getMask( i18n( " Select Files " ) );         // if the user canceled - quit         if ( filterMask.isNull() )            return;         view->setFilterMask( filterMask );         break;         default:         return ;   }   view->setFilter( f ); // do that in any case   func->files()->vfs_invalidate();   func->refresh();}QString ListPanel::getCurrentName() {   QString name = view->getCurrentItem();   if ( name != ".." )      return name;   else      return QString::null;}void ListPanel::prepareToDelete() {   view->setNameToMakeCurrent( view->firstUnmarkedBelowCurrent() );}void ListPanel::keyPressEvent( QKeyEvent *e ) {   switch ( e->key() ) {         case Key_Enter :         case Key_Return :         if ( e->state() & ControlButton ) {         	if (e->state() & AltButton) {         		vfile *vf = func->files()->vfs_search(view->getCurrentKrViewItem()->name());         		if (vf && vf->vfile_isDir()) SLOTS->newTab(vf->vfile_getUrl());         	} else {					SLOTS->insertFileName( ( e->state() & ShiftButton ) != 0 );            }         } else e->ignore();         break;         case Key_Right :         case Key_Left :         if ( e->state() == ControlButton ) {            // user pressed CTRL+Right/Left - refresh other panel to the selected path if it's a            // directory otherwise as this one            if ( ( _left && e->key() == Key_Right ) || ( !_left && e->key() == Key_Left ) ) {               KURL newPath;               KrViewItem *it = view->getCurrentKrViewItem();               if( it->name() == ".." ) {                  newPath = func->files()->vfs_getOrigin().upURL();               } else {                  vfile *v = func->getVFile( it );                  if ( v && v->vfile_isDir() && v->vfile_getName() != ".." ) {                     newPath = v->vfile_getUrl();                  } else {                     newPath = func->files() ->vfs_getOrigin();                  }               }               otherPanel->func->openUrl( newPath );            } else func->openUrl( otherPanel->func->files() ->vfs_getOrigin() );            return ;         } else            e->ignore();         break;         case Key_Down :         if ( e->state() == ControlButton ) { // give the keyboard focus to the command line            if ( MAIN_VIEW->cmdLine->isVisible() )               MAIN_VIEW->cmdLineFocus();            else                MAIN_VIEW->focusTerminalEmulator();            return ;         } else if ( e->state() == ( ControlButton | ShiftButton ) ) { // give the keyboard focus to TE           MAIN_VIEW->focusTerminalEmulator();         } else            e->ignore();         break;			case Key_Up :          if ( e->state() == ControlButton ) { // give the keyboard focus to the command line            origin->lineEdit()->setFocus();            return ;          } else             e->ignore();			break;         default:         // if we got this, it means that the view is not doing         // the quick search thing, so send the characters to the commandline, if normal key         if ( e->state() == NoButton )            MAIN_VIEW->cmdLine->addText( e->text() );         //e->ignore();   }}void ListPanel::slotItemAdded(vfile *vf) {	view->addItem(vf);}void ListPanel::slotItemDeleted(const QString& name) {	view->delItem(name);}void ListPanel::slotItemUpdated(vfile *vf) {	view->updateItem(vf);}void ListPanel::slotCleared() {	view->clear();}void ListPanel::showEvent( QShowEvent *e ) {  panelActive();  QWidget::showEvent(e);}void ListPanel::hideEvent( QHideEvent *e ) {  panelInactive();  QWidget::hideEvent(e);}void ListPanel::panelActive() {	// don't refresh when not active (ie: hidden, application isn't focussed ...)	func->files()->vfs_enableRefresh(true);}void ListPanel::panelInactive() {	func->files()->vfs_enableRefresh(false);}void ListPanel::slotJobStarted(KIO::Job* job) {	// disable the parts of the panel we don't want touched	//static_cast<KrDetailedView*>(view)->setEnabled(false);	status->setEnabled(false);	origin->setEnabled(false);	cdRootButton->setEnabled(false);   cdHomeButton->setEnabled(false);   cdUpButton->setEnabled(false);   cdOtherButton->setEnabled(false);	popupBtn->setEnabled(false);	popup->setEnabled(false);   bookmarksButton->setEnabled(false);   historyButton->setEnabled(false);   syncBrowseButton->setEnabled(false);	// connect to the job interface to provide in-panel refresh notification	connect( job, SIGNAL( infoMessage( KIO::Job*, const QString & ) ),		SLOT( inlineRefreshInfoMessage( KIO::Job*, const QString & ) ) );	connect( job, SIGNAL( percent( KIO::Job*, unsigned long ) ),      SLOT( inlineRefreshPercent( KIO::Job*, unsigned long ) ) );			connect(job,SIGNAL(result(KIO::Job*)),         this,SLOT(inlineRefreshListResult(KIO::Job*)));	connect(job,SIGNAL(canceled(KIO::Job*)),         this,SLOT(inlineRefreshListResult(KIO::Job*)));				inlineRefreshJob = job;		totals->setText(i18n(">> Reading..."));	inlineRefreshCancelButton->show();}void ListPanel::inlineRefreshCancel() {	if (inlineRefreshJob) {		inlineRefreshJob->kill(false);		inlineRefreshJob = 0;	}}void ListPanel::inlineRefreshPercent( KIO::Job*, unsigned long perc) {	QString msg = QString(">> %1: %2 % complete...").arg(i18n("Reading")).arg(perc);	totals->setText(msg);}void ListPanel::inlineRefreshInfoMessage( KIO::Job*, const QString &msg ) {	totals->setText(">> " + i18n("Reading: ") + msg);}void ListPanel::inlineRefreshListResult(KIO::Job*) {	inlineRefreshJob = 0;	// reenable everything	//static_cast<KrDetailedView*>(view)->setEnabled(true);	status->setEnabled(true);	origin->setEnabled(true);	cdRootButton->setEnabled(true);   cdHomeButton->setEnabled(true);   cdUpButton->setEnabled(true);   cdOtherButton->setEnabled(true);	popupBtn->setEnabled(true);	popup->setEnabled(true);   bookmarksButton->setEnabled(true);   historyButton->setEnabled(true);   syncBrowseButton->setEnabled(true);		inlineRefreshCancelButton->hide();}void ListPanel::jumpBack() {	func->openUrl( _jumpBackURL );}void ListPanel::setJumpBack( KURL url ) {	_jumpBackURL = url;}#include "listpanel.moc"

⌨️ 快捷键说明

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