libkdepim

ksubscription.h

Go to the documentation of this file.
00001 /*
00002    This file is part of libkdepim.
00003 
00004    Copyright (C) 2002 Carsten Burghardt <burghardt@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00025 #ifndef __KSUBSCRIPTION
00026 #define __KSUBSCRIPTION
00027 
00028 #include <qlistview.h>
00029 #include <qcheckbox.h>
00030 
00031 #include <kdialogbase.h>
00032 #include <kdepimmacros.h>
00033 #include "kfoldertree.h"
00034 
00035 class KSubscription;
00036 
00037 class KLineEdit;
00038 class QLayout;
00039 class QLabel;
00040 class QGridLayout;
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 QString &name, const QString &description = QString::null,
00056         bool newGroup = false, bool subscribed = false,
00057         Status status = unknown, QString path = QString::null );
00058 
00059     QString name, description;
00060     bool newGroup, subscribed;
00061     Status status;
00062     QString 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 QCheckListItem
00073 {
00074   public:
00075     GroupItem( QListView *v, const KGroupInfo &gi, KSubscription* browser,
00076         bool isCheckItem = false );
00077     GroupItem( QListViewItem *i, const KGroupInfo &gi, KSubscription* browser,
00078         bool isCheckItem = false );
00079 
00083     KGroupInfo info() { return mInfo; }
00084     void setInfo( KGroupInfo info );
00085 
00089     QListViewItem* originalParent() { return mOriginalParent; }
00090     void setOriginalParent( QListViewItem* 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( QPainter * p, const QColorGroup & cg,
00138         int column, int width, int align );
00139 
00144     virtual void paintFocus( QPainter *, const QColorGroup & cg,
00145                  const QRect & r );
00146 
00151     virtual int width( const QFontMetrics&, const QListView*, 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     QListViewItem* mOriginalParent;
00166     // remember last open state
00167     bool mLastOpenState;
00168     // is this a checkable item
00169     bool mIsCheckItem;
00170     // ignore state changes
00171     bool mIgnoreStateChange;
00172 };
00173 
00174 //==========================================================================
00175 
00188 class KDE_EXPORT KSubscription : public KDialogBase
00189 {
00190   Q_OBJECT
00191 
00192   public:
00196     enum Direction {
00197       Left,
00198       Right
00199     };
00200 
00201     KSubscription( QWidget *parent, const QString &caption, KAccount* acct,
00202         int buttons = 0, const QString &user1 = QString::null,
00203         bool descriptionColumn = true );
00204 
00205     ~KSubscription();
00206 
00210     KAccount* account() { return mAcct; }
00211     void setAccount( KAccount * acct ) { mAcct = acct; }
00212 
00216     QListView* folderTree() { return groupView; }
00217 
00221     KLineEdit* searchField() { return filterEdit; }
00222 
00226     void setStartItem( const KGroupInfo &info );
00227 
00231     void removeListItem( QListView *view, const KGroupInfo &gi );
00232 
00237     QListViewItem* getListItem( QListView *view, const KGroupInfo &gi );
00238 
00242     bool itemInListView( QListView *view, const KGroupInfo &gi );
00243 
00248     void changeItemState( GroupItem* item, bool on );
00249 
00253     Direction directionButton1() { return mDirButton1; }
00254     void setDirectionButton1( Direction dir );
00255 
00259     Direction directionButton2() { return mDirButton2; }
00260     void setDirectionButton2( Direction dir );
00261 
00266     bool isLoading() { return mLoading; }
00267 
00271     void hideTreeCheckbox() { noTreeCB->hide(); }
00272 
00276     void hideNewOnlyCheckbox() { newCB->hide(); }
00277 
00282     void filterChanged( QListViewItem* item = 0,
00283         const QString & text = QString::null );
00284 
00288     uint activeItemCount();
00289 
00293     void restoreOriginalParent();
00294 
00298     void saveOpenStates();
00299 
00303     void restoreOpenStates();
00304 
00305 
00306   public slots:
00310     void slotLoadingComplete();
00311 
00315     void slotChangeButtonState( QListViewItem* );
00316 
00320     void slotButton1();
00321     void slotButton2();
00322 
00326     void slotUpdateStatusLabel();
00327 
00331     void slotLoadFolders();
00332 
00333   protected slots:
00337     void slotCBToggled();
00338 
00342     void slotFilterTextChanged( const QString & text );
00343 
00344   signals:
00349     void listChanged();
00350 
00351 
00352   protected:
00353     // current account
00354     KAccount* mAcct;
00355 
00356     // widgets
00357     QWidget *page;
00358     QListView *groupView;
00359     QListView *subView, *unsubView;
00360     KLineEdit *filterEdit;
00361     QCheckBox *noTreeCB, *subCB, *newCB;
00362     QPushButton  *arrowBtn1, *arrowBtn2;
00363     QIconSet pmRight, pmLeft;
00364     QGridLayout *listL;
00365     QLabel *leftLabel, *rightLabel;
00366 
00367     // false if all items are loaded
00368     bool mLoading;
00369 
00370     // directions
00371     Direction mDirButton1;
00372     Direction mDirButton2;
00373 
00374     // remember last searchtext
00375     QString mLastText;
00376 
00377     // remember description column
00378     int mDescrColumn;
00379 };
00380 
00381 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys