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