00001
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;
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
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;
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
00164
bool eventFilter (
QObject *o,
QEvent *e );
00165
00167
const KMMsgBase *
getMsgBaseForItem(
const QListViewItem *item )
const;
00168
00169 signals:
00172
virtual void selected(KMMessage *);
00175
virtual void activated(KMMessage *);
00177
virtual void maybeDeleting();
00179
virtual void messageListUpdated();
00180
00181
public slots:
00183
void selectMessage(
QListViewItem*);
00185
void highlightMessage(
QListViewItem*);
00187
void slotRMB();
00189
void msgHeaderChanged(
KMFolder *folder,
int msgId);
00191
void msgChanged();
00193
void folderCleared();
00195
void msgAdded(
int);
00197
void msgRemoved(
int,
QString,
QString);
00199
void nextMessage();
00201
void selectNextMessage();
00203
void prevMessage();
00205
void selectPrevMessage();
00208
bool nextUnreadMessage(
bool acceptCurrent =
false);
00211
bool prevUnreadMessage();
00213
void slotNoDrag();
00215
void resetCurrentTime();
00216
00219
void slotExpandOrCollapseThread(
bool expand );
00222
void slotExpandOrCollapseAllThreads(
bool expand );
00223
00224
virtual void ensureCurrentItemVisible();
00225
00228
virtual void setSelected(
QListViewItem *item,
bool selected);
00229
00233
void setSelectedByIndex(
QValueList<int> items,
bool selected);
00234
00237
void slotToggleSizeColumn(
int mode = -1);
00238
00240
void setFolderInfoStatus();
00241
00242
protected:
00243
static QPixmap *pixNew, *pixUns, *pixDel, *pixRead, *pixRep, *pixSent,
00244 *pixQueued, *pixFwd, *pixFlag, *pixWatched, *pixIgnored, *pixSpam, *pixHam,
00245 *pixFullySigned, *pixPartiallySigned, *pixUndefinedSigned,
00246 *pixFullyEncrypted, *pixPartiallyEncrypted, *pixUndefinedEncrypted,
00247 *pixFiller, *pixEncryptionProblematic,
00248 *pixSignatureProblematic, *pixAttachment;
00249
00251
virtual bool event(
QEvent *e);
00252
00254
virtual void paintEmptyArea(
QPainter * p,
const QRect & rect );
00255
00257
void makeHeaderVisible();
00258
00260
void findUnreadAux( KMHeaderItem*&,
bool &,
bool,
bool );
00261
00266
virtual int firstSelectedMsg() const;
00267
00269 virtual
void readFolderConfig(
void);
00270
00272 virtual
void writeFolderConfig(
void);
00273
00275 virtual
void writeConfig(
void);
00276
00278 virtual
void contentsMousePressEvent(
QMouseEvent*);
00279 virtual
void contentsMouseReleaseEvent(QMouseEvent* e);
00280 virtual
void keyPressEvent(
QKeyEvent * e );
00281
00283 virtual
void setSorting(
int column,
bool ascending = true);
00284
00286
void contentsMouseMoveEvent( QMouseEvent *e );
00287
00290
void styleChange(
QStyle& oldStyle );
00291
00294
void setStyleDependantFrameWidth();
00295
00296 protected slots:
00299 virtual
void moveSelectedToFolder(
int menuId );
00301 virtual
void copySelectedToFolder(
int menuId );
00303 virtual
int slotFilterMsg( KMMessage * );
00305
void dirtySortOrder(
int);
00307
void rightButtonPressed(
QListViewItem *, const
QPoint &,
int );
00308
00309 private slots:
00310
void slotMoveCompleted( KMCommand * );
00311
00312 private:
00315 virtual
void updateMessageList(
bool set_selection=false,
00316
bool forceJumpToUnread = false );
00317
00319
QGuardedPtr<
KMFolder> mFolder;
00321 KMMainWidget* mOwner;
00323
int mTopItem;
00325
int mCurrentItem;
00327
unsigned long mCurrentItemSerNum;
00329
QMemArray<KMHeaderItem*> mItems;
00330
00331
00332
bool mNested, mNestedOverride, mSubjThreading;
00333 NestingPolicy nestingPolicy;
00334
int mSortCol;
00335
bool mSortDescending;
00336
00337 struct {
00338 uint ascending : 1;
00339 uint dirty : 1;
00340
short column;
00341 uint fakeSort : 1;
00342 uint removed : 1;
00343 } mSortInfo;
00344
00345
00347
QDict< KMSortCacheItem > mSortCacheItems;
00349
QDict< QPtrList< KMSortCacheItem > > mSubjectLists;
00351
QPtrList<KMHeaderItem> mImperfectlyThreadedList;
00352
00354
void buildThreadingTree(
QMemArray<KMSortCacheItem *> sortCache );
00356
void buildSubjectThreadingTree(
QMemArray<KMSortCacheItem *> sortCache );
00358 KMSortCacheItem* findParent(KMSortCacheItem *item);
00360 KMSortCacheItem* findParentBySubject(KMSortCacheItem *item);
00361
00363
void appendItemToSortFile(KMHeaderItem *);
00365
bool writeSortOrder();
00367
bool readSortOrder(
bool set_selection =
false,
00368
bool forceJumpToUnread =
false );
00369
00371
int getMsgIndex;
00373
bool getMsgMulti;
00375 KMHeaderItem* getMsgItem;
00377 KMMessageList mSelMsgBaseList;
00378
QPtrList<KMMessage> mSelMsgList;
00379 KMHeaderItem* mPrevCurrent;
00380
00382 KPaintInfo mPaintInfo;
00383
00385
static QIconSet *up, *down;
00387 KMMenuToFolder mMenuToFolder;
00388
00390
bool mMousePressed;
00392
QPoint mPressPos;
00393
00394 KMime::DateFormatter mDate;
00395
bool mReaderWindowActive;
00396
00398 KPopupMenu* mPopup;
00399
int mSizeColumn;
00400 };
00401
00402
#endif