• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kate
 

kate

  • kate
  • app
katefileselector.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org>
3 Copyright (C) 2001 Joseph Wenninger <jowenn@kde.org>
4 Copyright (C) 2001 Anders Lund <anders.lund@lund.tdcadsl.dk>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21//BEGIN Includes
22#include "katefileselector.h"
23#include "katefileselector.moc"
24
25#include "katemainwindow.h"
26#include "kateviewmanager.h"
27#include "kbookmarkhandler.h"
28
29#include "tdeactionselector.h"
30
31#include <tqlayout.h>
32#include <tqtoolbutton.h>
33#include <tqhbox.h>
34#include <tqvbox.h>
35#include <tqlabel.h>
36#include <tqstrlist.h>
37#include <tqtooltip.h>
38#include <tqwhatsthis.h>
39#include <tqapplication.h>
40#include <tqlistbox.h>
41#include <tqscrollbar.h>
42#include <tqspinbox.h>
43#include <tqgroupbox.h>
44#include <tqcheckbox.h>
45#include <tqregexp.h>
46#include <tqdockarea.h>
47#include <tqtimer.h>
48#include <tqdir.h>
49
50#include <tdeapplication.h>
51#include <kiconloader.h>
52#include <kurlcombobox.h>
53#include <kurlcompletion.h>
54#include <kprotocolinfo.h>
55#include <tdediroperator.h>
56#include <tdeconfig.h>
57#include <tdelocale.h>
58#include <kcombobox.h>
59#include <tdeaction.h>
60#include <tdemessagebox.h>
61#include <tdetoolbarbutton.h>
62#include <tqtoolbar.h>
63#include <tdepopupmenu.h>
64#include <kdialog.h>
65#include <kdebug.h>
66//END Includes
67
68//BEGIN Toolbar
69 // from tdefiledialog.cpp - avoid qt warning in STDERR (~/.xsessionerrors)
70static void silenceQToolBar(TQtMsgType, const char *){}
71
72// helper classes to be able to have a toolbar without move handle
73KateFileSelectorToolBar::KateFileSelectorToolBar(TQWidget *parent)
74 : TDEToolBar( parent, "Kate FileSelector Toolbar", true )
75{
76 setMinimumWidth(10);
77}
78
79KateFileSelectorToolBar::~KateFileSelectorToolBar(){}
80
81void KateFileSelectorToolBar::setMovingEnabled( bool)
82{
83 TDEToolBar::setMovingEnabled(false);
84}
85
86
87KateFileSelectorToolBarParent::KateFileSelectorToolBarParent(TQWidget *parent)
88 :TQFrame(parent),m_tb(0){}
89KateFileSelectorToolBarParent::~KateFileSelectorToolBarParent(){}
90void KateFileSelectorToolBarParent::setToolBar(KateFileSelectorToolBar *tb)
91{
92 m_tb=tb;
93}
94
95void KateFileSelectorToolBarParent::resizeEvent ( TQResizeEvent * )
96{
97 if (m_tb)
98 {
99 setMinimumHeight(m_tb->sizeHint().height());
100 m_tb->resize(width(),height());
101 }
102}
103//END
104
105//BEGIN Constructor/destructor
106
107KateFileSelector::KateFileSelector( KateMainWindow *mainWindow,
108 KateViewManager *viewManager,
109 TQWidget * parent, const char * name )
110 : TQVBox (parent, name),
111 mainwin(mainWindow),
112 viewmanager(viewManager)
113{
114 mActionCollection = new TDEActionCollection( this );
115
116 TQtMsgHandler oldHandler = qInstallMsgHandler( silenceQToolBar );
117
118 KateFileSelectorToolBarParent *tbp=new KateFileSelectorToolBarParent(this);
119 toolbar = new KateFileSelectorToolBar(tbp);
120 tbp->setToolBar(toolbar);
121 toolbar->setMovingEnabled(false);
122 toolbar->setFlat(true);
123 qInstallMsgHandler( oldHandler );
124
125 cmbPath = new KURLComboBox( KURLComboBox::Directories, true, this, "path combo" );
126 cmbPath->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
127 KURLCompletion* cmpl = new KURLCompletion(KURLCompletion::DirCompletion);
128 cmbPath->setCompletionObject( cmpl );
129 cmbPath->setAutoDeleteCompletionObject( true );
130 cmbPath->listBox()->installEventFilter( this );
131
132 dir = new KDirOperator(KURL(), this, "operator");
133 dir->setView(KFile::/* Simple */Detail);
134 dir->view()->setSelectionMode(KFile::Extended);
135 connect ( dir, TQ_SIGNAL( viewChanged(KFileView *) ),
136 this, TQ_SLOT( selectorViewChanged(KFileView *) ) );
137 setStretchFactor(dir, 2);
138
139 TDEActionCollection *coll = dir->actionCollection();
140 // some shortcuts of diroperator that clashes with Kate
141 coll->action( "delete" )->setShortcut( TDEShortcut( ALT + Key_Delete ) );
142 coll->action( "reload" )->setShortcut( TDEShortcut( ALT + Key_F5 ) );
143 coll->action( "back" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Left ) );
144 coll->action( "forward" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Right ) );
145 // some consistency - reset up for dir too
146 coll->action( "up" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Up ) );
147 coll->action( "home" )->setShortcut( TDEShortcut( CTRL + ALT + Key_Home ) );
148
149 // bookmarks action!
150 TDEActionMenu *acmBookmarks = new TDEActionMenu( i18n("Bookmarks"), "bookmark",
151 mActionCollection, "bookmarks" );
152 acmBookmarks->setDelayed( false );
153 bookmarkHandler = new KBookmarkHandler( this, acmBookmarks->popupMenu() );
154 TQHBox* filterBox = new TQHBox(this);
155
156 btnFilter = new TQToolButton( filterBox );
157 btnFilter->setIconSet( SmallIconSet("filter" ) );
158 btnFilter->setToggleButton( true );
159 filter = new KHistoryCombo( true, filterBox, "filter");
160 filter->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
161 filterBox->setStretchFactor(filter, 2);
162 connect( btnFilter, TQ_SIGNAL( clicked() ), this, TQ_SLOT( btnFilterClick() ) );
163
164 connect( filter, TQ_SIGNAL( activated(const TQString&) ),
165 TQ_SLOT( slotFilterChange(const TQString&) ) );
166 connect( filter, TQ_SIGNAL( returnPressed(const TQString&) ),
167 filter, TQ_SLOT( addToHistory(const TQString&) ) );
168
169 // tdeaction for the dir sync method
170 acSyncDir = new TDEAction( i18n("Current Document Folder"), "curfiledir", 0,
171 this, TQ_SLOT( setActiveDocumentDir() ), mActionCollection, "sync_dir" );
172 toolbar->setIconText( TDEToolBar::IconOnly );
173 toolbar->setIconSize( 16 );
174 toolbar->setEnableContextMenu( false );
175
176 connect( cmbPath, TQ_SIGNAL( urlActivated( const KURL& )),
177 this, TQ_SLOT( cmbPathActivated( const KURL& ) ));
178 connect( cmbPath, TQ_SIGNAL( returnPressed( const TQString& )),
179 this, TQ_SLOT( cmbPathReturnPressed( const TQString& ) ));
180 connect(dir, TQ_SIGNAL(urlEntered(const KURL&)),
181 this, TQ_SLOT(dirUrlEntered(const KURL&)) );
182
183 connect(dir, TQ_SIGNAL(finishedLoading()),
184 this, TQ_SLOT(dirFinishedLoading()) );
185
186 // enable dir sync button if current doc has a valid URL
187 connect ( viewmanager, TQ_SIGNAL( viewChanged() ),
188 this, TQ_SLOT( kateViewChanged() ) );
189
190 // Connect the bookmark handler
191 connect( bookmarkHandler, TQ_SIGNAL( openURL( const TQString& )),
192 this, TQ_SLOT( setDir( const TQString& ) ) );
193
194 waitingUrl = TQString::null;
195
196 // whatsthis help
197 TQWhatsThis::add( cmbPath,
198 i18n("<p>Here you can enter a path for a folder to display."
199 "<p>To go to a folder previously entered, press the arrow on "
200 "the right and choose one. <p>The entry has folder "
201 "completion. Right-click to choose how completion should behave.") );
202 TQWhatsThis::add( filter,
203 i18n("<p>Here you can enter a name filter to limit which files are displayed."
204 "<p>To clear the filter, toggle off the filter button to the left."
205 "<p>To reapply the last filter used, toggle on the filter button." ) );
206 TQWhatsThis::add( btnFilter,
207 i18n("<p>This button clears the name filter when toggled off, or "
208 "reapplies the last filter used when toggled on.") );
209
210}
211
212KateFileSelector::~KateFileSelector()
213{
214}
215//END Constroctor/Destrctor
216
217//BEGIN Public Methods
218
219void KateFileSelector::readConfig(TDEConfig *config, const TQString & name)
220{
221 dir->setViewConfig( config, name + ":view" );
222 dir->readConfig(config, name + ":dir");
223 dir->setView( KFile::Default );
224 dir->view()->setSelectionMode(KFile::Extended);
225 config->setGroup( name );
226
227 // set up the toolbar
228 setupToolbar( config );
229
230 cmbPath->setMaxItems( config->readNumEntry( "pathcombo history len", 9 ) );
231 cmbPath->setURLs( config->readPathListEntry( "dir history" ) );
232 // if we restore history
233 if ( config->readBoolEntry( "restore location", true ) || tdeApp->isRestored() ) {
234 TQString loc( config->readPathEntry( "location" ) );
235 if ( ! loc.isEmpty() ) {
236// waitingDir = loc;
237// TQTimer::singleShot(0, this, TQ_SLOT(initialDirChangeHack()));
238 setDir( loc );
239 }
240 }
241
242 // else is automatic, as cmpPath->setURL is called when a location is entered.
243
244 filter->setMaxCount( config->readNumEntry( "filter history len", 9 ) );
245 filter->setHistoryItems( config->readListEntry("filter history"), true );
246 lastFilter = config->readEntry( "last filter" );
247 TQString flt("");
248 if ( config->readBoolEntry( "restore last filter", true ) || tdeApp->isRestored() )
249 flt = config->readEntry("current filter");
250 filter->lineEdit()->setText( flt );
251 slotFilterChange( flt );
252
253 autoSyncEvents = config->readNumEntry( "AutoSyncEvents", 0 );
254}
255
256void KateFileSelector::initialDirChangeHack()
257{
258 setDir( waitingDir );
259}
260
261void KateFileSelector::setupToolbar( TDEConfig *config )
262{
263 toolbar->clear();
264 TQStringList tbactions = config->readListEntry( "toolbar actions", ',' );
265 if ( tbactions.isEmpty() ) {
266 // reasonable collection for default toolbar
267 tbactions << "up" << "back" << "forward" << "home" <<
268 "short view" << "detailed view" <<
269 "bookmarks" << "sync_dir";
270 }
271 TDEAction *ac;
272 for ( TQStringList::Iterator it=tbactions.begin(); it != tbactions.end(); ++it ) {
273 if ( *it == "bookmarks" || *it == "sync_dir" )
274 ac = mActionCollection->action( (*it).latin1() );
275 else
276 ac = dir->actionCollection()->action( (*it).latin1() );
277 if ( ac )
278 ac->plug( toolbar );
279 }
280}
281
282void KateFileSelector::writeConfig(TDEConfig *config, const TQString & name)
283{
284 dir->writeConfig(config,name + ":dir");
285
286 config->setGroup( name );
287 config->writeEntry( "pathcombo history len", cmbPath->maxItems() );
288 TQStringList l;
289 for (int i = 0; i < cmbPath->count(); i++) {
290 l.append( cmbPath->text( i ) );
291 }
292 config->writePathEntry( "dir history", l );
293 config->writePathEntry( "location", cmbPath->currentText() );
294
295 config->writeEntry( "filter history len", filter->maxCount() );
296 config->writeEntry( "filter history", filter->historyItems() );
297 config->writeEntry( "current filter", filter->currentText() );
298 config->writeEntry( "last filter", lastFilter );
299 config->writeEntry( "AutoSyncEvents", autoSyncEvents );
300}
301
302void KateFileSelector::setView(KFile::FileView view)
303{
304 dir->setView(view);
305 dir->view()->setSelectionMode(KFile::Extended);
306}
307
308//END Public Methods
309
310//BEGIN Public Slots
311
312void KateFileSelector::slotFilterChange( const TQString & nf )
313{
314 TQString f = nf.stripWhiteSpace();
315 bool empty = f.isEmpty() || f == "*";
316 TQToolTip::remove( btnFilter );
317 if ( empty ) {
318 dir->clearFilter();
319 filter->lineEdit()->setText( TQString::null );
320 TQToolTip::add( btnFilter,
321 TQString( i18n("Apply last filter (\"%1\")") ).arg( lastFilter ) );
322 }
323 else {
324 dir->setNameFilter( f );
325 lastFilter = f;
326 TQToolTip::add( btnFilter, i18n("Clear filter") );
327 }
328 btnFilter->setOn( !empty );
329 dir->updateDir();
330 // this will be never true after the filter has been used;)
331 btnFilter->setEnabled( !( empty && lastFilter.isEmpty() ) );
332
333}
334
335bool kateFileSelectorIsReadable ( const KURL& url )
336{
337 if ( !url.isLocalFile() )
338 return true; // what else can we say?
339
340 TQDir dir (url.path());
341 return dir.exists ();
342}
343
344void KateFileSelector::setDir( KURL u )
345{
346 KURL newurl;
347
348 if ( !u.isValid() )
349 newurl.setPath( TQDir::homeDirPath() );
350 else
351 newurl = u;
352
353 TQString pathstr = newurl.path(+1);
354 newurl.setPath(pathstr);
355
356 if ( !kateFileSelectorIsReadable ( newurl ) )
357 newurl.cd(TQString::fromLatin1(".."));
358
359 if ( !kateFileSelectorIsReadable (newurl) )
360 newurl.setPath( TQDir::homeDirPath() );
361
362 dir->setURL(newurl, true);
363}
364
365//END Public Slots
366
367//BEGIN Private Slots
368
369void KateFileSelector::cmbPathActivated( const KURL& u )
370{
371 cmbPathReturnPressed( u.url() );
372}
373
374void KateFileSelector::cmbPathReturnPressed( const TQString& u )
375{
376 KURL typedURL( u );
377 if ( typedURL.hasPass() )
378 typedURL.setPass( TQString::null );
379
380 TQStringList urls = cmbPath->urls();
381 urls.remove( typedURL.url() );
382 urls.prepend( typedURL.url() );
383 cmbPath->setURLs( urls, KURLComboBox::RemoveBottom );
384 dir->setFocus();
385 dir->setURL( KURL(u), true );
386}
387
388void KateFileSelector::dirUrlEntered( const KURL& u )
389{
390 cmbPath->setURL( u );
391}
392
393void KateFileSelector::dirFinishedLoading()
394{
395}
396
397
398/*
399 When the button in the filter box toggles:
400 If off:
401 If the name filer is anything but "" or "*", reset it.
402 If on:
403 Set last filter.
404*/
405void KateFileSelector::btnFilterClick()
406{
407 if ( !btnFilter->isOn() ) {
408 slotFilterChange( TQString::null );
409 }
410 else {
411 filter->lineEdit()->setText( lastFilter );
412 slotFilterChange( lastFilter );
413 }
414}
415
416void KateFileSelector::setActiveDocumentDir()
417{
418// kdDebug(13001)<<"KateFileSelector::setActiveDocumentDir()"<<endl;
419 KURL u = mainwin->activeDocumentUrl();
420// kdDebug(13001)<<"URL: "<<u.prettyURL()<<endl;
421 if (!u.isEmpty())
422 setDir( u.upURL() );
423// kdDebug(13001)<<"... setActiveDocumentDir() DONE!"<<endl;
424}
425
426void KateFileSelector::kateViewChanged()
427{
428 if ( autoSyncEvents & DocumentChanged )
429 {
430// kdDebug(13001)<<"KateFileSelector::do a sync ()"<<endl;
431 // if visible, sync
432 if ( isVisible() ) {
433 setActiveDocumentDir();
434 waitingUrl = TQString::null;
435 }
436 // else set waiting url
437 else {
438 KURL u = mainwin->activeDocumentUrl();
439 if (!u.isEmpty())
440 waitingUrl = u.directory();
441 }
442 }
443
444 // TODO: make sure the button is disabled if the directory is unreadable, eg
445 // the document URL has protocol http
446 acSyncDir->setEnabled( ! mainwin->activeDocumentUrl().directory().isEmpty() );
447}
448
449void KateFileSelector::selectorViewChanged( KFileView * newView )
450{
451 newView->setSelectionMode(KFile::Extended);
452}
453
454//END Private Slots
455
456//BEGIN Protected
457
458void KateFileSelector::focusInEvent( TQFocusEvent * )
459{
460 dir->setFocus();
461}
462
463void KateFileSelector::showEvent( TQShowEvent * )
464{
465 // sync if we should
466 if ( autoSyncEvents & GotVisible ) {
467// kdDebug(13001)<<"syncing fs on show"<<endl;
468 setActiveDocumentDir();
469 waitingUrl = TQString::null;
470 }
471 // else, if we have a waiting URL set it
472 else if ( ! waitingUrl.isEmpty() ) {
473 setDir( waitingUrl );
474 waitingUrl = TQString::null;
475 }
476}
477
478bool KateFileSelector::eventFilter( TQObject* o, TQEvent *e )
479{
480 /*
481 This is rather unfortunate, but:
482 TQComboBox does not support setting the size of the listbox to something
483 reasonable. Even using listbox->setVariableWidth() does not yield a
484 satisfying result, something is wrong with the handling of the sizehint.
485 And the popup is rather useless, if the paths are only partly visible.
486 */
487 TQListBox *lb = cmbPath->listBox();
488 if ( o == lb && e->type() == TQEvent::Show ) {
489 int add = lb->height() < lb->contentsHeight() ? lb->verticalScrollBar()->width() : 0;
490 int w = TQMIN( mainwin->width(), lb->contentsWidth() + add );
491 lb->resize( w, lb->height() );
492 // TODO - move the listbox to a suitable place if nessecary
493 // TODO - decide if it is worth caching the size while untill the contents
494 // are changed.
495 }
496 // TODO - same thing for the completion popup?
497 return TQWidget::eventFilter( o, e );
498}
499
500//END Protected
501
502//BEGIN ACtionLBItem
503/*
504 QListboxItem that can store and return a string,
505 used for the toolbar action selector.
506*/
507class ActionLBItem : public TQListBoxPixmap {
508 public:
509 ActionLBItem( TQListBox *lb=0,
510 const TQPixmap &pm = TQPixmap(),
511 const TQString &text=TQString::null,
512 const TQString &str=TQString::null ) :
513 TQListBoxPixmap( lb, pm, text ),
514 _str(str) {};
515 TQString idstring() { return _str; };
516 private:
517 TQString _str;
518};
519//END ActionLBItem
520
521//BEGIN KFSConfigPage
523// KFSConfigPage implementation
525KFSConfigPage::KFSConfigPage( TQWidget *parent, const char *name, KateFileSelector *kfs )
526 : Kate::ConfigPage( parent, name ),
527 fileSelector( kfs ),
528 m_changed( false )
529{
530 TQVBoxLayout *lo = new TQVBoxLayout( this );
531 int spacing = KDialog::spacingHint();
532 lo->setSpacing( spacing );
533
534 // Toolbar - a lot for a little...
535 TQGroupBox *gbToolbar = new TQGroupBox( 1, TQt::Vertical, i18n("Toolbar"), this );
536 acSel = new TDEActionSelector( gbToolbar );
537 acSel->setAvailableLabel( i18n("A&vailable actions:") );
538 acSel->setSelectedLabel( i18n("S&elected actions:") );
539 lo->addWidget( gbToolbar );
540 connect( acSel, TQ_SIGNAL( added( TQListBoxItem * ) ), this, TQ_SLOT( slotMyChanged() ) );
541 connect( acSel, TQ_SIGNAL( removed( TQListBoxItem * ) ), this, TQ_SLOT( slotMyChanged() ) );
542 connect( acSel, TQ_SIGNAL( movedUp( TQListBoxItem * ) ), this, TQ_SLOT( slotMyChanged() ) );
543 connect( acSel, TQ_SIGNAL( movedDown( TQListBoxItem * ) ), this, TQ_SLOT( slotMyChanged() ) );
544
545 // Sync
546 TQGroupBox *gbSync = new TQGroupBox( 1, TQt::Horizontal, i18n("Auto Synchronization"), this );
547 cbSyncActive = new TQCheckBox( i18n("When a docu&ment becomes active"), gbSync );
548 cbSyncShow = new TQCheckBox( i18n("When the file selector becomes visible"), gbSync );
549 lo->addWidget( gbSync );
550 connect( cbSyncActive, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotMyChanged() ) );
551 connect( cbSyncShow, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotMyChanged() ) );
552
553 // Histories
554 TQHBox *hbPathHist = new TQHBox ( this );
555 TQLabel *lbPathHist = new TQLabel( i18n("Remember &locations:"), hbPathHist );
556 sbPathHistLength = new TQSpinBox( hbPathHist );
557 lbPathHist->setBuddy( sbPathHistLength );
558 lo->addWidget( hbPathHist );
559 connect( sbPathHistLength, TQ_SIGNAL( valueChanged ( int ) ), this, TQ_SLOT( slotMyChanged() ) );
560
561 TQHBox *hbFilterHist = new TQHBox ( this );
562 TQLabel *lbFilterHist = new TQLabel( i18n("Remember &filters:"), hbFilterHist );
563 sbFilterHistLength = new TQSpinBox( hbFilterHist );
564 lbFilterHist->setBuddy( sbFilterHistLength );
565 lo->addWidget( hbFilterHist );
566 connect( sbFilterHistLength, TQ_SIGNAL( valueChanged ( int ) ), this, TQ_SLOT( slotMyChanged() ) );
567
568 // Session
569 TQGroupBox *gbSession = new TQGroupBox( 1, TQt::Horizontal, i18n("Session"), this );
570 cbSesLocation = new TQCheckBox( i18n("Restore loca&tion"), gbSession );
571 cbSesFilter = new TQCheckBox( i18n("Restore last f&ilter"), gbSession );
572 lo->addWidget( gbSession );
573 connect( cbSesLocation, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotMyChanged() ) );
574 connect( cbSesFilter, TQ_SIGNAL( toggled( bool ) ), this, TQ_SLOT( slotMyChanged() ) );
575
576 // make it look nice
577 lo->addStretch( 1 );
578
579 // be helpfull
580 /*
581 TQWhatsThis::add( lbAvailableActions, i18n(
582 "<p>Available actions for the toolbar. To add an action, select it here "
583 "and press the add (<strong>-&gt;</strong>) button" ) );
584 TQWhatsThis::add( lbUsedActions, i18n(
585 "<p>Actions used in the toolbar. To remove an action, select it and "
586 "press the remove (<strong>&lt;-</strong>) button."
587 "<p>To change the order of the actions, use the Up and Down buttons to "
588 "move the selected action.") );
589 */
590 TQString lhwt( i18n(
591 "<p>Decides how many locations to keep in the history of the location "
592 "combo box.") );
593 TQWhatsThis::add( lbPathHist, lhwt );
594 TQWhatsThis::add( sbPathHistLength, lhwt );
595 TQString fhwt( i18n(
596 "<p>Decides how many filters to keep in the history of the filter "
597 "combo box.") );
598 TQWhatsThis::add( lbFilterHist, fhwt );
599 TQWhatsThis::add( sbFilterHistLength, fhwt );
600 TQString synwt( i18n(
601 "<p>These options allow you to have the File Selector automatically "
602 "change location to the folder of the active document on certain "
603 "events."
604 "<p>Auto synchronization is <em>lazy</em>, meaning it will not take "
605 "effect until the file selector is visible."
606 "<p>None of these are enabled by default, but you can always sync the "
607 "location by pressing the sync button in the toolbar.") );
608 TQWhatsThis::add( gbSync, synwt );
609 TQWhatsThis::add( cbSesLocation, i18n(
610 "<p>If this option is enabled (default), the location will be restored "
611 "when you start Kate.<p><strong>Note</strong> that if the session is "
612 "handled by the TDE session manager, the location is always restored.") );
613 TQWhatsThis::add( cbSesFilter, i18n(
614 "<p>If this option is enabled (default), the current filter will be "
615 "restored when you start Kate.<p><strong>Note</strong> that if the "
616 "session is handled by the TDE session manager, the filter is always "
617 "restored."
618 "<p><strong>Note</strong> that some of the autosync settings may "
619 "override the restored location if on.") );
620
621 init();
622
623}
624
625void KFSConfigPage::apply()
626{
627 if ( ! m_changed )
628 return;
629
630 m_changed = false;
631
632 TDEConfig *config = tdeApp->config();
633 config->setGroup( "fileselector" );
634 // toolbar
635 TQStringList l;
636 TQListBoxItem *item = acSel->selectedListBox()->firstItem();
637 ActionLBItem *aItem;
638 while ( item )
639 {
640 aItem = (ActionLBItem*)item;
641 if ( aItem )
642 {
643 l << aItem->idstring();
644 }
645 item = item->next();
646 }
647 config->writeEntry( "toolbar actions", l );
648 fileSelector->setupToolbar( config );
649 // sync
650 int s = 0;
651 if ( cbSyncActive->isChecked() )
652 s |= KateFileSelector::DocumentChanged;
653 if ( cbSyncShow->isChecked() )
654 s |= KateFileSelector::GotVisible;
655 fileSelector->autoSyncEvents = s;
656
657 // histories
658 fileSelector->cmbPath->setMaxItems( sbPathHistLength->value() );
659 fileSelector->filter->setMaxCount( sbFilterHistLength->value() );
660 // session - theese are read/written directly to the app config,
661 // as they are not needed during operation.
662 config->writeEntry( "restore location", cbSesLocation->isChecked() );
663 config->writeEntry( "restore last filter", cbSesFilter->isChecked() );
664}
665
666void KFSConfigPage::reload()
667{
668 // hmm, what is this supposed to do, actually??
669 init();
670 m_changed = false;
671}
672void KFSConfigPage::init()
673{
674 TDEConfig *config = tdeApp->config();
675 config->setGroup( "fileselector" );
676 // toolbar
677 TQStringList l = config->readListEntry( "toolbar actions", ',' );
678 if ( l.isEmpty() ) // default toolbar
679 l << "up" << "back" << "forward" << "home" <<
680 "short view" << "detailed view" <<
681 "bookmarks" << "sync_dir";
682
683 // actions from diroperator + two of our own
684 TQStringList allActions;
685 allActions << "up" << "back" << "forward" << "home" <<
686 "reload" << "mkdir" << "delete" <<
687 "short view" << "detailed view" /*<< "view menu" <<
688 "show hidden" << "properties"*/ <<
689 "bookmarks" << "sync_dir";
690 TQRegExp re("&(?=[^&])");
691 TDEAction *ac;
692 TQListBox *lb;
693 for ( TQStringList::Iterator it=allActions.begin(); it != allActions.end(); ++it ) {
694 lb = l.contains( *it ) ? acSel->selectedListBox() : acSel->availableListBox();
695 if ( *it == "bookmarks" || *it == "sync_dir" )
696 ac = fileSelector->actionCollection()->action( (*it).latin1() );
697 else
698 ac = fileSelector->dirOperator()->actionCollection()->action( (*it).latin1() );
699 if ( ac )
700 new ActionLBItem( lb, SmallIcon( ac->icon() ), ac->text().replace( re, "" ), *it );
701 }
702
703 // sync
704 int s = fileSelector->autoSyncEvents;
705 cbSyncActive->setChecked( s & KateFileSelector::DocumentChanged );
706 cbSyncShow->setChecked( s & KateFileSelector::GotVisible );
707 // histories
708 sbPathHistLength->setValue( fileSelector->cmbPath->maxItems() );
709 sbFilterHistLength->setValue( fileSelector->filter->maxCount() );
710 // session
711 cbSesLocation->setChecked( config->readBoolEntry( "restore location", true ) );
712 cbSesFilter->setChecked( config->readBoolEntry( "restore last filter", true ) );
713}
714
715void KFSConfigPage::slotMyChanged()
716{
717 m_changed = true;
718 slotChanged();
719}
720//END KFSConfigPage
Kate
Namespace collecting as much of the internal Kate classes as we can manage.
Definition: kateapp.h:32

kate

Skip menu "kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kate

Skip menu "kate"
  • kate
  • libkonq
  • twin
  •   lib
Generated for kate by doxygen 1.9.4
This website is maintained by Timothy Pearson.