kmail

kmheaders.h
1#ifndef __KMHEADERS
2#define __KMHEADERS
3
4#include "kmime_util.h"
5#include "headeritem.h"
8
9#include <tdelistview.h>
10#include <kfoldertree.h> // for KPaintInfo
11#include <kmmsgbase.h> // for KMMsgStatus
12
13#include <tqwidget.h>
14#include <tqstrlist.h>
15#include <tqmemarray.h>
16#include <tqmap.h>
17#include <tqdragobject.h>
18#include <tqdict.h>
19#include <tqguardedptr.h>
20
21class KMFolder;
22class KMMessage;
23class KMMsgBase;
24class KMCommand;
25class KMMainWidget;
26class TDEPopupMenu;
27class TQPalette;
28class TQPixmap;
29class TQIconSet;
30class TQDateTime;
31
32typedef TQPtrList<KMMsgBase> KMMessageList;
33typedef TQValueList<TQ_UINT32> SerNumList;
34typedef TQMap<int,KMFolder*> KMMenuToFolder;
35enum NestingPolicy { AlwaysOpen = 0, DefaultOpen, DefaultClosed, OpenUnread };
36
37
38#define KMAIL_SORT_VERSION 1012
39#define KMAIL_SORT_FILE(x) x->indexLocation() + ".sorted"
40#define KMAIL_SORT_HEADER "## KMail Sort V%04d\n\t"
41#define KMAIL_MAGIC_HEADER_OFFSET 21 //strlen(KMAIL_SORT_HEADER)
42#define KMAIL_MAX_KEY_LEN 16384
43#define KMAIL_RESERVED 3
44
46class KMHeaders : public TDEListView
47{
48 TQ_OBJECT
49
50
51 friend class ::KMail::HeaderItem; // For easy access to the pixmaps
52
53public:
54 KMHeaders(KMMainWidget *owner, TQWidget *parent=0, const char *name=0);
55 virtual ~KMHeaders();
56
61 virtual void setFolder(KMFolder *, bool forceJumpToUnread = false);
62
64 KMFolder* folder(void) { return mFolder; }
65
67 void refreshNestedState(void);
68
71 virtual void setCurrentMsg(int msgId);
72
74 TQPtrList<TQListViewItem> currentThread() const;
75
78 virtual void setThreadStatus(KMMsgStatus status, bool toggle=false);
79
80 /* Set message status to read if it is new, or unread */
81 virtual void setMsgRead(int msgId);
82
84 virtual void setMsgStatus(KMMsgStatus status, bool toggle=false);
85 virtual void deleteMsg();
86 virtual void applyFiltersOnMsg();
87 virtual void undo();
88 virtual bool canUndo() const;
89 virtual HeaderItem * prepareMove( int *contentX, int *contentY );
90 virtual void finalizeMove( HeaderItem *item, int contentX, int contentY );
91
95 virtual void moveMsgToFolder( KMFolder* destination,
96 bool askForConfirmation=true );
97
100 virtual void copyMsgToFolder(KMFolder* destination,
101 KMMessage* aMsg = 0);
102
104 virtual void clearSelectableAndAboutToBeDeleted(TQ_UINT32 serNum);
107 virtual KMMessageList* selectedMsgs(bool toBeDeleted = false);
108
110 TQValueList<int> selectedItems();
111
113 TQValueList<TQ_UINT32> selectedSernums();
114
118 TQValueList<TQ_UINT32> selectedVisibleSernums();
119
121 int indexOfGetMsg (void) const { return getMsgIndex; }
122
124 KMMainWidget* owner(void) const { return mOwner; }
125
127 const KPaintInfo *paintInfo(void) const { return &mPaintInfo; }
128
130 virtual void readConfig(void);
131
133 virtual void readColorConfig(void);
134
142 void restoreColumnLayout( TDEConfig *config, const TQString &group );
143
145 virtual KMMessage* currentMsg();
147 virtual HeaderItem* currentHeaderItem();
149 virtual int currentItemIndex();
151 virtual void setCurrentItemByIndex( int msgIdx );
153 void setCurrentItemBySerialNum( unsigned long serialNum );
155 virtual int topItemIndex();
158 virtual void setTopItemByIndex( int aMsgIdx );
159 virtual void setNestedOverride( bool override );
160 virtual void setSubjectThreading( bool subjThreading );
162 virtual void setOpen ( TQListViewItem *, bool );
163
164 NestingPolicy getNestingPolicy() const { return nestingPolicy; }
166 bool isThreaded() const {
167 return mNested != mNestedOverride; // xor
168 }
169
172 virtual int findUnread(bool findNext, int startAt=-1, bool onlyNew = false, bool acceptCurrent = false);
173
174 void highlightMessage(TQListViewItem*, bool markitread);
175 void highlightCurrentThread();
176
178 static TQString fancyDate( time_t otime );
179
180 bool noRepaint;
181
182 // filter events for popup
183 bool eventFilter ( TQObject *o, TQEvent *e );
184
186 const KMMsgBase * getMsgBaseForItem( const TQListViewItem *item ) const;
187
188 // accessors
189 TQFont newFont() const { return mNewFont; }
190 TQFont unreadFont() const { return mUnreadFont; }
191 TQFont importantFont() const { return mImportantFont; }
192 TQFont todoFont() const { return mTodoFont; }
193 TQFont dateFont() const { return mDateFont; }
194
200 void setCopiedMessages( const TQValueList<TQ_UINT32> &msgs, bool move );
201
206 bool isMessageCut( TQ_UINT32 serNum ) const;
207
209 virtual void writeConfig(void);
210
211signals:
222
228 void msgAddedToListView( TQListViewItem* );
229
230public slots:
232 void selectMessage(TQListViewItem*);
234 void highlightMessage(TQListViewItem*);
236 void slotRMB();
238 void msgHeaderChanged(KMFolder *folder, int msgId);
240 void msgChanged();
242 void folderCleared();
244 void folderClosed();
246 void msgAdded(int);
248 void msgRemoved( int, TQString );
250 void nextMessage();
252 void selectNextMessage();
254 void prevMessage();
256 void selectPrevMessage();
259 bool nextUnreadMessage(bool acceptCurrent = false);
262 bool prevUnreadMessage();
264 void incCurrentMessage();
266 void decCurrentMessage();
270 void slotNoDrag();
272 void resetCurrentTime();
273
275 void reset();
276
279 void slotExpandOrCollapseThread( bool expand );
282 void slotExpandOrCollapseAllThreads( bool expand );
283
284 virtual void ensureCurrentItemVisible();
285
288 virtual void setSelected(TQListViewItem *item, bool selected);
289
293 void setSelectedByIndex(TQValueList<int> items, bool selected);
294
297 void slotToggleColumn(int id, int mode = -1);
298
300 void setFolderInfoStatus();
301
302protected:
303 static TQPixmap *pixNew, *pixUns, *pixDel, *pixRead, *pixRep, *pixSent,
304 *pixQueued, *pixFwd, *pixFlag, *pixWatched, *pixIgnored, *pixSpam, *pixHam,
305 *pixFullySigned, *pixPartiallySigned, *pixUndefinedSigned,
306 *pixFullyEncrypted, *pixPartiallyEncrypted, *pixUndefinedEncrypted,
307 *pixFiller, *pixEncryptionProblematic,
308 *pixSignatureProblematic, *pixAttachment, *pixInvitation,
309 *pixReadFwd, *pixReadReplied, *pixReadFwdReplied, *pixTodo;
310
312 virtual bool event(TQEvent *e);
313
315 virtual void paintEmptyArea( TQPainter * p, const TQRect & rect );
316
318 void makeHeaderVisible();
319
321 void findUnreadAux( HeaderItem*&, bool &, bool, bool );
322
327 virtual int firstSelectedMsg() const;
328
330 virtual void readFolderConfig(void);
331
333 virtual void writeFolderConfig(void);
334
336 virtual void contentsMousePressEvent(TQMouseEvent*);
337 virtual void contentsMouseReleaseEvent(TQMouseEvent* e);
338 virtual void keyPressEvent( TQKeyEvent * e );
339
341 virtual void setSorting( int column, bool ascending = true);
342
344 void contentsMouseMoveEvent( TQMouseEvent *e );
345
348 void styleChange( TQStyle& oldStyle );
349
353
354protected slots:
357 virtual void moveSelectedToFolder( int menuId );
359 virtual void copySelectedToFolder( int menuId );
361 virtual int slotFilterMsg( KMMessage * );
363 void dirtySortOrder(int);
365 void rightButtonPressed( TQListViewItem *, const TQPoint &, int );
366
367private slots:
368 void slotMoveCompleted( KMCommand * );
369
370 void copyMessages();
371 void cutMessages();
372 void pasteMessages();
373
374 void updateActions();
375
376private:
379 virtual void updateMessageList( bool set_selection=false,
380 bool forceJumpToUnread = false );
381
383 TQGuardedPtr<KMFolder> mFolder;
385 KMMainWidget* mOwner;
387 int mTopItem;
389 int mCurrentItem;
391 unsigned long mCurrentItemSerNum;
393 TQMemArray<HeaderItem*> mItems;
394
395 // ===== threading and sorting ==========
396 bool mNested, mNestedOverride, mSubjThreading;
397 NestingPolicy nestingPolicy;
398 int mSortCol;
399 bool mSortDescending;
400 bool mIgnoreSortOrderChanges;
401
402 struct {
403 uint ascending : 1;
404 uint dirty : 1;
405 short column;
406 uint fakeSort : 1;
407 uint removed : 1;
408 } mSortInfo;
409
410
412 TQDict< SortCacheItem > mSortCacheItems;
414 TQDict< TQPtrList< SortCacheItem > > mSubjectLists;
416 TQPtrList<HeaderItem> mImperfectlyThreadedList;
417
419 void printSubjectThreadingTree( );
420 void printThreadingTree( );
422 void buildThreadingTree( TQMemArray<SortCacheItem *> sortCache );
424 void buildSubjectThreadingTree( TQMemArray<SortCacheItem *> sortCache );
426 SortCacheItem* findParent(SortCacheItem *item);
428 SortCacheItem* findParentBySubject(SortCacheItem *item);
429 SortCacheItem* mRoot; // used to represent the list view itself while threading
430
432 void appendItemToSortFile(HeaderItem *);
434 bool writeSortOrder();
436 bool readSortOrder( bool set_selection = false,
437 bool forceJumpToUnread = false );
438
440 int getMsgIndex;
442 bool getMsgMulti;
444 HeaderItem* getMsgItem;
446 KMMessageList mSelMsgBaseList;
447 HeaderItem* mPrevCurrent;
448
450 KPaintInfo mPaintInfo;
451
452 TQFont mNewFont, mUnreadFont, mImportantFont, mDateFont,mTodoFont;
453
455 static TQIconSet *up, *down;
457 KMMenuToFolder mMenuToFolder;
458
460 bool mMousePressed;
462 TQPoint mPressPos;
463
464 KMime::DateFormatter mDate;
465 bool mReaderWindowActive;
466
468 TDEPopupMenu* mPopup;
469
470 // copied messages
471 TQValueList<TQ_UINT32> mCopiedMessages;
472 bool mMoveMessages;
473}; // class
474#endif
Mail folder.
Definition kmfolder.h:69
The widget that shows the contents of folders.
Definition kmheaders.h:47
virtual void setFolder(KMFolder *, bool forceJumpToUnread=false)
A new folder has been selected update the list of headers shown To override the global settings for j...
TQValueList< TQ_UINT32 > selectedSernums()
Returns the sernums of all selected items.
void incCurrentMessage()
Focus the next message, but don't select it.
void msgAdded(int)
For when the message with the given message id has been added to a folder.
void setSelectedByIndex(TQValueList< int > items, bool selected)
Select several items by message index and if they are the parent of a closed thread,...
void setFolderInfoStatus()
Provide information about number of messages in a folder.
const KPaintInfo * paintInfo(void) const
PaintInfo pointer.
Definition kmheaders.h:127
TQValueList< TQ_UINT32 > selectedVisibleSernums()
Returns the sernums of all visible (ie.
virtual void copySelectedToFolder(int menuId)
Same thing but copy.
int indexOfGetMsg(void) const
Returns index of message returned by last getMsg() call.
Definition kmheaders.h:121
virtual void paintEmptyArea(TQPainter *p, const TQRect &rect)
Overridden to support backing pixmap.
bool isThreaded() const
Returns true if the current header list is threaded.
Definition kmheaders.h:166
virtual void contentsMousePressEvent(TQMouseEvent *)
Handle shift and control selection.
void msgChanged()
For when the list of messages in a folder has changed.
const KMMsgBase * getMsgBaseForItem(const TQListViewItem *item) const
gets the message represented by the item as a KMMsgBase.
virtual void readFolderConfig(void)
Read per-folder config options and apply them.
void reset()
Refresh the list of message headers shown.
void selected(KMMessage *)
emitted when the list view item corresponding to this message has been selected
void styleChange(TQStyle &oldStyle)
reimplemented in order to update the frame width in case of a changed GUI style
virtual KMMessageList * selectedMsgs(bool toBeDeleted=false)
Returns list of selected messages.
void restoreColumnLayout(TDEConfig *config, const TQString &group)
Same as TDEListView::restoreLayout(), only that this does not restore the sort order.
virtual void setOpen(TQListViewItem *, bool)
Double force items to always be open.
virtual void moveSelectedToFolder(int menuId)
Move messages corresponding to the selected items to the folder corresponding to the given menuId.
void msgRemoved(int, TQString)
For when the message with the given id has been removed for a folder.
void makeHeaderVisible()
Ensure the current item is visible.
virtual void readConfig(void)
Read config options.
void selectCurrentMessage()
Select the message which currently has focus, if it's not already selected.
void slotExpandOrCollapseAllThreads(bool expand)
Expands (expand == true) or collapses (expand == false) all threads.
virtual void setSelected(TQListViewItem *item, bool selected)
Select an item and if it is the parent of a closed thread, also recursively select its children.
void decCurrentMessage()
Focus the previous message, but don't select it.
virtual void clearSelectableAndAboutToBeDeleted(TQ_UINT32 serNum)
Resets toBeDeleted and selectable status of all selected items.
virtual KMMessage * currentMsg()
Return the current message.
virtual void setCurrentItemByIndex(int msgIdx)
Set the current item to the one corresponding to the given msg id.
virtual bool event(TQEvent *e)
Look for color changes.
virtual int slotFilterMsg(KMMessage *)
Apply the filter Rules to a single message.
void folderClosed()
For when the folder has been cleared.
void slotNoDrag()
Don't show a drag cursor.
void resetCurrentTime()
timer function to set the current time regularly
void prevMessage()
Make the previous header visible scrolling if necessary.
TQValueList< int > selectedItems()
Returns the index values of currently selected items.
void selectPrevMessage()
Same as prevMessage() but don't clear the current selection.
void nextMessage()
Make the next header visible scrolling if necessary.
void setCopiedMessages(const TQValueList< TQ_UINT32 > &msgs, bool move)
Sets the list of copied/cutted messages.
void slotToggleColumn(int id, int mode=-1)
switch a column with the given id (see KPaintInfo enum) 1 for activate, 0 for deactivate,...
void dirtySortOrder(int)
dirties the sort order
void selectNextMessage()
Same as nextMessage() but don't clear the current selection.
bool nextUnreadMessage(bool acceptCurrent=false)
Make the nextUnread message header visible scrolling if necessary, returning true if an unread messag...
virtual void moveMsgToFolder(KMFolder *destination, bool askForConfirmation=true)
If destination is 0 then the messages are deleted, otherwise they are moved to this folder.
static TQString fancyDate(time_t otime)
return a string relativ to the current time
virtual void setSorting(int column, bool ascending=true)
Called when a header is clicked.
void contentsMouseMoveEvent(TQMouseEvent *e)
To initiate a drag operation.
void msgHeaderChanged(KMFolder *folder, int msgId)
Refresh list view item corresponding to the messae with the given id.
virtual void readColorConfig(void)
Read color options and set palette.
void setCurrentItemBySerialNum(unsigned long serialNum)
Set the current item to the one corresponding to the given serial number (slow!)
virtual HeaderItem * currentHeaderItem()
Return the current list view item.
KMFolder * folder(void)
Return the folder whose message headers are being displayed.
Definition kmheaders.h:64
virtual void copyMsgToFolder(KMFolder *destination, KMMessage *aMsg=0)
Messages are duplicated and added to given folder.
void refreshNestedState(void)
read the config file and update nested state if necessary
void rightButtonPressed(TQListViewItem *, const TQPoint &, int)
show context menu
TQPtrList< TQListViewItem > currentThread() const
Get a list of all items in the current thread.
virtual void setThreadStatus(KMMsgStatus status, bool toggle=false)
Set all messages in the current thread to status status or toggle it, if specified.
bool prevUnreadMessage()
Make the previous message header visible scrolling if necessary, returning true if an unread message ...
void activated(KMMessage *)
emitted when the list view item corresponding to this message has been double clicked
void setStyleDependantFrameWidth()
Set the width of the frame to a reasonable value for the current GUI style.
void folderCleared()
For when the folder has been cleared.
void slotRMB()
For when righ mouse button is pressed.
virtual int firstSelectedMsg() const
Returns message index of first selected message of the messages where the message with the given id i...
KMMainWidget * owner(void) const
Returns pointer to owning main window.
Definition kmheaders.h:124
virtual void setTopItemByIndex(int aMsgIdx)
Make the item corresponding to the message with the given id the top most visible item.
void slotExpandOrCollapseThread(bool expand)
Expands (expand == true) or collapses (expand == false) the current thread.
void msgAddedToListView(TQListViewItem *)
emitted after a new item has been fully built and added to the list view.
virtual void setCurrentMsg(int msgId)
Set current message.
virtual int currentItemIndex()
Return the index of the message corresponding to the current item.
virtual void setMsgStatus(KMMsgStatus status, bool toggle=false)
The following methods processes all selected messages.
virtual void writeFolderConfig(void)
Write per-folder config options.
virtual void writeConfig(void)
Write global config options.
void selectMessage(TQListViewItem *)
For when a list view item has been double clicked.
void findUnreadAux(HeaderItem *&, bool &, bool, bool)
Auxillary method to findUnread.
void messageListUpdated()
emitted when the list of messages has been completely rebuilt
bool isMessageCut(TQ_UINT32 serNum) const
Returns true if the message with the given serial number has been cut.
virtual int findUnread(bool findNext, int startAt=-1, bool onlyNew=false, bool acceptCurrent=false)
Find next/prev unread message.
virtual int topItemIndex()
Return the message id of the top most visible item.
void maybeDeleting()
emitted when we might be about to delete messages
This is a Mime Message.
Definition kmmessage.h:68
Visual representation of a member of the set of displayables (mails in the current folder).
Definition headeritem.h:164
Represents an item in the set of mails to be displayed but only as far as sorting,...
Definition headeritem.h:54