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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
|
/*
This file is part of libkdepim.
Copyright (C) 2002 Carsten Burghardt <burghardt@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
/** @file
* This file defines a generic subscription widget and some support classes.
*/
#ifndef __KSUBSCRIPTION
#define __KSUBSCRIPTION
#include <tqlistview.h>
#include <tqcheckbox.h>
#include <kdialogbase.h>
#include <kdepimmacros.h>
#include "kfoldertree.h"
class KSubscription;
class KLineEdit;
class TQLayout;
class TQLabel;
class TQGridLayout;
class KAccount;
//==========================================================================
class KDE_EXPORT KGroupInfo
{
public:
enum Status {
unknown,
readOnly,
postingAllowed,
moderated
};
KGroupInfo( const TQString &name, const TQString &description = TQString(),
bool newGroup = false, bool subscribed = false,
Status status = unknown, TQString path = TQString() );
TQString name, description;
bool newGroup, subscribed;
Status status;
TQString path;
bool operator== (const KGroupInfo &gi2);
bool operator< (const KGroupInfo &gi2);
};
//==========================================================================
/** A class representing a single group item (what's that?) */
class KDE_EXPORT GroupItem : public TQCheckListItem
{
public:
GroupItem( TQListView *v, const KGroupInfo &gi, KSubscription* browser,
bool isCheckItem = false );
GroupItem( TQListViewItem *i, const KGroupInfo &gi, KSubscription* browser,
bool isCheckItem = false );
/**
* Get/Set the KGroupInfo
*/
KGroupInfo info() { return mInfo; }
void setInfo( KGroupInfo info );
/**
* Get/Set the original parent
*/
TQListViewItem* originalParent() { return mOriginalParent; }
void setOriginalParent( TQListViewItem* parent ) { mOriginalParent = parent; }
/**
* Get/Set the last open state
*/
bool lastOpenState() { return mLastOpenState; }
void setLastOpenState( bool last ) { mLastOpenState = last; }
/**
* Sets the description from the KGroupInfo
* Reimplement this for special cases
*/
virtual void setDescription();
/**
* Get if this is a checkable item
*/
bool isCheckItem() const { return mIsCheckItem; }
/**
* Get/Set if state changes should be ignored
*/
bool ignoreStateChange() { return mIgnoreStateChange; }
void setIgnoreStateChange( bool ignore ) { mIgnoreStateChange = ignore; }
/**
* Reimplemented
* Sets the subscribed property (only while items are loaded)
*/
virtual void setOn( bool on );
/**
* Reimlemented
* Calls KSubscription::changeItemState if mIgnoreStateChange == false
*/
virtual void stateChange( bool on );
/**
* Reimplemented
* Sets items invisible or disabled or even moves them
*/
void setVisible( bool b );
/**
* Reimplemented
* Calls TQListViewItem or TQCheckListItem
*/
virtual void paintCell( TQPainter * p, const TQColorGroup & cg,
int column, int width, int align );
/**
* Reimplemented
* Calls TQListViewItem or TQCheckListItem
*/
virtual void paintFocus( TQPainter *, const TQColorGroup & cg,
const TQRect & r );
/**
* Reimplemented
* Calls TQListViewItem or TQCheckListItem
*/
virtual int width( const TQFontMetrics&, const TQListView*, int column) const;
/**
* Reimplemented
* Calls TQListViewItem or TQCheckListItem
*/
virtual void setup();
/** Reimplemented */
virtual int rtti () const { return 15689; }
protected:
KGroupInfo mInfo;
KSubscription* mBrowser;
TQListViewItem* mOriginalParent;
// remember last open state
bool mLastOpenState;
// is this a checkable item
bool mIsCheckItem;
// ignore state changes
bool mIgnoreStateChange;
};
//==========================================================================
/**
* This class provides a generic subscription widget
* The dialog itself has a main listview that holds all items and two listviews that
* show all changes. The user can change the state of the items via checkable items.
* When you construct a new instance you need to provide an account and a caption
* After inserting your items (checkable or not) you need to call slotLoadingComplete()
* You should at least connect slots to the signals okClicked() (to save your changes)
* and user1Clicked() (to reload the list)
* You can hide unwanted checkboxes via the respective hide<checkboxname> methods
*
*/
class KDE_EXPORT KSubscription : public KDialogBase
{
Q_OBJECT
TQ_OBJECT
public:
/**
* The direction of the buttons
*/
enum Direction {
Left,
Right
};
KSubscription( TQWidget *parent, const TQString &caption, KAccount* acct,
int buttons = 0, const TQString &user1 = TQString(),
bool descriptionColumn = true );
~KSubscription();
/**
* Get/Set the account
*/
KAccount* account() { return mAcct; }
void setAccount( KAccount * acct ) { mAcct = acct; }
/**
* Access to the treewidget that holds the GroupItems
*/
TQListView* folderTree() { return groupView; }
/**
* Access to the searchfield
*/
KLineEdit* searchField() { return filterEdit; }
/**
* The item that should be selected on startup
*/
void setStartItem( const KGroupInfo &info );
/**
* Removes the item from the listview
*/
void removeListItem( TQListView *view, const KGroupInfo &gi );
/**
* Gets the item from the listview
* Returns 0 if the item can't be found
*/
TQListViewItem* getListItem( TQListView *view, const KGroupInfo &gi );
/**
* Is the item in the given listview
*/
bool itemInListView( TQListView *view, const KGroupInfo &gi );
/**
* Makes all changes after an item is toggled
* called by the item's stateChange-method
*/
void changeItemState( GroupItem* item, bool on );
/**
* Get/Set the direction of button1
*/
Direction directionButton1() { return mDirButton1; }
void setDirectionButton1( Direction dir );
/**
* Get/Set the direction of button2
*/
Direction directionButton2() { return mDirButton2; }
void setDirectionButton2( Direction dir );
/**
* Returns true if items are being constructed
* Call 'slotLoadingComplete' to switch this
*/
bool isLoading() { return mLoading; }
/**
* Hide 'Disable tree view' checkbox
*/
void hideTreeCheckbox() { noTreeCB->hide(); }
/**
* Hide 'New Only' checkbox
*/
void hideNewOnlyCheckbox() { newCB->hide(); }
/**
* Update the item-states (visible, enabled) when a filter
* criteria changed
*/
void filterChanged( TQListViewItem* item = 0,
const TQString & text = TQString() );
/**
* The amount of items that are visible and enabled
*/
uint activeItemCount();
/**
* Moves all items from toplevel back to their original position
*/
void restoreOriginalParent();
/**
* Saves the open states
*/
void saveOpenStates();
/**
* Restores the saved open state
*/
void restoreOpenStates();
public slots:
/**
* Call this slot when you have created all items
*/
void slotLoadingComplete();
/**
* Changes the current state of the buttons
*/
void slotChangeButtonState( TQListViewItem* );
/**
* Buttons are clicked
*/
void slotButton1();
void slotButton2();
/**
* Updates the status-label
*/
void slotUpdateStatusLabel();
/**
* The reload-button is pressed
*/
void slotLoadFolders();
protected slots:
/**
* Slot for the checkboxes
*/
void slotCBToggled();
/**
* Filter text changed
*/
void slotFilterTextChanged( const TQString & text );
signals:
/**
* Emitted when the amount of items in the
* groupView changes (e.g. on filtering)
*/
void listChanged();
protected:
// current account
KAccount* mAcct;
// widgets
TQWidget *page;
TQListView *groupView;
TQListView *subView, *unsubView;
KLineEdit *filterEdit;
TQCheckBox *noTreeCB, *subCB, *newCB;
TQPushButton *arrowBtn1, *arrowBtn2;
TQIconSet pmRight, pmLeft;
TQGridLayout *listL;
TQLabel *leftLabel, *rightLabel;
// false if all items are loaded
bool mLoading;
// directions
Direction mDirButton1;
Direction mDirButton2;
// remember last searchtext
TQString mLastText;
// remember description column
int mDescrColumn;
};
#endif
|