00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025 #ifndef __KSUBSCRIPTION
00026 #define __KSUBSCRIPTION
00027
00028 #include <tqlistview.h>
00029 #include <tqcheckbox.h>
00030
00031 #include <kdialogbase.h>
00032 #include <tdepimmacros.h>
00033 #include "kfoldertree.h"
00034
00035 class KSubscription;
00036
00037 class KLineEdit;
00038 class TQLayout;
00039 class TQLabel;
00040 class TQGridLayout;
00041 class KAccount;
00042
00043
00044
00045 class KDE_EXPORT KGroupInfo
00046 {
00047 public:
00048 enum Status {
00049 unknown,
00050 readOnly,
00051 postingAllowed,
00052 moderated
00053 };
00054
00055 KGroupInfo( const TQString &name, const TQString &description = TQString(),
00056 bool newGroup = false, bool subscribed = false,
00057 Status status = unknown, TQString path = TQString() );
00058
00059 TQString name, description;
00060 bool newGroup, subscribed;
00061 Status status;
00062 TQString path;
00063
00064 bool operator== (const KGroupInfo &gi2);
00065 bool operator< (const KGroupInfo &gi2);
00066
00067 };
00068
00069
00070
00072 class KDE_EXPORT GroupItem : public TQCheckListItem
00073 {
00074 public:
00075 GroupItem( TQListView *v, const KGroupInfo &gi, KSubscription* browser,
00076 bool isCheckItem = false );
00077 GroupItem( TQListViewItem *i, const KGroupInfo &gi, KSubscription* browser,
00078 bool isCheckItem = false );
00079
00083 KGroupInfo info() { return mInfo; }
00084 void setInfo( KGroupInfo info );
00085
00089 TQListViewItem* originalParent() { return mOriginalParent; }
00090 void setOriginalParent( TQListViewItem* parent ) { mOriginalParent = parent; }
00091
00095 bool lastOpenState() { return mLastOpenState; }
00096 void setLastOpenState( bool last ) { mLastOpenState = last; }
00097
00102 virtual void setDescription();
00103
00107 bool isCheckItem() const { return mIsCheckItem; }
00108
00112 bool ignoreStateChange() { return mIgnoreStateChange; }
00113 void setIgnoreStateChange( bool ignore ) { mIgnoreStateChange = ignore; }
00114
00119 virtual void setOn( bool on );
00120
00125 virtual void stateChange( bool on );
00126
00131 void setVisible( bool b );
00132
00137 virtual void paintCell( TQPainter * p, const TQColorGroup & cg,
00138 int column, int width, int align );
00139
00144 virtual void paintFocus( TQPainter *, const TQColorGroup & cg,
00145 const TQRect & r );
00146
00151 virtual int width( const TQFontMetrics&, const TQListView*, int column) const;
00152
00157 virtual void setup();
00158
00160 virtual int rtti () const { return 15689; }
00161
00162 protected:
00163 KGroupInfo mInfo;
00164 KSubscription* mBrowser;
00165 TQListViewItem* mOriginalParent;
00166
00167 bool mLastOpenState;
00168
00169 bool mIsCheckItem;
00170
00171 bool mIgnoreStateChange;
00172 };
00173
00174
00175
00188 class KDE_EXPORT KSubscription : public KDialogBase
00189 {
00190 Q_OBJECT
00191
00192
00193 public:
00197 enum Direction {
00198 Left,
00199 Right
00200 };
00201
00202 KSubscription( TQWidget *parent, const TQString &caption, KAccount* acct,
00203 int buttons = 0, const TQString &user1 = TQString(),
00204 bool descriptionColumn = true );
00205
00206 ~KSubscription();
00207
00211 KAccount* account() { return mAcct; }
00212 void setAccount( KAccount * acct ) { mAcct = acct; }
00213
00217 TQListView* folderTree() { return groupView; }
00218
00222 KLineEdit* searchField() { return filterEdit; }
00223
00227 void setStartItem( const KGroupInfo &info );
00228
00232 void removeListItem( TQListView *view, const KGroupInfo &gi );
00233
00238 TQListViewItem* getListItem( TQListView *view, const KGroupInfo &gi );
00239
00243 bool itemInListView( TQListView *view, const KGroupInfo &gi );
00244
00249 void changeItemState( GroupItem* item, bool on );
00250
00254 Direction directionButton1() { return mDirButton1; }
00255 void setDirectionButton1( Direction dir );
00256
00260 Direction directionButton2() { return mDirButton2; }
00261 void setDirectionButton2( Direction dir );
00262
00267 bool isLoading() { return mLoading; }
00268
00272 void hideTreeCheckbox() { noTreeCB->hide(); }
00273
00277 void hideNewOnlyCheckbox() { newCB->hide(); }
00278
00283 void filterChanged( TQListViewItem* item = 0,
00284 const TQString & text = TQString() );
00285
00289 uint activeItemCount();
00290
00294 void restoreOriginalParent();
00295
00299 void saveOpenStates();
00300
00304 void restoreOpenStates();
00305
00306
00307 public slots:
00311 void slotLoadingComplete();
00312
00316 void slotChangeButtonState( TQListViewItem* );
00317
00321 void slotButton1();
00322 void slotButton2();
00323
00327 void slotUpdateStatusLabel();
00328
00332 void slotLoadFolders();
00333
00334 protected slots:
00338 void slotCBToggled();
00339
00343 void slotFilterTextChanged( const TQString & text );
00344
00345 signals:
00350 void listChanged();
00351
00352
00353 protected:
00354
00355 KAccount* mAcct;
00356
00357
00358 TQWidget *page;
00359 TQListView *groupView;
00360 TQListView *subView, *unsubView;
00361 KLineEdit *filterEdit;
00362 TQCheckBox *noTreeCB, *subCB, *newCB;
00363 TQPushButton *arrowBtn1, *arrowBtn2;
00364 TQIconSet pmRight, pmLeft;
00365 TQGridLayout *listL;
00366 TQLabel *leftLabel, *rightLabel;
00367
00368
00369 bool mLoading;
00370
00371
00372 Direction mDirButton1;
00373 Direction mDirButton2;
00374
00375
00376 TQString mLastText;
00377
00378
00379 int mDescrColumn;
00380 };
00381
00382 #endif