diff --git a/configuredialog.cpp b/configuredialog.cpp index bdde50959..c6ff9f0d6 100644 --- a/configuredialog.cpp +++ b/configuredialog.cpp @@ -61,6 +61,7 @@ using KMail::ImapAccountBase; using KRecentAddress::RecentAddresses; #include "completionordereditor.h" #include "ldapclient.h" +#include "index.h" using KMail::IdentityListView; using KMail::IdentityListViewItem; @@ -4378,6 +4379,16 @@ MiscPageFolderTab::MiscPageFolderTab( QWidget * parent, const char * name ) connect( mEmptyTrashCheck, SIGNAL( stateChanged( int ) ), this, SLOT( slotEmitChanged( void ) ) ); +#ifdef HAVE_INDEXLIB + // indexing enabled option: + mIndexingEnabled = new QCheckBox( i18n("Enable full text &indexing"), this ); + vlay->addWidget( mIndexingEnabled ); + connect( mIndexingEnabled, SIGNAL( stateChanged( int ) ), + this, SLOT( slotEmitChanged( void ) ) ); +#endif + + + vlay->addStretch( 1 ); // and now: add QWhatsThis: @@ -4412,6 +4423,22 @@ MiscPageFolderTab::MiscPageFolderTab( QWidget * parent, const char * name ) "the search will start from the bottom of the message list and continue to " "the previous folder depending on which option is selected.

" ); QWhatsThis::add( mLoopOnGotoUnread, msg ); + +#ifdef HAVE_INDEXLIB + // this is probably overly pessimistic + msg = i18n( "what's this help", + "

Full text indexing allows very fast searches on the content " + "of your messages. When enabled, the search dialog will work very fast. " + "Also, the search tool bar will also select messages based on content.

" + "

It takes up a certain amount of disk space " + "(about half the disk space for the messages).

" + "

After enabling, the index will need to be built, but you can continue to use KMail " + "while this operation is running.

" + "
" + ); + + QWhatsThis::add( mIndexingEnabled, msg ); +#endif } void MiscPage::FolderTab::doLoadFromGlobalSettings() { @@ -4435,6 +4462,8 @@ void MiscPage::FolderTab::doLoadOther() { int num = general.readNumEntry("default-mailbox-format", 1 ); if ( num < 0 || num > 1 ) num = 1; mMailboxPrefCombo->setCurrentItem( num ); + + mIndexingEnabled->setChecked( kmkernel->msgIndex() && kmkernel->msgIndex()->isEnabled() ); } void MiscPage::FolderTab::save() { @@ -4453,6 +4482,7 @@ void MiscPage::FolderTab::save() { GlobalSettings::self()->setShowPopupAfterDnD( mShowPopupAfterDnD->isChecked() ); GlobalSettings::self()->setExcludeImportantMailFromExpiry( mExcludeImportantFromExpiry->isChecked() ); + if ( kmkernel->msgIndex() ) kmkernel->msgIndex()->setEnabled( mIndexingEnabled->isChecked() ); } QString MiscPage::GroupwareTab::helpAnchor() const { diff --git a/configuredialog_p.h b/configuredialog_p.h index cb1ed5100..e06d4072f 100644 --- a/configuredialog_p.h +++ b/configuredialog_p.h @@ -916,6 +916,7 @@ private: QComboBox *mMailboxPrefCombo; QComboBox *mActionEnterFolder; QCheckBox *mEmptyTrashCheck; + QCheckBox *mIndexingEnabled; QCheckBox *mDelayedMarkAsRead; KIntSpinBox *mDelayedMarkTime; QCheckBox *mShowPopupAfterDnD; diff --git a/index.cpp b/index.cpp index 21abd37a6..e7b26238c 100644 --- a/index.cpp +++ b/index.cpp @@ -90,10 +90,6 @@ KMMsgIndex::KMMsgIndex( QObject* parent ): mSlowDown( false ) { kdDebug( 5006 ) << "KMMsgIndex::KMMsgIndex()" << endl; - if ( !QFileInfo( mIndexPath ).exists() ) { - ::mkdir( mIndexPath, S_IRWXU ); - } - connect( kmkernel->folderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( KMFolder*, Q_UINT32 ) ) ); connect( kmkernel->folderMgr(), SIGNAL( msgAdded( KMFolder*, Q_UINT32 ) ), SLOT( slotAddMessage( KMFolder*, Q_UINT32 ) ) ); connect( kmkernel->dimapFolderMgr(), SIGNAL( msgRemoved( KMFolder*, Q_UINT32 ) ), SLOT( slotRemoveMessage( KMFolder*, Q_UINT32 ) ) ); @@ -169,6 +165,10 @@ bool KMMsgIndex::isIndexed( KMFolder* folder ) const { void KMMsgIndex::setEnabled( bool e ) { kdDebug( 5006 ) << "KMMsgIndex::setEnabled( " << e << " )" << endl; + KConfig* config = KMKernel::config(); + KConfigGroupSaver saver( config, "text-index" ); + if ( config->readBoolEntry( "enabled", e ) == e ) return; + config->writeEntry( "enabled", e ); if ( e ) { switch ( mState ) { case s_idle: @@ -367,7 +367,11 @@ void KMMsgIndex::continueCreation() { void KMMsgIndex::create() { kdDebug( 5006 ) << "KMMsgIndex::create()" << endl; + #ifdef HAVE_INDEXLIB + if ( !QFileInfo( mIndexPath ).exists() ) { + ::mkdir( mIndexPath, S_IRWXU ); + } mState = s_creating; if ( !mIndex ) mIndex = indexlib::create( mIndexPath ).release(); if ( !mIndex ) { diff --git a/index.h b/index.h index b407e400c..9aa3d9ebc 100644 --- a/index.h +++ b/index.h @@ -92,6 +92,11 @@ class KMMsgIndex : public QObject { * even though the folder is probably still being indexed in the background. */ bool isIndexed( KMFolder* folder ) const; + + /** + * Returns whether the index is enabled + */ + bool isEnabled() const { return mState != s_disabled; } public slots: /** * Either enable or disable indexing.