• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmail

headeritem.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 **
00003 ** Filename   : headeritem.h
00004 ** Created on : 28 November, 2004
00005 ** Copyright  : (c) 2004 Till Adam
00006 ** Email      : adam@kde.org
00007 **
00008 *******************************************************************************/
00009 
00010 /*******************************************************************************
00011 **
00012 **   This program is free software; you can redistribute it and/or modify
00013 **   it under the terms of the GNU General Public License as published by
00014 **   the Free Software Foundation; either version 2 of the License, or
00015 **   (at your option) any later version.
00016 **
00017 **   In addition, as a special exception, the copyright holders give
00018 **   permission to link the code of this program with any edition of
00019 **   the Qt library by Trolltech AS, Norway (or with modified versions
00020 **   of Qt that use the same license as Qt), and distribute linked
00021 **   combinations including the two.  You must obey the GNU General
00022 **   Public License in all respects for all of the code used other than
00023 **   Qt.  If you modify this file, you may extend this exception to
00024 **   your version of the file, but you are not obligated to do so.  If
00025 **   you do not wish to do so, delete this exception statement from
00026 **   your version.
00027 **
00028 *******************************************************************************/
00029 #ifndef HEADERITEM_H
00030 #define HEADERITEM_H
00031 
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 
00035 #include <k3listview.h> // include for the base class
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; // forward declaration
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     // pointer to the list it might be on so it can be remove from it
00158     // when the item goes away.
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   // Profiling note: About 30% of the time taken to initialize the
00180   // listview is spent in this function. About 60% is spent in operator
00181   // new and QListViewItem::QListViewItem.
00182   void irefresh();
00183 
00185   int msgId() const;
00186 
00187   // Return the serial number of the message associated with this item;
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 /*ascending*/ ) const;
00220 
00221   void setTempKey( const QString &key );
00222 
00223   int compare( Q3ListViewItem *i, int col, bool ascending ) const;
00224 
00225   Q3ListViewItem* firstChildNonConst(); /* Non const! */
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 }; // End of class HeaderItem
00248 
00249 } // End of namespace KMail
00250 
00251 
00252 #endif // HEADERITEM_H

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal