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 slotTop();
00132   void slotUp();
00135   void slotDown();
00138   void slotBottom();
00141   void slotRename();
00142 
00143 protected:
00145   QPtrList<KMFilter> mFilterList;
00147   QListBox *mListBox;
00149   QPushButton *mBtnNew, *mBtnCopy, *mBtnDelete, *mBtnRename;
00150   QPushButton *mBtnTop, *mBtnUp, *mBtnDown, *mBtnBot;
00152   int mIdxSelItem;
00153   bool mShowLater;
00154 private:
00155   void enableControls();
00156   void insertFilter( KMFilter* aFilter );
00157   void swapFilters( int from, int to );
00158   void swapNeighbouringFilters( int untouchedOne, int movedOne );
00159   bool bPopFilter;
00160 };
00161 
00162 
00184 class KMFilterActionWidget : public QHBox
00185 {
00186   Q_OBJECT
00187 public:
00190   KMFilterActionWidget( QWidget* parent=0, const char* name=0 );
00191 
00195   void setAction( const KMFilterAction * aAction );
00200   KMFilterAction *action();
00201 
00202 private:
00207   QPtrList<KMFilterAction> mActionList;
00211   QComboBox      *mComboBox;
00214   QWidgetStack   *mWidgetStack;
00215 };
00216 
00217 class KMPopFilterActionWidget : public QVButtonGroup
00218 {
00219   Q_OBJECT
00220 public:
00221   KMPopFilterActionWidget( const QString &title, QWidget* parent=0, const char* name=0 );
00222   void setAction( KMPopFilterAction aAction );
00223   KMPopFilterAction action();
00224 
00225 public slots:
00226   void reset();
00227 
00228 private slots:
00229   void slotActionClicked(int aId);
00230 
00231 private:
00232   KMPopFilterAction mAction;
00233   KMFilter mFilter;
00234   QMap<KMPopFilterAction, QRadioButton*> mActionMap;
00235   QMap<int, KMPopFilterAction> mIdMap;
00236 
00237 signals: // Signals
00238   void actionChanged(const KMPopFilterAction aAction);
00239 };
00240 
00241 class KMFilterActionWidgetLister : public KWidgetLister
00242 {
00243   Q_OBJECT
00244 public:
00245   KMFilterActionWidgetLister( QWidget *parent=0, const char* name=0 );
00246 
00247   virtual ~KMFilterActionWidgetLister();
00248 
00249   void setActionList( QPtrList<KMFilterAction> * aList );
00250 
00252   void updateActionList() { regenerateActionListFromWidgets(); }
00253 
00254 public slots:
00255   void reset();
00256 
00257 protected:
00258   virtual void clearWidget( QWidget *aWidget );
00259   virtual QWidget* createWidget( QWidget *parent );
00260 
00261 private:
00262   void regenerateActionListFromWidgets();
00263   QPtrList<KMFilterAction> *mActionList;
00264 
00265 };
00266 
00267 
00268 
00324 class KMFilterDlg: public KDialogBase
00325 {
00326   Q_OBJECT
00327 public:
00331   KMFilterDlg( QWidget* parent=0, const char* name=0, bool popFilter=false,
00332                bool createDummyFilter=true );
00333 
00338   void createFilter( const QCString & field, const QString & value )
00339     { mFilterList->createFilter( field, value ); }
00340 
00341 public slots:
00346   void slotFilterSelected(KMFilter * aFilter);
00348   void slotActionChanged(const KMPopFilterAction aAction);
00349 
00350 protected slots:
00351   void slotApplicabilityChanged();
00352   void slotApplicableAccountsChanged();
00353   void slotStopProcessingButtonToggled( bool aChecked );
00354   void slotConfigureShortcutButtonToggled( bool aChecked );
00355   void slotCapturedShortcutChanged( const KShortcut& );
00356   void slotConfigureToolbarButtonToggled( bool aChecked );
00357   void slotFilterActionIconChanged( QString icon );
00358   void slotReset();
00359   void slotUpdateFilter();
00360   void slotSaveSize();
00361   // called when the dialog is closed (finished)
00362   void slotFinished();
00363   // update the list of accounts shown in the advanced tab
00364   void slotUpdateAccountList();
00365 
00366 protected:
00370   KMFilterListBox *mFilterList;
00372   KMSearchPatternEdit *mPatternEdit;
00374   KMFilterActionWidgetLister *mActionLister;
00376   KMPopFilterActionWidget *mActionGroup;
00379   QCheckBox *mApplyOnIn, *mApplyOnOut, *mApplyOnCtrlJ;
00382   QRadioButton *mApplyOnForAll, *mApplyOnForTraditional, *mApplyOnForChecked;
00384   KListView *mAccountList;
00385 
00386   QCheckBox *mStopProcessingHere;
00387   QCheckBox *mConfigureShortcut;
00388   QCheckBox *mConfigureToolbar;
00389   QLabel *mFilterActionLabel;
00390   KIconButton *mFilterActionIconButton;
00391   KKeyButton *mKeyButton;
00392   QGroupBox *mAdvOptsGroup;
00393   QVGroupBox *mGlobalsBox;
00394   QCheckBox *mShowLaterBtn;
00395 
00396   KMFilter *mFilter;
00397   bool bPopFilter;
00398 };
00399 
00400 
00401 
00402 #endif /*kmfilterdlg_h*/
KDE Home | KDE Accessibility Home | Description of Access Keys