summaryrefslogtreecommitdiffstats
path: root/kshowmail/kcmconfigs/filtersetupdialog.h
blob: b989238dd0eb18236d53ad1486338e0a8725cc76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
//
// C++ Interface: filtersetupdialog
//
// Description:
//
//
// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef FILTERSETUPDIALOG_H
#define FILTERSETUPDIALOG_H

//button IDs
#define ID_BUTTON_LINKAGE_MATCH_ALL 1
#define ID_BUTTON_LINKAGE_MATCH_ANY 2

//TQt headers
#include <ntqlayout.h>
#include <ntqgroupbox.h>
#include <ntqbuttongroup.h>
#include <ntqradiobutton.h>
#include <ntqvbox.h>
#include <ntqobjectlist.h>
#include <ntqtooltip.h>
#include <ntqlabel.h>

//KDE headers
#include <kdialogbase.h>
#include <tdelocale.h>
#include <kpushbutton.h>
#include <kcombobox.h>
#include <klineedit.h>

//KShowmail headers
#include "filtersetupitem.h"
#include "filtercriteriawidget.h"
#include "../constants.h"
#include "mailboxwizard.h"

//IDs of the action combo box
#define ID_COMBO_FILTER_ACTION_PASS       0
#define ID_COMBO_FILTER_ACTION_DELETE     1
#define ID_COMBO_FILTER_ACTION_MARK       2
#define ID_COMBO_FILTER_ACTION_MOVE       3
#define ID_COMBO_FILTER_ACTION_SPAMCHECK  4
#define ID_COMBO_FILTER_ACTION_IGNORE     5

/**
 * @brief Dialog to setup a filter.
 * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
 */
class FilterSetupDialog : public KDialogBase
{

  Q_OBJECT

  public:
   /**
    * General constructor
    * @param parent parent of the dialog
    * @param item filter to setup;
    */
    FilterSetupDialog( TQWidget* parent, FilterSetupItem* item = NULL );

    /**
     * Destructor
     */
    ~FilterSetupDialog();

  private:

   /**
    * filter to setup
    */
    FilterSetupItem* filter;

    /**
     * View which shows the filter items.
     */
    TDEListView* ListView;

    /**
     * Contains the filter name.
     */
    KLineEdit* txtName;

    /**
     * Combines the radio buttons to select the kind of linkage between the criterias.
     */
    TQButtonGroup* grpLinkage;

    /**
     * This widget holds one ore more filter criteria dialogs (class FilterCriteriaWidget).
     */
    TQWidget* wdgCriteriasHolding;

    /**
     * Layout for wdgCriterias.
     */
    TQVBoxLayout* layCriteriasHolding;

    /**
     * Button to add a criteria dialog.
     */
    KPushButton* btnAddCriteria;

    /**
     * Button to remove the last criteria.
     */
    KPushButton* btnRemoveCriteria;

    /**
     * Combobox to select the action.
     */
    KComboBox* cmbAction;

    /**
     * If selected, the mails will be moved to the mailbox which is written in this edit line.
     */
    KLineEdit* txtMailbox;

    /**
     * This button opens a wizard which will help to get the right mailbox
     */
    KPushButton* btnMailboxWizard;


  protected:

    /**
     * Writes the values of the given filter into the dialog items.
     */
    void fillDialog();

    /**
     * Adds a criteria widget dialog with values for numeric comparison.
     * @param source Object of Comparison. It accepts only numeric objects (e.g. Size) (see constants.h for valid values)
     * @param condition Condition of the comparison (see constants.h for valid values)
     * @param value comparison value
     */
    void addCriteriaWidget( int source, int condition, uint value );

    /**
     * Adds a criteria widget dialog with values for text comparison.
     * @param source Object of Comparison. It accepts only text objects (e.g. Subject) (see constants.h for valid values)
     * @param condition Condition of the comparison (see constants.h for valid values)
     * @param value comparison string
     * @param cs TRUE - comparison is case sensitive; FALSE - comparison is not case sensitive
     */
    void addCriteriaWidget( int source, int condition, TQString value, bool cs );


  protected slots:

    /**
     * Overwritten method of KDialogBase.
     * Called if OK was clicked.
     * Stores the entered values into the given account item.
     * If no item was given it creates a new one.
     * After then it invokes slotOk() of KDialogBase.
     */
    void slotOk();

    /**
     * Connected with combobox cmbAction.
     * Enables or disables additional widgets for action configuration.
     * @param index position (index) of the selected action
     */
    void slotActionChanged( int index );

    /**
     * Adds a empty critera dialog widget.
     * @return Pointer to the new widget
     */
    FilterCriteriaWidget* slotAddCriteriaWidget();

    /**
     * Removes the last criteria dialog widget.
     */
    void slotRemoveCriteriaWidget();

    /**
     * Connected with button btnMailboxWizard.
     * Opens a wizard to configure the mailbox
     */
    void slotOpenMailBoxWizard();
};

#endif