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"
24 #include "libkdepim/widgets/kwidgetlister.h"
32 #include <QStackedWidget>
43 class ScoreEditWidget
;
47 /** this widget implements an editor for one condition.
48 It is used in ExpressionEditWidget
50 class KNODE_EXPORT SingleConditionWidget
: public QFrame
53 friend class ConditionEditWidget
;
56 explicit SingleConditionWidget( KScoringManager
*, QWidget
*p
=0, const char *n
=0 );
57 ~SingleConditionWidget();
58 void setCondition( KScoringExpression
* );
59 KScoringExpression
*createCondition() const;
63 void toggleRegExpButton( int );
64 void showRegExpDialog();
67 /** marks a condition as negated */
69 /** list of possible headers */
71 /** list of match types */
73 /** the expression which will be matched */
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
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
* );
94 void slotEditRule( KScoringRule
* );
97 KScoringManager
*manager
;
100 /** this widget implements an editor for one action.
101 It is used in ActionEditWidget
103 class SingleActionWidget
: public QWidget
106 friend class ActionEditWidget
;
109 explicit SingleActionWidget( KScoringManager
*m
, QWidget
*p
=0, const char *n
=0 );
110 ~SingleActionWidget();
111 void setAction( ActionBase
* );
112 ActionBase
*createAction() const;
116 /** the list of available action */
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 */
129 KScoringManager
*manager
;
132 /** this widget implements the action editor
134 class KNODE_EXPORT ActionEditWidget
: public KWidgetLister
138 explicit ActionEditWidget( KScoringManager
*m
, QWidget
*p
=0, const char *n
=0 );
140 QWidget
*createWidget( QWidget
*parent
);
141 void updateRule( KScoringRule
* );
142 void clearWidget( QWidget
* );
145 void slotEditRule( KScoringRule
* );
148 KScoringManager
*manager
;
151 /** This widget implements the rule editor
153 class RuleEditWidget
: public QWidget
157 explicit RuleEditWidget( KScoringManager
*m
, QWidget
*p
=0, const char *n
=0 );
162 void slotEditRule( const QString
& );
163 void updateRule( KScoringRule
* );
174 void slotExpireEditChanged( int value
);
177 void clearContents();
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 */
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
205 /** This widget shows a list of rules with buttons for
208 class KNODE_EXPORT RuleListWidget
: public QWidget
212 explicit RuleListWidget( KScoringManager
*m
, bool=false, QWidget
*p
=0, const char *n
=0 );
214 QString
currentRule() const { return ruleList
->currentText(); }
220 void ruleSelected( const QString
& );
221 void ruleEdited( const QString
& );
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
& );
233 void slotGroupFilter( const QString
& );
234 void slotEditRule( Q3ListBoxItem
* );
235 void slotEditRule( const QString
& );
244 /** the list of rules */
246 /** the current group */
248 /** marks if we're alone or together with the edit widget */
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
266 void setRule( KScoringRule
* );
267 static KScoringEditor
*createEditor( KScoringManager
*m
, QWidget
*parent
=0 );
268 static KScoringEditor
*editor() { return scoreEditor
; }
272 KScoringEditor( KScoringManager
*m
, QWidget
*parent
=0 );
275 /** the editor for the current rule */
276 RuleEditWidget
*ruleEditor
;
277 /** the list of known rules */
278 RuleListWidget
*ruleLister
;
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
299 KScoringEditorWidgetDialog( KScoringManager
*m
, const QString
&rName
, QWidget
*parent
=0 );
308 RuleEditWidget
*ruleEditor
;
309 KScoringManager
*manager
;
313 class KNODE_EXPORT KScoringEditorWidget
: public QWidget
317 explicit KScoringEditorWidget( KScoringManager
*m
, QWidget
*p
=0, const char *n
=0 );
318 ~KScoringEditorWidget();
321 void slotRuleEdited( const QString
& );
324 RuleListWidget
*ruleLister
;
325 KScoringManager
*manager
;
330 #endif // LIBKDEPIM_KSCORINGEDITOR_H