Factor out the shared parts of the agent action manager setup.
[kdepim.git] / knode / headerview.h
blob7667c8929e01284ea1efbca181545a489762f2ed
1 /*
2 KNode, the KDE newsreader
3 Copyright (c) 1999-2005 the KNode authors.
4 See file AUTHORS for details
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
15 #ifndef KNHEADERVIEW_H
16 #define KNHEADERVIEW_H
18 #include <QMouseEvent>
19 #include <QKeyEvent>
20 #include <QEvent>
22 #include <k3listview.h>
23 #include <kmime/kmime_dateformatter.h>
25 class KMenu;
26 class KNHdrViewItem;
28 /** Information shared by all items in a list view */
29 struct KPaintInfo {
31 // Popup ids for toggle-able columns
32 enum ColumnIds {
33 COL_SIZE,
34 COL_ATTACHMENT,
35 COL_IMPORTANT,
36 COL_TOACT,
37 COL_SPAM_HAM,
38 COL_WATCHED_IGNORED,
39 COL_STATUS,
40 COL_SIGNED,
41 COL_CRYPTO,
42 COL_RECEIVER,
43 COL_SCORE
46 KPaintInfo() :
47 pixmapOn( false ),
49 showSize( false ),
50 showAttachment( false ),
51 showImportant( false ),
52 showToAct( false ),
53 showSpamHam( false ),
54 showWatchedIgnored( false ),
55 showStatus( false ),
56 showSigned( false ),
57 showCrypto( false ),
58 showReceiver( false ),
59 showScore( false ),
61 scoreCol( -1 ),
62 flagCol( -1 ),
63 senderCol( -1 ),
64 receiverCol( -1 ),
65 subCol( -1 ),
66 dateCol( -1 ),
67 sizeCol( -1 ),
68 attachmentCol( -1 ),
69 importantCol( -1 ),
70 toActCol( -1 ),
71 spamHamCol( -1 ),
72 watchedIgnoredCol( -1 ),
73 statusCol( -1 ),
74 signedCol( -1 ),
75 cryptoCol( -1 ),
77 orderOfArrival( false ),
78 status( false ),
79 showCryptoIcons( false ),
80 showAttachmentIcon( false )
83 bool pixmapOn;
84 QPixmap pixmap;
85 QColor colFore;
86 QColor colBack;
87 QColor colNew;
88 QColor colUnread;
89 QColor colFlag;
90 QColor colToAct;
91 QColor colCloseToQuota;
93 bool showSize;
94 bool showAttachment;
95 bool showImportant;
96 bool showToAct;
97 bool showSpamHam;
98 bool showWatchedIgnored;
99 bool showStatus;
100 bool showSigned;
101 bool showCrypto;
102 bool showReceiver;
103 bool showScore;
105 int scoreCol;
106 int flagCol;
107 int senderCol;
108 int receiverCol;
109 int subCol;
110 int dateCol;
111 int sizeCol;
112 int attachmentCol;
113 int importantCol;
114 int toActCol;
115 int spamHamCol;
116 int watchedIgnoredCol;
117 int statusCol;
118 int signedCol;
119 int cryptoCol;
121 bool orderOfArrival;
122 bool status;
123 bool showCryptoIcons;
124 bool showAttachmentIcon;
127 /** Header view, displays the article listing of the currently selected
128 * news group or folder.
130 class KNHeaderView : public K3ListView {
132 Q_OBJECT
134 friend class KNHdrViewItem;
136 public:
137 KNHeaderView( QWidget *parent );
138 ~KNHeaderView();
140 void setActive( Q3ListViewItem *item );
141 void clear();
143 void ensureItemVisibleWithMargin( const Q3ListViewItem *i );
145 virtual void setSorting( int column, bool ascending = true );
146 bool sortByThreadChangeDate() const { return mSortByThreadChangeDate; }
147 void setSortByThreadChangeDate( bool b ) { mSortByThreadChangeDate = b; }
149 bool nextUnreadArticle();
150 bool nextUnreadThread();
152 void readConfig();
153 void writeConfig();
155 const KPaintInfo* paintInfo() const { return &mPaintInfo; }
157 signals:
158 void itemSelected( Q3ListViewItem* );
159 void doubleClick( Q3ListViewItem* );
160 void sortingChanged( int );
162 public slots:
163 void nextArticle();
164 void prevArticle();
165 void incCurrentArticle();
166 void decCurrentArticle();
167 void selectCurrentArticle();
169 void toggleColumn( int column, int mode = -1 );
170 void prepareForGroup();
171 void prepareForFolder();
173 protected:
174 void activeRemoved() { mActiveItem = 0; }
176 * Reimplemented to avoid that KListview reloads the alternate
177 * background on palette changes.
179 virtual bool event( QEvent *e );
180 void contentsMousePressEvent( QMouseEvent *e );
181 void contentsMouseDoubleClickEvent( QMouseEvent *e );
182 void keyPressEvent( QKeyEvent *e );
183 bool eventFilter( QObject *, QEvent * );
184 virtual Q3DragObject* dragObject();
186 private:
187 int mSortCol;
188 bool mSortAsc;
189 bool mSortByThreadChangeDate;
190 int mDelayedCenter;
191 KNHdrViewItem *mActiveItem;
192 KPaintInfo mPaintInfo;
193 KMime::DateFormatter mDateFormatter;
194 KMenu *mPopup;
195 bool mShowingFolder;
196 bool mInitDone;
198 private slots:
199 void slotCenterDelayed();
200 void slotSizeChanged( int, int, int );
204 #if 0
205 class KNHeaderViewToolTip : public QToolTip {
207 public:
208 KNHeaderViewToolTip( KNHeaderView *parent );
210 protected:
211 void maybeTip( const QPoint &p );
213 private:
214 KNHeaderView *listView;
217 #endif
219 #endif