split message into several paras and fix file extension markup
[kdepim.git] / knode / kscoringeditor.h
blobf8baa12fad7adc87228a47f0603f9be261e63cb1
1 /*
2 kscoringeditor.h
4 Copyright (c) 2001 Mathias Waack <mathias@atoll-net.de>
5 Copyright (C) 2005 by Volker Krause <vkrause@kde.org>
7 Author: Mathias Waack <mathias@atoll-net.de>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software Foundation,
15 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
18 #ifndef LIBKDEPIM_KSCORINGEDITOR_H
19 #define LIBKDEPIM_KSCORINGEDITOR_H
21 #include "knode_export.h"
22 #include "kscoring.h"
24 #include "libkdepim/widgets/kwidgetlister.h"
26 #include <KDialog>
27 #include <K3ListBox>
29 #include <QMap>
30 #include <QLabel>
31 #include <QFrame>
32 #include <QStackedWidget>
34 class KComboBox;
35 class KColorCombo;
36 class KLineEdit;
37 class KIntSpinBox;
38 class QLabel;
39 class Q3ListBoxItem;
40 class QPushButton;
41 class QCheckBox;
42 class QRadioButton;
43 class ScoreEditWidget;
45 namespace KPIM {
47 /** this widget implements an editor for one condition.
48 It is used in ExpressionEditWidget
50 class KNODE_EXPORT SingleConditionWidget : public QFrame
52 Q_OBJECT
53 friend class ConditionEditWidget;
55 public:
56 explicit SingleConditionWidget( KScoringManager *, QWidget *p=0, const char *n=0 );
57 ~SingleConditionWidget();
58 void setCondition( KScoringExpression * );
59 KScoringExpression *createCondition() const;
60 void clear();
62 protected Q_SLOTS:
63 void toggleRegExpButton( int );
64 void showRegExpDialog();
66 private:
67 /** marks a condition as negated */
68 QCheckBox *neg;
69 /** list of possible headers */
70 KComboBox *headers;
71 /** list of match types */
72 KComboBox *matches;
73 /** the expression which will be matched */
74 KLineEdit *expr;
75 /** the button to open the regexp-editor */
76 QPushButton *regExpButton;
78 KScoringManager *manager;
81 /** this widget implements the conditions editor
83 class ConditionEditWidget: public KWidgetLister
85 Q_OBJECT
86 public:
87 explicit ConditionEditWidget( KScoringManager *, QWidget *p=0, const char *n=0 );
88 ~ConditionEditWidget();
89 QWidget *createWidget( QWidget * );
90 void updateRule( KScoringRule * );
91 void clearWidget( QWidget * );
93 public Q_SLOTS:
94 void slotEditRule( KScoringRule * );
96 private:
97 KScoringManager *manager;
100 /** this widget implements an editor for one action.
101 It is used in ActionEditWidget
103 class SingleActionWidget : public QWidget
105 Q_OBJECT
106 friend class ActionEditWidget;
108 public:
109 explicit SingleActionWidget( KScoringManager *m, QWidget *p=0, const char *n=0 );
110 ~SingleActionWidget();
111 void setAction( ActionBase * );
112 ActionBase *createAction() const;
113 void clear();
115 private:
116 /** the list of available action */
117 KComboBox *types;
118 /** the stack of the edit widgets for each action type */
119 QStackedWidget *stack;
120 /** the notify action editor */
121 KLineEdit *notifyEditor;
122 /** the score action editor */
123 KIntSpinBox *scoreEditor;
124 /** the color action editor */
125 KColorCombo *colorEditor;
126 /** the dummy label */
127 QLabel *dummyLabel;
129 KScoringManager *manager;
132 /** this widget implements the action editor
134 class KNODE_EXPORT ActionEditWidget : public KWidgetLister
136 Q_OBJECT
137 public:
138 explicit ActionEditWidget( KScoringManager *m, QWidget *p=0, const char *n=0 );
139 ~ActionEditWidget();
140 QWidget *createWidget( QWidget *parent );
141 void updateRule( KScoringRule * );
142 void clearWidget( QWidget * );
144 public Q_SLOTS:
145 void slotEditRule( KScoringRule * );
147 private:
148 KScoringManager *manager;
151 /** This widget implements the rule editor
153 class RuleEditWidget : public QWidget
155 Q_OBJECT
156 public:
157 explicit RuleEditWidget( KScoringManager *m, QWidget *p=0, const char *n=0 );
158 ~RuleEditWidget();
160 public Q_SLOTS:
161 void setDirty();
162 void slotEditRule( const QString & );
163 void updateRule( KScoringRule * );
164 void updateRule();
166 Q_SIGNALS:
167 void shrink();
169 protected Q_SLOTS:
170 void slotAddGroup();
171 void slotShrink();
173 private Q_SLOTS:
174 void slotExpireEditChanged( int value );
176 private:
177 void clearContents();
179 bool dirty;
180 /** the name of the rule */
181 KLineEdit *ruleNameEdit;
182 /** the list of groups this rule applies to */
183 KLineEdit *groupsEdit;
184 /** list of all available groups */
185 KComboBox *groupsBox;
186 /** the expire enable */
187 QCheckBox *expireCheck;
188 /** the label to the expireCheck */
189 QLabel *expireLabel;
190 /** the expire delay */
191 KIntSpinBox *expireEdit;
192 /** the link modes of the conditions */
193 QRadioButton *linkModeOr, *linkModeAnd;
194 /** the actions editor */
195 ActionEditWidget *actionEditor;
196 /** the conditions editor */
197 ConditionEditWidget *condEditor;
199 KScoringManager *manager;
201 // the old name of the current rule
202 QString oldRuleName;
205 /** This widget shows a list of rules with buttons for
206 copy, delete aso.
208 class KNODE_EXPORT RuleListWidget : public QWidget
210 Q_OBJECT
211 public:
212 explicit RuleListWidget( KScoringManager *m, bool=false, QWidget *p=0, const char *n=0 );
213 ~RuleListWidget();
214 QString currentRule() const { return ruleList->currentText(); }
216 protected:
217 void updateButton();
219 Q_SIGNALS:
220 void ruleSelected( const QString & );
221 void ruleEdited( const QString & );
222 void leavingRule();
224 public Q_SLOTS:
225 void slotRuleSelected( const QString & );
226 void slotRuleSelected( Q3ListBoxItem * );
227 void slotRuleSelected( int );
228 void updateRuleList();
229 void updateRuleList( const KScoringRule * );
230 void slotRuleNameChanged( const QString &, const QString & );
232 protected Q_SLOTS:
233 void slotGroupFilter( const QString & );
234 void slotEditRule( Q3ListBoxItem * );
235 void slotEditRule( const QString & );
236 void slotEditRule();
237 void slotDelRule();
238 void slotNewRule();
239 void slotCopyRule();
240 void slotRuleUp();
241 void slotRuleDown();
243 private:
244 /** the list of rules */
245 K3ListBox *ruleList;
246 /** the current group */
247 QString group;
248 /** marks if we're alone or together with the edit widget */
249 bool alone;
251 KScoringManager *manager;
253 QPushButton *editRule;
254 QPushButton *newRule;
255 QPushButton *delRule;
256 QPushButton *copyRule;
257 QPushButton *mRuleUp;
258 QPushButton *mRuleDown;
261 class KNODE_EXPORT KScoringEditor : public KDialog
263 Q_OBJECT
264 public:
265 ~KScoringEditor();
266 void setRule( KScoringRule * );
267 static KScoringEditor *createEditor( KScoringManager *m, QWidget *parent=0 );
268 static KScoringEditor *editor() { return scoreEditor; }
269 void setDirty();
271 protected:
272 KScoringEditor( KScoringManager *m, QWidget *parent=0 );
274 private:
275 /** the editor for the current rule */
276 RuleEditWidget *ruleEditor;
277 /** the list of known rules */
278 RuleListWidget *ruleLister;
280 protected Q_SLOTS:
281 void slotShrink();
282 void slotDoShrink();
283 void slotApply();
284 void slotOk();
285 void slotCancel();
286 void slotFinished();
288 private:
289 KScoringManager *manager;
290 ScoreEditWidget *edit;
291 /** make sure that there is only one instance of ourselve */
292 static KScoringEditor *scoreEditor;
295 class KScoringEditorWidgetDialog : public KDialog
297 Q_OBJECT
298 public:
299 KScoringEditorWidgetDialog( KScoringManager *m, const QString &rName, QWidget *parent=0 );
301 protected Q_SLOTS:
302 void slotApply();
303 void slotOk();
304 void slotShrink();
305 void slotDoShrink();
307 private:
308 RuleEditWidget *ruleEditor;
309 KScoringManager *manager;
310 QString ruleName;
313 class KNODE_EXPORT KScoringEditorWidget : public QWidget
315 Q_OBJECT
316 public:
317 explicit KScoringEditorWidget( KScoringManager *m, QWidget *p=0, const char *n=0 );
318 ~KScoringEditorWidget();
320 protected Q_SLOTS:
321 void slotRuleEdited( const QString & );
323 private:
324 RuleListWidget *ruleLister;
325 KScoringManager *manager;
330 #endif // LIBKDEPIM_KSCORINGEDITOR_H