00001
00002
00003
00004
00005 #ifdef HAVE_CONFIG_H
00006 #include <config.h>
00007 #endif
00008
00009 #include <kwin.h>
00010
00011 #ifdef MALLOC_DEBUG
00012 #include <malloc.h>
00013 #endif
00014
00015 #undef Unsorted // X headers...
00016 #include <qaccel.h>
00017 #include <qlayout.h>
00018 #include <qhbox.h>
00019 #include <qvbox.h>
00020 #include <qpopupmenu.h>
00021 #include <qptrlist.h>
00022 #include <qsignalmapper.h>
00023 #include <qvaluevector.h>
00024 #include <qstylesheet.h>
00025
00026 #include <kopenwith.h>
00027 #include <kmessagebox.h>
00028 #include <kpopupmenu.h>
00029 #include <kaccelmanager.h>
00030 #include <kglobalsettings.h>
00031 #include <kstdaccel.h>
00032 #include <kkeydialog.h>
00033 #include <kcharsets.h>
00034 #include <knotifyclient.h>
00035 #include <kdebug.h>
00036 #include <kapplication.h>
00037 #include <kfiledialog.h>
00038 #include <ktip.h>
00039 #include <knotifydialog.h>
00040 #include <kstandarddirs.h>
00041 #include <dcopclient.h>
00042 #include <kaddrbook.h>
00043 #include <kaccel.h>
00044 #include <kstringhandler.h>
00045
00046 #include "globalsettings.h"
00047 #include "kcursorsaver.h"
00048 #include "broadcaststatus.h"
00049 using KPIM::BroadcastStatus;
00050 #include "kmfoldermgr.h"
00051 #include "kmfolderdia.h"
00052 #include "accountmanager.h"
00053 using KMail::AccountManager;
00054 #include "kmfilter.h"
00055 #include "kmfoldertree.h"
00056 #include "kmreadermainwin.h"
00057 #include "kmfoldercachedimap.h"
00058 #include "kmfolderimap.h"
00059 #include "kmacctcachedimap.h"
00060 #include "composer.h"
00061 #include "kmfolderseldlg.h"
00062 #include "kmfiltermgr.h"
00063 #include "messagesender.h"
00064 #include "kmaddrbook.h"
00065 #include "kmversion.h"
00066 #include "searchwindow.h"
00067 using KMail::SearchWindow;
00068 #include "kmacctfolder.h"
00069 #include "undostack.h"
00070 #include "kmcommands.h"
00071 #include "kmmainwin.h"
00072 #include "kmsystemtray.h"
00073 #include "imapaccountbase.h"
00074 #include "transportmanager.h"
00075 using KMail::ImapAccountBase;
00076 #include "vacation.h"
00077 using KMail::Vacation;
00078 #include "favoritefolderview.h"
00079 #include "subscriptiondialog.h"
00080 using KMail::SubscriptionDialog;
00081 #include "localsubscriptiondialog.h"
00082 using KMail::LocalSubscriptionDialog;
00083 #include "attachmentstrategy.h"
00084 using KMail::AttachmentStrategy;
00085 #include "headerstrategy.h"
00086 using KMail::HeaderStrategy;
00087 #include "headerstyle.h"
00088 using KMail::HeaderStyle;
00089 #include "folderjob.h"
00090 using KMail::FolderJob;
00091 #include "mailinglist-magic.h"
00092 #include "antispamwizard.h"
00093 using KMail::AntiSpamWizard;
00094 #include "filterlogdlg.h"
00095 using KMail::FilterLogDialog;
00096 #include <headerlistquicksearch.h>
00097 #include "klistviewindexedsearchline.h"
00098 using KMail::HeaderListQuickSearch;
00099 #include "kmheaders.h"
00100 #include "mailinglistpropertiesdialog.h"
00101 #include "templateparser.h"
00102 #include "archivefolderdialog.h"
00103 #include "folderutil.h"
00104
00105 #if !defined(NDEBUG)
00106 #include "sievedebugdialog.h"
00107 using KMail::SieveDebugDialog;
00108 #endif
00109
00110 #include <libkpimidentities/identity.h>
00111 #include <libkpimidentities/identitymanager.h>
00112
00113 #include <assert.h>
00114 #include <kstatusbar.h>
00115 #include <kstaticdeleter.h>
00116 #include <kaction.h>
00117
00118 #include <kmime_mdn.h>
00119 #include <kmime_header_parsing.h>
00120 using namespace KMime;
00121 using KMime::Types::AddrSpecList;
00122
00123 #include "progressmanager.h"
00124 using KPIM::ProgressManager;
00125
00126 #include "managesievescriptsdialog.h"
00127
00128 #include "customtemplates.h"
00129 #include "customtemplates_kfg.h"
00130
00131 #include "kmmainwidget.moc"
00132
00133 QValueList<KMMainWidget*>* KMMainWidget::s_mainWidgetList = 0;
00134 static KStaticDeleter<QValueList<KMMainWidget*> > mwlsd;
00135
00136
00137 KMMainWidget::KMMainWidget(QWidget *parent, const char *name,
00138 KXMLGUIClient *aGUIClient,
00139 KActionCollection *actionCollection, KConfig* config ) :
00140 QWidget(parent, name),
00141 mFavoritesCheckMailAction( 0 ),
00142 mFavoriteFolderView( 0 ),
00143 mFolderView( 0 ),
00144 mFolderViewParent( 0 ),
00145 mFolderViewSplitter( 0 ),
00146 mQuickSearchLine( 0 ),
00147 mArchiveFolderAction( 0 ),
00148 mShowBusySplashTimer( 0 ),
00149 mShowingOfflineScreen( false ),
00150 mMsgActions( 0 ),
00151 mVacationIndicatorActive( false )
00152 {
00153
00154 mStartupDone = false;
00155 mSearchWin = 0;
00156 mIntegrated = true;
00157 mFolder = 0;
00158 mTemplateFolder = 0;
00159 mFolderThreadPref = false;
00160 mFolderThreadSubjPref = true;
00161 mReaderWindowActive = true;
00162 mReaderWindowBelow = true;
00163 mFolderHtmlPref = false;
00164 mFolderHtmlLoadExtPref = false;
00165 mSystemTray = 0;
00166 mDestructed = false;
00167 mActionCollection = actionCollection;
00168 mTopLayout = new QVBoxLayout(this);
00169 mFilterMenuActions.setAutoDelete(true);
00170 mFilterTBarActions.setAutoDelete(false);
00171 mFilterCommands.setAutoDelete(true);
00172 mFolderShortcutCommands.setAutoDelete(true);
00173 mJob = 0;
00174 mConfig = config;
00175 mGUIClient = aGUIClient;
00176
00177 mCustomReplyActionMenu = 0;
00178 mCustomReplyAllActionMenu = 0;
00179 mCustomForwardActionMenu = 0;
00180 mCustomReplyMapper = 0;
00181 mCustomReplyAllMapper = 0;
00182 mCustomForwardMapper = 0;
00183
00184
00185
00186 mToolbarActionSeparator = new KActionSeparator( actionCollection );
00187
00188 if( !s_mainWidgetList )
00189 mwlsd.setObject( s_mainWidgetList, new QValueList<KMMainWidget*>() );
00190 s_mainWidgetList->append( this );
00191
00192 mPanner1Sep << 1 << 1;
00193 mPanner2Sep << 1 << 1;
00194
00195 setMinimumSize(400, 300);
00196
00197 readPreConfig();
00198 createWidgets();
00199
00200 setupActions();
00201
00202 readConfig();
00203
00204 activatePanners();
00205
00206 QTimer::singleShot( 0, this, SLOT( slotShowStartupFolder() ));
00207
00208 connect( kmkernel->acctMgr(), SIGNAL( checkedMail( bool, bool, const QMap<QString, int> & ) ),
00209 this, SLOT( slotMailChecked( bool, bool, const QMap<QString, int> & ) ) );
00210
00211 connect( kmkernel->acctMgr(), SIGNAL( accountAdded( KMAccount* ) ),
00212 this, SLOT( initializeIMAPActions() ) );
00213 connect( kmkernel->acctMgr(), SIGNAL( accountRemoved( KMAccount* ) ),
00214 this, SLOT( initializeIMAPActions() ) );
00215
00216 connect(kmkernel, SIGNAL( configChanged() ),
00217 this, SLOT( slotConfigChanged() ));
00218
00219
00220 connect(mFolderTree, SIGNAL(currentChanged(QListViewItem*)),
00221 this, SLOT(slotChangeCaption(QListViewItem*)));
00222 connect(mFolderTree, SIGNAL(selectionChanged()),
00223 SLOT(updateFolderMenu()) );
00224
00225 connect(kmkernel->folderMgr(), SIGNAL(folderRemoved(KMFolder*)),
00226 this, SLOT(slotFolderRemoved(KMFolder*)));
00227
00228 connect(kmkernel->imapFolderMgr(), SIGNAL(folderRemoved(KMFolder*)),
00229 this, SLOT(slotFolderRemoved(KMFolder*)));
00230
00231 connect(kmkernel->dimapFolderMgr(), SIGNAL(folderRemoved(KMFolder*)),
00232 this, SLOT(slotFolderRemoved(KMFolder*)));
00233
00234 connect(kmkernel->searchFolderMgr(), SIGNAL(folderRemoved(KMFolder*)),
00235 this, SLOT(slotFolderRemoved(KMFolder*)));
00236
00237 connect( kmkernel, SIGNAL( onlineStatusChanged( GlobalSettings::EnumNetworkState::type ) ),
00238 this, SLOT( slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type ) ) );
00239
00240 toggleSystemTray();
00241
00242
00243 mStartupDone = true;
00244
00245
00246 KMainWindow *mainWin = dynamic_cast<KMainWindow*>(topLevelWidget());
00247 KStatusBar *sb = mainWin ? mainWin->statusBar() : 0;
00248 mVacationScriptIndicator = new KStatusBarLabel( QString(), 0, sb );
00249 mVacationScriptIndicator->hide();
00250 connect( mVacationScriptIndicator, SIGNAL(itemReleased(int)), SLOT(slotEditVacation()) );
00251 if ( GlobalSettings::checkOutOfOfficeOnStartup() )
00252 QTimer::singleShot( 0, this, SLOT(slotCheckVacation()) );
00253 }
00254
00255
00256
00257
00258
00259 KMMainWidget::~KMMainWidget()
00260 {
00261 s_mainWidgetList->remove( this );
00262 destruct();
00263 }
00264
00265
00266
00267
00268 void KMMainWidget::destruct()
00269 {
00270 if (mDestructed)
00271 return;
00272 if (mSearchWin)
00273 mSearchWin->close();
00274 writeConfig();
00275 writeFolderConfig();
00276 delete mHeaders;
00277 delete mFolderTree;
00278 delete mSystemTray;
00279 delete mMsgView;
00280 mDestructed = true;
00281 }
00282
00283
00284
00285 void KMMainWidget::readPreConfig(void)
00286 {
00287 const KConfigGroup geometry( KMKernel::config(), "Geometry" );
00288 const KConfigGroup reader( KMKernel::config(), "Reader" );
00289
00290 mLongFolderList = geometry.readEntry( "FolderList", "long" ) != "short";
00291 mReaderWindowActive = geometry.readEntry( "readerWindowMode", "below" ) != "hide";
00292 mReaderWindowBelow = geometry.readEntry( "readerWindowMode", "below" ) == "below";
00293 mThreadPref = geometry.readBoolEntry( "nestedMessages", false );
00294
00295 mHtmlPref = reader.readBoolEntry( "htmlMail", false );
00296 mHtmlLoadExtPref = reader.readBoolEntry( "htmlLoadExternal", false );
00297 mEnableFavoriteFolderView = GlobalSettings::self()->enableFavoriteFolderView();
00298 }
00299
00300
00301
00302 void KMMainWidget::readFolderConfig(void)
00303 {
00304 if (!mFolder)
00305 return;
00306
00307 KConfig *config = KMKernel::config();
00308 KConfigGroupSaver saver(config, "Folder-" + mFolder->idString());
00309 mFolderThreadPref = config->readBoolEntry( "threadMessagesOverride", false );
00310 mFolderThreadSubjPref = config->readBoolEntry( "threadMessagesBySubject", true );
00311 mFolderHtmlPref = config->readBoolEntry( "htmlMailOverride", false );
00312 mFolderHtmlLoadExtPref = config->readBoolEntry( "htmlLoadExternalOverride", false );
00313 }
00314
00315
00316
00317 void KMMainWidget::writeFolderConfig(void)
00318 {
00319 if (!mFolder)
00320 return;
00321
00322 KConfig *config = KMKernel::config();
00323 KConfigGroupSaver saver(config, "Folder-" + mFolder->idString());
00324 config->writeEntry( "threadMessagesOverride", mFolderThreadPref );
00325 config->writeEntry( "threadMessagesBySubject", mFolderThreadSubjPref );
00326 config->writeEntry( "htmlMailOverride", mFolderHtmlPref );
00327 config->writeEntry( "htmlLoadExternalOverride", mFolderHtmlLoadExtPref );
00328 }
00329
00330
00331
00332 void KMMainWidget::readConfig(void)
00333 {
00334 KConfig *config = KMKernel::config();
00335
00336 bool oldLongFolderList = mLongFolderList;
00337 bool oldReaderWindowActive = mReaderWindowActive;
00338 bool oldReaderWindowBelow = mReaderWindowBelow;
00339 bool oldFavoriteFolderView = mEnableFavoriteFolderView;
00340
00341 QString str;
00342 QSize siz;
00343
00344 if (mStartupDone)
00345 {
00346 writeConfig();
00347
00348 readPreConfig();
00349 mHeaders->refreshNestedState();
00350
00351 bool layoutChanged = ( oldLongFolderList != mLongFolderList )
00352 || ( oldReaderWindowActive != mReaderWindowActive )
00353 || ( oldReaderWindowBelow != mReaderWindowBelow )
00354 || ( oldFavoriteFolderView != mEnableFavoriteFolderView );
00355
00356
00357 if( layoutChanged ) {
00358 hide();
00359
00360 delete mPanner1;
00361 createWidgets();
00362 }
00363
00364 }
00365
00366 {
00367 KConfigGroupSaver saver(config, "Geometry");
00368
00369 QSize defaultSize(750,560);
00370 siz = config->readSizeEntry("MainWin", &defaultSize);
00371 if (!siz.isEmpty())
00372 resize(siz);
00373
00374 static const int folderpanewidth = 250;
00375
00376 const int folderW = config->readNumEntry( "FolderPaneWidth", folderpanewidth );
00377 const int headerW = config->readNumEntry( "HeaderPaneWidth", width()-folderpanewidth );
00378 const int headerH = config->readNumEntry( "HeaderPaneHeight", 180 );
00379 const int readerH = config->readNumEntry( "ReaderPaneHeight", 280 );
00380
00381 mPanner1Sep.clear();
00382 mPanner2Sep.clear();
00383 QValueList<int> & widths = mLongFolderList ? mPanner1Sep : mPanner2Sep ;
00384 QValueList<int> & heights = mLongFolderList ? mPanner2Sep : mPanner1Sep ;
00385
00386 widths << folderW << headerW;
00387 heights << headerH << readerH;
00388
00389 bool layoutChanged = ( oldLongFolderList != mLongFolderList )
00390 || ( oldReaderWindowActive != mReaderWindowActive )
00391 || ( oldReaderWindowBelow != mReaderWindowBelow );
00392
00393 if (!mStartupDone || layoutChanged )
00394 {
00398
00399
00400 const int unreadColumn = config->readNumEntry("UnreadColumn", 1);
00401 const int totalColumn = config->readNumEntry("TotalColumn", 2);
00402 const int sizeColumn = config->readNumEntry("SizeColumn", 3);
00403
00404
00405
00406
00407
00408 if (unreadColumn == 1)
00409 mFolderTree->addUnreadColumn( i18n("Unread"), 70 );
00410 else if (totalColumn == 1)
00411 mFolderTree->addTotalColumn( i18n("Total"), 70 );
00412 else if (sizeColumn == 1)
00413 mFolderTree->addSizeColumn( i18n("Size"), 70 );
00414
00415 if (unreadColumn == 2)
00416 mFolderTree->addUnreadColumn( i18n("Unread"), 70 );
00417 else if (totalColumn == 2)
00418 mFolderTree->addTotalColumn( i18n("Total"), 70 );
00419 else if (sizeColumn == 2)
00420 mFolderTree->addSizeColumn( i18n("Size"), 70 );
00421
00422 if (unreadColumn == 3)
00423 mFolderTree->addUnreadColumn( i18n("Unread"), 70 );
00424 else if (totalColumn == 3)
00425 mFolderTree->addTotalColumn( i18n("Total"), 70 );
00426 else if (sizeColumn == 3)
00427 mFolderTree->addSizeColumn( i18n("Size"), 70 );
00428
00429 mUnreadColumnToggle->setChecked( mFolderTree->isUnreadActive() );
00430 mUnreadTextToggle->setChecked( !mFolderTree->isUnreadActive() );
00431 mTotalColumnToggle->setChecked( mFolderTree->isTotalActive() );
00432 mSizeColumnToggle->setChecked( mFolderTree->isSizeActive() );
00433
00434 mFolderTree->updatePopup();
00435 }
00436 }
00437
00438 if (mMsgView)
00439 mMsgView->readConfig();
00440
00441 mHeaders->readConfig();
00442 mHeaders->restoreColumnLayout( KMKernel::config(), "Header-Geometry" );
00443
00444 if ( mFolderViewSplitter && !GlobalSettings::self()->folderViewSplitterPosition().isEmpty() ) {
00445 mFolderViewSplitter->setSizes( GlobalSettings::self()->folderViewSplitterPosition() );
00446 } else {
00447 QValueList<int> defaults;
00448 defaults << (int)(height() * 0.2) << (int)(height() * 0.8);
00449 mFolderViewSplitter->setSizes( defaults );
00450 }
00451
00452 mFolderTree->readConfig();
00453 if ( mFavoriteFolderView )
00454 mFavoriteFolderView->readConfig();
00455 mFavoritesCheckMailAction->setEnabled( GlobalSettings::self()->enableFavoriteFolderView() );
00456
00457 {
00458 KConfigGroupSaver saver(config, "General");
00459 mBeepOnNew = config->readBoolEntry("beep-on-mail", false);
00460 mConfirmEmpty = config->readBoolEntry("confirm-before-empty", true);
00461
00462 mStartupFolder = config->readEntry("startupFolder", kmkernel->inboxFolder()->idString());
00463 if (!mStartupDone)
00464 {
00465
00466 bool check = config->readBoolEntry("checkmail-startup", false);
00467 if (check)
00468
00469 QTimer::singleShot( 0, this, SLOT( slotCheckMail() ) );
00470 }
00471 }
00472
00473
00474 mFolderTree->reload();
00475
00476
00477 if (mStartupDone)
00478 {
00479
00480 toggleSystemTray();
00481
00482 bool layoutChanged = ( oldLongFolderList != mLongFolderList )
00483 || ( oldReaderWindowActive != mReaderWindowActive )
00484 || ( oldReaderWindowBelow != mReaderWindowBelow )
00485 || ( oldFavoriteFolderView != mEnableFavoriteFolderView );
00486 if ( layoutChanged ) {
00487 activatePanners();
00488 }
00489
00490 mFolderTree->showFolder( mFolder );
00491
00492
00493 mHeaders->setFolder(mFolder);
00494 if (mMsgView) {
00495 int aIdx = mHeaders->currentItemIndex();
00496 if (aIdx != -1)
00497 mMsgView->setMsg( mFolder->getMsg(aIdx), true );
00498 else
00499 mMsgView->clear( true );
00500 }
00501 updateMessageActions();
00502 show();
00503
00504
00505 }
00506 updateMessageMenu();
00507 updateFileMenu();
00508 }
00509
00510
00511
00512 void KMMainWidget::writeConfig(void)
00513 {
00514 QString s;
00515 KConfig *config = KMKernel::config();
00516 KConfigGroup geometry( config, "Geometry" );
00517
00518 if (mMsgView)
00519 mMsgView->writeConfig();
00520
00521 if ( mFolderViewSplitter )
00522 GlobalSettings::setFolderViewSplitterPosition( mFolderViewSplitter->sizes() );
00523 mFolderTree->writeConfig();
00524 if ( mFavoriteFolderView )
00525 mFavoriteFolderView->writeConfig();
00526
00527 geometry.writeEntry( "MainWin", this->geometry().size() );
00528
00529 const QValueList<int> widths = ( mLongFolderList ? mPanner1 : mPanner2 )->sizes();
00530 const QValueList<int> heights = ( mLongFolderList ? mPanner2 : mPanner1 )->sizes();
00531
00532 geometry.writeEntry( "FolderPaneWidth", widths[0] );
00533 geometry.writeEntry( "HeaderPaneWidth", widths[1] );
00534
00535
00536 if ( mSearchAndHeaders && mSearchAndHeaders->isShown() ) {
00537 geometry.writeEntry( "HeaderPaneHeight", heights[0] );
00538 geometry.writeEntry( "ReaderPaneHeight", heights[1] );
00539 }
00540
00541
00542 geometry.writeEntry( "UnreadColumn", mFolderTree->unreadIndex() );
00543 geometry.writeEntry( "TotalColumn", mFolderTree->totalIndex() );
00544 geometry.writeEntry( "SizeColumn", mFolderTree->sizeIndex() );
00545 }
00546
00547
00548
00549 void KMMainWidget::createWidgets(void)
00550 {
00551
00552 QWidget *headerParent = 0,
00553 *mimeParent = 0, *messageParent = 0;
00554
00555 const bool opaqueResize = KGlobalSettings::opaqueResize();
00556 if ( mLongFolderList ) {
00557
00558
00559 mPanner1 = new QSplitter( Qt::Horizontal, this, "panner 1" );
00560 mPanner1->setOpaqueResize( opaqueResize );
00561 Qt::Orientation orientation = mReaderWindowBelow ? Qt::Vertical : Qt::Horizontal;
00562 mPanner2 = new QSplitter( orientation, mPanner1, "panner 2" );
00563 mPanner2->setOpaqueResize( opaqueResize );
00564 mPanner2->setChildrenCollapsible( false );
00565 mFolderViewParent = mPanner1;
00566 headerParent = mimeParent = messageParent = mPanner2;
00567 } else {
00568
00569
00570 mPanner1 = new QSplitter( Qt::Vertical, this, "panner 1" );
00571 mPanner1->setOpaqueResize( opaqueResize );
00572 mPanner1->setChildrenCollapsible( false );
00573 mPanner2 = new QSplitter( Qt::Horizontal, mPanner1, "panner 2" );
00574 mPanner2->setOpaqueResize( opaqueResize );
00575 headerParent = mFolderViewParent = mPanner2;
00576 mimeParent = messageParent = mPanner1;
00577 }
00578
00579 #ifndef NDEBUG
00580 if( mPanner1 ) mPanner1->dumpObjectTree();
00581 if( mPanner2 ) mPanner2->dumpObjectTree();
00582 #endif
00583
00584 mTopLayout->add( mPanner1 );
00585
00586
00587
00588
00589
00590
00591 #ifndef NDEBUG
00592 headerParent->dumpObjectTree();
00593 #endif
00594 mSearchAndHeaders = new QVBox( headerParent );
00595 mSearchToolBar = new KToolBar( mSearchAndHeaders, "search toolbar");
00596 mSearchToolBar->setMovingEnabled(false);
00597 mSearchToolBar->boxLayout()->setSpacing( KDialog::spacingHint() );
00598 QLabel *label = new QLabel( i18n("S&earch:"), mSearchToolBar, "kde toolbar widget" );
00599
00600
00601 mHeaders = new KMHeaders(this, mSearchAndHeaders, "headers");
00602 #ifdef HAVE_INDEXLIB
00603 mQuickSearchLine = new KListViewIndexedSearchLine( mSearchToolBar, mHeaders,
00604 actionCollection(), "headers quick search line" );
00605 #else
00606 mQuickSearchLine = new HeaderListQuickSearch( mSearchToolBar, mHeaders,
00607 actionCollection(), "headers quick search line" );
00608 #endif
00609 label->setBuddy( mQuickSearchLine );
00610 connect( mQuickSearchLine, SIGNAL( requestFullSearch() ),
00611 this, SLOT( slotRequestFullSearchFromQuickSearch() ) );
00612 mSearchToolBar->setStretchableWidget( mQuickSearchLine );
00613 connect( mHeaders, SIGNAL( messageListUpdated() ),
00614 mQuickSearchLine, SLOT( updateSearch() ) );
00615 if ( !GlobalSettings::self()->quickSearchActive() ) mSearchToolBar->hide();
00616
00617 if (mReaderWindowActive) {
00618 connect(mHeaders, SIGNAL(selected(KMMessage*)),
00619 this, SLOT(slotMsgSelected(KMMessage*)));
00620 }
00621 connect(mHeaders, SIGNAL(activated(KMMessage*)),
00622 this, SLOT(slotMsgActivated(KMMessage*)));
00623 connect( mHeaders, SIGNAL( selectionChanged() ),
00624 SLOT( startUpdateMessageActionsTimer() ) );
00625 QAccel *accel = actionCollection()->kaccel();
00626 accel->connectItem(accel->insertItem(SHIFT+Key_Left),
00627 mHeaders, SLOT(selectPrevMessage()));
00628 accel->connectItem(accel->insertItem(SHIFT+Key_Right),
00629 mHeaders, SLOT(selectNextMessage()));
00630
00631 if (mReaderWindowActive) {
00632 mMsgView = new KMReaderWin(messageParent, this, actionCollection(), 0 );
00633 if ( mMsgActions ) {
00634 mMsgActions->setMessageView( mMsgView );
00635 }
00636
00637 connect(mMsgView, SIGNAL(replaceMsgByUnencryptedVersion()),
00638 this, SLOT(slotReplaceMsgByUnencryptedVersion()));
00639 connect(mMsgView, SIGNAL(popupMenu(KMMessage&,const KURL&,const QPoint&)),
00640 this, SLOT(slotMsgPopup(KMMessage&,const KURL&,const QPoint&)));
00641 connect(mMsgView, SIGNAL(urlClicked(const KURL&,int)),
00642 mMsgView, SLOT(slotUrlClicked()));
00643 connect(mHeaders, SIGNAL(maybeDeleting()),
00644 mMsgView, SLOT(clearCache()));
00645 connect(mMsgView, SIGNAL(noDrag()),
00646 mHeaders, SLOT(slotNoDrag()));
00647 accel->connectItem(accel->insertItem(Key_Up),
00648 mMsgView, SLOT(slotScrollUp()));
00649 accel->connectItem(accel->insertItem(Key_Down),
00650 mMsgView, SLOT(slotScrollDown()));
00651 accel->connectItem(accel->insertItem(Key_Prior),
00652 mMsgView, SLOT(slotScrollPrior()));
00653 accel->connectItem(accel->insertItem(Key_Next),
00654 mMsgView, SLOT(slotScrollNext()));
00655 } else {
00656 mMsgView = NULL;
00657 }
00658
00659 KAction *action;
00660
00661 mMoveMsgToFolderAction = new KAction( i18n("Move Message to Folder"), Key_M, this,
00662 SLOT(slotMoveMsg()), actionCollection(),
00663 "move_message_to_folder" );
00664 mMoveMsgToFolderAction->plugAccel( actionCollection()->kaccel() );
00665
00666 action = new KAction( i18n("Copy Message to Folder"), Key_C, this,
00667 SLOT(slotCopyMsg()), actionCollection(),
00668 "copy_message_to_folder" );
00669 action->plugAccel( actionCollection()->kaccel() );
00670
00671 action = new KAction( i18n("Jump to Folder"), Key_J, this,
00672 SLOT(slotJumpToFolder()), actionCollection(),
00673 "jump_to_folder" );
00674 action->plugAccel( actionCollection()->kaccel() );
00675
00676
00677 mFolderViewSplitter = new QSplitter( Qt::Vertical, mFolderViewParent );
00678 mFolderViewSplitter->setOpaqueResize( KGlobalSettings::opaqueResize() );
00679 mFavoriteFolderView = new KMail::FavoriteFolderView( this, mFolderViewSplitter );
00680 if ( mFavoritesCheckMailAction )
00681 connect( mFavoritesCheckMailAction, SIGNAL(activated()), mFavoriteFolderView, SLOT(checkMail()) );
00682 QWidget *folderTreeParent = mFolderViewParent;
00683 if ( GlobalSettings::enableFavoriteFolderView() ) {
00684 folderTreeParent = mFolderViewSplitter;
00685 mFolderView = mFolderViewSplitter;
00686 }
00687 mFolderTree = new KMFolderTree(this, folderTreeParent, "folderTree");
00688 if ( !GlobalSettings::enableFavoriteFolderView() ) {
00689 mFolderView = mFolderTree;
00690 }
00691 connect( mFolderTree, SIGNAL(folderSelected(KMFolder*)),
00692 mFavoriteFolderView, SLOT(folderTreeSelectionChanged(KMFolder*)) );
00693
00694 connect(mFolderTree, SIGNAL(folderSelected(KMFolder*)),
00695 this, SLOT(folderSelected(KMFolder*)));
00696 connect( mFolderTree, SIGNAL( folderSelected( KMFolder* ) ),
00697 mQuickSearchLine, SLOT( reset() ) );
00698 connect(mFolderTree, SIGNAL(folderSelectedUnread(KMFolder*)),
00699 this, SLOT(folderSelectedUnread(KMFolder*)));
00700 connect(mFolderTree, SIGNAL(folderDrop(KMFolder*)),
00701 this, SLOT(slotMoveMsgToFolder(KMFolder*)));
00702 connect(mFolderTree, SIGNAL(folderDropCopy(KMFolder*)),
00703 this, SLOT(slotCopyMsgToFolder(KMFolder*)));
00704 connect(mFolderTree, SIGNAL(columnsChanged()),
00705 this, SLOT(slotFolderTreeColumnsChanged()));
00706
00707 if ( mFavoriteFolderView ) {
00708 connect( mFavoriteFolderView, SIGNAL(folderDrop(KMFolder*)), SLOT(slotMoveMsgToFolder(KMFolder*)) );
00709 connect( mFavoriteFolderView, SIGNAL(folderDropCopy(KMFolder*)), SLOT(slotCopyMsgToFolder(KMFolder*)) );
00710 }
00711
00712
00713 mRemoveDuplicatesAction = new KAction(
00714 i18n("Remove Duplicate Messages"), CTRL+Key_Asterisk, this,
00715 SLOT(removeDuplicates()), actionCollection(), "remove_duplicate_messages");
00716 action->plugAccel( actionCollection()->kaccel() );
00717
00718 action = new KAction(
00719 i18n("Abort Current Operation"), Key_Escape, ProgressManager::instance(),
00720 SLOT(slotAbortAll()), actionCollection(), "cancel" );
00721 action->plugAccel( actionCollection()->kaccel() );
00722
00723 action = new KAction(
00724 i18n("Focus on Next Folder"), CTRL+Key_Right, mFolderTree,
00725 SLOT(incCurrentFolder()), actionCollection(), "inc_current_folder");
00726 action->plugAccel( actionCollection()->kaccel() );
00727
00728 action = new KAction(
00729 i18n("Focus on Previous Folder"), CTRL+Key_Left, mFolderTree,
00730 SLOT(decCurrentFolder()), actionCollection(), "dec_current_folder");
00731 action->plugAccel( actionCollection()->kaccel() );
00732
00733 action = new KAction(
00734 i18n("Select Folder with Focus"), CTRL+Key_Space, mFolderTree,
00735 SLOT(selectCurrentFolder()), actionCollection(), "select_current_folder");
00736 action->plugAccel( actionCollection()->kaccel() );
00737
00738 action = new KAction(
00739 i18n("Focus on Next Message"), ALT+Key_Right, mHeaders,
00740 SLOT(incCurrentMessage()), actionCollection(), "inc_current_message");
00741 action->plugAccel( actionCollection()->kaccel() );
00742
00743 action = new KAction(
00744 i18n("Focus on Previous Message"), ALT+Key_Left, mHeaders,
00745 SLOT(decCurrentMessage()), actionCollection(), "dec_current_message");
00746 action->plugAccel( actionCollection()->kaccel() );
00747
00748 action = new KAction(
00749 i18n("Select Message with Focus"), ALT+Key_Space, mHeaders,
00750 SLOT( selectCurrentMessage() ), actionCollection(), "select_current_message");
00751 action->plugAccel( actionCollection()->kaccel() );
00752
00753 connect( kmkernel->outboxFolder(), SIGNAL( msgRemoved(int, QString) ),
00754 SLOT( startUpdateMessageActionsTimer() ) );
00755 connect( kmkernel->outboxFolder(), SIGNAL( msgAdded(int) ),
00756 SLOT( startUpdateMessageActionsTimer() ) );
00757 }
00758
00759
00760
00761 void KMMainWidget::activatePanners(void)
00762 {
00763 if (mMsgView) {
00764 QObject::disconnect( mMsgView->copyAction(),
00765 SIGNAL( activated() ),
00766 mMsgView, SLOT( slotCopySelectedText() ));
00767 }
00768
00769 setupFolderView();
00770 if ( mLongFolderList ) {
00771 mSearchAndHeaders->reparent( mPanner2, 0, QPoint( 0, 0 ) );
00772 if (mMsgView) {
00773 mMsgView->reparent( mPanner2, 0, QPoint( 0, 0 ) );
00774 mPanner2->moveToLast( mMsgView );
00775 }
00776 mFolderViewParent = mPanner1;
00777 mFolderView->reparent( mFolderViewParent, 0, QPoint( 0, 0 ) );
00778 mPanner1->moveToLast( mPanner2 );
00779 mPanner1->setSizes( mPanner1Sep );
00780 mPanner1->setResizeMode( mFolderView, QSplitter::KeepSize );
00781 mPanner2->setSizes( mPanner2Sep );
00782 mPanner2->setResizeMode( mSearchAndHeaders, QSplitter::KeepSize );
00783 } else {
00784 mFolderViewParent = mPanner2;
00785 mFolderView->reparent( mFolderViewParent, 0, QPoint( 0, 0 ) );
00786 mSearchAndHeaders->reparent( mPanner2, 0, QPoint( 0, 0 ) );
00787 mPanner2->moveToLast( mSearchAndHeaders );
00788 mPanner1->moveToFirst( mPanner2 );
00789 if (mMsgView) {
00790 mMsgView->reparent( mPanner1, 0, QPoint( 0, 0 ) );
00791 mPanner1->moveToLast( mMsgView );
00792 }
00793 mPanner1->setSizes( mPanner1Sep );
00794 mPanner2->setSizes( mPanner2Sep );
00795 mPanner1->setResizeMode( mPanner2, QSplitter::KeepSize );
00796 mPanner2->setResizeMode( mFolderView, QSplitter::KeepSize );
00797 }
00798
00799 if (mMsgView) {
00800 QObject::connect( mMsgView->copyAction(),
00801 SIGNAL( activated() ),
00802 mMsgView, SLOT( slotCopySelectedText() ));
00803 }
00804 }
00805
00806
00807
00808 void KMMainWidget::hide()
00809 {
00810 QWidget::hide();
00811 }
00812
00813
00814
00815 void KMMainWidget::show()
00816 {
00817 QWidget::show();
00818 }
00819
00820
00821 void KMMainWidget::slotSearch()
00822 {
00823 if(!mSearchWin)
00824 {
00825 mSearchWin = new SearchWindow(this, "Search", mFolder, false);
00826 connect(mSearchWin, SIGNAL(destroyed()),
00827 this, SLOT(slotSearchClosed()));
00828 }
00829 else
00830 {
00831 mSearchWin->activateFolder(mFolder);
00832 }
00833
00834 mSearchWin->show();
00835 KWin::activateWindow( mSearchWin->winId() );
00836 }
00837
00838
00839
00840 void KMMainWidget::slotSearchClosed()
00841 {
00842 mSearchWin = 0;
00843 }
00844
00845
00846
00847 void KMMainWidget::slotFind()
00848 {
00849 if( mMsgView )
00850 mMsgView->slotFind();
00851 }
00852
00853
00854
00855 void KMMainWidget::slotHelp()
00856 {
00857 kapp->invokeHelp();
00858 }
00859
00860
00861
00862 void KMMainWidget::slotFilter()
00863 {
00864 kmkernel->filterMgr()->openDialog( this );
00865 }
00866
00867
00868
00869 void KMMainWidget::slotPopFilter()
00870 {
00871 kmkernel->popFilterMgr()->openDialog( this );
00872 }
00873
00874 void KMMainWidget::slotManageSieveScripts()
00875 {
00876 if ( !kmkernel->askToGoOnline() ) {
00877 return;
00878 }
00879 KMail::ManageSieveScriptsDialog * dlg = new KMail::ManageSieveScriptsDialog( this );
00880 dlg->show();
00881 }
00882
00883
00884
00885 void KMMainWidget::slotAddrBook()
00886 {
00887 KAddrBookExternal::openAddressBook(this);
00888 }
00889
00890
00891
00892 void KMMainWidget::slotImport()
00893 {
00894 KRun::runCommand("kmailcvt");
00895 }
00896
00897
00898 void KMMainWidget::slotCheckMail()
00899 {
00900 if ( !kmkernel->askToGoOnline() ) {
00901 return;
00902 }
00903 kmkernel->acctMgr()->checkMail(true);
00904 }
00905
00906
00907 void KMMainWidget::slotCheckOneAccount(int item)
00908 {
00909 if ( !kmkernel->askToGoOnline() ) {
00910 return;
00911 }
00912 kmkernel->acctMgr()->intCheckMail(item);
00913 }
00914
00915
00916 void KMMainWidget::slotMailChecked( bool newMail, bool sendOnCheck,
00917 const QMap<QString, int> & newInFolder )
00918 {
00919 const bool sendOnAll =
00920 GlobalSettings::self()->sendOnCheck() == GlobalSettings::EnumSendOnCheck::SendOnAllChecks;
00921 const bool sendOnManual =
00922 GlobalSettings::self()->sendOnCheck() == GlobalSettings::EnumSendOnCheck::SendOnManualChecks;
00923 if( !kmkernel->isOffline() && ( sendOnAll || (sendOnManual && sendOnCheck ) ) )
00924 slotSendQueued();
00925
00926 if ( !newMail || newInFolder.isEmpty() )
00927 return;
00928
00929 kapp->dcopClient()->emitDCOPSignal( "unreadCountChanged()", QByteArray() );
00930
00931
00932 bool showNotification = false;
00933 QString summary;
00934 QStringList keys( newInFolder.keys() );
00935 keys.sort();
00936 for ( QStringList::const_iterator it = keys.begin();
00937 it != keys.end();
00938 ++it ) {
00939 kdDebug(5006) << newInFolder.find( *it ).data() << " new message(s) in "
00940 << *it << endl;
00941
00942 KMFolder *folder = kmkernel->findFolderById( *it );
00943
00944 if ( folder && !folder->ignoreNewMail() ) {
00945 showNotification = true;
00946 if ( GlobalSettings::self()->verboseNewMailNotification() ) {
00947 summary += "<br>" + i18n( "1 new message in %1",
00948 "%n new messages in %1",
00949 newInFolder.find( *it ).data() )
00950 .arg( folder->prettyURL() );
00951 }
00952 }
00953 }
00954
00955
00956
00957 updateFolderMenu();
00958
00959 if ( !showNotification )
00960 return;
00961
00962 if ( GlobalSettings::self()->verboseNewMailNotification() ) {
00963 summary = i18n( "%1 is a list of the number of new messages per folder",
00964 "<b>New mail arrived</b><br>%1" )
00965 .arg( summary );
00966 }
00967 else {
00968 summary = i18n( "New mail arrived" );
00969 }
00970
00971 if(kmkernel->xmlGuiInstance()) {
00972 KNotifyClient::Instance instance(kmkernel->xmlGuiInstance());
00973 KNotifyClient::event( topLevelWidget()->winId(), "new-mail-arrived",
00974 summary );
00975 }
00976 else
00977 KNotifyClient::event( topLevelWidget()->winId(), "new-mail-arrived",
00978 summary );
00979
00980 if (mBeepOnNew) {
00981 KNotifyClient::beep();
00982 }
00983 }
00984
00985
00986
00987 void KMMainWidget::slotCompose()
00988 {
00989 KMail::Composer * win;
00990 KMMessage* msg = new KMMessage;
00991
00992 if ( mFolder ) {
00993 msg->initHeader( mFolder->identity() );
00994 TemplateParser parser( msg, TemplateParser::NewMessage );
00995 parser.process( NULL, mFolder );
00996 win = KMail::makeComposer( msg, mFolder->identity() );
00997 } else {
00998 msg->initHeader();
00999 TemplateParser parser( msg, TemplateParser::NewMessage );
01000 parser.process( NULL, NULL );
01001 win = KMail::makeComposer( msg );
01002 }
01003
01004 win->show();
01005
01006 }
01007
01008
01009
01010 void KMMainWidget::slotShowNewFromTemplate()
01011 {
01012 if ( mFolder ) {
01013 const KPIM::Identity & ident =
01014 kmkernel->identityManager()->identityForUoidOrDefault( mFolder->identity() );
01015 mTemplateFolder = kmkernel->folderMgr()->findIdString( ident.templates() );
01016 }
01017 else mTemplateFolder = kmkernel->templatesFolder();
01018 if ( !mTemplateFolder )
01019 return;
01020
01021 mTemplateMenu->popupMenu()->clear();
01022 for ( int idx = 0; idx<mTemplateFolder->count(); ++idx ) {
01023 KMMsgBase *mb = mTemplateFolder->getMsgBase( idx );
01024
01025 QString subj = mb->subject();
01026 if ( subj.isEmpty() ) subj = i18n("No Subject");
01027 mTemplateMenu->popupMenu()->insertItem(
01028 KStringHandler::rsqueeze( subj.replace( "&", "&&" ) ), idx );
01029 }
01030 }
01031
01032
01033 void KMMainWidget::slotNewFromTemplate( int id )
01034 {
01035 if ( !mTemplateFolder )
01036 return;
01037 newFromTemplate(mTemplateFolder->getMsg( id ) );
01038 }
01039
01040
01041 void KMMainWidget::newFromTemplate( KMMessage *msg )
01042 {
01043 if ( !msg )
01044 return;
01045 KMCommand *command = new KMUseTemplateCommand( this, msg );
01046 command->start();
01047 }
01048
01049
01050 void KMMainWidget::slotPostToML()
01051 {
01052 if ( mFolder && mFolder->isMailingListEnabled() ) {
01053 KMCommand *command = new KMMailingListPostCommand( this, mFolder );
01054 command->start();
01055 }
01056 else
01057 slotCompose();
01058 }
01059
01060
01061 void KMMainWidget::slotFolderMailingListProperties()
01062 {
01063 if (!mFolderTree) return;
01064 KMFolderTreeItem *item = static_cast<KMFolderTreeItem*>( mFolderTree->currentItem() );
01065 if ( !item ) return;
01066 KMFolder* folder = item->folder();
01067 if ( folder ) {
01068 ( new KMail::MailingListFolderPropertiesDialog( this, folder ) )->show();
01069 }
01070 }
01071
01072
01073 void KMMainWidget::slotFolderShortcutCommand()
01074 {
01075 if (!mFolderTree) return;
01076 KMFolderTreeItem *item = static_cast<KMFolderTreeItem*>( mFolderTree->currentItem() );
01077 if ( item )
01078 item->assignShortcut();
01079 }
01080
01081
01082
01083 void KMMainWidget::slotModifyFolder()
01084 {
01085 if (!mFolderTree) return;
01086 KMFolderTreeItem *item = static_cast<KMFolderTreeItem*>( mFolderTree->currentItem() );
01087 if ( item )
01088 modifyFolder( item );
01089 }
01090
01091
01092 void KMMainWidget::modifyFolder( KMFolderTreeItem* folderItem )
01093 {
01094 KMFolder* folder = folderItem->folder();
01095 KMFolderTree* folderTree = static_cast<KMFolderTree *>( folderItem->listView() );
01096 KMFolderDialog props( folder, folder->parent(), folderTree,
01097 i18n("Properties of Folder %1").arg( folder->label() ) );
01098 props.exec();
01099 updateFolderMenu();
01100
01101 if ( mSystemTray )
01102 mSystemTray->foldersChanged();
01103 }
01104
01105
01106 void KMMainWidget::slotExpireFolder()
01107 {
01108 QString str;
01109 bool canBeExpired = true;
01110
01111 if (!mFolder) return;
01112
01113 if (!mFolder->isAutoExpire()) {
01114 canBeExpired = false;
01115 } else if (mFolder->getUnreadExpireUnits()==expireNever &&
01116 mFolder->getReadExpireUnits()==expireNever) {
01117 canBeExpired = false;
01118 }
01119
01120 if (!canBeExpired) {
01121 str = i18n("This folder does not have any expiry options set");
01122 KMessageBox::information(this, str);
01123 return;
01124 }
01125 KConfig *config = KMKernel::config();
01126 KConfigGroupSaver saver(config, "General");
01127
01128 if (config->readBoolEntry("warn-before-expire", true)) {
01129 str = i18n("<qt>Are you sure you want to expire the folder <b>%1</b>?</qt>").arg(QStyleSheet::escape( mFolder->label() ));
01130 if (KMessageBox::warningContinueCancel(this, str, i18n("Expire Folder"),
01131 i18n("&Expire"))
01132 != KMessageBox::Continue) return;
01133 }
01134
01135 mFolder->expireOldMessages( true );
01136 }
01137
01138
01139 void KMMainWidget::slotEmptyFolder()
01140 {
01141 QString str;
01142
01143 if (!mFolder) return;
01144 bool isTrash = kmkernel->folderIsTrash(mFolder);
01145
01146 if (mConfirmEmpty)
01147 {
01148 QString title = (isTrash) ? i18n("Empty Trash") : i18n("Move to Trash");
01149 QString text = (isTrash) ?
01150 i18n("Are you sure you want to empty the trash folder?") :
01151 i18n("<qt>Are you sure you want to move all messages from "
01152 "folder <b>%1</b> to the trash?</qt>").arg( QStyleSheet::escape( mFolder->label() ) );
01153
01154 if (KMessageBox::warningContinueCancel(this, text, title, KGuiItem( title, "edittrash"))
01155 != KMessageBox::Continue) return;
01156 }
01157 KCursorSaver busy(KBusyPtr::busy());
01158 slotMarkAll();
01159 if (isTrash) {
01160
01161
01162 slotDeleteMsg( false );
01163 }
01164 else
01165 slotTrashMsg();
01166
01167 if (mMsgView) mMsgView->clearCache();
01168
01169 if ( !isTrash )
01170 BroadcastStatus::instance()->setStatusMsg(i18n("Moved all messages to the trash"));
01171
01172 updateMessageActions();
01173
01174
01175
01176 mEmptyFolderAction->setEnabled( false );
01177 }
01178
01179
01180 void KMMainWidget::slotArchiveFolder()
01181 {
01182 KMail::ArchiveFolderDialog archiveDialog;
01183 archiveDialog.setFolder( mFolder );
01184 archiveDialog.exec();
01185 }
01186
01187
01188 void KMMainWidget::slotRemoveFolder()
01189 {
01190 QString str;
01191 QDir dir;
01192
01193 if ( !mFolder ) return;
01194 if ( mFolder->isSystemFolder() ) return;
01195 if ( mFolder->isReadOnly() ) return;
01196
01197 QString title;
01198 if ( mFolder->folderType() == KMFolderTypeSearch ) {
01199 title = i18n("Delete Search");
01200 str = i18n("<qt>Are you sure you want to delete the search <b>%1</b>?<br>"
01201 "Any messages it shows will still be available in their original folder.</qt>")
01202 .arg( QStyleSheet::escape( mFolder->label() ) );
01203 } else {
01204 title = i18n("Delete Folder");
01205 if ( mFolder->count() == 0 ) {
01206 if ( !mFolder->child() || mFolder->child()->isEmpty() ) {
01207 str = i18n("<qt>Are you sure you want to delete the empty folder "
01208 "<b>%1</b>?</qt>")
01209 .arg( QStyleSheet::escape( mFolder->label() ) );
01210 }
01211 else {
01212 str = i18n("<qt>Are you sure you want to delete the empty folder "
01213 "<b>%1</b> and all its subfolders? Those subfolders might "
01214 "not be empty and their contents will be discarded as well. "
01215 "<p><b>Beware</b> that discarded messages are not saved "
01216 "into your Trash folder and are permanently deleted.</qt>")
01217 .arg( QStyleSheet::escape( mFolder->label() ) );
01218 }
01219 } else {
01220 if ( !mFolder->child() || mFolder->child()->isEmpty() ) {
01221 str = i18n("<qt>Are you sure you want to delete the folder "
01222 "<b>%1</b>, discarding its contents? "
01223 "<p><b>Beware</b> that discarded messages are not saved "
01224 "into your Trash folder and are permanently deleted.</qt>")
01225 .arg( QStyleSheet::escape( mFolder->label() ) );
01226 }
01227 else {
01228 str = i18n("<qt>Are you sure you want to delete the folder <b>%1</b> "
01229 "and all its subfolders, discarding their contents? "
01230 "<p><b>Beware</b> that discarded messages are not saved "
01231 "into your Trash folder and are permanently deleted.</qt>")
01232 .arg( QStyleSheet::escape( mFolder->label() ) );
01233 }
01234 }
01235 }
01236
01237 if (KMessageBox::warningContinueCancel(this, str, title,
01238 KGuiItem( i18n("&Delete"), "editdelete"))
01239 == KMessageBox::Continue)
01240 {
01241 KMail::FolderUtil::deleteFolder( mFolder, this );
01242 }
01243 }
01244
01245
01246 void KMMainWidget::slotMarkAllAsRead()
01247 {
01248 if (!mFolder)
01249 return;
01250 mFolder->markUnreadAsRead();
01251 }
01252
01253
01254 void KMMainWidget::slotCompactFolder()
01255 {
01256 if (mFolder) {
01257 int idx = mHeaders->currentItemIndex();
01258 KCursorSaver busy(KBusyPtr::busy());
01259 mFolder->compact( KMFolder::CompactNow );
01260
01261 QString statusMsg = BroadcastStatus::instance()->statusMsg();
01262 mHeaders->setCurrentItemByIndex(idx);
01263 BroadcastStatus::instance()->setStatusMsg( statusMsg );
01264 }
01265 }
01266
01267
01268
01269 void KMMainWidget::slotRefreshFolder()
01270 {
01271 if (mFolder)
01272 {
01273 if ( mFolder->folderType() == KMFolderTypeImap || mFolder->folderType() == KMFolderTypeCachedImap ) {
01274 if ( !kmkernel->askToGoOnline() ) {
01275 return;
01276 }
01277 }
01278
01279 if (mFolder->folderType() == KMFolderTypeImap)
01280 {
01281 KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage());
01282 imap->getAndCheckFolder();
01283 } else if ( mFolder->folderType() == KMFolderTypeCachedImap ) {
01284 KMFolderCachedImap* f = static_cast<KMFolderCachedImap*>( mFolder->storage() );
01285 f->account()->processNewMailInFolder( mFolder );
01286 }
01287 }
01288 }
01289
01290 void KMMainWidget::slotTroubleshootFolder()
01291 {
01292 if (mFolder)
01293 {
01294 if ( mFolder->folderType() == KMFolderTypeCachedImap ) {
01295 KMFolderCachedImap* f = static_cast<KMFolderCachedImap*>( mFolder->storage() );
01296 f->slotTroubleshoot();
01297 }
01298 }
01299 }
01300
01301 void KMMainWidget::slotInvalidateIMAPFolders() {
01302 if ( KMessageBox::warningContinueCancel( this,
01303 i18n("Are you sure you want to refresh the IMAP cache?\n"
01304 "This will remove all changes that you have done "
01305 "locally to your IMAP folders."),
01306 i18n("Refresh IMAP Cache"), i18n("&Refresh") ) == KMessageBox::Continue )
01307 kmkernel->acctMgr()->invalidateIMAPFolders();
01308 }
01309
01310
01311 void KMMainWidget::slotExpireAll() {
01312 KConfig *config = KMKernel::config();
01313 int ret = 0;
01314
01315 KConfigGroupSaver saver(config, "General");
01316
01317 if (config->readBoolEntry("warn-before-expire", true)) {
01318 ret = KMessageBox::warningContinueCancel(KMainWindow::memberList->first(),
01319 i18n("Are you sure you want to expire all old messages?"),
01320 i18n("Expire Old Messages?"), i18n("Expire"));
01321 if (ret != KMessageBox::Continue) {
01322 return;
01323 }
01324 }
01325
01326 kmkernel->expireAllFoldersNow();
01327 }
01328
01329
01330 void KMMainWidget::slotCompactAll()
01331 {
01332 KCursorSaver busy(KBusyPtr::busy());
01333 kmkernel->compactAllFolders();
01334 }
01335
01336
01337
01338 void KMMainWidget::slotOverrideHtml()
01339 {
01340 if( mHtmlPref == mFolderHtmlPref ) {
01341 int result = KMessageBox::warningContinueCancel( this,
01342
01343 i18n( "Use of HTML in mail will make you more vulnerable to "
01344 "\"spam\" and may increase the likelihood that your system will be "
01345 "compromised by other present and anticipated security exploits." ),
01346 i18n( "Security Warning" ),
01347 i18n( "Use HTML" ),
01348 "OverrideHtmlWarning", false);
01349 if( result == KMessageBox::Cancel ) {
01350 mPreferHtmlAction->setChecked( false );
01351 return;
01352 }
01353 }
01354 mFolderHtmlPref = !mFolderHtmlPref;
01355 if (mMsgView) {
01356 mMsgView->setHtmlOverride(mFolderHtmlPref);
01357 mMsgView->update( true );
01358 }
01359 }
01360
01361
01362 void KMMainWidget::slotOverrideHtmlLoadExt()
01363 {
01364 if( mHtmlLoadExtPref == mFolderHtmlLoadExtPref ) {
01365 int result = KMessageBox::warningContinueCancel( this,
01366
01367 i18n( "Loading external references in html mail will make you more vulnerable to "
01368 "\"spam\" and may increase the likelihood that your system will be "
01369 "compromised by other present and anticipated security exploits." ),
01370 i18n( "Security Warning" ),
01371 i18n( "Load External References" ),
01372 "OverrideHtmlLoadExtWarning", false);
01373 if( result == KMessageBox::Cancel ) {
01374 mPreferHtmlLoadExtAction->setChecked( false );
01375 return;
01376 }
01377 }
01378 mFolderHtmlLoadExtPref = !mFolderHtmlLoadExtPref;
01379 if (mMsgView) {
01380 mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref);
01381 mMsgView->update( true );
01382 }
01383 }
01384
01385
01386 void KMMainWidget::slotOverrideThread()
01387 {
01388 mFolderThreadPref = !mFolderThreadPref;
01389 mHeaders->setNestedOverride(mFolderThreadPref);
01390 mThreadBySubjectAction->setEnabled(mThreadMessagesAction->isChecked());
01391 }
01392
01393
01394 void KMMainWidget::slotToggleSubjectThreading()
01395 {
01396 mFolderThreadSubjPref = !mFolderThreadSubjPref;
01397 mHeaders->setSubjectThreading(mFolderThreadSubjPref);
01398 }
01399
01400
01401 void KMMainWidget::slotToggleShowQuickSearch()
01402 {
01403 GlobalSettings::self()->setQuickSearchActive( !GlobalSettings::self()->quickSearchActive() );
01404 if ( GlobalSettings::self()->quickSearchActive() )
01405 mSearchToolBar->show();
01406 else {
01407 mQuickSearchLine->reset();
01408 mSearchToolBar->hide();
01409 }
01410 }
01411
01412
01413 void KMMainWidget::slotMessageQueuedOrDrafted()
01414 {
01415 if (!kmkernel->folderIsDraftOrOutbox(mFolder))
01416 return;
01417 if (mMsgView)
01418 mMsgView->update(true);
01419 }
01420
01421
01422
01423 void KMMainWidget::slotForwardInlineMsg()
01424 {
01425 KMMessageList* selected = mHeaders->selectedMsgs();
01426 KMCommand *command = 0L;
01427 if(selected && !selected->isEmpty()) {
01428 command = new KMForwardInlineCommand( this, *selected,
01429 mFolder->identity() );
01430 } else {
01431 command = new KMForwardInlineCommand( this, mHeaders->currentMsg(),
01432 mFolder->identity() );
01433 }
01434
01435 command->start();
01436 }
01437
01438
01439
01440 void KMMainWidget::slotForwardAttachedMsg()
01441 {
01442 KMMessageList* selected = mHeaders->selectedMsgs();
01443 KMCommand *command = 0L;
01444 if(selected && !selected->isEmpty()) {
01445 command = new KMForwardAttachedCommand( this, *selected, mFolder->identity() );
01446 } else {
01447 command = new KMForwardAttachedCommand( this, mHeaders->currentMsg(), mFolder->identity() );
01448 }
01449
01450 command->start();
01451 }
01452
01453
01454 void KMMainWidget::slotForwardDigestMsg()
01455 {
01456 KMMessageList* selected = mHeaders->selectedMsgs();
01457 KMCommand *command = 0L;
01458 if(selected && !selected->isEmpty()) {
01459 command = new KMForwardDigestCommand( this, *selected, mFolder->identity() );
01460 } else {
01461 command = new KMForwardDigestCommand( this, mHeaders->currentMsg(), mFolder->identity() );
01462 }
01463
01464 command->start();
01465 }
01466
01467
01468 void KMMainWidget::slotUseTemplate()
01469 {
01470 newFromTemplate( mHeaders->currentMsg() );
01471 }
01472
01473
01474 void KMMainWidget::slotResendMsg()
01475 {
01476 KMCommand *command = new KMResendMessageCommand( this, mHeaders->currentMsg() );
01477 command->start();
01478 }
01479
01480
01481
01482 void KMMainWidget::slotTrashMsg()
01483 {
01484 mHeaders->deleteMsg();
01485 }
01486
01487
01488 void KMMainWidget::slotDeleteMsg( bool confirmDelete )
01489 {
01490 mHeaders->moveMsgToFolder( 0, confirmDelete );
01491 }
01492
01493
01494 void KMMainWidget::slotTrashThread()
01495 {
01496 mHeaders->highlightCurrentThread();
01497 mHeaders->deleteMsg();
01498 }
01499
01500
01501 void KMMainWidget::slotDeleteThread( bool confirmDelete )
01502 {
01503 mHeaders->highlightCurrentThread();
01504 mHeaders->moveMsgToFolder( 0, confirmDelete );
01505 }
01506
01507
01508 void KMMainWidget::slotRedirectMsg()
01509 {
01510 KMCommand *command = new KMRedirectCommand( this, mHeaders->currentMsg() );
01511 command->start();
01512 }
01513
01514
01515
01516 void KMMainWidget::slotCustomReplyToMsg( int tid )
01517 {
01518 QString text = mMsgView? mMsgView->copyText() : "";
01519 QString tmpl = mCustomTemplates[ tid ];
01520 kdDebug() << "Reply with template: " << tmpl << " (" << tid << ")" << endl;
01521 KMCommand *command = new KMCustomReplyToCommand( this,
01522 mHeaders->currentMsg(),
01523 text,
01524 tmpl );
01525 command->start();
01526 }
01527
01528
01529
01530 void KMMainWidget::slotCustomReplyAllToMsg( int tid )
01531 {
01532 QString text = mMsgView? mMsgView->copyText() : "";
01533 QString tmpl = mCustomTemplates[ tid ];
01534 kdDebug() << "Reply to All with template: " << tmpl << " (" << tid << ")" << endl;
01535 KMCommand *command = new KMCustomReplyAllToCommand( this,
01536 mHeaders->currentMsg(),
01537 text,
01538 tmpl );
01539 command->start();
01540 }
01541
01542
01543
01544 void KMMainWidget::slotCustomForwardMsg( int tid )
01545 {
01546 QString tmpl = mCustomTemplates[ tid ];
01547 kdDebug() << "Forward with template: " << tmpl << " (" << tid << ")" << endl;
01548 KMMessageList* selected = mHeaders->selectedMsgs();
01549 KMCommand *command = 0L;
01550 if(selected && !selected->isEmpty()) {
01551 command = new KMCustomForwardCommand( this, *selected,
01552 mFolder->identity(), tmpl );
01553 } else {
01554 command = new KMCustomForwardCommand( this, mHeaders->currentMsg(),
01555 mFolder->identity(), tmpl );
01556 }
01557 command->start();
01558 }
01559
01560
01561
01562 void KMMainWidget::slotNoQuoteReplyToMsg()
01563 {
01564 KMCommand *command = new KMNoQuoteReplyToCommand( this, mHeaders->currentMsg() );
01565 command->start();
01566 }
01567
01568
01569 void KMMainWidget::slotSubjectFilter()
01570 {
01571 KMMessage *msg = mHeaders->currentMsg();
01572 if (!msg)
01573 return;
01574
01575 KMCommand *command = new KMFilterCommand( "Subject", msg->subject() );
01576 command->start();
01577 }
01578
01579
01580 void KMMainWidget::slotMailingListFilter()
01581 {
01582 KMMessage *msg = mHeaders->currentMsg();
01583 if (!msg)
01584 return;
01585
01586 KMCommand *command = new KMMailingListFilterCommand( this, msg );
01587 command->start();
01588 }
01589
01590
01591 void KMMainWidget::slotFromFilter()
01592 {
01593 KMMessage *msg = mHeaders->currentMsg();
01594 if (!msg)
01595 return;
01596
01597 AddrSpecList al = msg->extractAddrSpecs( "From" );
01598 KMCommand *command;
01599 if ( al.empty() )
01600 command = new KMFilterCommand( "From", msg->from() );
01601 else
01602 command = new KMFilterCommand( "From", al.front().asString() );
01603 command->start();
01604 }
01605
01606
01607 void KMMainWidget::slotToFilter()
01608 {
01609 KMMessage *msg = mHeaders->currentMsg();
01610 if (!msg)
01611 return;
01612
01613 KMCommand *command = new KMFilterCommand( "To", msg->to() );
01614 command->start();
01615 }
01616
01617
01618 void KMMainWidget::updateListFilterAction()
01619 {
01620
01621 QCString name;
01622 QString value;
01623 QString lname = MailingList::name( mHeaders->currentMsg(), name, value );
01624 mListFilterAction->setText( i18n("Filter on Mailing-List...") );
01625 if ( lname.isNull() )
01626 mListFilterAction->setEnabled( false );
01627 else {
01628 mListFilterAction->setEnabled( true );
01629 mListFilterAction->setText( i18n( "Filter on Mailing-List %1..." ).arg( lname ) );
01630 }
01631 }
01632
01633
01634
01635 void KMMainWidget::slotUndo()
01636 {
01637 mHeaders->undo();
01638 updateMessageActions();
01639 updateFolderMenu();
01640 }
01641
01642
01643 void KMMainWidget::slotToggleUnread()
01644 {
01645 mFolderTree->toggleColumn(KMFolderTree::unread);
01646 }
01647
01648
01649 void KMMainWidget::slotToggleTotalColumn()
01650 {
01651 mFolderTree->toggleColumn(KMFolderTree::total, true);
01652 }
01653
01654
01655 void KMMainWidget::slotToggleSizeColumn()
01656 {
01657 mFolderTree->toggleColumn(KMFolderTree::foldersize);
01658 }
01659
01660
01661
01662 void KMMainWidget::slotJumpToFolder()
01663 {
01664 KMail::KMFolderSelDlg dlg( this, i18n("Jump to Folder"), true );
01665 KMFolder* dest;
01666
01667 if (!dlg.exec()) return;
01668 if (!(dest = dlg.folder())) return;
01669
01670 slotSelectFolder( dest );
01671 }
01672
01673
01674 void KMMainWidget::slotMoveMsg()
01675 {
01676 KMail::KMFolderSelDlg dlg( this, i18n("Move Message to Folder"), true );
01677 KMFolder* dest;
01678
01679 if (!dlg.exec()) return;
01680 if (!(dest = dlg.folder())) return;
01681
01682 mHeaders->moveMsgToFolder(dest);
01683 }
01684
01685
01686 void KMMainWidget::slotMoveMsgToFolder( KMFolder *dest)
01687 {
01688 mHeaders->moveMsgToFolder(dest);
01689 }
01690
01691
01692 void KMMainWidget::slotCopyMsgToFolder( KMFolder *dest)
01693 {
01694 mHeaders->copyMsgToFolder(dest);
01695 }
01696
01697
01698 void KMMainWidget::slotApplyFilters()
01699 {
01700 mHeaders->applyFiltersOnMsg();
01701 }
01702
01703
01704 void KMMainWidget::slotCheckVacation()
01705 {
01706 updateVactionScriptStatus( false );
01707 if ( !kmkernel->askToGoOnline() )
01708 return;
01709
01710 Vacation *vac = new Vacation( this, true );
01711 connect( vac, SIGNAL(scriptActive(bool)), SLOT(updateVactionScriptStatus(bool)) );
01712 }
01713
01714 void KMMainWidget::slotEditVacation()
01715 {
01716 if ( !kmkernel->askToGoOnline() ) {
01717 return;
01718 }
01719
01720 if ( mVacation )
01721 return;
01722
01723 mVacation = new Vacation( this );
01724 connect( mVacation, SIGNAL(scriptActive(bool)), SLOT(updateVactionScriptStatus(bool)) );
01725 if ( mVacation->isUsable() ) {
01726 connect( mVacation, SIGNAL(result(bool)), mVacation, SLOT(deleteLater()) );
01727 } else {
01728 QString msg = i18n("KMail's Out of Office Reply functionality relies on "
01729 "server-side filtering. You have not yet configured an "
01730 "IMAP server for this.\n"
01731 "You can do this on the \"Filtering\" tab of the IMAP "
01732 "account configuration.");
01733 KMessageBox::sorry( this, msg, i18n("No Server-Side Filtering Configured") );
01734
01735 delete mVacation;
01736 }
01737 }
01738
01739
01740 void KMMainWidget::slotDebugSieve()
01741 {
01742 #if !defined(NDEBUG)
01743 if ( mSieveDebugDialog )
01744 return;
01745
01746 mSieveDebugDialog = new SieveDebugDialog( this );
01747 mSieveDebugDialog->exec();
01748 delete mSieveDebugDialog;
01749 #endif
01750 }
01751
01752
01753 void KMMainWidget::slotStartCertManager()
01754 {
01755 KProcess certManagerProc;
01756
01757 certManagerProc << "kleopatra";
01758
01759 if( !certManagerProc.start( KProcess::DontCare ) )
01760 KMessageBox::error( this, i18n( "Could not start certificate manager; "
01761 "please check your installation." ),
01762 i18n( "KMail Error" ) );
01763 else
01764 kdDebug(5006) << "\nslotStartCertManager(): certificate manager started.\n" << endl;
01765
01766
01767
01768 }
01769
01770
01771 void KMMainWidget::slotStartWatchGnuPG()
01772 {
01773 KProcess certManagerProc;
01774 certManagerProc << "kwatchgnupg";
01775
01776 if( !certManagerProc.start( KProcess::DontCare ) )
01777 KMessageBox::error( this, i18n( "Could not start GnuPG LogViewer (kwatchgnupg); "
01778 "please check your installation." ),
01779 i18n( "KMail Error" ) );
01780 }
01781
01782
01783 void KMMainWidget::slotCopyMsg()
01784 {
01785 KMail::KMFolderSelDlg dlg( this, i18n("Copy Message to Folder"), true );
01786 KMFolder* dest;
01787
01788 if (!dlg.exec()) return;
01789 if (!(dest = dlg.folder())) return;
01790
01791 mHeaders->copyMsgToFolder(dest);
01792 }
01793
01794
01795 void KMMainWidget::slotPrintMsg()
01796 {
01797 bool htmlOverride = mMsgView ? mMsgView->htmlOverride() : false;
01798 bool htmlLoadExtOverride = mMsgView ? mMsgView->htmlLoadExtOverride() : false;
01799 KConfigGroup reader( KMKernel::config(), "Reader" );
01800 bool useFixedFont = mMsgView ? mMsgView->isFixedFont()
01801 : reader.readBoolEntry( "useFixedFont", false );
01802 KMCommand *command =
01803 new KMPrintCommand( this, mHeaders->currentMsg(),
01804 mMsgView->headerStyle(), mMsgView->headerStrategy(),
01805 htmlOverride, htmlLoadExtOverride,
01806 useFixedFont, overrideEncoding() );
01807 command->start();
01808 }
01809
01810
01811 void KMMainWidget::setupForwardActions()
01812 {
01813 disconnect( mForwardActionMenu, SIGNAL( activated() ), 0, 0 );
01814 mForwardActionMenu->remove( mForwardInlineAction );
01815 mForwardActionMenu->remove( mForwardAttachedAction );
01816
01817 if ( GlobalSettings::self()->forwardingInlineByDefault() ) {
01818 mForwardActionMenu->insert( mForwardInlineAction, 0 );
01819 mForwardActionMenu->insert( mForwardAttachedAction, 1 );
01820 mForwardInlineAction->setShortcut( Key_F );
01821 mForwardAttachedAction->setShortcut( SHIFT+Key_F );
01822 connect( mForwardActionMenu, SIGNAL(activated()), this,
01823 SLOT(slotForwardInlineMsg()) );
01824
01825 } else {
01826 mForwardActionMenu->insert( mForwardAttachedAction, 0 );
01827 mForwardActionMenu->insert( mForwardInlineAction, 1 );
01828 mForwardInlineAction->setShortcut( SHIFT+Key_F );
01829 mForwardAttachedAction->setShortcut( Key_F );
01830 connect( mForwardActionMenu, SIGNAL(activated()), this,
01831 SLOT(slotForwardAttachedMsg()) );
01832 }
01833 }
01834
01835
01836 void KMMainWidget::slotConfigChanged()
01837 {
01838 readConfig();
01839 setupForwardActions();
01840 setupForwardingActionsList();
01841 }
01842
01843
01844 void KMMainWidget::slotSaveMsg()
01845 {
01846 KMMessage *msg = mHeaders->currentMsg();
01847 if (!msg)
01848 return;
01849 KMSaveMsgCommand *saveCommand = new KMSaveMsgCommand( this,
01850 *mHeaders->selectedMsgs() );
01851
01852 if (saveCommand->url().isEmpty())
01853 delete saveCommand;
01854 else
01855 saveCommand->start();
01856 }
01857
01858
01859 void KMMainWidget::slotOpenMsg()
01860 {
01861 KMOpenMsgCommand *openCommand = new KMOpenMsgCommand( this, 0, overrideEncoding() );
01862
01863 openCommand->start();
01864 }
01865
01866
01867 void KMMainWidget::slotSaveAttachments()
01868 {
01869 KMMessage *msg = mHeaders->currentMsg();
01870 if (!msg)
01871 return;
01872 KMSaveAttachmentsCommand *saveCommand = new KMSaveAttachmentsCommand( this,
01873 *mHeaders->selectedMsgs() );
01874 saveCommand->start();
01875 }
01876
01877 void KMMainWidget::slotOnlineStatus()
01878 {
01879
01880
01881 if ( GlobalSettings::self()->networkState() == GlobalSettings::EnumNetworkState::Online ) {
01882
01883 kmkernel->stopNetworkJobs();
01884 } else {
01885 kmkernel->resumeNetworkJobs();
01886 slotCheckVacation();
01887 }
01888 }
01889
01890 void KMMainWidget::slotUpdateOnlineStatus( GlobalSettings::EnumNetworkState::type )
01891 {
01892 if ( GlobalSettings::self()->networkState() == GlobalSettings::EnumNetworkState::Online )
01893 actionCollection()->action( "online_status" )->setText( i18n("Work Offline") );
01894 else
01895 actionCollection()->action( "online_status" )->setText( i18n("Work Online") );
01896 }
01897
01898
01899
01900 void KMMainWidget::slotSendQueued()
01901 {
01902 if ( !kmkernel->askToGoOnline() ) {
01903 return;
01904 }
01905
01906 kmkernel->msgSender()->sendQueued();
01907 }
01908
01909
01910 void KMMainWidget::slotSendQueuedVia( int item )
01911 {
01912 if ( !kmkernel->askToGoOnline() ) {
01913 return;
01914 }
01915
01916 QStringList availTransports= KMail::TransportManager::transportNames();
01917 QString customTransport = availTransports[ item ];
01918
01919 kmkernel->msgSender()->sendQueued( customTransport );
01920 }
01921
01922
01923 void KMMainWidget::slotViewChange()
01924 {
01925 if(mBodyPartsMenu->isItemChecked(mBodyPartsMenu->idAt(0)))
01926 {
01927 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(0),false);
01928 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(1),true);
01929 }
01930 else if(mBodyPartsMenu->isItemChecked(mBodyPartsMenu->idAt(1)))
01931 {
01932 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(1),false);
01933 mBodyPartsMenu->setItemChecked(mBodyPartsMenu->idAt(0),true);
01934 }
01935
01936
01937 }
01938
01939
01940
01941 void KMMainWidget::folderSelectedUnread( KMFolder* aFolder )
01942 {
01943 folderSelected( aFolder, true );
01944 slotChangeCaption( mFolderTree->currentItem() );
01945 }
01946
01947
01948 void KMMainWidget::folderSelected()
01949 {
01950 folderSelected( mFolder );
01951 updateFolderMenu();
01952
01953 if ( mFolder && mFolder->folderType() == KMFolderTypeImap )
01954 mFolder->close("mainwidget");
01955 }
01956
01957
01958 void KMMainWidget::folderSelected( KMFolder* aFolder, bool forceJumpToUnread )
01959 {
01960 KCursorSaver busy(KBusyPtr::busy());
01961
01962 if (mMsgView)
01963 mMsgView->clear(true);
01964
01965 if ( mFolder && mFolder->folderType() == KMFolderTypeImap && !mFolder->noContent() )
01966 {
01967 KMFolderImap *imap = static_cast<KMFolderImap*>(mFolder->storage());
01968 if ( mFolder->needsCompacting() && imap->autoExpunge() )
01969 imap->expungeFolder(imap, true);
01970 }
01971
01972
01973
01974
01975
01976
01977
01978
01979 bool newFolder = ( (KMFolder*)mFolder != aFolder );
01980 bool isNewImapFolder = aFolder && aFolder->folderType() == KMFolderTypeImap && newFolder;
01981 if( !mFolder
01982 || ( !isNewImapFolder && mShowBusySplashTimer )
01983 || ( newFolder && mShowingOfflineScreen && !( isNewImapFolder && kmkernel->isOffline() ) ) ) {
01984 if ( mMsgView ) {
01985 mMsgView->enableMsgDisplay();
01986 mMsgView->clear( true );
01987 }
01988 if( mSearchAndHeaders && mHeaders )
01989 mSearchAndHeaders->show();
01990 mShowingOfflineScreen = false;
01991 }
01992
01993
01994 delete mShowBusySplashTimer;
01995 mShowBusySplashTimer = 0;
01996
01997 if ( newFolder )
01998 writeFolderConfig();
01999 if ( mFolder ) {
02000 disconnect( mFolder, SIGNAL( changed() ),
02001 this, SLOT( updateMarkAsReadAction() ) );
02002 disconnect( mFolder, SIGNAL( msgHeaderChanged( KMFolder*, int ) ),
02003 this, SLOT( updateMarkAsReadAction() ) );
02004 disconnect( mFolder, SIGNAL( msgAdded( int ) ),
02005 this, SLOT( updateMarkAsReadAction() ) );
02006 disconnect( mFolder, SIGNAL( msgRemoved( KMFolder * ) ),
02007 this, SLOT( updateMarkAsReadAction() ) );
02008 }
02009
02010 mFolder = aFolder;
02011
02012 if ( aFolder && aFolder->folderType() == KMFolderTypeImap )
02013 {
02014 if ( kmkernel->isOffline() ) {
02015 showOfflinePage();
02016 return;
02017 }
02018 KMFolderImap *imap = static_cast<KMFolderImap*>(aFolder->storage());
02019 if ( newFolder && !mFolder->noContent() )
02020 {
02021 imap->open("mainwidget");
02022
02023 imap->setSelected( true );
02024 connect( imap, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
02025 this, SLOT( folderSelected() ) );
02026 imap->getAndCheckFolder();
02027 mHeaders->setFolder( 0 );
02028 updateFolderMenu();
02029 mForceJumpToUnread = forceJumpToUnread;
02030
02031
02032
02033 mShowBusySplashTimer = new QTimer( this );
02034 connect( mShowBusySplashTimer, SIGNAL( timeout() ), this, SLOT( slotShowBusySplash() ) );
02035 mShowBusySplashTimer->start( GlobalSettings::self()->folderLoadingTimeout(), true );
02036 return;
02037 } else {
02038
02039 disconnect( imap, SIGNAL( folderComplete( KMFolderImap*, bool ) ),
02040 this, SLOT( folderSelected() ) );
02041 forceJumpToUnread = mForceJumpToUnread;
02042 }
02043 }
02044
02045 if ( mFolder ) {
02046 connect( mFolder, SIGNAL( changed() ),
02047 this, SLOT( updateMarkAsReadAction() ) );
02048 connect( mFolder, SIGNAL( msgHeaderChanged( KMFolder*, int ) ),
02049 this, SLOT( updateMarkAsReadAction() ) );
02050 connect( mFolder, SIGNAL( msgAdded( int ) ),
02051 this, SLOT( updateMarkAsReadAction() ) );
02052 connect( mFolder, SIGNAL( msgRemoved(KMFolder *) ),
02053 this, SLOT( updateMarkAsReadAction() ) );
02054 }
02055 readFolderConfig();
02056 if (mMsgView)
02057 {
02058 mMsgView->setHtmlOverride(mFolderHtmlPref);
02059 mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref);
02060 }
02061 mHeaders->setFolder( mFolder, forceJumpToUnread );
02062 updateMessageActions();
02063 updateFolderMenu();
02064 if (!aFolder)
02065 slotIntro();
02066 }
02067
02068
02069 void KMMainWidget::slotShowBusySplash()
02070 {
02071 if ( mReaderWindowActive )
02072 {
02073 mMsgView->displayBusyPage();
02074
02075 if ( mSearchAndHeaders && mHeaders && mLongFolderList )
02076 mSearchAndHeaders->hide();
02077 }
02078 }
02079
02080 void KMMainWidget::showOfflinePage()
02081 {
02082 if ( !mReaderWindowActive ) return;
02083 mShowingOfflineScreen = true;
02084
02085 mMsgView->displayOfflinePage();
02086
02087 if ( mSearchAndHeaders && mHeaders && mLongFolderList )
02088 mSearchAndHeaders->hide();
02089 }
02090
02091
02092 void KMMainWidget::slotMsgSelected(KMMessage *msg)
02093 {
02094 if ( msg && msg->parent() && !msg->isComplete() )
02095 {
02096 if ( msg->transferInProgress() )
02097 return;
02098 mMsgView->clear();
02099 mMsgView->setWaitingForSerNum( msg->getMsgSerNum() );
02100
02101 if ( mJob ) {
02102 disconnect( mJob, 0, mMsgView, 0 );
02103 delete mJob;
02104 }
02105 mJob = msg->parent()->createJob( msg, FolderJob::tGetMessage, 0,
02106 "STRUCTURE", mMsgView->attachmentStrategy() );
02107 connect(mJob, SIGNAL(messageRetrieved(KMMessage*)),
02108 mMsgView, SLOT(slotMessageArrived(KMMessage*)));
02109 mJob->start();
02110 } else {
02111 mMsgView->setMsg(msg);
02112 }
02113
02114 mMsgView->setHtmlOverride(mFolderHtmlPref);
02115 mMsgView->setHtmlLoadExtOverride(mFolderHtmlLoadExtPref);
02116 mMsgView->setDecryptMessageOverwrite( false );
02117 mMsgView->setShowSignatureDetails( false );
02118 }
02119
02120
02121 void KMMainWidget::slotMsgChanged()
02122 {
02123 mHeaders->msgChanged();
02124 }
02125
02126
02127 void KMMainWidget::slotSelectFolder(KMFolder* folder)
02128 {
02129 QListViewItem* item = mFolderTree->indexOfFolder(folder);
02130 if ( item ) {
02131 mFolderTree->ensureItemVisible( item );
02132 mFolderTree->doFolderSelected( item );
02133 }
02134 }
02135
02136
02137 void KMMainWidget::slotSelectMessage(KMMessage* msg)
02138 {
02139 int idx = mFolder->find(msg);
02140 if (idx != -1) {
02141 mHeaders->setCurrentMsg(idx);
02142 if (mMsgView)
02143 mMsgView->setMsg(msg);
02144 else
02145 slotMsgActivated(msg);
02146 }
02147 }
02148
02149
02150 void KMMainWidget::slotReplaceMsgByUnencryptedVersion()
02151 {
02152 kdDebug(5006) << "KMMainWidget::slotReplaceMsgByUnencryptedVersion()" << endl;
02153 KMMessage* oldMsg = mHeaders->currentMsg();
02154 if( oldMsg ) {
02155 kdDebug(5006) << "KMMainWidget - old message found" << endl;
02156 if( oldMsg->hasUnencryptedMsg() ) {
02157 kdDebug(5006) << "KMMainWidget - extra unencrypted message found" << endl;
02158 KMMessage* newMsg = oldMsg->unencryptedMsg();
02159
02160 {
02161 QString msgId( oldMsg->msgId() );
02162 QString prefix("DecryptedMsg.");
02163 int oldIdx = msgId.find(prefix, 0, false);
02164 if( -1 == oldIdx ) {
02165 int leftAngle = msgId.findRev( '<' );
02166 msgId = msgId.insert( (-1 == leftAngle) ? 0 : ++leftAngle, prefix );
02167 }
02168 else {
02169
02170
02171 QCharRef c = msgId[ oldIdx+2 ];
02172 if( 'C' == c )
02173 c = 'c';
02174 else
02175 c = 'C';
02176 }
02177 newMsg->setMsgId( msgId );
02178 mMsgView->setIdOfLastViewedMessage( msgId );
02179 }
02180
02181 kdDebug(5006) << "KMMainWidget - adding unencrypted message to folder" << endl;
02182 mFolder->addMsg( newMsg );
02183
02184
02185 int newMsgIdx = mFolder->find( newMsg );
02186 Q_ASSERT( newMsgIdx != -1 );
02187
02188 mFolder->unGetMsg( newMsgIdx );
02189 int idx = mFolder->find( oldMsg );
02190 Q_ASSERT( idx != -1 );
02191
02192
02193 mHeaders->setCurrentItemByIndex( newMsgIdx );
02194
02195 if ( idx != -1 ) {
02196 kdDebug(5006) << "KMMainWidget - deleting encrypted message" << endl;
02197 mFolder->take( idx );
02198 }
02199
02200 kdDebug(5006) << "KMMainWidget - updating message actions" << endl;
02201 updateMessageActions();
02202
02203 kdDebug(5006) << "KMMainWidget - done." << endl;
02204 } else
02205 kdDebug(5006) << "KMMainWidget - NO EXTRA UNENCRYPTED MESSAGE FOUND" << endl;
02206 } else
02207 kdDebug(5006) << "KMMainWidget - PANIC: NO OLD MESSAGE FOUND" << endl;
02208 }
02209
02210
02211 void KMMainWidget::slotSetThreadStatusNew()
02212 {
02213 mHeaders->setThreadStatus(KMMsgStatusNew);
02214 }
02215
02216
02217 void KMMainWidget::slotSetThreadStatusUnread()
02218 {
02219 mHeaders->setThreadStatus(KMMsgStatusUnread);
02220 }
02221
02222
02223 void KMMainWidget::slotSetThreadStatusFlag()
02224 {
02225 mHeaders->setThreadStatus(KMMsgStatusFlag, true);
02226 }
02227
02228
02229 void KMMainWidget::slotSetThreadStatusRead()
02230 {
02231 mHeaders->setThreadStatus(KMMsgStatusRead);
02232 }
02233
02234
02235 void KMMainWidget::slotSetThreadStatusTodo()
02236 {
02237 mHeaders->setThreadStatus(KMMsgStatusTodo, true);
02238 }
02239
02240
02241 void KMMainWidget::slotSetThreadStatusWatched()
02242 {
02243 mHeaders->setThreadStatus(KMMsgStatusWatched, true);
02244 if (mWatchThreadAction->isChecked()) {
02245 mIgnoreThreadAction->setChecked(false);
02246 }
02247 }
02248
02249
02250 void KMMainWidget::slotSetThreadStatusIgnored()
02251 {
02252 mHeaders->setThreadStatus(KMMsgStatusIgnored, true);
02253 if (mIgnoreThreadAction->isChecked()) {
02254 mWatchThreadAction->setChecked(false);
02255 }
02256 }
02257
02258
02259 void KMMainWidget::slotNextMessage() { mHeaders->nextMessage(); }
02260 void KMMainWidget::slotNextUnreadMessage()
02261 {
02262 if ( !mHeaders->nextUnreadMessage() )
02263 if ( GlobalSettings::self()->loopOnGotoUnread() == GlobalSettings::EnumLoopOnGotoUnread::LoopInAllFolders )
02264 mFolderTree->nextUnreadFolder(true);
02265 }
02266 void KMMainWidget::slotNextImportantMessage() {
02267
02268 }
02269 void KMMainWidget::slotPrevMessage() { mHeaders->prevMessage(); }
02270 void KMMainWidget::slotPrevUnreadMessage()
02271 {
02272 if ( !mHeaders->prevUnreadMessage() )
02273 if ( GlobalSettings::self()->loopOnGotoUnread() == GlobalSettings::EnumLoopOnGotoUnread::LoopInAllFolders )
02274 mFolderTree->prevUnreadFolder();
02275 }
02276 void KMMainWidget::slotPrevImportantMessage() {
02277
02278 }
02279
02280 void KMMainWidget::slotDisplayCurrentMessage()
02281 {
02282 if ( mHeaders->currentMsg() )
02283 slotMsgActivated( mHeaders->currentMsg() );
02284 }
02285
02286
02287 void KMMainWidget::slotMsgActivated(KMMessage *msg)
02288 {
02289 if ( !msg ) return;
02290 if ( msg->parent() && !msg->isComplete() ) {
02291 FolderJob *job = msg->parent()->createJob( msg );
02292 connect( job, SIGNAL( messageRetrieved( KMMessage* ) ),
02293 SLOT( slotMsgActivated( KMMessage* ) ) );
02294 job->start();
02295 return;
02296 }
02297
02298 if (kmkernel->folderIsDraftOrOutbox( mFolder ) ) {
02299 mMsgActions->editCurrentMessage();
02300 return;
02301 }
02302 if ( kmkernel->folderIsTemplates( mFolder ) ) {
02303 slotUseTemplate();
02304 return;
02305 }
02306
02307 assert( msg != 0 );
02308 KMReaderMainWin *win = new KMReaderMainWin( mFolderHtmlPref, mFolderHtmlLoadExtPref );
02309 KConfigGroup reader( KMKernel::config(), "Reader" );
02310 bool useFixedFont = mMsgView ? mMsgView->isFixedFont()
02311 : reader.readBoolEntry( "useFixedFont", false );
02312 win->setUseFixedFont( useFixedFont );
02313 KMMessage *newMessage = new KMMessage(*msg);
02314 newMessage->setParent( msg->parent() );
02315 newMessage->setMsgSerNum( msg->getMsgSerNum() );
02316 newMessage->setReadyToShow( true );
02317 win->showMsg( overrideEncoding(), newMessage );
02318 win->show();
02319 }
02320
02321
02322 void KMMainWidget::slotMarkAll()
02323 {
02324 mHeaders->selectAll( true );
02325 }
02326
02327
02328 void KMMainWidget::slotMsgPopup(KMMessage&, const KURL &aUrl, const QPoint& aPoint)
02329 {
02330 KPopupMenu * menu = new KPopupMenu;
02331 updateMessageMenu();
02332 mUrlCurrent = aUrl;
02333
02334 bool urlMenuAdded = false;
02335
02336 if (!aUrl.isEmpty())
02337 {
02338 if (aUrl.protocol() == "mailto")
02339 {
02340
02341 mMsgView->mailToComposeAction()->plug( menu );
02342 mMsgView->mailToReplyAction()->plug( menu );
02343 mMsgView->mailToForwardAction()->plug( menu );
02344
02345 menu->insertSeparator();
02346 mMsgView->addAddrBookAction()->plug( menu );
02347 mMsgView->openAddrBookAction()->plug( menu );
02348 mMsgView->copyURLAction()->plug( menu );
02349 mMsgView->startImChatAction()->plug( menu );
02350
02351 mMsgView->startImChatAction()->setEnabled( kmkernel->imProxy()->initialize() );
02352
02353 } else {
02354
02355 mMsgView->urlOpenAction()->plug( menu );
02356 mMsgView->addBookmarksAction()->plug( menu );
02357 mMsgView->urlSaveAsAction()->plug( menu );
02358 mMsgView->copyURLAction()->plug( menu );
02359 }
02360 if ( aUrl.protocol() == "im" )
02361 {
02362
02363
02364
02365 mMsgView->startImChatAction()->plug( menu );
02366 }
02367
02368 urlMenuAdded=true;
02369 kdDebug( 0 ) << k_funcinfo << " URL is: " << aUrl << endl;
02370 }
02371
02372
02373 if(mMsgView && !mMsgView->copyText().isEmpty()) {
02374 if ( urlMenuAdded )
02375 menu->insertSeparator();
02376 mMsgActions->replyMenu()->plug(menu);
02377 menu->insertSeparator();
02378
02379 mMsgView->copyAction()->plug( menu );
02380 mMsgView->selectAllAction()->plug( menu );
02381 } else if ( !urlMenuAdded )
02382 {
02383
02384
02385 if (!mHeaders->currentMsg())
02386 {
02387 delete menu;
02388 return;
02389 }
02390
02391
02392 if ( mFolder->isTemplates() ) {
02393 mUseAction->plug( menu );
02394 } else {
02395 mMsgActions->replyMenu()->plug( menu );
02396 mForwardActionMenu->plug( menu );
02397 }
02398 editAction()->plug(menu);
02399 menu->insertSeparator();
02400
02401 mCopyActionMenu->plug( menu );
02402 mMoveActionMenu->plug( menu );
02403
02404 menu->insertSeparator();
02405
02406 mMsgActions->messageStatusMenu()->plug( menu );
02407 menu->insertSeparator();
02408
02409 viewSourceAction()->plug(menu);
02410 if(mMsgView) {
02411 mMsgView->toggleFixFontAction()->plug(menu);
02412 }
02413 menu->insertSeparator();
02414 mPrintAction->plug( menu );
02415 mSaveAsAction->plug( menu );
02416 mSaveAttachmentsAction->plug( menu );
02417
02418 menu->insertSeparator();
02419 if( mFolder->isTrash() )
02420 mDeleteAction->plug( menu );
02421 else
02422 mTrashAction->plug( menu );
02423
02424 menu->insertSeparator();
02425 mMsgActions->createTodoAction()->plug( menu );
02426 }
02427 KAcceleratorManager::manage(menu);
02428 menu->exec(aPoint, 0);
02429 delete menu;
02430 }
02431
02432
02433 void KMMainWidget::getAccountMenu()
02434 {
02435 QStringList actList;
02436
02437 mActMenu->clear();
02438 actList = kmkernel->acctMgr()->getAccounts();
02439 QStringList::Iterator it;
02440 int id = 0;
02441 for(it = actList.begin(); it != actList.end() ; ++it, id++)
02442 mActMenu->insertItem((*it).replace("&", "&&"), id);
02443 }
02444
02445
02446 void KMMainWidget::getTransportMenu()
02447 {
02448 QStringList availTransports;
02449
02450 mSendMenu->clear();
02451 availTransports = KMail::TransportManager::transportNames();
02452 QStringList::Iterator it;
02453 int id = 0;
02454 for(it = availTransports.begin(); it != availTransports.end() ; ++it, id++)
02455 mSendMenu->insertItem((*it).replace("&", "&&"), id);
02456 }
02457
02458
02459 void KMMainWidget::updateCustomTemplateMenus()
02460 {
02461 if ( !mCustomTemplateActions.isEmpty() ) {
02462 QPtrList<KAction>::iterator ait = mCustomTemplateActions.begin();
02463 for ( ; ait != mCustomTemplateActions.end() ; ++ait ) {
02464 (*ait)->unplugAll();
02465 delete (*ait);
02466 }
02467 mCustomTemplateActions.clear();
02468 }
02469
02470 delete mCustomReplyActionMenu;
02471 delete mCustomReplyAllActionMenu;
02472 delete mCustomForwardActionMenu;
02473
02474 delete mCustomReplyMapper;
02475 delete mCustomReplyAllMapper;
02476 delete mCustomForwardMapper;
02477
02478 mCustomForwardActionMenu =
02479 new KActionMenu( i18n("Forward With Custom Template"),
02480 "mail_custom_forward",
02481 actionCollection(), "custom_forward" );
02482 QSignalMapper *mCustomForwardMapper = new QSignalMapper( this );
02483 connect( mCustomForwardMapper, SIGNAL( mapped( int ) ),
02484 this, SLOT( slotCustomForwardMsg( int ) ) );
02485 mForwardActionMenu->insert( mCustomForwardActionMenu );
02486
02487 mCustomReplyActionMenu =
02488 new KActionMenu( i18n("Reply With Custom Template"), "mail_custom_reply",
02489 actionCollection(), "custom_reply" );
02490 QSignalMapper *mCustomReplyMapper = new QSignalMapper( this );
02491 connect( mCustomReplyMapper, SIGNAL( mapped( int ) ),
02492 this, SLOT( slotCustomReplyToMsg( int ) ) );
02493 mMsgActions->replyMenu()->insert( mCustomReplyActionMenu );
02494
02495 mCustomReplyAllActionMenu =
02496 new KActionMenu( i18n("Reply to All With Custom Template"),
02497 "mail_custom_reply_all",
02498 actionCollection(), "custom_reply_all" );
02499 QSignalMapper *mCustomReplyAllMapper = new QSignalMapper( this );
02500 connect( mCustomReplyAllMapper, SIGNAL( mapped( int ) ),
02501 this, SLOT( slotCustomReplyAllToMsg( int ) ) );
02502 mMsgActions->replyMenu()->insert( mCustomReplyAllActionMenu );
02503
02504 mCustomTemplates.clear();
02505
02506 QStringList list = GlobalSettingsBase::self()->customTemplates();
02507 QStringList::iterator it = list.begin();
02508 int idx = 0;
02509 int replyc = 0;
02510 int replyallc = 0;
02511 int forwardc = 0;
02512 for ( ; it != list.end(); ++it ) {
02513 CTemplates t( *it );
02514 mCustomTemplates.append( *it );
02515
02516 KAction *action;
02517 switch ( t.type() ) {
02518 case CustomTemplates::TReply:
02519 action = new KAction( (*it).replace( "&", "&&" ),
02520 KShortcut( t.shortcut() ),
02521 mCustomReplyMapper,
02522 SLOT( map() ),
02523 actionCollection(),
02524 (*it).utf8() );
02525 mCustomReplyMapper->setMapping( action, idx );
02526 mCustomReplyActionMenu->insert( action, idx );
02527 mCustomTemplateActions.append( action );
02528 ++replyc;
02529 break;
02530 case CustomTemplates::TReplyAll:
02531 action = new KAction( (*it).replace( "&", "&&" ),
02532 KShortcut( t.shortcut() ),
02533 mCustomReplyAllMapper,
02534 SLOT( map() ),
02535 actionCollection(),
02536 (*it).utf8() );
02537 mCustomReplyAllMapper->setMapping( action, idx );
02538 mCustomReplyAllActionMenu->insert( action, idx );
02539 mCustomTemplateActions.append( action );
02540 ++replyallc;
02541 break;
02542 case CustomTemplates::TForward:
02543 action = new KAction( (*it).replace( "&", "&&" ),
02544 KShortcut( t.shortcut() ),
02545 mCustomForwardMapper,
02546 SLOT( map() ),
02547 actionCollection(),
02548 (*it).utf8() );
02549 mCustomForwardMapper->setMapping( action, idx );
02550 mCustomForwardActionMenu->insert( action, idx );
02551 mCustomTemplateActions.append( action );
02552 ++forwardc;
02553 break;
02554 case CustomTemplates::TUniversal:
02555 action = new KAction( (*it).replace( "&", "&&" ),
02556 KShortcut::null(),
02557 mCustomReplyMapper,
02558 SLOT( map() ),
02559 actionCollection(),
02560 (*it).utf8() );
02561 mCustomReplyMapper->setMapping( action, idx );
02562 mCustomReplyActionMenu->insert( action, idx );
02563 mCustomTemplateActions.append( action );
02564 ++replyc;
02565 action = new KAction( (*it).replace( "&", "&&" ),
02566 KShortcut::null(),
02567 mCustomReplyAllMapper,
02568 SLOT( map() ),
02569 actionCollection(),
02570 (*it).utf8() );
02571 mCustomReplyAllMapper->setMapping( action, idx );
02572 mCustomReplyAllActionMenu->insert( action, idx );
02573 mCustomTemplateActions.append( action );
02574 ++replyallc;
02575 action = new KAction( (*it).replace( "&", "&&" ),
02576 KShortcut::null(),
02577 mCustomForwardMapper,
02578 SLOT( map() ),
02579 actionCollection(),
02580 (*it).utf8() );
02581 mCustomForwardMapper->setMapping( action, idx );
02582 mCustomForwardActionMenu->insert( action, idx );
02583 mCustomTemplateActions.append( action );
02584 ++forwardc;
02585 break;
02586 }
02587
02588 ++idx;
02589 }
02590 if ( !replyc ) {
02591 mCustomReplyActionMenu->popupMenu()->insertItem( i18n( "(no custom templates)" ), 0 );
02592 mCustomReplyActionMenu->popupMenu()->setItemEnabled( 0, false );
02593 mCustomReplyActionMenu->setEnabled(false);
02594 }
02595 if ( !replyallc ) {
02596 mCustomReplyAllActionMenu->popupMenu()->insertItem( i18n( "(no custom templates)" ), 0 );
02597 mCustomReplyAllActionMenu->popupMenu()->setItemEnabled( 0, false );
02598 mCustomReplyAllActionMenu->setEnabled(false);
02599 }
02600 if ( !forwardc ) {
02601 mCustomForwardActionMenu->popupMenu()->insertItem( i18n( "(no custom templates)" ), 0 );
02602 mCustomForwardActionMenu->popupMenu()->setItemEnabled( 0, false );
02603 mCustomForwardActionMenu->setEnabled(false);
02604 }
02605
02606 }
02607
02608
02609
02610 void KMMainWidget::setupActions()
02611 {
02612 mMsgActions = new KMail::MessageActions( actionCollection(), this );
02613 mMsgActions->setMessageView( mMsgView );
02614
02615
02616 mSaveAsAction = new KAction( i18n("Save &As..."), "filesave",
02617 KStdAccel::shortcut(KStdAccel::Save),
02618 this, SLOT(slotSaveMsg()), actionCollection(), "file_save_as" );
02619
02620 mOpenAction = KStdAction::open( this, SLOT( slotOpenMsg() ),
02621 actionCollection() );
02622
02623 (void) new KAction( i18n("&Compact All Folders"), 0,
02624 this, SLOT(slotCompactAll()),
02625 actionCollection(), "compact_all_folders" );
02626
02627 (void) new KAction( i18n("&Expire All Folders"), 0,
02628 this, SLOT(slotExpireAll()),
02629 actionCollection(), "expire_all_folders" );
02630
02631 (void) new KAction( i18n("&Refresh Local IMAP Cache"), "refresh",
02632 this, SLOT(slotInvalidateIMAPFolders()),
02633 actionCollection(), "file_invalidate_imap_cache" );
02634
02635 (void) new KAction( i18n("Empty All &Trash Folders"), 0,
02636 KMKernel::self(), SLOT(slotEmptyTrash()),
02637 actionCollection(), "empty_trash" );
02638
02639 (void) new KAction( i18n("Check &Mail"), "mail_get", CTRL+Key_L,
02640 this, SLOT(slotCheckMail()),
02641 actionCollection(), "check_mail" );
02642
02643 mFavoritesCheckMailAction = new KAction( i18n("Check Mail in Favorite Folders"),
02644 "mail_get", CTRL+SHIFT+Key_L, 0, 0,
02645 actionCollection(), "favorite_check_mail" );
02646 if ( mFavoriteFolderView )
02647 connect( mFavoritesCheckMailAction, SIGNAL(activated()), mFavoriteFolderView, SLOT(checkMail()) );
02648
02649 KActionMenu *actActionMenu = new
02650 KActionMenu( i18n("Check Mail &In"), "mail_get", actionCollection(),
02651 "check_mail_in" );
02652 actActionMenu->setDelayed(true);
02653
02654 connect(actActionMenu,SIGNAL(activated()),this,SLOT(slotCheckMail()));
02655
02656 mActMenu = actActionMenu->popupMenu();
02657 connect(mActMenu,SIGNAL(activated(int)),this,SLOT(slotCheckOneAccount(int)));
02658 connect(mActMenu,SIGNAL(aboutToShow()),this,SLOT(getAccountMenu()));
02659
02660 (void) new KAction( i18n("&Send Queued Messages"), "mail_send", 0, this,
02661 SLOT(slotSendQueued()), actionCollection(), "send_queued");
02662
02663 (void) new KAction( i18n("Online Status (unknown)"), "online_status", 0, this,
02664 SLOT(slotOnlineStatus()), actionCollection(), "online_status");
02665
02666 KActionMenu *sendActionMenu = new
02667 KActionMenu( i18n("Send Queued Messages Via"), "mail_send_via", actionCollection(),
02668 "send_queued_via" );
02669 sendActionMenu->setDelayed(true);
02670
02671 mSendMenu = sendActionMenu->popupMenu();
02672 connect(mSendMenu,SIGNAL(activated(int)), this, SLOT(slotSendQueuedVia(int)));
02673 connect(mSendMenu,SIGNAL(aboutToShow()),this,SLOT(getTransportMenu()));
02674
02675 KAction *act;
02676
02677 if (parent()->inherits("KMMainWin")) {
02678 act = new KAction( i18n("&Address Book..."), "contents", 0, this,
02679 SLOT(slotAddrBook()), actionCollection(), "addressbook" );
02680 if (KStandardDirs::findExe("kaddressbook").isEmpty()) act->setEnabled(false);
02681 }
02682
02683 act = new KAction( i18n("Certificate Manager..."), "pgp-keys", 0, this,
02684 SLOT(slotStartCertManager()), actionCollection(), "tools_start_certman");
02685
02686 if (KStandardDirs::findExe("kleopatra").isEmpty()) act->setEnabled(false);
02687
02688 act = new KAction( i18n("GnuPG Log Viewer..."), "pgp-keys", 0, this,
02689 SLOT(slotStartWatchGnuPG()), actionCollection(), "tools_start_kwatchgnupg");
02690
02691 if (KStandardDirs::findExe("kwatchgnupg").isEmpty()) act->setEnabled(false);
02692
02693 act = new KAction( i18n("&Import Messages..."), "fileopen", 0, this,
02694 SLOT(slotImport()), actionCollection(), "import" );
02695 if (KStandardDirs::findExe("kmailcvt").isEmpty()) act->setEnabled(false);
02696
02697 #if !defined(NDEBUG)
02698 (void) new KAction( i18n("&Debug Sieve..."),
02699 "idea", 0, this, SLOT(slotDebugSieve()),
02700 actionCollection(), "tools_debug_sieve" );
02701 #endif
02702
02703 if ( GlobalSettings::allowOutOfOfficeSettings() ) {
02704 (void) new KAction( i18n("Edit \"Out of Office\" Replies..."),
02705 "configure", 0, this, SLOT(slotEditVacation()),
02706 actionCollection(), "tools_edit_vacation" );
02707
02708 }
02709
02710 (void) new KAction( i18n("Filter &Log Viewer..."), 0, this,
02711 SLOT(slotFilterLogViewer()), actionCollection(), "filter_log_viewer" );
02712
02713 (void) new KAction( i18n("&Anti-Spam Wizard..."), 0, this,
02714 SLOT(slotAntiSpamWizard()), actionCollection(), "antiSpamWizard" );
02715 (void) new KAction( i18n("&Anti-Virus Wizard..."), 0, this,
02716 SLOT(slotAntiVirusWizard()), actionCollection(), "antiVirusWizard" );
02717
02718
02719 mTrashAction = new KAction( KGuiItem( i18n("&Move to Trash"), "edittrash",
02720 i18n("Move message to trashcan") ),
02721 Key_Delete, this, SLOT(slotTrashMsg()),
02722 actionCollection(), "move_to_trash" );
02723
02724
02725
02726
02727
02728 mDeleteAction = new KAction( i18n("&Delete"), "editdelete", SHIFT+Key_Delete, this,
02729 SLOT(slotDeleteMsg()), actionCollection(), "delete" );
02730 mDeleteAction->plugAccel( actionCollection()->kaccel() );
02731
02732 mTrashThreadAction = new KAction( KGuiItem( i18n("M&ove Thread to Trash"), "edittrash",
02733 i18n("Move thread to trashcan") ),
02734 CTRL+Key_Delete, this, SLOT(slotTrashThread()),
02735 actionCollection(), "move_thread_to_trash" );
02736
02737 mDeleteThreadAction = new KAction( i18n("Delete T&hread"), "editdelete", CTRL+SHIFT+Key_Delete, this,
02738 SLOT(slotDeleteThread()), actionCollection(), "delete_thread" );
02739
02740
02741 (void) new KAction( i18n("&Find Messages..."), "mail_find", Key_S, this,
02742 SLOT(slotRequestFullSearchFromQuickSearch()), actionCollection(), "search_messages" );
02743
02744 mFindInMessageAction = new KAction( i18n("&Find in Message..."), "find", KStdAccel::shortcut(KStdAccel::Find), this,
02745 SLOT(slotFind()), actionCollection(), "find_in_messages" );
02746
02747 (void) new KAction( i18n("Select &All Messages"), KStdAccel::selectAll(), this,
02748 SLOT(slotMarkAll()), actionCollection(), "mark_all_messages" );
02749
02750
02751 mNewFolderAction = new KAction( i18n("&New Folder..."), "folder_new", 0, mFolderTree,
02752 SLOT(addChildFolder()), actionCollection(), "new_folder" );
02753
02754 mModifyFolderAction = new KAction( i18n("&Properties"), "configure", 0, this,
02755 SLOT(slotModifyFolder()), actionCollection(), "modify" );
02756
02757 mFolderMailingListPropertiesAction = new KAction( i18n("&Mailing List Management..."),
02758 0, this, SLOT( slotFolderMailingListProperties() ),
02759 actionCollection(), "folder_mailinglist_properties" );
02760
02761 mFolderShortCutCommandAction = new KAction( i18n("&Assign Shortcut..."), "configure_shortcuts",
02762 0, this, SLOT( slotFolderShortcutCommand() ), actionCollection(),
02763 "folder_shortcut_command" );
02764
02765
02766 mMarkAllAsReadAction = new KAction( i18n("Mark All Messages as &Read"), "goto", 0, this,
02767 SLOT(slotMarkAllAsRead()), actionCollection(), "mark_all_as_read" );
02768
02769 mExpireFolderAction = new KAction(i18n("&Expiration Settings"), 0, this, SLOT(slotExpireFolder()),
02770 actionCollection(), "expire");
02771
02772 mCompactFolderAction = new KAction( i18n("&Compact Folder"), 0, this,
02773 SLOT(slotCompactFolder()), actionCollection(), "compact" );
02774
02775 mRefreshFolderAction = new KAction( i18n("Check Mail &in This Folder"), "reload",
02776 KStdAccel::shortcut( KStdAccel::Reload ), this,
02777 SLOT(slotRefreshFolder()),
02778 actionCollection(), "refresh_folder" );
02779 mTroubleshootFolderAction = 0;
02780
02781 mEmptyFolderAction = new KAction( "foo" , "edittrash", 0, this,
02782 SLOT(slotEmptyFolder()), actionCollection(), "empty" );
02783
02784 mRemoveFolderAction = new KAction( "foo" , "editdelete", 0, this,
02785 SLOT(slotRemoveFolder()), actionCollection(), "delete_folder" );
02786
02787 mArchiveFolderAction = new KAction( i18n( "&Archive Folder..." ), "filesave", 0, this,
02788 SLOT( slotArchiveFolder() ), actionCollection(),
02789 "archive_folder" );
02790
02791 mPreferHtmlAction = new KToggleAction( i18n("Prefer &HTML to Plain Text"), 0, this,
02792 SLOT(slotOverrideHtml()), actionCollection(), "prefer_html" );
02793
02794 mPreferHtmlLoadExtAction = new KToggleAction( i18n("Load E&xternal References"), 0, this,
02795 SLOT(slotOverrideHtmlLoadExt()), actionCollection(), "prefer_html_external_refs" );
02796
02797 mThreadMessagesAction = new KToggleAction( i18n("&Thread Messages"), 0, this,
02798 SLOT(slotOverrideThread()), actionCollection(), "thread_messages" );
02799
02800 mThreadBySubjectAction = new KToggleAction( i18n("Thread Messages also by &Subject"), 0, this,
02801 SLOT(slotToggleSubjectThreading()), actionCollection(), "thread_messages_by_subject" );
02802
02803 new KAction( i18n("Copy Folder"), "editcopy", SHIFT+CTRL+Key_C, folderTree(),
02804 SLOT(copyFolder()), actionCollection(), "copy_folder" );
02805 new KAction( i18n("Cut Folder"), "editcut", SHIFT+CTRL+Key_X, folderTree(),
02806 SLOT(cutFolder()), actionCollection(), "cut_folder" );
02807 new KAction( i18n("Paste Folder"), "editpaste", SHIFT+CTRL+Key_V, folderTree(),
02808 SLOT(pasteFolder()), actionCollection(), "paste_folder" );
02809
02810 new KAction( i18n("Copy Messages"), "editcopy", ALT+CTRL+Key_C, headers(),
02811 SLOT(copyMessages()), actionCollection(), "copy_messages" );
02812 new KAction( i18n("Cut Messages"), "editcut", ALT+CTRL+Key_X, headers(),
02813 SLOT(cutMessages()), actionCollection(), "cut_messages" );
02814 new KAction( i18n("Paste Messages"), "editpaste", ALT+CTRL+Key_V, headers(),
02815 SLOT(pasteMessages()), actionCollection(), "paste_messages" );
02816
02817
02818 (void) new KAction( i18n("&New Message..."), "mail_new", KStdAccel::shortcut(KStdAccel::New), this,
02819 SLOT(slotCompose()), actionCollection(), "new_message" );
02820 mTemplateMenu =
02821 new KActionMenu( i18n("New Message From &Template"), "filenew",
02822 actionCollection(), "new_from_template" );
02823 mTemplateMenu->setDelayed( true );
02824 connect( mTemplateMenu->popupMenu(), SIGNAL( aboutToShow() ), this,
02825 SLOT( slotShowNewFromTemplate() ) );
02826 connect( mTemplateMenu->popupMenu(), SIGNAL( activated(int) ), this,
02827 SLOT( slotNewFromTemplate(int) ) );
02828
02829 KAction* newToML = new KAction( i18n("New Message t&o Mailing-List..."), "mail_post_to",
02830 CTRL+SHIFT+Key_N, this,
02831 SLOT(slotPostToML()), actionCollection(), "post_message" );
02832 newToML->plugAccel( actionCollection()->kaccel() );
02833
02834 mForwardActionMenu = new KActionMenu( i18n("Message->","&Forward"),
02835 "mail_forward", actionCollection(),
02836 "message_forward" );
02837
02838 mForwardInlineAction = new KAction( i18n("&Inline..."),
02839 "mail_forward", 0, this,
02840 SLOT(slotForwardInlineMsg()),
02841 actionCollection(),
02842 "message_forward_inline" );
02843
02844 mForwardAttachedAction = new KAction( i18n("Message->Forward->","As &Attachment..."),
02845 "mail_forward", 0, this,
02846 SLOT(slotForwardAttachedMsg()),
02847 actionCollection(),
02848 "message_forward_as_attachment" );
02849
02850 mForwardDigestAction = new KAction( i18n("Message->Forward->","As Di&gest..."),
02851 "mail_forward", 0, this,
02852 SLOT(slotForwardDigestMsg()),
02853 actionCollection(),
02854 "message_forward_as_digest" );
02855
02856 mRedirectAction = new KAction( i18n("Message->Forward->","&Redirect..."),
02857 "mail_forward", Key_E, this,
02858 SLOT(slotRedirectMsg()),
02859 actionCollection(),
02860 "message_forward_redirect" );
02861
02862
02863 setupForwardActions();
02864
02865 mForwardActionMenu->insert( mForwardDigestAction );
02866 mForwardActionMenu->insert( mRedirectAction );
02867
02868 mSendAgainAction = new KAction( i18n("Send A&gain..."), 0, this,
02869 SLOT(slotResendMsg()), actionCollection(), "send_again" );
02870
02871
02872
02873 mFilterMenu = new KActionMenu( i18n("&Create Filter"), "filter", actionCollection(), "create_filter" );
02874 connect( mFilterMenu, SIGNAL(activated()), this,
02875 SLOT(slotFilter()) );
02876 mSubjectFilterAction = new KAction( i18n("Filter on &Subject..."), 0, this,
02877 SLOT(slotSubjectFilter()),
02878 actionCollection(), "subject_filter");
02879 mFilterMenu->insert( mSubjectFilterAction );
02880
02881 mFromFilterAction = new KAction( i18n("Filter on &From..."), 0, this,
02882 SLOT(slotFromFilter()),
02883 actionCollection(), "from_filter");
02884 mFilterMenu->insert( mFromFilterAction );
02885
02886 mToFilterAction = new KAction( i18n("Filter on &To..."), 0, this,
02887 SLOT(slotToFilter()),
02888 actionCollection(), "to_filter");
02889 mFilterMenu->insert( mToFilterAction );
02890
02891 mListFilterAction = new KAction( i18n("Filter on Mailing-&List..."), 0, this,
02892 SLOT(slotMailingListFilter()), actionCollection(),
02893 "mlist_filter");
02894 mFilterMenu->insert( mListFilterAction );
02895
02896 mPrintAction = KStdAction::print (this, SLOT(slotPrintMsg()), actionCollection());
02897
02898 mUseAction = new KAction( i18n("New Message From &Template"), "filenew",
02899 Key_N, this, SLOT( slotUseTemplate() ),
02900 actionCollection(), "use_template" );
02901 mUseAction->plugAccel( actionCollection()->kaccel() );
02902
02903
02904 mThreadStatusMenu = new KActionMenu ( i18n( "Mark &Thread" ),
02905 actionCollection(), "thread_status" );
02906
02907 mMarkThreadAsReadAction = new KAction(KGuiItem(i18n("Mark Thread as &Read"), "kmmsgread",
02908 i18n("Mark all messages in the selected thread as read")),
02909 0, this, SLOT(slotSetThreadStatusRead()),
02910 actionCollection(), "thread_read");
02911 mThreadStatusMenu->insert( mMarkThreadAsReadAction );
02912
02913 mMarkThreadAsNewAction = new KAction(KGuiItem(i18n("Mark Thread as &New"), "kmmsgnew",
02914 i18n("Mark all messages in the selected thread as new")),
02915 0, this, SLOT(slotSetThreadStatusNew()),
02916 actionCollection(), "thread_new");
02917 mThreadStatusMenu->insert( mMarkThreadAsNewAction );
02918
02919 mMarkThreadAsUnreadAction = new KAction(KGuiItem(i18n("Mark Thread as &Unread"), "kmmsgunseen",
02920 i18n("Mark all messages in the selected thread as unread")),
02921 0, this, SLOT(slotSetThreadStatusUnread()),
02922 actionCollection(), "thread_unread");
02923 mThreadStatusMenu->insert( mMarkThreadAsUnreadAction );
02924
02925 mThreadStatusMenu->insert( new KActionSeparator( this ) );
02926
02927
02928 mToggleThreadFlagAction = new KToggleAction(i18n("Mark Thread as &Important"), "mail_flag",
02929 0, this, SLOT(slotSetThreadStatusFlag()),
02930 actionCollection(), "thread_flag");
02931 mToggleThreadFlagAction->setCheckedState( i18n("Remove &Important Thread Mark") );
02932 mThreadStatusMenu->insert( mToggleThreadFlagAction );
02933
02934 mToggleThreadTodoAction = new KToggleAction(i18n("Mark Thread as &Action Item"), "mail_todo",
02935 0, this, SLOT(slotSetThreadStatusTodo()),
02936 actionCollection(), "thread_todo");
02937 mToggleThreadTodoAction->setCheckedState( i18n("Remove &Action Item Thread Mark") );
02938 mThreadStatusMenu->insert( mToggleThreadTodoAction );
02939
02940
02941 mWatchThreadAction = new KToggleAction(i18n("&Watch Thread"), "kmmsgwatched",
02942 0, this, SLOT(slotSetThreadStatusWatched()),
02943 actionCollection(), "thread_watched");
02944
02945 mIgnoreThreadAction = new KToggleAction(i18n("&Ignore Thread"), "mail_ignore",
02946 0, this, SLOT(slotSetThreadStatusIgnored()),
02947 actionCollection(), "thread_ignored");
02948
02949 mThreadStatusMenu->insert( new KActionSeparator( this ) );
02950 mThreadStatusMenu->insert( mWatchThreadAction );
02951 mThreadStatusMenu->insert( mIgnoreThreadAction );
02952
02953 mSaveAttachmentsAction = new KAction( i18n("Save A&ttachments..."), "attach",
02954 0, this, SLOT(slotSaveAttachments()),
02955 actionCollection(), "file_save_attachments" );
02956
02957 mMoveActionMenu = new KActionMenu( i18n("&Move To" ),
02958 actionCollection(), "move_to" );
02959
02960 mCopyActionMenu = new KActionMenu( i18n("&Copy To" ),
02961 actionCollection(), "copy_to" );
02962
02963 mApplyAllFiltersAction = new KAction( i18n("Appl&y All Filters"), "filter",
02964 CTRL+Key_J, this,
02965 SLOT(slotApplyFilters()),
02966 actionCollection(), "apply_filters" );
02967
02968 mApplyFilterActionsMenu = new KActionMenu( i18n("A&pply Filter" ),
02969 actionCollection(),
02970 "apply_filter_actions" );
02971
02972
02973
02974 KActionMenu * unreadMenu =
02975 new KActionMenu( i18n("View->", "&Unread Count"),
02976 actionCollection(), "view_unread" );
02977 unreadMenu->setToolTip( i18n("Choose how to display the count of unread messages") );
02978
02979 mUnreadColumnToggle = new KRadioAction( i18n("View->Unread Count", "View in &Separate Column"), 0, this,
02980 SLOT(slotToggleUnread()),
02981 actionCollection(), "view_unread_column" );
02982 mUnreadColumnToggle->setExclusiveGroup( "view_unread_group" );
02983 unreadMenu->insert( mUnreadColumnToggle );
02984
02985 mUnreadTextToggle = new KRadioAction( i18n("View->Unread Count", "View After &Folder Name"), 0, this,
02986 SLOT(slotToggleUnread()),
02987 actionCollection(), "view_unread_text" );
02988 mUnreadTextToggle->setExclusiveGroup( "view_unread_group" );
02989 unreadMenu->insert( mUnreadTextToggle );
02990
02991
02992 mTotalColumnToggle = new KToggleAction( i18n("View->", "&Total Column"), 0, this,
02993 SLOT(slotToggleTotalColumn()),
02994 actionCollection(), "view_columns_total" );
02995 mTotalColumnToggle->setToolTip( i18n("Toggle display of column showing the "
02996 "total number of messages in folders.") );
02997 mSizeColumnToggle = new KToggleAction( i18n("View->", "&Size Column"), 0, this,
02998 SLOT(slotToggleSizeColumn()),
02999 actionCollection(), "view_columns_size" );
03000 mSizeColumnToggle->setToolTip( i18n("Toggle display of column showing the "
03001 "total size of messages in folders.") );
03002
03003 (void)new KAction( KGuiItem( i18n("View->","&Expand Thread"), QString::null,
03004 i18n("Expand the current thread") ),
03005 Key_Period, this,
03006 SLOT(slotExpandThread()),
03007 actionCollection(), "expand_thread" );
03008
03009 (void)new KAction( KGuiItem( i18n("View->","&Collapse Thread"), QString::null,
03010 i18n("Collapse the current thread") ),
03011 Key_Comma, this,
03012 SLOT(slotCollapseThread()),
03013 actionCollection(), "collapse_thread" );
03014
03015 (void)new KAction( KGuiItem( i18n("View->","Ex&pand All Threads"), QString::null,
03016 i18n("Expand all threads in the current folder") ),
03017 CTRL+Key_Period, this,
03018 SLOT(slotExpandAllThreads()),
03019 actionCollection(), "expand_all_threads" );
03020
03021 (void)new KAction( KGuiItem( i18n("View->","C&ollapse All Threads"), QString::null,
03022 i18n("Collapse all threads in the current folder") ),
03023 CTRL+Key_Comma, this,
03024 SLOT(slotCollapseAllThreads()),
03025 actionCollection(), "collapse_all_threads" );
03026
03027 mViewSourceAction = new KAction( i18n("&View Source"), Key_V, this,
03028 SLOT(slotShowMsgSrc()), actionCollection(),
03029 "view_source" );
03030
03031 KAction* dukeOfMonmoth = new KAction( i18n("&Display Message"), Key_Return, this,
03032 SLOT( slotDisplayCurrentMessage() ), actionCollection(),
03033 "display_message" );
03034 dukeOfMonmoth->plugAccel( actionCollection()->kaccel() );
03035
03036
03037 new KAction( KGuiItem( i18n("&Next Message"), QString::null,
03038 i18n("Go to the next message") ),
03039 "N;Right", this, SLOT(slotNextMessage()),
03040 actionCollection(), "go_next_message" );
03041
03042 new KAction( KGuiItem( i18n("Next &Unread Message"),
03043 QApplication::reverseLayout() ? "previous" : "next",
03044 i18n("Go to the next unread message") ),
03045 Key_Plus, this, SLOT(slotNextUnreadMessage()),
03046 actionCollection(), "go_next_unread_message" );
03047
03048
03049
03050
03051
03052
03053
03054
03055 new KAction( KGuiItem( i18n("&Previous Message"), QString::null,
03056 i18n("Go to the previous message") ),
03057 "P;Left", this, SLOT(slotPrevMessage()),
03058 actionCollection(), "go_prev_message" );
03059
03060 new KAction( KGuiItem( i18n("Previous Unread &Message"),
03061 QApplication::reverseLayout() ? "next" : "previous",
03062 i18n("Go to the previous unread message") ),
03063 Key_Minus, this, SLOT(slotPrevUnreadMessage()),
03064 actionCollection(), "go_prev_unread_message" );
03065
03066
03067
03068
03069
03070
03071
03072
03073 KAction *action =
03074 new KAction( KGuiItem( i18n("Next Unread &Folder"), QString::null,
03075 i18n("Go to the next folder with unread messages") ),
03076 ALT+Key_Plus, this, SLOT(slotNextUnreadFolder()),
03077 actionCollection(), "go_next_unread_folder" );
03078 KShortcut shortcut = action->shortcut();
03079 shortcut.append( KKey( CTRL+Key_Plus ) );
03080 action->setShortcut( shortcut );
03081
03082 action =
03083 new KAction( KGuiItem( i18n("Previous Unread F&older"), QString::null,
03084 i18n("Go to the previous folder with unread messages") ),
03085 ALT+Key_Minus, this, SLOT(slotPrevUnreadFolder()),
03086 actionCollection(), "go_prev_unread_folder" );
03087 shortcut = action->shortcut();
03088 shortcut.append( KKey( CTRL+Key_Minus ) );
03089 action->setShortcut( shortcut );
03090
03091 new KAction( KGuiItem( i18n("Go->","Next Unread &Text"), QString::null,
03092 i18n("Go to the next unread text"),
03093 i18n("Scroll down current message. "
03094 "If at end of current message, "
03095 "go to next unread message.") ),
03096 Key_Space, this, SLOT(slotReadOn()),
03097 actionCollection(), "go_next_unread_text" );
03098
03099
03100 mToggleShowQuickSearchAction = new KToggleAction(i18n("Show Quick Search"), QString::null,
03101 0, this, SLOT(slotToggleShowQuickSearch()),
03102 actionCollection(), "show_quick_search");
03103 mToggleShowQuickSearchAction->setChecked( GlobalSettings::self()->quickSearchActive() );
03104 mToggleShowQuickSearchAction->setWhatsThis(
03105 i18n( GlobalSettings::self()->quickSearchActiveItem()->whatsThis().utf8() ) );
03106
03107 (void) new KAction( i18n("Configure &Filters..."), 0, this,
03108 SLOT(slotFilter()), actionCollection(), "filter" );
03109 (void) new KAction( i18n("Configure &POP Filters..."), 0, this,
03110 SLOT(slotPopFilter()), actionCollection(), "popFilter" );
03111 (void) new KAction( i18n("Manage &Sieve Scripts..."), 0, this,
03112 SLOT(slotManageSieveScripts()), actionCollection(), "sieveFilters" );
03113
03114 (void) new KAction( KGuiItem( i18n("KMail &Introduction"), 0,
03115 i18n("Display KMail's Welcome Page") ),
03116 0, this, SLOT(slotIntro()),
03117 actionCollection(), "help_kmail_welcomepage" );
03118
03119
03120
03121 (void) new KAction( i18n("Configure &Notifications..."),
03122 "knotify", 0, this,
03123 SLOT(slotEditNotifications()), actionCollection(),
03124 "kmail_configure_notifications" );
03125
03126 (void) new KAction( i18n("&Configure KMail..."),
03127 "configure", 0, kmkernel,
03128 SLOT(slotShowConfigurationDialog()), actionCollection(),
03129 "kmail_configure_kmail" );
03130
03131 KStdAction::undo(this, SLOT(slotUndo()), actionCollection(), "kmail_undo");
03132
03133 KStdAction::tipOfDay( this, SLOT( slotShowTip() ), actionCollection() );
03134
03135 menutimer = new QTimer( this, "menutimer" );
03136 connect( menutimer, SIGNAL( timeout() ), SLOT( updateMessageActions() ) );
03137 connect( kmkernel->undoStack(),
03138 SIGNAL( undoStackChanged() ), this, SLOT( slotUpdateUndo() ));
03139
03140 initializeIMAPActions( false );
03141 updateMessageActions();
03142 updateCustomTemplateMenus();
03143 updateFolderMenu();
03144 }
03145
03146 void KMMainWidget::setupForwardingActionsList()
03147 {
03148 QPtrList<KAction> mForwardActionList;
03149 if ( GlobalSettings::self()->forwardingInlineByDefault() ) {
03150 mGUIClient->unplugActionList( "forward_action_list" );
03151 mForwardActionList.append( mForwardInlineAction );
03152 mForwardActionList.append( mForwardAttachedAction );
03153 mForwardActionList.append( mForwardDigestAction );
03154 mForwardActionList.append( mRedirectAction );
03155 mGUIClient->plugActionList( "forward_action_list", mForwardActionList );
03156 } else {
03157 mGUIClient->unplugActionList( "forward_action_list" );
03158 mForwardActionList.append( mForwardAttachedAction );
03159 mForwardActionList.append( mForwardInlineAction );
03160 mForwardActionList.append( mForwardDigestAction );
03161 mForwardActionList.append( mRedirectAction );
03162 mGUIClient->plugActionList( "forward_action_list", mForwardActionList );
03163 }
03164 }
03165
03166
03167 void KMMainWidget::slotEditNotifications()
03168 {
03169 if(kmkernel->xmlGuiInstance())
03170 KNotifyDialog::configure(this, 0, kmkernel->xmlGuiInstance()->aboutData());
03171 else
03172 KNotifyDialog::configure(this);
03173 }
03174
03175 void KMMainWidget::slotEditKeys()
03176 {
03177 KKeyDialog::configure( actionCollection(),
03178 true
03179 );
03180 }
03181
03182
03183 void KMMainWidget::slotReadOn()
03184 {
03185 if ( !mMsgView )
03186 return;
03187
03188 if ( !mMsgView->atBottom() ) {
03189 mMsgView->slotJumpDown();
03190 return;
03191 }
03192 slotNextUnreadMessage();
03193 }
03194
03195 void KMMainWidget::slotNextUnreadFolder() {
03196 if ( !mFolderTree ) return;
03197 mFolderTree->nextUnreadFolder();
03198 }
03199
03200 void KMMainWidget::slotPrevUnreadFolder() {
03201 if ( !mFolderTree ) return;
03202 mFolderTree->prevUnreadFolder();
03203 }
03204
03205 void KMMainWidget::slotExpandThread()
03206 {
03207 mHeaders->slotExpandOrCollapseThread( true );
03208 }
03209
03210 void KMMainWidget::slotCollapseThread()
03211 {
03212 mHeaders->slotExpandOrCollapseThread( false );
03213 }
03214
03215 void KMMainWidget::slotExpandAllThreads()
03216 {
03217 mHeaders->slotExpandOrCollapseAllThreads( true );
03218 }
03219
03220 void KMMainWidget::slotCollapseAllThreads()
03221 {
03222 mHeaders->slotExpandOrCollapseAllThreads( false );
03223 }
03224
03225
03226 void KMMainWidget::slotShowMsgSrc()
03227 {
03228 if ( mMsgView )
03229 mMsgView->setUpdateAttachment( false );
03230 KMMessage *msg = mHeaders->currentMsg();
03231 if ( !msg )
03232 return;
03233 KMCommand *command = new KMShowMsgSrcCommand( this, msg,
03234 mMsgView
03235 ? mMsgView->isFixedFont()
03236 : false );
03237 command->start();
03238 }
03239
03240
03241
03242 void KMMainWidget::moveSelectedToFolder( int menuId )
03243 {
03244 if (mMenuToFolder[menuId])
03245 mHeaders->moveMsgToFolder( mMenuToFolder[menuId] );
03246 }
03247
03248
03249
03250 void KMMainWidget::copySelectedToFolder(int menuId )
03251 {
03252 if (mMenuToFolder[menuId])
03253 mHeaders->copyMsgToFolder( mMenuToFolder[menuId] );
03254 }
03255
03256
03257
03258 void KMMainWidget::updateMessageMenu()
03259 {
03260 mMenuToFolder.clear();
03261 folderTree()->folderToPopupMenu( KMFolderTree::MoveMessage, this,
03262 &mMenuToFolder, mMoveActionMenu->popupMenu() );
03263 folderTree()->folderToPopupMenu( KMFolderTree::CopyMessage, this,
03264 &mMenuToFolder, mCopyActionMenu->popupMenu() );
03265 updateMessageActions();
03266 }
03267
03268 void KMMainWidget::startUpdateMessageActionsTimer()
03269 {
03270 menutimer->stop();
03271 menutimer->start( 20, true );
03272 }
03273
03274 void KMMainWidget::updateMessageActions()
03275 {
03276 int count = 0;
03277 QPtrList<QListViewItem> selectedItems;
03278
03279 if ( mFolder ) {
03280 for (QListViewItem *item = mHeaders->firstChild(); item; item = item->itemBelow())
03281 if (item->isSelected() )
03282 selectedItems.append(item);
03283 if ( selectedItems.isEmpty() && mFolder->count() )
03284 count = 1;
03285 else
03286 count = selectedItems.count();
03287 mMsgActions->setCurrentMessage( mHeaders->currentMsg() );
03288 mMsgActions->setSelectedSernums( mHeaders->selectedSernums() );
03289 mMsgActions->setSelectedVisibleSernums( mHeaders->selectedVisibleSernums() );
03290 } else {
03291 mMsgActions->setCurrentMessage( 0 );
03292 }
03293
03294 updateListFilterAction();
03295
03296 bool allSelectedInCommonThread = false;
03297 if ( mHeaders->isThreaded() && count > 1 ) {
03298 allSelectedInCommonThread = true;
03299 for ( QPtrListIterator<QListViewItem> it( selectedItems ) ;
03300 it.current() ; ++ it ) {
03301 QListViewItem * item = *it;
03302 if ( item->parent()==0 && item->childCount()==0 ) {
03303 allSelectedInCommonThread = false;
03304 break;
03305 }
03306 }
03307 }
03308 else if ( mHeaders->isThreaded() && count == 1 ) {
03309 allSelectedInCommonThread = true;
03310 }
03311
03312 QListViewItem *curItemParent = mHeaders->currentItem();
03313 bool parent_thread = 0;
03314 if ( curItemParent && curItemParent->firstChild() != 0 ) parent_thread = 1;
03315
03316 bool mass_actions = count >= 1;
03317 bool thread_actions = mass_actions && allSelectedInCommonThread &&
03318 mHeaders->isThreaded();
03319 bool flags_available = GlobalSettings::self()->allowLocalFlags() || !(mFolder ? mFolder->isReadOnly() : true);
03320 mThreadStatusMenu->setEnabled( thread_actions );
03321
03322
03323 mWatchThreadAction->setEnabled( thread_actions && flags_available );
03324 mIgnoreThreadAction->setEnabled( thread_actions && flags_available );
03325 mMarkThreadAsNewAction->setEnabled( thread_actions );
03326 mMarkThreadAsReadAction->setEnabled( thread_actions );
03327 mMarkThreadAsUnreadAction->setEnabled( thread_actions );
03328 mToggleThreadTodoAction->setEnabled( thread_actions && flags_available );
03329 mToggleThreadFlagAction->setEnabled( thread_actions && flags_available );
03330 mTrashThreadAction->setEnabled( thread_actions && mFolder->canDeleteMessages() );
03331 mDeleteThreadAction->setEnabled( thread_actions && mFolder->canDeleteMessages() );
03332
03333 if (mFolder && mHeaders && mHeaders->currentMsg()) {
03334 if (thread_actions) {
03335 mToggleThreadTodoAction->setChecked(mHeaders->currentMsg()->isTodo());
03336 mToggleThreadFlagAction->setChecked(mHeaders->currentMsg()->isImportant());
03337 mWatchThreadAction->setChecked( mHeaders->currentMsg()->isWatched());
03338 mIgnoreThreadAction->setChecked( mHeaders->currentMsg()->isIgnored());
03339 }
03340 }
03341
03342 mMoveActionMenu->setEnabled( mass_actions && mFolder->canDeleteMessages() );
03343 mMoveMsgToFolderAction->setEnabled( mass_actions && mFolder->canDeleteMessages() );
03344 mCopyActionMenu->setEnabled( mass_actions );
03345 mTrashAction->setEnabled( mass_actions && mFolder->canDeleteMessages() );
03346 mDeleteAction->setEnabled( mass_actions && mFolder->canDeleteMessages() );
03347 mFindInMessageAction->setEnabled( mass_actions && !kmkernel->folderIsTemplates( mFolder ) );
03348 mForwardInlineAction->setEnabled( mass_actions && !kmkernel->folderIsTemplates( mFolder ));
03349 mForwardAttachedAction->setEnabled( mass_actions && !kmkernel->folderIsTemplates( mFolder ) );
03350 mForwardDigestAction->setEnabled( ( count > 1 || parent_thread ) && !kmkernel->folderIsTemplates( mFolder ) );
03351
03352 forwardMenu()->setEnabled( mass_actions && !kmkernel->folderIsTemplates( mFolder ));
03353
03354 bool single_actions = count == 1;
03355 mUseAction->setEnabled( single_actions &&
03356 kmkernel->folderIsTemplates( mFolder ) );
03357 filterMenu()->setEnabled( single_actions );
03358 redirectAction()->setEnabled( single_actions && !kmkernel->folderIsTemplates( mFolder ) );
03359 printAction()->setEnabled( single_actions );
03360 viewSourceAction()->setEnabled( single_actions );
03361
03362 mSendAgainAction->setEnabled( single_actions
03363 && ( ( mHeaders->currentMsg() && mHeaders->currentMsg()->isSent() )
03364 || ( mFolder && mHeaders->currentMsg() &&
03365 kmkernel->folderIsSentMailFolder( mFolder ) ) ) );
03366 mSaveAsAction->setEnabled( mass_actions );
03367 bool mails = mFolder && mFolder->count();
03368 bool enable_goto_unread = mails
03369 || (GlobalSettings::self()->loopOnGotoUnread() == GlobalSettings::EnumLoopOnGotoUnread::LoopInAllFolders);
03370 actionCollection()->action( "go_next_message" )->setEnabled( mails );
03371 actionCollection()->action( "go_next_unread_message" )->setEnabled( enable_goto_unread );
03372 actionCollection()->action( "go_prev_message" )->setEnabled( mails );
03373 actionCollection()->action( "go_prev_unread_message" )->setEnabled( enable_goto_unread );
03374 actionCollection()->action( "send_queued" )->setEnabled( kmkernel->outboxFolder()->count() > 0 );
03375 actionCollection()->action( "send_queued_via" )->setEnabled( kmkernel->outboxFolder()->count() > 0 );
03376 slotUpdateOnlineStatus( static_cast<GlobalSettingsBase::EnumNetworkState::type>( GlobalSettings::self()->networkState() ) );
03377 if (action( "edit_undo" ))
03378 action( "edit_undo" )->setEnabled( mHeaders->canUndo() );
03379
03380 if ( count == 1 ) {
03381 KMMessage *msg;
03382 int aIdx;
03383 if((aIdx = mHeaders->currentItemIndex()) <= -1)
03384 return;
03385 if(!(msg = mFolder->getMsg(aIdx)))
03386 return;
03387
03388 if ((KMFolder*)mFolder == kmkernel->outboxFolder())
03389 editAction()->setEnabled( !msg->transferInProgress() );
03390 }
03391
03392 mApplyAllFiltersAction->setEnabled(count);
03393 mApplyFilterActionsMenu->setEnabled(count);
03394 }
03395
03396
03397 void KMMainWidget::updateMarkAsReadAction()
03398 {
03399 mMarkAllAsReadAction->setEnabled( mFolder && (mFolder->countUnread() > 0) );
03400 }
03401
03402
03403 void KMMainWidget::updateFolderMenu()
03404 {
03405 bool folderWithContent = mFolder && !mFolder->noContent();
03406 bool multiFolder = folderTree()->selectedFolders().count() > 1;
03407 mModifyFolderAction->setEnabled( folderWithContent && !multiFolder );
03408 mFolderMailingListPropertiesAction->setEnabled( folderWithContent && !multiFolder );
03409 mCompactFolderAction->setEnabled( folderWithContent && !multiFolder );
03410
03411
03412 bool imap = mFolder && mFolder->folderType() == KMFolderTypeImap;
03413 bool cachedImap = mFolder && mFolder->folderType() == KMFolderTypeCachedImap;
03414
03415 bool knownImapPath = cachedImap && !static_cast<KMFolderCachedImap*>( mFolder->storage() )->imapPath().isEmpty();
03416 mRefreshFolderAction->setEnabled( folderWithContent && ( imap
03417 || ( cachedImap && knownImapPath ) ) && !multiFolder );
03418 if ( mTroubleshootFolderAction )
03419 mTroubleshootFolderAction->setEnabled( folderWithContent && ( cachedImap && knownImapPath ) && !multiFolder );
03420
03421 mEmptyFolderAction->setEnabled( folderWithContent &&
03422 ( mFolder->count() > 0 ) && mFolder->canDeleteMessages() &&
03423 !multiFolder );
03424 mEmptyFolderAction->setText( ( mFolder && kmkernel->folderIsTrash( mFolder ) ) ?
03425 i18n( "E&mpty Trash" ) :
03426 i18n( "&Move All Messages to Trash" ) );
03427
03428 mRemoveFolderAction->setEnabled( mFolder &&
03429 !mFolder->isSystemFolder() &&
03430 mFolder->canDeleteMessages() &&
03431 !multiFolder && !mFolder->noContent() );
03432 mRemoveFolderAction->setText( mFolder &&
03433 mFolder->folderType() == KMFolderTypeSearch ?
03434 i18n( "&Delete Search" ) :
03435 i18n( "&Delete Folder" ) );
03436
03437 if ( mArchiveFolderAction )
03438 mArchiveFolderAction->setEnabled( mFolder && !multiFolder );
03439 mExpireFolderAction->setEnabled( mFolder && mFolder->isAutoExpire() && !multiFolder && mFolder->canDeleteMessages() );
03440 updateMarkAsReadAction();
03441
03442 mPreferHtmlAction->setEnabled( mHeaders->folder() ? true : false );
03443 mPreferHtmlLoadExtAction->setEnabled( mHeaders->folder() && (mHtmlPref ? !mFolderHtmlPref : mFolderHtmlPref) ? true : false );
03444 mThreadMessagesAction->setEnabled( mHeaders->folder() ? true : false );
03445
03446 mPreferHtmlAction->setChecked( mHtmlPref ? !mFolderHtmlPref : mFolderHtmlPref );
03447 mPreferHtmlLoadExtAction->setChecked( mHtmlLoadExtPref ? !mFolderHtmlLoadExtPref : mFolderHtmlLoadExtPref );
03448 mThreadMessagesAction->setChecked(
03449 mThreadPref ? !mFolderThreadPref : mFolderThreadPref );
03450 mThreadBySubjectAction->setEnabled(
03451 mHeaders->folder() ? ( mThreadMessagesAction->isChecked()) : false );
03452 mThreadBySubjectAction->setChecked( mFolderThreadSubjPref );
03453
03454 mNewFolderAction->setEnabled( !multiFolder && ( mFolder && mFolder->folderType() != KMFolderTypeSearch ));
03455 mRemoveDuplicatesAction->setEnabled( !multiFolder && mFolder && mFolder->canDeleteMessages() );
03456 mFolderShortCutCommandAction->setEnabled( !multiFolder );
03457 }
03458
03459
03460 #ifdef MALLOC_DEBUG
03461 static QString fmt(long n) {
03462 char buf[32];
03463
03464 if(n > 1024*1024*1024)
03465 sprintf(buf, "%0.2f GB", ((double)n)/1024.0/1024.0/1024.0);
03466 else if(n > 1024*1024)
03467 sprintf(buf, "%0.2f MB", ((double)n)/1024.0/1024.0);
03468 else if(n > 1024)
03469 sprintf(buf, "%0.2f KB", ((double)n)/1024.0);
03470 else
03471 sprintf(buf, "%ld Byte", n);
03472 return QString(buf);
03473 }
03474 #endif
03475
03476 void KMMainWidget::slotMemInfo() {
03477 #ifdef MALLOC_DEBUG
03478 struct mallinfo mi;
03479
03480 mi = mallinfo();
03481 QString s = QString("\nMALLOC - Info\n\n"
03482 "Number of mmapped regions : %1\n"
03483 "Memory allocated in use : %2\n"
03484 "Memory allocated, not used: %3\n"
03485 "Memory total allocated : %4\n"
03486 "Max. freeable memory : %5\n")
03487 .arg(mi.hblks).arg(fmt(mi.uordblks)).arg(fmt(mi.fordblks))
03488 .arg(fmt(mi.arena)).arg(fmt(mi.keepcost));
03489 KMessageBox::information(0, s, "Malloc information", s);
03490 #endif
03491 }
03492
03493
03494
03495 void KMMainWidget::slotIntro()
03496 {
03497 if ( !mMsgView ) return;
03498
03499 mMsgView->clear( true );
03500
03501 if ( mSearchAndHeaders && mHeaders && mLongFolderList )
03502 mSearchAndHeaders->hide();
03503
03504
03505 mMsgView->displayAboutPage();
03506
03507 mFolder = 0;
03508 }
03509
03510 void KMMainWidget::slotShowStartupFolder()
03511 {
03512 if ( mFolderTree ) {
03513 mFolderTree->reload();
03514 mFolderTree->readConfig();
03515
03516 mFolderTree->cleanupConfigFile();
03517 }
03518
03519 connect( kmkernel->filterMgr(), SIGNAL( filterListUpdated() ),
03520 this, SLOT( initializeFilterActions() ));
03521
03522
03523 initializeFilterActions();
03524
03525
03526 initializeFolderShortcutActions();
03527
03528 QString newFeaturesMD5 = KMReaderWin::newFeaturesMD5();
03529 if ( kmkernel->firstStart() ||
03530 GlobalSettings::self()->previousNewFeaturesMD5() != newFeaturesMD5 ) {
03531 GlobalSettings::self()->setPreviousNewFeaturesMD5( newFeaturesMD5 );
03532 slotIntro();
03533 return;
03534 }
03535
03536 KMFolder* startup = 0;
03537 if ( !mStartupFolder.isEmpty() ) {
03538
03539 startup = kmkernel->findFolderById( mStartupFolder );
03540 }
03541 if ( !startup )
03542 startup = kmkernel->inboxFolder();
03543
03544 if ( mFolderTree ) {
03545 mFolderTree->showFolder( startup );
03546 }
03547 }
03548
03549 void KMMainWidget::slotShowTip()
03550 {
03551 KTipDialog::showTip( this, QString::null, true );
03552 }
03553
03554
03555 void KMMainWidget::slotChangeCaption(QListViewItem * i)
03556 {
03557 if ( !i ) return;
03558
03559 QStringList names;
03560 for ( QListViewItem * item = i ; item ; item = item->parent() )
03561 names.prepend( item->text(0) );
03562 emit captionChangeRequest( names.join( "/" ) );
03563 }
03564
03565
03566 void KMMainWidget::removeDuplicates()
03567 {
03568 if (!mFolder)
03569 return;
03570 KMFolder *oFolder = mFolder;
03571 mHeaders->setFolder(0);
03572 QMap< QString, QValueList<int> > idMD5s;
03573 QValueList<int> redundantIds;
03574 QValueList<int>::Iterator kt;
03575 mFolder->open("removedups");
03576 for (int i = mFolder->count() - 1; i >= 0; --i) {
03577 QString id = (*mFolder)[i]->msgIdMD5();
03578 if ( !id.isEmpty() ) {
03579 QString subjMD5 = (*mFolder)[i]->strippedSubjectMD5();
03580 int other = -1;
03581 if ( idMD5s.contains(id) )
03582 other = idMD5s[id].first();
03583 else
03584 idMD5s[id].append( i );
03585 if ( other != -1 ) {
03586 QString otherSubjMD5 = (*mFolder)[other]->strippedSubjectMD5();
03587 if (otherSubjMD5 == subjMD5)
03588 idMD5s[id].append( i );
03589 }
03590 }
03591 }
03592 QMap< QString, QValueList<int> >::Iterator it;
03593 for ( it = idMD5s.begin(); it != idMD5s.end() ; ++it ) {
03594 QValueList<int>::Iterator jt;
03595 bool finished = false;
03596 for ( jt = (*it).begin(); jt != (*it).end() && !finished; ++jt )
03597 if (!((*mFolder)[*jt]->isUnread())) {
03598 (*it).remove( jt );
03599 (*it).prepend( *jt );
03600 finished = true;
03601 }
03602 for ( jt = (*it).begin(), ++jt; jt != (*it).end(); ++jt )
03603 redundantIds.append( *jt );
03604 }
03605 qHeapSort( redundantIds );
03606 kt = redundantIds.end();
03607 int numDuplicates = 0;
03608 if (kt != redundantIds.begin()) do {
03609 mFolder->removeMsg( *(--kt) );
03610 ++numDuplicates;
03611 }
03612 while (kt != redundantIds.begin());
03613
03614 mFolder->close("removedups");
03615 mHeaders->setFolder(oFolder);
03616 QString msg;
03617 if ( numDuplicates )
03618 msg = i18n("Removed %n duplicate message.",
03619 "Removed %n duplicate messages.", numDuplicates );
03620 else
03621 msg = i18n("No duplicate messages found.");
03622 BroadcastStatus::instance()->setStatusMsg( msg );
03623 }
03624
03625
03626
03627 void KMMainWidget::slotUpdateUndo()
03628 {
03629 if (actionCollection()->action( "edit_undo" ))
03630 actionCollection()->action( "edit_undo" )->setEnabled( mHeaders->canUndo() );
03631 }
03632
03633
03634
03635 void KMMainWidget::clearFilterActions()
03636 {
03637 if ( !mFilterTBarActions.isEmpty() ) {
03638 if ( mGUIClient->factory() )
03639 mGUIClient->unplugActionList( "toolbar_filter_actions" );
03640 mFilterTBarActions.clear();
03641 }
03642 mApplyFilterActionsMenu->popupMenu()->clear();
03643 if ( !mFilterMenuActions.isEmpty() ) {
03644 if ( mGUIClient->factory() )
03645 mGUIClient->unplugActionList( "menu_filter_actions" );
03646 mFilterMenuActions.clear();
03647 }
03648 mFilterCommands.clear();
03649 }
03650
03651
03652 void KMMainWidget::initializeFolderShortcutActions()
03653 {
03654
03655
03656
03657
03658 bool old = actionCollection()->isAutoConnectShortcuts();
03659
03660 actionCollection()->setAutoConnectShortcuts( true );
03661 QValueList< QGuardedPtr< KMFolder > > folders = kmkernel->allFolders();
03662 QValueList< QGuardedPtr< KMFolder > >::Iterator it = folders.begin();
03663 while ( it != folders.end() ) {
03664 KMFolder *folder = (*it);
03665 ++it;
03666 slotShortcutChanged( folder );
03667 }
03668 actionCollection()->setAutoConnectShortcuts( old );
03669 }
03670
03671
03672
03673 void KMMainWidget::initializeFilterActions()
03674 {
03675 QString filterName, normalizedName;
03676 KMMetaFilterActionCommand *filterCommand;
03677 KAction *filterAction = 0;
03678
03679 clearFilterActions();
03680 mApplyAllFiltersAction->plug(mApplyFilterActionsMenu->popupMenu());
03681 bool addedSeparator = false;
03682 QValueListConstIterator<KMFilter*> it = kmkernel->filterMgr()->filters().constBegin();
03683 for ( ;it != kmkernel->filterMgr()->filters().constEnd(); ++it ) {
03684 if (!(*it)->isEmpty() && (*it)->configureShortcut()) {
03685 filterName = QString("Filter %1").arg((*it)->name());
03686 normalizedName = filterName.replace(" ", "_");
03687 if (action(normalizedName.utf8()))
03688 continue;
03689 filterCommand = new KMMetaFilterActionCommand(*it, mHeaders, this);
03690 mFilterCommands.append(filterCommand);
03691 QString as = i18n("Filter %1").arg((*it)->name());
03692 QString icon = (*it)->icon();
03693 if ( icon.isEmpty() )
03694 icon = "gear";
03695 filterAction = new KAction(as, icon, (*it)->shortcut(), filterCommand,
03696 SLOT(start()), actionCollection(),
03697 normalizedName.local8Bit());
03698 if(!addedSeparator) {
03699 mApplyFilterActionsMenu->popupMenu()->insertSeparator();
03700 addedSeparator = !addedSeparator;
03701 mFilterMenuActions.append( new KActionSeparator());
03702 }
03703 filterAction->plug( mApplyFilterActionsMenu->popupMenu() );
03704 mFilterMenuActions.append(filterAction);
03705 if ( (*it)->configureToolbar() )
03706 mFilterTBarActions.append(filterAction);
03707 }
03708 }
03709 if ( !mFilterMenuActions.isEmpty() && mGUIClient->factory() )
03710 mGUIClient->plugActionList( "menu_filter_actions", mFilterMenuActions );
03711 if ( !mFilterTBarActions.isEmpty() && mGUIClient->factory() ) {
03712 mFilterTBarActions.prepend( mToolbarActionSeparator );
03713 mGUIClient->plugActionList( "toolbar_filter_actions", mFilterTBarActions );
03714 }
03715 }
03716
03717 void KMMainWidget::slotFolderRemoved( KMFolder *folder )
03718 {
03719 mFolderShortcutCommands.remove( folder->idString() );
03720 }
03721
03722
03723 void KMMainWidget::initializeIMAPActions( bool setState )
03724 {
03725 bool hasImapAccount = false;
03726 for( KMAccount *a = kmkernel->acctMgr()->first(); a;
03727 a = kmkernel->acctMgr()->next() ) {
03728 if ( a->type() == "cachedimap" ) {
03729 hasImapAccount = true;
03730 break;
03731 }
03732 }
03733 if ( hasImapAccount == ( mTroubleshootFolderAction != 0 ) )
03734 return;
03735
03736 KXMLGUIFactory* factory = mGUIClient->factory();
03737 if ( factory )
03738 factory->removeClient( mGUIClient );
03739
03740 if ( !mTroubleshootFolderAction ) {
03741 mTroubleshootFolderAction = new KAction( i18n("&Troubleshoot IMAP Cache..."), "wizard", 0,
03742 this, SLOT(slotTroubleshootFolder()), actionCollection(), "troubleshoot_folder" );
03743 if ( setState )
03744 updateFolderMenu();
03745 } else {
03746 delete mTroubleshootFolderAction ;
03747 mTroubleshootFolderAction = 0;
03748 }
03749
03750 if ( factory )
03751 factory->addClient( mGUIClient );
03752 }
03753
03754 bool KMMainWidget::shortcutIsValid( const KShortcut &sc ) const
03755 {
03756 KActionPtrList actions = actionCollection()->actions();
03757 KActionPtrList::Iterator it( actions.begin() );
03758 for ( ; it != actions.end(); it++ ) {
03759 if ( (*it)->shortcut() == sc ) return false;
03760 }
03761 return true;
03762 }
03763
03764 void KMMainWidget::slotShortcutChanged( KMFolder *folder )
03765 {
03766
03767 mFolderShortcutCommands.remove( folder->idString() );
03768 if ( folder->shortcut().isNull() )
03769 return;
03770
03771 FolderShortcutCommand *c = new FolderShortcutCommand( this, folder );
03772 mFolderShortcutCommands.insert( folder->idString(), c );
03773
03774 QString actionlabel = QString( "FolderShortcut %1").arg( folder->prettyURL() );
03775 QString actionname = QString( "FolderShortcut %1").arg( folder->idString() );
03776 QString normalizedName = actionname.replace(" ", "_");
03777 KAction* action =
03778 new KAction(actionlabel, folder->shortcut(), c, SLOT(start()),
03779 actionCollection(), normalizedName.local8Bit());
03780 action->setIcon( folder->unreadIconPath() );
03781 c->setAction( action );
03782 }
03783
03784
03785 QString KMMainWidget::findCurrentImapPath()
03786 {
03787 QString startPath;
03788 if (!mFolder) return startPath;
03789 if (mFolder->folderType() == KMFolderTypeImap)
03790 {
03791 startPath = static_cast<KMFolderImap*>(mFolder->storage())->imapPath();
03792 } else if (mFolder->folderType() == KMFolderTypeCachedImap)
03793 {
03794 startPath = static_cast<KMFolderCachedImap*>(mFolder->storage())->imapPath();
03795 }
03796 return startPath;
03797 }
03798
03799
03800 ImapAccountBase* KMMainWidget::findCurrentImapAccountBase()
03801 {
03802 ImapAccountBase* account = 0;
03803 if (!mFolder) return account;
03804 if (mFolder->folderType() == KMFolderTypeImap)
03805 {
03806 account = static_cast<KMFolderImap*>(mFolder->storage())->account();
03807 } else if (mFolder->folderType() == KMFolderTypeCachedImap)
03808 {
03809 account = static_cast<KMFolderCachedImap*>(mFolder->storage())->account();
03810 }
03811 return account;
03812 }
03813
03814
03815 void KMMainWidget::slotSubscriptionDialog()
03816 {
03817 if ( !kmkernel->askToGoOnline() )
03818 return;
03819 ImapAccountBase* account = findCurrentImapAccountBase();
03820 if ( !account ) return;
03821 const QString startPath = findCurrentImapPath();
03822
03823
03824 SubscriptionDialog * dialog =
03825 new SubscriptionDialog(this, i18n("Subscription"), account, startPath);
03826 if ( dialog->exec() ) {
03827
03828 if (mFolder->folderType() == KMFolderTypeImap)
03829 static_cast<KMFolderImap*>(mFolder->storage())->account()->listDirectory();
03830 }
03831 }
03832
03833
03834 void KMMainWidget::slotLocalSubscriptionDialog()
03835 {
03836 ImapAccountBase* account = findCurrentImapAccountBase();
03837 if ( !account ) return;
03838
03839 const QString startPath = findCurrentImapPath();
03840
03841 LocalSubscriptionDialog *dialog =
03842 new LocalSubscriptionDialog(this, i18n("Local Subscription"), account, startPath);
03843 if ( dialog->exec() ) {
03844
03845 if (mFolder->folderType() == KMFolderTypeImap)
03846 static_cast<KMFolderImap*>(mFolder->storage())->account()->listDirectory();
03847 }
03848 }
03849
03850
03851 void KMMainWidget::slotFolderTreeColumnsChanged()
03852 {
03853 mTotalColumnToggle->setChecked( mFolderTree->isTotalActive() );
03854 mUnreadColumnToggle->setChecked( mFolderTree->isUnreadActive() );
03855 mSizeColumnToggle->setChecked( mFolderTree->isSizeActive() );
03856 mUnreadTextToggle->setChecked( !mFolderTree->isUnreadActive() );
03857 }
03858
03859 void KMMainWidget::toggleSystemTray()
03860 {
03861 if ( !mSystemTray && GlobalSettings::self()->systemTrayEnabled() ) {
03862 mSystemTray = new KMSystemTray();
03863 }
03864 else if ( mSystemTray && !GlobalSettings::self()->systemTrayEnabled() ) {
03865
03866 kdDebug(5006) << "deleting systray" << endl;
03867 delete mSystemTray;
03868 mSystemTray = 0;
03869 }
03870
03871
03872 if ( mSystemTray )
03873 mSystemTray->setMode( GlobalSettings::self()->systemTrayPolicy() );
03874 }
03875
03876
03877 void KMMainWidget::slotAntiSpamWizard()
03878 {
03879 AntiSpamWizard wiz( AntiSpamWizard::AntiSpam, this, folderTree() );
03880 wiz.exec();
03881 }
03882
03883
03884 void KMMainWidget::slotAntiVirusWizard()
03885 {
03886 AntiSpamWizard wiz( AntiSpamWizard::AntiVirus, this, folderTree() );
03887 wiz.exec();
03888 }
03889
03890
03891 void KMMainWidget::slotFilterLogViewer()
03892 {
03893 FilterLogDialog * dlg = new FilterLogDialog( 0 );
03894 dlg->show();
03895 }
03896
03897
03898 void KMMainWidget::updateFileMenu()
03899 {
03900 QStringList actList = kmkernel->acctMgr()->getAccounts();
03901
03902 actionCollection()->action("check_mail")->setEnabled( actList.size() > 0 );
03903 actionCollection()->action("check_mail_in")->setEnabled( actList.size() > 0 );
03904 actionCollection()->action("favorite_check_mail")->setEnabled( actList.size() > 0 );
03905 }
03906
03907
03908
03909 void KMMainWidget::setAccelsEnabled( bool enabled )
03910 {
03911 actionCollection()->kaccel()->setEnabled( enabled );
03912 }
03913
03914
03915
03916 KMSystemTray *KMMainWidget::systray() const
03917 {
03918 return mSystemTray;
03919 }
03920
03921
03922 QString KMMainWidget::overrideEncoding() const
03923 {
03924 if ( mMsgView )
03925 return mMsgView->overrideEncoding();
03926 else
03927 return GlobalSettings::self()->overrideCharacterEncoding();
03928 }
03929
03930 void KMMainWidget::slotCreateTodo()
03931 {
03932 KMMessage *msg = mHeaders->currentMsg();
03933 if ( !msg )
03934 return;
03935 KMCommand *command = new CreateTodoCommand( this, msg );
03936 command->start();
03937 }
03938
03939 void KMMainWidget::setupFolderView()
03940 {
03941 if ( GlobalSettings::self()->enableFavoriteFolderView() ) {
03942 mFolderView = mFolderViewSplitter;
03943 mFolderTree->reparent( mFolderViewSplitter, 0, QPoint( 0, 0 ) );
03944 mFolderViewSplitter->show();
03945 mFavoriteFolderView->show();
03946 } else {
03947 mFolderView = mFolderTree;
03948 mFolderViewSplitter->hide();
03949 mFavoriteFolderView->hide();
03950 }
03951 mFolderView->reparent( mFolderViewParent, 0, QPoint( 0, 0 ) );
03952 mFolderViewParent->moveToFirst( mFolderView );
03953 mFolderTree->show();
03954 }
03955
03956
03957 void KMMainWidget::slotRequestFullSearchFromQuickSearch()
03958 {
03959 slotSearch();
03960 #ifdef HAVE_INDEXLIB
03961 return;
03962 #endif
03963 assert( mSearchWin );
03964 KMSearchPattern pattern;
03965 pattern.append( KMSearchRule::createInstance( "<message>", KMSearchRule::FuncContains, mQuickSearchLine->currentSearchTerm() ) );
03966 int status = mQuickSearchLine->currentStatus();
03967 if ( status != 0 ) {
03968 pattern.append( new KMSearchRuleStatus( status ) );
03969 }
03970 mSearchWin->setSearchPattern( pattern );
03971 }
03972
03973 void KMMainWidget::updateVactionScriptStatus(bool active)
03974 {
03975 mVacationIndicatorActive = active;
03976 if ( active ) {
03977 mVacationScriptIndicator->setText( i18n("Out of office reply active") );
03978 mVacationScriptIndicator->setPaletteBackgroundColor( Qt::yellow );
03979 mVacationScriptIndicator->setCursor( QCursor( Qt::PointingHandCursor ) );
03980 mVacationScriptIndicator->show();
03981 } else {
03982 mVacationScriptIndicator->hide();
03983 }
03984 }
03985