-rw-r--r-- | korganizer/komonthview.cpp | 116 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 |
2 files changed, 67 insertions, 54 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9f7db69..1ed288b 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1931 +1,1943 @@ | |||
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 | resetOnFocusIn = true; |
87 | setVScrollBarMode(QScrollView::AlwaysOff); | ||
88 | setHScrollBarMode(QScrollView::AlwaysOff); | ||
87 | } | 89 | } |
88 | KNoScrollListBox::~KNoScrollListBox() | 90 | KNoScrollListBox::~KNoScrollListBox() |
89 | { | 91 | { |
90 | 92 | ||
91 | } | 93 | } |
92 | 94 | ||
93 | 95 | ||
94 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 96 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
95 | { | 97 | { |
96 | QListBox::focusInEvent ( e ); | 98 | QListBox::focusInEvent ( e ); |
97 | QListBoxItem * i = item ( 0 ); | 99 | QListBoxItem * i = item ( 0 ); |
98 | if ( i && resetOnFocusIn ) { | 100 | if ( i && resetOnFocusIn ) { |
99 | setCurrentItem( i ); | 101 | setCurrentItem( i ); |
100 | setSelected ( 0, true ); | 102 | setSelected ( 0, true ); |
101 | } | 103 | } |
102 | resetOnFocusIn = true; | 104 | resetOnFocusIn = true; |
105 | |||
106 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | ||
107 | QListBoxItem *fi = firstItem (); | ||
108 | if (fi ) { | ||
109 | int ihei = fi->height( this ); | ||
110 | int hei = numRows () * ihei; | ||
111 | if ( hei < height() - horizontalScrollBar()->height () ) { | ||
112 | setVScrollBarMode(QScrollView::AlwaysOff); | ||
113 | } | ||
114 | else | ||
115 | setVScrollBarMode(QScrollView::Auto); | ||
116 | if ( ihei *3 > height() ) { | ||
117 | setHScrollBarMode(QScrollView::AlwaysOff); | ||
118 | } | ||
119 | else { | ||
120 | setHScrollBarMode(QScrollView::Auto); | ||
121 | } | ||
122 | } else { | ||
123 | setVScrollBarMode(QScrollView::Auto); | ||
124 | setHScrollBarMode(QScrollView::Auto); | ||
125 | } | ||
126 | } | ||
103 | } | 127 | } |
104 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 128 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
105 | { | 129 | { |
106 | int i = currentItem (); | 130 | int i = currentItem (); |
107 | if ( i >= 0 ) { | 131 | if ( i >= 0 ) { |
108 | setSelected ( i, false ); | 132 | setSelected ( i, false ); |
109 | } | 133 | } |
110 | QListBox::focusOutEvent ( e ); | 134 | QListBox::focusOutEvent ( e ); |
135 | setVScrollBarMode(QScrollView::AlwaysOff); | ||
136 | setHScrollBarMode(QScrollView::AlwaysOff); | ||
111 | } | 137 | } |
112 | 138 | ||
113 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 139 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
114 | { | 140 | { |
115 | QListBoxItem* item = itemAt ( p ); | 141 | QListBoxItem* item = itemAt ( p ); |
116 | if ( ! item ) { | 142 | if ( ! item ) { |
117 | return i18n("Click in the cell\nto add an event!"); | 143 | return i18n("Click in the cell\nto add an event!"); |
118 | } | 144 | } |
119 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 145 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
120 | KOPrefs::instance()->mWTshowDetails, | 146 | KOPrefs::instance()->mWTshowDetails, |
121 | KOPrefs::instance()->mWTshowCreated, | 147 | KOPrefs::instance()->mWTshowCreated, |
122 | KOPrefs::instance()->mWTshowChanged); | 148 | KOPrefs::instance()->mWTshowChanged); |
123 | } | 149 | } |
124 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 150 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
125 | { | 151 | { |
126 | //qDebug("KNoScrollListBox::keyPressEvent "); | 152 | //qDebug("KNoScrollListBox::keyPressEvent "); |
127 | switch(e->key()) { | 153 | switch(e->key()) { |
128 | case Key_Right: | 154 | case Key_Right: |
129 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 155 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
130 | { | 156 | { |
131 | e->ignore(); | 157 | e->ignore(); |
132 | return; | 158 | return; |
133 | } | 159 | } |
134 | scrollBy(10,0); | 160 | scrollBy(10,0); |
135 | break; | 161 | break; |
136 | case Key_Left: | 162 | case Key_Left: |
137 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 163 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
138 | { | 164 | { |
139 | e->ignore(); | 165 | e->ignore(); |
140 | return; | 166 | return; |
141 | } | 167 | } |
142 | scrollBy(-10,0); | 168 | scrollBy(-10,0); |
143 | break; | 169 | break; |
144 | case Key_Up: | 170 | case Key_Up: |
145 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 171 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
146 | e->ignore(); | 172 | e->ignore(); |
147 | break; | 173 | break; |
148 | } | 174 | } |
149 | if ( count() ) { | 175 | if ( count() ) { |
150 | setCurrentItem((currentItem()+count()-1)%count()); | 176 | setCurrentItem((currentItem()+count()-1)%count()); |
151 | if(!itemVisible(currentItem())) { | 177 | if(!itemVisible(currentItem())) { |
152 | if((unsigned int) currentItem() == (count()-1)) { | 178 | if((unsigned int) currentItem() == (count()-1)) { |
153 | setTopItem(currentItem()-numItemsVisible()+1); | 179 | setTopItem(currentItem()-numItemsVisible()+1); |
154 | } else { | 180 | } else { |
155 | setTopItem(topItem()-1); | 181 | setTopItem(topItem()-1); |
156 | } | 182 | } |
157 | } | 183 | } |
158 | } | 184 | } |
159 | break; | 185 | break; |
160 | case Key_Down: | 186 | case Key_Down: |
161 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 187 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
162 | e->ignore(); | 188 | e->ignore(); |
163 | break; | 189 | break; |
164 | } | 190 | } |
165 | if ( count () ) { | 191 | if ( count () ) { |
166 | setCurrentItem((currentItem()+1)%count()); | 192 | setCurrentItem((currentItem()+1)%count()); |
167 | if(!itemVisible(currentItem())) { | 193 | if(!itemVisible(currentItem())) { |
168 | if(currentItem() == 0) { | 194 | if(currentItem() == 0) { |
169 | setTopItem(0); | 195 | setTopItem(0); |
170 | } else { | 196 | } else { |
171 | setTopItem(topItem()+1); | 197 | setTopItem(topItem()+1); |
172 | } | 198 | } |
173 | } | 199 | } |
174 | } | 200 | } |
175 | break; | 201 | break; |
176 | case Key_I: | 202 | case Key_I: |
177 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 203 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
178 | e->ignore(); | 204 | e->ignore(); |
179 | break; | 205 | break; |
180 | case Key_Return: | 206 | case Key_Return: |
181 | case Key_Enter: | 207 | case Key_Enter: |
182 | { | 208 | { |
183 | if ( currentItem() >= 0 ) { | 209 | if ( currentItem() >= 0 ) { |
184 | emit doubleClicked( item( currentItem() ) ); | 210 | emit doubleClicked( item( currentItem() ) ); |
185 | e->accept(); | 211 | e->accept(); |
186 | } else { | 212 | } else { |
187 | e->ignore(); | 213 | e->ignore(); |
188 | } | 214 | } |
189 | } | 215 | } |
190 | break; | 216 | break; |
191 | case Key_Shift: | 217 | case Key_Shift: |
192 | emit shiftDown(); | 218 | emit shiftDown(); |
193 | break; | 219 | break; |
194 | default: | 220 | default: |
195 | e->ignore(); | 221 | e->ignore(); |
196 | break; | 222 | break; |
197 | } | 223 | } |
198 | } | 224 | } |
199 | 225 | ||
200 | void KNoScrollListBox::oneDown() | 226 | void KNoScrollListBox::oneDown() |
201 | { | 227 | { |
202 | if ( count () ) { | 228 | if ( count () ) { |
203 | resetOnFocusIn = false; | 229 | resetOnFocusIn = false; |
204 | setCurrentItem((currentItem()+1)%count()); | 230 | setCurrentItem((currentItem()+1)%count()); |
205 | if(!itemVisible(currentItem())) { | 231 | if(!itemVisible(currentItem())) { |
206 | if(currentItem() == 0) { | 232 | if(currentItem() == 0) { |
207 | setTopItem(0); | 233 | setTopItem(0); |
208 | } else { | 234 | } else { |
209 | setTopItem(topItem()+1); | 235 | setTopItem(topItem()+1); |
210 | } | 236 | } |
211 | } | 237 | } |
212 | } | 238 | } |
213 | } | 239 | } |
214 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 240 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
215 | { | 241 | { |
216 | switch(e->key()) { | 242 | switch(e->key()) { |
217 | case Key_Shift: | 243 | case Key_Shift: |
218 | emit shiftUp(); | 244 | emit shiftUp(); |
219 | break; | 245 | break; |
220 | default: | 246 | default: |
221 | break; | 247 | break; |
222 | } | 248 | } |
223 | } | 249 | } |
224 | 250 | ||
225 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 251 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
226 | { | 252 | { |
227 | QListBox::mousePressEvent(e); | 253 | QListBox::mousePressEvent(e); |
228 | 254 | ||
229 | if(e->button() == RightButton) { | 255 | if(e->button() == RightButton) { |
230 | emit rightClick(); | 256 | emit rightClick(); |
231 | } | 257 | } |
232 | } | 258 | } |
233 | 259 | ||
234 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 260 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
235 | : QListBoxItem() | 261 | : QListBoxItem() |
236 | { | 262 | { |
237 | mblockRepaint = true; | 263 | mblockRepaint = true; |
238 | setText( s ); | 264 | setText( s ); |
239 | mMultiday = 0; | 265 | mMultiday = 0; |
240 | mIncidence = incidence; | 266 | mIncidence = incidence; |
241 | mDate = qd; | 267 | mDate = qd; |
242 | mRecur = false; | 268 | mRecur = false; |
243 | mAlarm = false; | 269 | mAlarm = false; |
244 | mReply = false; | 270 | mReply = false; |
245 | mInfo = false; | 271 | mInfo = false; |
272 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | ||
246 | //qDebug("NEWWWWWWWWWWWWW "); | 273 | //qDebug("NEWWWWWWWWWWWWW "); |
247 | } | 274 | } |
248 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 275 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
249 | { | 276 | { |
250 | setText( s ); | 277 | setText( s ); |
251 | mMultiday = 0; | 278 | mMultiday = 0; |
252 | mIncidence = incidence; | 279 | mIncidence = incidence; |
253 | mDate = qd; | 280 | mDate = qd; |
254 | mRecur = false; | 281 | mRecur = false; |
255 | mAlarm = false; | 282 | mAlarm = false; |
256 | mReply = false; | 283 | mReply = false; |
257 | mInfo = false; | 284 | mInfo = false; |
258 | //qDebug("recucleeeeeeeeeeeeeeeee "); | 285 | //qDebug("recucleeeeeeeeeeeeeeeee "); |
259 | } | 286 | } |
260 | 287 | ||
261 | void MonthViewItem::paint(QPainter *p) | 288 | void MonthViewItem::paint(QPainter *p) |
262 | { | 289 | { |
263 | if ( mblockRepaint ) { | 290 | if ( mblockRepaint ) { |
264 | //qDebug("block "); | 291 | //qDebug("block "); |
265 | return; | 292 | return; |
266 | } | 293 | } |
267 | //qDebug("NON block "); | 294 | //qDebug("NON block "); |
268 | #if QT_VERSION >= 0x030000 | 295 | #if QT_VERSION >= 0x030000 |
269 | bool sel = isSelected(); | 296 | bool sel = isSelected(); |
270 | #else | 297 | #else |
271 | bool sel = selected(); | 298 | bool sel = selected(); |
272 | #endif | 299 | #endif |
273 | 300 | ||
274 | 301 | ||
275 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 302 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
276 | { | 303 | { |
277 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 304 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
278 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 305 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
279 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 306 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
280 | } | 307 | } |
281 | int x = 1; | 308 | int x = 1; |
282 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 309 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
283 | int size = PIXMAP_SIZE; | 310 | int size = PIXMAP_SIZE; |
284 | if ( QApplication::desktop()->width() < 300 ) | 311 | if ( QApplication::desktop()->width() < 300 ) |
285 | size = 3; | 312 | size = 3; |
286 | int heihei = height( listBox () ); | 313 | int heihei = height( listBox () ); |
287 | int y = (heihei - size -1 ) /2; | 314 | int y = (heihei - size -1 ) /2; |
288 | 315 | ||
289 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 316 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
290 | if ( mInfo ) { | 317 | if ( mInfo ) { |
291 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 318 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
292 | x += size + 1; | 319 | x += size + 1; |
293 | } | 320 | } |
294 | if ( mRecur ) { | 321 | if ( mRecur ) { |
295 | p->fillRect ( x, y,size,size, Qt::blue ); | 322 | p->fillRect ( x, y,size,size, Qt::blue ); |
296 | x += size + 1; | 323 | x += size + 1; |
297 | } | 324 | } |
298 | if ( mAlarm ) { | 325 | if ( mAlarm ) { |
299 | p->fillRect ( x, y,size,size, Qt::red ); | 326 | p->fillRect ( x, y,size,size, Qt::red ); |
300 | x += size + 1; | 327 | x += size + 1; |
301 | } | 328 | } |
302 | if ( mReply ) { | 329 | if ( mReply ) { |
303 | p->fillRect ( x, y,size,size, Qt::yellow ); | 330 | p->fillRect ( x, y,size,size, Qt::yellow ); |
304 | x += size + 1; | 331 | x += size + 1; |
305 | } | 332 | } |
306 | } | 333 | } |
307 | if ( mMultiday ) { | 334 | if ( mMultiday ) { |
308 | int yyy = y+(size/2); | 335 | int yyy = y+(size/2); |
309 | int sizeM = size+2; | 336 | int sizeM = size+2; |
310 | p->setBrush( QBrush::SolidPattern ); | 337 | p->setBrush( QBrush::SolidPattern ); |
311 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 338 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
312 | if ( mMultiday == 2 || mMultiday == 3 ) { | 339 | if ( mMultiday == 2 || mMultiday == 3 ) { |
313 | QPointArray pa ( 3 ); | 340 | QPointArray pa ( 3 ); |
314 | pa.setPoint (0, x, yyy ); | 341 | pa.setPoint (0, x, yyy ); |
315 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 342 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
316 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 343 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
317 | p->drawPolygon( pa ); | 344 | p->drawPolygon( pa ); |
318 | } | 345 | } |
319 | if ( mMultiday == 2 || mMultiday == 1 ) { | 346 | if ( mMultiday == 2 || mMultiday == 1 ) { |
320 | QPointArray pa ( 3 ); | 347 | QPointArray pa ( 3 ); |
321 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 348 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
322 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 349 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
323 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 350 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
324 | p->drawPolygon( pa ); | 351 | p->drawPolygon( pa ); |
325 | } | 352 | } |
326 | if ( mMultiday == 1 ) { | 353 | if ( mMultiday == 1 ) { |
327 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 354 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
328 | 355 | ||
329 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 356 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
330 | } | 357 | } |
331 | if ( mMultiday == 3 ) { | 358 | if ( mMultiday == 3 ) { |
332 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 359 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
333 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 360 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
334 | 361 | ||
335 | } | 362 | } |
336 | x += sizeM/2 + 1; | 363 | x += sizeM/2 + 1; |
337 | x += sizeM + 1; | 364 | x += sizeM + 1; |
338 | } | 365 | } |
339 | 366 | ||
340 | if ( mIncidence->type() == "Todo" ){ | 367 | if ( mIncidence->type() == "Todo" ){ |
341 | Todo* td = ( Todo* ) mIncidence; | 368 | Todo* td = ( Todo* ) mIncidence; |
342 | if ( td->isCompleted() ) { | 369 | if ( td->isCompleted() ) { |
343 | int half = size/2; | 370 | int half = size/2; |
344 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 371 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
345 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 372 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
346 | x += half+half + 4; | 373 | x += half+half + 4; |
347 | 374 | ||
348 | } else { | 375 | } else { |
349 | int val = td->percentComplete()/20; | 376 | int val = td->percentComplete()/20; |
350 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); | 377 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); |
351 | p->drawRect ( x, y-2,7,size+4); | 378 | p->drawRect ( x, y-2,7,size+4); |
352 | x += size + 3; | 379 | x += size + 3; |
353 | } | 380 | } |
354 | } | 381 | } |
355 | QFontMetrics fm = p->fontMetrics(); | 382 | QFontMetrics fm = p->fontMetrics(); |
356 | int yPos; | 383 | int yPos; |
357 | int pmheight = size; | 384 | int pmheight = size; |
358 | if( pmheight < fm.height() ) | 385 | if( pmheight < fm.height() ) |
359 | yPos = fm.ascent() + fm.leading()/2; | 386 | yPos = fm.ascent() + fm.leading()/2; |
360 | else | 387 | else |
361 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 388 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
362 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 389 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
363 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 390 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
364 | p->drawText( x, yPos, text() ); | 391 | p->drawText( x, yPos, text() ); |
365 | if ( mIncidence->cancelled() ) { | 392 | if ( mIncidence->cancelled() ) { |
366 | int wid = fm.width( text() ); | 393 | int wid = fm.width( text() ); |
367 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); | 394 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); |
368 | } | 395 | } |
369 | 396 | ||
370 | } | 397 | } |
371 | 398 | ||
372 | int MonthViewItem::height(const QListBox *lb) const | 399 | int MonthViewItem::height(const QListBox *lb) const |
373 | { | 400 | { |
374 | int ret = 10; | 401 | int ret = 10; |
375 | if ( lb ) | 402 | if ( lb ) |
376 | ret = lb->fontMetrics().lineSpacing()+1; | 403 | ret = lb->fontMetrics().lineSpacing()+1; |
377 | return ret; | 404 | return ret; |
378 | } | 405 | } |
379 | 406 | ||
380 | int MonthViewItem::width(const QListBox *lb) const | 407 | int MonthViewItem::width(const QListBox *lb) const |
381 | { | 408 | { |
382 | 409 | ||
383 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 410 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
384 | int size = PIXMAP_SIZE; | 411 | int size = PIXMAP_SIZE; |
385 | if ( QApplication::desktop()->width() < 300 ) | 412 | if ( QApplication::desktop()->width() < 300 ) |
386 | size = 3; | 413 | size = 3; |
387 | int x = 1; | 414 | int x = 1; |
388 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 415 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
389 | if ( mInfo ) { | 416 | if ( mInfo ) { |
390 | x += size + 1; | 417 | x += size + 1; |
391 | } | 418 | } |
392 | if( mRecur ) { | 419 | if( mRecur ) { |
393 | x += size+1; | 420 | x += size+1; |
394 | } | 421 | } |
395 | if( mAlarm ) { | 422 | if( mAlarm ) { |
396 | x += size+1; | 423 | x += size+1; |
397 | } | 424 | } |
398 | if( mReply ) { | 425 | if( mReply ) { |
399 | x += size+1; | 426 | x += size+1; |
400 | } | 427 | } |
401 | } | 428 | } |
402 | if( mMultiday ) { | 429 | if( mMultiday ) { |
403 | x += size+1+2+size/2; | 430 | x += size+1+2+size/2; |
404 | } | 431 | } |
405 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 432 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
406 | } | 433 | } |
407 | if ( ! lb ) | 434 | if ( ! lb ) |
408 | return 10; | 435 | return 10; |
409 | //qDebug("ret wid %d ", lb->width()); | 436 | //qDebug("ret wid %d ", lb->width()); |
410 | return lb->width(); | 437 | return lb->width(); |
411 | } | 438 | } |
412 | 439 | ||
413 | 440 | ||
414 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 441 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
415 | : KNoScrollListBox( par ), | 442 | : KNoScrollListBox( par ), |
416 | mMonthView( parent ) | 443 | mMonthView( parent ) |
417 | { | 444 | { |
418 | |||
419 | mCurrentAvailItem = 0; | ||
420 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 445 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
421 | currentPalette = 0; | 446 | currentPalette = 0; |
422 | // mLabel = new QLabel( this );QPushButton | 447 | // mLabel = new QLabel( this );QPushButton |
423 | mLabel = new QPushButton( this ); | 448 | mLabel = new QPushButton( this ); |
424 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 449 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
425 | //mLabel->setLineWidth( 1 ); | 450 | //mLabel->setLineWidth( 1 ); |
426 | //mLabel->setAlignment( AlignCenter ); | 451 | //mLabel->setAlignment( AlignCenter ); |
427 | mLabel->setFlat( true ); | 452 | mLabel->setFlat( true ); |
428 | mLabel->setFocusPolicy(NoFocus); | 453 | mLabel->setFocusPolicy(NoFocus); |
429 | //mItemList = new KNoScrollListBox( this ); | 454 | //mItemList = new KNoScrollListBox( this ); |
430 | setMinimumSize( 10, 10 ); | 455 | setMinimumSize( 10, 10 ); |
431 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 456 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
432 | setLineWidth( 1 ); | 457 | setLineWidth( 1 ); |
433 | //topLayout->addWidget( mItemList ); | 458 | //topLayout->addWidget( mItemList ); |
434 | mLabel->raise(); | 459 | mLabel->raise(); |
435 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 460 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
436 | mStandardPalette = palette(); | 461 | mStandardPalette = palette(); |
437 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 462 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
438 | 463 | ||
439 | enableScrollBars( false ); | 464 | enableScrollBars( false ); |
440 | updateConfig(); | 465 | updateConfig(); |
441 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 466 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
442 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 467 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
443 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 468 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
444 | SLOT( defaultAction( QListBoxItem * ) ) ); | 469 | SLOT( defaultAction( QListBoxItem * ) ) ); |
445 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 470 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
446 | const QPoint &) ), | 471 | const QPoint &) ), |
447 | SLOT( contextMenu( QListBoxItem * ) ) ); | 472 | SLOT( contextMenu( QListBoxItem * ) ) ); |
448 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 473 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
449 | SLOT( selection( QListBoxItem * ) ) ); | 474 | SLOT( selection( QListBoxItem * ) ) ); |
450 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 475 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
451 | SLOT( cellClicked( QListBoxItem * ) ) ); | 476 | SLOT( cellClicked( QListBoxItem * ) ) ); |
452 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 477 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
453 | SLOT( selection( QListBoxItem * ) ) ); | 478 | SLOT( selection( QListBoxItem * ) ) ); |
454 | } | 479 | } |
455 | #ifdef DESKTOP_VERSION | 480 | #ifdef DESKTOP_VERSION |
456 | QToolTipGroup *MonthViewCell::toolTipGroup() | 481 | QToolTipGroup *MonthViewCell::toolTipGroup() |
457 | { | 482 | { |
458 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 483 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
459 | return mToolTipGroup; | 484 | return mToolTipGroup; |
460 | } | 485 | } |
461 | #endif | 486 | #endif |
462 | 487 | ||
463 | void MonthViewCell::setDate( const QDate &date ) | 488 | void MonthViewCell::setDate( const QDate &date ) |
464 | { | 489 | { |
465 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 490 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
466 | mDate = date; | 491 | mDate = date; |
467 | 492 | ||
468 | 493 | ||
469 | 494 | ||
470 | //resizeEvent( 0 ); | 495 | //resizeEvent( 0 ); |
471 | } | 496 | } |
472 | 497 | ||
473 | QDate MonthViewCell::date() const | 498 | QDate MonthViewCell::date() const |
474 | { | 499 | { |
475 | return mDate; | 500 | return mDate; |
476 | } | 501 | } |
477 | 502 | ||
478 | void MonthViewCell::setPrimary( bool primary ) | 503 | void MonthViewCell::setPrimary( bool primary ) |
479 | { | 504 | { |
480 | mPrimary = primary; | 505 | mPrimary = primary; |
481 | //setMyPalette(); | 506 | //setMyPalette(); |
482 | } | 507 | } |
483 | void MonthViewCell::setMyPalette() | 508 | void MonthViewCell::setMyPalette() |
484 | { | 509 | { |
485 | 510 | ||
486 | if ( mHoliday) { | 511 | if ( mHoliday) { |
487 | if ( currentPalette == 1 ) return; | 512 | if ( currentPalette == 1 ) return; |
488 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 513 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
489 | setPalette( mHolidayPalette ); | 514 | setPalette( mHolidayPalette ); |
490 | //mLabel->setPalette( mHolidayPalette ); | 515 | //mLabel->setPalette( mHolidayPalette ); |
491 | currentPalette = 1; | 516 | currentPalette = 1; |
492 | 517 | ||
493 | } else { | 518 | } else { |
494 | if ( mPrimary ) { | 519 | if ( mPrimary ) { |
495 | if ( currentPalette == 2 ) return; | 520 | if ( currentPalette == 2 ) return; |
496 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 521 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
497 | //mLabel->setPalette( mPrimaryPalette ); | 522 | //mLabel->setPalette( mPrimaryPalette ); |
498 | setPalette( mPrimaryPalette ); | 523 | setPalette( mPrimaryPalette ); |
499 | currentPalette = 2; | 524 | currentPalette = 2; |
500 | 525 | ||
501 | } else { | 526 | } else { |
502 | if ( currentPalette == 3 ) return; | 527 | if ( currentPalette == 3 ) return; |
503 | setPalette( mNonPrimaryPalette ); | 528 | setPalette( mNonPrimaryPalette ); |
504 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 529 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
505 | //mLabel->setPalette( mNonPrimaryPalette );; | 530 | //mLabel->setPalette( mNonPrimaryPalette );; |
506 | currentPalette = 3; | 531 | currentPalette = 3; |
507 | } | 532 | } |
508 | } | 533 | } |
509 | //QPalette pal = palette(); | 534 | //QPalette pal = palette(); |
510 | 535 | ||
511 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 536 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
512 | } | 537 | } |
513 | QPalette MonthViewCell::getPalette () | 538 | QPalette MonthViewCell::getPalette () |
514 | { | 539 | { |
515 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 540 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
516 | return mStandardPalette; | 541 | return mStandardPalette; |
517 | if ( mHoliday) { | 542 | if ( mHoliday) { |
518 | return mHolidayPalette ; | 543 | return mHolidayPalette ; |
519 | } else { | 544 | } else { |
520 | if ( mPrimary ) { | 545 | if ( mPrimary ) { |
521 | return mPrimaryPalette ; | 546 | return mPrimaryPalette ; |
522 | } | 547 | } |
523 | } | 548 | } |
524 | return mNonPrimaryPalette; | 549 | return mNonPrimaryPalette; |
525 | } | 550 | } |
526 | bool MonthViewCell::isPrimary() const | 551 | bool MonthViewCell::isPrimary() const |
527 | { | 552 | { |
528 | return mPrimary; | 553 | return mPrimary; |
529 | } | 554 | } |
530 | 555 | ||
531 | void MonthViewCell::setHoliday( bool holiday ) | 556 | void MonthViewCell::setHoliday( bool holiday ) |
532 | { | 557 | { |
533 | mHoliday = holiday; | 558 | mHoliday = holiday; |
534 | //setMyPalette(); | 559 | //setMyPalette(); |
535 | } | 560 | } |
536 | 561 | ||
537 | void MonthViewCell::setHoliday( const QString &holiday ) | 562 | void MonthViewCell::setHoliday( const QString &holiday ) |
538 | { | 563 | { |
539 | mHolidayString = holiday; | 564 | mHolidayString = holiday; |
540 | 565 | ||
541 | if ( !holiday.isEmpty() ) { | 566 | if ( !holiday.isEmpty() ) { |
542 | setHoliday( true ); | 567 | setHoliday( true ); |
543 | } | 568 | } |
544 | } | 569 | } |
545 | 570 | ||
546 | void MonthViewCell::startUpdateCell() | 571 | void MonthViewCell::startUpdateCell() |
547 | { | 572 | { |
548 | 573 | ||
549 | setFocusPolicy(NoFocus); | 574 | setFocusPolicy(NoFocus); |
550 | if ( !mMonthView->isUpdatePossible() ) | 575 | if ( !mMonthView->isUpdatePossible() ) |
551 | return; | 576 | return; |
552 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 577 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
553 | while ( mitem ) { | 578 | while ( mitem ) { |
554 | mitem->setBlockRepaint( true ); | 579 | mitem->setBlockRepaint( true ); |
555 | mitem = (MonthViewItem *)mitem->next(); | 580 | mitem = (MonthViewItem *)mitem->next(); |
556 | } | 581 | } |
557 | if ( mAvailItemList.count() > 20 ) { | 582 | if ( mAvailItemList.count() > 20 ) { |
558 | mAvailItemList.setAutoDelete( true ); | 583 | mAvailItemList.setAutoDelete( true ); |
559 | mAvailItemList.clear(); | 584 | mAvailItemList.clear(); |
560 | mAvailItemList.setAutoDelete( false ); | 585 | mAvailItemList.setAutoDelete( false ); |
561 | } | 586 | } |
562 | /* | 587 | /* |
563 | if ( !isVisible() ){ | 588 | if ( !isVisible() ){ |
564 | return; | 589 | return; |
565 | } | 590 | } |
566 | */ | 591 | */ |
567 | // qDebug("MonthViewCell::updateCell() "); | 592 | // qDebug("MonthViewCell::updateCell() "); |
568 | setPrimary( mDate.month()%2 ); | 593 | setPrimary( mDate.month()%2 ); |
569 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 594 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
570 | if ( mDate == QDate::currentDate() ) { | 595 | if ( mDate == QDate::currentDate() ) { |
571 | setLineWidth( 3 ); | 596 | setLineWidth( 3 ); |
572 | } else { | 597 | } else { |
573 | setLineWidth( 1 ); | 598 | setLineWidth( 1 ); |
574 | } | 599 | } |
575 | mCurrentAvailItem = (MonthViewItem*) firstItem (); | 600 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
576 | //clear(); | 601 | //clear(); |
602 | while ( CurrentAvailItem ) { | ||
603 | MonthViewItem *item = CurrentAvailItem; | ||
604 | CurrentAvailItem = (MonthViewItem *)item->next(); | ||
605 | mAvailItemList.append( item ); | ||
606 | takeItem ( item ); | ||
607 | } | ||
577 | 608 | ||
578 | #ifdef DESKTOP_VERSION | 609 | #ifdef DESKTOP_VERSION |
579 | QToolTip::remove(this); | 610 | QToolTip::remove(this); |
580 | #endif | 611 | #endif |
581 | mToolTip.clear(); | 612 | mToolTip.clear(); |
582 | //qApp->processEvents(); | 613 | //qApp->processEvents(); |
583 | #if 0 | 614 | #if 0 |
584 | if ( !mHolidayString.isEmpty() ) { | 615 | if ( !mHolidayString.isEmpty() ) { |
585 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 616 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
586 | item->setPalette( mHolidayPalette ); | 617 | item->setPalette( mHolidayPalette ); |
587 | insertItem( item ); | 618 | insertItem( item ); |
588 | mToolTip.append ( mHolidayString ); | 619 | mToolTip.append ( mHolidayString ); |
589 | } | 620 | } |
590 | #endif | 621 | #endif |
591 | } | 622 | } |
592 | 623 | ||
593 | void MonthViewCell::insertEvent(Event *event) | 624 | void MonthViewCell::insertEvent(Event *event) |
594 | { | 625 | { |
595 | QString mToolTipText; | 626 | QString mToolTipText; |
596 | bool insertNewItem = false; | ||
597 | setFocusPolicy(WheelFocus); | 627 | setFocusPolicy(WheelFocus); |
598 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 628 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
599 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 629 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
600 | return; | 630 | return; |
601 | else | 631 | else |
602 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 632 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
603 | return; | 633 | return; |
604 | } | 634 | } |
605 | 635 | ||
606 | if ( event->isHoliday()) { | 636 | if ( event->isHoliday()) { |
607 | setHoliday( true ); | 637 | setHoliday( true ); |
608 | if ( mDate.dayOfWeek() == 7 ) | 638 | if ( mDate.dayOfWeek() == 7 ) |
609 | setLineWidth( 3 ); | 639 | setLineWidth( 3 ); |
610 | } | 640 | } |
611 | QString text; | 641 | QString text; |
612 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 642 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
613 | if (event->isMultiDay()) { | 643 | if (event->isMultiDay()) { |
614 | QString prefix = "<->";multiday = 2; | 644 | QString prefix = "<->";multiday = 2; |
615 | QString time; | 645 | QString time; |
616 | if ( event->doesRecur() ) { | 646 | if ( event->doesRecur() ) { |
617 | if ( event->recursOn( mDate) ) { | 647 | if ( event->recursOn( mDate) ) { |
618 | prefix ="->" ;multiday = 1; | 648 | prefix ="->" ;multiday = 1; |
619 | } | 649 | } |
620 | else { | 650 | else { |
621 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 651 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
622 | if ( event->recursOn( mDate.addDays( -days)) ) { | 652 | if ( event->recursOn( mDate.addDays( -days)) ) { |
623 | prefix ="<-" ;multiday = 3; | 653 | prefix ="<-" ;multiday = 3; |
624 | } | 654 | } |
625 | } | 655 | } |
626 | 656 | ||
627 | } else { | 657 | } else { |
628 | if (mDate == event->dtStart().date()) { | 658 | if (mDate == event->dtStart().date()) { |
629 | prefix ="->" ;multiday = 1; | 659 | prefix ="->" ;multiday = 1; |
630 | } else if (mDate == event->dtEnd().date()) { | 660 | } else if (mDate == event->dtEnd().date()) { |
631 | prefix ="<-" ;multiday = 3; | 661 | prefix ="<-" ;multiday = 3; |
632 | } | 662 | } |
633 | } | 663 | } |
634 | if ( !event->doesFloat() ) { | 664 | if ( !event->doesFloat() ) { |
635 | if ( mDate == event->dtStart().date () ) | 665 | if ( mDate == event->dtStart().date () ) |
636 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 666 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
637 | else if ( mDate == event->dtEnd().date () ) | 667 | else if ( mDate == event->dtEnd().date () ) |
638 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 668 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
639 | 669 | ||
640 | } | 670 | } |
641 | text = time + event->summary(); | 671 | text = time + event->summary(); |
642 | mToolTipText += prefix + text; | 672 | mToolTipText += prefix + text; |
643 | } else { | 673 | } else { |
644 | if (event->doesFloat()) { | 674 | if (event->doesFloat()) { |
645 | text = event->summary(); | 675 | text = event->summary(); |
646 | mToolTipText += text; | 676 | mToolTipText += text; |
647 | } | 677 | } |
648 | else { | 678 | else { |
649 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 679 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
650 | text += " " + event->summary(); | 680 | text += " " + event->summary(); |
651 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 681 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
652 | } | 682 | } |
653 | } | 683 | } |
654 | MonthViewItem *item ; | 684 | MonthViewItem *item ; |
655 | if ( mCurrentAvailItem ) { | 685 | |
656 | item = mCurrentAvailItem; | 686 | if ( mAvailItemList.count() ) { |
657 | mCurrentAvailItem = (MonthViewItem*) item->next(); | 687 | item = mAvailItemList.first(); |
688 | mAvailItemList.remove( item ); | ||
658 | item->recycle( event, mDate, text ); | 689 | item->recycle( event, mDate, text ); |
659 | } else { | 690 | } else { |
660 | if ( mAvailItemList.count() ) { | 691 | item = new MonthViewItem( event, mDate, text ); |
661 | item = mAvailItemList.first(); | ||
662 | mAvailItemList.remove( item ); | ||
663 | item->recycle( event, mDate, text ); | ||
664 | insertNewItem = true; | ||
665 | } else { | ||
666 | insertNewItem = true; | ||
667 | item = new MonthViewItem( event, mDate, text ); | ||
668 | } | ||
669 | } | 692 | } |
693 | |||
670 | QPalette pal; | 694 | QPalette pal; |
671 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 695 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
672 | QStringList categories = event->categories(); | 696 | QStringList categories = event->categories(); |
673 | QString cat = categories.first(); | 697 | QString cat = categories.first(); |
674 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 698 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
675 | pal = getPalette(); | 699 | pal = getPalette(); |
676 | if (cat.isEmpty()) { | 700 | if (cat.isEmpty()) { |
677 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 701 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
678 | } else { | 702 | } else { |
679 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 703 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
680 | } | 704 | } |
681 | 705 | ||
682 | } else { | 706 | } else { |
683 | if (cat.isEmpty()) { | 707 | if (cat.isEmpty()) { |
684 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 708 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
685 | } else { | 709 | } else { |
686 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 710 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
687 | } | 711 | } |
688 | } | 712 | } |
689 | 713 | ||
690 | } else { | 714 | } else { |
691 | pal = mStandardPalette ; | 715 | pal = mStandardPalette ; |
692 | } | 716 | } |
693 | item->setPalette( pal ); | 717 | item->setPalette( pal ); |
694 | item->setRecur( event->recurrence()->doesRecur() ); | 718 | item->setRecur( event->recurrence()->doesRecur() ); |
695 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 719 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
696 | item->setMoreInfo( event->description().length() > 0 ); | 720 | item->setMoreInfo( event->description().length() > 0 ); |
697 | #ifdef DESKTOP_VERSION | 721 | #ifdef DESKTOP_VERSION |
698 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 722 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
699 | KOPrefs::instance()->email()); | 723 | KOPrefs::instance()->email()); |
700 | if ( me != 0 ) { | 724 | if ( me != 0 ) { |
701 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 725 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
702 | item->setReply(true && multiday < 2); | 726 | item->setReply(true && multiday < 2); |
703 | else | 727 | else |
704 | item->setReply(false); | 728 | item->setReply(false); |
705 | } else | 729 | } else |
706 | item->setReply(false); | 730 | item->setReply(false); |
707 | #endif | 731 | #endif |
708 | item->setMultiDay( multiday ); | 732 | item->setMultiDay( multiday ); |
709 | if ( insertNewItem) | 733 | insertItem( item ); |
710 | insertItem( item ); | ||
711 | mToolTip.append( mToolTipText ); | 734 | mToolTip.append( mToolTipText ); |
712 | } | 735 | } |
713 | void MonthViewCell::insertTodo(Todo *todo) | 736 | void MonthViewCell::insertTodo(Todo *todo) |
714 | { | 737 | { |
715 | bool insertNewItem = false; | ||
716 | setFocusPolicy(WheelFocus); | 738 | setFocusPolicy(WheelFocus); |
717 | QString text; | 739 | QString text; |
718 | if (todo->hasDueDate()) { | 740 | if (todo->hasDueDate()) { |
719 | if (!todo->doesFloat()) { | 741 | if (!todo->doesFloat()) { |
720 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 742 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
721 | text += " "; | 743 | text += " "; |
722 | } | 744 | } |
723 | } | 745 | } |
724 | text += todo->summary(); | 746 | text += todo->summary(); |
725 | MonthViewItem *item ; | 747 | MonthViewItem *item ; |
726 | if ( mCurrentAvailItem ) { | 748 | if ( mAvailItemList.count() ) { |
727 | item = mCurrentAvailItem; | 749 | item = mAvailItemList.first(); |
728 | mCurrentAvailItem = (MonthViewItem*) item->next(); | 750 | mAvailItemList.remove( item ); |
729 | item->recycle( todo, mDate, text ); | 751 | item->recycle( todo, mDate, text ); |
730 | } else { | 752 | } else { |
731 | if ( mAvailItemList.count() ) { | 753 | item = new MonthViewItem( todo, mDate, text ); |
732 | item = mAvailItemList.first(); | ||
733 | mAvailItemList.remove( item ); | ||
734 | item->recycle( todo, mDate, text ); | ||
735 | insertNewItem = true; | ||
736 | } else { | ||
737 | insertNewItem = true; | ||
738 | item = new MonthViewItem( todo, mDate, text ); | ||
739 | } | ||
740 | } | 754 | } |
741 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 755 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
742 | //item->setPalette( mStandardPalette ); | 756 | //item->setPalette( mStandardPalette ); |
743 | QPalette pal; | 757 | QPalette pal; |
744 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 758 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
745 | QStringList categories = todo->categories(); | 759 | QStringList categories = todo->categories(); |
746 | QString cat = categories.first(); | 760 | QString cat = categories.first(); |
747 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 761 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
748 | pal = getPalette(); | 762 | pal = getPalette(); |
749 | if (cat.isEmpty()) { | 763 | if (cat.isEmpty()) { |
750 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 764 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
751 | } else { | 765 | } else { |
752 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 766 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
753 | } | 767 | } |
754 | 768 | ||
755 | } else { | 769 | } else { |
756 | if (cat.isEmpty()) { | 770 | if (cat.isEmpty()) { |
757 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 771 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
758 | } else { | 772 | } else { |
759 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 773 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
760 | } | 774 | } |
761 | } | 775 | } |
762 | 776 | ||
763 | } else { | 777 | } else { |
764 | pal = mStandardPalette ; | 778 | pal = mStandardPalette ; |
765 | } | 779 | } |
766 | item->setPalette( pal ); | 780 | item->setPalette( pal ); |
767 | item->setRecur( todo->recurrence()->doesRecur() ); | 781 | item->setRecur( todo->recurrence()->doesRecur() ); |
768 | item->setAlarm( todo->isAlarmEnabled() ); | 782 | item->setAlarm( todo->isAlarmEnabled() ); |
769 | item->setMoreInfo( todo->description().length() > 0 ); | 783 | item->setMoreInfo( todo->description().length() > 0 ); |
770 | if ( insertNewItem) | 784 | insertItem( item ); |
771 | insertItem( item ); | ||
772 | mToolTip.append( text ); | 785 | mToolTip.append( text ); |
773 | } | 786 | } |
774 | void MonthViewCell::repaintfinishUpdateCell() | 787 | void MonthViewCell::repaintfinishUpdateCell() |
775 | { | 788 | { |
776 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 789 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
777 | while ( mitem ) { | 790 | while ( mitem ) { |
778 | mitem->setBlockRepaint( false ); | 791 | mitem->setBlockRepaint( false ); |
779 | updateItem ( mitem ); | 792 | updateItem ( mitem ); |
780 | mitem = (MonthViewItem *)mitem->next(); | 793 | mitem = (MonthViewItem *)mitem->next(); |
781 | } | 794 | } |
782 | } | 795 | } |
783 | void MonthViewCell::finishUpdateCell() | 796 | void MonthViewCell::finishUpdateCell() |
784 | { | 797 | { |
785 | while ( mCurrentAvailItem ) { | 798 | |
786 | MonthViewItem *item = mCurrentAvailItem; | ||
787 | mCurrentAvailItem = (MonthViewItem *)item->next(); | ||
788 | mAvailItemList.append( item ); | ||
789 | takeItem ( item ); | ||
790 | } | ||
791 | 799 | ||
792 | 800 | ||
793 | #ifdef DESKTOP_VERSION | 801 | #ifdef DESKTOP_VERSION |
794 | if (mToolTip.count() > 0 ) { | 802 | if (mToolTip.count() > 0 ) { |
795 | mToolTip.sort(); | 803 | mToolTip.sort(); |
796 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 804 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
797 | } | 805 | } |
798 | #endif | 806 | #endif |
799 | sort(); | 807 | sort(); |
800 | //setMyPalette(); | 808 | //setMyPalette(); |
801 | setMyPalette(); | 809 | setMyPalette(); |
802 | 810 | ||
803 | resizeEvent( 0 ); | 811 | resizeEvent( 0 ); |
804 | 812 | ||
805 | } | 813 | } |
806 | void MonthViewCell::updateCell() | 814 | void MonthViewCell::updateCell() |
807 | { | 815 | { |
808 | //qDebug("MonthViewCell::updateCell() "); | 816 | //qDebug("MonthViewCell::updateCell() "); |
809 | if ( !mMonthView->isUpdatePossible() ) | 817 | if ( !mMonthView->isUpdatePossible() ) |
810 | return; | 818 | return; |
811 | startUpdateCell(); | 819 | startUpdateCell(); |
812 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 820 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
813 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 821 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
814 | Event *event; | 822 | Event *event; |
815 | for( event = events.first(); event; event = events.next() ) { // for event | 823 | for( event = events.first(); event; event = events.next() ) { // for event |
816 | insertEvent(event); | 824 | insertEvent(event); |
817 | } | 825 | } |
818 | // insert due todos | 826 | // insert due todos |
819 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 827 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
820 | Todo *todo; | 828 | Todo *todo; |
821 | for(todo = todos.first(); todo; todo = todos.next()) { | 829 | for(todo = todos.first(); todo; todo = todos.next()) { |
822 | insertTodo( todo ); | 830 | insertTodo( todo ); |
823 | } | 831 | } |
824 | finishUpdateCell(); | 832 | finishUpdateCell(); |
825 | // if ( isVisible()) | 833 | // if ( isVisible()) |
826 | //qApp->processEvents(); | 834 | //qApp->processEvents(); |
827 | } | 835 | } |
828 | 836 | ||
829 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 837 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
830 | { | 838 | { |
831 | 839 | ||
832 | if ( bigFont ) { | 840 | if ( bigFont ) { |
833 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 841 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
834 | int ps = fo.pointSize() + 2; | 842 | int ps = fo.pointSize() + 2; |
835 | if ( ps < 18 ) | 843 | if ( ps < 18 ) |
836 | ps += 2; | 844 | ps += 2; |
837 | fo.setPointSize( ps ); | 845 | fo.setPointSize( ps ); |
838 | setFont( fo ); | 846 | setFont( fo ); |
839 | } else | 847 | } else |
840 | setFont( KOPrefs::instance()->mMonthViewFont ); | 848 | setFont( KOPrefs::instance()->mMonthViewFont ); |
841 | 849 | ||
842 | QFontMetrics fm( font() ); | 850 | QFontMetrics fm( font() ); |
843 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 851 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
844 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 852 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
845 | mHolidayPalette = mStandardPalette; | 853 | mHolidayPalette = mStandardPalette; |
846 | mPrimaryPalette = mStandardPalette; | 854 | mPrimaryPalette = mStandardPalette; |
847 | mNonPrimaryPalette = mStandardPalette; | 855 | mNonPrimaryPalette = mStandardPalette; |
848 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 856 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
849 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 857 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
850 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 858 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
851 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 859 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
852 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 860 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
853 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 861 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
854 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 862 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
855 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 863 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
856 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 864 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
857 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 865 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
858 | } | 866 | } |
859 | //updateCell(); | 867 | //updateCell(); |
860 | } | 868 | } |
861 | 869 | ||
862 | void MonthViewCell::enableScrollBars( bool enabled ) | 870 | void MonthViewCell::enableScrollBars( bool enabled ) |
863 | { | 871 | { |
872 | |||
873 | return; | ||
864 | if ( enabled ) { | 874 | if ( enabled ) { |
865 | QListBoxItem *fi = firstItem (); | 875 | QListBoxItem *fi = firstItem (); |
866 | if (fi ) { | 876 | if (fi ) { |
867 | int ihei = fi->height( this ); | 877 | int ihei = fi->height( this ); |
868 | int hei = numRows () * ihei; | 878 | int hei = numRows () * ihei; |
869 | if ( hei < height() - horizontalScrollBar()->height () ) { | 879 | if ( hei < height() - horizontalScrollBar()->height () ) { |
870 | setVScrollBarMode(QScrollView::AlwaysOff); | 880 | setVScrollBarMode(QScrollView::AlwaysOff); |
871 | } | 881 | } |
872 | else | 882 | else |
873 | setVScrollBarMode(QScrollView::Auto); | 883 | setVScrollBarMode(QScrollView::Auto); |
874 | if ( ihei *3 > height() ) | 884 | if ( ihei *3 > height() ) { |
875 | setHScrollBarMode(QScrollView::AlwaysOff); | 885 | setHScrollBarMode(QScrollView::AlwaysOff); |
876 | else | 886 | } |
887 | else { | ||
877 | setHScrollBarMode(QScrollView::Auto); | 888 | setHScrollBarMode(QScrollView::Auto); |
889 | } | ||
878 | } else { | 890 | } else { |
879 | setVScrollBarMode(QScrollView::Auto); | 891 | setVScrollBarMode(QScrollView::Auto); |
880 | setHScrollBarMode(QScrollView::Auto); | 892 | setHScrollBarMode(QScrollView::Auto); |
881 | } | 893 | } |
882 | } else { | 894 | } else { |
883 | setVScrollBarMode(QScrollView::AlwaysOff); | 895 | setVScrollBarMode(QScrollView::AlwaysOff); |
884 | setHScrollBarMode(QScrollView::AlwaysOff); | 896 | setHScrollBarMode(QScrollView::AlwaysOff); |
885 | } | 897 | } |
886 | } | 898 | } |
887 | 899 | ||
888 | Incidence *MonthViewCell::selectedIncidence() | 900 | Incidence *MonthViewCell::selectedIncidence() |
889 | { | 901 | { |
890 | int index = currentItem(); | 902 | int index = currentItem(); |
891 | if ( index < 0 ) return 0; | 903 | if ( index < 0 ) return 0; |
892 | 904 | ||
893 | MonthViewItem *mitem = | 905 | MonthViewItem *mitem = |
894 | static_cast<MonthViewItem *>( item( index ) ); | 906 | static_cast<MonthViewItem *>( item( index ) ); |
895 | 907 | ||
896 | if ( !mitem ) return 0; | 908 | if ( !mitem ) return 0; |
897 | 909 | ||
898 | return mitem->incidence(); | 910 | return mitem->incidence(); |
899 | } | 911 | } |
900 | 912 | ||
901 | QDate MonthViewCell::selectedIncidenceDate() | 913 | QDate MonthViewCell::selectedIncidenceDate() |
902 | { | 914 | { |
903 | QDate qd; | 915 | QDate qd; |
904 | int index = currentItem(); | 916 | int index = currentItem(); |
905 | if ( index < 0 ) return qd; | 917 | if ( index < 0 ) return qd; |
906 | 918 | ||
907 | MonthViewItem *mitem = | 919 | MonthViewItem *mitem = |
908 | static_cast<MonthViewItem *>( item( index ) ); | 920 | static_cast<MonthViewItem *>( item( index ) ); |
909 | 921 | ||
910 | if ( !mitem ) return qd; | 922 | if ( !mitem ) return qd; |
911 | 923 | ||
912 | return mitem->incidenceDate(); | 924 | return mitem->incidenceDate(); |
913 | } | 925 | } |
914 | 926 | ||
915 | void MonthViewCell::deselect() | 927 | void MonthViewCell::deselect() |
916 | { | 928 | { |
917 | clearSelection(); | 929 | clearSelection(); |
918 | enableScrollBars( false ); | 930 | enableScrollBars( false ); |
919 | // updateCell(); | 931 | // updateCell(); |
920 | } | 932 | } |
921 | void MonthViewCell::select() | 933 | void MonthViewCell::select() |
922 | { | 934 | { |
923 | ;// updateCell(); | 935 | ;// updateCell(); |
924 | } | 936 | } |
925 | 937 | ||
926 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 938 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
927 | { | 939 | { |
928 | if ( !mMonthView->isUpdatePossible() ) | 940 | if ( !mMonthView->isUpdatePossible() ) |
929 | return; | 941 | return; |
930 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 942 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
931 | deselect(); | 943 | deselect(); |
932 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 944 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
933 | 945 | ||
934 | QString text; | 946 | QString text; |
935 | mLabel->setText( text ); | 947 | mLabel->setText( text ); |
936 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 948 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
937 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 949 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
938 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 950 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
939 | mLabel->resize( mLabelBigSize ); | 951 | mLabel->resize( mLabelBigSize ); |
940 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 952 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
941 | } else { | 953 | } else { |
942 | mLabel->resize( mLabelSize ); | 954 | mLabel->resize( mLabelSize ); |
943 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 955 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
944 | } | 956 | } |
945 | mLabel->setText( text ); | 957 | mLabel->setText( text ); |
946 | 958 | ||
947 | int size = height() - mLabel->height() - lineWidth()-1; | 959 | int size = height() - mLabel->height() - lineWidth()-1; |
948 | //qDebug("LW %d ", lineWidth()); | 960 | //qDebug("LW %d ", lineWidth()); |
949 | if ( size > 0 ) | 961 | if ( size > 0 ) |
950 | verticalScrollBar()->setMaximumHeight( size ); | 962 | verticalScrollBar()->setMaximumHeight( size ); |
951 | size = width() - mLabel->width() -lineWidth()-1; | 963 | size = width() - mLabel->width() -lineWidth()-1; |
952 | if ( size > 0 ) | 964 | if ( size > 0 ) |
953 | horizontalScrollBar()->setMaximumWidth( size ); | 965 | horizontalScrollBar()->setMaximumWidth( size ); |
954 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 966 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
955 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 967 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
956 | // mItemList->resize ( width(), height () ); | 968 | // mItemList->resize ( width(), height () ); |
957 | if ( e ) | 969 | if ( e ) |
958 | KNoScrollListBox::resizeEvent ( e ); | 970 | KNoScrollListBox::resizeEvent ( e ); |
959 | } | 971 | } |
960 | 972 | ||
961 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 973 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
962 | { | 974 | { |
963 | if ( !item ) { | 975 | if ( !item ) { |
964 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 976 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
965 | emit newEventSignal( dt ); | 977 | emit newEventSignal( dt ); |
966 | return; | 978 | return; |
967 | } | 979 | } |
968 | 980 | ||
969 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 981 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
970 | Incidence *incidence = eventItem->incidence(); | 982 | Incidence *incidence = eventItem->incidence(); |
971 | if ( incidence ) mMonthView->defaultAction( incidence ); | 983 | if ( incidence ) mMonthView->defaultAction( incidence ); |
972 | } | 984 | } |
973 | void MonthViewCell::showDay() | 985 | void MonthViewCell::showDay() |
974 | { | 986 | { |
975 | emit showDaySignal( date() ); | 987 | emit showDaySignal( date() ); |
976 | } | 988 | } |
977 | void MonthViewCell::newEvent() | 989 | void MonthViewCell::newEvent() |
978 | { | 990 | { |
979 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 991 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
980 | emit newEventSignal( dt ); | 992 | emit newEventSignal( dt ); |
981 | } | 993 | } |
982 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 994 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
983 | { | 995 | { |
984 | static QListBoxItem * lastClicked = 0; | ||
985 | if ( item == 0 ) { | 996 | if ( item == 0 ) { |
986 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 997 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
987 | emit newEventSignal( dt ); | 998 | emit newEventSignal( dt ); |
988 | return; | 999 | return; |
989 | } | 1000 | } |
990 | /* | 1001 | /* |
991 | if ( lastClicked ) | 1002 | if ( lastClicked ) |
992 | if ( ! item ) { | 1003 | if ( ! item ) { |
993 | if ( lastClicked->listBox() != item->listBox() ) | 1004 | if ( lastClicked->listBox() != item->listBox() ) |
994 | lastClicked->listBox()->clearSelection(); | 1005 | lastClicked->listBox()->clearSelection(); |
995 | } | 1006 | } |
996 | */ | 1007 | */ |
997 | 1008 | ||
998 | mMonthView->setSelectedCell( this ); | 1009 | mMonthView->setSelectedCell( this ); |
999 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 1010 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
1000 | select(); | 1011 | select(); |
1001 | } | 1012 | } |
1002 | 1013 | ||
1003 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1014 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1004 | { | 1015 | { |
1005 | if ( !item ) return; | 1016 | if ( !item ) return; |
1006 | 1017 | ||
1007 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1018 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1008 | Incidence *incidence = eventItem->incidence(); | 1019 | Incidence *incidence = eventItem->incidence(); |
1009 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1020 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1010 | } | 1021 | } |
1011 | 1022 | ||
1012 | void MonthViewCell::selection( QListBoxItem *item ) | 1023 | void MonthViewCell::selection( QListBoxItem *item ) |
1013 | { | 1024 | { |
1014 | if ( !item ) return; | 1025 | if ( !item ) return; |
1015 | 1026 | ||
1016 | mMonthView->setSelectedCell( this ); | 1027 | mMonthView->setSelectedCell( this ); |
1017 | } | 1028 | } |
1018 | 1029 | ||
1019 | 1030 | ||
1020 | // ******************************************************************************* | 1031 | // ******************************************************************************* |
1021 | // ******************************************************************************* | 1032 | // ******************************************************************************* |
1022 | // ******************************************************************************* | 1033 | // ******************************************************************************* |
1023 | 1034 | ||
1024 | 1035 | ||
1025 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1036 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1026 | : KOEventView( calendar, parent, name ), | 1037 | : KOEventView( calendar, parent, name ), |
1027 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1038 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1028 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1039 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1029 | { | 1040 | { |
1030 | mFlagKeyPressed = false; | 1041 | mFlagKeyPressed = false; |
1031 | mShortDayLabelsM = false; | 1042 | mShortDayLabelsM = false; |
1032 | mShortDayLabelsW = false; | 1043 | mShortDayLabelsW = false; |
1033 | skipResize = false; | 1044 | skipResize = false; |
1034 | clPending = true; | 1045 | clPending = true; |
1035 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1046 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1036 | mWidStack = new QWidgetStack( this ); | 1047 | mWidStack = new QWidgetStack( this ); |
1037 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1048 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1038 | mMonthView = new QWidget( mWidStack ); | 1049 | mMonthView = new QWidget( mWidStack ); |
1039 | mWeekView = new QWidget( mWidStack ); | 1050 | mWeekView = new QWidget( mWidStack ); |
1040 | #if QT_VERSION >= 0x030000 | 1051 | #if QT_VERSION >= 0x030000 |
1041 | mWidStack->addWidget(mMonthView ); | 1052 | mWidStack->addWidget(mMonthView ); |
1042 | mWidStack->addWidget(mWeekView ); | 1053 | mWidStack->addWidget(mWeekView ); |
1043 | #else | 1054 | #else |
1044 | mWidStack->addWidget( mMonthView, 1 ); | 1055 | mWidStack->addWidget( mMonthView, 1 ); |
1045 | mWidStack->addWidget( mWeekView , 1 ); | 1056 | mWidStack->addWidget( mWeekView , 1 ); |
1046 | #endif | 1057 | #endif |
1047 | hb->addWidget( mNavigatorBar ); | 1058 | hb->addWidget( mNavigatorBar ); |
1048 | hb->addWidget( mWidStack ); | 1059 | hb->addWidget( mWidStack ); |
1049 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1060 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1050 | updatePossible = false; | 1061 | updatePossible = false; |
1051 | //updatePossible = true; | 1062 | //updatePossible = true; |
1052 | mCells.setAutoDelete( true ); | 1063 | mCells.setAutoDelete( true ); |
1053 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1064 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1054 | mDayLabels.resize( mDaysPerWeek ); | 1065 | mDayLabels.resize( mDaysPerWeek ); |
1055 | mDayLabelsW.resize( mDaysPerWeek ); | 1066 | mDayLabelsW.resize( mDaysPerWeek ); |
1056 | QFont bfont = font(); | 1067 | QFont bfont = font(); |
1057 | if ( QApplication::desktop()->width() < 650 ) { | 1068 | if ( QApplication::desktop()->width() < 650 ) { |
1058 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1069 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1059 | } | 1070 | } |
1060 | bfont.setBold( true ); | 1071 | bfont.setBold( true ); |
1061 | int i; | 1072 | int i; |
1062 | 1073 | ||
1063 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1074 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1064 | QLabel *label = new QLabel( mMonthView ); | 1075 | QLabel *label = new QLabel( mMonthView ); |
1065 | label->setFont(bfont); | 1076 | label->setFont(bfont); |
1066 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1077 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1067 | label->setLineWidth(1); | 1078 | label->setLineWidth(1); |
1068 | label->setAlignment(AlignCenter); | 1079 | label->setAlignment(AlignCenter); |
1069 | mDayLabels.insert( i, label ); | 1080 | mDayLabels.insert( i, label ); |
1070 | label = new QLabel( mWeekView ); | 1081 | label = new QLabel( mWeekView ); |
1071 | label->setFont(bfont); | 1082 | label->setFont(bfont); |
1072 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1083 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1073 | label->setLineWidth(1); | 1084 | label->setLineWidth(1); |
1074 | label->setAlignment(AlignCenter); | 1085 | label->setAlignment(AlignCenter); |
1075 | mDayLabelsW.insert( i, label ); | 1086 | mDayLabelsW.insert( i, label ); |
1076 | } | 1087 | } |
1077 | 1088 | ||
1078 | bfont.setBold( false ); | 1089 | bfont.setBold( false ); |
1079 | mWeekLabels.resize( mNumWeeks+1 ); | 1090 | mWeekLabels.resize( mNumWeeks+1 ); |
1080 | mWeekLabelsW.resize( 2 ); | 1091 | mWeekLabelsW.resize( 2 ); |
1081 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1092 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1082 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1093 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1083 | label->setFocusPolicy(NoFocus); | 1094 | label->setFocusPolicy(NoFocus); |
1084 | label->setFont(bfont); | 1095 | label->setFont(bfont); |
1085 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1096 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1086 | label->setFlat(true); | 1097 | label->setFlat(true); |
1087 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1098 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1088 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1099 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1089 | //label->setLineWidth(1); | 1100 | //label->setLineWidth(1); |
1090 | //label->setAlignment(AlignCenter); | 1101 | //label->setAlignment(AlignCenter); |
1091 | mWeekLabels.insert( i, label ); | 1102 | mWeekLabels.insert( i, label ); |
1092 | } | 1103 | } |
1093 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1104 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1094 | mWeekLabels[0]->setFocusPolicy(WheelFocus); | 1105 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1095 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1106 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1096 | 1107 | ||
1097 | for( i = 0; i < 1+1; i++ ) { | 1108 | for( i = 0; i < 1+1; i++ ) { |
1098 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1109 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1099 | label->setFocusPolicy(NoFocus); | 1110 | label->setFocusPolicy(NoFocus); |
1100 | label->setFont(bfont); | 1111 | label->setFont(bfont); |
1101 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1112 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1102 | label->setFlat(true); | 1113 | label->setFlat(true); |
1103 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1114 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1104 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1115 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1105 | //label->setLineWidth(1); | 1116 | //label->setLineWidth(1); |
1106 | //label->setAlignment(AlignCenter); | 1117 | //label->setAlignment(AlignCenter); |
1107 | mWeekLabelsW.insert( i, label ); | 1118 | mWeekLabelsW.insert( i, label ); |
1108 | } | 1119 | } |
1109 | mWeekLabelsW[1]->setText( i18n("W")); | 1120 | mWeekLabelsW[1]->setText( i18n("W")); |
1110 | mWeekLabelsW[0]->setFocusPolicy(WheelFocus); | 1121 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1111 | 1122 | ||
1112 | 1123 | ||
1113 | int row, col; | 1124 | int row, col; |
1114 | mCells.resize( mNumCells ); | 1125 | mCells.resize( mNumCells ); |
1115 | for( row = 0; row < mNumWeeks; ++row ) { | 1126 | for( row = 0; row < mNumWeeks; ++row ) { |
1116 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1127 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1117 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1128 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1118 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1129 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1119 | 1130 | ||
1120 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1131 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1121 | SLOT( defaultAction( Incidence * ) ) ); | 1132 | SLOT( defaultAction( Incidence * ) ) ); |
1122 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1133 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1123 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1134 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1124 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1135 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1125 | SIGNAL( showDaySignal( QDate ) ) ); | 1136 | SIGNAL( showDaySignal( QDate ) ) ); |
1126 | } | 1137 | } |
1127 | } | 1138 | } |
1128 | mCellsW.resize( mDaysPerWeek ); | 1139 | mCellsW.resize( mDaysPerWeek ); |
1129 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1140 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1130 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1141 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1131 | mCellsW.insert( col, cell ); | 1142 | mCellsW.insert( col, cell ); |
1132 | 1143 | ||
1133 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1144 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1134 | SLOT( defaultAction( Incidence * ) ) ); | 1145 | SLOT( defaultAction( Incidence * ) ) ); |
1135 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1146 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1136 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1147 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1137 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1148 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1138 | SIGNAL( showDaySignal( QDate ) ) ); | 1149 | SIGNAL( showDaySignal( QDate ) ) ); |
1139 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1150 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1140 | } | 1151 | } |
1141 | 1152 | ||
1142 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1153 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1143 | mContextMenu = eventPopup(); | 1154 | mContextMenu = eventPopup(); |
1144 | // updateConfig(); //useless here... | 1155 | // updateConfig(); //useless here... |
1145 | // ... but we need mWidthLongDayLabel computed | 1156 | // ... but we need mWidthLongDayLabel computed |
1146 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1157 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1147 | mWidthLongDayLabel = 0; | 1158 | mWidthLongDayLabel = 0; |
1148 | for (int i = 0; i < 7; i++) { | 1159 | for (int i = 0; i < 7; i++) { |
1149 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1160 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1150 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1161 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1151 | } | 1162 | } |
1152 | 1163 | ||
1153 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1164 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1154 | 1165 | ||
1155 | #if 0 | 1166 | #if 0 |
1156 | if ( mShowWeekView ) | 1167 | if ( mShowWeekView ) |
1157 | mWidStack->raiseWidget( mWeekView ); | 1168 | mWidStack->raiseWidget( mWeekView ); |
1158 | else | 1169 | else |
1159 | mWidStack->raiseWidget( mMonthView ); | 1170 | mWidStack->raiseWidget( mMonthView ); |
1160 | #endif | 1171 | #endif |
1161 | 1172 | ||
1162 | emit incidenceSelected( 0 ); | 1173 | emit incidenceSelected( 0 ); |
1163 | 1174 | ||
1164 | mComputeLayoutTimer = new QTimer( this ); | 1175 | mComputeLayoutTimer = new QTimer( this ); |
1165 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1176 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1166 | 1177 | ||
1167 | 1178 | ||
1168 | #ifndef DESKTOP_VERSION | 1179 | #ifndef DESKTOP_VERSION |
1169 | resize( QApplication::desktop()->size() ); | 1180 | resize( QApplication::desktop()->size() ); |
1170 | #else | 1181 | #else |
1171 | resize(640, 480 ); | 1182 | resize(640, 480 ); |
1172 | updatePossible = true; | 1183 | updatePossible = true; |
1173 | #endif | 1184 | #endif |
1174 | computeLayout(); | 1185 | computeLayout(); |
1175 | 1186 | ||
1176 | if ( mShowWeekView ) | 1187 | if ( mShowWeekView ) |
1177 | mWidStack->raiseWidget( mWeekView ); | 1188 | mWidStack->raiseWidget( mWeekView ); |
1178 | else | 1189 | else |
1179 | mWidStack->raiseWidget( mMonthView ); | 1190 | mWidStack->raiseWidget( mMonthView ); |
1180 | } | 1191 | } |
1181 | 1192 | ||
1182 | KOMonthView::~KOMonthView() | 1193 | KOMonthView::~KOMonthView() |
1183 | { | 1194 | { |
1184 | delete mContextMenu; | 1195 | delete mContextMenu; |
1185 | } | 1196 | } |
1186 | 1197 | ||
1187 | void KOMonthView::selectInternalWeekNum ( int n ) | 1198 | void KOMonthView::selectInternalWeekNum ( int n ) |
1188 | { | 1199 | { |
1189 | switchView(); | 1200 | switchView(); |
1190 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1201 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1191 | emit selectMonth (); | 1202 | emit selectMonth (); |
1192 | else | 1203 | else |
1193 | emit selectWeekNum ( n ); | 1204 | emit selectWeekNum ( n ); |
1194 | } | 1205 | } |
1195 | 1206 | ||
1196 | int KOMonthView::currentWeek() | 1207 | int KOMonthView::currentWeek() |
1197 | { | 1208 | { |
1198 | if ( mShowWeekView ) | 1209 | if ( mShowWeekView ) |
1199 | return mWeekLabelsW[0]->getWeekNum(); | 1210 | return mWeekLabelsW[0]->getWeekNum(); |
1200 | return mWeekLabels[0]->getWeekNum(); | 1211 | return mWeekLabels[0]->getWeekNum(); |
1201 | } | 1212 | } |
1202 | void KOMonthView::switchView() | 1213 | void KOMonthView::switchView() |
1203 | { | 1214 | { |
1204 | if ( selectedCell( ) ) | 1215 | if ( selectedCell( ) ) |
1205 | selectedCell()->deselect(); | 1216 | selectedCell()->deselect(); |
1206 | mShowWeekView = !mShowWeekView; | 1217 | mShowWeekView = !mShowWeekView; |
1207 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1218 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1208 | if ( clPending ) { | 1219 | if ( clPending ) { |
1209 | computeLayout(); | 1220 | computeLayout(); |
1210 | updateConfig(); | 1221 | updateConfig(); |
1211 | } | 1222 | } |
1212 | if ( mShowWeekView ) | 1223 | if ( mShowWeekView ) |
1213 | mWidStack->raiseWidget( mWeekView ); | 1224 | mWidStack->raiseWidget( mWeekView ); |
1214 | else | 1225 | else |
1215 | mWidStack->raiseWidget( mMonthView ); | 1226 | mWidStack->raiseWidget( mMonthView ); |
1216 | clPending = false; | 1227 | clPending = false; |
1217 | } | 1228 | } |
1218 | 1229 | ||
1219 | int KOMonthView::maxDatesHint() | 1230 | int KOMonthView::maxDatesHint() |
1220 | { | 1231 | { |
1221 | return mNumCells; | 1232 | return mNumCells; |
1222 | } | 1233 | } |
1223 | 1234 | ||
1224 | int KOMonthView::currentDateCount() | 1235 | int KOMonthView::currentDateCount() |
1225 | { | 1236 | { |
1226 | return mNumCells; | 1237 | return mNumCells; |
1227 | } | 1238 | } |
1228 | 1239 | ||
1229 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1240 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1230 | { | 1241 | { |
1231 | QPtrList<Incidence> selected; | 1242 | QPtrList<Incidence> selected; |
1232 | 1243 | ||
1233 | if ( mSelectedCell ) { | 1244 | if ( mSelectedCell ) { |
1234 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1245 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1235 | if ( incidence ) selected.append( incidence ); | 1246 | if ( incidence ) selected.append( incidence ); |
1236 | } | 1247 | } |
1237 | 1248 | ||
1238 | return selected; | 1249 | return selected; |
1239 | } | 1250 | } |
1240 | 1251 | ||
1241 | DateList KOMonthView::selectedDates() | 1252 | DateList KOMonthView::selectedDates() |
1242 | { | 1253 | { |
1243 | DateList selected; | 1254 | DateList selected; |
1244 | 1255 | ||
1245 | if ( mSelectedCell ) { | 1256 | if ( mSelectedCell ) { |
1246 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1257 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1247 | if ( qd.isValid() ) selected.append( qd ); | 1258 | if ( qd.isValid() ) selected.append( qd ); |
1248 | } | 1259 | } |
1249 | 1260 | ||
1250 | return selected; | 1261 | return selected; |
1251 | } | 1262 | } |
1252 | 1263 | ||
1253 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1264 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1254 | const QDate &td) | 1265 | const QDate &td) |
1255 | { | 1266 | { |
1256 | #ifndef KORG_NOPRINTER | 1267 | #ifndef KORG_NOPRINTER |
1257 | calPrinter->preview(CalPrinter::Month, fd, td); | 1268 | calPrinter->preview(CalPrinter::Month, fd, td); |
1258 | #endif | 1269 | #endif |
1259 | } | 1270 | } |
1260 | 1271 | ||
1261 | void KOMonthView::updateConfig() | 1272 | void KOMonthView::updateConfig() |
1262 | { | 1273 | { |
1263 | 1274 | ||
1264 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1275 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1265 | 1276 | ||
1266 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1277 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1267 | mWeekStartsMonday = true; | 1278 | mWeekStartsMonday = true; |
1268 | } | 1279 | } |
1269 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1280 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1270 | mWidthLongDayLabel = 0; | 1281 | mWidthLongDayLabel = 0; |
1271 | 1282 | ||
1272 | for (int i = 0; i < 7; i++) { | 1283 | for (int i = 0; i < 7; i++) { |
1273 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1284 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1274 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1285 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1275 | } | 1286 | } |
1276 | bool temp = mShowSatSunComp ; | 1287 | bool temp = mShowSatSunComp ; |
1277 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1288 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1278 | if ( ! mShowWeekView ) { | 1289 | if ( ! mShowWeekView ) { |
1279 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1290 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1280 | computeLayout(); | 1291 | computeLayout(); |
1281 | } | 1292 | } |
1282 | updateDayLabels(); | 1293 | updateDayLabels(); |
1283 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1294 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1284 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1295 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1285 | //resizeEvent( 0 ); | 1296 | //resizeEvent( 0 ); |
1286 | for (uint i = 0; i < mCells.count(); ++i) { | 1297 | for (uint i = 0; i < mCells.count(); ++i) { |
1287 | mCells[i]->updateConfig(); | 1298 | mCells[i]->updateConfig(); |
1288 | } | 1299 | } |
1289 | 1300 | ||
1290 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1301 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1291 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1302 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1292 | } | 1303 | } |
1293 | #ifdef DESKTOP_VERSION | 1304 | #ifdef DESKTOP_VERSION |
1294 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1305 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1295 | #endif | 1306 | #endif |
1296 | updateView(); | 1307 | updateView(); |
1297 | } | 1308 | } |
1298 | 1309 | ||
1299 | void KOMonthView::updateDayLabels() | 1310 | void KOMonthView::updateDayLabels() |
1300 | { | 1311 | { |
1301 | 1312 | ||
1302 | QPtrVector<QLabel> *mDayLabelsT; | 1313 | QPtrVector<QLabel> *mDayLabelsT; |
1303 | 1314 | ||
1304 | mDayLabelsT = &mDayLabelsW; | 1315 | mDayLabelsT = &mDayLabelsW; |
1305 | for (int i = 0; i < 7; i++) { | 1316 | for (int i = 0; i < 7; i++) { |
1306 | { | 1317 | { |
1307 | bool show = mShortDayLabelsW; | 1318 | bool show = mShortDayLabelsW; |
1308 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1319 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1309 | show = true; | 1320 | show = true; |
1310 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1321 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1311 | } | 1322 | } |
1312 | } | 1323 | } |
1313 | mDayLabelsT = &mDayLabels; | 1324 | mDayLabelsT = &mDayLabels; |
1314 | for (int i = 0; i < 7; i++) { | 1325 | for (int i = 0; i < 7; i++) { |
1315 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1326 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1316 | bool show = mShortDayLabelsM; | 1327 | bool show = mShortDayLabelsM; |
1317 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1328 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1318 | show = true; | 1329 | show = true; |
1319 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1330 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1320 | } else { | 1331 | } else { |
1321 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1332 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1322 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1333 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1323 | 1334 | ||
1324 | } | 1335 | } |
1325 | } | 1336 | } |
1326 | 1337 | ||
1327 | } | 1338 | } |
1328 | 1339 | ||
1329 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1340 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1330 | { | 1341 | { |
1331 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1342 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1332 | 1343 | ||
1333 | QPtrVector<MonthViewCell> *cells; | 1344 | QPtrVector<MonthViewCell> *cells; |
1334 | QPtrVector<QLabel> *dayLabels; | 1345 | QPtrVector<QLabel> *dayLabels; |
1335 | QPtrVector<KOWeekButton> *weekLabels; | 1346 | QPtrVector<KOWeekButton> *weekLabels; |
1336 | int weekNum = 6; | 1347 | int weekNum = 6; |
1337 | mStartDate = start; | 1348 | mStartDate = start; |
1338 | if ( mShowWeekView ) { | 1349 | if ( mShowWeekView ) { |
1339 | weekNum = 1; | 1350 | weekNum = 1; |
1340 | cells = &mCellsW; | 1351 | cells = &mCellsW; |
1341 | dayLabels = &mDayLabelsW; | 1352 | dayLabels = &mDayLabelsW; |
1342 | weekLabels = &mWeekLabelsW; | 1353 | weekLabels = &mWeekLabelsW; |
1343 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1354 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1344 | mStartDate = mStartDate.addDays( 1 ); | 1355 | mStartDate = mStartDate.addDays( 1 ); |
1345 | } | 1356 | } |
1346 | } else { | 1357 | } else { |
1347 | cells = &mCells; | 1358 | cells = &mCells; |
1348 | dayLabels = &mDayLabels; | 1359 | dayLabels = &mDayLabels; |
1349 | weekLabels = &mWeekLabels; | 1360 | weekLabels = &mWeekLabels; |
1350 | } | 1361 | } |
1351 | 1362 | ||
1352 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1363 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1353 | 1364 | ||
1354 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1365 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1355 | mWeekStartsMonday = true; | 1366 | mWeekStartsMonday = true; |
1356 | } | 1367 | } |
1357 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1368 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1358 | 1369 | ||
1359 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1370 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1360 | mStartDate = mStartDate.addDays( -1 ); | 1371 | mStartDate = mStartDate.addDays( -1 ); |
1361 | } | 1372 | } |
1362 | bool primary = false; | 1373 | bool primary = false; |
1363 | uint i; | 1374 | uint i; |
1364 | for( i = 0; i < (*cells).size(); ++i ) { | 1375 | for( i = 0; i < (*cells).size(); ++i ) { |
1365 | QDate date = mStartDate.addDays( i ); | 1376 | QDate date = mStartDate.addDays( i ); |
1366 | (*cells)[i]->setDate( date ); | 1377 | (*cells)[i]->setDate( date ); |
1367 | 1378 | ||
1368 | #ifndef KORG_NOPLUGINS | 1379 | #ifndef KORG_NOPLUGINS |
1369 | // add holiday, if present | 1380 | // add holiday, if present |
1370 | QString hstring(KOCore::self()->holiday(date)); | 1381 | QString hstring(KOCore::self()->holiday(date)); |
1371 | (*cells)[i]->setHoliday( hstring ); | 1382 | (*cells)[i]->setHoliday( hstring ); |
1372 | #endif | 1383 | #endif |
1373 | 1384 | ||
1374 | } | 1385 | } |
1375 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1386 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1376 | for( i = 0; i < weekNum; ++i ) { | 1387 | for( i = 0; i < weekNum; ++i ) { |
1377 | int wno; | 1388 | int wno; |
1378 | // remember, according to ISO 8601, the first week of the year is the | 1389 | // remember, according to ISO 8601, the first week of the year is the |
1379 | // first week that contains a thursday. Thus we must subtract off 4, | 1390 | // first week that contains a thursday. Thus we must subtract off 4, |
1380 | // not just 1. | 1391 | // not just 1. |
1381 | int dayOfYear = date.dayOfYear(); | 1392 | int dayOfYear = date.dayOfYear(); |
1382 | if (dayOfYear % 7 != 0) | 1393 | if (dayOfYear % 7 != 0) |
1383 | wno = dayOfYear / 7 + 1; | 1394 | wno = dayOfYear / 7 + 1; |
1384 | else | 1395 | else |
1385 | wno =dayOfYear / 7; | 1396 | wno =dayOfYear / 7; |
1386 | (*weekLabels)[i]->setWeekNum( wno ); | 1397 | (*weekLabels)[i]->setWeekNum( wno ); |
1387 | date = date.addDays( 7 ); | 1398 | date = date.addDays( 7 ); |
1388 | } | 1399 | } |
1389 | updateView(); | 1400 | updateView(); |
1390 | } | 1401 | } |
1391 | 1402 | ||
1392 | void KOMonthView::showEvents(QPtrList<Event>) | 1403 | void KOMonthView::showEvents(QPtrList<Event>) |
1393 | { | 1404 | { |
1394 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1405 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1395 | } | 1406 | } |
1396 | 1407 | ||
1397 | void KOMonthView::changeEventDisplay(Event *, int) | 1408 | void KOMonthView::changeEventDisplay(Event *, int) |
1398 | { | 1409 | { |
1399 | // this should be re-written to be much more efficient, but this | 1410 | // this should be re-written to be much more efficient, but this |
1400 | // quick-and-dirty-hack gets the job done for right now. | 1411 | // quick-and-dirty-hack gets the job done for right now. |
1401 | qDebug("KOMonthView::changeEventDisplay "); | 1412 | //qDebug("KOMonthView::changeEventDisplay "); |
1402 | updateView(); | 1413 | updateView(); |
1403 | } | 1414 | } |
1404 | 1415 | ||
1405 | void KOMonthView::updateView() | 1416 | void KOMonthView::updateView() |
1406 | { | 1417 | { |
1407 | 1418 | ||
1408 | if ( !updatePossible ) | 1419 | if ( !updatePossible ) |
1409 | return; | 1420 | return; |
1410 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1421 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1411 | //QTime ti; | 1422 | //QTime ti; |
1412 | //ti.start(); | 1423 | //ti.start(); |
1413 | clearSelection(); | 1424 | clearSelection(); |
1414 | QPtrVector<MonthViewCell> *cells; | 1425 | QPtrVector<MonthViewCell> *cells; |
1415 | if ( mShowWeekView ) { | 1426 | if ( mShowWeekView ) { |
1416 | cells = &mCellsW; | 1427 | cells = &mCellsW; |
1417 | } else { | 1428 | } else { |
1418 | cells = &mCells; | 1429 | cells = &mCells; |
1419 | } | 1430 | } |
1420 | #if 1 | 1431 | #if 1 |
1421 | int i; | 1432 | int i; |
1422 | int timeSpan = (*cells).size()-1; | 1433 | int timeSpan = (*cells).size()-1; |
1423 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1434 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1424 | timeSpan = 6; | 1435 | timeSpan = 6; |
1425 | for( i = 0; i < timeSpan + 1; ++i ) { | 1436 | for( i = 0; i < timeSpan + 1; ++i ) { |
1426 | (*cells)[i]->startUpdateCell(); | 1437 | (*cells)[i]->startUpdateCell(); |
1427 | } | 1438 | } |
1428 | 1439 | ||
1429 | QPtrList<Event> events = calendar()->events(); | 1440 | QPtrList<Event> events = calendar()->events(); |
1430 | Event *event; | 1441 | Event *event; |
1431 | QDateTime dt; | 1442 | QDateTime dt; |
1432 | bool ok; | 1443 | bool ok; |
1433 | QDate endDate = mStartDate.addDays( timeSpan ); | 1444 | QDate endDate = mStartDate.addDays( timeSpan ); |
1434 | for( event = events.first(); event; event = events.next() ) { // for event | 1445 | for( event = events.first(); event; event = events.next() ) { // for event |
1435 | if ( event->doesRecur() ) { | 1446 | if ( event->doesRecur() ) { |
1436 | bool last; | 1447 | bool last; |
1437 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1448 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1438 | QDateTime incidenceEnd; | 1449 | QDateTime incidenceEnd; |
1439 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1450 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1440 | bool invalid = false; | 1451 | bool invalid = false; |
1441 | while( true ) { | 1452 | while( true ) { |
1442 | if ( incidenceStart.isValid() ) { | 1453 | if ( incidenceStart.isValid() ) { |
1443 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1454 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1444 | int st = incidenceStart.date().daysTo( endDate ); | 1455 | int st = incidenceStart.date().daysTo( endDate ); |
1445 | if ( st >= 0 ) { // start before timeend | 1456 | if ( st >= 0 ) { // start before timeend |
1446 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1457 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1447 | if ( end >= 0 ) { // end after timestart --- got one! | 1458 | if ( end >= 0 ) { // end after timestart --- got one! |
1448 | //normalize | 1459 | //normalize |
1449 | st = timeSpan - st; | 1460 | st = timeSpan - st; |
1450 | if ( st < 0 ) st = 0; | 1461 | if ( st < 0 ) st = 0; |
1451 | if ( end > timeSpan ) end = timeSpan; | 1462 | if ( end > timeSpan ) end = timeSpan; |
1452 | int iii; | 1463 | int iii; |
1453 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1464 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1454 | for ( iii = st;iii<= end;++iii) | 1465 | for ( iii = st;iii<= end;++iii) |
1455 | (*cells)[iii]->insertEvent( event ); | 1466 | (*cells)[iii]->insertEvent( event ); |
1456 | } | 1467 | } |
1457 | } | 1468 | } |
1458 | } else { | 1469 | } else { |
1459 | if ( invalid ) | 1470 | if ( invalid ) |
1460 | break; | 1471 | break; |
1461 | invalid = true; | 1472 | invalid = true; |
1462 | //qDebug("invalid %s", event->summary().latin1()); | 1473 | //qDebug("invalid %s", event->summary().latin1()); |
1463 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1474 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1464 | } | 1475 | } |
1465 | if ( last ) | 1476 | if ( last ) |
1466 | break; | 1477 | break; |
1467 | bool ok; | 1478 | bool ok; |
1468 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1479 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1469 | if ( ! ok ) | 1480 | if ( ! ok ) |
1470 | break; | 1481 | break; |
1471 | if ( incidenceStart.date() > endDate ) | 1482 | if ( incidenceStart.date() > endDate ) |
1472 | break; | 1483 | break; |
1473 | } | 1484 | } |
1474 | } else { // no recur | 1485 | } else { // no recur |
1475 | int st = event->dtStart().date().daysTo( endDate ); | 1486 | int st = event->dtStart().date().daysTo( endDate ); |
1476 | if ( st >= 0 ) { // start before timeend | 1487 | if ( st >= 0 ) { // start before timeend |
1477 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1488 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1478 | if ( end >= 0 ) { // end after timestart --- got one! | 1489 | if ( end >= 0 ) { // end after timestart --- got one! |
1479 | //normalize | 1490 | //normalize |
1480 | st = timeSpan - st; | 1491 | st = timeSpan - st; |
1481 | if ( st < 0 ) st = 0; | 1492 | if ( st < 0 ) st = 0; |
1482 | if ( end > timeSpan ) end = timeSpan; | 1493 | if ( end > timeSpan ) end = timeSpan; |
1483 | int iii; | 1494 | int iii; |
1484 | for ( iii = st;iii<= end;++iii) | 1495 | for ( iii = st;iii<= end;++iii) |
1485 | (*cells)[iii]->insertEvent( event ); | 1496 | (*cells)[iii]->insertEvent( event ); |
1486 | } | 1497 | } |
1487 | } | 1498 | } |
1488 | } | 1499 | } |
1489 | } | 1500 | } |
1490 | // insert due todos | 1501 | // insert due todos |
1491 | QPtrList<Todo> todos = calendar()->todos( ); | 1502 | QPtrList<Todo> todos = calendar()->todos( ); |
1492 | Todo *todo; | 1503 | Todo *todo; |
1493 | for(todo = todos.first(); todo; todo = todos.next()) { | 1504 | for(todo = todos.first(); todo; todo = todos.next()) { |
1494 | //insertTodo( todo ); | 1505 | //insertTodo( todo ); |
1495 | if ( todo->hasDueDate() ) { | 1506 | if ( todo->hasDueDate() ) { |
1496 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1507 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1497 | if ( day >= 0 && day < timeSpan + 1) { | 1508 | if ( day >= 0 && day < timeSpan + 1) { |
1498 | (*cells)[day]->insertTodo( todo ); | 1509 | (*cells)[day]->insertTodo( todo ); |
1499 | } | 1510 | } |
1500 | } | 1511 | } |
1501 | } | 1512 | } |
1502 | 1513 | ||
1503 | for( i = 0; i < timeSpan+1; ++i ) { | 1514 | for( i = 0; i < timeSpan+1; ++i ) { |
1504 | (*cells)[i]->finishUpdateCell(); | 1515 | (*cells)[i]->finishUpdateCell(); |
1505 | } | 1516 | } |
1506 | processSelectionChange(); | 1517 | processSelectionChange(); |
1507 | //qApp->processEvents(); | 1518 | //qApp->processEvents(); |
1508 | for( i = 0; i < timeSpan+1; ++i ) { | 1519 | for( i = 0; i < timeSpan+1; ++i ) { |
1509 | (*cells)[i]->repaintfinishUpdateCell(); | 1520 | (*cells)[i]->repaintfinishUpdateCell(); |
1510 | } | 1521 | } |
1511 | setKeyBFocus(); | 1522 | setKeyBFocus(); |
1512 | #else | 1523 | #else |
1513 | // old code | 1524 | // old code |
1514 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1525 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1515 | int i; | 1526 | int i; |
1516 | for( i = 0; i < (*cells).count(); ++i ) { | 1527 | for( i = 0; i < (*cells).count(); ++i ) { |
1517 | (*cells)[i]->updateCell(); | 1528 | (*cells)[i]->updateCell(); |
1518 | } | 1529 | } |
1519 | 1530 | ||
1520 | //qDebug("KOMonthView::updateView() "); | 1531 | //qDebug("KOMonthView::updateView() "); |
1521 | processSelectionChange(); | 1532 | processSelectionChange(); |
1522 | // qDebug("---------------------------------------------------------------------+ "); | 1533 | // qDebug("---------------------------------------------------------------------+ "); |
1523 | (*cells)[0]->setFocus(); | 1534 | (*cells)[0]->setFocus(); |
1524 | #endif | 1535 | #endif |
1525 | 1536 | ||
1526 | //qDebug("update time %d ", ti.elapsed()); | 1537 | //qDebug("update time %d ", ti.elapsed()); |
1527 | } | 1538 | } |
1528 | 1539 | ||
1529 | void KOMonthView::setKeyBoardFocus() | 1540 | void KOMonthView::setKeyBoardFocus() |
1530 | { | 1541 | { |
1542 | //qDebug("KOMonthView::setKeyBoardFocus() "); | ||
1531 | bool shootAgain = false; | 1543 | bool shootAgain = false; |
1532 | if ( mShowWeekView ) { | 1544 | if ( mShowWeekView ) { |
1533 | shootAgain = !mWeekLabelsW[0]->hasFocus(); | 1545 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1534 | mWeekLabelsW[0]->setFocus(); | 1546 | mWeekLabelsW[1]->setFocus(); |
1535 | } | 1547 | } |
1536 | else { | 1548 | else { |
1537 | shootAgain = !mWeekLabels[0]->hasFocus(); | 1549 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1538 | mWeekLabels[0]->setFocus(); | 1550 | mWeekLabels[mNumWeeks]->setFocus(); |
1539 | } | 1551 | } |
1540 | if ( shootAgain ) { | 1552 | if ( shootAgain ) { |
1541 | QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); | 1553 | QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); |
1542 | } | 1554 | } |
1543 | } | 1555 | } |
1544 | void KOMonthView::setKeyBFocus() | 1556 | void KOMonthView::setKeyBFocus() |
1545 | { | 1557 | { |
1546 | //qDebug("KOMonthView::setKeyBFocus() "); | 1558 | //qDebug("KOMonthView::setKeyBFocus() "); |
1547 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1559 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1548 | } | 1560 | } |
1549 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1561 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1550 | { | 1562 | { |
1551 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1563 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1552 | if ( isVisible() ) { | 1564 | if ( isVisible() ) { |
1553 | //qDebug("KOMonthView::isVisible "); | 1565 | //qDebug("KOMonthView::isVisible "); |
1554 | slotComputeLayout(); | 1566 | slotComputeLayout(); |
1555 | } else | 1567 | } else |
1556 | mComputeLayoutTimer->start( 100 ); | 1568 | mComputeLayoutTimer->start( 100 ); |
1557 | } | 1569 | } |
1558 | 1570 | ||
1559 | void KOMonthView::slotComputeLayout() | 1571 | void KOMonthView::slotComputeLayout() |
1560 | { | 1572 | { |
1561 | mComputeLayoutTimer->stop(); | 1573 | mComputeLayoutTimer->stop(); |
1562 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1574 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1563 | computeLayout(); | 1575 | computeLayout(); |
1564 | clPending = true; | 1576 | clPending = true; |
1565 | setKeyBFocus(); | 1577 | setKeyBFocus(); |
1566 | } | 1578 | } |
1567 | void KOMonthView::computeLayoutWeek() | 1579 | void KOMonthView::computeLayoutWeek() |
1568 | { | 1580 | { |
1569 | static int lastWid = 0; | 1581 | static int lastWid = 0; |
1570 | static int lastHei = 0; | 1582 | static int lastHei = 0; |
1571 | int daysToShow; | 1583 | int daysToShow; |
1572 | bool combinedSatSun = false; | 1584 | bool combinedSatSun = false; |
1573 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1585 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1574 | daysToShow = 6; | 1586 | daysToShow = 6; |
1575 | combinedSatSun = true; | 1587 | combinedSatSun = true; |
1576 | } | 1588 | } |
1577 | int tWid = topLevelWidget()->size().width(); | 1589 | int tWid = topLevelWidget()->size().width(); |
1578 | int tHei = topLevelWidget()->size().height(); | 1590 | int tHei = topLevelWidget()->size().height(); |
1579 | 1591 | ||
1580 | int wid = width();//e | 1592 | int wid = width();//e |
1581 | int hei = height()-1-mNavigatorBar->height(); | 1593 | int hei = height()-1-mNavigatorBar->height(); |
1582 | 1594 | ||
1583 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1595 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1584 | return; | 1596 | return; |
1585 | 1597 | ||
1586 | if ( lastWid == width() && lastHei == height() ) { | 1598 | if ( lastWid == width() && lastHei == height() ) { |
1587 | //qDebug("KOListWeekView::No compute layout needed "); | 1599 | //qDebug("KOListWeekView::No compute layout needed "); |
1588 | return; | 1600 | return; |
1589 | } | 1601 | } |
1590 | lastWid = width(); | 1602 | lastWid = width(); |
1591 | lastHei = height(); | 1603 | lastHei = height(); |
1592 | 1604 | ||
1593 | 1605 | ||
1594 | if ( wid < hei ) | 1606 | if ( wid < hei ) |
1595 | daysToShow = 2; | 1607 | daysToShow = 2; |
1596 | else | 1608 | else |
1597 | daysToShow = 3; | 1609 | daysToShow = 3; |
1598 | mShowSatSunComp = true; | 1610 | mShowSatSunComp = true; |
1599 | combinedSatSun = true; | 1611 | combinedSatSun = true; |
1600 | 1612 | ||
1601 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1613 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1602 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1614 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1603 | int weeklabelwid = fm.width( "888" ); | 1615 | int weeklabelwid = fm.width( "888" ); |
1604 | wid -= weeklabelwid; | 1616 | wid -= weeklabelwid; |
1605 | 1617 | ||
1606 | int colWid = wid / daysToShow; | 1618 | int colWid = wid / daysToShow; |
1607 | int lastCol = wid - ( colWid*6 ); | 1619 | int lastCol = wid - ( colWid*6 ); |
1608 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1620 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1609 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1621 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1610 | int colModulo = wid % daysToShow; | 1622 | int colModulo = wid % daysToShow; |
1611 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1623 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1612 | //qDebug("rowmod %d ", rowModulo); | 1624 | //qDebug("rowmod %d ", rowModulo); |
1613 | int i; | 1625 | int i; |
1614 | int x,y,w,h; | 1626 | int x,y,w,h; |
1615 | x= 0; | 1627 | x= 0; |
1616 | y= 0; | 1628 | y= 0; |
1617 | w = colWid; | 1629 | w = colWid; |
1618 | h = dayLabelHei ; | 1630 | h = dayLabelHei ; |
1619 | for ( i = 0; i < 7; i++) { | 1631 | for ( i = 0; i < 7; i++) { |
1620 | if ( i && !( i % daysToShow) && i < 6) { | 1632 | if ( i && !( i % daysToShow) && i < 6) { |
1621 | y += hei/(5-daysToShow); | 1633 | y += hei/(5-daysToShow); |
1622 | x = 0; | 1634 | x = 0; |
1623 | w = colWid; | 1635 | w = colWid; |
1624 | } | 1636 | } |
1625 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1637 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1626 | ++w; | 1638 | ++w; |
1627 | } | 1639 | } |
1628 | if ( i >= 5 ) { | 1640 | if ( i >= 5 ) { |
1629 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1641 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1630 | x -= (w/2 ); | 1642 | x -= (w/2 ); |
1631 | } | 1643 | } |
1632 | else | 1644 | else |
1633 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1645 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1634 | x += w; | 1646 | x += w; |
1635 | } | 1647 | } |
1636 | x= 0; | 1648 | x= 0; |
1637 | y= dayLabelHei; | 1649 | y= dayLabelHei; |
1638 | w = colWid; | 1650 | w = colWid; |
1639 | h = cellHei; | 1651 | h = cellHei; |
1640 | int max = 0; | 1652 | int max = 0; |
1641 | for ( i = 0; i < mCellsW.count(); ++i) { | 1653 | for ( i = 0; i < mCellsW.count(); ++i) { |
1642 | if ( i > 6 ) { | 1654 | if ( i > 6 ) { |
1643 | mCellsW[i]->hide(); | 1655 | mCellsW[i]->hide(); |
1644 | continue; | 1656 | continue; |
1645 | } | 1657 | } |
1646 | 1658 | ||
1647 | w = colWid; | 1659 | w = colWid; |
1648 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1660 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1649 | ++w; | 1661 | ++w; |
1650 | } | 1662 | } |
1651 | if ( i == (daysToShow-1-rowModulo)*7) | 1663 | if ( i == (daysToShow-1-rowModulo)*7) |
1652 | ++h; | 1664 | ++h; |
1653 | 1665 | ||
1654 | if ( i >= 5 ) { | 1666 | if ( i >= 5 ) { |
1655 | if ( i ==5 ) { | 1667 | if ( i ==5 ) { |
1656 | max = h/2; | 1668 | max = h/2; |
1657 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1669 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1658 | x -= w ;y += h/2; | 1670 | x -= w ;y += h/2; |
1659 | } else { | 1671 | } else { |
1660 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1672 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1661 | ++w; | 1673 | ++w; |
1662 | } | 1674 | } |
1663 | max = h-h/2; | 1675 | max = h-h/2; |
1664 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1676 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1665 | y -= h/2; | 1677 | y -= h/2; |
1666 | } | 1678 | } |
1667 | } else { | 1679 | } else { |
1668 | max = h; | 1680 | max = h; |
1669 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1681 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1670 | } | 1682 | } |
1671 | 1683 | ||
1672 | 1684 | ||
1673 | x += w; | 1685 | x += w; |
1674 | if ( x + w/2 > wid ) { | 1686 | if ( x + w/2 > wid ) { |
1675 | x = 0; | 1687 | x = 0; |
1676 | y += h+dayLabelHei ; | 1688 | y += h+dayLabelHei ; |
1677 | } | 1689 | } |
1678 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1690 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1679 | } | 1691 | } |
1680 | y= dayLabelHei; | 1692 | y= dayLabelHei; |
1681 | h = cellHei ; | 1693 | h = cellHei ; |
1682 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1694 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1683 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1695 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1684 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1696 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1685 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1697 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1686 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1698 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1687 | updateDayLabels(); | 1699 | updateDayLabels(); |
1688 | //bool forceUpdate = !updatePossible; | 1700 | //bool forceUpdate = !updatePossible; |
1689 | updatePossible = true; | 1701 | updatePossible = true; |
1690 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1702 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1691 | //if ( forceUpdate ) | 1703 | //if ( forceUpdate ) |
1692 | // updateView(); | 1704 | // updateView(); |
1693 | } | 1705 | } |
1694 | void KOMonthView::computeLayout() | 1706 | void KOMonthView::computeLayout() |
1695 | { | 1707 | { |
1696 | 1708 | ||
1697 | 1709 | ||
1698 | static int lastWid = 0; | 1710 | static int lastWid = 0; |
1699 | static int lastHei = 0; | 1711 | static int lastHei = 0; |
1700 | 1712 | ||
1701 | if ( mShowWeekView ){ | 1713 | if ( mShowWeekView ){ |
1702 | computeLayoutWeek(); | 1714 | computeLayoutWeek(); |
1703 | return; | 1715 | return; |
1704 | } | 1716 | } |
1705 | int daysToShow = 7; | 1717 | int daysToShow = 7; |
1706 | bool combinedSatSun = false; | 1718 | bool combinedSatSun = false; |
1707 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1719 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1708 | daysToShow = 6; | 1720 | daysToShow = 6; |
1709 | combinedSatSun = true; | 1721 | combinedSatSun = true; |
1710 | } | 1722 | } |
1711 | int tWid = topLevelWidget()->size().width(); | 1723 | int tWid = topLevelWidget()->size().width(); |
1712 | int tHei = topLevelWidget()->size().height(); | 1724 | int tHei = topLevelWidget()->size().height(); |
1713 | 1725 | ||
1714 | int wid = width();//e | 1726 | int wid = width();//e |
1715 | int hei = height()-1-mNavigatorBar->height(); | 1727 | int hei = height()-1-mNavigatorBar->height(); |
1716 | 1728 | ||
1717 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1729 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1718 | return; | 1730 | return; |
1719 | } | 1731 | } |
1720 | if ( lastWid == width() && lastHei == height() ){ | 1732 | if ( lastWid == width() && lastHei == height() ){ |
1721 | //qDebug("KOMonthview::No compute layout needed "); | 1733 | //qDebug("KOMonthview::No compute layout needed "); |
1722 | return; | 1734 | return; |
1723 | } | 1735 | } |
1724 | 1736 | ||
1725 | lastWid = width(); | 1737 | lastWid = width(); |
1726 | lastHei = height(); | 1738 | lastHei = height(); |
1727 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 1739 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
1728 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1740 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1729 | int weeklabelwid = fm.width( "888" ); | 1741 | int weeklabelwid = fm.width( "888" ); |
1730 | wid -= weeklabelwid; | 1742 | wid -= weeklabelwid; |
1731 | 1743 | ||
1732 | int colWid = wid / daysToShow; | 1744 | int colWid = wid / daysToShow; |
1733 | int lastCol = wid - ( colWid*6 ); | 1745 | int lastCol = wid - ( colWid*6 ); |
1734 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1746 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1735 | int cellHei = (hei - dayLabelHei) /6; | 1747 | int cellHei = (hei - dayLabelHei) /6; |
1736 | int colModulo = wid % daysToShow; | 1748 | int colModulo = wid % daysToShow; |
1737 | int rowModulo = (hei- dayLabelHei) % 6; | 1749 | int rowModulo = (hei- dayLabelHei) % 6; |
1738 | //qDebug("rowmod %d ", rowModulo); | 1750 | //qDebug("rowmod %d ", rowModulo); |
1739 | int i; | 1751 | int i; |
1740 | int x,y,w,h; | 1752 | int x,y,w,h; |
1741 | x= 0; | 1753 | x= 0; |
1742 | y= 0; | 1754 | y= 0; |
1743 | w = colWid; | 1755 | w = colWid; |
1744 | h = dayLabelHei ; | 1756 | h = dayLabelHei ; |
1745 | for ( i = 0; i < 7; i++) { | 1757 | for ( i = 0; i < 7; i++) { |
1746 | if ( i == daysToShow-colModulo ) | 1758 | if ( i == daysToShow-colModulo ) |
1747 | ++w; | 1759 | ++w; |
1748 | if ( combinedSatSun ) { | 1760 | if ( combinedSatSun ) { |
1749 | if ( i >= daysToShow-1 ) { | 1761 | if ( i >= daysToShow-1 ) { |
1750 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1762 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1751 | x -= w/2 ; | 1763 | x -= w/2 ; |
1752 | } | 1764 | } |
1753 | else | 1765 | else |
1754 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1766 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1755 | } else | 1767 | } else |
1756 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1768 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1757 | x += w; | 1769 | x += w; |
1758 | } | 1770 | } |
1759 | x= 0; | 1771 | x= 0; |
1760 | y= dayLabelHei; | 1772 | y= dayLabelHei; |
1761 | w = colWid; | 1773 | w = colWid; |
1762 | h = cellHei ; | 1774 | h = cellHei ; |
1763 | int max = 0; | 1775 | int max = 0; |
1764 | for ( i = 0; i < mCells.count(); ++i) { | 1776 | for ( i = 0; i < mCells.count(); ++i) { |
1765 | //qDebug("iii %d ", i); | 1777 | //qDebug("iii %d ", i); |
1766 | w = colWid; | 1778 | w = colWid; |
1767 | if ( ((i) % 7) >= 7-colModulo ) { | 1779 | if ( ((i) % 7) >= 7-colModulo ) { |
1768 | ++w; | 1780 | ++w; |
1769 | } | 1781 | } |
1770 | if ( i == (6-rowModulo)*7) | 1782 | if ( i == (6-rowModulo)*7) |
1771 | ++h; | 1783 | ++h; |
1772 | if ( combinedSatSun ) { | 1784 | if ( combinedSatSun ) { |
1773 | if ( (i)%7 >= daysToShow-1 ) { | 1785 | if ( (i)%7 >= daysToShow-1 ) { |
1774 | if ( (i)%7 == daysToShow-1 ) { | 1786 | if ( (i)%7 == daysToShow-1 ) { |
1775 | max = h/2; | 1787 | max = h/2; |
1776 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1788 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1777 | x -= w ;y += h/2; | 1789 | x -= w ;y += h/2; |
1778 | } else { | 1790 | } else { |
1779 | max = h-h/2; | 1791 | max = h-h/2; |
1780 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1792 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1781 | y -= h/2; | 1793 | y -= h/2; |
1782 | } | 1794 | } |
1783 | } else { | 1795 | } else { |
1784 | max = h; | 1796 | max = h; |
1785 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1797 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1786 | } | 1798 | } |
1787 | 1799 | ||
1788 | } | 1800 | } |
1789 | else { | 1801 | else { |
1790 | max = h; | 1802 | max = h; |
1791 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1803 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1792 | } | 1804 | } |
1793 | x += w; | 1805 | x += w; |
1794 | if ( x + w/2 > wid ) { | 1806 | if ( x + w/2 > wid ) { |
1795 | x = 0; | 1807 | x = 0; |
1796 | y += h; | 1808 | y += h; |
1797 | } | 1809 | } |
1798 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 1810 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
1799 | } | 1811 | } |
1800 | y= dayLabelHei; | 1812 | y= dayLabelHei; |
1801 | h = cellHei ; | 1813 | h = cellHei ; |
1802 | for ( i = 0; i < 6; i++) { | 1814 | for ( i = 0; i < 6; i++) { |
1803 | if ( i == (6-rowModulo)) | 1815 | if ( i == (6-rowModulo)) |
1804 | ++h; | 1816 | ++h; |
1805 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1817 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1806 | y += h; | 1818 | y += h; |
1807 | } | 1819 | } |
1808 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1820 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1809 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1821 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1810 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1822 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1811 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 1823 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
1812 | updateDayLabels(); | 1824 | updateDayLabels(); |
1813 | //bool forceUpdate = !updatePossible; | 1825 | //bool forceUpdate = !updatePossible; |
1814 | updatePossible = true; | 1826 | updatePossible = true; |
1815 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1827 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1816 | } | 1828 | } |
1817 | 1829 | ||
1818 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1830 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1819 | { | 1831 | { |
1820 | mContextMenu->showIncidencePopup(incidence); | 1832 | mContextMenu->showIncidencePopup(incidence); |
1821 | /* | 1833 | /* |
1822 | if( incidence && incidence->type() == "Event" ) { | 1834 | if( incidence && incidence->type() == "Event" ) { |
1823 | Event *event = static_cast<Event *>(incidence); | 1835 | Event *event = static_cast<Event *>(incidence); |
1824 | mContextMenu->showEventPopup(event); | 1836 | mContextMenu->showEventPopup(event); |
1825 | } else { | 1837 | } else { |
1826 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1838 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1827 | } | 1839 | } |
1828 | */ | 1840 | */ |
1829 | } | 1841 | } |
1830 | MonthViewCell * KOMonthView::selectedCell( ) | 1842 | MonthViewCell * KOMonthView::selectedCell( ) |
1831 | { | 1843 | { |
1832 | return mSelectedCell; | 1844 | return mSelectedCell; |
1833 | } | 1845 | } |
1834 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1846 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1835 | { | 1847 | { |
1836 | //qDebug("KOMonthView::setSelectedCell "); | 1848 | //qDebug("KOMonthView::setSelectedCell "); |
1837 | if ( mSelectedCell && mSelectedCell != cell ) { | 1849 | if ( mSelectedCell && mSelectedCell != cell ) { |
1838 | MonthViewCell * mvc = mSelectedCell; | 1850 | MonthViewCell * mvc = mSelectedCell; |
1839 | mSelectedCell = cell; | 1851 | mSelectedCell = cell; |
1840 | mvc->deselect(); | 1852 | mvc->deselect(); |
1841 | } else | 1853 | } else |
1842 | mSelectedCell = cell; | 1854 | mSelectedCell = cell; |
1843 | // if ( mSelectedCell ) | 1855 | // if ( mSelectedCell ) |
1844 | // mSelectedCell->select(); | 1856 | // mSelectedCell->select(); |
1845 | if ( !mSelectedCell ) | 1857 | if ( !mSelectedCell ) |
1846 | emit incidenceSelected( 0 ); | 1858 | emit incidenceSelected( 0 ); |
1847 | else | 1859 | else |
1848 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1860 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1849 | } | 1861 | } |
1850 | 1862 | ||
1851 | void KOMonthView::processSelectionChange() | 1863 | void KOMonthView::processSelectionChange() |
1852 | { | 1864 | { |
1853 | QPtrList<Incidence> incidences = selectedIncidences(); | 1865 | QPtrList<Incidence> incidences = selectedIncidences(); |
1854 | if (incidences.count() > 0) { | 1866 | if (incidences.count() > 0) { |
1855 | emit incidenceSelected( incidences.first() ); | 1867 | emit incidenceSelected( incidences.first() ); |
1856 | } else { | 1868 | } else { |
1857 | emit incidenceSelected( 0 ); | 1869 | emit incidenceSelected( 0 ); |
1858 | clearSelection(); | 1870 | clearSelection(); |
1859 | } | 1871 | } |
1860 | } | 1872 | } |
1861 | 1873 | ||
1862 | void KOMonthView::clearSelection() | 1874 | void KOMonthView::clearSelection() |
1863 | { | 1875 | { |
1864 | if ( mSelectedCell ) { | 1876 | if ( mSelectedCell ) { |
1865 | mSelectedCell->deselect(); | 1877 | mSelectedCell->deselect(); |
1866 | mSelectedCell = 0; | 1878 | mSelectedCell = 0; |
1867 | } | 1879 | } |
1868 | } | 1880 | } |
1869 | 1881 | ||
1870 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 1882 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
1871 | { | 1883 | { |
1872 | if ( !e->isAutoRepeat() ) { | 1884 | if ( !e->isAutoRepeat() ) { |
1873 | mFlagKeyPressed = false; | 1885 | mFlagKeyPressed = false; |
1874 | } | 1886 | } |
1875 | } | 1887 | } |
1876 | 1888 | ||
1877 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1889 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1878 | { | 1890 | { |
1879 | 1891 | ||
1880 | qApp->processEvents(); | 1892 | qApp->processEvents(); |
1881 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1893 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1882 | //e->ignore(); | 1894 | //e->ignore(); |
1883 | e->accept(); | 1895 | e->accept(); |
1884 | return; | 1896 | return; |
1885 | } | 1897 | } |
1886 | if (! e->isAutoRepeat() ) | 1898 | if (! e->isAutoRepeat() ) |
1887 | mFlagKeyPressed = true; | 1899 | mFlagKeyPressed = true; |
1888 | switch(e->key()) { | 1900 | switch(e->key()) { |
1889 | case Key_Up: | 1901 | case Key_Up: |
1890 | { | 1902 | { |
1891 | if ( mShowWeekView ) { | 1903 | if ( mShowWeekView ) { |
1892 | emit selectWeekNum ( currentWeek() - 1 ); | 1904 | emit selectWeekNum ( currentWeek() - 1 ); |
1893 | } | 1905 | } |
1894 | else { | 1906 | else { |
1895 | emit prevMonth(); | 1907 | emit prevMonth(); |
1896 | } | 1908 | } |
1897 | } | 1909 | } |
1898 | e->accept(); | 1910 | e->accept(); |
1899 | break; | 1911 | break; |
1900 | case Key_Down: | 1912 | case Key_Down: |
1901 | { | 1913 | { |
1902 | if ( mShowWeekView ) { | 1914 | if ( mShowWeekView ) { |
1903 | emit selectWeekNum ( currentWeek() +1); | 1915 | emit selectWeekNum ( currentWeek() +1); |
1904 | } | 1916 | } |
1905 | else { | 1917 | else { |
1906 | emit nextMonth(); | 1918 | emit nextMonth(); |
1907 | } | 1919 | } |
1908 | 1920 | ||
1909 | } | 1921 | } |
1910 | e->accept(); | 1922 | e->accept(); |
1911 | break; | 1923 | break; |
1912 | case Key_Return: | 1924 | case Key_Return: |
1913 | case Key_Enter: | 1925 | case Key_Enter: |
1914 | { | 1926 | { |
1915 | selectInternalWeekNum ( currentWeek() ); | 1927 | selectInternalWeekNum ( currentWeek() ); |
1916 | } | 1928 | } |
1917 | e->accept(); | 1929 | e->accept(); |
1918 | break; | 1930 | break; |
1919 | case Key_D: | 1931 | case Key_D: |
1920 | if ( mSelectedCell ) { | 1932 | if ( mSelectedCell ) { |
1921 | mSelectedCell->showDay(); | 1933 | mSelectedCell->showDay(); |
1922 | e->accept(); | 1934 | e->accept(); |
1923 | } else { | 1935 | } else { |
1924 | e->ignore(); | 1936 | e->ignore(); |
1925 | } | 1937 | } |
1926 | break; | 1938 | break; |
1927 | default: | 1939 | default: |
1928 | e->ignore(); | 1940 | e->ignore(); |
1929 | break; | 1941 | break; |
1930 | } | 1942 | } |
1931 | } | 1943 | } |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index e04cdf5..e962756 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,324 +1,325 @@ | |||
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 | void focusInEvent ( QFocusEvent * ){;} | ||
63 | int mNumber; | 64 | int mNumber; |
64 | void keyPressEvent ( QKeyEvent * e ) | 65 | void keyPressEvent ( QKeyEvent * e ) |
65 | { | 66 | { |
66 | e->ignore(); | 67 | e->ignore(); |
67 | } | 68 | } |
68 | 69 | ||
69 | private slots : | 70 | private slots : |
70 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 71 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
71 | }; | 72 | }; |
72 | 73 | ||
73 | class KNoScrollListBox: public QListBox | 74 | class KNoScrollListBox: public QListBox |
74 | { | 75 | { |
75 | Q_OBJECT | 76 | Q_OBJECT |
76 | public: | 77 | public: |
77 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 78 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
78 | ~KNoScrollListBox(); | 79 | ~KNoScrollListBox(); |
79 | QString getWhatsThisText(QPoint p) ; | 80 | QString getWhatsThisText(QPoint p) ; |
80 | 81 | ||
81 | signals: | 82 | signals: |
82 | void shiftDown(); | 83 | void shiftDown(); |
83 | void shiftUp(); | 84 | void shiftUp(); |
84 | void rightClick(); | 85 | void rightClick(); |
85 | 86 | ||
86 | protected slots: | 87 | protected slots: |
87 | void oneDown(); | 88 | void oneDown(); |
88 | void keyPressEvent(QKeyEvent *); | 89 | void keyPressEvent(QKeyEvent *); |
89 | void keyReleaseEvent(QKeyEvent *); | 90 | void keyReleaseEvent(QKeyEvent *); |
90 | void mousePressEvent(QMouseEvent *); | 91 | void mousePressEvent(QMouseEvent *); |
91 | void focusInEvent ( QFocusEvent * ); | 92 | void focusInEvent ( QFocusEvent * ); |
92 | void focusOutEvent ( QFocusEvent * ); | 93 | void focusOutEvent ( QFocusEvent * ); |
93 | 94 | ||
94 | private: | 95 | private: |
95 | bool resetOnFocusIn; | 96 | bool resetOnFocusIn; |
96 | KNOWhatsThis * mWT; | 97 | KNOWhatsThis * mWT; |
97 | }; | 98 | }; |
98 | 99 | ||
99 | 100 | ||
100 | class MonthViewItem: public QListBoxItem | 101 | class MonthViewItem: public QListBoxItem |
101 | { | 102 | { |
102 | public: | 103 | public: |
103 | MonthViewItem( Incidence *, QDate qd, const QString & title ); | 104 | MonthViewItem( Incidence *, QDate qd, const QString & title ); |
104 | void recycle( Incidence *incidence, QDate qd, const QString & s); | 105 | void recycle( Incidence *incidence, QDate qd, const QString & s); |
105 | void setRecur(bool on) { mRecur = on; } | 106 | void setRecur(bool on) { mRecur = on; } |
106 | void setAlarm(bool on) { mAlarm = on; } | 107 | void setAlarm(bool on) { mAlarm = on; } |
107 | void setReply(bool on) { mReply = on; } | 108 | void setReply(bool on) { mReply = on; } |
108 | void setMoreInfo(bool on) { mInfo = on; } | 109 | void setMoreInfo(bool on) { mInfo = on; } |
109 | void setMultiDay(int type) { mMultiday = type; } | 110 | void setMultiDay(int type) { mMultiday = type; } |
110 | void setBlockRepaint(bool on) { mblockRepaint = on; } | 111 | void setBlockRepaint(bool on) { mblockRepaint = on; } |
111 | 112 | ||
112 | 113 | ||
113 | void setPalette(const QPalette &p) { mPalette = p; } | 114 | void setPalette(const QPalette &p) { mPalette = p; } |
114 | QPalette palette() const { return mPalette; } | 115 | QPalette palette() const { return mPalette; } |
115 | 116 | ||
116 | Incidence *incidence() const { return mIncidence; } | 117 | Incidence *incidence() const { return mIncidence; } |
117 | QDate incidenceDate() { return mDate; } | 118 | QDate incidenceDate() { return mDate; } |
118 | 119 | ||
119 | protected: | 120 | protected: |
120 | virtual void paint(QPainter *); | 121 | virtual void paint(QPainter *); |
121 | virtual int height(const QListBox *) const; | 122 | virtual int height(const QListBox *) const; |
122 | virtual int width(const QListBox *) const; | 123 | virtual int width(const QListBox *) const; |
123 | 124 | ||
124 | private: | 125 | private: |
126 | bool isWeekItem; | ||
125 | bool mblockRepaint; | 127 | bool mblockRepaint; |
126 | int mMultiday; | 128 | int mMultiday; |
127 | bool mRecur; | 129 | bool mRecur; |
128 | bool mAlarm; | 130 | bool mAlarm; |
129 | bool mReply; | 131 | bool mReply; |
130 | bool mInfo; | 132 | bool mInfo; |
131 | 133 | ||
132 | QPalette mPalette; | 134 | QPalette mPalette; |
133 | QDate mDate; | 135 | QDate mDate; |
134 | 136 | ||
135 | Incidence *mIncidence; | 137 | Incidence *mIncidence; |
136 | }; | 138 | }; |
137 | 139 | ||
138 | 140 | ||
139 | class KOMonthView; | 141 | class KOMonthView; |
140 | 142 | ||
141 | class MonthViewCell : public KNoScrollListBox | 143 | class MonthViewCell : public KNoScrollListBox |
142 | { | 144 | { |
143 | Q_OBJECT | 145 | Q_OBJECT |
144 | public: | 146 | public: |
145 | MonthViewCell(KOMonthView *,QWidget* ); | 147 | MonthViewCell(KOMonthView *,QWidget* ); |
146 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} | 148 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} |
147 | 149 | ||
148 | void setDate( const QDate & ); | 150 | void setDate( const QDate & ); |
149 | QDate date() const; | 151 | QDate date() const; |
150 | 152 | ||
151 | void setPrimary( bool ); | 153 | void setPrimary( bool ); |
152 | bool isPrimary() const; | 154 | bool isPrimary() const; |
153 | 155 | ||
154 | void setHoliday( bool ); | 156 | void setHoliday( bool ); |
155 | void setHoliday( const QString & ); | 157 | void setHoliday( const QString & ); |
156 | 158 | ||
157 | void updateCell(); | 159 | void updateCell(); |
158 | void startUpdateCell(); | 160 | void startUpdateCell(); |
159 | void finishUpdateCell(); | 161 | void finishUpdateCell(); |
160 | void repaintfinishUpdateCell(); | 162 | void repaintfinishUpdateCell(); |
161 | void insertEvent(Event *); | 163 | void insertEvent(Event *); |
162 | void insertTodo(Todo *); | 164 | void insertTodo(Todo *); |
163 | 165 | ||
164 | void updateConfig( bool bigFont = false ); | 166 | void updateConfig( bool bigFont = false ); |
165 | 167 | ||
166 | void enableScrollBars( bool ); | 168 | void enableScrollBars( bool ); |
167 | 169 | ||
168 | Incidence *selectedIncidence(); | 170 | Incidence *selectedIncidence(); |
169 | QDate selectedIncidenceDate(); | 171 | QDate selectedIncidenceDate(); |
170 | QPushButton * dateLabel() { return mLabel; } | 172 | QPushButton * dateLabel() { return mLabel; } |
171 | 173 | ||
172 | void deselect(); | 174 | void deselect(); |
173 | void select(); | 175 | void select(); |
174 | #ifdef DESKTOP_VERSION | 176 | #ifdef DESKTOP_VERSION |
175 | static QToolTipGroup *toolTipGroup(); | 177 | static QToolTipGroup *toolTipGroup(); |
176 | #endif | 178 | #endif |
177 | signals: | 179 | signals: |
178 | void defaultAction( Incidence * ); | 180 | void defaultAction( Incidence * ); |
179 | void newEventSignal( QDateTime ); | 181 | void newEventSignal( QDateTime ); |
180 | void showDaySignal( QDate ); | 182 | void showDaySignal( QDate ); |
181 | 183 | ||
182 | protected: | 184 | protected: |
183 | QStringList mToolTip; | 185 | QStringList mToolTip; |
184 | void resizeEvent( QResizeEvent * ); | 186 | void resizeEvent( QResizeEvent * ); |
185 | 187 | ||
186 | 188 | ||
187 | public slots: | 189 | public slots: |
188 | void showDay(); | 190 | void showDay(); |
189 | 191 | ||
190 | protected slots: | 192 | protected slots: |
191 | void defaultAction( QListBoxItem * ); | 193 | void defaultAction( QListBoxItem * ); |
192 | void contextMenu( QListBoxItem * ); | 194 | void contextMenu( QListBoxItem * ); |
193 | void selection( QListBoxItem * ); | 195 | void selection( QListBoxItem * ); |
194 | void cellClicked( QListBoxItem * ); | 196 | void cellClicked( QListBoxItem * ); |
195 | void newEvent(); | 197 | void newEvent(); |
196 | 198 | ||
197 | private: | 199 | private: |
198 | MonthViewItem* mCurrentAvailItem; | ||
199 | QPtrList <MonthViewItem> mAvailItemList; | 200 | QPtrList <MonthViewItem> mAvailItemList; |
200 | KOMonthView *mMonthView; | 201 | KOMonthView *mMonthView; |
201 | int currentPalette; | 202 | int currentPalette; |
202 | 203 | ||
203 | QDate mDate; | 204 | QDate mDate; |
204 | bool mPrimary; | 205 | bool mPrimary; |
205 | bool mHoliday; | 206 | bool mHoliday; |
206 | QString mHolidayString; | 207 | QString mHolidayString; |
207 | 208 | ||
208 | //QLabel *mLabel; | 209 | //QLabel *mLabel; |
209 | QPushButton *mLabel; | 210 | QPushButton *mLabel; |
210 | //QListBox *mItemList; | 211 | //QListBox *mItemList; |
211 | #ifdef DESKTOP_VERSION | 212 | #ifdef DESKTOP_VERSION |
212 | static QToolTipGroup *mToolTipGroup; | 213 | static QToolTipGroup *mToolTipGroup; |
213 | #endif | 214 | #endif |
214 | QSize mLabelSize; | 215 | QSize mLabelSize; |
215 | QSize mLabelBigSize; | 216 | QSize mLabelBigSize; |
216 | QPalette mHolidayPalette; | 217 | QPalette mHolidayPalette; |
217 | QPalette mStandardPalette; | 218 | QPalette mStandardPalette; |
218 | QPalette mPrimaryPalette; | 219 | QPalette mPrimaryPalette; |
219 | QPalette mNonPrimaryPalette; | 220 | QPalette mNonPrimaryPalette; |
220 | void setMyPalette(); | 221 | void setMyPalette(); |
221 | QPalette getPalette (); | 222 | QPalette getPalette (); |
222 | 223 | ||
223 | }; | 224 | }; |
224 | 225 | ||
225 | 226 | ||
226 | class KOMonthView: public KOEventView | 227 | class KOMonthView: public KOEventView |
227 | { | 228 | { |
228 | Q_OBJECT | 229 | Q_OBJECT |
229 | public: | 230 | public: |
230 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 231 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
231 | ~KOMonthView(); | 232 | ~KOMonthView(); |
232 | 233 | ||
233 | /** Returns maximum number of days supported by the komonthview */ | 234 | /** Returns maximum number of days supported by the komonthview */ |
234 | virtual int maxDatesHint(); | 235 | virtual int maxDatesHint(); |
235 | 236 | ||
236 | /** Returns number of currently shown dates. */ | 237 | /** Returns number of currently shown dates. */ |
237 | virtual int currentDateCount(); | 238 | virtual int currentDateCount(); |
238 | 239 | ||
239 | /** returns the currently selected events */ | 240 | /** returns the currently selected events */ |
240 | virtual QPtrList<Incidence> selectedIncidences(); | 241 | virtual QPtrList<Incidence> selectedIncidences(); |
241 | 242 | ||
242 | /** returns dates of the currently selected events */ | 243 | /** returns dates of the currently selected events */ |
243 | virtual DateList selectedDates(); | 244 | virtual DateList selectedDates(); |
244 | 245 | ||
245 | virtual void printPreview(CalPrinter *calPrinter, | 246 | virtual void printPreview(CalPrinter *calPrinter, |
246 | const QDate &, const QDate &); | 247 | const QDate &, const QDate &); |
247 | bool isMonthView() { return !mShowWeekView; } | 248 | bool isMonthView() { return !mShowWeekView; } |
248 | bool isUpdatePossible() { return updatePossible; } | 249 | bool isUpdatePossible() { return updatePossible; } |
249 | 250 | ||
250 | MonthViewCell * selectedCell(); | 251 | MonthViewCell * selectedCell(); |
251 | bool skipResize; | 252 | bool skipResize; |
252 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} | 253 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} |
253 | public slots: | 254 | public slots: |
254 | virtual void updateView(); | 255 | virtual void updateView(); |
255 | virtual void updateConfig(); | 256 | virtual void updateConfig(); |
256 | virtual void showDates(const QDate &start, const QDate &end); | 257 | virtual void showDates(const QDate &start, const QDate &end); |
257 | virtual void showEvents(QPtrList<Event> eventList); | 258 | virtual void showEvents(QPtrList<Event> eventList); |
258 | 259 | ||
259 | void changeEventDisplay(Event *, int); | 260 | void changeEventDisplay(Event *, int); |
260 | 261 | ||
261 | void clearSelection(); | 262 | void clearSelection(); |
262 | 263 | ||
263 | void showContextMenu( Incidence * ); | 264 | void showContextMenu( Incidence * ); |
264 | 265 | ||
265 | void setSelectedCell( MonthViewCell * ); | 266 | void setSelectedCell( MonthViewCell * ); |
266 | void switchView(); | 267 | void switchView(); |
267 | void setKeyBoardFocus(); | 268 | void setKeyBoardFocus(); |
268 | void setKeyBFocus(); | 269 | void setKeyBFocus(); |
269 | 270 | ||
270 | protected slots: | 271 | protected slots: |
271 | void slotComputeLayout(); | 272 | void slotComputeLayout(); |
272 | void selectInternalWeekNum ( int ); | 273 | void selectInternalWeekNum ( int ); |
273 | void processSelectionChange(); | 274 | void processSelectionChange(); |
274 | signals: | 275 | signals: |
275 | void nextMonth(); | 276 | void nextMonth(); |
276 | void prevMonth(); | 277 | void prevMonth(); |
277 | void selectWeekNum ( int ); | 278 | void selectWeekNum ( int ); |
278 | void selectMonth (); | 279 | void selectMonth (); |
279 | void showDaySignal( QDate ); | 280 | void showDaySignal( QDate ); |
280 | protected: | 281 | protected: |
281 | void resizeEvent(QResizeEvent *); | 282 | void resizeEvent(QResizeEvent *); |
282 | void viewChanged(); | 283 | void viewChanged(); |
283 | void updateDayLabels(); | 284 | void updateDayLabels(); |
284 | 285 | ||
285 | private: | 286 | private: |
286 | QTimer* mComputeLayoutTimer; | 287 | QTimer* mComputeLayoutTimer; |
287 | NavigatorBar* mNavigatorBar; | 288 | NavigatorBar* mNavigatorBar; |
288 | int currentWeek(); | 289 | int currentWeek(); |
289 | bool clPending; | 290 | bool clPending; |
290 | QWidgetStack * mWidStack; | 291 | QWidgetStack * mWidStack; |
291 | QWidget* mMonthView; | 292 | QWidget* mMonthView; |
292 | QWidget* mWeekView; | 293 | QWidget* mWeekView; |
293 | bool mShowWeekView; | 294 | bool mShowWeekView; |
294 | bool updatePossible; | 295 | bool updatePossible; |
295 | int mDaysPerWeek; | 296 | int mDaysPerWeek; |
296 | int mNumWeeks; | 297 | int mNumWeeks; |
297 | int mNumCells; | 298 | int mNumCells; |
298 | //bool mWeekStartsMonday; | 299 | //bool mWeekStartsMonday; |
299 | bool mShowSatSunComp; | 300 | bool mShowSatSunComp; |
300 | void computeLayout(); | 301 | void computeLayout(); |
301 | void computeLayoutWeek(); | 302 | void computeLayoutWeek(); |
302 | 303 | ||
303 | QPtrVector<MonthViewCell> mCells; | 304 | QPtrVector<MonthViewCell> mCells; |
304 | QPtrVector<QLabel> mDayLabels; | 305 | QPtrVector<QLabel> mDayLabels; |
305 | QPtrVector<KOWeekButton> mWeekLabels; | 306 | QPtrVector<KOWeekButton> mWeekLabels; |
306 | QPtrVector<MonthViewCell> mCellsW; | 307 | QPtrVector<MonthViewCell> mCellsW; |
307 | QPtrVector<QLabel> mDayLabelsW; | 308 | QPtrVector<QLabel> mDayLabelsW; |
308 | QPtrVector<KOWeekButton> mWeekLabelsW; | 309 | QPtrVector<KOWeekButton> mWeekLabelsW; |
309 | 310 | ||
310 | bool mShortDayLabelsM; | 311 | bool mShortDayLabelsM; |
311 | bool mShortDayLabelsW; | 312 | bool mShortDayLabelsW; |
312 | int mWidthLongDayLabel; | 313 | int mWidthLongDayLabel; |
313 | 314 | ||
314 | QDate mStartDate; | 315 | QDate mStartDate; |
315 | 316 | ||
316 | MonthViewCell *mSelectedCell; | 317 | MonthViewCell *mSelectedCell; |
317 | bool mFlagKeyPressed; | 318 | bool mFlagKeyPressed; |
318 | KOEventPopupMenu *mContextMenu; | 319 | KOEventPopupMenu *mContextMenu; |
319 | void keyPressEvent ( QKeyEvent * ) ; | 320 | void keyPressEvent ( QKeyEvent * ) ; |
320 | void keyReleaseEvent ( QKeyEvent * ) ; | 321 | void keyReleaseEvent ( QKeyEvent * ) ; |
321 | 322 | ||
322 | }; | 323 | }; |
323 | 324 | ||
324 | #endif | 325 | #endif |