kmail

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