kmfilterdlg.h
00001 /* Filter Dialog 00002 * Author: Marc Mutz <Marc@Mutz.com>, 00003 * based upon work by Stefan Taferner <taferner@kde.org> 00004 * This code is under GPL 00005 */ 00006 #ifndef kmfilterdlg_h 00007 #define kmfilterdlg_h 00008 00009 #include "kmfilter.h" 00010 #include "kmfilteraction.h" 00011 00012 #include <kwidgetlister.h> 00013 00014 #include <kdialogbase.h> 00015 00016 #include <tqvgroupbox.h> 00017 #include <tqgroupbox.h> 00018 #include <tqhbox.h> 00019 #include <tqstring.h> 00020 #include <tqptrlist.h> 00021 #include <tqradiobutton.h> 00022 #include <tqvbuttongroup.h> 00023 #include <tqmap.h> 00024 00025 class KMSearchPatternEdit; 00026 class TQListBox; 00027 class TQPushButton; 00028 class TQComboBox; 00029 class TQWidgetStack; 00030 class TQCheckBox; 00031 class TDEIconButton; 00032 class KKeyButton; 00033 class TDEListView; 00034 00035 00060 class KMFilterListBox : public TQGroupBox 00061 { 00062 Q_OBJECT 00063 00064 public: 00066 KMFilterListBox( const TQString & title, TQWidget* parent=0, const char* name=0, bool popFilter = false); 00067 00074 void createFilter( const TQCString & field, const TQString & value ); 00075 00080 void loadFilterList( bool createDummyFilter ); 00081 00083 bool showLaterMsgs(); 00084 00085 void insertFilter( KMFilter* aFilter ); 00086 00087 void appendFilter( KMFilter* aFilter ); 00088 00092 TQValueList<KMFilter*> filtersForSaving() const; 00093 00094 signals: 00098 void filterSelected( KMFilter* filter ); 00099 00104 void resetWidgets(); 00105 00108 void applyWidgets(); 00109 00110 public slots: 00115 void slotUpdateFilterName(); 00118 void slotApplyFilterChanges(); 00121 void slotShowLaterToggled(bool aOn); 00122 00123 protected slots: 00127 void slotSelected( int aIdx ); 00130 void slotNew(); 00133 void slotCopy(); 00136 void slotDelete(); 00139 void slotTop(); 00142 void slotUp(); 00145 void slotDown(); 00148 void slotBottom(); 00151 void slotRename(); 00152 00153 void slotSelectSourceFolders(); 00154 00155 protected: 00157 TQPtrList<KMFilter> mFilterList; 00159 TQListBox *mListBox; 00161 TQPushButton *mBtnNew, *mBtnCopy, *mBtnDelete, *mBtnRename; 00162 TQPushButton *mBtnTop, *mBtnUp, *mBtnDown, *mBtnBot; 00164 int mIdxSelItem; 00165 bool mShowLater; 00166 private: 00167 void enableControls(); 00168 00169 void swapFilters( int from, int to ); 00170 void swapNeighbouringFilters( int untouchedOne, int movedOne ); 00171 bool bPopFilter; 00172 }; 00173 00174 00196 class KMFilterActionWidget : public TQHBox 00197 { 00198 Q_OBJECT 00199 00200 public: 00203 KMFilterActionWidget( TQWidget* parent=0, const char* name=0 ); 00204 00208 void setAction( const KMFilterAction * aAction ); 00213 KMFilterAction *action(); 00214 00215 private: 00220 TQPtrList<KMFilterAction> mActionList; 00224 TQComboBox *mComboBox; 00227 TQWidgetStack *mWidgetStack; 00228 }; 00229 00230 class KMPopFilterActionWidget : public TQVButtonGroup 00231 { 00232 Q_OBJECT 00233 00234 public: 00235 KMPopFilterActionWidget( const TQString &title, TQWidget* parent=0, const char* name=0 ); 00236 void setAction( KMPopFilterAction aAction ); 00237 KMPopFilterAction action(); 00238 00239 public slots: 00240 void reset(); 00241 00242 private slots: 00243 void slotActionClicked(int aId); 00244 00245 private: 00246 KMPopFilterAction mAction; 00247 KMFilter mFilter; 00248 TQMap<KMPopFilterAction, TQRadioButton*> mActionMap; 00249 TQMap<int, KMPopFilterAction> mIdMap; 00250 00251 signals: // Signals 00252 void actionChanged(const KMPopFilterAction aAction); 00253 }; 00254 00255 class KMFilterActionWidgetLister : public KWidgetLister 00256 { 00257 Q_OBJECT 00258 00259 public: 00260 KMFilterActionWidgetLister( TQWidget *parent=0, const char* name=0 ); 00261 00262 virtual ~KMFilterActionWidgetLister(); 00263 00264 void setActionList( TQPtrList<KMFilterAction> * aList ); 00265 00267 void updateActionList() { regenerateActionListFromWidgets(); } 00268 00269 public slots: 00270 void reset(); 00271 00272 protected: 00273 virtual void clearWidget( TQWidget *aWidget ); 00274 virtual TQWidget* createWidget( TQWidget *parent ); 00275 00276 private: 00277 void regenerateActionListFromWidgets(); 00278 TQPtrList<KMFilterAction> *mActionList; 00279 00280 }; 00281 00282 00283 00339 class KMFilterDlg: public KDialogBase 00340 { 00341 Q_OBJECT 00342 00343 public: 00347 KMFilterDlg( TQWidget* parent=0, const char* name=0, bool popFilter=false, 00348 bool createDummyFilter=true ); 00349 00354 void createFilter( const TQCString & field, const TQString & value ) 00355 { mFilterList->createFilter( field, value ); } 00356 00357 public slots: 00362 void slotFilterSelected(KMFilter * aFilter); 00364 void slotActionChanged(const KMPopFilterAction aAction); 00365 00366 protected slots: 00367 void slotApplicabilityChanged(); 00368 void slotApplicableAccountsChanged(); 00369 void slotStopProcessingButtonToggled( bool aChecked ); 00370 void slotConfigureShortcutButtonToggled( bool aChecked ); 00371 void slotCapturedShortcutChanged( const TDEShortcut& ); 00372 void slotConfigureToolbarButtonToggled( bool aChecked ); 00373 void slotFilterActionIconChanged( TQString icon ); 00374 void slotReset(); 00375 void slotUpdateFilter(); 00376 void slotSaveSize(); 00377 // called when the dialog is closed (finished) 00378 void slotFinished(); 00379 // update the list of accounts shown in the advanced tab 00380 void slotUpdateAccountList(); 00381 00382 00386 void slotImportFilters(); 00387 00391 void slotExportFilters(); 00392 00393 protected: 00397 KMFilterListBox *mFilterList; 00399 KMSearchPatternEdit *mPatternEdit; 00401 KMFilterActionWidgetLister *mActionLister; 00403 KMPopFilterActionWidget *mActionGroup; 00406 TQCheckBox *mApplyOnIn, *mApplyOnOut, *mApplyOnCtrlJ; 00409 TQRadioButton *mApplyOnForAll, *mApplyOnForTraditional, *mApplyOnForChecked; 00411 TDEListView *mAccountList; 00412 00413 TQCheckBox *mStopProcessingHere; 00414 TQCheckBox *mConfigureShortcut; 00415 TQCheckBox *mConfigureToolbar; 00416 TQLabel *mFilterActionLabel; 00417 TDEIconButton *mFilterActionIconButton; 00418 KKeyButton *mKeyButton; 00419 TQGroupBox *mAdvOptsGroup; 00420 TQVGroupBox *mGlobalsBox; 00421 TQCheckBox *mShowLaterBtn; 00422 00423 KMFilter *mFilter; 00424 bool bPopFilter; 00425 }; 00426 00427 00428 00429 #endif /*kmfilterdlg_h*/