kmail

kmfilterdlg.h
1 /* Filter Dialog
2  * Author: Marc Mutz <Marc@Mutz.com>,
3  * based upon work by Stefan Taferner <taferner@kde.org>
4  * This code is under GPL
5  */
6 #ifndef kmfilterdlg_h
7 #define kmfilterdlg_h
8 
9 #include "kmfilter.h"
10 #include "kmfilteraction.h"
11 
12 #include <kwidgetlister.h>
13 
14 #include <kdialogbase.h>
15 
16 #include <tqvgroupbox.h>
17 #include <tqgroupbox.h>
18 #include <tqhbox.h>
19 #include <tqstring.h>
20 #include <tqptrlist.h>
21 #include <tqradiobutton.h>
22 #include <tqvbuttongroup.h>
23 #include <tqmap.h>
24 
26 class TQListBox;
27 class TQPushButton;
28 class TQComboBox;
29 class TQWidgetStack;
30 class TQCheckBox;
31 class TDEIconButton;
32 class KKeyButton;
33 class TDEListView;
34 
35 
60 class KMFilterListBox : public TQGroupBox
61 {
62  Q_OBJECT
63 
64 public:
66  KMFilterListBox( const TQString & title, TQWidget* parent=0, const char* name=0, bool popFilter = false);
67 
74  void createFilter( const TQCString & field, const TQString & value );
75 
80  void loadFilterList( bool createDummyFilter );
81 
83  bool showLaterMsgs();
84 
85  void insertFilter( KMFilter* aFilter );
86 
87  void appendFilter( KMFilter* aFilter );
88 
92  TQValueList<KMFilter*> filtersForSaving() const;
93 
94 signals:
98  void filterSelected( KMFilter* filter );
99 
104  void resetWidgets();
105 
108  void applyWidgets();
109 
110 public slots:
115  void slotUpdateFilterName();
118  void slotApplyFilterChanges();
121  void slotShowLaterToggled(bool aOn);
122 
123 protected slots:
127  void slotSelected( int aIdx );
130  void slotNew();
133  void slotCopy();
136  void slotDelete();
139  void slotTop();
142  void slotUp();
145  void slotDown();
148  void slotBottom();
151  void slotRename();
152 
153  void slotSelectSourceFolders();
154 
155 protected:
157  TQPtrList<KMFilter> mFilterList;
159  TQListBox *mListBox;
161  TQPushButton *mBtnNew, *mBtnCopy, *mBtnDelete, *mBtnRename;
162  TQPushButton *mBtnTop, *mBtnUp, *mBtnDown, *mBtnBot;
165  bool mShowLater;
166 private:
167  void enableControls();
168 
169  void swapFilters( int from, int to );
170  void swapNeighbouringFilters( int untouchedOne, int movedOne );
171  bool bPopFilter;
172 };
173 
174 
196 class KMFilterActionWidget : public TQHBox
197 {
198  Q_OBJECT
199 
200 public:
203  KMFilterActionWidget( TQWidget* parent=0, const char* name=0 );
204 
208  void setAction( const KMFilterAction * aAction );
213  KMFilterAction *action();
214 
215 private:
220  TQPtrList<KMFilterAction> mActionList;
224  TQComboBox *mComboBox;
227  TQWidgetStack *mWidgetStack;
228 };
229 
230 class KMPopFilterActionWidget : public TQVButtonGroup
231 {
232  Q_OBJECT
233 
234 public:
235  KMPopFilterActionWidget( const TQString &title, TQWidget* parent=0, const char* name=0 );
236  void setAction( KMPopFilterAction aAction );
237  KMPopFilterAction action();
238 
239 public slots:
240  void reset();
241 
242 private slots:
243  void slotActionClicked(int aId);
244 
245 private:
246  KMPopFilterAction mAction;
247  KMFilter mFilter;
248  TQMap<KMPopFilterAction, TQRadioButton*> mActionMap;
249  TQMap<int, KMPopFilterAction> mIdMap;
250 
251 signals: // Signals
252  void actionChanged(const KMPopFilterAction aAction);
253 };
254 
255 class KMFilterActionWidgetLister : public KWidgetLister
256 {
257  Q_OBJECT
258 
259 public:
260  KMFilterActionWidgetLister( TQWidget *parent=0, const char* name=0 );
261 
262  virtual ~KMFilterActionWidgetLister();
263 
264  void setActionList( TQPtrList<KMFilterAction> * aList );
265 
267  void updateActionList() { regenerateActionListFromWidgets(); }
268 
269 public slots:
270  void reset();
271 
272 protected:
273  virtual void clearWidget( TQWidget *aWidget );
274  virtual TQWidget* createWidget( TQWidget *parent );
275 
276 private:
277  void regenerateActionListFromWidgets();
278  TQPtrList<KMFilterAction> *mActionList;
279 
280 };
281 
282 
283 
339 class KMFilterDlg: public KDialogBase
340 {
341  Q_OBJECT
342 
343 public:
347  KMFilterDlg( TQWidget* parent=0, const char* name=0, bool popFilter=false,
348  bool createDummyFilter=true );
349 
354  void createFilter( const TQCString & field, const TQString & value )
355  { mFilterList->createFilter( field, value ); }
356 
357 public slots:
362  void slotFilterSelected(KMFilter * aFilter);
364  void slotActionChanged(const KMPopFilterAction aAction);
365 
366 protected slots:
367  void slotApplicabilityChanged();
368  void slotApplicableAccountsChanged();
369  void slotStopProcessingButtonToggled( bool aChecked );
370  void slotConfigureShortcutButtonToggled( bool aChecked );
371  void slotCapturedShortcutChanged( const TDEShortcut& );
372  void slotConfigureToolbarButtonToggled( bool aChecked );
373  void slotFilterActionIconChanged( TQString icon );
374  void slotReset();
375  void slotUpdateFilter();
376  void slotSaveSize();
377  // called when the dialog is closed (finished)
378  void slotFinished();
379  // update the list of accounts shown in the advanced tab
380  void slotUpdateAccountList();
381 
382 
386  void slotImportFilters();
387 
391  void slotExportFilters();
392 
393 protected:
401  KMFilterActionWidgetLister *mActionLister;
403  KMPopFilterActionWidget *mActionGroup;
406  TQCheckBox *mApplyOnIn, *mApplyOnOut, *mApplyOnCtrlJ;
409  TQRadioButton *mApplyOnForAll, *mApplyOnForTraditional, *mApplyOnForChecked;
411  TDEListView *mAccountList;
412 
413  TQCheckBox *mStopProcessingHere;
414  TQCheckBox *mConfigureShortcut;
415  TQCheckBox *mConfigureToolbar;
416  TQLabel *mFilterActionLabel;
417  TDEIconButton *mFilterActionIconButton;
418  KKeyButton *mKeyButton;
419  TQGroupBox *mAdvOptsGroup;
420  TQVGroupBox *mGlobalsBox;
421  TQCheckBox *mShowLaterBtn;
422 
423  KMFilter *mFilter;
424  bool bPopFilter;
425 };
426 
427 
428 
429 #endif /*kmfilterdlg_h*/
TQListBox * mListBox
The listbox displaying the filter list.
Definition: kmfilterdlg.h:159
void slotTop()
Called when the user clicks the &#39;Top&#39; button.
TQValueList< KMFilter * > filtersForSaving() const
Returns a list of copies of the current list of filters.
TQRadioButton * mApplyOnForAll
For a filter applied to inbound messages selects whether to apply this filter to all accounts or to s...
Definition: kmfilterdlg.h:409
TDEListView * mAccountList
ListView that shows the accounts in the advanced tab.
Definition: kmfilterdlg.h:411
void createFilter(const TQCString &field, const TQString &value)
Called from KMFilterDlg.
Abstract base class for KMail&#39;s filter actions.
This widgets allows to edit a single KMFilterAction (in fact any derived class that is registered in ...
Definition: kmfilterdlg.h:196
bool showLaterMsgs()
Returns wheather the global option &#39;Show Later Msgs&#39; is set or not.
void slotRename()
Called when the user clicks the &#39;Rename&#39; button.
KMFilterListBox(const TQString &title, TQWidget *parent=0, const char *name=0, bool popFilter=false)
Constuctor.
void slotCopy()
Called when the user clicks the &#39;Copy&#39; button.
void resetWidgets()
Emitted when this widget wants the edit widgets to let go of their filter reference.
void slotShowLaterToggled(bool aOn)
Called when the user toggles the &#39;Show Download Later Msgs&#39; Checkbox in the Global Options section...
TQPushButton * mBtnNew
The various action buttons.
Definition: kmfilterdlg.h:161
void slotDown()
Called when the user clicks the &#39;Down&#39; button.
KMSearchPatternEdit * mPatternEdit
The widget that allows editing of the filter pattern.
Definition: kmfilterdlg.h:399
void slotUp()
Called when the user clicks the &#39;Up&#39; button.
int mIdxSelItem
The index of the currently selected item.
Definition: kmfilterdlg.h:164
The filter dialog.
Definition: kmfilterdlg.h:339
KMFilterListBox * mFilterList
The widget that contains the ListBox showing the filters, and the controls to remove filters...
Definition: kmfilterdlg.h:397
This widget is intended to be used in the filter configuration as well as in the message search dialo...
KMPopFilterActionWidget * mActionGroup
The widget that allows editing the popFilter actions.
Definition: kmfilterdlg.h:403
This is a complex widget that is used to manipulate KMail&#39;s filter list.
Definition: kmfilterdlg.h:60
void slotDelete()
Called when the user clicks the &#39;Delete&#39; button.
void slotBottom()
Called when the user clicks the &#39;Bottom&#39; button.
void slotUpdateFilterName()
Called when the name of a filter might have changed (e.g.
void slotNew()
Called when the user clicks the &#39;New&#39; button.
void slotSelected(int aIdx)
Called when the user clicks on a filter in the filter list.
void applyWidgets()
Emitted when this widget wants the edit widgets to apply the changes to the current filter...
void createFilter(const TQCString &field, const TQString &value)
Called from KMFilterMgr.
Definition: kmfilterdlg.h:354
TQPtrList< KMFilter > mFilterList
The deep copy of the filter list.
Definition: kmfilterdlg.h:157
void slotApplyFilterChanges()
Called when the user clicks either &#39;Apply&#39; or &#39;OK&#39; in KMFilterDlg.
void loadFilterList(bool createDummyFilter)
Loads the filter list and selects the first filter.
void filterSelected(KMFilter *filter)
Emitted when a new filter has been selected by the user or if the current filter has changed after a ...
KMFilterActionWidgetLister * mActionLister
The widget that allows editing of the filter actions.
Definition: kmfilterdlg.h:401
TQCheckBox * mApplyOnIn
Lets the user select whether to apply this filter on inbound/outbound messages, both, or only on explicit CTRL-J.
Definition: kmfilterdlg.h:406