kmail

kmsearchpatternedit.h
1 // kmfilterrulesedit.h
2 // Author: Marc Mutz <Marc@Mutz.com>
3 // This code is under GPL
4 
5 #ifndef KMFILTERRULESEDIT_H
6 #define KMFILTERRULESEDIT_H
7 
8 #include "kwidgetlister.h"
9 
10 #include <tqgroupbox.h>
11 #include <tqstringlist.h>
12 
13 class KMSearchRule;
14 class KMSearchPattern;
15 
16 template <typename T> class TQPtrList;
17 class TQString;
18 class TQComboBox;
19 class TQLineEdit;
20 class TQRadioButton;
21 class TQWidgetStack;
22 class TQLabel;
24 
39 class KMSearchRuleWidget : public TQWidget
40 {
41  TQ_OBJECT
42 
43 public:
46  KMSearchRuleWidget( TQWidget* parent=0, KMSearchRule* aRule=0, const char* name=0, bool headersOnly = false, bool absoluteDates = false );
47 
48  enum { Message, Body, AnyHeader, Recipients, Size, AgeInDays, Status,
49  Subject, From, To, CC, ReplyTo, Organization };
50 
54  void setHeadersOnly( bool headersOnly );
60  void setRule( KMSearchRule* aRule );
62  KMSearchRule* rule() const;
65  void reset();
66  static int ruleFieldToId( const TQString & i18nVal );
67 
68 public slots:
69  void slotFunctionChanged();
70  void slotValueChanged();
71 
72 signals:
76  void fieldChanged( const TQString & );
77 
80  void contentsChanged( const TQString & );
81 
82 protected:
85  static TQCString ruleFieldToEnglish(const TQString & i18nVal);
88  int indexOfRuleField( const TQCString & aName ) const;
89 
90 protected slots:
91  void slotRuleFieldChanged( const TQString & );
92 
93 private:
94  void initWidget();
95  void initFieldList( bool headersOnly, bool absoluteDates );
96 
97  TQStringList mFilterFieldList;
98  TQComboBox *mRuleField;
99  TQWidgetStack *mFunctionStack;
100  TQWidgetStack *mValueStack;
101  bool mAbsoluteDates;
102 };
103 
104 
105 class KMSearchRuleWidgetLister : public KWidgetLister
106 {
107  TQ_OBJECT
108 
109 
110  friend class ::KMSearchPatternEdit;
111 
112 public:
113  KMSearchRuleWidgetLister( TQWidget *parent=0, const char* name=0, bool headersOnly = false, bool absoluteDates = false );
114 
115  virtual ~KMSearchRuleWidgetLister();
116 
117  void setRuleList( TQPtrList<KMSearchRule> * aList );
118  void setHeadersOnly( bool headersOnly );
119 
120 public slots:
121  void reset();
122 
123 protected:
124  virtual void clearWidget( TQWidget *aWidget );
125  virtual TQWidget* createWidget( TQWidget *parent );
126 
127 private:
128  void regenerateRuleListFromWidgets();
129  TQPtrList<KMSearchRule> *mRuleList;
130  bool mHeadersOnly;
131  bool mAbsoluteDates;
132 };
133 
134 
167 class KMSearchPatternEdit : public TQGroupBox {
168  TQ_OBJECT
169 
170 public:
173  KMSearchPatternEdit(TQWidget *parent=0, const char *name=0, bool headersOnly = false, bool absoluteDates = false);
176  KMSearchPatternEdit(const TQString & title, TQWidget *parent=0, const char *name=0, bool headersOnly = false, bool absoluteDates = false);
178 
183  void setSearchPattern( KMSearchPattern* aPattern );
187  void setHeadersOnly( bool headersOnly );
188 
190  void updateSearchPattern() { mRuleLister->regenerateRuleListFromWidgets(); }
191 
192 public slots:
195  void reset();
196 
197 signals:
201 
202 private slots:
203  void slotRadioClicked(int aIdx);
204  void slotAutoNameHack();
205 
206 private:
207  void initLayout( bool headersOnly, bool absoluteDates );
208 
209  KMSearchPattern *mPattern;
210  TQRadioButton *mAllRBtn, *mAnyRBtn;
211  KMSearchRuleWidgetLister *mRuleLister;
212 };
213 
214 #endif
This widget is intended to be used in the filter configuration as well as in the message search dialo...
void maybeNameChanged()
This signal is emitted whenever the name of the processed search pattern may have changed.
void updateSearchPattern()
Updates the search pattern according to the current widget values.
KMSearchPatternEdit(TQWidget *parent=0, const char *name=0, bool headersOnly=false, bool absoluteDates=false)
Constructor.
void setHeadersOnly(bool headersOnly)
Set whether only header fields can be searched.
void reset()
Called when the widget should let go of the currently referenced filter and disable itself.
void setSearchPattern(KMSearchPattern *aPattern)
Set the search pattern.
This class is an abstraction of a search over messages.
A widget to edit a single KMSearchRule.
void fieldChanged(const TQString &)
This signal is emitted whenever the user alters the field.
KMSearchRuleWidget(TQWidget *parent=0, KMSearchRule *aRule=0, const char *name=0, bool headersOnly=false, bool absoluteDates=false)
Constructor.
void setRule(KMSearchRule *aRule)
Set the rule.
KMSearchRule * rule() const
Return a reference to the currently-worked-on KMSearchRule.
int indexOfRuleField(const TQCString &aName) const
Used internally to find the corresponding index into the field ComboBox.
void setHeadersOnly(bool headersOnly)
Set whether only header fields can be searched.
static TQCString ruleFieldToEnglish(const TQString &i18nVal)
Used internally to translate i18n-ized pseudo-headers back to english.
void contentsChanged(const TQString &)
This signal is emitted whenever the user alters the contents/value of the rule.
void reset()
Resets the rule currently worked on and updates the widget accordingly.
Incoming mail is sent through the list of mail filter rules before it is placed in the associated mai...