00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
#ifndef __KSUBSCRIPTION
00020
#define __KSUBSCRIPTION
00021
00034
#include <qlistview.h>
00035
#include <qcheckbox.h>
00036
00037
#include <kdialogbase.h>
00038
#include "kfoldertree.h"
00039
00040
class KSubscription;
00041
00042
class KLineEdit;
00043
class QLayout;
00044
class QLabel;
00045
class QGridLayout;
00046
class KAccount;
00047
00048
00049
00050
class KGroupInfo
00051 {
00052
public:
00053
enum Status {
00054 unknown,
00055 readOnly,
00056 postingAllowed,
00057 moderated
00058 };
00059
00060 KGroupInfo(
const QString &name,
const QString &description = QString::null,
00061
bool newGroup =
false,
bool subscribed =
false,
00062 Status status = unknown,
QString path = QString::null );
00063
00064
QString name, description;
00065
bool newGroup, subscribed;
00066 Status status;
00067
QString path;
00068
00069
bool operator== (
const KGroupInfo &gi2);
00070
bool operator< (
const KGroupInfo &gi2);
00071
00072 };
00073
00074
00075
00076
class GroupItem :
public QCheckListItem
00077 {
00078
public:
00079 GroupItem(
QListView *v,
const KGroupInfo &gi, KSubscription* browser,
00080
bool isCheckItem =
false );
00081 GroupItem(
QListViewItem *i,
const KGroupInfo &gi, KSubscription* browser,
00082
bool isCheckItem =
false );
00083
00087 KGroupInfo info() {
return mInfo; }
00088
void setInfo( KGroupInfo info );
00089
00093
QListViewItem* originalParent() {
return mOriginalParent; }
00094
void setOriginalParent(
QListViewItem* parent ) { mOriginalParent = parent; }
00095
00099
bool lastOpenState() {
return mLastOpenState; }
00100
void setLastOpenState(
bool last ) { mLastOpenState = last; }
00101
00106
virtual void setDescription();
00107
00111
bool isCheckItem()
const {
return mIsCheckItem; }
00112
00116
bool ignoreStateChange() {
return mIgnoreStateChange; }
00117
void setIgnoreStateChange(
bool ignore ) { mIgnoreStateChange = ignore; }
00118
00123
virtual void setOn(
bool on );
00124
00129
virtual void stateChange(
bool on );
00130
00135
void setVisible(
bool b );
00136
00141
virtual void paintCell(
QPainter * p,
const QColorGroup & cg,
00142
int column,
int width,
int align );
00143
00148
virtual void paintFocus(
QPainter *,
const QColorGroup & cg,
00149
const QRect & r );
00150
00155
virtual int width(
const QFontMetrics&,
const QListView*,
int column)
const;
00156
00161
virtual void setup();
00162
00164
virtual int rtti ()
const {
return 15689; }
00165
00166
protected:
00167 KGroupInfo mInfo;
00168 KSubscription* mBrowser;
00169
QListViewItem* mOriginalParent;
00170
00171
bool mLastOpenState;
00172
00173
bool mIsCheckItem;
00174
00175
bool mIgnoreStateChange;
00176 };
00177
00178
00179
00180
class KSubscription :
public KDialogBase
00181 {
00182 Q_OBJECT
00183
00184
public:
00188
enum Direction {
00189 Left,
00190 Right
00191 };
00192
00193 KSubscription(
QWidget *parent,
const QString &caption, KAccount* acct,
00194
int buttons = 0,
const QString &user1 = QString::null,
00195
bool descriptionColumn =
true );
00196
00197 ~KSubscription();
00198
00202 KAccount* account() {
return mAcct; }
00203
void setAccount( KAccount * acct ) { mAcct = acct; }
00204
00208
QListView* folderTree() {
return groupView; }
00209
00213 KLineEdit* searchField() {
return filterEdit; }
00214
00218
void setStartItem(
const KGroupInfo &info );
00219
00223
void removeListItem(
QListView *view,
const KGroupInfo &gi );
00224
00229
QListViewItem* getListItem(
QListView *view,
const KGroupInfo &gi );
00230
00234
bool itemInListView(
QListView *view,
const KGroupInfo &gi );
00235
00240
void changeItemState( GroupItem* item,
bool on );
00241
00245 Direction directionButton1() {
return mDirButton1; }
00246
void setDirectionButton1( Direction dir );
00247
00251 Direction directionButton2() {
return mDirButton2; }
00252
void setDirectionButton2( Direction dir );
00253
00258
bool isLoading() {
return mLoading; }
00259
00263
void hideTreeCheckbox() { noTreeCB->hide(); }
00264
00268
void hideNewOnlyCheckbox() { newCB->hide(); }
00269
00274
void filterChanged(
QListViewItem* item = 0,
00275
const QString & text = QString::null );
00276
00280 uint activeItemCount();
00281
00285
void restoreOriginalParent();
00286
00290
void saveOpenStates();
00291
00295
void restoreOpenStates();
00296
00297
00298
public slots:
00302
void slotLoadingComplete();
00303
00307
void slotChangeButtonState(
QListViewItem* );
00308
00312
void slotButton1();
00313
void slotButton2();
00314
00318
void slotUpdateStatusLabel();
00319
00323
void slotLoadFolders();
00324
00325
protected slots:
00329
void slotCBToggled();
00330
00334
void slotFilterTextChanged(
const QString & text );
00335
00336
00337 signals:
00342
void listChanged();
00343
00344
00345
protected:
00346
00347 KAccount* mAcct;
00348
00349
00350
QWidget *page;
00351
QListView *groupView;
00352
QListView *subView, *unsubView;
00353 KLineEdit *filterEdit;
00354
QCheckBox *noTreeCB, *subCB, *newCB;
00355
QPushButton *arrowBtn1, *arrowBtn2;
00356
QPixmap pmRight, pmLeft;
00357
QGridLayout *listL;
00358
QLabel *leftLabel, *rightLabel;
00359
00360
00361
bool mLoading;
00362
00363
00364 Direction mDirButton1;
00365 Direction mDirButton2;
00366
00367
00368
QString mLastText;
00369
00370
00371
int mDescrColumn;
00372 };
00373
00374
#endif