kmail

searchwindow.h

Go to the documentation of this file.
00001 /*
00002  * kmail: KDE mail client
00003  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
00004  * Copyright (c) 2001 Aaron J. Seigo <aseigo@kde.org>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  */
00021 #ifndef searchwindow_h
00022 #define searchwindow_h
00023 
00024 #include <qvaluelist.h>
00025 #include <qptrlist.h>
00026 #include <qstringlist.h>
00027 #include <qguardedptr.h>
00028 #include <qtimer.h>
00029 
00030 #include <kdialogbase.h>
00031 #include <kxmlguiclient.h>
00032 
00033 class QCheckBox;
00034 class QComboBox;
00035 class QGridLayout;
00036 class QLabel;
00037 class QLineEdit;
00038 class KListView;
00039 class QListViewItem;
00040 class QPushButton;
00041 class QRadioButton;
00042 class KAction;
00043 class KActionMenu;
00044 class KMFolder;
00045 class KMFolderSearch;
00046 class KMFolderImap;
00047 class KMFolderMgr;
00048 class KMMainWidget;
00049 class KMMessage;
00050 class KMSearchPattern;
00051 class KMSearchPatternEdit;
00052 class KStatusBar;
00053 class DwBoyerMoore;
00054 namespace KMail {
00055   class FolderRequester;
00056 }
00057 
00058 typedef QPtrList<KMMsgBase> KMMessageList;
00059 
00060 namespace KMail {
00061 
00068 class SearchWindow: public KDialogBase, virtual public KXMLGUIClient
00069 {
00070   Q_OBJECT
00071 
00072 public:
00081   SearchWindow( KMMainWidget* parent, const char* name=0,
00082                        KMFolder *curFolder=0, bool modal=false );
00083   virtual ~SearchWindow();
00084 
00089   void activateFolder( KMFolder* curFolder );
00090 
00095   KMMessageList selectedMessages();
00096 
00101   KMMessage* message();
00102 
00103   void setSearchPattern( const KMSearchPattern& pattern );
00104 
00105 protected slots:
00107   virtual void updStatus(void);
00108 
00109   virtual void slotClose();
00110   virtual void slotSearch();
00111   virtual void slotStop();
00112   void scheduleRename( const QString &);
00113   void renameSearchFolder();
00114   void openSearchFolder();
00115   void folderInvalidated(KMFolder *);
00116   virtual bool slotShowMsg(QListViewItem *);
00117   void slotShowSelectedMsg();
00118   void slotCurrentChanged(QListViewItem *);
00119   virtual void updateContextMenuActions();
00120   virtual void slotContextMenuRequested( QListViewItem*, const QPoint &, int );
00121   virtual void copySelectedToFolder( int menuId );
00122   virtual void moveSelectedToFolder( int menuId );
00123   virtual void slotFolderActivated();
00124   void slotClearSelection();
00125   void slotReplyToMsg();
00126   void slotReplyAllToMsg();
00127   void slotReplyListToMsg();
00128   void slotForwardInlineMsg();
00129   void slotForwardAttachedMsg();
00130   void slotForwardDigestMsg();
00131   void slotRedirectMsg();
00132   void slotSaveMsg();
00133   void slotSaveAttachments();
00134   void slotPrintMsg();
00135   void slotCopyMsgs();
00136   void slotCutMsgs();
00137 
00139   virtual void searchDone();
00140   virtual void slotAddMsg(int idx);
00141   virtual void slotRemoveMsg(KMFolder *, Q_UINT32 serNum);
00142   void enableGUI();
00143 
00144   void setEnabledSearchButton(bool);
00145 
00146 protected:
00147 
00149   virtual void keyPressEvent(QKeyEvent*);
00150 
00152   virtual void closeEvent(QCloseEvent*);
00153 
00154 protected:
00155   bool mStopped;
00156   bool mCloseRequested;
00157   int mFetchingInProgress;
00158   int mSortColumn;
00159   SortOrder mSortOrder;
00160   QGuardedPtr<KMFolderSearch> mFolder;
00161   QTimer *mTimer;
00162 
00163   // GC'd by Qt
00164   QRadioButton *mChkbxAllFolders;
00165   QRadioButton *mChkbxSpecificFolders;
00166   KMail::FolderRequester *mCbxFolders;
00167   QPushButton *mBtnSearch;
00168   QPushButton *mBtnStop;
00169   QCheckBox *mChkSubFolders;
00170   KListView* mLbxMatches;
00171   QLabel *mSearchFolderLbl;
00172   QLineEdit *mSearchFolderEdt;
00173   QPushButton *mSearchFolderOpenBtn;
00174   QPushButton *mSearchResultOpenBtn;
00175   KStatusBar* mStatusBar;
00176   QWidget* mLastFocus; // to remember the position of the focus
00177   QMap<int,KMFolder*> mMenuToFolder;
00178   KAction *mReplyAction, *mReplyAllAction, *mReplyListAction, *mSaveAsAction,
00179     *mForwardInlineAction, *mForwardAttachedAction, *mForwardDigestAction,
00180     *mRedirectAction, *mPrintAction, *mClearAction, *mSaveAtchAction,
00181     *mCopyAction, *mCutAction;
00182   KActionMenu *mForwardActionMenu;
00183   QValueList<QGuardedPtr<KMFolder> > mFolders;
00184   QTimer mRenameTimer;
00185 
00186   // not owned by us
00187   KMMainWidget* mKMMainWidget;
00188   KMSearchPatternEdit *mPatternEdit;
00189   KMSearchPattern *mSearchPattern;
00190 
00191   static const int MSGID_COLUMN;
00192 };
00193 
00194 } // namespace KMail
00195 #endif /*searchwindow_h*/