kmail Library API Documentation

kmheaders.h

00001 // -*- mode: C++ -*-
00002 
00003 #ifndef __KMHEADERS
00004 #define __KMHEADERS
00005 
00006 #include "kmmessage.h"
00007 #include "kmime_util.h"
00008 #include "kmcommands.h"
00009 
00010 #include <klistview.h>
00011 #include <kfoldertree.h>
00012 #include <kpopupmenu.h>
00013 
00014 #include <qwidget.h>
00015 #include <qstrlist.h>
00016 #include <qmemarray.h>
00017 #include <qmap.h>
00018 #include <qdragobject.h>
00019 #include <qdict.h>
00020 
00021 class KMFolder;
00022 class KMMessage;
00023 class KMMsgBase;
00024 class KMMainWidget;
00025 class QPalette;
00026 class KMHeaderItem;
00027 class QPixmap;
00028 class QIconSet;
00029 class QDateTime;
00030 class KMSortCacheItem;
00031 
00032 typedef QPtrList<KMMsgBase> KMMessageList;
00033 typedef QValueList<Q_UINT32> SerNumList;
00034 typedef QMap<int,KMFolder*> KMMenuToFolder;
00035 enum NestingPolicy { AlwaysOpen = 0, DefaultOpen, DefaultClosed, OpenUnread };
00036 
00038 class KMHeaders : public KListView
00039 {
00040   Q_OBJECT
00041 
00042   friend class KMHeaderItem; // For easy access to the pixmaps
00043 
00044 public:
00045   KMHeaders(KMMainWidget *owner, QWidget *parent=0, const char *name=0);
00046   virtual ~KMHeaders();
00047 
00052   virtual void setFolder(KMFolder *, bool forceJumpToUnread = false);
00053 
00055   KMFolder* folder(void) { return mFolder; }
00056 
00058   void refreshNestedState(void);
00059 
00062   virtual void setCurrentMsg(int msgId);
00063 
00065   QPtrList<QListViewItem> currentThread() const;
00066 
00069   virtual void setThreadStatus(KMMsgStatus status, bool toggle=false);
00070 
00071   /* Set message status to read if it is new, or unread */
00072   virtual void setMsgRead(int msgId);
00073 
00075   virtual void setMsgStatus(KMMsgStatus status, bool toggle=false);
00076   virtual void deleteMsg();
00077   virtual void applyFiltersOnMsg();
00078   virtual void undo();
00079   virtual bool canUndo() const;
00080   virtual KMHeaderItem * prepareMove( int *contentX, int *contentY );
00081   virtual void finalizeMove( KMHeaderItem *item, int contentX, int contentY );
00082 
00086   virtual void moveMsgToFolder( KMFolder* destination,
00087                                 bool askForConfirmation=true );
00088 
00091   virtual void copyMsgToFolder(KMFolder* destination,
00092                                KMMessage* aMsg = 0);
00093 
00095   virtual void clearSelectableAndAboutToBeDeleted(Q_UINT32 serNum);
00098   virtual KMMessageList* selectedMsgs(bool toBeDeleted = false);
00099 
00101   QValueList<int> selectedItems();
00102 
00104   int indexOfGetMsg (void) const { return getMsgIndex; }
00105 
00107   KMMainWidget* owner(void) const { return mOwner; }
00108 
00110   const KPaintInfo *paintInfo(void) const { return &mPaintInfo; }
00111 
00113   virtual void readConfig(void);
00114 
00116   virtual void readColorConfig(void);
00117 
00119   virtual void reset(void);
00120 
00122   void showNewMail();
00123 
00125   virtual KMMessage* currentMsg();
00127   virtual KMHeaderItem* currentHeaderItem();
00129   virtual int currentItemIndex();
00131   virtual void setCurrentItemByIndex( int msgIdx );
00133   void setCurrentItemBySerialNum( unsigned long serialNum );
00135   virtual int topItemIndex();
00138   virtual void setTopItemByIndex( int aMsgIdx );
00139   virtual void setNestedOverride( bool override );
00140   virtual void setSubjectThreading( bool subjThreading );
00142   virtual void setOpen ( QListViewItem *, bool );
00143 
00144   NestingPolicy getNestingPolicy() const { return nestingPolicy; }
00146   bool isThreaded() const {
00147     return mNested != mNestedOverride; // xor
00148   }
00149 
00152   virtual int findUnread(bool findNext, int startAt=-1, bool onlyNew = false, bool acceptCurrent = false);
00153 
00154   void highlightMessage(QListViewItem*, bool markitread);
00155 
00157   static QString fancyDate( time_t otime );
00158 
00159   QFont dateFont;
00160 
00161   bool noRepaint;
00162 
00163   // filter events for popup
00164   bool eventFilter ( QObject *o, QEvent *e );
00165 
00167   const KMMsgBase * getMsgBaseForItem( const QListViewItem *item ) const;
00168 
00169 signals:
00172   void selected(KMMessage *);
00175   void activated(KMMessage *);
00177   void maybeDeleting();
00179   void messageListUpdated();
00180 
00186   void msgAddedToListView( QListViewItem* );
00187 
00188 public slots:
00190   void selectMessage(QListViewItem*);
00192   void highlightMessage(QListViewItem*);
00194   void slotRMB();
00196   void msgHeaderChanged(KMFolder *folder, int msgId);
00198   void msgChanged();
00200   void folderCleared();
00202   void msgAdded(int);
00204   void msgRemoved(int, QString, QString);
00206   void nextMessage();
00208   void selectNextMessage();
00210   void prevMessage();
00212   void selectPrevMessage();
00215   bool nextUnreadMessage(bool acceptCurrent = false);
00218   bool prevUnreadMessage();
00220   void slotNoDrag();
00222   void resetCurrentTime();
00223 
00226   void slotExpandOrCollapseThread( bool expand );
00229   void slotExpandOrCollapseAllThreads( bool expand );
00230 
00231   virtual void ensureCurrentItemVisible();
00232 
00235   virtual void setSelected(QListViewItem *item, bool selected);
00236 
00240   void setSelectedByIndex(QValueList<int> items, bool selected);
00241 
00244   //void slotToggleSizeColumn(int mode = -1);
00245 
00248   void slotToggleColumn(int id, int mode = -1);
00249 
00251   void setFolderInfoStatus();
00252 
00253 protected:
00254   static QPixmap *pixNew, *pixUns, *pixDel, *pixRead, *pixRep, *pixSent,
00255     *pixQueued, *pixFwd, *pixFlag, *pixWatched, *pixIgnored, *pixSpam, *pixHam,
00256     *pixFullySigned, *pixPartiallySigned, *pixUndefinedSigned,
00257     *pixFullyEncrypted, *pixPartiallyEncrypted, *pixUndefinedEncrypted,
00258       *pixFiller, *pixEncryptionProblematic,
00259       *pixSignatureProblematic, *pixAttachment,
00260    *pixReadFwd, *pixReadReplied, *pixReadFwdReplied,*pixTodo;
00261 
00263   virtual bool event(QEvent *e);
00264 
00266   virtual void paintEmptyArea( QPainter * p, const QRect & rect );
00267 
00269   void makeHeaderVisible();
00270 
00272   void findUnreadAux( KMHeaderItem*&, bool &, bool, bool );
00273 
00278   virtual int firstSelectedMsg() const;
00279 
00281   virtual void readFolderConfig(void);
00282 
00284   virtual void writeFolderConfig(void);
00285 
00287   virtual void writeConfig(void);
00288 
00290   virtual void contentsMousePressEvent(QMouseEvent*);
00291   virtual void contentsMouseReleaseEvent(QMouseEvent* e);
00292   virtual void keyPressEvent( QKeyEvent * e );
00293 
00295   virtual void setSorting( int column, bool ascending = true);
00296 
00298   void contentsMouseMoveEvent( QMouseEvent *e );
00299 
00302   void styleChange( QStyle& oldStyle );
00303 
00306   void setStyleDependantFrameWidth();
00307 
00308 protected slots:
00311   virtual void moveSelectedToFolder( int menuId );
00313   virtual void copySelectedToFolder( int menuId );
00315   virtual int slotFilterMsg( KMMessage * );
00317   void dirtySortOrder(int);
00319   void rightButtonPressed( QListViewItem *, const QPoint &, int );
00320 
00321 private slots:
00322   void slotMoveCompleted( KMCommand * );
00323 
00324 private:
00327   virtual void updateMessageList( bool set_selection=false,
00328       bool forceJumpToUnread = false );
00329 
00331   QGuardedPtr<KMFolder> mFolder;
00333   KMMainWidget* mOwner;
00335   int mTopItem;
00337   int mCurrentItem;
00339   unsigned long mCurrentItemSerNum;
00341   QMemArray<KMHeaderItem*> mItems;
00342 
00343   // ===== threading and sorting ==========
00344   bool mNested, mNestedOverride, mSubjThreading;
00345   NestingPolicy nestingPolicy;
00346   int mSortCol;
00347   bool mSortDescending;
00348 
00349   struct {
00350       uint ascending : 1;
00351       uint dirty : 1;
00352       short column;
00353       uint fakeSort : 1;
00354       uint removed : 1;
00355   } mSortInfo;
00356 
00357 
00359   QDict< KMSortCacheItem > mSortCacheItems;
00361   QDict< QPtrList< KMSortCacheItem > > mSubjectLists;
00363   QPtrList<KMHeaderItem> mImperfectlyThreadedList;
00364 
00366   void buildThreadingTree( QMemArray<KMSortCacheItem *> sortCache );
00368   void buildSubjectThreadingTree( QMemArray<KMSortCacheItem *> sortCache );
00370   KMSortCacheItem* findParent(KMSortCacheItem *item);
00372   KMSortCacheItem* findParentBySubject(KMSortCacheItem *item);
00373 
00375   void appendItemToSortFile(KMHeaderItem *);
00377   bool writeSortOrder();
00379   bool readSortOrder( bool set_selection = false,
00380       bool forceJumpToUnread = false );
00381 
00383   int getMsgIndex;
00385   bool getMsgMulti;
00387   KMHeaderItem* getMsgItem;
00389   KMMessageList mSelMsgBaseList;
00390   QPtrList<KMMessage> mSelMsgList;
00391   KMHeaderItem* mPrevCurrent;
00392 
00394   KPaintInfo mPaintInfo;
00395 
00397   static QIconSet *up, *down;
00399   KMMenuToFolder mMenuToFolder;
00400 
00402   bool mMousePressed;
00404   QPoint mPressPos;
00405 
00406   KMime::DateFormatter mDate;
00407   bool mReaderWindowActive;
00408 
00410   KPopupMenu* mPopup;
00411   int mSizeColumn;
00412 
00413   int mImportantColumnId;
00414   int mTodoColumnId;
00415   int mSpamHamColumnId;
00416   int mWatchIgnoredColumnId;
00417   int mSignColumnId;
00418   int mReceiverColumnId;
00419   int mStatusColumnId;
00420   int mAttachmentColumnId;
00421   int mEncryptColumnId;
00422 };
00423 
00424 #endif
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jan 31 15:55:00 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003