📄 synchronizergui.cpp
字号:
"M c #DCF6DB","N c #B4EAB0","O c #70D965","P c #2AC71B","Q c #68D85D","R c #CFF1CB","S c #DCEFDB","T c #589955","U c #0A212C","V c #467B92","W c #B6D9E8","X c #B6E2ED","Y c #69C7DC","Z c #19A2C5","` c #0796BC"," . c #13A5C5",".. c #59BBD7","+. c #6BC5DD","@. c #98D8E8","#. c #B4E2EE","$. c #A6DCE9","%. c #98CFDF","&. c #6DBCD4","*. c #74D46D","=. c #9DDF98","-. c #ABE8A5",";. c #B8EEB4",">. c #9EE797",",. c #74DD6A","'. c #62D758","). c #23C512","!. c #15BC07","~. c #27C519","{. c #73DC69","]. c #BAEDB6","^. c #B8E7B6","/. c #499145","(. c #061D28","_. c #125F7C",":. c #29A6C3","<. c #4BD4E3","[. c #4BC5DA","}. c #129FC4","|. c #0D95BC","1. c #0F90B7","2. c #16A2C5","3. c #0FA3C4","4. c #26A8C5","5. c #37A8C4","6. c #2DA9C7","7. c #75C1D9","8. c #71BED6","9. c #77D671","0. c #7BD874","a. c #3AC72C","b. c #42C437","c. c #34C526","d. c #1FC40F","e. c #24C516","f. c #1AB70E","g. c #1ABC0D","h. c #20C411","i. c #5AD94B","j. c #5DE24A","k. c #36C229","l. c #177B11","m. c #052837","n. c #0D617F","o. c #25ABC7","p. c #3BD0E1","q. c #1DC0D9","r. c #14A8CC","s. c #11A3C5","t. c #11ABCC","u. c #17AAC8","v. c #23ACC6","w. c #1FA8C0","x. c #1AAAC5","y. c #7CCDE1","z. c #76C4DB","A. c #7DDA75","B. c #84E07B","C. c #2BC519","D. c #2FBF1F","E. c #33C623","F. c #28C716","G. c #22CC11","H. c #20C511","I. c #23CC13","J. c #31D81C","K. c #4FE03B","L. c #34C725","M. c #137F0D","N. c #04151E","O. c #0D5672","P. c #1E99B8","Q. c #39CEDF","R. c #22C5DC","S. c #10A1C4","T. c #0E799B","U. c #0E5976","V. c #0D516D","W. c #0F4E6B","X. c #0F4D6A","Y. c #0F607D","Z. c #157C0E","`. c #126B0F"," + c #126A0E",".+ c #116C0C","++ c #13760E","@+ c #179A0E","#+ c #37DC22","$+ c #4DDF38","%+ c #2AB71D","&+ c #12720D","*+ c #062332","=+ c #0D506B","-+ c #209FBD",";+ c #33CBDF",">+ c #16ACC8",",+ c #0C4968","'+ c #061F2D",")+ c #031721","!+ c #041621","~+ c #051721","{+ c #021621","]+ c #031B27","^+ c #010C00","/+ c #28C715","(+ c #47DF32","_+ c #2DBD1F",":+ c #116B0D","<+ c #04121A","[+ c #0C4A62","}+ c #198AAD","|+ c #2291B2","1+ c #104564","2+ c #2CB122","3+ c #23AD18","4+ c #10620C","5+ c #051C26","6+ c #0F455C","7+ c #237191","8+ c #104363","9+ c #289023","0+ c #125B0E","a+ c #041F2B","b+ c #073347","c+ c #0D3C5A","d+ c #094706","e+ c #0D3A57"," "," "," . + @ # "," $ % & @ * @ "," = - ; > @ , ' @ "," ) ! ~ { ] @ ^ / ( @ "," _ : < [ } | 1 3 4 5 @ @ @ @ @ @ 6 7 8 9 @ "," 0 a b c d e f g i i j @ k l l k n o p q r s @ "," t u v w x y z A B E F G @ H I K M N O P Q R S T @ ","U V W X Y Z ` ...+.$.%.&.@ *.=.;.,.'.).!.~.{.].^./.@ ","(._.:.<.[.}.|.1.2.3.6.7.8.@ 9.0.b.d.e.f.g.h.i.j.k.l.@ "," m.n.o.p.q.r.s.t.u.x.y.z.@ A.B.D.F.G.H.I.J.K.L.M.@ "," N.O.P.Q.R.S.T.U.X.W.Y.@ Z.`.`.++@+d.#+$+%+&+@ "," *+=+-+;+>+,+'+~+{+]+^+@ @ @ @ @ /+(+_+:+@ "," <+[+}+|+1+ @ 2+3+4+@ "," 5+6+7+8+ @ 9+0+@ "," a+b+c+ @ d+@ "," . e+ @ @ "," "," "};class SynchronizerListView : public QListView{private: Synchronizer *synchronizer; bool isLeft; public: SynchronizerListView( Synchronizer * sync, QWidget * parent ) : QListView( parent ), synchronizer( sync ) { } void contentsMouseMoveEvent ( QMouseEvent * e ) { isLeft = (( e->state() & ShiftButton ) == 0 ); QListView::contentsMouseMoveEvent( e ); } void startDrag() { KURL::List urls; unsigned ndx = 0; SynchronizerFileItem *currentItem; while( ( currentItem = synchronizer->getItemAt( ndx++ ) ) != 0 ) { SynchronizerGUI::SyncViewItem *viewItem = (SynchronizerGUI::SyncViewItem *)currentItem->userData(); if( !viewItem || !viewItem->isSelected() || !viewItem->isVisible() ) continue; SynchronizerFileItem *item = viewItem->synchronizerItemRef(); if( item ) { if( isLeft && item->existsInLeft() ) { QString leftDirName = item->leftDirectory().isEmpty() ? "" : item->leftDirectory() + "/"; KURL leftURL = vfs::fromPathOrURL( synchronizer->leftBaseDirectory() + leftDirName + item->leftName() ); urls.push_back( leftURL ); } else if( !isLeft && item->existsInRight() ) { QString rightDirName = item->rightDirectory().isEmpty() ? "" : item->rightDirectory() + "/"; KURL rightURL = vfs::fromPathOrURL( synchronizer->rightBaseDirectory() + rightDirName + item->rightName() ); urls.push_back( rightURL ); } } } if( urls.count() == 0 ) return; KURLDrag *d = new KURLDrag(urls, this); d->setPixmap( FL_LOADICON( isLeft ? "2leftarrow" : "2rightarrow" ), QPoint( -7, 0 ) ); d->dragCopy(); }};SynchronizerGUI::SynchronizerGUI(QWidget* parent, KURL leftURL, KURL rightURL, QStringList selList ) : QDialog( parent, "Krusader::SynchronizerGUI", false, 0 ) { initGUI( parent, QString::null, leftURL, rightURL, selList );}SynchronizerGUI::SynchronizerGUI(QWidget* parent, QString profile ) : QDialog( parent, "Krusader::SynchronizerGUI", false, 0 ) { initGUI( parent, profile, KURL(), KURL(), QStringList() );}void SynchronizerGUI::initGUI(QWidget* /* parent */, QString profileName, KURL leftURL, KURL rightURL, QStringList selList) { selectedFiles = selList; isComparing = wasClosed = wasSync = false; firstResize = true; sizeX = sizeY = -1; hasSelectedFiles = ( selectedFiles.count() != 0 ); if( leftURL.isEmpty() ) leftURL = KURL("/"); if( rightURL.isEmpty() ) rightURL = KURL("/"); setCaption( i18n("Krusader::Synchronize Directories") ); QGridLayout *synchGrid = new QGridLayout( this ); synchGrid->setSpacing( 6 ); synchGrid->setMargin( 11 ); folderIcon = QPixmap( ( const char** ) folder_data ); fileIcon = QPixmap( ( const char** ) file_data ); synchronizerTabs = new QTabWidget( this, "synchronizerTabs" ); /* ============================== Compare groupbox ============================== */ QWidget *synchronizerTab = new QWidget( this, "syncronizerTab" ); QGridLayout *synchronizerGrid = new QGridLayout( synchronizerTab ); synchronizerGrid->setSpacing( 6 ); synchronizerGrid->setMargin( 11 ); QGroupBox *compareDirs = new QGroupBox( synchronizerTab, "SyncCompareDirectories" ); compareDirs->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed); compareDirs->setTitle( i18n( "Directory Comparison" ) ); compareDirs->setColumnLayout(0, Qt::Vertical ); compareDirs->layout()->setSpacing( 0 ); compareDirs->layout()->setMargin( 0 ); QGridLayout *grid = new QGridLayout( compareDirs->layout() ); grid->setSpacing( 6 ); grid->setMargin( 11 ); leftDirLabel = new QLabel( compareDirs, "leftDirLabel" ); leftDirLabel->setAlignment( Qt::AlignHCenter ); grid->addWidget( leftDirLabel, 0 ,0 ); QLabel *filterLabel = new QLabel( compareDirs, "filterLabel" ); filterLabel->setText( i18n( "File &Filter:" ) ); filterLabel->setAlignment( Qt::AlignHCenter ); grid->addWidget( filterLabel, 0 ,1 ); rightDirLabel = new QLabel( compareDirs, "rightDirLabel" ); rightDirLabel->setAlignment( Qt::AlignHCenter ); grid->addWidget( rightDirLabel, 0 ,2 ); krConfig->setGroup("Synchronize"); leftLocation = new KHistoryCombo(false, compareDirs, "SynchronizerHistoryLeft"); leftLocation->setMaxCount(25); // remember 25 items leftLocation->setDuplicatesEnabled( false ); leftLocation->setEditable( true ); leftLocation->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Fixed); QStringList list = krConfig->readListEntry("Left Directory History"); leftLocation->setHistoryItems(list); KURLRequester *leftUrlReq = new KURLRequester( leftLocation, compareDirs, "LeftDirectory" ); leftUrlReq->setURL( vfs::pathOrURL( leftURL ) ); leftUrlReq->setMode( KFile::Directory ); leftUrlReq->setMinimumWidth( 250 ); grid->addWidget( leftUrlReq, 1 ,0 ); QWhatsThis::add( leftLocation, i18n( "The left base directory used during the synchronisation process." ) ); leftUrlReq->setEnabled( !hasSelectedFiles ); leftLocation->setEnabled( !hasSelectedFiles ); leftDirLabel->setBuddy( leftLocation ); fileFilter = new KHistoryCombo(false, compareDirs, "SynchronizerFilter"); fileFilter->setMaxCount(25); // remember 25 items fileFilter->setDuplicatesEnabled( false ); fileFilter->setMinimumWidth( 100 ); fileFilter->setMaximumWidth( 100 ); fileFilter->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); list = krConfig->readListEntry("File Filter"); fileFilter->setHistoryItems(list); fileFilter->setEditText("*"); grid->addWidget( fileFilter, 1 ,1 ); filterLabel->setBuddy( fileFilter ); QString wtFilter = "<p><img src='toolbar|find'></p>" + i18n("<p>The filename filtering criteria is defined here.</p><p>You can make use of wildcards. Multiple patterns are separated by space (means logical OR) and patterns are excluded from the search using the pipe symbol.</p><p>If the pattern is ended with a slash (<code>*pattern*/</code>), that means that pattern relates to recursive search of directories.<ul><li><code>pattern</code> - means to search those files/directories that name is <code>pattern</code>, recursive search goes through all subdirectories independently of the value of <code>pattern</code></li><li><code>pattern/</code> - means to search all files/directories, but recursive search goes through/excludes the directories that name is <code>pattern</code></li></ul><p></p><p>It's allowed to use quotation marks for names that contain space. Filter <code>\"Program Files\"</code> searches out those files/directories that name is <code>Program Files</code>.</p><p>Examples:<ul><code><li>*.o</li><li>*.h *.c\?\?</li><li>*.cpp *.h | *.moc.cpp</li><li>* | CVS/ .svn/</li></code></ul><b>Note</b>: the search term '<code>text</code>' is equivalent to '<code>*text*</code>'.</p>"); QWhatsThis::add(fileFilter, wtFilter); QWhatsThis::add(filterLabel, wtFilter); rightLocation = new KHistoryCombo(compareDirs, "SynchronizerHistoryRight"); rightLocation->setMaxCount(25); // remember 25 items rightLocation->setDuplicatesEnabled( false ); rightLocation->setEditable( true ); rightLocation->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Fixed); list = krConfig->readListEntry("Right Directory History"); rightLocation->setHistoryItems(list); KURLRequester *rightUrlReq = new KURLRequester( rightLocation, compareDirs, "RightDirectory" ); rightUrlReq->setURL( vfs::pathOrURL( rightURL ) ); rightUrlReq->setMode( KFile::Directory ); rightUrlReq->setMinimumWidth( 250 ); grid->addWidget( rightUrlReq, 1 ,2 ); QWhatsThis::add( rightLocation, i18n( "The right base directory used during the synchronisation process." ) ); rightUrlReq->setEnabled( !hasSelectedFiles ); rightLocation->setEnabled( !hasSelectedFiles ); rightDirLabel->setBuddy( rightLocation ); QHBox *optionBox = new QHBox( compareDirs ); QGrid *optionGrid = new QGrid( 3, optionBox ); cbSubdirs = new QCheckBox( i18n( "Recurse subdirectories" ), optionGrid, "cbSubdirs" ); cbSubdirs->setChecked( krConfig->readBoolEntry( "Recurse Subdirectories", _RecurseSubdirs ) ); QWhatsThis::add( cbSubdirs, i18n( "Compare not only the base directories but their subdirectories as well." ) ); cbSymlinks = new QCheckBox( i18n( "Follow symlinks" ), optionGrid, "cbSymlinks" ); cbSymlinks->setChecked( krConfig->readBoolEntry( "Follow Symlinks", _FollowSymlinks ) ); cbSymlinks->setEnabled( cbSubdirs->isChecked() ); QWhatsThis::add( cbSymlinks, i18n( "Follow symbolic links during the compare process." ) ); cbByContent = new QCheckBox( i18n( "Compare by content" ), optionGrid, "cbByContent" ); cbByContent->setChecked( krConfig->readBoolEntry( "Compare By Content", _CompareByContent ) ); QWhatsThis::add( cbByContent, i18n( "Compare duplicated files with same size by content." ) ); cbIgnoreDate = new QCheckBox( i18n( "Ignore Date" ), optionGrid, "cbIgnoreDate" ); cbIgnoreDate->setChecked( krConfig->readBoolEntry( "Ignore Date", _IgnoreDate ) ); QWhatsThis::add( cbIgnoreDate, i18n( "<p>Ignore date information during the compare process.</p><p><b>Note</b>: useful if the files are located on network filesystems or in archives.</p>" ) ); cbAsymmetric = new QCheckBox( i18n( "Asymmetric" ), optionGrid, "cbAsymmetric" ); cbAsymmetric->setChecked( krConfig->readBoolEntry( "Asymmetric", _Asymmetric ) ); QWhatsThis::add( cbAsymmetric, i18n( "<p><b>Asymmetric mode</b></p><p>The left side is the destination, the right is the source directory. Files existing only in the left directory will be deleted, the other differing ones will be copied from right to left.</p><p><b>Note</b>: useful when updating a directory from a file server.</p>" ) ); cbIgnoreCase = new QCheckBox( i18n( "Ignore Case" ), optionGrid, "cbIgnoreCase" ); cbIgnoreCase->setChecked( krConfig->readBoolEntry( "Ignore Case", _IgnoreCase ) ); QWhatsThis::add( cbIgnoreCase, i18n( "<p>Case insensitive filename compare.</p><p><b>Note</b>: useful when synchronizing Windows filesystems.</p>" ) ); /* =========================== Show options groupbox ============================= */ QGroupBox *showOptions = new QGroupBox( optionBox, "SyncOptionBox" ); showOptions->setTitle( i18n( "S&how options" ) ); showOptions->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed); showOptions->setColumnLayout(0, Qt::Vertical ); showOptions->layout()->setSpacing( 0 ); showOptions->layout()->setMargin( 0 ); QGridLayout *showOptionsLayout = new QGridLayout( showOptions->layout() ); showOptionsLayout->setSpacing( 6 ); showOptionsLayout->setMargin( 11 ); QPixmap showLeftToRight( ( const char** ) right_arrow_button_data ); QPixmap showEquals ( ( const char** ) equals_button_data ); QPixmap showDifferents ( ( const char** ) differents_button_data ); QPixmap showRightToLeft( ( const char** ) left_arrow_button_data ); QPixmap showDeletable ( ( const char** ) trash_button_data ); btnLeftToRight = new QPushButton( showOptions, "btnLeftToRight" ); btnLeftToRight->setText( "" ); btnLeftToRight->setPixmap( showLeftToRight ); btnLeftToRight->setToggleButton( true ); btnLeftToRight->setOn( krConfig->readBoolEntry( "LeftToRight Button", _BtnLeftToRight ) ); btnLeftToRight->setAccel( CTRL + Key_L ); QWhatsThis::add( btnLeftToRight, i18n( "Show files marked to <i>Copy from left to right</i> (CTRL+L)." ) ); showOptionsLayout->addWidget( btnLeftToRight, 0, 0); btnEquals = new QPushButton( showOptions, "btnEquals" ); btnEquals->setText( "" ); btnEquals->setPixmap( showEquals ); btnEquals->setToggleButton( true ); btnEquals->setOn( krConfig->readBoolEntry( "Equals Button", _BtnEquals ) ); btnEquals->setAccel( CTRL + Key_E ); QWhatsThis::add( btnEquals, i18n( "Show files considered to be identical (CTRL+E)." ) ); showOptionsLayout->addWidget( btnEquals, 0, 1); btnDifferents = new QPushButton( showOptions, "btnDifferents" ); btnDifferents->setText( "" ); btnDifferents->setPixmap( showDifferents ); btnDifferents->setToggleButton( true ); btnDifferents->setOn( krConfig->readBoolEntry( "Differents Button", _BtnDifferents ) ); btnDifferents->setAccel( CTRL + Key_D ); QWhatsThis::add( btnDifferents, i18n( "Show excluded files (CTRL+D)." ) ); showOptionsLayout->addWidget( btnDifferents, 0, 2); btnRightToLeft = new QPushButton( showOptions, "btnRightToLeft" ); btnRightToLeft->setText( "" ); btnRightToLeft->setPixmap( showRightToLeft ); btnRightToLeft->setToggleButton( true ); btnRightToLeft->setOn( krConfig->readBoolEntry( "RightToLeft Button", _BtnRightToLeft ) ); btnRightToLeft->setAccel( CTRL + Key_R ); QWhatsThis::add( btnRightToLeft, i18n( "Show files marked to <i>Copy from right to left</i> (CTRL+R)." ) ); showOptionsLayout->addWidget( btnRightToLeft, 0, 3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -