00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __KFOLDERTREE
00023 #define __KFOLDERTREE
00024
00025 #include <qpixmap.h>
00026 #include <qbitarray.h>
00027 #include <qdragobject.h>
00028 #include <qcolor.h>
00029 #include <klistview.h>
00030 #include <kdepimmacros.h>
00031
00032 class KFolderTree;
00033
00035 struct KPaintInfo {
00036
00037
00038 enum ColumnIds
00039 {
00040 COL_SIZE,
00041 COL_ATTACHMENT,
00042 COL_IMPORTANT,
00043 COL_TODO,
00044 COL_SPAM_HAM,
00045 COL_WATCHED_IGNORED,
00046 COL_STATUS,
00047 COL_SIGNED,
00048 COL_CRYPTO,
00049 COL_RECEIVER,
00050 COL_SCORE
00051 };
00052
00053 KPaintInfo() :
00054 pixmapOn(false),
00055
00056 showSize(false),
00057 showAttachment(false),
00058 showImportant(false),
00059 showTodo( false ),
00060 showSpamHam(false),
00061 showWatchedIgnored(false),
00062 showStatus(false),
00063 showSigned(false),
00064 showCrypto(false),
00065 showReceiver(false),
00066 showScore(false),
00067
00068 scoreCol(-1),
00069 flagCol(-1),
00070 senderCol(-1),
00071 receiverCol(-1),
00072 subCol(-1),
00073 dateCol(-1),
00074 sizeCol(-1),
00075 attachmentCol(-1),
00076 importantCol(-1),
00077 todoCol(-1),
00078 spamHamCol(-1),
00079 watchedIgnoredCol(-1),
00080 statusCol(-1),
00081 signedCol(-1),
00082 cryptoCol(-1),
00083
00084 orderOfArrival(false),
00085 status(false),
00086 showCryptoIcons(false),
00087 showAttachmentIcon(false)
00088 {}
00089
00090 bool pixmapOn;
00091 QPixmap pixmap;
00092 QColor colFore;
00093 QColor colBack;
00094 QColor colNew;
00095 QColor colUnread;
00096 QColor colFlag;
00097 QColor colTodo;
00098 QColor colCloseToQuota;
00099
00100 bool showSize;
00101 bool showAttachment;
00102 bool showImportant;
00103 bool showTodo;
00104 bool showSpamHam;
00105 bool showWatchedIgnored;
00106 bool showStatus;
00107 bool showSigned;
00108 bool showCrypto;
00109 bool showReceiver;
00110 bool showScore;
00111
00112 int scoreCol;
00113 int flagCol;
00114 int senderCol;
00115 int receiverCol;
00116 int subCol;
00117 int dateCol;
00118 int sizeCol;
00119 int attachmentCol;
00120 int importantCol;
00121 int todoCol;
00122 int spamHamCol;
00123 int watchedIgnoredCol;
00124 int statusCol;
00125 int signedCol;
00126 int cryptoCol;
00127
00128 bool orderOfArrival;
00129 bool status;
00130 bool showCryptoIcons;
00131 bool showAttachmentIcon;
00132 };
00133
00134
00135
00136 class KDE_EXPORT KFolderTreeItem : public KListViewItem
00137 {
00138 public:
00140 enum Protocol {
00141 Imap,
00142 Local,
00143 News,
00144 CachedImap,
00145 Search,
00146 NONE
00147 };
00148
00150 enum Type {
00151 Inbox,
00152 Outbox,
00153 SentMail,
00154 Trash,
00155 Drafts,
00156 Templates,
00157 Root,
00158 Calendar,
00159 Tasks,
00160 Journals,
00161 Contacts,
00162 Notes,
00163 Other
00164 };
00165
00167 KFolderTreeItem( KFolderTree *parent, const QString & label=QString::null,
00168 Protocol protocol=NONE, Type type=Root );
00169
00171 KFolderTreeItem( KFolderTreeItem *parent, const QString & label=QString::null,
00172 Protocol protocol=NONE, Type type=Other, int unread=0, int total=0 );
00173
00175 virtual int compare( QListViewItem * i, int col,
00176 bool ascending ) const;
00177
00179 int unreadCount() { return mUnread; }
00180 virtual void setUnreadCount( int aUnread );
00181
00183 int totalCount() { return mTotal; }
00184 virtual void setTotalCount( int aTotal );
00185
00187 int folderSize() { return mSize; }
00188 virtual void setFolderSize( int aSize );
00189
00191 Protocol protocol() const { return mProtocol; }
00192 virtual void setProtocol( Protocol aProtocol ) { mProtocol = aProtocol; }
00193
00195 Type type() const { return mType; }
00196 virtual void setType( Type aType ) { mType = aType; }
00197
00199 virtual int countUnreadRecursive();
00200
00201 virtual size_t recursiveFolderSize() const;
00202
00204 virtual void paintCell( QPainter * p, const QColorGroup & cg,
00205 int column, int width, int align );
00206
00208 virtual bool acceptDrag(QDropEvent* ) const { return true; }
00209
00210 void setFolderIsCloseToQuota( bool );
00211 bool folderIsCloseToQuota() const;
00212
00213 private:
00215 int protocolSortingKey() const;
00217 int typeSortingKey() const;
00218
00219 protected:
00221 virtual QString squeezeFolderName( const QString &text,
00222 const QFontMetrics &fm,
00223 uint width ) const;
00224
00225 Protocol mProtocol;
00226 Type mType;
00227 int mUnread;
00228 int mTotal;
00229 int mSize;
00230 bool mFolderIsCloseToQuota;
00231 };
00232
00233
00234
00235 class KDE_EXPORT KFolderTree : public KListView
00236 {
00237 Q_OBJECT
00238
00239 public:
00240 KFolderTree( QWidget *parent, const char *name=0 );
00241
00246 virtual void addAcceptableDropMimetype( const char *mimeType, bool outsideOk );
00247
00249 virtual bool acceptDrag( QDropEvent* event ) const;
00250
00252 KPaintInfo paintInfo() const { return mPaintInfo; }
00253
00255 virtual void addUnreadColumn( const QString & name, int width=70 );
00256 virtual void removeUnreadColumn();
00257 virtual void addTotalColumn( const QString & name, int width=70 );
00258 virtual void removeTotalColumn();
00259 virtual void addSizeColumn( const QString & name, int width=70 );
00260 virtual void removeSizeColumn();
00261
00262
00264 int unreadIndex() const { return mUnreadIndex; }
00265 int totalIndex() const { return mTotalIndex; }
00266 int sizeIndex() const { return mSizeIndex; }
00267
00269 bool isUnreadActive() const { return mUnreadIndex >= 0; }
00270 bool isTotalActive() const { return mTotalIndex >= 0; }
00271 bool isSizeActive() const { return mSizeIndex >= 0; }
00272
00274 virtual void setFullWidth( bool fullWidth );
00275
00276 protected:
00279 void styleChange( QStyle& oldStyle );
00280
00283 void setStyleDependantFrameWidth();
00284
00285 virtual void drawContentsOffset( QPainter * p, int ox, int oy,
00286 int cx, int cy, int cw, int ch );
00287
00288 virtual void contentsMousePressEvent( QMouseEvent *e );
00289 virtual void contentsMouseReleaseEvent( QMouseEvent *e );
00290
00292 QMemArray<const char*> mAcceptableDropMimetypes;
00293 QBitArray mAcceptOutside;
00294
00296 KPaintInfo mPaintInfo;
00297
00300 int mUnreadIndex;
00301 int mTotalIndex;
00302 int mSizeIndex;
00303
00304 private slots:
00307 void slotSizeChanged( int section, int oldSize, int newSize );
00308
00309 };
00310
00311 #endif