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