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 <klistview.h>
00029 #include <kdepimmacros.h>
00030
00031 class KFolderTree;
00032
00034 struct KPaintInfo {
00035
00036
00037 enum ColumnIds
00038 {
00039 COL_SIZE,
00040 COL_ATTACHMENT,
00041 COL_IMPORTANT,
00042 COL_TODO,
00043 COL_SPAM_HAM,
00044 COL_WATCHED_IGNORED,
00045 COL_STATUS,
00046 COL_SIGNED,
00047 COL_CRYPTO,
00048 COL_RECEIVER,
00049 COL_SCORE
00050 };
00051
00052 KPaintInfo() :
00053 pixmapOn(false),
00054
00055 showSize(false),
00056 showAttachment(false),
00057 showImportant(false),
00058 showTodo( false ),
00059 showSpamHam(false),
00060 showWatchedIgnored(false),
00061 showStatus(false),
00062 showSigned(false),
00063 showCrypto(false),
00064 showReceiver(false),
00065 showScore(false),
00066
00067 scoreCol(-1),
00068 flagCol(-1),
00069 senderCol(-1),
00070 receiverCol(-1),
00071 subCol(-1),
00072 dateCol(-1),
00073 sizeCol(-1),
00074 attachmentCol(-1),
00075 importantCol(-1),
00076 todoCol(-1),
00077 spamHamCol(-1),
00078 watchedIgnoredCol(-1),
00079 statusCol(-1),
00080 signedCol(-1),
00081 cryptoCol(-1),
00082
00083 orderOfArrival(false),
00084 status(false),
00085 showCryptoIcons(false),
00086 showAttachmentIcon(false)
00087 {}
00088
00089 bool pixmapOn;
00090 QPixmap pixmap;
00091 QColor colFore;
00092 QColor colBack;
00093 QColor colNew;
00094 QColor colUnread;
00095 QColor colFlag;
00096 QColor colTodo;
00097
00098 bool showSize;
00099 bool showAttachment;
00100 bool showImportant;
00101 bool showTodo;
00102 bool showSpamHam;
00103 bool showWatchedIgnored;
00104 bool showStatus;
00105 bool showSigned;
00106 bool showCrypto;
00107 bool showReceiver;
00108 bool showScore;
00109
00110 int scoreCol;
00111 int flagCol;
00112 int senderCol;
00113 int receiverCol;
00114 int subCol;
00115 int dateCol;
00116 int sizeCol;
00117 int attachmentCol;
00118 int importantCol;
00119 int todoCol;
00120 int spamHamCol;
00121 int watchedIgnoredCol;
00122 int statusCol;
00123 int signedCol;
00124 int cryptoCol;
00125
00126 bool orderOfArrival;
00127 bool status;
00128 bool showCryptoIcons;
00129 bool showAttachmentIcon;
00130 };
00131
00132
00133
00134 class KDE_EXPORT KFolderTreeItem : public KListViewItem
00135 {
00136 public:
00138 enum Protocol {
00139 Imap,
00140 Local,
00141 News,
00142 CachedImap,
00143 Search,
00144 NONE
00145 };
00146
00148 enum Type {
00149 Inbox,
00150 Outbox,
00151 SentMail,
00152 Trash,
00153 Drafts,
00154 Templates,
00155 Root,
00156 Calendar,
00157 Tasks,
00158 Journals,
00159 Contacts,
00160 Notes,
00161 Other
00162 };
00163
00165 KFolderTreeItem( KFolderTree *parent, const QString & label=QString::null,
00166 Protocol protocol=NONE, Type type=Root );
00167
00169 KFolderTreeItem( KFolderTreeItem *parent, const QString & label=QString::null,
00170 Protocol protocol=NONE, Type type=Other, int unread=0, int total=0 );
00171
00173 virtual int compare( QListViewItem * i, int col,
00174 bool ascending ) const;
00175
00177 int unreadCount() { return mUnread; }
00178 virtual void setUnreadCount( int aUnread );
00179
00181 int totalCount() { return mTotal; }
00182 virtual void setTotalCount( int aTotal );
00183
00185 Protocol protocol() const { return mProtocol; }
00186 virtual void setProtocol( Protocol aProtocol ) { mProtocol = aProtocol; }
00187
00189 Type type() const { return mType; }
00190 virtual void setType( Type aType ) { mType = aType; }
00191
00193 virtual int countUnreadRecursive();
00194
00196 virtual void paintCell( QPainter * p, const QColorGroup & cg,
00197 int column, int width, int align );
00198
00200 virtual bool acceptDrag(QDropEvent* ) const { return true; }
00201
00202 private:
00204 int protocolSortingKey() const;
00206 int typeSortingKey() const;
00207
00208 protected:
00210 virtual QString squeezeFolderName( const QString &text,
00211 const QFontMetrics &fm,
00212 uint width ) const;
00213
00214 Protocol mProtocol;
00215 Type mType;
00216 int mUnread;
00217 int mTotal;
00218 };
00219
00220
00221
00222 class KDE_EXPORT KFolderTree : public KListView
00223 {
00224 Q_OBJECT
00225
00226 public:
00227 KFolderTree( QWidget *parent, const char *name=0 );
00228
00233 virtual void addAcceptableDropMimetype( const char *mimeType, bool outsideOk );
00234
00236 virtual bool acceptDrag( QDropEvent* event ) const;
00237
00239 KPaintInfo paintInfo() const { return mPaintInfo; }
00240
00242 virtual void addUnreadColumn( const QString & name, int width=70 );
00243 virtual void removeUnreadColumn();
00244 virtual void addTotalColumn( const QString & name, int width=70 );
00245 virtual void removeTotalColumn();
00246
00248 int unreadIndex() const { return mUnreadIndex; }
00249 int totalIndex() const { return mTotalIndex; }
00250
00252 bool isUnreadActive() const { return mUnreadIndex >= 0; }
00253 bool isTotalActive() const { return mTotalIndex >= 0; }
00254
00256 virtual void setFullWidth( bool fullWidth );
00257
00258 protected:
00261 void styleChange( QStyle& oldStyle );
00262
00265 void setStyleDependantFrameWidth();
00266
00267 virtual void drawContentsOffset( QPainter * p, int ox, int oy,
00268 int cx, int cy, int cw, int ch );
00269
00270 virtual void contentsMousePressEvent( QMouseEvent *e );
00271 virtual void contentsMouseReleaseEvent( QMouseEvent *e );
00272
00274 QMemArray<const char*> mAcceptableDropMimetypes;
00275 QBitArray mAcceptOutside;
00276
00278 KPaintInfo mPaintInfo;
00279
00282 int mUnreadIndex;
00283 int mTotalIndex;
00284
00285 private slots:
00288 void slotSizeChanged( int section, int oldSize, int newSize );
00289
00290 };
00291
00292 #endif