kmail

searchwindow.h
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 <tqvaluelist.h>
00025 #include <tqptrlist.h>
00026 #include <tqstringlist.h>
00027 #include <tqguardedptr.h>
00028 #include <tqtimer.h>
00029 
00030 #include <kdialogbase.h>
00031 #include <kxmlguiclient.h>
00032 
00033 class TQCheckBox;
00034 class TQComboBox;
00035 class TQGridLayout;
00036 class TQLabel;
00037 class TQLineEdit;
00038 class KListView;
00039 class TQListViewItem;
00040 class TQPushButton;
00041 class TQRadioButton;
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 TQPtrList<KMMsgBase> KMMessageList;
00059 
00060 namespace KMail {
00061 
00068 class SearchWindow: public KDialogBase, virtual public KXMLGUIClient
00069 {
00070   Q_OBJECT
00071   TQ_OBJECT
00072 
00073 public:
00082   SearchWindow( KMMainWidget* parent, const char* name=0,
00083                        KMFolder *curFolder=0, bool modal=false );
00084   virtual ~SearchWindow();
00085 
00090   void activateFolder( KMFolder* curFolder );
00091 
00096   KMMessageList selectedMessages();
00097 
00102   KMMessage* message();
00103 
00104   void setSearchPattern( const KMSearchPattern& pattern );
00105 
00106 protected slots:
00108   virtual void updStatus(void);
00109 
00110   virtual void slotClose();
00111   virtual void slotSearch();
00112   virtual void slotStop();
00113   void scheduleRename( const TQString &);
00114   void renameSearchFolder();
00115   void openSearchFolder();
00116   void folderInvalidated(KMFolder *);
00117   virtual bool slotShowMsg( TQListViewItem * );
00118   void slotViewSelectedMsg();
00119   virtual bool slotViewMsg( TQListViewItem * );
00120   void slotCurrentChanged( TQListViewItem * );
00121   virtual void updateContextMenuActions();
00122   virtual void slotContextMenuRequested( TQListViewItem*, const TQPoint &, int );
00123   virtual void copySelectedToFolder( int menuId );
00124   virtual void moveSelectedToFolder( int menuId );
00125   virtual void slotFolderActivated();
00126   void slotClearSelection();
00127   void slotReplyToMsg();
00128   void slotReplyAllToMsg();
00129   void slotReplyListToMsg();
00130   void slotForwardInlineMsg();
00131   void slotForwardAttachedMsg();
00132   void slotForwardDigestMsg();
00133   void slotRedirectMsg();
00134   void slotSaveMsg();
00135   void slotSaveAttachments();
00136   void slotPrintMsg();
00137   void slotCopyMsgs();
00138   void slotCutMsgs();
00139 
00141   virtual void searchDone();
00142   virtual void slotAddMsg(int idx);
00143   virtual void slotRemoveMsg(KMFolder *, TQ_UINT32 serNum);
00144   void enableGUI();
00145 
00146   void setEnabledSearchButton(bool);
00147 
00148 protected:
00149 
00151   virtual void keyPressEvent(TQKeyEvent*);
00152 
00154   virtual void closeEvent(TQCloseEvent*);
00155 
00156 protected:
00157   bool mStopped;
00158   bool mCloseRequested;
00159   int mFetchingInProgress;
00160   int mSortColumn;
00161   SortOrder mSortOrder;
00162   TQGuardedPtr<KMFolderSearch> mFolder;
00163   TQTimer *mTimer;
00164 
00165   // GC'd by TQt
00166   TQRadioButton *mChkbxAllFolders;
00167   TQRadioButton *mChkbxSpecificFolders;
00168   KMail::FolderRequester *mCbxFolders;
00169   TQPushButton *mBtnSearch;
00170   TQPushButton *mBtnStop;
00171   TQCheckBox *mChkSubFolders;
00172   KListView* mLbxMatches;
00173   TQLabel *mSearchFolderLbl;
00174   TQLineEdit *mSearchFolderEdt;
00175   TQPushButton *mSearchFolderOpenBtn;
00176   TQPushButton *mSearchResultOpenBtn;
00177   KStatusBar* mStatusBar;
00178   TQWidget* mLastFocus; // to remember the position of the focus
00179   TQMap<int,KMFolder*> mMenuToFolder;
00180   KAction *mReplyAction, *mReplyAllAction, *mReplyListAction, *mSaveAsAction,
00181     *mForwardInlineAction, *mForwardAttachedAction, *mForwardDigestAction,
00182     *mRedirectAction, *mPrintAction, *mClearAction, *mSaveAtchAction,
00183     *mCopyAction, *mCutAction;
00184   KActionMenu *mForwardActionMenu;
00185   TQValueList<TQGuardedPtr<KMFolder> > mFolders;
00186   TQTimer mRenameTimer;
00187 
00188   // not owned by us
00189   KMMainWidget* mKMMainWidget;
00190   KMSearchPatternEdit *mPatternEdit;
00191   KMSearchPattern *mSearchPattern;
00192 
00193   static const int MSGID_COLUMN;
00194 
00195 private:
00196   KMMessage *indexToMessage( TQListViewItem *item );
00197 };
00198 
00199 } // namespace KMail
00200 #endif /*searchwindow_h*/