summaryrefslogtreecommitdiffstats
path: root/kshowmail/kcmconfigs/configfilter.h
blob: 297ba759222ab15e78c33f773a51d5a8d0f30f90 (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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
//
// C++ Interface: configfilter
//
// Description:
//
//
// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef CONFIGFILTER_H
#define CONFIGFILTER_H

//QT headers
#include <tqlayout.h>
#include <tqgroupbox.h>
#include <tqtooltip.h>
#include <tqcheckbox.h>

//KDE headers
#include <tdecmodule.h>
#include <tdeconfig.h>
#include <kgenericfactory.h>
#include <tdeapplication.h>
#include <tdelistview.h>
#include <kpushbutton.h>
#include <kcombobox.h>
#include <klineedit.h>

//Kshowmail headers
#include "../constants.h"
#include "senderlistdialog.h"
#include "filtersetupdialog.h"
#include "mailboxwizard.h"

//radio button IDs
#define ID_COMBO_FILTER_OTHERS_ACTION_PASS       0
#define ID_COMBO_FILTER_OTHERS_ACTION_DELETE     1
#define ID_COMBO_FILTER_OTHERS_ACTION_MARK       2
#define ID_COMBO_FILTER_OTHERS_ACTION_MOVE       3
#define ID_COMBO_FILTER_OTHERS_ACTION_SPAMCHECK  4
#define ID_COMBO_FILTER_OTHERS_ACTION_IGNORE     5


/**
 * @brief Part of the setup dialog (KShowMailApp::SetupDialog) to configure the filter.
 * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
 */
class ConfigFilter : public TDECModule
{
Q_OBJECT

  public:

    /**
     * Generic constructor
     */
    ConfigFilter( TQWidget* parent = 0, const char* name = 0, const TQStringList &args = TQStringList() );

    /**
     * Destructor
     */
    ~ConfigFilter();

    /**
     * Overloaded method of TDECModule.
     * Sets the user interface elements to reflect the current settings stored in the
     * config file.
     */
    virtual void load();

    /**
     * Overloaded method of TDECModule.
     * Sets the user interface elements to default values.
     * This method is called when the user clicks the "Default" button.
     */
    virtual void defaults();

    /**
     * Overloaded method of TDECModule.
     * Stores the config information as shown in the user interface in the
     * config file.
     * Is called when the user clicks "Apply" or "Ok".
     */
    virtual void save();

  private:

    /**
     * Connector to the configuration file
     */
    TDEConfig* config;

    /**
     * Check box to activate the filter
     */
    TQCheckBox* chkActivateFilter;

    /**
     * Group box for sender lists.
     */
    TQGroupBox* gboxSenderLists;

    /**
     * Group box for filter items.
     */
    TQGroupBox* gboxFilters;

    /**
     * Group box for other action.
     */
    TQGroupBox* gboxOthers;

    /**
     * Button to open the Blacklist.
     */
    KPushButton* btnOpenBlacklist;

    /**
     * Button to open the Whitelist.
     */
    KPushButton* btnOpenWhitelist;

    /**
     * List of filters
     */
    TDEListView* listFilters;

    /**
     * Button to move a filter at top.
     */
    KPushButton* btnMoveTop;

    /**
     * Button to move a filter at bottom.
     */
    KPushButton* btnMoveBottom;

    /**
     * Button to move a filter up.
     */
    KPushButton* btnMoveUp;

    /**
     * Button to move a filter down.
     */
    KPushButton* btnMoveDown;

    /**
     * Button to add a new filter.
     */
    KPushButton* btnAdd;

    /**
     * Button to edit a filter.
     */
    KPushButton* btnEdit;

    /**
     * Button to remove a filter.
     */
    KPushButton* btnRemove;

    /**
     * Combobox to select the action for the rest of mails.
     */
    KComboBox* cmbActionOthers;

    /**
     * If selected, the other 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;

    /**
     * The last assigned number of a filter setup item.
     * It is set to zero by the constructor. Therefore the first filter number is 1.
     */
    uint lastFilterNumber;

  private slots:

   /**
    * Connected with the configuration items.
    * Calls the slot changed() of TDECModule to notify the dialog about the change.
    */
    void slotChanged();

    /**
     * Connected with the button btnOpenWhitelist.
     * Creates and opens a dialog to edit the whitelist.
     */
    void slotOpenWhitelist();

    /**
     * Connected with the button btnOpenBlacklist.
     * Creates and opens a dialog to edit the blacklist.
     */
    void slotOpenBlacklist();

    /**
     * Connected with button btnAdd.
     * Opens the account setup dialog with an account item pointer of NULL.
     * If the user has clicked OK, the dialog will create a new account item with
     * the entered values and adds it to the list view.
     */
    void slotAdd();

    /**
     * Connected with button btnEdit.
     * Opens the account setup with the selected account item.
     */
    void slotEdit();

    /**
     * Connected with button btnRemove.
     * Removes the selected item.
     */
    void slotRemove();

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

    /**
     * Connected with button btnMoveTop.
     * Moves the selected filter item at the top of the list, i.e. the number of this item will be the least one.
     */
    void slotMoveTop();

    /**
     * Connected with button btnMoveBottom.
     * Moves the selected filter item at the bottom of the list, i.e. the number of this item will be the greatest one.
     */
    void slotMoveBottom();

    /**
     * Connected with button btnMoveUp.
     * Moves the selected filter item up, i.e. the number of this item will be decreased.
     */
    void slotMoveUp();

    /**
     * Connected with button btnMoveDown.
     * Moves the selected filter item down, i.e. the number of this item will be increased.
     */
    void slotMoveDown();

    /**
     * Connected with chkActivateFilter, signal toggled().
     * Enabled or disabled the other widget of this GUI.
     * @param filterOn TRUE - filter is active; FALSE - filter is not active
     */
    void slotFilterActiveToggled( bool filterOn );

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


  protected:

    /**
     * Decrease the numbers of these filter setup items whose number is greater than or equals num.
     * @param number start number of renumbering
     */
    void decreaseNumbers( uint number );

    /**
     * Returns the pointer to the filter setup item with number num. Returns 0 if no item found.
     * @param num number of the searched filter item
     * @return pointer to the found item
     */
    FilterSetupItem* getFilterItem( uint num );

};

#endif