kmail

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 <qvgroupbox.h>
00017 #include <qgroupbox.h>
00018 #include <qhbox.h>
00019 #include <qstring.h>
00020 #include <qptrlist.h>
00021 #include <qradiobutton.h>
00022 #include <qvbuttongroup.h>
00023 #include <qmap.h>
00024 
00025 class KMSearchPatternEdit;
00026 class QListBox;
00027 class QPushButton;
00028 class QComboBox;
00029 class QWidgetStack;
00030 class QCheckBox;
00031 class KIconButton;
00032 class KKeyButton;
00033 class KListView;
00034 
00035 
00060 class KMFilterListBox : public QGroupBox
00061 {
00062   Q_OBJECT
00063 public:
00065   KMFilterListBox( const QString & title, QWidget* parent=0, const char* name=0, bool popFilter = false);
00066 
00073   void createFilter( const QCString & field, const QString & value );
00074 
00079   void loadFilterList( bool createDummyFilter );
00080 
00082   bool showLaterMsgs();
00083 
00084 signals:
00088   void filterSelected( KMFilter* filter );
00089 
00094   void resetWidgets();
00095 
00098   void applyWidgets();
00099 
00100 public slots:
00105   void slotUpdateFilterName();
00108   void slotApplyFilterChanges();
00111   void slotShowLaterToggled(bool aOn);
00112 
00113 protected slots:
00117   void slotSelected( int aIdx );
00120   void slotNew();
00123   void slotCopy();
00126   void slotDelete();
00129   void slotUp();
00132   void slotDown();
00135   void slotRename();
00136 
00137 protected:
00139   QPtrList<KMFilter> mFilterList;
00141   QListBox *mListBox;
00143   QPushButton *mBtnNew, *mBtnCopy, *mBtnDelete, *mBtnUp, *mBtnDown, *mBtnRename;
00145   int mIdxSelItem;
00146   bool mShowLater;
00147 private:
00148   void enableControls();
00149   void insertFilter( KMFilter* aFilter );
00150   void swapNeighbouringFilters( int untouchedOne, int movedOne);
00151   bool bPopFilter;
00152 };
00153 
00154 
00176 class KMFilterActionWidget : public QHBox
00177 {
00178   Q_OBJECT
00179 public:
00182   KMFilterActionWidget( QWidget* parent=0, const char* name=0 );
00183 
00187   void setAction( const KMFilterAction * aAction );
00192   KMFilterAction *action();
00193 
00194 private:
00199   QPtrList<KMFilterAction> mActionList;
00203   QComboBox      *mComboBox;
00206   QWidgetStack   *mWidgetStack;
00207 };
00208 
00209 class KMPopFilterActionWidget : public QVButtonGroup
00210 {
00211   Q_OBJECT
00212 public:
00213   KMPopFilterActionWidget( const QString &title, QWidget* parent=0, const char* name=0 );
00214   void setAction( KMPopFilterAction aAction );
00215   KMPopFilterAction action();
00216 
00217 public slots:
00218   void reset();
00219 
00220 private slots:
00221   void slotActionClicked(int aId);
00222 
00223 private:
00224   KMPopFilterAction mAction;
00225   KMFilter mFilter;
00226   QMap<KMPopFilterAction, QRadioButton*> mActionMap;
00227   QMap<int, KMPopFilterAction> mIdMap;
00228 
00229 signals: // Signals
00230   void actionChanged(const KMPopFilterAction aAction);
00231 };
00232 
00233 class KMFilterActionWidgetLister : public KWidgetLister
00234 {
00235   Q_OBJECT
00236 public:
00237   KMFilterActionWidgetLister( QWidget *parent=0, const char* name=0 );
00238 
00239   virtual ~KMFilterActionWidgetLister();
00240 
00241   void setActionList( QPtrList<KMFilterAction> * aList );
00242 
00244   void updateActionList() { regenerateActionListFromWidgets(); }
00245 
00246 public slots:
00247   void reset();
00248 
00249 protected:
00250   virtual void clearWidget( QWidget *aWidget );
00251   virtual QWidget* createWidget( QWidget *parent );
00252 
00253 private:
00254   void regenerateActionListFromWidgets();
00255   QPtrList<KMFilterAction> *mActionList;
00256 
00257 };
00258 
00259 
00260 
00316 class KMFilterDlg: public KDialogBase
00317 {
00318   Q_OBJECT
00319 public:
00323   KMFilterDlg( QWidget* parent=0, const char* name=0, bool popFilter=false,
00324                bool createDummyFilter=true );
00325 
00330   void createFilter( const QCString & field, const QString & value )
00331     { mFilterList->createFilter( field, value ); }
00332 
00333 public slots:
00338   void slotFilterSelected(KMFilter * aFilter);
00340   void slotActionChanged(const KMPopFilterAction aAction);
00341 
00342 protected slots:
00343   void slotApplicabilityChanged();
00344   void slotApplicableAccountsChanged();
00345   void slotStopProcessingButtonToggled( bool aChecked );
00346   void slotConfigureShortcutButtonToggled( bool aChecked );
00347   void slotCapturedShortcutChanged( const KShortcut& );
00348   void slotConfigureToolbarButtonToggled( bool aChecked );
00349   void slotFilterActionIconChanged( QString icon );
00350   void slotReset();
00351   void slotUpdateFilter();
00352   void slotSaveSize();
00353   // called when the dialog is closed (finished)
00354   void slotFinished();
00355   // update the list of accounts shown in the advanced tab
00356   void slotUpdateAccountList();
00357 
00358 protected:
00362   KMFilterListBox *mFilterList;
00364   KMSearchPatternEdit *mPatternEdit;
00366   KMFilterActionWidgetLister *mActionLister;
00368   KMPopFilterActionWidget *mActionGroup;
00371   QCheckBox *mApplyOnIn, *mApplyOnOut, *mApplyOnCtrlJ;
00374   QRadioButton *mApplyOnForAll, *mApplyOnForTraditional, *mApplyOnForChecked;
00376   KListView *mAccountList;
00377 
00378   QCheckBox *mStopProcessingHere;
00379   QCheckBox *mConfigureShortcut;
00380   QCheckBox *mConfigureToolbar;
00381   QLabel *mFilterActionLabel;
00382   KIconButton *mFilterActionIconButton;
00383   KKeyButton *mKeyButton;
00384   QGroupBox *mAdvOptsGroup;
00385   QVGroupBox *mGlobalsBox;
00386   QCheckBox *mShowLaterBtn;
00387 
00388   KMFilter *mFilter;
00389   bool bPopFilter;
00390 };
00391 
00392 
00393 
00394 #endif /*kmfilterdlg_h*/
KDE Home | KDE Accessibility Home | Description of Access Keys