libkdenetwork Library API Documentation

kfoldertree.h

00001 /* -*- mode: C++; c-file-style: "gnu" -*-
00002 
00003    This file is part of the KDE libraries
00004    Copyright (C) 2002 Carsten Burghardt <burghardt@kde.org>
00005    Copyright (C) 2002 Marc Mutz <mutz@kde.org>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License version 2 as published by the Free Software Foundation.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019    Boston, MA 02111-1307, USA.
00020 */
00021 #ifndef __KFOLDERTREE
00022 #define __KFOLDERTREE
00023 
00024 #include <qpixmap.h>
00025 #include <qbitarray.h>
00026 #include <qdragobject.h>
00027 #include <klistview.h>
00028 
00029 class KFolderTree;
00030 
00032 struct KPaintInfo {
00033 
00034   // Popup ids for toggle-able columns
00035   enum ColumnIds
00036   {
00037     COL_SIZE,
00038     COL_ATTACHMENT,
00039     COL_IMPORTANT,
00040     COL_TODO,
00041     COL_SPAM_HAM,
00042     COL_WATCHED_IGNORED,
00043     COL_STATUS,
00044     COL_SIGNED,
00045     COL_CRYPTO,
00046     COL_RECEIVER,
00047     COL_SCORE
00048   };
00049 
00050   KPaintInfo() :
00051     pixmapOn(false),
00052 
00053     showSize(false),
00054     showAttachment(false),
00055     showImportant(false),
00056     showTodo( false ),
00057     showSpamHam(false),
00058     showWatchedIgnored(false),
00059     showStatus(false),
00060     showSigned(false),
00061     showCrypto(false),
00062     showReceiver(false),
00063     showScore(false),
00064 
00065     scoreCol(-1),
00066     flagCol(-1),
00067     senderCol(-1),
00068     receiverCol(-1),
00069     subCol(-1),
00070     dateCol(-1),
00071     sizeCol(-1),
00072     attachmentCol(-1),
00073     importantCol(-1),
00074     todoCol(-1),
00075     spamHamCol(-1),
00076     watchedIgnoredCol(-1),
00077     statusCol(-1),
00078     signedCol(-1),
00079     cryptoCol(-1),
00080 
00081     orderOfArrival(false),
00082     status(false),
00083     showCryptoIcons(false),
00084     showAttachmentIcon(false)
00085     {}
00086 
00087   bool pixmapOn;
00088   QPixmap pixmap;
00089   QColor colFore;
00090   QColor colBack;
00091   QColor colNew;
00092   QColor colUnread;
00093   QColor colFlag;
00094   QColor colTodo;
00095 
00096   bool showSize;
00097   bool showAttachment;
00098   bool showImportant;
00099   bool showTodo;
00100   bool showSpamHam;
00101   bool showWatchedIgnored;
00102   bool showStatus;
00103   bool showSigned;
00104   bool showCrypto;
00105   bool showReceiver;
00106   bool showScore;
00107 
00108   int scoreCol;
00109   int flagCol;
00110   int senderCol;
00111   int receiverCol;
00112   int subCol;
00113   int dateCol;
00114   int sizeCol;
00115   int attachmentCol;
00116   int importantCol;
00117   int todoCol;
00118   int spamHamCol;
00119   int watchedIgnoredCol;
00120   int statusCol;
00121   int signedCol;
00122   int cryptoCol;
00123 
00124   bool orderOfArrival;
00125   bool status;
00126   bool showCryptoIcons;
00127   bool showAttachmentIcon;
00128 };
00129 
00130 //==========================================================================
00131 
00132 class KFolderTreeItem : public KListViewItem
00133 {
00134   public:
00136     enum Protocol {
00137       Imap,
00138       Local,
00139       News,
00140       CachedImap,
00141       Search,
00142       NONE
00143     };
00144 
00146     enum Type {
00147       Inbox,
00148       Outbox,
00149       SentMail,
00150       Trash,
00151       Drafts,
00152       Templates,
00153       Root,
00154       Calendar,
00155       Tasks,
00156       Journals,
00157       Contacts,
00158       Notes,
00159       Other
00160     };
00161 
00163     KFolderTreeItem( KFolderTree *parent, const QString & label=QString::null,
00164         Protocol protocol=NONE, Type type=Root );
00165 
00167     KFolderTreeItem( KFolderTreeItem *parent, const QString & label=QString::null,
00168         Protocol protocol=NONE, Type type=Other, int unread=0, int total=0 );
00169 
00171     virtual int compare( QListViewItem * i, int col,
00172         bool ascending ) const;
00173 
00175     int unreadCount() { return mUnread; }
00176     virtual void setUnreadCount( int aUnread );
00177 
00179     int totalCount() { return mTotal; }
00180     virtual void setTotalCount( int aTotal );
00181 
00183     Protocol protocol() const { return mProtocol; }
00184     virtual void setProtocol( Protocol aProtocol ) { mProtocol = aProtocol; }
00185 
00187     Type type() const { return mType; }
00188     virtual void setType( Type aType ) { mType = aType; }
00189 
00191     virtual int countUnreadRecursive();
00192 
00194     virtual void paintCell( QPainter * p, const QColorGroup & cg,
00195         int column, int width, int align );
00196 
00198     virtual bool acceptDrag(QDropEvent* ) const { return true; }
00199 
00200   private:
00202     int protocolSortingKey() const;
00204     int typeSortingKey() const;
00205 
00206   protected:
00207     Protocol mProtocol;
00208     Type mType;
00209     int mUnread;
00210     int mTotal;
00211 };
00212 
00213 //==========================================================================
00214 
00215 class KFolderTree : public KListView
00216 {
00217   Q_OBJECT
00218 
00219   public:
00220     KFolderTree( QWidget *parent, const char *name=0 );
00221 
00226     virtual void addAcceptableDropMimetype( const char *mimeType, bool outsideOk );
00227 
00229     virtual bool acceptDrag( QDropEvent* event ) const;
00230 
00232     KPaintInfo paintInfo() const { return mPaintInfo; }
00233 
00235     virtual void addUnreadColumn( const QString & name, int width=70 );
00236     virtual void removeUnreadColumn();
00237     virtual void addTotalColumn( const QString & name, int width=70 );
00238     virtual void removeTotalColumn();
00239 
00241     int unreadIndex() const { return mUnreadIndex; }
00242     int totalIndex() const { return mTotalIndex;  }
00243 
00245     bool isUnreadActive() const { return mUnreadIndex >= 0; }
00246     bool isTotalActive() const { return mTotalIndex >=  0; }
00247 
00249     virtual void setFullWidth( bool fullWidth );
00250 
00251   protected:
00254     void styleChange( QStyle& oldStyle );
00255 
00258     void setStyleDependantFrameWidth();
00259 
00260     virtual void drawContentsOffset( QPainter * p, int ox, int oy,
00261         int cx, int cy, int cw, int ch );
00262 
00263     virtual void contentsMousePressEvent( QMouseEvent *e );
00264     virtual void contentsMouseReleaseEvent( QMouseEvent *e );
00265 
00267     QMemArray<const char*> mAcceptableDropMimetypes;
00268     QBitArray mAcceptOutside;
00269  // ### why isn't it then static? ;-)
00271     KPaintInfo mPaintInfo;
00272 
00275     int mUnreadIndex;
00276     int mTotalIndex;
00277 };
00278 
00279 #endif
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu May 3 20:16:59 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003