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