00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#include "fileselector_part.h"
00025
#include "fileselector_widget.h"
00026
#include "kactionselector.h"
00027
#include "kbookmarkhandler.h"
00028
00029
#include <kdevcore.h>
00030
#include <kdevmainwindow.h>
00031
#include <kdevpartcontroller.h>
00032
00033
#include <qlayout.h>
00034
#include <qtoolbutton.h>
00035
#include <qhbox.h>
00036
#include <qvbox.h>
00037
#include <qlabel.h>
00038
#include <qstrlist.h>
00039
#include <qtooltip.h>
00040
#include <qwhatsthis.h>
00041
#include <qapplication.h>
00042
#include <qlistbox.h>
00043
#include <qscrollbar.h>
00044
#include <qspinbox.h>
00045
#include <qgroupbox.h>
00046
#include <qcheckbox.h>
00047
#include <qregexp.h>
00048
#include <qdockarea.h>
00049
#include <qtimer.h>
00050
00051
#include <ktexteditor/document.h>
00052
00053
#include <kmainwindow.h>
00054
#include <kapplication.h>
00055
#include <kiconloader.h>
00056
#include <kurlcombobox.h>
00057
#include <kurlcompletion.h>
00058
#include <kprotocolinfo.h>
00059
#include <kconfig.h>
00060
#include <klocale.h>
00061
#include <kcombobox.h>
00062
#include <kaction.h>
00063
#include <kmessagebox.h>
00064
#include <ktoolbarbutton.h>
00065
#include <qtoolbar.h>
00066
#include <kpopupmenu.h>
00067
#include <kdialog.h>
00068
#include <kio/netaccess.h>
00069
00070
#include <kdebug.h>
00071
00072
00073
00074 static void silenceQToolBar(QtMsgType,
const char *)
00075 {}
00076
00077
00078 KDevFileSelectorToolBar::KDevFileSelectorToolBar(
QWidget *parent)
00079 :
KToolBar( parent, "KDev FileSelector Toolbar", true )
00080 {
00081 setMinimumWidth(10);
00082 }
00083
00084 KDevFileSelectorToolBar::~KDevFileSelectorToolBar()
00085 {}
00086
00087 void KDevFileSelectorToolBar::setMovingEnabled(
bool)
00088 {
00089 KToolBar::setMovingEnabled(
false);
00090 }
00091
00092
00093 KDevFileSelectorToolBarParent::KDevFileSelectorToolBarParent(
QWidget *parent)
00094 :
QFrame(parent),m_tb(0)
00095 {}
00096 KDevFileSelectorToolBarParent::~KDevFileSelectorToolBarParent()
00097 {}
00098 void KDevFileSelectorToolBarParent::setToolBar(
KDevFileSelectorToolBar *tb)
00099 {
00100
m_tb=tb;
00101 }
00102
00103 void KDevFileSelectorToolBarParent::resizeEvent (
QResizeEvent * )
00104 {
00105
if (
m_tb)
00106 {
00107 setMinimumHeight(
m_tb->
sizeHint().height());
00108
m_tb->resize(width(),height());
00109 }
00110 }
00111
00112
00113
00114
00115 KDevFileSelector::KDevFileSelector(
FileSelectorPart *part,
KDevMainWindow *mainWindow,
00116
KDevPartController *partController,
00117
QWidget * parent,
const char * name )
00118 :
QWidget(parent, name),
00119 m_part(part),
00120 mainwin(mainWindow),
00121 partController(partController)
00122 {
00123
mActionCollection =
new KActionCollection(
this );
00124
00125
QVBoxLayout* lo =
new QVBoxLayout(
this);
00126
00127 QtMsgHandler oldHandler = qInstallMsgHandler(
silenceQToolBar );
00128
00129
KDevFileSelectorToolBarParent *tbp=
new KDevFileSelectorToolBarParent(
this);
00130
toolbar =
new KDevFileSelectorToolBar(tbp);
00131 tbp->
setToolBar(
toolbar);
00132 lo->addWidget(tbp);
00133
toolbar->
setMovingEnabled(
false);
00134
toolbar->
setFlat(
true);
00135 qInstallMsgHandler( oldHandler );
00136
00137
cmbPath =
new KURLComboBox( KURLComboBox::Directories,
true,
this,
"path combo" );
00138
cmbPath->setSizePolicy(
QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ));
00139
KURLCompletion* cmpl =
new KURLCompletion(KURLCompletion::DirCompletion);
00140
cmbPath->
setCompletionObject( cmpl );
00141 lo->addWidget(
cmbPath);
00142
cmbPath->listBox()->installEventFilter(
this );
00143
00144
dir =
new KDevDirOperator(
m_part, QString::null,
this,
"operator");
00145
dir->
setView(KFile::Detail);
00146
00147 KActionCollection *coll =
dir->
actionCollection();
00148
00149 coll->
action(
"delete" )->
setShortcut(
KShortcut( ALT + Key_Delete ) );
00150 coll->
action(
"reload" )->
setShortcut(
KShortcut( ALT + Key_F5 ) );
00151 coll->
action(
"back" )->
setShortcut(
KShortcut( ALT + SHIFT + Key_Left ) );
00152 coll->
action(
"forward" )->
setShortcut(
KShortcut( ALT + SHIFT + Key_Right ) );
00153
00154 coll->
action(
"up" )->
setShortcut(
KShortcut( ALT + SHIFT + Key_Up ) );
00155 coll->
action(
"home" )->
setShortcut(
KShortcut( CTRL + ALT + Key_Home ) );
00156
00157 lo->addWidget(
dir);
00158 lo->setStretchFactor(
dir, 2);
00159
00160
00161
KActionMenu *acmBookmarks =
new KActionMenu( i18n(
"Bookmarks"),
"bookmark",
00162
mActionCollection,
"bookmarks" );
00163 acmBookmarks->
setDelayed(
false );
00164
00165
bookmarkHandler =
new KBookmarkHandler(
this, acmBookmarks->
popupMenu() );
00166
00167
QHBox* filterBox =
new QHBox(
this);
00168
00169
btnFilter =
new QToolButton( filterBox );
00170
btnFilter->setIconSet( SmallIconSet(
"filter" ) );
00171
btnFilter->setToggleButton(
true );
00172
filter =
new KHistoryCombo(
true, filterBox,
"filter");
00173
filter->setSizePolicy(
QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ));
00174 filterBox->setStretchFactor(
filter, 2);
00175 connect(
btnFilter, SIGNAL( clicked() ),
this, SLOT(
btnFilterClick() ) );
00176 lo->addWidget(filterBox);
00177
00178 connect(
filter, SIGNAL( activated(
const QString&) ),
00179 SLOT(
slotFilterChange(
const QString&) ) );
00180 connect(
filter, SIGNAL( returnPressed(
const QString&) ),
00181
filter, SLOT( addToHistory(
const QString&) ) );
00182
00183
00184
acSyncDir =
new KAction( i18n(
"Current Document Directory"),
"dirsynch", 0,
00185
this, SLOT(
setActiveDocumentDir() ),
mActionCollection,
"sync_dir" );
00186
toolbar->
setIconText( KToolBar::IconOnly );
00187
toolbar->
setIconSize( 16 );
00188
toolbar->
setEnableContextMenu(
false );
00189
00190 connect(
cmbPath, SIGNAL( urlActivated(
const KURL& )),
00191
this, SLOT(
cmbPathActivated(
const KURL& ) ));
00192 connect(
cmbPath, SIGNAL( returnPressed(
const QString& )),
00193
this, SLOT(
cmbPathReturnPressed(
const QString& ) ));
00194 connect(
dir, SIGNAL(urlEntered(
const KURL&)),
00195
this, SLOT(
dirUrlEntered(
const KURL&)) );
00196
00197 connect(
dir, SIGNAL(finishedLoading()),
00198
this, SLOT(
dirFinishedLoading()) );
00199
00200
00201 connect ( partController, SIGNAL(activePartChanged(
KParts::Part*) ),
00202
this, SLOT(
viewChanged() ) );
00203
00204
00205 connect(
bookmarkHandler, SIGNAL( openURL(
const QString& )),
00206
this, SLOT(
setDir(
const QString& ) ) );
00207
00208
waitingUrl = QString::null;
00209
00210
00211 QWhatsThis::add
00212 (
cmbPath,
00213 i18n(
"<p>Here you can enter a path for a directory to display."
00214
"<p>To go to a directory previously entered, press the arrow on "
00215
"the right and choose one. <p>The entry has directory "
00216
"completion. Right-click to choose how completion should behave.") );
00217 QWhatsThis::add
00218 (
filter,
00219 i18n(
"<p>Here you can enter a name filter to limit which files are displayed."
00220
"<p>To clear the filter, toggle off the filter button to the left."
00221
"<p>To reapply the last filter used, toggle on the filter button." ) );
00222 QWhatsThis::add
00223 (
btnFilter,
00224 i18n(
"<p>This button clears the name filter when toggled off, or "
00225
"reapplies the last filter used when toggled on.") );
00226 }
00227
00228 KDevFileSelector::~KDevFileSelector()
00229 {
00230
writeConfig(
m_part->
instance()->
config(),
"fileselector" );
00231 }
00232
00233
00234
00235
00236 void KDevFileSelector::readConfig(
KConfig *config,
const QString & name)
00237 {
00238
dir->
readConfig(config, name +
":dir");
00239
dir->
setView( KFile::Default );
00240
00241 config->
setGroup( name );
00242
00243
00244
setupToolbar( config );
00245
00246
cmbPath->
setMaxItems( config->
readNumEntry(
"pathcombo history len", 9 ) );
00247
cmbPath->
setURLs( config->
readListEntry(
"dir history") );
00248
00249
if ( config->
readBoolEntry(
"restore location",
true ) || kapp->isRestored() )
00250 {
00251
QString loc( config->
readPathEntry(
"location" ) );
00252
if ( ! loc.isEmpty() )
00253 {
00254
waitingDir = loc;
00255 QTimer::singleShot(0,
this, SLOT(
initialDirChangeHack()));
00256 }
00257 }
00258
00259
00260
00261
filter->setMaxCount( config->
readNumEntry(
"filter history len", 9 ) );
00262
filter->
setHistoryItems( config->
readListEntry(
"filter history"),
true );
00263
lastFilter = config->
readEntry(
"last filter" );
00264
QString flt(
"");
00265
if ( config->
readBoolEntry(
"restore last filter",
true ) || kapp->isRestored() )
00266 flt = config->
readEntry(
"current filter");
00267
filter->lineEdit()->setText( flt );
00268
slotFilterChange( flt );
00269
00270
autoSyncEvents = config->
readNumEntry(
"AutoSyncEvents", 0 );
00271
00273
if (
autoSyncEvents &
DocumentChanged )
00274 connect(
partController, SIGNAL(
viewChanged() ),
this, SLOT(
autoSync() ) );
00275
00276
if (
autoSyncEvents &
DocumentOpened )
00277 connect(
partController, SIGNAL( partAdded(
KParts::Part*) ),
00278
this, SLOT(
autoSync(
KParts::Part*) ) );
00279
00280 }
00281
00282 void KDevFileSelector::initialDirChangeHack()
00283 {
00284
setDir(
waitingDir );
00285 }
00286
00287 void KDevFileSelector::setupToolbar(
KConfig *config )
00288 {
00289
toolbar->
clear();
00290
QStringList tbactions = config->
readListEntry(
"toolbar actions",
',' );
00291
if ( tbactions.isEmpty() )
00292 {
00293
00294 tbactions <<
"up" <<
"back" <<
"forward" <<
"home" <<
00295
"short view" <<
"detailed view" <<
00296
"bookmarks" <<
"sync_dir";
00297 }
00298
KAction *ac;
00299
for ( QStringList::Iterator it=tbactions.begin(); it != tbactions.end(); ++it )
00300 {
00301
if ( *it ==
"bookmarks" || *it ==
"sync_dir" )
00302 ac =
mActionCollection->
action( (*it).latin1() );
00303
else
00304 ac =
dir->
actionCollection()->
action( (*it).latin1() );
00305
if ( ac )
00306 ac->
plug(
toolbar );
00307 }
00308 }
00309
00310 void KDevFileSelector::writeConfig(
KConfig *config,
const QString & name)
00311 {
00312
dir->
writeConfig(config,name +
":dir");
00313
00314 config->
setGroup( name );
00315 config->
writeEntry(
"pathcombo history len",
cmbPath->
maxItems() );
00316
QStringList l;
00317
for (
int i = 0; i <
cmbPath->count(); i++)
00318 {
00319 l.append(
cmbPath->text( i ) );
00320 }
00321 config->
writeEntry(
"dir history", l );
00322
#if defined(KDE_IS_VERSION)
00323
# if KDE_IS_VERSION(3,1,3)
00324
# ifndef _KDE_3_1_3_
00325
# define _KDE_3_1_3_
00326
# endif
00327
# endif
00328
#endif
00329
#if defined(_KDE_3_1_3_)
00330
config->
writePathEntry(
"location",
cmbPath->currentText() );
00331
#else
00332
config->
writeEntry(
"location",
cmbPath->currentText() );
00333
#endif
00334
00335 config->
writeEntry(
"filter history len",
filter->maxCount() );
00336 config->
writeEntry(
"filter history",
filter->
historyItems() );
00337 config->
writeEntry(
"current filter",
filter->currentText() );
00338 config->
writeEntry(
"last filter",
lastFilter );
00339 config->
writeEntry(
"AutoSyncEvents",
autoSyncEvents );
00340 }
00341
00342 void KDevFileSelector::setView(KFile::FileView view)
00343 {
00344
dir->
setView(view);
00345 }
00346
00347
00348
00349
00350
00351 void KDevFileSelector::slotFilterChange(
const QString & nf )
00352 {
00353
QString f = nf.stripWhiteSpace();
00354 QToolTip::remove(
btnFilter);
00355
bool empty = f.isEmpty() || f ==
"*";
00356
if (
empty )
00357 {
00358
dir->
clearFilter();
00359
filter->lineEdit()->setText( QString::null );
00360 QToolTip::add
00361 (
btnFilter,
00362
QString( i18n(
"Apply last filter (\"%1\")") ).arg(
lastFilter ) );
00363 }
00364
else
00365 {
00366
dir->
setNameFilter( f );
00367
lastFilter = f;
00368 QToolTip::add
00369 (
btnFilter, i18n(
"Clear filter") );
00370 }
00371
btnFilter->setOn( !
empty );
00372
dir->
updateDir();
00373
00374
btnFilter->setEnabled( !(
empty &&
lastFilter.isEmpty() ) );
00375
00376 }
00377 void KDevFileSelector::setDir(
KURL u )
00378 {
00379
dir->
setURL(u,
true);
00380 }
00381
00382
00383
00384
00385
00386 void KDevFileSelector::cmbPathActivated(
const KURL& u )
00387 {
00388
cmbPathReturnPressed( u.
url() );
00389 }
00390
00391 void KDevFileSelector::cmbPathReturnPressed(
const QString& u )
00392 {
00393
QStringList urls =
cmbPath->
urls();
00394 urls.remove( u );
00395 urls.prepend( u );
00396
cmbPath->
setURLs( urls, KURLComboBox::RemoveBottom );
00397
dir->setFocus();
00398
dir->
setURL(
KURL(u),
true );
00399 }
00400
00401 void KDevFileSelector::dirUrlEntered(
const KURL& u )
00402 {
00403
cmbPath->
setURL( u );
00404 }
00405
00406 void KDevFileSelector::dirFinishedLoading()
00407 {}
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417 void KDevFileSelector::btnFilterClick()
00418 {
00419
if ( !
btnFilter->isOn() )
00420 {
00421
slotFilterChange( QString::null );
00422 }
00423
else
00424 {
00425
filter->lineEdit()->setText(
lastFilter );
00426
slotFilterChange(
lastFilter );
00427 }
00428 }
00429
00430
00431 void KDevFileSelector::autoSync()
00432 {
00433
kdDebug()<<
"KDevFileSelector::autoSync()"<<
endl;
00434
00435
if ( isVisible() )
00436 {
00437
setActiveDocumentDir();
00438
waitingUrl = QString::null;
00439 }
00440
00441
else
00442 {
00443
KURL u =
activeDocumentUrl();
00444
if (!u.
isEmpty())
00445
waitingUrl = u.
directory();
00446 }
00447 }
00448
00449 void KDevFileSelector::autoSync(
KParts::Part *part )
00450 {
00451
KTextEditor::Document* doc = dynamic_cast<KTextEditor::Document*>( part );
00452
if( !doc )
00453
return;
00454
00455
00456
kdDebug()<<
"KDevFileSelector::autoSync( KTextEditor::Document )"<<
endl;
00457
KURL u ( doc->
url() );
00458
if ( u.
isEmpty() )
00459 {
00460
waitingUrl = QString::null;
00461
return;
00462 }
00463
if ( isVisible() )
00464 {
00465
setDir( u.
directory() );
00466
waitingUrl = QString::null;
00467 }
00468
else
00469 {
00470
waitingUrl = u.
directory();
00471 }
00472 }
00474 void KDevFileSelector::setActiveDocumentDir()
00475 {
00476
00477
KURL u =
activeDocumentUrl();
00478
if (!u.
isEmpty())
00479
setDir( u.
upURL() );
00480 }
00481
00482 void KDevFileSelector::viewChanged()
00483 {
00486
acSyncDir->
setEnabled( !
activeDocumentUrl().directory().isEmpty() );
00487 }
00488
00489
00490
00491
00492
00493 void KDevFileSelector::focusInEvent(
QFocusEvent * )
00494 {
00495
dir->setFocus();
00496 }
00497
00498 void KDevFileSelector::showEvent(
QShowEvent * )
00499 {
00500
00501
if (
autoSyncEvents &
GotVisible )
00502 {
00503
kdDebug()<<
"syncing fs on show"<<
endl;
00504
setActiveDocumentDir();
00505
waitingUrl = QString::null;
00506 }
00507
00508
else if ( !
waitingUrl.isEmpty() )
00509 {
00510
setDir(
waitingUrl );
00511
waitingUrl = QString::null;
00512 }
00513 }
00514
00515 bool KDevFileSelector::eventFilter(
QObject* o,
QEvent *e )
00516 {
00517
00518
00519
00520
00521
00522
00523
00524
QListBox *lb =
cmbPath->listBox();
00525
if ( o == lb && e->type() == QEvent::Show )
00526 {
00527
int add
00528 = lb->height() < lb->contentsHeight() ? lb->verticalScrollBar()->width() : 0;
00529
int w = QMIN(
mainwin->
main()->width(), lb->contentsWidth() + add );
00530 lb->resize( w, lb->height() );
00534 }
00536
return QWidget::eventFilter( o, e );
00537 }
00538
00539
00540
00541
00542
00543
00544
00545
00546 class ActionLBItem :
public QListBoxPixmap
00547 {
00548
public:
00549 ActionLBItem(
QListBox *lb=0,
00550
const QPixmap &pm =
QPixmap(),
00551
const QString &text=QString::null,
00552
const QString &str=QString::null ) :
00553
QListBoxPixmap( lb, pm,
text ),
00554
_str(str)
00555 {}
00556 ;
00557 QString idstring()
00558 {
00559
return _str;
00560 };
00561
private:
00562 QString _str;
00563 };
00564
00565 KURL KDevFileSelector::activeDocumentUrl( )
00566 {
00567
KTextEditor::Document* doc = dynamic_cast<KTextEditor::Document*>(
partController->
activePart() );
00568
if( doc )
00569
return doc->
url();
00570
00571
return KURL();
00572 }
00573
00574
00575
00577
00579 KFSConfigPage::KFSConfigPage(
QWidget *parent,
const char *name,
KDevFileSelector *kfs )
00580 :
QWidget( parent, name ),
00581 fileSelector( kfs ),
00582 bDirty( false )
00583 {
00584
QVBoxLayout *lo =
new QVBoxLayout(
this );
00585
int spacing =
KDialog::spacingHint();
00586 lo->setSpacing( spacing );
00587
00588
00589
QGroupBox *gbToolbar =
new QGroupBox( 1, Qt::Vertical, i18n(
"Toolbar"),
this );
00590
acSel =
new KActionSelector( gbToolbar );
00591
acSel->
setAvailableLabel( i18n(
"A&vailable actions:") );
00592
acSel->
setSelectedLabel( i18n(
"S&elected actions:") );
00593 lo->addWidget( gbToolbar );
00594 connect(
acSel, SIGNAL( added(
QListBoxItem * ) ),
this, SLOT(
slotChanged() ) );
00595 connect(
acSel, SIGNAL( removed(
QListBoxItem * ) ),
this, SLOT(
slotChanged() ) );
00596 connect(
acSel, SIGNAL( movedUp(
QListBoxItem * ) ),
this, SLOT(
slotChanged() ) );
00597 connect(
acSel, SIGNAL( movedDown(
QListBoxItem * ) ),
this, SLOT(
slotChanged() ) );
00598
00599
00600 QGroupBox *gbSync =
new QGroupBox( 1, Qt::Horizontal, i18n(
"Auto Synchronization"),
this );
00601
cbSyncActive =
new QCheckBox( i18n(
"When a docu&ment becomes active"), gbSync );
00602
cbSyncOpen =
new QCheckBox( i18n(
"When a document is o&pened"), gbSync );
00603
cbSyncShow =
new QCheckBox( i18n(
"When the file selector becomes visible"), gbSync );
00604 lo->addWidget( gbSync );
00605 connect(
cbSyncActive, SIGNAL( toggled(
bool ) ),
this, SLOT(
slotChanged() ) );
00606 connect(
cbSyncOpen, SIGNAL( toggled(
bool ) ),
this, SLOT(
slotChanged() ) );
00607 connect(
cbSyncShow, SIGNAL( toggled(
bool ) ),
this, SLOT(
slotChanged() ) );
00608
00609
00610
QHBox *hbPathHist =
new QHBox (
this );
00611
QLabel *lbPathHist =
new QLabel( i18n(
"Remember &locations:"), hbPathHist );
00612
sbPathHistLength =
new QSpinBox( hbPathHist );
00613 lbPathHist->setBuddy(
sbPathHistLength );
00614 lo->addWidget( hbPathHist );
00615 connect(
sbPathHistLength, SIGNAL( valueChanged (
int ) ),
this, SLOT(
slotChanged() ) );
00616
00617 QHBox *hbFilterHist =
new QHBox (
this );
00618 QLabel *lbFilterHist =
new QLabel( i18n(
"Remember &filters:"), hbFilterHist );
00619
sbFilterHistLength =
new QSpinBox( hbFilterHist );
00620 lbFilterHist->setBuddy(
sbFilterHistLength );
00621 lo->addWidget( hbFilterHist );
00622 connect(
sbFilterHistLength, SIGNAL( valueChanged (
int ) ),
this, SLOT(
slotChanged() ) );
00623
00624
00625 QGroupBox *gbSession =
new QGroupBox( 1, Qt::Horizontal, i18n(
"Session"),
this );
00626
cbSesLocation =
new QCheckBox( i18n(
"Restore loca&tion"), gbSession );
00627
cbSesFilter =
new QCheckBox( i18n(
"Restore last f&ilter"), gbSession );
00628 lo->addWidget( gbSession );
00629 connect(
cbSesLocation, SIGNAL( toggled(
bool ) ),
this, SLOT(
slotChanged() ) );
00630 connect(
cbSesFilter, SIGNAL( toggled(
bool ) ),
this, SLOT(
slotChanged() ) );
00631
00632
00633 lo->addStretch( 1 );
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
QString lhwt( i18n(
00647
"<p>Decides how many locations to keep in the history of the location "
00648
"combo box") );
00649 QWhatsThis::add
00650 ( lbPathHist, lhwt );
00651 QWhatsThis::add
00652 (
sbPathHistLength, lhwt );
00653
QString fhwt( i18n(
00654
"<p>Decides how many filters to keep in the history of the filter "
00655
"combo box") );
00656 QWhatsThis::add
00657 ( lbFilterHist, fhwt );
00658 QWhatsThis::add
00659 (
sbFilterHistLength, fhwt );
00660
QString synwt( i18n(
00661
"<p>These options allow you to have the File Selector automatically "
00662
"change location to the directory of the active document on certain "
00663
"events."
00664
"<p>Auto synchronization is <em>lazy</em>, meaning it will not take "
00665
"effect until the file selector is visible."
00666
"<p>None of these are enabled by default, but you can always sync the "
00667
"location by pressing the sync button in the toolbar.") );
00668 QWhatsThis::add
00669 ( gbSync, synwt );
00670 QWhatsThis::add
00671 (
cbSesLocation, i18n(
00672
"<p>If this option is enabled (default), the location will be restored "
00673
"when you start KDev.<p><strong>Note</strong> that if the session is "
00674
"handled by the KDE session manager, the location is always restored.") );
00675 QWhatsThis::add
00676 (
cbSesFilter, i18n(
00677
"<p>If this option is enabled (default), the current filter will be "
00678
"restored when you start KDev.<p><strong>Note</strong> that if the "
00679
"session is handled by the KDE session manager, the filter is always "
00680
"restored."
00681
"<p><strong>Note</strong> that some of the autosync settings may "
00682
"override the restored location if on.") );
00683
00684
init();
00685
00686 }
00687
00688 void KFSConfigPage::apply()
00689 {
00690
KConfig *config =
fileSelector->
m_part->
instance()->
config();
00691 config->
setGroup(
"fileselector" );
00692
00693
QStringList l;
00694
QListBoxItem *item =
acSel->
selectedListBox()->firstItem();
00695
ActionLBItem *aItem;
00696
while ( item )
00697 {
00698 aItem = (
ActionLBItem*)item;
00699
if ( aItem )
00700 {
00701 l << aItem->
idstring();
00702 }
00703 item = item->next();
00704 }
00705 config->
writeEntry(
"toolbar actions", l );
00706
fileSelector->
setupToolbar( config );
00707
00708
int s = 0;
00709
if (
cbSyncActive->isChecked() )
00710 s |= KDevFileSelector::DocumentChanged;
00711
if (
cbSyncOpen->isChecked() )
00712 s |= KDevFileSelector::DocumentOpened;
00713
if (
cbSyncShow->isChecked() )
00714 s |= KDevFileSelector::GotVisible;
00715
fileSelector->
autoSyncEvents = s;
00716
00717 disconnect(
fileSelector->
partController, 0,
fileSelector, SLOT( autoSync() ) );
00718 disconnect(
fileSelector->
partController, 0,
00719
fileSelector, SLOT( autoSync(
KParts::Part *) ) );
00720
if ( s & KDevFileSelector::DocumentChanged )
00721 connect(
fileSelector->
partController, SIGNAL( viewChanged() ),
00722
fileSelector, SLOT( autoSync() ) );
00723
if ( s & KDevFileSelector::DocumentOpened )
00724 connect(
fileSelector->
partController,
00725 SIGNAL( partAdded(
KParts::Part *) ),
00726
fileSelector, SLOT( autoSync(
KParts::Part *) ) );
00727
00728
00729
fileSelector->
cmbPath->
setMaxItems(
sbPathHistLength->value() );
00730
fileSelector->
filter->setMaxCount(
sbFilterHistLength->value() );
00731
00732
00733 config->
writeEntry(
"restore location",
cbSesLocation->isChecked() );
00734 config->
writeEntry(
"restore last filter",
cbSesFilter->isChecked() );
00735 }
00736
00737 void KFSConfigPage::reload()
00738 {
00739
00740
init();
00741 }
00742
00743 void KFSConfigPage::init()
00744 {
00745
KConfig *config =
fileSelector->
m_part->
instance()->
config();
00746 config->
setGroup(
"fileselector" );
00747
00748
QStringList l = config->
readListEntry(
"toolbar actions",
',' );
00749
if ( l.isEmpty() )
00750 l <<
"up" <<
"back" <<
"forward" <<
"home" <<
00751
"short view" <<
"detailed view" <<
00752
"bookmarks" <<
"sync_dir";
00753
00754
00755
QStringList allActions;
00756 allActions <<
"up" <<
"back" <<
"forward" <<
"home" <<
00757
"reload" <<
"mkdir" <<
"delete" <<
00758
"short view" <<
"detailed view"
00759 <<
00760
"bookmarks" <<
"sync_dir";
00761
QRegExp re(
"&(?=[^&])");
00762
KAction *ac;
00763
QListBox *lb;
00764
for ( QStringList::Iterator it=allActions.begin(); it != allActions.end(); ++it )
00765 {
00766 lb = l.contains( *it ) ?
acSel->
selectedListBox() :
acSel->
availableListBox();
00767
if ( *it ==
"bookmarks" || *it ==
"sync_dir" )
00768 ac =
fileSelector->
actionCollection()->
action( (*it).latin1() );
00769
else
00770 ac =
fileSelector->
dirOperator()->
actionCollection()->
action( (*it).latin1() );
00771
if ( ac )
00772
new ActionLBItem( lb, SmallIcon( ac->
icon() ), ac->
text().replace( re,
"" ), *it );
00773 }
00774
00775
00776
int s =
fileSelector->
autoSyncEvents;
00777
cbSyncActive->setChecked( s & KDevFileSelector::DocumentChanged );
00778
cbSyncOpen->setChecked( s & KDevFileSelector::DocumentOpened );
00779
cbSyncShow->setChecked( s & KDevFileSelector::GotVisible );
00780
00781
sbPathHistLength->setValue(
fileSelector->
cmbPath->
maxItems() );
00782
sbFilterHistLength->setValue(
fileSelector->
filter->maxCount() );
00783
00784
cbSesLocation->setChecked( config->
readBoolEntry(
"restore location",
true ) );
00785
cbSesFilter->setChecked( config->
readBoolEntry(
"restore last filter",
true ) );
00786 }
00787
00788 void KFSConfigPage::slotChanged()
00789 {
00790 }
00791
00792
00793
00794
00795
00796
00797 void KDevDirOperator::activatedMenu(
const KFileItem *fi,
const QPoint & pos )
00798 {
00799
setupMenu();
00800
updateSelectionDependentActions();
00801
00802
KActionMenu * am = dynamic_cast<KActionMenu*>(
actionCollection()->
action(
"popupMenu"));
00803
if (!am)
00804
return;
00805
KPopupMenu *popup = am->
popupMenu();
00806
00807
if (fi)
00808 {
00809
FileContext context(
KURL::List(fi->
url()));
00810
if ( (
m_part) && (
m_part->
core()))
00811
m_part->
core()->
fillContextMenu(popup, &context);
00812 }
00813
00814 popup->popup(pos);
00815 }
00816
00817
00818
00819
#include "fileselector_widget.moc"