libtdepim

ksubscription.h
Go to the documentation of this file.
1 /*
2  This file is part of libtdepim.
3 
4  Copyright (C) 2002 Carsten Burghardt <burghardt@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
25 #ifndef __KSUBSCRIPTION
26 #define __KSUBSCRIPTION
27 
28 #include <tqlistview.h>
29 #include <tqcheckbox.h>
30 
31 #include <kdialogbase.h>
32 #include <tdemacros.h>
33 #include "kfoldertree.h"
34 
35 class KSubscription;
36 
37 class KLineEdit;
38 class TQLayout;
39 class TQLabel;
40 class TQGridLayout;
41 class KAccount;
42 
43 //==========================================================================
44 
45 class TDE_EXPORT KGroupInfo
46 {
47  public:
48  enum Status {
49  unknown,
50  readOnly,
51  postingAllowed,
52  moderated
53  };
54 
55  KGroupInfo( const TQString &name, const TQString &description = TQString(),
56  bool newGroup = false, bool subscribed = false,
57  Status status = unknown, TQString path = TQString() );
58 
59  TQString name, description;
60  bool newGroup, subscribed;
61  Status status;
62  TQString path;
63 
64  bool operator== (const KGroupInfo &gi2);
65  bool operator< (const KGroupInfo &gi2);
66 
67 };
68 
69 //==========================================================================
70 
72 class TDE_EXPORT GroupItem : public TQCheckListItem
73 {
74  public:
75  GroupItem( TQListView *v, const KGroupInfo &gi, KSubscription* browser,
76  bool isCheckItem = false );
77  GroupItem( TQListViewItem *i, const KGroupInfo &gi, KSubscription* browser,
78  bool isCheckItem = false );
79 
83  KGroupInfo info() { return mInfo; }
84  void setInfo( KGroupInfo info );
85 
89  TQListViewItem* originalParent() { return mOriginalParent; }
90  void setOriginalParent( TQListViewItem* parent ) { mOriginalParent = parent; }
91 
95  bool lastOpenState() { return mLastOpenState; }
96  void setLastOpenState( bool last ) { mLastOpenState = last; }
97 
102  virtual void setDescription();
103 
107  bool isCheckItem() const { return mIsCheckItem; }
108 
112  bool ignoreStateChange() { return mIgnoreStateChange; }
113  void setIgnoreStateChange( bool ignore ) { mIgnoreStateChange = ignore; }
114 
119  virtual void setOn( bool on );
120 
125  virtual void stateChange( bool on );
126 
131  void setVisible( bool b );
132 
137  virtual void paintCell( TQPainter * p, const TQColorGroup & cg,
138  int column, int width, int align );
139 
144  virtual void paintFocus( TQPainter *, const TQColorGroup & cg,
145  const TQRect & r );
146 
151  virtual int width( const TQFontMetrics&, const TQListView*, int column) const;
152 
157  virtual void setup();
158 
160  virtual int rtti () const { return 15689; }
161 
162  protected:
163  KGroupInfo mInfo;
164  KSubscription* mBrowser;
165  TQListViewItem* mOriginalParent;
166  // remember last open state
167  bool mLastOpenState;
168  // is this a checkable item
169  bool mIsCheckItem;
170  // ignore state changes
171  bool mIgnoreStateChange;
172 };
173 
174 //==========================================================================
175 
188 class TDE_EXPORT KSubscription : public KDialogBase
189 {
190  TQ_OBJECT
191 
192 
193  public:
197  enum Direction {
198  Left,
199  Right
200  };
201 
202  KSubscription( TQWidget *parent, const TQString &caption, KAccount* acct,
203  int buttons = 0, const TQString &user1 = TQString(),
204  bool descriptionColumn = true );
205 
206  ~KSubscription();
207 
211  KAccount* account() { return mAcct; }
212  void setAccount( KAccount * acct ) { mAcct = acct; }
213 
217  TQListView* folderTree() { return groupView; }
218 
222  KLineEdit* searchField() { return filterEdit; }
223 
227  void setStartItem( const KGroupInfo &info );
228 
232  void removeListItem( TQListView *view, const KGroupInfo &gi );
233 
238  TQListViewItem* getListItem( TQListView *view, const KGroupInfo &gi );
239 
243  bool itemInListView( TQListView *view, const KGroupInfo &gi );
244 
249  void changeItemState( GroupItem* item, bool on );
250 
254  Direction directionButton1() { return mDirButton1; }
255  void setDirectionButton1( Direction dir );
256 
260  Direction directionButton2() { return mDirButton2; }
261  void setDirectionButton2( Direction dir );
262 
267  bool isLoading() { return mLoading; }
268 
272  void hideTreeCheckbox() { noTreeCB->hide(); }
273 
277  void hideNewOnlyCheckbox() { newCB->hide(); }
278 
283  void filterChanged( TQListViewItem* item = 0,
284  const TQString & text = TQString() );
285 
289  uint activeItemCount();
290 
294  void restoreOriginalParent();
295 
299  void saveOpenStates();
300 
304  void restoreOpenStates();
305 
306 
307  public slots:
311  void slotLoadingComplete();
312 
316  void slotChangeButtonState( TQListViewItem* );
317 
321  void slotButton1();
322  void slotButton2();
323 
327  void slotUpdateStatusLabel();
328 
332  void slotLoadFolders();
333 
334  protected slots:
338  void slotCBToggled();
339 
343  void slotFilterTextChanged( const TQString & text );
344 
345  signals:
350  void listChanged();
351 
352 
353  protected:
354  // current account
355  KAccount* mAcct;
356 
357  // widgets
358  TQWidget *page;
359  TQListView *groupView;
360  TQListView *subView, *unsubView;
361  KLineEdit *filterEdit;
362  TQCheckBox *noTreeCB, *subCB, *newCB;
363  TQPushButton *arrowBtn1, *arrowBtn2;
364  TQIconSet pmRight, pmLeft;
365  TQGridLayout *listL;
366  TQLabel *leftLabel, *rightLabel;
367 
368  // false if all items are loaded
369  bool mLoading;
370 
371  // directions
372  Direction mDirButton1;
373  Direction mDirButton2;
374 
375  // remember last searchtext
376  TQString mLastText;
377 
378  // remember description column
379  int mDescrColumn;
380 };
381 
382 #endif
A class representing a single group item (what's that?)
Definition: ksubscription.h:73
bool isCheckItem() const
Get if this is a checkable item.
bool ignoreStateChange()
Get/Set if state changes should be ignored.
KGroupInfo info()
Get/Set the KGroupInfo.
Definition: ksubscription.h:83
TQListViewItem * originalParent()
Get/Set the original parent.
Definition: ksubscription.h:89
virtual int rtti() const
Reimplemented.
bool lastOpenState()
Get/Set the last open state.
Definition: ksubscription.h:95
This class provides a generic subscription widget The dialog itself has a main listview that holds al...
void hideTreeCheckbox()
Hide 'Disable tree view' checkbox.
bool isLoading()
Returns true if items are being constructed Call 'slotLoadingComplete' to switch this.
KAccount * account()
Get/Set the account.
KLineEdit * searchField()
Access to the searchfield.
Direction
The direction of the buttons.
void listChanged()
Emitted when the amount of items in the groupView changes (e.g.
Direction directionButton1()
Get/Set the direction of button1.
TQListView * folderTree()
Access to the treewidget that holds the GroupItems.
Direction directionButton2()
Get/Set the direction of button2.
void hideNewOnlyCheckbox()
Hide 'New Only' checkbox.