-rw-r--r-- | korganizer/komonthview.cpp | 27 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 |
2 files changed, 29 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index ab9a4b6..9f7db69 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,564 +1,587 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | resetOnFocusIn = true; | ||
86 | } | 87 | } |
87 | KNoScrollListBox::~KNoScrollListBox() | 88 | KNoScrollListBox::~KNoScrollListBox() |
88 | { | 89 | { |
89 | 90 | ||
90 | } | 91 | } |
92 | |||
93 | |||
94 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | ||
95 | { | ||
96 | QListBox::focusInEvent ( e ); | ||
97 | QListBoxItem * i = item ( 0 ); | ||
98 | if ( i && resetOnFocusIn ) { | ||
99 | setCurrentItem( i ); | ||
100 | setSelected ( 0, true ); | ||
101 | } | ||
102 | resetOnFocusIn = true; | ||
103 | } | ||
104 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | ||
105 | { | ||
106 | int i = currentItem (); | ||
107 | if ( i >= 0 ) { | ||
108 | setSelected ( i, false ); | ||
109 | } | ||
110 | QListBox::focusOutEvent ( e ); | ||
111 | } | ||
112 | |||
91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 113 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
92 | { | 114 | { |
93 | QListBoxItem* item = itemAt ( p ); | 115 | QListBoxItem* item = itemAt ( p ); |
94 | if ( ! item ) { | 116 | if ( ! item ) { |
95 | return i18n("Click in the cell\nto add an event!"); | 117 | return i18n("Click in the cell\nto add an event!"); |
96 | } | 118 | } |
97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 119 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
98 | KOPrefs::instance()->mWTshowDetails, | 120 | KOPrefs::instance()->mWTshowDetails, |
99 | KOPrefs::instance()->mWTshowCreated, | 121 | KOPrefs::instance()->mWTshowCreated, |
100 | KOPrefs::instance()->mWTshowChanged); | 122 | KOPrefs::instance()->mWTshowChanged); |
101 | } | 123 | } |
102 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 124 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
103 | { | 125 | { |
104 | //qDebug("KNoScrollListBox::keyPressEvent "); | 126 | //qDebug("KNoScrollListBox::keyPressEvent "); |
105 | switch(e->key()) { | 127 | switch(e->key()) { |
106 | case Key_Right: | 128 | case Key_Right: |
107 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 129 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
108 | { | 130 | { |
109 | e->ignore(); | 131 | e->ignore(); |
110 | return; | 132 | return; |
111 | } | 133 | } |
112 | scrollBy(10,0); | 134 | scrollBy(10,0); |
113 | break; | 135 | break; |
114 | case Key_Left: | 136 | case Key_Left: |
115 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 137 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
116 | { | 138 | { |
117 | e->ignore(); | 139 | e->ignore(); |
118 | return; | 140 | return; |
119 | } | 141 | } |
120 | scrollBy(-10,0); | 142 | scrollBy(-10,0); |
121 | break; | 143 | break; |
122 | case Key_Up: | 144 | case Key_Up: |
123 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 145 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
124 | e->ignore(); | 146 | e->ignore(); |
125 | break; | 147 | break; |
126 | } | 148 | } |
127 | if ( count() ) { | 149 | if ( count() ) { |
128 | setCurrentItem((currentItem()+count()-1)%count()); | 150 | setCurrentItem((currentItem()+count()-1)%count()); |
129 | if(!itemVisible(currentItem())) { | 151 | if(!itemVisible(currentItem())) { |
130 | if((unsigned int) currentItem() == (count()-1)) { | 152 | if((unsigned int) currentItem() == (count()-1)) { |
131 | setTopItem(currentItem()-numItemsVisible()+1); | 153 | setTopItem(currentItem()-numItemsVisible()+1); |
132 | } else { | 154 | } else { |
133 | setTopItem(topItem()-1); | 155 | setTopItem(topItem()-1); |
134 | } | 156 | } |
135 | } | 157 | } |
136 | } | 158 | } |
137 | break; | 159 | break; |
138 | case Key_Down: | 160 | case Key_Down: |
139 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 161 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
140 | e->ignore(); | 162 | e->ignore(); |
141 | break; | 163 | break; |
142 | } | 164 | } |
143 | if ( count () ) { | 165 | if ( count () ) { |
144 | setCurrentItem((currentItem()+1)%count()); | 166 | setCurrentItem((currentItem()+1)%count()); |
145 | if(!itemVisible(currentItem())) { | 167 | if(!itemVisible(currentItem())) { |
146 | if(currentItem() == 0) { | 168 | if(currentItem() == 0) { |
147 | setTopItem(0); | 169 | setTopItem(0); |
148 | } else { | 170 | } else { |
149 | setTopItem(topItem()+1); | 171 | setTopItem(topItem()+1); |
150 | } | 172 | } |
151 | } | 173 | } |
152 | } | 174 | } |
153 | break; | 175 | break; |
154 | case Key_I: | 176 | case Key_I: |
155 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 177 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
156 | e->ignore(); | 178 | e->ignore(); |
157 | break; | 179 | break; |
158 | case Key_Return: | 180 | case Key_Return: |
159 | case Key_Enter: | 181 | case Key_Enter: |
160 | { | 182 | { |
161 | if ( currentItem() >= 0 ) { | 183 | if ( currentItem() >= 0 ) { |
162 | emit doubleClicked( item( currentItem() ) ); | 184 | emit doubleClicked( item( currentItem() ) ); |
163 | e->accept(); | 185 | e->accept(); |
164 | } else { | 186 | } else { |
165 | e->ignore(); | 187 | e->ignore(); |
166 | } | 188 | } |
167 | } | 189 | } |
168 | break; | 190 | break; |
169 | case Key_Shift: | 191 | case Key_Shift: |
170 | emit shiftDown(); | 192 | emit shiftDown(); |
171 | break; | 193 | break; |
172 | default: | 194 | default: |
173 | e->ignore(); | 195 | e->ignore(); |
174 | break; | 196 | break; |
175 | } | 197 | } |
176 | } | 198 | } |
177 | 199 | ||
178 | void KNoScrollListBox::oneDown() | 200 | void KNoScrollListBox::oneDown() |
179 | { | 201 | { |
180 | if ( count () ) { | 202 | if ( count () ) { |
203 | resetOnFocusIn = false; | ||
181 | setCurrentItem((currentItem()+1)%count()); | 204 | setCurrentItem((currentItem()+1)%count()); |
182 | if(!itemVisible(currentItem())) { | 205 | if(!itemVisible(currentItem())) { |
183 | if(currentItem() == 0) { | 206 | if(currentItem() == 0) { |
184 | setTopItem(0); | 207 | setTopItem(0); |
185 | } else { | 208 | } else { |
186 | setTopItem(topItem()+1); | 209 | setTopItem(topItem()+1); |
187 | } | 210 | } |
188 | } | 211 | } |
189 | } | 212 | } |
190 | } | 213 | } |
191 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 214 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
192 | { | 215 | { |
193 | switch(e->key()) { | 216 | switch(e->key()) { |
194 | case Key_Shift: | 217 | case Key_Shift: |
195 | emit shiftUp(); | 218 | emit shiftUp(); |
196 | break; | 219 | break; |
197 | default: | 220 | default: |
198 | break; | 221 | break; |
199 | } | 222 | } |
200 | } | 223 | } |
201 | 224 | ||
202 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 225 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
203 | { | 226 | { |
204 | QListBox::mousePressEvent(e); | 227 | QListBox::mousePressEvent(e); |
205 | 228 | ||
206 | if(e->button() == RightButton) { | 229 | if(e->button() == RightButton) { |
207 | emit rightClick(); | 230 | emit rightClick(); |
208 | } | 231 | } |
209 | } | 232 | } |
210 | 233 | ||
211 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 234 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
212 | : QListBoxItem() | 235 | : QListBoxItem() |
213 | { | 236 | { |
214 | mblockRepaint = true; | 237 | mblockRepaint = true; |
215 | setText( s ); | 238 | setText( s ); |
216 | mMultiday = 0; | 239 | mMultiday = 0; |
217 | mIncidence = incidence; | 240 | mIncidence = incidence; |
218 | mDate = qd; | 241 | mDate = qd; |
219 | mRecur = false; | 242 | mRecur = false; |
220 | mAlarm = false; | 243 | mAlarm = false; |
221 | mReply = false; | 244 | mReply = false; |
222 | mInfo = false; | 245 | mInfo = false; |
223 | //qDebug("NEWWWWWWWWWWWWW "); | 246 | //qDebug("NEWWWWWWWWWWWWW "); |
224 | } | 247 | } |
225 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 248 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
226 | { | 249 | { |
227 | setText( s ); | 250 | setText( s ); |
228 | mMultiday = 0; | 251 | mMultiday = 0; |
229 | mIncidence = incidence; | 252 | mIncidence = incidence; |
230 | mDate = qd; | 253 | mDate = qd; |
231 | mRecur = false; | 254 | mRecur = false; |
232 | mAlarm = false; | 255 | mAlarm = false; |
233 | mReply = false; | 256 | mReply = false; |
234 | mInfo = false; | 257 | mInfo = false; |
235 | //qDebug("recucleeeeeeeeeeeeeeeee "); | 258 | //qDebug("recucleeeeeeeeeeeeeeeee "); |
236 | } | 259 | } |
237 | 260 | ||
238 | void MonthViewItem::paint(QPainter *p) | 261 | void MonthViewItem::paint(QPainter *p) |
239 | { | 262 | { |
240 | if ( mblockRepaint ) { | 263 | if ( mblockRepaint ) { |
241 | //qDebug("block "); | 264 | //qDebug("block "); |
242 | return; | 265 | return; |
243 | } | 266 | } |
244 | //qDebug("NON block "); | 267 | //qDebug("NON block "); |
245 | #if QT_VERSION >= 0x030000 | 268 | #if QT_VERSION >= 0x030000 |
246 | bool sel = isSelected(); | 269 | bool sel = isSelected(); |
247 | #else | 270 | #else |
248 | bool sel = selected(); | 271 | bool sel = selected(); |
249 | #endif | 272 | #endif |
250 | 273 | ||
251 | 274 | ||
252 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 275 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
253 | { | 276 | { |
254 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 277 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
255 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 278 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
256 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 279 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
257 | } | 280 | } |
258 | int x = 1; | 281 | int x = 1; |
259 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 282 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
260 | int size = PIXMAP_SIZE; | 283 | int size = PIXMAP_SIZE; |
261 | if ( QApplication::desktop()->width() < 300 ) | 284 | if ( QApplication::desktop()->width() < 300 ) |
262 | size = 3; | 285 | size = 3; |
263 | int heihei = height( listBox () ); | 286 | int heihei = height( listBox () ); |
264 | int y = (heihei - size -1 ) /2; | 287 | int y = (heihei - size -1 ) /2; |
265 | 288 | ||
266 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 289 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
267 | if ( mInfo ) { | 290 | if ( mInfo ) { |
268 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 291 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
269 | x += size + 1; | 292 | x += size + 1; |
270 | } | 293 | } |
271 | if ( mRecur ) { | 294 | if ( mRecur ) { |
272 | p->fillRect ( x, y,size,size, Qt::blue ); | 295 | p->fillRect ( x, y,size,size, Qt::blue ); |
273 | x += size + 1; | 296 | x += size + 1; |
274 | } | 297 | } |
275 | if ( mAlarm ) { | 298 | if ( mAlarm ) { |
276 | p->fillRect ( x, y,size,size, Qt::red ); | 299 | p->fillRect ( x, y,size,size, Qt::red ); |
277 | x += size + 1; | 300 | x += size + 1; |
278 | } | 301 | } |
279 | if ( mReply ) { | 302 | if ( mReply ) { |
280 | p->fillRect ( x, y,size,size, Qt::yellow ); | 303 | p->fillRect ( x, y,size,size, Qt::yellow ); |
281 | x += size + 1; | 304 | x += size + 1; |
282 | } | 305 | } |
283 | } | 306 | } |
284 | if ( mMultiday ) { | 307 | if ( mMultiday ) { |
285 | int yyy = y+(size/2); | 308 | int yyy = y+(size/2); |
286 | int sizeM = size+2; | 309 | int sizeM = size+2; |
287 | p->setBrush( QBrush::SolidPattern ); | 310 | p->setBrush( QBrush::SolidPattern ); |
288 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 311 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
289 | if ( mMultiday == 2 || mMultiday == 3 ) { | 312 | if ( mMultiday == 2 || mMultiday == 3 ) { |
290 | QPointArray pa ( 3 ); | 313 | QPointArray pa ( 3 ); |
291 | pa.setPoint (0, x, yyy ); | 314 | pa.setPoint (0, x, yyy ); |
292 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 315 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
293 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 316 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
294 | p->drawPolygon( pa ); | 317 | p->drawPolygon( pa ); |
295 | } | 318 | } |
296 | if ( mMultiday == 2 || mMultiday == 1 ) { | 319 | if ( mMultiday == 2 || mMultiday == 1 ) { |
297 | QPointArray pa ( 3 ); | 320 | QPointArray pa ( 3 ); |
298 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 321 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
299 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 322 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
300 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 323 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
301 | p->drawPolygon( pa ); | 324 | p->drawPolygon( pa ); |
302 | } | 325 | } |
303 | if ( mMultiday == 1 ) { | 326 | if ( mMultiday == 1 ) { |
304 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 327 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
305 | 328 | ||
306 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 329 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
307 | } | 330 | } |
308 | if ( mMultiday == 3 ) { | 331 | if ( mMultiday == 3 ) { |
309 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 332 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
310 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 333 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
311 | 334 | ||
312 | } | 335 | } |
313 | x += sizeM/2 + 1; | 336 | x += sizeM/2 + 1; |
314 | x += sizeM + 1; | 337 | x += sizeM + 1; |
315 | } | 338 | } |
316 | 339 | ||
317 | if ( mIncidence->type() == "Todo" ){ | 340 | if ( mIncidence->type() == "Todo" ){ |
318 | Todo* td = ( Todo* ) mIncidence; | 341 | Todo* td = ( Todo* ) mIncidence; |
319 | if ( td->isCompleted() ) { | 342 | if ( td->isCompleted() ) { |
320 | int half = size/2; | 343 | int half = size/2; |
321 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 344 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
322 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 345 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
323 | x += half+half + 4; | 346 | x += half+half + 4; |
324 | 347 | ||
325 | } else { | 348 | } else { |
326 | int val = td->percentComplete()/20; | 349 | int val = td->percentComplete()/20; |
327 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); | 350 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); |
328 | p->drawRect ( x, y-2,7,size+4); | 351 | p->drawRect ( x, y-2,7,size+4); |
329 | x += size + 3; | 352 | x += size + 3; |
330 | } | 353 | } |
331 | } | 354 | } |
332 | QFontMetrics fm = p->fontMetrics(); | 355 | QFontMetrics fm = p->fontMetrics(); |
333 | int yPos; | 356 | int yPos; |
334 | int pmheight = size; | 357 | int pmheight = size; |
335 | if( pmheight < fm.height() ) | 358 | if( pmheight < fm.height() ) |
336 | yPos = fm.ascent() + fm.leading()/2; | 359 | yPos = fm.ascent() + fm.leading()/2; |
337 | else | 360 | else |
338 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 361 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
339 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 362 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
340 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 363 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
341 | p->drawText( x, yPos, text() ); | 364 | p->drawText( x, yPos, text() ); |
342 | if ( mIncidence->cancelled() ) { | 365 | if ( mIncidence->cancelled() ) { |
343 | int wid = fm.width( text() ); | 366 | int wid = fm.width( text() ); |
344 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); | 367 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); |
345 | } | 368 | } |
346 | 369 | ||
347 | } | 370 | } |
348 | 371 | ||
349 | int MonthViewItem::height(const QListBox *lb) const | 372 | int MonthViewItem::height(const QListBox *lb) const |
350 | { | 373 | { |
351 | int ret = 10; | 374 | int ret = 10; |
352 | if ( lb ) | 375 | if ( lb ) |
353 | ret = lb->fontMetrics().lineSpacing()+1; | 376 | ret = lb->fontMetrics().lineSpacing()+1; |
354 | return ret; | 377 | return ret; |
355 | } | 378 | } |
356 | 379 | ||
357 | int MonthViewItem::width(const QListBox *lb) const | 380 | int MonthViewItem::width(const QListBox *lb) const |
358 | { | 381 | { |
359 | 382 | ||
360 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 383 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
361 | int size = PIXMAP_SIZE; | 384 | int size = PIXMAP_SIZE; |
362 | if ( QApplication::desktop()->width() < 300 ) | 385 | if ( QApplication::desktop()->width() < 300 ) |
363 | size = 3; | 386 | size = 3; |
364 | int x = 1; | 387 | int x = 1; |
365 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 388 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
366 | if ( mInfo ) { | 389 | if ( mInfo ) { |
367 | x += size + 1; | 390 | x += size + 1; |
368 | } | 391 | } |
369 | if( mRecur ) { | 392 | if( mRecur ) { |
370 | x += size+1; | 393 | x += size+1; |
371 | } | 394 | } |
372 | if( mAlarm ) { | 395 | if( mAlarm ) { |
373 | x += size+1; | 396 | x += size+1; |
374 | } | 397 | } |
375 | if( mReply ) { | 398 | if( mReply ) { |
376 | x += size+1; | 399 | x += size+1; |
377 | } | 400 | } |
378 | } | 401 | } |
379 | if( mMultiday ) { | 402 | if( mMultiday ) { |
380 | x += size+1+2+size/2; | 403 | x += size+1+2+size/2; |
381 | } | 404 | } |
382 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 405 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
383 | } | 406 | } |
384 | if ( ! lb ) | 407 | if ( ! lb ) |
385 | return 10; | 408 | return 10; |
386 | //qDebug("ret wid %d ", lb->width()); | 409 | //qDebug("ret wid %d ", lb->width()); |
387 | return lb->width(); | 410 | return lb->width(); |
388 | } | 411 | } |
389 | 412 | ||
390 | 413 | ||
391 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 414 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
392 | : KNoScrollListBox( par ), | 415 | : KNoScrollListBox( par ), |
393 | mMonthView( parent ) | 416 | mMonthView( parent ) |
394 | { | 417 | { |
395 | 418 | ||
396 | mCurrentAvailItem = 0; | 419 | mCurrentAvailItem = 0; |
397 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 420 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
398 | currentPalette = 0; | 421 | currentPalette = 0; |
399 | // mLabel = new QLabel( this );QPushButton | 422 | // mLabel = new QLabel( this );QPushButton |
400 | mLabel = new QPushButton( this ); | 423 | mLabel = new QPushButton( this ); |
401 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 424 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
402 | //mLabel->setLineWidth( 1 ); | 425 | //mLabel->setLineWidth( 1 ); |
403 | //mLabel->setAlignment( AlignCenter ); | 426 | //mLabel->setAlignment( AlignCenter ); |
404 | mLabel->setFlat( true ); | 427 | mLabel->setFlat( true ); |
405 | mLabel->setFocusPolicy(NoFocus); | 428 | mLabel->setFocusPolicy(NoFocus); |
406 | //mItemList = new KNoScrollListBox( this ); | 429 | //mItemList = new KNoScrollListBox( this ); |
407 | setMinimumSize( 10, 10 ); | 430 | setMinimumSize( 10, 10 ); |
408 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 431 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
409 | setLineWidth( 1 ); | 432 | setLineWidth( 1 ); |
410 | //topLayout->addWidget( mItemList ); | 433 | //topLayout->addWidget( mItemList ); |
411 | mLabel->raise(); | 434 | mLabel->raise(); |
412 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 435 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
413 | mStandardPalette = palette(); | 436 | mStandardPalette = palette(); |
414 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 437 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
415 | 438 | ||
416 | enableScrollBars( false ); | 439 | enableScrollBars( false ); |
417 | updateConfig(); | 440 | updateConfig(); |
418 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 441 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
419 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 442 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
420 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 443 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
421 | SLOT( defaultAction( QListBoxItem * ) ) ); | 444 | SLOT( defaultAction( QListBoxItem * ) ) ); |
422 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 445 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
423 | const QPoint &) ), | 446 | const QPoint &) ), |
424 | SLOT( contextMenu( QListBoxItem * ) ) ); | 447 | SLOT( contextMenu( QListBoxItem * ) ) ); |
425 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 448 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
426 | SLOT( selection( QListBoxItem * ) ) ); | 449 | SLOT( selection( QListBoxItem * ) ) ); |
427 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 450 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
428 | SLOT( cellClicked( QListBoxItem * ) ) ); | 451 | SLOT( cellClicked( QListBoxItem * ) ) ); |
429 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 452 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
430 | SLOT( selection( QListBoxItem * ) ) ); | 453 | SLOT( selection( QListBoxItem * ) ) ); |
431 | } | 454 | } |
432 | #ifdef DESKTOP_VERSION | 455 | #ifdef DESKTOP_VERSION |
433 | QToolTipGroup *MonthViewCell::toolTipGroup() | 456 | QToolTipGroup *MonthViewCell::toolTipGroup() |
434 | { | 457 | { |
435 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 458 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
436 | return mToolTipGroup; | 459 | return mToolTipGroup; |
437 | } | 460 | } |
438 | #endif | 461 | #endif |
439 | 462 | ||
440 | void MonthViewCell::setDate( const QDate &date ) | 463 | void MonthViewCell::setDate( const QDate &date ) |
441 | { | 464 | { |
442 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 465 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
443 | mDate = date; | 466 | mDate = date; |
444 | 467 | ||
445 | 468 | ||
446 | 469 | ||
447 | //resizeEvent( 0 ); | 470 | //resizeEvent( 0 ); |
448 | } | 471 | } |
449 | 472 | ||
450 | QDate MonthViewCell::date() const | 473 | QDate MonthViewCell::date() const |
451 | { | 474 | { |
452 | return mDate; | 475 | return mDate; |
453 | } | 476 | } |
454 | 477 | ||
455 | void MonthViewCell::setPrimary( bool primary ) | 478 | void MonthViewCell::setPrimary( bool primary ) |
456 | { | 479 | { |
457 | mPrimary = primary; | 480 | mPrimary = primary; |
458 | //setMyPalette(); | 481 | //setMyPalette(); |
459 | } | 482 | } |
460 | void MonthViewCell::setMyPalette() | 483 | void MonthViewCell::setMyPalette() |
461 | { | 484 | { |
462 | 485 | ||
463 | if ( mHoliday) { | 486 | if ( mHoliday) { |
464 | if ( currentPalette == 1 ) return; | 487 | if ( currentPalette == 1 ) return; |
465 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 488 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
466 | setPalette( mHolidayPalette ); | 489 | setPalette( mHolidayPalette ); |
467 | //mLabel->setPalette( mHolidayPalette ); | 490 | //mLabel->setPalette( mHolidayPalette ); |
468 | currentPalette = 1; | 491 | currentPalette = 1; |
469 | 492 | ||
470 | } else { | 493 | } else { |
471 | if ( mPrimary ) { | 494 | if ( mPrimary ) { |
472 | if ( currentPalette == 2 ) return; | 495 | if ( currentPalette == 2 ) return; |
473 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 496 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
474 | //mLabel->setPalette( mPrimaryPalette ); | 497 | //mLabel->setPalette( mPrimaryPalette ); |
475 | setPalette( mPrimaryPalette ); | 498 | setPalette( mPrimaryPalette ); |
476 | currentPalette = 2; | 499 | currentPalette = 2; |
477 | 500 | ||
478 | } else { | 501 | } else { |
479 | if ( currentPalette == 3 ) return; | 502 | if ( currentPalette == 3 ) return; |
480 | setPalette( mNonPrimaryPalette ); | 503 | setPalette( mNonPrimaryPalette ); |
481 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 504 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
482 | //mLabel->setPalette( mNonPrimaryPalette );; | 505 | //mLabel->setPalette( mNonPrimaryPalette );; |
483 | currentPalette = 3; | 506 | currentPalette = 3; |
484 | } | 507 | } |
485 | } | 508 | } |
486 | //QPalette pal = palette(); | 509 | //QPalette pal = palette(); |
487 | 510 | ||
488 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 511 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
489 | } | 512 | } |
490 | QPalette MonthViewCell::getPalette () | 513 | QPalette MonthViewCell::getPalette () |
491 | { | 514 | { |
492 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 515 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
493 | return mStandardPalette; | 516 | return mStandardPalette; |
494 | if ( mHoliday) { | 517 | if ( mHoliday) { |
495 | return mHolidayPalette ; | 518 | return mHolidayPalette ; |
496 | } else { | 519 | } else { |
497 | if ( mPrimary ) { | 520 | if ( mPrimary ) { |
498 | return mPrimaryPalette ; | 521 | return mPrimaryPalette ; |
499 | } | 522 | } |
500 | } | 523 | } |
501 | return mNonPrimaryPalette; | 524 | return mNonPrimaryPalette; |
502 | } | 525 | } |
503 | bool MonthViewCell::isPrimary() const | 526 | bool MonthViewCell::isPrimary() const |
504 | { | 527 | { |
505 | return mPrimary; | 528 | return mPrimary; |
506 | } | 529 | } |
507 | 530 | ||
508 | void MonthViewCell::setHoliday( bool holiday ) | 531 | void MonthViewCell::setHoliday( bool holiday ) |
509 | { | 532 | { |
510 | mHoliday = holiday; | 533 | mHoliday = holiday; |
511 | //setMyPalette(); | 534 | //setMyPalette(); |
512 | } | 535 | } |
513 | 536 | ||
514 | void MonthViewCell::setHoliday( const QString &holiday ) | 537 | void MonthViewCell::setHoliday( const QString &holiday ) |
515 | { | 538 | { |
516 | mHolidayString = holiday; | 539 | mHolidayString = holiday; |
517 | 540 | ||
518 | if ( !holiday.isEmpty() ) { | 541 | if ( !holiday.isEmpty() ) { |
519 | setHoliday( true ); | 542 | setHoliday( true ); |
520 | } | 543 | } |
521 | } | 544 | } |
522 | 545 | ||
523 | void MonthViewCell::startUpdateCell() | 546 | void MonthViewCell::startUpdateCell() |
524 | { | 547 | { |
525 | 548 | ||
526 | setFocusPolicy(NoFocus); | 549 | setFocusPolicy(NoFocus); |
527 | if ( !mMonthView->isUpdatePossible() ) | 550 | if ( !mMonthView->isUpdatePossible() ) |
528 | return; | 551 | return; |
529 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 552 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
530 | while ( mitem ) { | 553 | while ( mitem ) { |
531 | mitem->setBlockRepaint( true ); | 554 | mitem->setBlockRepaint( true ); |
532 | mitem = (MonthViewItem *)mitem->next(); | 555 | mitem = (MonthViewItem *)mitem->next(); |
533 | } | 556 | } |
534 | if ( mAvailItemList.count() > 20 ) { | 557 | if ( mAvailItemList.count() > 20 ) { |
535 | mAvailItemList.setAutoDelete( true ); | 558 | mAvailItemList.setAutoDelete( true ); |
536 | mAvailItemList.clear(); | 559 | mAvailItemList.clear(); |
537 | mAvailItemList.setAutoDelete( false ); | 560 | mAvailItemList.setAutoDelete( false ); |
538 | } | 561 | } |
539 | /* | 562 | /* |
540 | if ( !isVisible() ){ | 563 | if ( !isVisible() ){ |
541 | return; | 564 | return; |
542 | } | 565 | } |
543 | */ | 566 | */ |
544 | // qDebug("MonthViewCell::updateCell() "); | 567 | // qDebug("MonthViewCell::updateCell() "); |
545 | setPrimary( mDate.month()%2 ); | 568 | setPrimary( mDate.month()%2 ); |
546 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 569 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
547 | if ( mDate == QDate::currentDate() ) { | 570 | if ( mDate == QDate::currentDate() ) { |
548 | setLineWidth( 3 ); | 571 | setLineWidth( 3 ); |
549 | } else { | 572 | } else { |
550 | setLineWidth( 1 ); | 573 | setLineWidth( 1 ); |
551 | } | 574 | } |
552 | mCurrentAvailItem = (MonthViewItem*) firstItem (); | 575 | mCurrentAvailItem = (MonthViewItem*) firstItem (); |
553 | //clear(); | 576 | //clear(); |
554 | 577 | ||
555 | #ifdef DESKTOP_VERSION | 578 | #ifdef DESKTOP_VERSION |
556 | QToolTip::remove(this); | 579 | QToolTip::remove(this); |
557 | #endif | 580 | #endif |
558 | mToolTip.clear(); | 581 | mToolTip.clear(); |
559 | //qApp->processEvents(); | 582 | //qApp->processEvents(); |
560 | #if 0 | 583 | #if 0 |
561 | if ( !mHolidayString.isEmpty() ) { | 584 | if ( !mHolidayString.isEmpty() ) { |
562 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 585 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
563 | item->setPalette( mHolidayPalette ); | 586 | item->setPalette( mHolidayPalette ); |
564 | insertItem( item ); | 587 | insertItem( item ); |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 88050fe..e04cdf5 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,321 +1,324 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef _KOMONTHVIEW_H | 20 | #ifndef _KOMONTHVIEW_H |
21 | #define _KOMONTHVIEW_H | 21 | #define _KOMONTHVIEW_H |
22 | 22 | ||
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qframe.h> | 24 | #include <qframe.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qlistbox.h> | 26 | #include <qlistbox.h> |
27 | #include <qpoint.h> | 27 | #include <qpoint.h> |
28 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qintdict.h> | 31 | #include <qintdict.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qvaluelist.h> | 33 | #include <qvaluelist.h> |
34 | #include <qptrvector.h> | 34 | #include <qptrvector.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | #include <libkcal/event.h> | 37 | #include <libkcal/event.h> |
38 | 38 | ||
39 | #include "koeventview.h" | 39 | #include "koeventview.h" |
40 | #include "navigatorbar.h" | 40 | #include "navigatorbar.h" |
41 | 41 | ||
42 | #ifdef DESKTOP_VERSION | 42 | #ifdef DESKTOP_VERSION |
43 | class QToolTipGroup; | 43 | class QToolTipGroup; |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | class KNOWhatsThis; | 46 | class KNOWhatsThis; |
47 | class KOWeekButton : public QPushButton | 47 | class KOWeekButton : public QPushButton |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | public: | 50 | public: |
51 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 51 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
52 | QPushButton( parent, name) | 52 | QPushButton( parent, name) |
53 | { | 53 | { |
54 | connect( this, SIGNAL( clicked() ), | 54 | connect( this, SIGNAL( clicked() ), |
55 | SLOT( bottonClicked() )); | 55 | SLOT( bottonClicked() )); |
56 | mNumber = -1; | 56 | mNumber = -1; |
57 | } | 57 | } |
58 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 58 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
59 | int getWeekNum() { return mNumber;} | 59 | int getWeekNum() { return mNumber;} |
60 | signals: | 60 | signals: |
61 | void selectWeekNum ( int ); | 61 | void selectWeekNum ( int ); |
62 | private: | 62 | private: |
63 | int mNumber; | 63 | int mNumber; |
64 | void keyPressEvent ( QKeyEvent * e ) | 64 | void keyPressEvent ( QKeyEvent * e ) |
65 | { | 65 | { |
66 | e->ignore(); | 66 | e->ignore(); |
67 | } | 67 | } |
68 | 68 | ||
69 | private slots : | 69 | private slots : |
70 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 70 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
71 | }; | 71 | }; |
72 | 72 | ||
73 | class KNoScrollListBox: public QListBox | 73 | class KNoScrollListBox: public QListBox |
74 | { | 74 | { |
75 | Q_OBJECT | 75 | Q_OBJECT |
76 | public: | 76 | public: |
77 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 77 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
78 | ~KNoScrollListBox(); | 78 | ~KNoScrollListBox(); |
79 | QString getWhatsThisText(QPoint p) ; | 79 | QString getWhatsThisText(QPoint p) ; |
80 | 80 | ||
81 | signals: | 81 | signals: |
82 | void shiftDown(); | 82 | void shiftDown(); |
83 | void shiftUp(); | 83 | void shiftUp(); |
84 | void rightClick(); | 84 | void rightClick(); |
85 | 85 | ||
86 | protected slots: | 86 | protected slots: |
87 | void oneDown(); | 87 | void oneDown(); |
88 | void keyPressEvent(QKeyEvent *); | 88 | void keyPressEvent(QKeyEvent *); |
89 | void keyReleaseEvent(QKeyEvent *); | 89 | void keyReleaseEvent(QKeyEvent *); |
90 | void mousePressEvent(QMouseEvent *); | 90 | void mousePressEvent(QMouseEvent *); |
91 | void focusInEvent ( QFocusEvent * ); | ||
92 | void focusOutEvent ( QFocusEvent * ); | ||
91 | 93 | ||
92 | private: | 94 | private: |
95 | bool resetOnFocusIn; | ||
93 | KNOWhatsThis * mWT; | 96 | KNOWhatsThis * mWT; |
94 | }; | 97 | }; |
95 | 98 | ||
96 | 99 | ||
97 | class MonthViewItem: public QListBoxItem | 100 | class MonthViewItem: public QListBoxItem |
98 | { | 101 | { |
99 | public: | 102 | public: |
100 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 103 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
101 | void recycle( Incidence *incidence, QDate qd, const QString & s); | 104 | void recycle( Incidence *incidence, QDate qd, const QString & s); |
102 | void setRecur(bool on) { mRecur = on; } | 105 | void setRecur(bool on) { mRecur = on; } |
103 | void setAlarm(bool on) { mAlarm = on; } | 106 | void setAlarm(bool on) { mAlarm = on; } |
104 | void setReply(bool on) { mReply = on; } | 107 | void setReply(bool on) { mReply = on; } |
105 | void setMoreInfo(bool on) { mInfo = on; } | 108 | void setMoreInfo(bool on) { mInfo = on; } |
106 | void setMultiDay(int type) { mMultiday = type; } | 109 | void setMultiDay(int type) { mMultiday = type; } |
107 | void setBlockRepaint(bool on) { mblockRepaint = on; } | 110 | void setBlockRepaint(bool on) { mblockRepaint = on; } |
108 | 111 | ||
109 | 112 | ||
110 | void setPalette(const QPalette &p) { mPalette = p; } | 113 | void setPalette(const QPalette &p) { mPalette = p; } |
111 | QPalette palette() const { return mPalette; } | 114 | QPalette palette() const { return mPalette; } |
112 | 115 | ||
113 | Incidence *incidence() const { return mIncidence; } | 116 | Incidence *incidence() const { return mIncidence; } |
114 | QDate incidenceDate() { return mDate; } | 117 | QDate incidenceDate() { return mDate; } |
115 | 118 | ||
116 | protected: | 119 | protected: |
117 | virtual void paint(QPainter *); | 120 | virtual void paint(QPainter *); |
118 | virtual int height(const QListBox *) const; | 121 | virtual int height(const QListBox *) const; |
119 | virtual int width(const QListBox *) const; | 122 | virtual int width(const QListBox *) const; |
120 | 123 | ||
121 | private: | 124 | private: |
122 | bool mblockRepaint; | 125 | bool mblockRepaint; |
123 | int mMultiday; | 126 | int mMultiday; |
124 | bool mRecur; | 127 | bool mRecur; |
125 | bool mAlarm; | 128 | bool mAlarm; |
126 | bool mReply; | 129 | bool mReply; |
127 | bool mInfo; | 130 | bool mInfo; |
128 | 131 | ||
129 | QPalette mPalette; | 132 | QPalette mPalette; |
130 | QDate mDate; | 133 | QDate mDate; |
131 | 134 | ||
132 | Incidence *mIncidence; | 135 | Incidence *mIncidence; |
133 | }; | 136 | }; |
134 | 137 | ||
135 | 138 | ||
136 | class KOMonthView; | 139 | class KOMonthView; |
137 | 140 | ||
138 | class MonthViewCell : public KNoScrollListBox | 141 | class MonthViewCell : public KNoScrollListBox |
139 | { | 142 | { |
140 | Q_OBJECT | 143 | Q_OBJECT |
141 | public: | 144 | public: |
142 | MonthViewCell(KOMonthView *,QWidget* ); | 145 | MonthViewCell(KOMonthView *,QWidget* ); |
143 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} | 146 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} |
144 | 147 | ||
145 | void setDate( const QDate & ); | 148 | void setDate( const QDate & ); |
146 | QDate date() const; | 149 | QDate date() const; |
147 | 150 | ||
148 | void setPrimary( bool ); | 151 | void setPrimary( bool ); |
149 | bool isPrimary() const; | 152 | bool isPrimary() const; |
150 | 153 | ||
151 | void setHoliday( bool ); | 154 | void setHoliday( bool ); |
152 | void setHoliday( const QString & ); | 155 | void setHoliday( const QString & ); |
153 | 156 | ||
154 | void updateCell(); | 157 | void updateCell(); |
155 | void startUpdateCell(); | 158 | void startUpdateCell(); |
156 | void finishUpdateCell(); | 159 | void finishUpdateCell(); |
157 | void repaintfinishUpdateCell(); | 160 | void repaintfinishUpdateCell(); |
158 | void insertEvent(Event *); | 161 | void insertEvent(Event *); |
159 | void insertTodo(Todo *); | 162 | void insertTodo(Todo *); |
160 | 163 | ||
161 | void updateConfig( bool bigFont = false ); | 164 | void updateConfig( bool bigFont = false ); |
162 | 165 | ||
163 | void enableScrollBars( bool ); | 166 | void enableScrollBars( bool ); |
164 | 167 | ||
165 | Incidence *selectedIncidence(); | 168 | Incidence *selectedIncidence(); |
166 | QDate selectedIncidenceDate(); | 169 | QDate selectedIncidenceDate(); |
167 | QPushButton * dateLabel() { return mLabel; } | 170 | QPushButton * dateLabel() { return mLabel; } |
168 | 171 | ||
169 | void deselect(); | 172 | void deselect(); |
170 | void select(); | 173 | void select(); |
171 | #ifdef DESKTOP_VERSION | 174 | #ifdef DESKTOP_VERSION |
172 | static QToolTipGroup *toolTipGroup(); | 175 | static QToolTipGroup *toolTipGroup(); |
173 | #endif | 176 | #endif |
174 | signals: | 177 | signals: |
175 | void defaultAction( Incidence * ); | 178 | void defaultAction( Incidence * ); |
176 | void newEventSignal( QDateTime ); | 179 | void newEventSignal( QDateTime ); |
177 | void showDaySignal( QDate ); | 180 | void showDaySignal( QDate ); |
178 | 181 | ||
179 | protected: | 182 | protected: |
180 | QStringList mToolTip; | 183 | QStringList mToolTip; |
181 | void resizeEvent( QResizeEvent * ); | 184 | void resizeEvent( QResizeEvent * ); |
182 | 185 | ||
183 | 186 | ||
184 | public slots: | 187 | public slots: |
185 | void showDay(); | 188 | void showDay(); |
186 | 189 | ||
187 | protected slots: | 190 | protected slots: |
188 | void defaultAction( QListBoxItem * ); | 191 | void defaultAction( QListBoxItem * ); |
189 | void contextMenu( QListBoxItem * ); | 192 | void contextMenu( QListBoxItem * ); |
190 | void selection( QListBoxItem * ); | 193 | void selection( QListBoxItem * ); |
191 | void cellClicked( QListBoxItem * ); | 194 | void cellClicked( QListBoxItem * ); |
192 | void newEvent(); | 195 | void newEvent(); |
193 | 196 | ||
194 | private: | 197 | private: |
195 | MonthViewItem* mCurrentAvailItem; | 198 | MonthViewItem* mCurrentAvailItem; |
196 | QPtrList <MonthViewItem> mAvailItemList; | 199 | QPtrList <MonthViewItem> mAvailItemList; |
197 | KOMonthView *mMonthView; | 200 | KOMonthView *mMonthView; |
198 | int currentPalette; | 201 | int currentPalette; |
199 | 202 | ||
200 | QDate mDate; | 203 | QDate mDate; |
201 | bool mPrimary; | 204 | bool mPrimary; |
202 | bool mHoliday; | 205 | bool mHoliday; |
203 | QString mHolidayString; | 206 | QString mHolidayString; |
204 | 207 | ||
205 | //QLabel *mLabel; | 208 | //QLabel *mLabel; |
206 | QPushButton *mLabel; | 209 | QPushButton *mLabel; |
207 | //QListBox *mItemList; | 210 | //QListBox *mItemList; |
208 | #ifdef DESKTOP_VERSION | 211 | #ifdef DESKTOP_VERSION |
209 | static QToolTipGroup *mToolTipGroup; | 212 | static QToolTipGroup *mToolTipGroup; |
210 | #endif | 213 | #endif |
211 | QSize mLabelSize; | 214 | QSize mLabelSize; |
212 | QSize mLabelBigSize; | 215 | QSize mLabelBigSize; |
213 | QPalette mHolidayPalette; | 216 | QPalette mHolidayPalette; |
214 | QPalette mStandardPalette; | 217 | QPalette mStandardPalette; |
215 | QPalette mPrimaryPalette; | 218 | QPalette mPrimaryPalette; |
216 | QPalette mNonPrimaryPalette; | 219 | QPalette mNonPrimaryPalette; |
217 | void setMyPalette(); | 220 | void setMyPalette(); |
218 | QPalette getPalette (); | 221 | QPalette getPalette (); |
219 | 222 | ||
220 | }; | 223 | }; |
221 | 224 | ||
222 | 225 | ||
223 | class KOMonthView: public KOEventView | 226 | class KOMonthView: public KOEventView |
224 | { | 227 | { |
225 | Q_OBJECT | 228 | Q_OBJECT |
226 | public: | 229 | public: |
227 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 230 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
228 | ~KOMonthView(); | 231 | ~KOMonthView(); |
229 | 232 | ||
230 | /** Returns maximum number of days supported by the komonthview */ | 233 | /** Returns maximum number of days supported by the komonthview */ |
231 | virtual int maxDatesHint(); | 234 | virtual int maxDatesHint(); |
232 | 235 | ||
233 | /** Returns number of currently shown dates. */ | 236 | /** Returns number of currently shown dates. */ |
234 | virtual int currentDateCount(); | 237 | virtual int currentDateCount(); |
235 | 238 | ||
236 | /** returns the currently selected events */ | 239 | /** returns the currently selected events */ |
237 | virtual QPtrList<Incidence> selectedIncidences(); | 240 | virtual QPtrList<Incidence> selectedIncidences(); |
238 | 241 | ||
239 | /** returns dates of the currently selected events */ | 242 | /** returns dates of the currently selected events */ |
240 | virtual DateList selectedDates(); | 243 | virtual DateList selectedDates(); |
241 | 244 | ||
242 | virtual void printPreview(CalPrinter *calPrinter, | 245 | virtual void printPreview(CalPrinter *calPrinter, |
243 | const QDate &, const QDate &); | 246 | const QDate &, const QDate &); |
244 | bool isMonthView() { return !mShowWeekView; } | 247 | bool isMonthView() { return !mShowWeekView; } |
245 | bool isUpdatePossible() { return updatePossible; } | 248 | bool isUpdatePossible() { return updatePossible; } |
246 | 249 | ||
247 | MonthViewCell * selectedCell(); | 250 | MonthViewCell * selectedCell(); |
248 | bool skipResize; | 251 | bool skipResize; |
249 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} | 252 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} |
250 | public slots: | 253 | public slots: |
251 | virtual void updateView(); | 254 | virtual void updateView(); |
252 | virtual void updateConfig(); | 255 | virtual void updateConfig(); |
253 | virtual void showDates(const QDate &start, const QDate &end); | 256 | virtual void showDates(const QDate &start, const QDate &end); |
254 | virtual void showEvents(QPtrList<Event> eventList); | 257 | virtual void showEvents(QPtrList<Event> eventList); |
255 | 258 | ||
256 | void changeEventDisplay(Event *, int); | 259 | void changeEventDisplay(Event *, int); |
257 | 260 | ||
258 | void clearSelection(); | 261 | void clearSelection(); |
259 | 262 | ||
260 | void showContextMenu( Incidence * ); | 263 | void showContextMenu( Incidence * ); |
261 | 264 | ||
262 | void setSelectedCell( MonthViewCell * ); | 265 | void setSelectedCell( MonthViewCell * ); |
263 | void switchView(); | 266 | void switchView(); |
264 | void setKeyBoardFocus(); | 267 | void setKeyBoardFocus(); |
265 | void setKeyBFocus(); | 268 | void setKeyBFocus(); |
266 | 269 | ||
267 | protected slots: | 270 | protected slots: |
268 | void slotComputeLayout(); | 271 | void slotComputeLayout(); |
269 | void selectInternalWeekNum ( int ); | 272 | void selectInternalWeekNum ( int ); |
270 | void processSelectionChange(); | 273 | void processSelectionChange(); |
271 | signals: | 274 | signals: |
272 | void nextMonth(); | 275 | void nextMonth(); |
273 | void prevMonth(); | 276 | void prevMonth(); |
274 | void selectWeekNum ( int ); | 277 | void selectWeekNum ( int ); |
275 | void selectMonth (); | 278 | void selectMonth (); |
276 | void showDaySignal( QDate ); | 279 | void showDaySignal( QDate ); |
277 | protected: | 280 | protected: |
278 | void resizeEvent(QResizeEvent *); | 281 | void resizeEvent(QResizeEvent *); |
279 | void viewChanged(); | 282 | void viewChanged(); |
280 | void updateDayLabels(); | 283 | void updateDayLabels(); |
281 | 284 | ||
282 | private: | 285 | private: |
283 | QTimer* mComputeLayoutTimer; | 286 | QTimer* mComputeLayoutTimer; |
284 | NavigatorBar* mNavigatorBar; | 287 | NavigatorBar* mNavigatorBar; |
285 | int currentWeek(); | 288 | int currentWeek(); |
286 | bool clPending; | 289 | bool clPending; |
287 | QWidgetStack * mWidStack; | 290 | QWidgetStack * mWidStack; |
288 | QWidget* mMonthView; | 291 | QWidget* mMonthView; |
289 | QWidget* mWeekView; | 292 | QWidget* mWeekView; |
290 | bool mShowWeekView; | 293 | bool mShowWeekView; |
291 | bool updatePossible; | 294 | bool updatePossible; |
292 | int mDaysPerWeek; | 295 | int mDaysPerWeek; |
293 | int mNumWeeks; | 296 | int mNumWeeks; |
294 | int mNumCells; | 297 | int mNumCells; |
295 | //bool mWeekStartsMonday; | 298 | //bool mWeekStartsMonday; |
296 | bool mShowSatSunComp; | 299 | bool mShowSatSunComp; |
297 | void computeLayout(); | 300 | void computeLayout(); |
298 | void computeLayoutWeek(); | 301 | void computeLayoutWeek(); |
299 | 302 | ||
300 | QPtrVector<MonthViewCell> mCells; | 303 | QPtrVector<MonthViewCell> mCells; |
301 | QPtrVector<QLabel> mDayLabels; | 304 | QPtrVector<QLabel> mDayLabels; |
302 | QPtrVector<KOWeekButton> mWeekLabels; | 305 | QPtrVector<KOWeekButton> mWeekLabels; |
303 | QPtrVector<MonthViewCell> mCellsW; | 306 | QPtrVector<MonthViewCell> mCellsW; |
304 | QPtrVector<QLabel> mDayLabelsW; | 307 | QPtrVector<QLabel> mDayLabelsW; |
305 | QPtrVector<KOWeekButton> mWeekLabelsW; | 308 | QPtrVector<KOWeekButton> mWeekLabelsW; |
306 | 309 | ||
307 | bool mShortDayLabelsM; | 310 | bool mShortDayLabelsM; |
308 | bool mShortDayLabelsW; | 311 | bool mShortDayLabelsW; |
309 | int mWidthLongDayLabel; | 312 | int mWidthLongDayLabel; |
310 | 313 | ||
311 | QDate mStartDate; | 314 | QDate mStartDate; |
312 | 315 | ||
313 | MonthViewCell *mSelectedCell; | 316 | MonthViewCell *mSelectedCell; |
314 | bool mFlagKeyPressed; | 317 | bool mFlagKeyPressed; |
315 | KOEventPopupMenu *mContextMenu; | 318 | KOEventPopupMenu *mContextMenu; |
316 | void keyPressEvent ( QKeyEvent * ) ; | 319 | void keyPressEvent ( QKeyEvent * ) ; |
317 | void keyReleaseEvent ( QKeyEvent * ) ; | 320 | void keyReleaseEvent ( QKeyEvent * ) ; |
318 | 321 | ||
319 | }; | 322 | }; |
320 | 323 | ||
321 | #endif | 324 | #endif |