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   void insertFilter( KMFilter* aFilter );
00085   
00086   void appendFilter( KMFilter* aFilter );
00087   
00091   QValueList<KMFilter*> filtersForSaving() const;
00092 
00093 signals:
00097   void filterSelected( KMFilter* filter );
00098 
00103   void resetWidgets();
00104 
00107   void applyWidgets();
00108 
00109 public slots:
00114   void slotUpdateFilterName();
00117   void slotApplyFilterChanges();
00120   void slotShowLaterToggled(bool aOn);
00121 
00122 protected slots:
00126   void slotSelected( int aIdx );
00129   void slotNew();
00132   void slotCopy();
00135   void slotDelete();
00138   void slotTop();
00141   void slotUp();
00144   void slotDown();
00147   void slotBottom();
00150   void slotRename();
00151 
00152   void slotSelectSourceFolders();
00153 
00154 protected:
00156   QPtrList<KMFilter> mFilterList;
00158   QListBox *mListBox;
00160   QPushButton *mBtnNew, *mBtnCopy, *mBtnDelete, *mBtnRename;
00161   QPushButton *mBtnTop, *mBtnUp, *mBtnDown, *mBtnBot;
00163   int mIdxSelItem;
00164   bool mShowLater;
00165 private:
00166   void enableControls();
00167  
00168   void swapFilters( int from, int to );
00169   void swapNeighbouringFilters( int untouchedOne, int movedOne );
00170   bool bPopFilter;
00171 };
00172 
00173 
00195 class KMFilterActionWidget : public QHBox
00196 {
00197   Q_OBJECT
00198 public:
00201   KMFilterActionWidget( QWidget* parent=0, const char* name=0 );
00202 
00206   void setAction( const KMFilterAction * aAction );
00211   KMFilterAction *action();
00212 
00213 private:
00218   QPtrList<KMFilterAction> mActionList;
00222   QComboBox      *mComboBox;
00225   QWidgetStack   *mWidgetStack;
00226 };
00227 
00228 class KMPopFilterActionWidget : public QVButtonGroup
00229 {
00230   Q_OBJECT
00231 public:
00232   KMPopFilterActionWidget( const QString &title, QWidget* parent=0, const char* name=0 );
00233   void setAction( KMPopFilterAction aAction );
00234   KMPopFilterAction action();
00235 
00236 public slots:
00237   void reset();
00238 
00239 private slots:
00240   void slotActionClicked(int aId);
00241 
00242 private:
00243   KMPopFilterAction mAction;
00244   KMFilter mFilter;
00245   QMap<KMPopFilterAction, QRadioButton*> mActionMap;
00246   QMap<int, KMPopFilterAction> mIdMap;
00247 
00248 signals: // Signals
00249   void actionChanged(const KMPopFilterAction aAction);
00250 };
00251 
00252 class KMFilterActionWidgetLister : public KWidgetLister
00253 {
00254   Q_OBJECT
00255 public:
00256   KMFilterActionWidgetLister( QWidget *parent=0, const char* name=0 );
00257 
00258   virtual ~KMFilterActionWidgetLister();
00259 
00260   void setActionList( QPtrList<KMFilterAction> * aList );
00261 
00263   void updateActionList() { regenerateActionListFromWidgets(); }
00264 
00265 public slots:
00266   void reset();
00267 
00268 protected:
00269   virtual void clearWidget( QWidget *aWidget );
00270   virtual QWidget* createWidget( QWidget *parent );
00271 
00272 private:
00273   void regenerateActionListFromWidgets();
00274   QPtrList<KMFilterAction> *mActionList;
00275 
00276 };
00277 
00278 
00279 
00335 class KMFilterDlg: public KDialogBase
00336 {
00337   Q_OBJECT
00338 public:
00342   KMFilterDlg( QWidget* parent=0, const char* name=0, bool popFilter=false,
00343                bool createDummyFilter=true );
00344 
00349   void createFilter( const QCString & field, const QString & value )
00350     { mFilterList->createFilter( field, value ); }
00351 
00352 public slots:
00357   void slotFilterSelected(KMFilter * aFilter);
00359   void slotActionChanged(const KMPopFilterAction aAction);
00360 
00361 protected slots:
00362   void slotApplicabilityChanged();
00363   void slotApplicableAccountsChanged();
00364   void slotStopProcessingButtonToggled( bool aChecked );
00365   void slotConfigureShortcutButtonToggled( bool aChecked );
00366   void slotCapturedShortcutChanged( const KShortcut& );
00367   void slotConfigureToolbarButtonToggled( bool aChecked );
00368   void slotFilterActionIconChanged( QString icon );
00369   void slotReset();
00370   void slotUpdateFilter();
00371   void slotSaveSize();
00372   // called when the dialog is closed (finished)
00373   void slotFinished();
00374   // update the list of accounts shown in the advanced tab
00375   void slotUpdateAccountList();
00376   
00377   
00381   void slotImportFilters();
00382   
00386   void slotExportFilters();
00387 
00388 protected:
00392   KMFilterListBox *mFilterList;
00394   KMSearchPatternEdit *mPatternEdit;
00396   KMFilterActionWidgetLister *mActionLister;
00398   KMPopFilterActionWidget *mActionGroup;
00401   QCheckBox *mApplyOnIn, *mApplyOnOut, *mApplyOnCtrlJ;
00404   QRadioButton *mApplyOnForAll, *mApplyOnForTraditional, *mApplyOnForChecked;
00406   KListView *mAccountList;
00407 
00408   QCheckBox *mStopProcessingHere;
00409   QCheckBox *mConfigureShortcut;
00410   QCheckBox *mConfigureToolbar;
00411   QLabel *mFilterActionLabel;
00412   KIconButton *mFilterActionIconButton;
00413   KKeyButton *mKeyButton;
00414   QGroupBox *mAdvOptsGroup;
00415   QVGroupBox *mGlobalsBox;
00416   QCheckBox *mShowLaterBtn;
00417 
00418   KMFilter *mFilter;
00419   bool bPopFilter;
00420 };
00421 
00422 
00423 
00424 #endif /*kmfilterdlg_h*/
KDE Home | KDE Accessibility Home | Description of Access Keys