kmail
headeritem.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef HEADERITEM_H
00030 #define HEADERITEM_H
00031
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034
00035 #include <k3listview.h>
00036 #include <QPixmap>
00037 #include <QList>
00038
00039 class KMMsgBase;
00040 namespace KPIM {
00041 struct KPaintInfo;
00042 }
00043 class KMFolder;
00044 class KMHeaders;
00045
00046 namespace KMail
00047 {
00048 class HeaderItem;
00049
00059 class SortCacheItem {
00060
00061 public:
00062 SortCacheItem() : mItem(0), mParent(0), mId(-1), mSortOffset(-1),
00063 mUnsortedCount(0), mUnsortedSize(0), mUnsortedChildren(0),
00064 mImperfectlyThreaded (true), mSubjThreadingList(0) { }
00065 SortCacheItem(int i, QString k, int o=-1)
00066 : mItem(0), mParent(0), mId(i), mSortOffset(o), mKey(k),
00067 mUnsortedCount(0), mUnsortedSize(0), mUnsortedChildren(0),
00068 mImperfectlyThreaded (true), mSubjThreadingList(0) { }
00069 ~SortCacheItem() { if(mUnsortedChildren) free(mUnsortedChildren); }
00070
00073 SortCacheItem *parent() const { return mParent; }
00079 bool isImperfectlyThreaded() const
00080 { return mImperfectlyThreaded; }
00083 void setImperfectlyThreaded (bool val)
00084 { mImperfectlyThreaded = val; }
00086 bool hasChildren() const
00087 { return mSortedChildren.count() || mUnsortedCount; }
00090 const QList<SortCacheItem*> *sortedChildren() const
00091 { return &mSortedChildren; }
00094 SortCacheItem **unsortedChildren(int &count) const
00095 { count = mUnsortedCount; return mUnsortedChildren; }
00097 void addSortedChild(SortCacheItem *i) {
00098 i->mParent = this;
00099 mSortedChildren.append(i);
00100 }
00102 void addUnsortedChild(SortCacheItem *i) {
00103 i->mParent = this;
00104 if(!mUnsortedChildren)
00105 mUnsortedChildren = (SortCacheItem **)malloc((mUnsortedSize = 25) * sizeof(SortCacheItem *));
00106 else if(mUnsortedCount >= mUnsortedSize)
00107 mUnsortedChildren = (SortCacheItem **)realloc(mUnsortedChildren,
00108 (mUnsortedSize *= 2) * sizeof(SortCacheItem *));
00109 mUnsortedChildren[mUnsortedCount++] = i;
00110 }
00111
00113 void clearChildren() {
00114 mSortedChildren.clear();
00115 free( mUnsortedChildren );
00116 mUnsortedChildren = 0;
00117 mUnsortedCount = mUnsortedSize = 0;
00118 }
00119
00121 HeaderItem *item() const { return mItem; }
00123 void setItem(HeaderItem *i) { Q_ASSERT(!mItem); mItem = i; }
00124
00126 const QString &key() const { return mKey; }
00128 void setKey(const QString &key) { mKey = key; }
00129
00130 int id() const { return mId; }
00131 void setId(int id) { mId = id; }
00132
00134 int offset() const { return mSortOffset; }
00135 void setOffset(int x) { mSortOffset = x; }
00136
00137 void updateSortFile( FILE *sortStream, KMFolder *folder,
00138 bool waiting_for_parent = false,
00139 bool update_discovered_count = false);
00140
00143 void setSubjectThreadingList( QList<SortCacheItem*> *list ) { mSubjThreadingList = list; }
00145 QList<SortCacheItem*>* subjectThreadingList() const { return mSubjThreadingList; }
00146
00147 private:
00148 HeaderItem *mItem;
00149 SortCacheItem *mParent;
00150 int mId, mSortOffset;
00151 QString mKey;
00152
00153 QList<SortCacheItem*> mSortedChildren;
00154 int mUnsortedCount, mUnsortedSize;
00155 SortCacheItem **mUnsortedChildren;
00156 bool mImperfectlyThreaded;
00157
00158
00159 QList<SortCacheItem*>* mSubjThreadingList;
00160 };
00161
00162
00168 class HeaderItem : public K3ListViewItem
00169 {
00170 public:
00171 HeaderItem( Q3ListView* parent, int msgId, const QString& key = QString() );
00172 HeaderItem( Q3ListViewItem* parent, int msgId, const QString& key = QString() );
00173 ~HeaderItem ();
00174
00177 void setMsgId( int aMsgId );
00178
00179
00180
00181
00182 void irefresh();
00183
00185 int msgId() const;
00186
00187
00188 quint32 msgSerNum() const;
00189
00191 void setOpenRecursive( bool open );
00192
00194 QString text( int col) const;
00195
00196 void setup();
00197
00198 typedef QList<QPixmap> PixmapList;
00199
00206 QPixmap pixmapMerge( PixmapList pixmaps ) const;
00207
00208 const QPixmap *cryptoIcon(KMMsgBase *msgBase) const;
00209 const QPixmap *signatureIcon(KMMsgBase *msgBase) const;
00210 const QPixmap *statusIcon(KMMsgBase *msgBase) const;
00211
00212 const QPixmap *pixmap(int col) const;
00213
00214 void paintCell( QPainter * p, const QColorGroup & cg,
00215 int column, int width, int align );
00216
00217 static QString generate_key( KMHeaders *headers, KMMsgBase *msg, const KPIM::KPaintInfo *paintInfo, int sortOrder );
00218
00219 virtual QString key( int column, bool ) const;
00220
00221 void setTempKey( const QString &key );
00222
00223 int compare( Q3ListViewItem *i, int col, bool ascending ) const;
00224
00225 Q3ListViewItem* firstChildNonConst();
00226
00230 bool aboutToBeDeleted() const { return mAboutToBeDeleted; }
00233 void setAboutToBeDeleted( bool val ) { mAboutToBeDeleted = val; }
00234
00237 void setSortCacheItem( SortCacheItem *item ) { mSortCacheItem = item; }
00239 SortCacheItem* sortCacheItem() const { return mSortCacheItem; }
00240
00241 private:
00242 int mMsgId;
00243 quint32 mSerNum;
00244 QString mKey;
00245 bool mAboutToBeDeleted;
00246 SortCacheItem *mSortCacheItem;
00247 };
00248
00249 }
00250
00251
00252 #endif // HEADERITEM_H