00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "katefileselector.h"
00023 #include "katefileselector.moc"
00024
00025 #include "katemainwindow.h"
00026 #include "kateviewmanager.h"
00027 #include "kbookmarkhandler.h"
00028
00029 #include "tdeactionselector.h"
00030
00031 #include <tqlayout.h>
00032 #include <tqtoolbutton.h>
00033 #include <tqhbox.h>
00034 #include <tqvbox.h>
00035 #include <tqlabel.h>
00036 #include <tqstrlist.h>
00037 #include <tqtooltip.h>
00038 #include <tqwhatsthis.h>
00039 #include <tqapplication.h>
00040 #include <tqlistbox.h>
00041 #include <tqscrollbar.h>
00042 #include <tqspinbox.h>
00043 #include <tqgroupbox.h>
00044 #include <tqcheckbox.h>
00045 #include <tqregexp.h>
00046 #include <tqdockarea.h>
00047 #include <tqtimer.h>
00048 #include <tqdir.h>
00049
00050 #include <tdeapplication.h>
00051 #include <kiconloader.h>
00052 #include <kurlcombobox.h>
00053 #include <kurlcompletion.h>
00054 #include <kprotocolinfo.h>
00055 #include <tdediroperator.h>
00056 #include <tdeconfig.h>
00057 #include <tdelocale.h>
00058 #include <kcombobox.h>
00059 #include <tdeaction.h>
00060 #include <tdemessagebox.h>
00061 #include <tdetoolbarbutton.h>
00062 #include <tqtoolbar.h>
00063 #include <tdepopupmenu.h>
00064 #include <kdialog.h>
00065 #include <kdebug.h>
00066
00067
00068
00069
00070 static void silenceQToolBar(TQtMsgType, const char *){}
00071
00072
00073 KateFileSelectorToolBar::KateFileSelectorToolBar(TQWidget *parent)
00074 : TDEToolBar( parent, "Kate FileSelector Toolbar", true )
00075 {
00076 setMinimumWidth(10);
00077 }
00078
00079 KateFileSelectorToolBar::~KateFileSelectorToolBar(){}
00080
00081 void KateFileSelectorToolBar::setMovingEnabled( bool)
00082 {
00083 TDEToolBar::setMovingEnabled(false);
00084 }
00085
00086
00087 KateFileSelectorToolBarParent::KateFileSelectorToolBarParent(TQWidget *parent)
00088 :TQFrame(parent),m_tb(0){}
00089 KateFileSelectorToolBarParent::~KateFileSelectorToolBarParent(){}
00090 void KateFileSelectorToolBarParent::setToolBar(KateFileSelectorToolBar *tb)
00091 {
00092 m_tb=tb;
00093 }
00094
00095 void KateFileSelectorToolBarParent::resizeEvent ( TQResizeEvent * )
00096 {
00097 if (m_tb)
00098 {
00099 setMinimumHeight(m_tb->sizeHint().height());
00100 m_tb->resize(width(),height());
00101 }
00102 }
00103
00104
00105
00106
00107 KateFileSelector::KateFileSelector( KateMainWindow *mainWindow,
00108 KateViewManager *viewManager,
00109 TQWidget * parent, const char * name )
00110 : TQVBox (parent, name),
00111 mainwin(mainWindow),
00112 viewmanager(viewManager)
00113 {
00114 mActionCollection = new TDEActionCollection( this );
00115
00116 TQtMsgHandler oldHandler = tqInstallMsgHandler( silenceQToolBar );
00117
00118 KateFileSelectorToolBarParent *tbp=new KateFileSelectorToolBarParent(this);
00119 toolbar = new KateFileSelectorToolBar(tbp);
00120 tbp->setToolBar(toolbar);
00121 toolbar->setMovingEnabled(false);
00122 toolbar->setFlat(true);
00123 tqInstallMsgHandler( oldHandler );
00124
00125 cmbPath = new KURLComboBox( KURLComboBox::Directories, true, this, "path combo" );
00126 cmbPath->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
00127 KURLCompletion* cmpl = new KURLCompletion(KURLCompletion::DirCompletion);
00128 cmbPath->setCompletionObject( cmpl );
00129 cmbPath->setAutoDeleteCompletionObject( true );
00130 cmbPath->listBox()->installEventFilter( this );
00131
00132 dir = new KDirOperator(KURL(), this, "operator");
00133 dir->setView(KFile::Detail);
00134 dir->view()->setSelectionMode(KFile::Extended);
00135 connect ( dir, TQT_SIGNAL( viewChanged(KFileView *) ),
00136 this, TQT_SLOT( selectorViewChanged(KFileView *) ) );
00137 setStretchFactor(dir, 2);
00138
00139 TDEActionCollection *coll = dir->actionCollection();
00140
00141 coll->action( "delete" )->setShortcut( TDEShortcut( ALT + Key_Delete ) );
00142 coll->action( "reload" )->setShortcut( TDEShortcut( ALT + Key_F5 ) );
00143 coll->action( "back" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Left ) );
00144 coll->action( "forward" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Right ) );
00145
00146 coll->action( "up" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Up ) );
00147 coll->action( "home" )->setShortcut( TDEShortcut( CTRL + ALT + Key_Home ) );
00148
00149
00150 TDEActionMenu *acmBookmarks = new TDEActionMenu( i18n("Bookmarks"), "bookmark",
00151 mActionCollection, "bookmarks" );
00152 acmBookmarks->setDelayed( false );
00153 bookmarkHandler = new KBookmarkHandler( this, acmBookmarks->popupMenu() );
00154 TQHBox* filterBox = new TQHBox(this);
00155
00156 btnFilter = new TQToolButton( filterBox );
00157 btnFilter->setIconSet( SmallIconSet("filter" ) );
00158 btnFilter->setToggleButton( true );
00159 filter = new KHistoryCombo( true, filterBox, "filter");
00160 filter->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
00161 filterBox->setStretchFactor(filter, 2);
00162 connect( btnFilter, TQT_SIGNAL( clicked() ), this, TQT_SLOT( btnFilterClick() ) );
00163
00164 connect( filter, TQT_SIGNAL( activated(const TQString&) ),
00165 TQT_SLOT( slotFilterChange(const TQString&) ) );
00166 connect( filter, TQT_SIGNAL( returnPressed(const TQString&) ),
00167 filter, TQT_SLOT( addToHistory(const TQString&) ) );
00168
00169
00170 acSyncDir = new TDEAction( i18n("Current Document Folder"), "curfiledir", 0,
00171 TQT_TQOBJECT(this), TQT_SLOT( setActiveDocumentDir() ), mActionCollection, "sync_dir" );
00172 toolbar->setIconText( TDEToolBar::IconOnly );
00173 toolbar->setIconSize( 16 );
00174 toolbar->setEnableContextMenu( false );
00175
00176 connect( cmbPath, TQT_SIGNAL( urlActivated( const KURL& )),
00177 this, TQT_SLOT( cmbPathActivated( const KURL& ) ));
00178 connect( cmbPath, TQT_SIGNAL( returnPressed( const TQString& )),
00179 this, TQT_SLOT( cmbPathReturnPressed( const TQString& ) ));
00180 connect(dir, TQT_SIGNAL(urlEntered(const KURL&)),
00181 this, TQT_SLOT(dirUrlEntered(const KURL&)) );
00182
00183 connect(dir, TQT_SIGNAL(finishedLoading()),
00184 this, TQT_SLOT(dirFinishedLoading()) );
00185
00186
00187 connect ( viewmanager, TQT_SIGNAL( viewChanged() ),
00188 this, TQT_SLOT( kateViewChanged() ) );
00189
00190
00191 connect( bookmarkHandler, TQT_SIGNAL( openURL( const TQString& )),
00192 this, TQT_SLOT( setDir( const TQString& ) ) );
00193
00194 waitingUrl = TQString::null;
00195
00196
00197 TQWhatsThis::add( cmbPath,
00198 i18n("<p>Here you can enter a path for a folder to display."
00199 "<p>To go to a folder previously entered, press the arrow on "
00200 "the right and choose one. <p>The entry has folder "
00201 "completion. Right-click to choose how completion should behave.") );
00202 TQWhatsThis::add( filter,
00203 i18n("<p>Here you can enter a name filter to limit which files are displayed."
00204 "<p>To clear the filter, toggle off the filter button to the left."
00205 "<p>To reapply the last filter used, toggle on the filter button." ) );
00206 TQWhatsThis::add( btnFilter,
00207 i18n("<p>This button clears the name filter when toggled off, or "
00208 "reapplies the last filter used when toggled on.") );
00209
00210 }
00211
00212 KateFileSelector::~KateFileSelector()
00213 {
00214 }
00215
00216
00217
00218
00219 void KateFileSelector::readConfig(TDEConfig *config, const TQString & name)
00220 {
00221 dir->setViewConfig( config, name + ":view" );
00222 dir->readConfig(config, name + ":dir");
00223 dir->setView( KFile::Default );
00224 dir->view()->setSelectionMode(KFile::Extended);
00225 config->setGroup( name );
00226
00227
00228 setupToolbar( config );
00229
00230 cmbPath->setMaxItems( config->readNumEntry( "pathcombo history len", 9 ) );
00231 cmbPath->setURLs( config->readPathListEntry( "dir history" ) );
00232
00233 if ( config->readBoolEntry( "restore location", true ) || kapp->isRestored() ) {
00234 TQString loc( config->readPathEntry( "location" ) );
00235 if ( ! loc.isEmpty() ) {
00236
00237
00238 setDir( loc );
00239 }
00240 }
00241
00242
00243
00244 filter->setMaxCount( config->readNumEntry( "filter history len", 9 ) );
00245 filter->setHistoryItems( config->readListEntry("filter history"), true );
00246 lastFilter = config->readEntry( "last filter" );
00247 TQString flt("");
00248 if ( config->readBoolEntry( "restore last filter", true ) || kapp->isRestored() )
00249 flt = config->readEntry("current filter");
00250 filter->lineEdit()->setText( flt );
00251 slotFilterChange( flt );
00252
00253 autoSyncEvents = config->readNumEntry( "AutoSyncEvents", 0 );
00254 }
00255
00256 void KateFileSelector::initialDirChangeHack()
00257 {
00258 setDir( waitingDir );
00259 }
00260
00261 void KateFileSelector::setupToolbar( TDEConfig *config )
00262 {
00263 toolbar->clear();
00264 TQStringList tbactions = config->readListEntry( "toolbar actions", ',' );
00265 if ( tbactions.isEmpty() ) {
00266
00267 tbactions << "up" << "back" << "forward" << "home" <<
00268 "short view" << "detailed view" <<
00269 "bookmarks" << "sync_dir";
00270 }
00271 TDEAction *ac;
00272 for ( TQStringList::Iterator it=tbactions.begin(); it != tbactions.end(); ++it ) {
00273 if ( *it == "bookmarks" || *it == "sync_dir" )
00274 ac = mActionCollection->action( (*it).latin1() );
00275 else
00276 ac = dir->actionCollection()->action( (*it).latin1() );
00277 if ( ac )
00278 ac->plug( toolbar );
00279 }
00280 }
00281
00282 void KateFileSelector::writeConfig(TDEConfig *config, const TQString & name)
00283 {
00284 dir->writeConfig(config,name + ":dir");
00285
00286 config->setGroup( name );
00287 config->writeEntry( "pathcombo history len", cmbPath->maxItems() );
00288 TQStringList l;
00289 for (int i = 0; i < cmbPath->count(); i++) {
00290 l.append( cmbPath->text( i ) );
00291 }
00292 config->writePathEntry( "dir history", l );
00293 config->writePathEntry( "location", cmbPath->currentText() );
00294
00295 config->writeEntry( "filter history len", filter->maxCount() );
00296 config->writeEntry( "filter history", filter->historyItems() );
00297 config->writeEntry( "current filter", filter->currentText() );
00298 config->writeEntry( "last filter", lastFilter );
00299 config->writeEntry( "AutoSyncEvents", autoSyncEvents );
00300 }
00301
00302 void KateFileSelector::setView(KFile::FileView view)
00303 {
00304 dir->setView(view);
00305 dir->view()->setSelectionMode(KFile::Extended);
00306 }
00307
00308
00309
00310
00311
00312 void KateFileSelector::slotFilterChange( const TQString & nf )
00313 {
00314 TQString f = nf.stripWhiteSpace();
00315 bool empty = f.isEmpty() || f == "*";
00316 TQToolTip::remove( btnFilter );
00317 if ( empty ) {
00318 dir->clearFilter();
00319 filter->lineEdit()->setText( TQString::null );
00320 TQToolTip::add( btnFilter,
00321 TQString( i18n("Apply last filter (\"%1\")") ).arg( lastFilter ) );
00322 }
00323 else {
00324 dir->setNameFilter( f );
00325 lastFilter = f;
00326 TQToolTip::add( btnFilter, i18n("Clear filter") );
00327 }
00328 btnFilter->setOn( !empty );
00329 dir->updateDir();
00330
00331 btnFilter->setEnabled( !( empty && lastFilter.isEmpty() ) );
00332
00333 }
00334
00335 bool kateFileSelectorIsReadable ( const KURL& url )
00336 {
00337 if ( !url.isLocalFile() )
00338 return true;
00339
00340 TQDir dir (url.path());
00341 return dir.exists ();
00342 }
00343
00344 void KateFileSelector::setDir( KURL u )
00345 {
00346 KURL newurl;
00347
00348 if ( !u.isValid() )
00349 newurl.setPath( TQDir::homeDirPath() );
00350 else
00351 newurl = u;
00352
00353 TQString pathstr = newurl.path(+1);
00354 newurl.setPath(pathstr);
00355
00356 if ( !kateFileSelectorIsReadable ( newurl ) )
00357 newurl.cd(TQString::fromLatin1(".."));
00358
00359 if ( !kateFileSelectorIsReadable (newurl) )
00360 newurl.setPath( TQDir::homeDirPath() );
00361
00362 dir->setURL(newurl, true);
00363 }
00364
00365
00366
00367
00368
00369 void KateFileSelector::cmbPathActivated( const KURL& u )
00370 {
00371 cmbPathReturnPressed( u.url() );
00372 }
00373
00374 void KateFileSelector::cmbPathReturnPressed( const TQString& u )
00375 {
00376 KURL typedURL( u );
00377 if ( typedURL.hasPass() )
00378 typedURL.setPass( TQString::null );
00379
00380 TQStringList urls = cmbPath->urls();
00381 urls.remove( typedURL.url() );
00382 urls.prepend( typedURL.url() );
00383 cmbPath->setURLs( urls, KURLComboBox::RemoveBottom );
00384 dir->setFocus();
00385 dir->setURL( KURL(u), true );
00386 }
00387
00388 void KateFileSelector::dirUrlEntered( const KURL& u )
00389 {
00390 cmbPath->setURL( u );
00391 }
00392
00393 void KateFileSelector::dirFinishedLoading()
00394 {
00395 }
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 void KateFileSelector::btnFilterClick()
00406 {
00407 if ( !btnFilter->isOn() ) {
00408 slotFilterChange( TQString::null );
00409 }
00410 else {
00411 filter->lineEdit()->setText( lastFilter );
00412 slotFilterChange( lastFilter );
00413 }
00414 }
00415
00416
00417 void KateFileSelector::setActiveDocumentDir()
00418 {
00419
00420 KURL u = mainwin->activeDocumentUrl();
00421
00422 if (!u.isEmpty())
00423 setDir( u.upURL() );
00424
00425 }
00426
00427 void KateFileSelector::kateViewChanged()
00428 {
00429 if ( autoSyncEvents & DocumentChanged )
00430 {
00431
00432
00433 if ( isVisible() ) {
00434 setActiveDocumentDir();
00435 waitingUrl = TQString::null;
00436 }
00437
00438 else {
00439 KURL u = mainwin->activeDocumentUrl();
00440 if (!u.isEmpty())
00441 waitingUrl = u.directory();
00442 }
00443 }
00444
00445
00446
00447 acSyncDir->setEnabled( ! mainwin->activeDocumentUrl().directory().isEmpty() );
00448 }
00449
00450 void KateFileSelector::selectorViewChanged( KFileView * newView )
00451 {
00452 newView->setSelectionMode(KFile::Extended);
00453 }
00454
00455
00456
00457
00458
00459 void KateFileSelector::focusInEvent( TQFocusEvent * )
00460 {
00461 dir->setFocus();
00462 }
00463
00464 void KateFileSelector::showEvent( TQShowEvent * )
00465 {
00466
00467 if ( autoSyncEvents & GotVisible ) {
00468
00469 setActiveDocumentDir();
00470 waitingUrl = TQString::null;
00471 }
00472
00473 else if ( ! waitingUrl.isEmpty() ) {
00474 setDir( waitingUrl );
00475 waitingUrl = TQString::null;
00476 }
00477 }
00478
00479 bool KateFileSelector::eventFilter( TQObject* o, TQEvent *e )
00480 {
00481
00482
00483
00484
00485
00486
00487
00488 TQListBox *lb = cmbPath->listBox();
00489 if ( TQT_BASE_OBJECT(o) == TQT_BASE_OBJECT(lb) && e->type() == TQEvent::Show ) {
00490 int add = lb->height() < lb->contentsHeight() ? lb->verticalScrollBar()->width() : 0;
00491 int w = TQMIN( mainwin->width(), lb->contentsWidth() + add );
00492 lb->resize( w, lb->height() );
00493
00494
00495
00496 }
00497
00498 return TQWidget::eventFilter( o, e );
00499 }
00500
00501
00502
00503
00504
00505
00506
00507
00508 class ActionLBItem : public TQListBoxPixmap {
00509 public:
00510 ActionLBItem( TQListBox *lb=0,
00511 const TQPixmap &pm = TQPixmap(),
00512 const TQString &text=TQString::null,
00513 const TQString &str=TQString::null ) :
00514 TQListBoxPixmap( lb, pm, text ),
00515 _str(str) {};
00516 TQString idstring() { return _str; };
00517 private:
00518 TQString _str;
00519 };
00520
00521
00522
00524
00526 KFSConfigPage::KFSConfigPage( TQWidget *parent, const char *name, KateFileSelector *kfs )
00527 : Kate::ConfigPage( parent, name ),
00528 fileSelector( kfs ),
00529 m_changed( false )
00530 {
00531 TQVBoxLayout *lo = new TQVBoxLayout( this );
00532 int spacing = KDialog::spacingHint();
00533 lo->setSpacing( spacing );
00534
00535
00536 TQGroupBox *gbToolbar = new TQGroupBox( 1, Qt::Vertical, i18n("Toolbar"), this );
00537 acSel = new TDEActionSelector( gbToolbar );
00538 acSel->setAvailableLabel( i18n("A&vailable actions:") );
00539 acSel->setSelectedLabel( i18n("S&elected actions:") );
00540 lo->addWidget( gbToolbar );
00541 connect( acSel, TQT_SIGNAL( added( TQListBoxItem * ) ), this, TQT_SLOT( slotMyChanged() ) );
00542 connect( acSel, TQT_SIGNAL( removed( TQListBoxItem * ) ), this, TQT_SLOT( slotMyChanged() ) );
00543 connect( acSel, TQT_SIGNAL( movedUp( TQListBoxItem * ) ), this, TQT_SLOT( slotMyChanged() ) );
00544 connect( acSel, TQT_SIGNAL( movedDown( TQListBoxItem * ) ), this, TQT_SLOT( slotMyChanged() ) );
00545
00546
00547 TQGroupBox *gbSync = new TQGroupBox( 1, Qt::Horizontal, i18n("Auto Synchronization"), this );
00548 cbSyncActive = new TQCheckBox( i18n("When a docu&ment becomes active"), gbSync );
00549 cbSyncShow = new TQCheckBox( i18n("When the file selector becomes visible"), gbSync );
00550 lo->addWidget( gbSync );
00551 connect( cbSyncActive, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotMyChanged() ) );
00552 connect( cbSyncShow, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotMyChanged() ) );
00553
00554
00555 TQHBox *hbPathHist = new TQHBox ( this );
00556 TQLabel *lbPathHist = new TQLabel( i18n("Remember &locations:"), hbPathHist );
00557 sbPathHistLength = new TQSpinBox( hbPathHist );
00558 lbPathHist->setBuddy( sbPathHistLength );
00559 lo->addWidget( hbPathHist );
00560 connect( sbPathHistLength, TQT_SIGNAL( valueChanged ( int ) ), this, TQT_SLOT( slotMyChanged() ) );
00561
00562 TQHBox *hbFilterHist = new TQHBox ( this );
00563 TQLabel *lbFilterHist = new TQLabel( i18n("Remember &filters:"), hbFilterHist );
00564 sbFilterHistLength = new TQSpinBox( hbFilterHist );
00565 lbFilterHist->setBuddy( sbFilterHistLength );
00566 lo->addWidget( hbFilterHist );
00567 connect( sbFilterHistLength, TQT_SIGNAL( valueChanged ( int ) ), this, TQT_SLOT( slotMyChanged() ) );
00568
00569
00570 TQGroupBox *gbSession = new TQGroupBox( 1, Qt::Horizontal, i18n("Session"), this );
00571 cbSesLocation = new TQCheckBox( i18n("Restore loca&tion"), gbSession );
00572 cbSesFilter = new TQCheckBox( i18n("Restore last f&ilter"), gbSession );
00573 lo->addWidget( gbSession );
00574 connect( cbSesLocation, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotMyChanged() ) );
00575 connect( cbSesFilter, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotMyChanged() ) );
00576
00577
00578 lo->addStretch( 1 );
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 TQString lhwt( i18n(
00592 "<p>Decides how many locations to keep in the history of the location "
00593 "combo box.") );
00594 TQWhatsThis::add( lbPathHist, lhwt );
00595 TQWhatsThis::add( sbPathHistLength, lhwt );
00596 TQString fhwt( i18n(
00597 "<p>Decides how many filters to keep in the history of the filter "
00598 "combo box.") );
00599 TQWhatsThis::add( lbFilterHist, fhwt );
00600 TQWhatsThis::add( sbFilterHistLength, fhwt );
00601 TQString synwt( i18n(
00602 "<p>These options allow you to have the File Selector automatically "
00603 "change location to the folder of the active document on certain "
00604 "events."
00605 "<p>Auto synchronization is <em>lazy</em>, meaning it will not take "
00606 "effect until the file selector is visible."
00607 "<p>None of these are enabled by default, but you can always sync the "
00608 "location by pressing the sync button in the toolbar.") );
00609 TQWhatsThis::add( gbSync, synwt );
00610 TQWhatsThis::add( cbSesLocation, i18n(
00611 "<p>If this option is enabled (default), the location will be restored "
00612 "when you start Kate.<p><strong>Note</strong> that if the session is "
00613 "handled by the TDE session manager, the location is always restored.") );
00614 TQWhatsThis::add( cbSesFilter, i18n(
00615 "<p>If this option is enabled (default), the current filter will be "
00616 "restored when you start Kate.<p><strong>Note</strong> that if the "
00617 "session is handled by the TDE session manager, the filter is always "
00618 "restored."
00619 "<p><strong>Note</strong> that some of the autosync settings may "
00620 "override the restored location if on.") );
00621
00622 init();
00623
00624 }
00625
00626 void KFSConfigPage::apply()
00627 {
00628 if ( ! m_changed )
00629 return;
00630
00631 m_changed = false;
00632
00633 TDEConfig *config = kapp->config();
00634 config->setGroup( "fileselector" );
00635
00636 TQStringList l;
00637 TQListBoxItem *item = acSel->selectedListBox()->firstItem();
00638 ActionLBItem *aItem;
00639 while ( item )
00640 {
00641 aItem = (ActionLBItem*)item;
00642 if ( aItem )
00643 {
00644 l << aItem->idstring();
00645 }
00646 item = item->next();
00647 }
00648 config->writeEntry( "toolbar actions", l );
00649 fileSelector->setupToolbar( config );
00650
00651 int s = 0;
00652 if ( cbSyncActive->isChecked() )
00653 s |= KateFileSelector::DocumentChanged;
00654 if ( cbSyncShow->isChecked() )
00655 s |= KateFileSelector::GotVisible;
00656 fileSelector->autoSyncEvents = s;
00657
00658
00659 fileSelector->cmbPath->setMaxItems( sbPathHistLength->value() );
00660 fileSelector->filter->setMaxCount( sbFilterHistLength->value() );
00661
00662
00663 config->writeEntry( "restore location", cbSesLocation->isChecked() );
00664 config->writeEntry( "restore last filter", cbSesFilter->isChecked() );
00665 }
00666
00667 void KFSConfigPage::reload()
00668 {
00669
00670 init();
00671 m_changed = false;
00672 }
00673 void KFSConfigPage::init()
00674 {
00675 TDEConfig *config = kapp->config();
00676 config->setGroup( "fileselector" );
00677
00678 TQStringList l = config->readListEntry( "toolbar actions", ',' );
00679 if ( l.isEmpty() )
00680 l << "up" << "back" << "forward" << "home" <<
00681 "short view" << "detailed view" <<
00682 "bookmarks" << "sync_dir";
00683
00684
00685 TQStringList allActions;
00686 allActions << "up" << "back" << "forward" << "home" <<
00687 "reload" << "mkdir" << "delete" <<
00688 "short view" << "detailed view"
00689 <<
00690 "bookmarks" << "sync_dir";
00691 TQRegExp re("&(?=[^&])");
00692 TDEAction *ac;
00693 TQListBox *lb;
00694 for ( TQStringList::Iterator it=allActions.begin(); it != allActions.end(); ++it ) {
00695 lb = l.contains( *it ) ? acSel->selectedListBox() : acSel->availableListBox();
00696 if ( *it == "bookmarks" || *it == "sync_dir" )
00697 ac = fileSelector->actionCollection()->action( (*it).latin1() );
00698 else
00699 ac = fileSelector->dirOperator()->actionCollection()->action( (*it).latin1() );
00700 if ( ac )
00701 new ActionLBItem( lb, SmallIcon( ac->icon() ), ac->text().replace( re, "" ), *it );
00702 }
00703
00704
00705 int s = fileSelector->autoSyncEvents;
00706 cbSyncActive->setChecked( s & KateFileSelector::DocumentChanged );
00707 cbSyncShow->setChecked( s & KateFileSelector::GotVisible );
00708
00709 sbPathHistLength->setValue( fileSelector->cmbPath->maxItems() );
00710 sbFilterHistLength->setValue( fileSelector->filter->maxCount() );
00711
00712 cbSesLocation->setChecked( config->readBoolEntry( "restore location", true ) );
00713 cbSesFilter->setChecked( config->readBoolEntry( "restore last filter", true ) );
00714 }
00715
00716 void KFSConfigPage::slotMyChanged()
00717 {
00718 m_changed = true;
00719 slotChanged();
00720 }
00721
00722