author | zautrix <zautrix> | 2005-06-28 07:40:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-28 07:40:22 (UTC) |
commit | 4385e73c51688f0b8b21bfe061c04a6c42e92701 (patch) (unidiff) | |
tree | cc55a5cdfa999b9e285d37116901f4c0a2357b20 /korganizer | |
parent | 386f48c2011e49c7c145bad7754a725cabc25dd5 (diff) | |
download | kdepimpi-4385e73c51688f0b8b21bfe061c04a6c42e92701.zip kdepimpi-4385e73c51688f0b8b21bfe061c04a6c42e92701.tar.gz kdepimpi-4385e73c51688f0b8b21bfe061c04a6c42e92701.tar.bz2 |
fixx
-rw-r--r-- | korganizer/komonthview.cpp | 44 | ||||
-rw-r--r-- | korganizer/komonthview.h | 8 |
2 files changed, 26 insertions, 26 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 64b0e95..1c2d6a2 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,532 +1,532 @@ | |||
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); | 87 | setVScrollBarMode(QScrollView::AlwaysOff); |
88 | setHScrollBarMode(QScrollView::AlwaysOff); | 88 | setHScrollBarMode(QScrollView::AlwaysOff); |
89 | } | 89 | } |
90 | KNoScrollListBox::~KNoScrollListBox() | 90 | KNoScrollListBox::~KNoScrollListBox() |
91 | { | 91 | { |
92 | #if QT_VERSION >= 0x030000 | 92 | #if QT_VERSION >= 0x030000 |
93 | 93 | ||
94 | #else | 94 | #else |
95 | delete mWT; | 95 | delete mWT; |
96 | #endif | 96 | #endif |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
101 | { | 101 | { |
102 | QListBox::focusInEvent ( e ); | 102 | QListBox::focusInEvent ( e ); |
103 | if ( count() ){ | 103 | if ( count() ){ |
104 | int ci = currentItem(); | 104 | int ci = currentItem(); |
105 | if ( ci < 0 ) ci = 0; | 105 | if ( ci < 0 ) ci = 0; |
106 | 106 | ||
107 | setCurrentItem( ci ); | 107 | setCurrentItem( ci ); |
108 | setSelected ( ci, true ); | 108 | setSelected ( ci, true ); |
109 | emit highlighted( item ( ci ) ); | 109 | emit highlighted( item ( ci ) ); |
110 | 110 | ||
111 | resetOnFocusIn = true; | 111 | resetOnFocusIn = true; |
112 | 112 | ||
113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
114 | QListBoxItem *fi = firstItem (); | 114 | QListBoxItem *fi = firstItem (); |
115 | if (fi ) { | 115 | if (fi ) { |
116 | int ihei = fi->height( this ); | 116 | int ihei = fi->height( this ); |
117 | int hei = numRows () * ihei; | 117 | int hei = numRows () * ihei; |
118 | if ( hei < height() - horizontalScrollBar()->height () ) { | 118 | if ( hei < height() - horizontalScrollBar()->height () ) { |
119 | setVScrollBarMode(QScrollView::AlwaysOff); | 119 | setVScrollBarMode(QScrollView::AlwaysOff); |
120 | } | 120 | } |
121 | else | 121 | else |
122 | setVScrollBarMode(QScrollView::Auto); | 122 | setVScrollBarMode(QScrollView::Auto); |
123 | if ( ihei *3 > height() ) { | 123 | if ( ihei *3 > height() ) { |
124 | setHScrollBarMode(QScrollView::AlwaysOff); | 124 | setHScrollBarMode(QScrollView::AlwaysOff); |
125 | } | 125 | } |
126 | else { | 126 | else { |
127 | setHScrollBarMode(QScrollView::Auto); | 127 | setHScrollBarMode(QScrollView::Auto); |
128 | } | 128 | } |
129 | } else { | 129 | } else { |
130 | setVScrollBarMode(QScrollView::Auto); | 130 | setVScrollBarMode(QScrollView::Auto); |
131 | setHScrollBarMode(QScrollView::Auto); | 131 | setHScrollBarMode(QScrollView::Auto); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
137 | { | 137 | { |
138 | int i = currentItem (); | 138 | int i = currentItem (); |
139 | if ( i >= 0 ) { | 139 | if ( i >= 0 ) { |
140 | setSelected ( i, false ); | 140 | setSelected ( i, false ); |
141 | } | 141 | } |
142 | QListBox::focusOutEvent ( e ); | 142 | QListBox::focusOutEvent ( e ); |
143 | setVScrollBarMode(QScrollView::AlwaysOff); | 143 | setVScrollBarMode(QScrollView::AlwaysOff); |
144 | setHScrollBarMode(QScrollView::AlwaysOff); | 144 | setHScrollBarMode(QScrollView::AlwaysOff); |
145 | emit highligtIncidence( 0, (MonthViewCell*)this, 0 ); | 145 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); |
146 | } | 146 | } |
147 | 147 | ||
148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
149 | { | 149 | { |
150 | QListBoxItem* item = itemAt ( p ); | 150 | QListBoxItem* item = itemAt ( p ); |
151 | if ( ! item ) { | 151 | if ( ! item ) { |
152 | return i18n("Click in the cell\nto add an event!"); | 152 | return i18n("Click in the cell\nto add an event!"); |
153 | } | 153 | } |
154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
155 | KOPrefs::instance()->mWTshowDetails, | 155 | KOPrefs::instance()->mWTshowDetails, |
156 | KOPrefs::instance()->mWTshowCreated, | 156 | KOPrefs::instance()->mWTshowCreated, |
157 | KOPrefs::instance()->mWTshowChanged); | 157 | KOPrefs::instance()->mWTshowChanged); |
158 | } | 158 | } |
159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
160 | { | 160 | { |
161 | //qDebug("KNoScrollListBox::keyPressEvent "); | 161 | //qDebug("KNoScrollListBox::keyPressEvent "); |
162 | switch(e->key()) { | 162 | switch(e->key()) { |
163 | case Key_Right: | 163 | case Key_Right: |
164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
165 | { | 165 | { |
166 | e->ignore(); | 166 | e->ignore(); |
167 | return; | 167 | return; |
168 | } | 168 | } |
169 | scrollBy(10,0); | 169 | scrollBy(10,0); |
170 | break; | 170 | break; |
171 | case Key_Left: | 171 | case Key_Left: |
172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
173 | { | 173 | { |
174 | e->ignore(); | 174 | e->ignore(); |
175 | return; | 175 | return; |
176 | } | 176 | } |
177 | scrollBy(-10,0); | 177 | scrollBy(-10,0); |
178 | break; | 178 | break; |
179 | case Key_Up: | 179 | case Key_Up: |
180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
181 | e->ignore(); | 181 | e->ignore(); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | if ( count() ) { | 184 | if ( count() ) { |
185 | if ( currentItem() == 0 ) { | 185 | if ( currentItem() == 0 ) { |
186 | emit prevCell(); | 186 | emit prevCell(); |
187 | } else { | 187 | } else { |
188 | setCurrentItem((currentItem()+count()-1)%count()); | 188 | setCurrentItem((currentItem()+count()-1)%count()); |
189 | if(!itemVisible(currentItem())) { | 189 | if(!itemVisible(currentItem())) { |
190 | if((unsigned int) currentItem() == (count()-1)) { | 190 | if((unsigned int) currentItem() == (count()-1)) { |
191 | setTopItem(currentItem()-numItemsVisible()+1); | 191 | setTopItem(currentItem()-numItemsVisible()+1); |
192 | } else { | 192 | } else { |
193 | setTopItem(topItem()-1); | 193 | setTopItem(topItem()-1); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | break; | 198 | break; |
199 | case Key_Down: | 199 | case Key_Down: |
200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
201 | e->ignore(); | 201 | e->ignore(); |
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | if ( count () ) { | 204 | if ( count () ) { |
205 | if ( currentItem()+1 == count () ) { | 205 | if ( currentItem()+1 == count () ) { |
206 | emit nextCell(); | 206 | emit nextCell(); |
207 | } else { | 207 | } else { |
208 | setCurrentItem((currentItem()+1)%count()); | 208 | setCurrentItem((currentItem()+1)%count()); |
209 | if(!itemVisible(currentItem())) { | 209 | if(!itemVisible(currentItem())) { |
210 | if(currentItem() == 0) { | 210 | if(currentItem() == 0) { |
211 | setTopItem(0); | 211 | setTopItem(0); |
212 | } else { | 212 | } else { |
213 | setTopItem(topItem()+1); | 213 | setTopItem(topItem()+1); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | } | 217 | } |
218 | break; | 218 | break; |
219 | case Key_I: | 219 | case Key_I: |
220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
221 | e->ignore(); | 221 | e->ignore(); |
222 | break; | 222 | break; |
223 | case Key_Return: | 223 | case Key_Return: |
224 | case Key_Enter: | 224 | case Key_Enter: |
225 | { | 225 | { |
226 | if ( currentItem() >= 0 ) { | 226 | if ( currentItem() >= 0 ) { |
227 | emit doubleClicked( item( currentItem() ) ); | 227 | emit doubleClicked( item( currentItem() ) ); |
228 | e->accept(); | 228 | e->accept(); |
229 | } else { | 229 | } else { |
230 | e->ignore(); | 230 | e->ignore(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | case Key_Shift: | 234 | case Key_Shift: |
235 | emit shiftDown(); | 235 | emit shiftDown(); |
236 | break; | 236 | break; |
237 | default: | 237 | default: |
238 | e->ignore(); | 238 | e->ignore(); |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | void KNoScrollListBox::oneDown() | 243 | void KNoScrollListBox::oneDown() |
244 | { | 244 | { |
245 | if ( count () ) { | 245 | if ( count () ) { |
246 | if ( currentItem()+1 == count () ) { | 246 | if ( currentItem()+1 == count () ) { |
247 | emit nextCell(); | 247 | emit nextCell(); |
248 | } else { | 248 | } else { |
249 | resetOnFocusIn = false; | 249 | resetOnFocusIn = false; |
250 | setCurrentItem((currentItem()+1)%count()); | 250 | setCurrentItem((currentItem()+1)%count()); |
251 | if(!itemVisible(currentItem())) { | 251 | if(!itemVisible(currentItem())) { |
252 | if(currentItem() == 0) { | 252 | if(currentItem() == 0) { |
253 | setTopItem(0); | 253 | setTopItem(0); |
254 | } else { | 254 | } else { |
255 | setTopItem(topItem()+1); | 255 | setTopItem(topItem()+1); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | } | 260 | } |
261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
262 | { | 262 | { |
263 | switch(e->key()) { | 263 | switch(e->key()) { |
264 | case Key_Shift: | 264 | case Key_Shift: |
265 | emit shiftUp(); | 265 | emit shiftUp(); |
266 | break; | 266 | break; |
267 | default: | 267 | default: |
268 | break; | 268 | break; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
273 | { | 273 | { |
274 | QListBox::mousePressEvent(e); | 274 | QListBox::mousePressEvent(e); |
275 | 275 | ||
276 | if(e->button() == RightButton) { | 276 | if(e->button() == RightButton) { |
277 | emit rightClick(); | 277 | emit rightClick(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) | 281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) |
282 | : QListBoxItem() | 282 | : QListBoxItem() |
283 | { | 283 | { |
284 | mblockRepaint = true; | 284 | mblockRepaint = true; |
285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
286 | recycle( incidence, s ); | 286 | recycle( incidence, s ); |
287 | } | 287 | } |
288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) | 288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) |
289 | { | 289 | { |
290 | mDisplayHightlighted = false; | 290 | mDisplayHighlighted = false; |
291 | setText( s ); | 291 | setText( s ); |
292 | mMultiday = 0; | 292 | mMultiday = 0; |
293 | mIncidence = incidence; | 293 | mIncidence = incidence; |
294 | mRecur = false; | 294 | mRecur = false; |
295 | mAlarm = false; | 295 | mAlarm = false; |
296 | mReply = false; | 296 | mReply = false; |
297 | mInfo = false; | 297 | mInfo = false; |
298 | mdayPos = 0; | 298 | mdayPos = 0; |
299 | } | 299 | } |
300 | 300 | ||
301 | bool MonthViewItem::setHighlightedFalse() | 301 | bool MonthViewItem::setHighlightedFalse() |
302 | { | 302 | { |
303 | if ( !mDisplayHightlighted ) | 303 | if ( !mDisplayHighlighted ) |
304 | return false; | 304 | return false; |
305 | mDisplayHightlighted = false; | 305 | mDisplayHighlighted = false; |
306 | return true; | 306 | return true; |
307 | } | 307 | } |
308 | 308 | ||
309 | bool MonthViewItem::setHighlighted( Incidence * inc ) | 309 | bool MonthViewItem::setHighlighted( Incidence * inc ) |
310 | { | 310 | { |
311 | if ( inc == mIncidence ) { | 311 | if ( inc == mIncidence ) { |
312 | if ( mDisplayHightlighted ) | 312 | if ( mDisplayHighlighted ) |
313 | return false; | 313 | return false; |
314 | mDisplayHightlighted = true; | 314 | mDisplayHighlighted = true; |
315 | return true; | 315 | return true; |
316 | } else { | 316 | } else { |
317 | if ( !mDisplayHightlighted ) | 317 | if ( !mDisplayHighlighted ) |
318 | return false; | 318 | return false; |
319 | mDisplayHightlighted = false; | 319 | mDisplayHighlighted = false; |
320 | return true; | 320 | return true; |
321 | } | 321 | } |
322 | return false; | 322 | return false; |
323 | } | 323 | } |
324 | void MonthViewItem::paint(QPainter *p) | 324 | void MonthViewItem::paint(QPainter *p) |
325 | { | 325 | { |
326 | if ( mblockRepaint || !mIncidence ) { | 326 | if ( mblockRepaint || !mIncidence ) { |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | #if QT_VERSION >= 0x030000 | 329 | #if QT_VERSION >= 0x030000 |
330 | bool sel = isSelected(); | 330 | bool sel = isSelected(); |
331 | #else | 331 | #else |
332 | bool sel = selected(); | 332 | bool sel = selected(); |
333 | #endif | 333 | #endif |
334 | int heihei = height( listBox () ); | 334 | int heihei = height( listBox () ); |
335 | int x = 1; | 335 | int x = 1; |
336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted || sel ) | 336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) |
337 | { | 337 | { |
338 | 338 | ||
339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
340 | sel ||mDisplayHightlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); | 340 | sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); |
341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); | 341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); |
342 | } | 342 | } |
343 | 343 | ||
344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
345 | int size = PIXMAP_SIZE; | 345 | int size = PIXMAP_SIZE; |
346 | if ( QApplication::desktop()->width() < 300 ) | 346 | if ( QApplication::desktop()->width() < 300 ) |
347 | size = 3; | 347 | size = 3; |
348 | int y = (heihei - size -1 ) /2; | 348 | int y = (heihei - size -1 ) /2; |
349 | 349 | ||
350 | if ( mIncidence->calID() > 1 ) { | 350 | if ( mIncidence->calID() > 1 ) { |
351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
352 | p->drawRect ( x, y-2,size,size+4); | 352 | p->drawRect ( x, y-2,size,size+4); |
353 | x += size + 1; | 353 | x += size + 1; |
354 | } | 354 | } |
355 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 355 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
356 | if ( mInfo ) { | 356 | if ( mInfo ) { |
357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
358 | x += size + 1; | 358 | x += size + 1; |
359 | } | 359 | } |
360 | if ( mRecur ) { | 360 | if ( mRecur ) { |
361 | p->fillRect ( x, y,size,size, Qt::blue ); | 361 | p->fillRect ( x, y,size,size, Qt::blue ); |
362 | x += size + 1; | 362 | x += size + 1; |
363 | } | 363 | } |
364 | if ( mAlarm ) { | 364 | if ( mAlarm ) { |
365 | p->fillRect ( x, y,size,size, Qt::red ); | 365 | p->fillRect ( x, y,size,size, Qt::red ); |
366 | x += size + 1; | 366 | x += size + 1; |
367 | } | 367 | } |
368 | if ( mReply ) { | 368 | if ( mReply ) { |
369 | p->fillRect ( x, y,size,size, Qt::yellow ); | 369 | p->fillRect ( x, y,size,size, Qt::yellow ); |
370 | x += size + 1; | 370 | x += size + 1; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | if ( mMultiday ) { | 373 | if ( mMultiday ) { |
374 | int yyy = y+(size/2); | 374 | int yyy = y+(size/2); |
375 | int sizeM = size+2; | 375 | int sizeM = size+2; |
376 | p->setBrush( QBrush( p->pen().color() ) ); | 376 | p->setBrush( QBrush( p->pen().color() ) ); |
377 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 377 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
378 | if ( mMultiday == 2 || mMultiday == 3 ) { | 378 | if ( mMultiday == 2 || mMultiday == 3 ) { |
379 | QPointArray pa ( 3 ); | 379 | QPointArray pa ( 3 ); |
380 | pa.setPoint (0, x, yyy ); | 380 | pa.setPoint (0, x, yyy ); |
381 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 381 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
382 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 382 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
383 | p->drawPolygon( pa ); | 383 | p->drawPolygon( pa ); |
384 | } | 384 | } |
385 | if ( mMultiday == 2 || mMultiday == 1 ) { | 385 | if ( mMultiday == 2 || mMultiday == 1 ) { |
386 | QPointArray pa ( 3 ); | 386 | QPointArray pa ( 3 ); |
387 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 387 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
388 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 388 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
389 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 389 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
390 | p->drawPolygon( pa ); | 390 | p->drawPolygon( pa ); |
391 | } | 391 | } |
392 | if ( mMultiday == 1 ) { | 392 | if ( mMultiday == 1 ) { |
393 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 393 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
394 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 394 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
395 | } | 395 | } |
396 | if ( mMultiday == 3 ) { | 396 | if ( mMultiday == 3 ) { |
397 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 397 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
398 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 398 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
399 | 399 | ||
400 | } | 400 | } |
401 | x += sizeM/2 + 1; | 401 | x += sizeM/2 + 1; |
402 | x += sizeM + 1; | 402 | x += sizeM + 1; |
403 | } | 403 | } |
404 | 404 | ||
405 | if ( mIncidence->typeID() == todoID ){ | 405 | if ( mIncidence->typeID() == todoID ){ |
406 | Todo* td = ( Todo* ) mIncidence; | 406 | Todo* td = ( Todo* ) mIncidence; |
407 | if ( td->isCompleted() ) { | 407 | if ( td->isCompleted() ) { |
408 | int half = size/2; | 408 | int half = size/2; |
409 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 409 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
410 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 410 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
411 | x += half+half + 4; | 411 | x += half+half + 4; |
412 | 412 | ||
413 | } else { | 413 | } else { |
414 | int val = td->percentComplete()/20; | 414 | int val = td->percentComplete()/20; |
415 | p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() ); | 415 | p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() ); |
416 | p->drawRect ( x, y-2,7,size+4); | 416 | p->drawRect ( x, y-2,7,size+4); |
417 | x += size + 3; | 417 | x += size + 3; |
418 | } | 418 | } |
419 | } | 419 | } |
420 | QFontMetrics fm = p->fontMetrics(); | 420 | QFontMetrics fm = p->fontMetrics(); |
421 | int yPos; | 421 | int yPos; |
422 | int pmheight = size; | 422 | int pmheight = size; |
423 | if( pmheight < fm.height() ) | 423 | if( pmheight < fm.height() ) |
424 | yPos = fm.ascent() + fm.leading()/2; | 424 | yPos = fm.ascent() + fm.leading()/2; |
425 | else | 425 | else |
426 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 426 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
427 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 427 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
428 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 428 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
429 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 429 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
430 | p->drawText( x, yPos, text() ); | 430 | p->drawText( x, yPos, text() ); |
431 | if ( mIncidence->cancelled() ) { | 431 | if ( mIncidence->cancelled() ) { |
432 | int wid = fm.width( text() ); | 432 | int wid = fm.width( text() ); |
433 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 433 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
434 | } | 434 | } |
435 | } else { | 435 | } else { |
436 | QString pText = text(); | 436 | QString pText = text(); |
437 | if( pText.mid(2,1) == ":" ) | 437 | if( pText.mid(2,1) == ":" ) |
438 | pText = pText.mid( 6 ); | 438 | pText = pText.mid( 6 ); |
439 | p->drawText( x, yPos, pText ); | 439 | p->drawText( x, yPos, pText ); |
440 | if ( mIncidence->cancelled() ) { | 440 | if ( mIncidence->cancelled() ) { |
441 | int wid = fm.width( pText ); | 441 | int wid = fm.width( pText ); |
442 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 442 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
443 | } | 443 | } |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | int MonthViewItem::height(const QListBox *lb) const | 447 | int MonthViewItem::height(const QListBox *lb) const |
448 | { | 448 | { |
449 | int ret = 10; | 449 | int ret = 10; |
450 | if ( lb ) | 450 | if ( lb ) |
451 | ret = lb->fontMetrics().lineSpacing()+1; | 451 | ret = lb->fontMetrics().lineSpacing()+1; |
452 | return ret; | 452 | return ret; |
453 | } | 453 | } |
454 | 454 | ||
455 | int MonthViewItem::width(const QListBox *lb) const | 455 | int MonthViewItem::width(const QListBox *lb) const |
456 | { | 456 | { |
457 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 457 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
458 | int size = PIXMAP_SIZE; | 458 | int size = PIXMAP_SIZE; |
459 | if ( QApplication::desktop()->width() < 300 ) | 459 | if ( QApplication::desktop()->width() < 300 ) |
460 | size = 3; | 460 | size = 3; |
461 | int x = 1; | 461 | int x = 1; |
462 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 462 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
463 | if ( mInfo ) { | 463 | if ( mInfo ) { |
464 | x += size + 1; | 464 | x += size + 1; |
465 | } | 465 | } |
466 | if( mRecur ) { | 466 | if( mRecur ) { |
467 | x += size+1; | 467 | x += size+1; |
468 | } | 468 | } |
469 | if( mAlarm ) { | 469 | if( mAlarm ) { |
470 | x += size+1; | 470 | x += size+1; |
471 | } | 471 | } |
472 | if( mReply ) { | 472 | if( mReply ) { |
473 | x += size+1; | 473 | x += size+1; |
474 | } | 474 | } |
475 | } | 475 | } |
476 | if( mMultiday ) { | 476 | if( mMultiday ) { |
477 | x += size+1+2+size/2; | 477 | x += size+1+2+size/2; |
478 | } | 478 | } |
479 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 479 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
480 | } | 480 | } |
481 | if ( ! lb ) | 481 | if ( ! lb ) |
482 | return 10; | 482 | return 10; |
483 | return lb->width(); | 483 | return lb->width(); |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 487 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
488 | : KNoScrollListBox( par ), | 488 | : KNoScrollListBox( par ), |
489 | mMonthView( parent ) | 489 | mMonthView( parent ) |
490 | { | 490 | { |
491 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 491 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
492 | currentPalette = 0; | 492 | currentPalette = 0; |
493 | // mLabel = new QLabel( this );QPushButton | 493 | // mLabel = new QLabel( this );QPushButton |
494 | mLabel = new QPushButton( this ); | 494 | mLabel = new QPushButton( this ); |
495 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 495 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
496 | //mLabel->setLineWidth( 1 ); | 496 | //mLabel->setLineWidth( 1 ); |
497 | //mLabel->setAlignment( AlignCenter ); | 497 | //mLabel->setAlignment( AlignCenter ); |
498 | mLabel->setFlat( true ); | 498 | mLabel->setFlat( true ); |
499 | mLabel->setFocusPolicy(NoFocus); | 499 | mLabel->setFocusPolicy(NoFocus); |
500 | //mItemList = new KNoScrollListBox( this ); | 500 | //mItemList = new KNoScrollListBox( this ); |
501 | setMinimumSize( 10, 10 ); | 501 | setMinimumSize( 10, 10 ); |
502 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 502 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
503 | setLineWidth( 1 ); | 503 | setLineWidth( 1 ); |
504 | //topLayout->addWidget( mItemList ); | 504 | //topLayout->addWidget( mItemList ); |
505 | mLabel->raise(); | 505 | mLabel->raise(); |
506 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 506 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
507 | mStandardPalette = palette(); | 507 | mStandardPalette = palette(); |
508 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 508 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
509 | 509 | ||
510 | enableScrollBars( false ); | 510 | enableScrollBars( false ); |
511 | updateConfig(); | 511 | updateConfig(); |
512 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 512 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
513 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 513 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
514 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 514 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
515 | SLOT( defaultAction( QListBoxItem * ) ) ); | 515 | SLOT( defaultAction( QListBoxItem * ) ) ); |
516 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 516 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
517 | const QPoint &) ), | 517 | const QPoint &) ), |
518 | SLOT( contextMenu( QListBoxItem * ) ) ); | 518 | SLOT( contextMenu( QListBoxItem * ) ) ); |
519 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 519 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
520 | SLOT( selection( QListBoxItem * ) ) ); | 520 | SLOT( selection( QListBoxItem * ) ) ); |
521 | 521 | ||
522 | /* | 522 | /* |
523 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 523 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
524 | SLOT( selection( QListBoxItem * ) ) ); | 524 | SLOT( selection( QListBoxItem * ) ) ); |
525 | */ | 525 | */ |
526 | } | 526 | } |
527 | #ifdef DESKTOP_VERSION | 527 | #ifdef DESKTOP_VERSION |
528 | QToolTipGroup *MonthViewCell::toolTipGroup() | 528 | QToolTipGroup *MonthViewCell::toolTipGroup() |
529 | { | 529 | { |
530 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 530 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
531 | return mToolTipGroup; | 531 | return mToolTipGroup; |
532 | } | 532 | } |
@@ -911,666 +911,666 @@ void MonthViewCell::updateCell() | |||
911 | for( event = events.first(); event; event = events.next() ) { // for event | 911 | for( event = events.first(); event; event = events.next() ) { // for event |
912 | insertEvent(event); | 912 | insertEvent(event); |
913 | } | 913 | } |
914 | // insert due todos | 914 | // insert due todos |
915 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 915 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
916 | Todo *todo; | 916 | Todo *todo; |
917 | for(todo = todos.first(); todo; todo = todos.next()) { | 917 | for(todo = todos.first(); todo; todo = todos.next()) { |
918 | insertTodo( todo ); | 918 | insertTodo( todo ); |
919 | } | 919 | } |
920 | finishUpdateCell(); | 920 | finishUpdateCell(); |
921 | // if ( isVisible()) | 921 | // if ( isVisible()) |
922 | //qApp->processEvents(); | 922 | //qApp->processEvents(); |
923 | } | 923 | } |
924 | 924 | ||
925 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 925 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
926 | { | 926 | { |
927 | 927 | ||
928 | if ( bigFont ) { | 928 | if ( bigFont ) { |
929 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 929 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
930 | int ps = fo.pointSize() + 2; | 930 | int ps = fo.pointSize() + 2; |
931 | if ( ps < 18 ) | 931 | if ( ps < 18 ) |
932 | ps += 2; | 932 | ps += 2; |
933 | fo.setPointSize( ps ); | 933 | fo.setPointSize( ps ); |
934 | setFont( fo ); | 934 | setFont( fo ); |
935 | } else | 935 | } else |
936 | setFont( KOPrefs::instance()->mMonthViewFont ); | 936 | setFont( KOPrefs::instance()->mMonthViewFont ); |
937 | 937 | ||
938 | QFontMetrics fm( font() ); | 938 | QFontMetrics fm( font() ); |
939 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 939 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
940 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 940 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
941 | mHolidayPalette = mStandardPalette; | 941 | mHolidayPalette = mStandardPalette; |
942 | mPrimaryPalette = mStandardPalette; | 942 | mPrimaryPalette = mStandardPalette; |
943 | mNonPrimaryPalette = mStandardPalette; | 943 | mNonPrimaryPalette = mStandardPalette; |
944 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 944 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
945 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 945 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
946 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 946 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
947 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 947 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
948 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 948 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
949 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 949 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
950 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 950 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
951 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 951 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
952 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 952 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
953 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 953 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
954 | } | 954 | } |
955 | //updateCell(); | 955 | //updateCell(); |
956 | } | 956 | } |
957 | 957 | ||
958 | void MonthViewCell::enableScrollBars( bool enabled ) | 958 | void MonthViewCell::enableScrollBars( bool enabled ) |
959 | { | 959 | { |
960 | 960 | ||
961 | return; | 961 | return; |
962 | if ( enabled ) { | 962 | if ( enabled ) { |
963 | QListBoxItem *fi = firstItem (); | 963 | QListBoxItem *fi = firstItem (); |
964 | if (fi ) { | 964 | if (fi ) { |
965 | int ihei = fi->height( this ); | 965 | int ihei = fi->height( this ); |
966 | int hei = numRows () * ihei; | 966 | int hei = numRows () * ihei; |
967 | if ( hei < height() - horizontalScrollBar()->height () ) { | 967 | if ( hei < height() - horizontalScrollBar()->height () ) { |
968 | setVScrollBarMode(QScrollView::AlwaysOff); | 968 | setVScrollBarMode(QScrollView::AlwaysOff); |
969 | } | 969 | } |
970 | else | 970 | else |
971 | setVScrollBarMode(QScrollView::Auto); | 971 | setVScrollBarMode(QScrollView::Auto); |
972 | if ( ihei *3 > height() ) { | 972 | if ( ihei *3 > height() ) { |
973 | setHScrollBarMode(QScrollView::AlwaysOff); | 973 | setHScrollBarMode(QScrollView::AlwaysOff); |
974 | } | 974 | } |
975 | else { | 975 | else { |
976 | setHScrollBarMode(QScrollView::Auto); | 976 | setHScrollBarMode(QScrollView::Auto); |
977 | } | 977 | } |
978 | } else { | 978 | } else { |
979 | setVScrollBarMode(QScrollView::Auto); | 979 | setVScrollBarMode(QScrollView::Auto); |
980 | setHScrollBarMode(QScrollView::Auto); | 980 | setHScrollBarMode(QScrollView::Auto); |
981 | } | 981 | } |
982 | } else { | 982 | } else { |
983 | setVScrollBarMode(QScrollView::AlwaysOff); | 983 | setVScrollBarMode(QScrollView::AlwaysOff); |
984 | setHScrollBarMode(QScrollView::AlwaysOff); | 984 | setHScrollBarMode(QScrollView::AlwaysOff); |
985 | } | 985 | } |
986 | } | 986 | } |
987 | 987 | ||
988 | Incidence *MonthViewCell::selectedIncidence() | 988 | Incidence *MonthViewCell::selectedIncidence() |
989 | { | 989 | { |
990 | int index = currentItem(); | 990 | int index = currentItem(); |
991 | if ( index < 0 ) return 0; | 991 | if ( index < 0 ) return 0; |
992 | 992 | ||
993 | MonthViewItem *mitem = | 993 | MonthViewItem *mitem = |
994 | static_cast<MonthViewItem *>( item( index ) ); | 994 | static_cast<MonthViewItem *>( item( index ) ); |
995 | 995 | ||
996 | if ( !mitem ) return 0; | 996 | if ( !mitem ) return 0; |
997 | 997 | ||
998 | return mitem->incidence(); | 998 | return mitem->incidence(); |
999 | } | 999 | } |
1000 | 1000 | ||
1001 | QDate MonthViewCell::selectedIncidenceDate() | 1001 | QDate MonthViewCell::selectedIncidenceDate() |
1002 | { | 1002 | { |
1003 | QDate qd; | 1003 | QDate qd; |
1004 | int index = currentItem(); | 1004 | int index = currentItem(); |
1005 | if ( index < 0 ) return qd; | 1005 | if ( index < 0 ) return qd; |
1006 | return mDate; | 1006 | return mDate; |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | void MonthViewCell::deselect() | 1009 | void MonthViewCell::deselect() |
1010 | { | 1010 | { |
1011 | clearSelection(); | 1011 | clearSelection(); |
1012 | enableScrollBars( false ); | 1012 | enableScrollBars( false ); |
1013 | // updateCell(); | 1013 | // updateCell(); |
1014 | } | 1014 | } |
1015 | void MonthViewCell::select() | 1015 | void MonthViewCell::select() |
1016 | { | 1016 | { |
1017 | ;// updateCell(); | 1017 | ;// updateCell(); |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 1020 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
1021 | { | 1021 | { |
1022 | if ( !mMonthView->isUpdatePossible() ) | 1022 | if ( !mMonthView->isUpdatePossible() ) |
1023 | return; | 1023 | return; |
1024 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 1024 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
1025 | deselect(); | 1025 | deselect(); |
1026 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 1026 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
1027 | 1027 | ||
1028 | QString text; | 1028 | QString text; |
1029 | mLabel->setText( text ); | 1029 | mLabel->setText( text ); |
1030 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 1030 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1031 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1031 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1032 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 1032 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
1033 | mLabel->resize( mLabelBigSize ); | 1033 | mLabel->resize( mLabelBigSize ); |
1034 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 1034 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1035 | } else { | 1035 | } else { |
1036 | mLabel->resize( mLabelSize ); | 1036 | mLabel->resize( mLabelSize ); |
1037 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 1037 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1038 | } | 1038 | } |
1039 | mLabel->setText( text ); | 1039 | mLabel->setText( text ); |
1040 | 1040 | ||
1041 | int size = height() - mLabel->height() - lineWidth()-1; | 1041 | int size = height() - mLabel->height() - lineWidth()-1; |
1042 | //qDebug("LW %d ", lineWidth()); | 1042 | //qDebug("LW %d ", lineWidth()); |
1043 | if ( size > 0 ) | 1043 | if ( size > 0 ) |
1044 | verticalScrollBar()->setMaximumHeight( size ); | 1044 | verticalScrollBar()->setMaximumHeight( size ); |
1045 | size = width() - mLabel->width() -lineWidth()-1; | 1045 | size = width() - mLabel->width() -lineWidth()-1; |
1046 | if ( size > 0 ) | 1046 | if ( size > 0 ) |
1047 | horizontalScrollBar()->setMaximumWidth( size ); | 1047 | horizontalScrollBar()->setMaximumWidth( size ); |
1048 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1048 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1049 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1049 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1050 | // mItemList->resize ( width(), height () ); | 1050 | // mItemList->resize ( width(), height () ); |
1051 | if ( e ) | 1051 | if ( e ) |
1052 | KNoScrollListBox::resizeEvent ( e ); | 1052 | KNoScrollListBox::resizeEvent ( e ); |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1055 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1056 | { | 1056 | { |
1057 | 1057 | ||
1058 | if ( !item ) { | 1058 | if ( !item ) { |
1059 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1059 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1060 | emit newEventSignal( dt ); | 1060 | emit newEventSignal( dt ); |
1061 | return; | 1061 | return; |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1064 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1065 | Incidence *incidence = eventItem->incidence(); | 1065 | Incidence *incidence = eventItem->incidence(); |
1066 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1066 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1067 | } | 1067 | } |
1068 | void MonthViewCell::showDay() | 1068 | void MonthViewCell::showDay() |
1069 | { | 1069 | { |
1070 | emit showDaySignal( date() ); | 1070 | emit showDaySignal( date() ); |
1071 | } | 1071 | } |
1072 | void MonthViewCell::newEvent() | 1072 | void MonthViewCell::newEvent() |
1073 | { | 1073 | { |
1074 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1074 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1075 | emit newEventSignal( dt ); | 1075 | emit newEventSignal( dt ); |
1076 | } | 1076 | } |
1077 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1077 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1078 | { | 1078 | { |
1079 | mMonthView->setSelectedCell( this ); | 1079 | mMonthView->setSelectedCell( this ); |
1080 | if ( item == 0 ) { | 1080 | if ( item == 0 ) { |
1081 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1081 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1082 | emit newEventSignal( dt ); | 1082 | emit newEventSignal( dt ); |
1083 | return; | 1083 | return; |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1088 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1089 | { | 1089 | { |
1090 | mMonthView->setPopupCell( this ); | 1090 | mMonthView->setPopupCell( this ); |
1091 | if ( !item ) { | 1091 | if ( !item ) { |
1092 | mMonthView->showContextMenu( 0 ); | 1092 | mMonthView->showContextMenu( 0 ); |
1093 | return; | 1093 | return; |
1094 | } | 1094 | } |
1095 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1095 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1096 | Incidence *incidence = eventItem->incidence(); | 1096 | Incidence *incidence = eventItem->incidence(); |
1097 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1097 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1098 | } | 1098 | } |
1099 | 1099 | ||
1100 | void MonthViewCell::selection( QListBoxItem *item ) | 1100 | void MonthViewCell::selection( QListBoxItem *item ) |
1101 | { | 1101 | { |
1102 | if ( !item ) { | 1102 | if ( !item ) { |
1103 | emit highligtIncidence( 0 , this, 0 ); | 1103 | emit highlightIncidence( 0 , this, 0 ); |
1104 | return; | 1104 | return; |
1105 | } | 1105 | } |
1106 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1106 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1107 | emit highligtIncidence( it->incidence(), this, it->multiDay() ); | 1107 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1108 | mMonthView->setSelectedCell( this ); | 1108 | mMonthView->setSelectedCell( this ); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | void MonthViewCell::deHightLight() | 1111 | void MonthViewCell::deHighLight() |
1112 | { | 1112 | { |
1113 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1113 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1114 | while ( mitem ) { | 1114 | while ( mitem ) { |
1115 | if ( mitem->setHighlightedFalse() ) | 1115 | if ( mitem->setHighlightedFalse() ) |
1116 | updateItem ( mitem ); | 1116 | updateItem ( mitem ); |
1117 | mitem = (MonthViewItem *)mitem->next(); | 1117 | mitem = (MonthViewItem *)mitem->next(); |
1118 | } | 1118 | } |
1119 | } | 1119 | } |
1120 | // returns true if no inc found | 1120 | // returns true if no inc found |
1121 | bool MonthViewCell::doHightLight( Incidence * inc ) | 1121 | bool MonthViewCell::doHighLight( Incidence * inc ) |
1122 | { | 1122 | { |
1123 | 1123 | ||
1124 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1124 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1125 | while ( mitem ) { | 1125 | while ( mitem ) { |
1126 | if ( mitem->incidence() == inc ) { | 1126 | if ( mitem->incidence() == inc ) { |
1127 | if ( mitem->setHighlighted( inc ) ) | 1127 | if ( mitem->setHighlighted( inc ) ) |
1128 | updateItem ( mitem ); | 1128 | updateItem ( mitem ); |
1129 | return false; | 1129 | return false; |
1130 | } | 1130 | } |
1131 | mitem = (MonthViewItem *)mitem->next(); | 1131 | mitem = (MonthViewItem *)mitem->next(); |
1132 | } | 1132 | } |
1133 | return true; | 1133 | return true; |
1134 | } | 1134 | } |
1135 | // ******************************************************************************* | 1135 | // ******************************************************************************* |
1136 | // ******************************************************************************* | 1136 | // ******************************************************************************* |
1137 | // ******************************************************************************* | 1137 | // ******************************************************************************* |
1138 | 1138 | ||
1139 | 1139 | ||
1140 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1140 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1141 | : KOEventView( calendar, parent, name ), | 1141 | : KOEventView( calendar, parent, name ), |
1142 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1142 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1143 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1143 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1144 | { | 1144 | { |
1145 | mFlagKeyPressed = false; | 1145 | mFlagKeyPressed = false; |
1146 | mShortDayLabelsM = false; | 1146 | mShortDayLabelsM = false; |
1147 | mShortDayLabelsW = false; | 1147 | mShortDayLabelsW = false; |
1148 | skipResize = false; | 1148 | skipResize = false; |
1149 | clPending = true; | 1149 | clPending = true; |
1150 | mPopupCell = 0; | 1150 | mPopupCell = 0; |
1151 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1151 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1152 | mWidStack = new QWidgetStack( this ); | 1152 | mWidStack = new QWidgetStack( this ); |
1153 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1153 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1154 | mMonthView = new QWidget( mWidStack ); | 1154 | mMonthView = new QWidget( mWidStack ); |
1155 | mWeekView = new QWidget( mWidStack ); | 1155 | mWeekView = new QWidget( mWidStack ); |
1156 | #if QT_VERSION >= 0x030000 | 1156 | #if QT_VERSION >= 0x030000 |
1157 | mWidStack->addWidget(mMonthView ); | 1157 | mWidStack->addWidget(mMonthView ); |
1158 | mWidStack->addWidget(mWeekView ); | 1158 | mWidStack->addWidget(mWeekView ); |
1159 | #else | 1159 | #else |
1160 | mWidStack->addWidget( mMonthView, 1 ); | 1160 | mWidStack->addWidget( mMonthView, 1 ); |
1161 | mWidStack->addWidget( mWeekView , 1 ); | 1161 | mWidStack->addWidget( mWeekView , 1 ); |
1162 | #endif | 1162 | #endif |
1163 | hb->addWidget( mNavigatorBar ); | 1163 | hb->addWidget( mNavigatorBar ); |
1164 | hb->addWidget( mWidStack ); | 1164 | hb->addWidget( mWidStack ); |
1165 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1165 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1166 | updatePossible = false; | 1166 | updatePossible = false; |
1167 | //updatePossible = true; | 1167 | //updatePossible = true; |
1168 | mCells.setAutoDelete( true ); | 1168 | mCells.setAutoDelete( true ); |
1169 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1169 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1170 | mDayLabels.resize( mDaysPerWeek ); | 1170 | mDayLabels.resize( mDaysPerWeek ); |
1171 | mDayLabelsW.resize( mDaysPerWeek ); | 1171 | mDayLabelsW.resize( mDaysPerWeek ); |
1172 | QFont bfont = font(); | 1172 | QFont bfont = font(); |
1173 | if ( QApplication::desktop()->width() < 650 ) { | 1173 | if ( QApplication::desktop()->width() < 650 ) { |
1174 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1174 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1175 | } | 1175 | } |
1176 | bfont.setBold( true ); | 1176 | bfont.setBold( true ); |
1177 | int i; | 1177 | int i; |
1178 | 1178 | ||
1179 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1179 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1180 | QLabel *label = new QLabel( mMonthView ); | 1180 | QLabel *label = new QLabel( mMonthView ); |
1181 | label->setFont(bfont); | 1181 | label->setFont(bfont); |
1182 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1182 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1183 | label->setLineWidth(1); | 1183 | label->setLineWidth(1); |
1184 | label->setAlignment(AlignCenter); | 1184 | label->setAlignment(AlignCenter); |
1185 | mDayLabels.insert( i, label ); | 1185 | mDayLabels.insert( i, label ); |
1186 | label = new QLabel( mWeekView ); | 1186 | label = new QLabel( mWeekView ); |
1187 | label->setFont(bfont); | 1187 | label->setFont(bfont); |
1188 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1188 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1189 | label->setLineWidth(1); | 1189 | label->setLineWidth(1); |
1190 | label->setAlignment(AlignCenter); | 1190 | label->setAlignment(AlignCenter); |
1191 | mDayLabelsW.insert( i, label ); | 1191 | mDayLabelsW.insert( i, label ); |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | bfont.setBold( false ); | 1194 | bfont.setBold( false ); |
1195 | mWeekLabels.resize( mNumWeeks+1 ); | 1195 | mWeekLabels.resize( mNumWeeks+1 ); |
1196 | mWeekLabelsW.resize( 2 ); | 1196 | mWeekLabelsW.resize( 2 ); |
1197 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1197 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1198 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1198 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1199 | label->setFocusPolicy(NoFocus); | 1199 | label->setFocusPolicy(NoFocus); |
1200 | label->setFont(bfont); | 1200 | label->setFont(bfont); |
1201 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1201 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1202 | label->setFlat(true); | 1202 | label->setFlat(true); |
1203 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1203 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1204 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1204 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1205 | //label->setLineWidth(1); | 1205 | //label->setLineWidth(1); |
1206 | //label->setAlignment(AlignCenter); | 1206 | //label->setAlignment(AlignCenter); |
1207 | mWeekLabels.insert( i, label ); | 1207 | mWeekLabels.insert( i, label ); |
1208 | } | 1208 | } |
1209 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1209 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1210 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1210 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1211 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1211 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1212 | 1212 | ||
1213 | for( i = 0; i < 1+1; i++ ) { | 1213 | for( i = 0; i < 1+1; i++ ) { |
1214 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1214 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1215 | label->setFocusPolicy(NoFocus); | 1215 | label->setFocusPolicy(NoFocus); |
1216 | label->setFont(bfont); | 1216 | label->setFont(bfont); |
1217 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1217 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1218 | label->setFlat(true); | 1218 | label->setFlat(true); |
1219 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1219 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1220 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1220 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1221 | //label->setLineWidth(1); | 1221 | //label->setLineWidth(1); |
1222 | //label->setAlignment(AlignCenter); | 1222 | //label->setAlignment(AlignCenter); |
1223 | mWeekLabelsW.insert( i, label ); | 1223 | mWeekLabelsW.insert( i, label ); |
1224 | } | 1224 | } |
1225 | mWeekLabelsW[1]->setText( i18n("W")); | 1225 | mWeekLabelsW[1]->setText( i18n("W")); |
1226 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1226 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1227 | 1227 | ||
1228 | 1228 | ||
1229 | int row, col; | 1229 | int row, col; |
1230 | mCells.resize( mNumCells ); | 1230 | mCells.resize( mNumCells ); |
1231 | for( row = 0; row < mNumWeeks; ++row ) { | 1231 | for( row = 0; row < mNumWeeks; ++row ) { |
1232 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1232 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1233 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1233 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1234 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1234 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1235 | 1235 | ||
1236 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1236 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1237 | SLOT( defaultAction( Incidence * ) ) ); | 1237 | SLOT( defaultAction( Incidence * ) ) ); |
1238 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1238 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1239 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1239 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1240 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1240 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1241 | SIGNAL( showDaySignal( QDate ) ) ); | 1241 | SIGNAL( showDaySignal( QDate ) ) ); |
1242 | connect( cell, SIGNAL( nextCell() ), | 1242 | connect( cell, SIGNAL( nextCell() ), |
1243 | SLOT( nextCell() ) ); | 1243 | SLOT( nextCell() ) ); |
1244 | connect( cell, SIGNAL( prevCell() ), | 1244 | connect( cell, SIGNAL( prevCell() ), |
1245 | SLOT( prevCell() ) ); | 1245 | SLOT( prevCell() ) ); |
1246 | connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), | 1246 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1247 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1247 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1248 | } | 1248 | } |
1249 | } | 1249 | } |
1250 | mCellsW.resize( mDaysPerWeek ); | 1250 | mCellsW.resize( mDaysPerWeek ); |
1251 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1251 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1252 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1252 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1253 | mCellsW.insert( col, cell ); | 1253 | mCellsW.insert( col, cell ); |
1254 | 1254 | ||
1255 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1255 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1256 | SLOT( defaultAction( Incidence * ) ) ); | 1256 | SLOT( defaultAction( Incidence * ) ) ); |
1257 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1257 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1258 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1258 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1259 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1259 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1260 | SIGNAL( showDaySignal( QDate ) ) ); | 1260 | SIGNAL( showDaySignal( QDate ) ) ); |
1261 | connect( cell, SIGNAL( nextCell() ), | 1261 | connect( cell, SIGNAL( nextCell() ), |
1262 | SLOT( nextCell() ) ); | 1262 | SLOT( nextCell() ) ); |
1263 | connect( cell, SIGNAL( prevCell() ), | 1263 | connect( cell, SIGNAL( prevCell() ), |
1264 | SLOT( prevCell() ) ); | 1264 | SLOT( prevCell() ) ); |
1265 | connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ), | 1265 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1266 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1266 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1267 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1267 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1270 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1271 | mContextMenu = eventPopup(); | 1271 | mContextMenu = eventPopup(); |
1272 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1272 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1273 | i18n("New Event..."),this, | 1273 | i18n("New Event..."),this, |
1274 | SLOT(slotNewEvent()),false); | 1274 | SLOT(slotNewEvent()),false); |
1275 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1275 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1276 | i18n("New Todo..."),this, | 1276 | i18n("New Todo..."),this, |
1277 | SLOT(slotNewTodo()),false); | 1277 | SLOT(slotNewTodo()),false); |
1278 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1278 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1279 | i18n("Journal"),this, | 1279 | i18n("Journal"),this, |
1280 | SLOT(slotEditJournal()),false); | 1280 | SLOT(slotEditJournal()),false); |
1281 | 1281 | ||
1282 | 1282 | ||
1283 | 1283 | ||
1284 | QString pathString = ""; | 1284 | QString pathString = ""; |
1285 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1285 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1286 | if ( QApplication::desktop()->width() < 480 ) | 1286 | if ( QApplication::desktop()->width() < 480 ) |
1287 | pathString += "icons16/"; | 1287 | pathString += "icons16/"; |
1288 | } else | 1288 | } else |
1289 | pathString += "iconsmini/"; | 1289 | pathString += "iconsmini/"; |
1290 | mNewItemMenu = new QPopupMenu( this ); | 1290 | mNewItemMenu = new QPopupMenu( this ); |
1291 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1291 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1292 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1292 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1293 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1293 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1294 | 1294 | ||
1295 | // updateConfig(); //useless here... | 1295 | // updateConfig(); //useless here... |
1296 | // ... but we need mWidthLongDayLabel computed | 1296 | // ... but we need mWidthLongDayLabel computed |
1297 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1297 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1298 | mWidthLongDayLabel = 0; | 1298 | mWidthLongDayLabel = 0; |
1299 | for (int i = 0; i < 7; i++) { | 1299 | for (int i = 0; i < 7; i++) { |
1300 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1300 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1301 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1301 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1304 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1305 | 1305 | ||
1306 | #if 0 | 1306 | #if 0 |
1307 | if ( mShowWeekView ) | 1307 | if ( mShowWeekView ) |
1308 | mWidStack->raiseWidget( mWeekView ); | 1308 | mWidStack->raiseWidget( mWeekView ); |
1309 | else | 1309 | else |
1310 | mWidStack->raiseWidget( mMonthView ); | 1310 | mWidStack->raiseWidget( mMonthView ); |
1311 | #endif | 1311 | #endif |
1312 | 1312 | ||
1313 | emit incidenceSelected( 0 ); | 1313 | emit incidenceSelected( 0 ); |
1314 | 1314 | ||
1315 | mComputeLayoutTimer = new QTimer( this ); | 1315 | mComputeLayoutTimer = new QTimer( this ); |
1316 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1316 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1317 | 1317 | ||
1318 | 1318 | ||
1319 | #ifndef DESKTOP_VERSION | 1319 | #ifndef DESKTOP_VERSION |
1320 | resize( QApplication::desktop()->size() ); | 1320 | resize( QApplication::desktop()->size() ); |
1321 | #else | 1321 | #else |
1322 | resize(640, 480 ); | 1322 | resize(640, 480 ); |
1323 | updatePossible = true; | 1323 | updatePossible = true; |
1324 | #endif | 1324 | #endif |
1325 | computeLayout(); | 1325 | computeLayout(); |
1326 | 1326 | ||
1327 | if ( mShowWeekView ) | 1327 | if ( mShowWeekView ) |
1328 | mWidStack->raiseWidget( mWeekView ); | 1328 | mWidStack->raiseWidget( mWeekView ); |
1329 | else | 1329 | else |
1330 | mWidStack->raiseWidget( mMonthView ); | 1330 | mWidStack->raiseWidget( mMonthView ); |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | KOMonthView::~KOMonthView() | 1333 | KOMonthView::~KOMonthView() |
1334 | { | 1334 | { |
1335 | delete mContextMenu; | 1335 | delete mContextMenu; |
1336 | } | 1336 | } |
1337 | 1337 | ||
1338 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | 1338 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) |
1339 | { | 1339 | { |
1340 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1340 | qDebug("11 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1341 | static Incidence * lastInc = 0; | 1341 | static Incidence * lastInc = 0; |
1342 | static MonthViewCell * lastCell = 0; | 1342 | static MonthViewCell * lastCell = 0; |
1343 | 1343 | ||
1344 | if ( lastInc == inc && lastCell == mc ) | 1344 | if ( lastInc == inc && lastCell == mc ) |
1345 | return; | 1345 | return; |
1346 | lastInc = inc; | 1346 | lastInc = inc; |
1347 | lastCell = mc; | 1347 | lastCell = mc; |
1348 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1348 | qDebug("222 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1349 | 1349 | ||
1350 | bool weekview = false; | 1350 | bool weekview = false; |
1351 | int index = 0; | 1351 | int index = 0; |
1352 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1352 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1353 | if ( mCellsW[i] == mc ) { | 1353 | if ( mCellsW[i] == mc ) { |
1354 | weekview = true; | 1354 | weekview = true; |
1355 | index = i; | 1355 | index = i; |
1356 | break; | 1356 | break; |
1357 | } | 1357 | } |
1358 | } | 1358 | } |
1359 | QPtrVector<MonthViewCell> *cells; | 1359 | QPtrVector<MonthViewCell> *cells; |
1360 | if ( weekview ) | 1360 | if ( weekview ) |
1361 | cells = &mCellsW; | 1361 | cells = &mCellsW; |
1362 | else { | 1362 | else { |
1363 | for (uint i = 0; i < mCells.count(); ++i) { | 1363 | for (uint i = 0; i < mCells.count(); ++i) { |
1364 | if ( mCells[i] == mc ) { | 1364 | if ( mCells[i] == mc ) { |
1365 | index = i; | 1365 | index = i; |
1366 | break; | 1366 | break; |
1367 | } | 1367 | } |
1368 | } | 1368 | } |
1369 | cells = &mCells; | 1369 | cells = &mCells; |
1370 | } | 1370 | } |
1371 | for (uint i = 0; i < (*cells).count(); ++i) { | 1371 | for (uint i = 0; i < (*cells).count(); ++i) { |
1372 | (*cells)[i]->deHightLight(); | 1372 | (*cells)[i]->deHighLight(); |
1373 | } | 1373 | } |
1374 | if ( ! inc ) | 1374 | if ( ! inc ) |
1375 | return; | 1375 | return; |
1376 | if ( mday > 1 && index > 0 ) | 1376 | if ( mday > 1 && index > 0 ) |
1377 | for (int i = index-1; i >= 0; --i) { | 1377 | for (int i = index-1; i >= 0; --i) { |
1378 | //qDebug("index %d iii %d ", index, i); | 1378 | //qDebug("index %d iii %d ", index, i); |
1379 | if ( (*cells)[(uint)i]->doHightLight(inc) ) | 1379 | if ( (*cells)[(uint)i]->doHighLight(inc) ) |
1380 | break; | 1380 | break; |
1381 | } | 1381 | } |
1382 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) | 1382 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) |
1383 | for (uint i = index+1; i < (*cells).count(); ++i) { | 1383 | for (uint i = index+1; i < (*cells).count(); ++i) { |
1384 | if ( (*cells)[i]->doHightLight(inc) ) | 1384 | if ( (*cells)[i]->doHighLight(inc) ) |
1385 | break; | 1385 | break; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | } | 1388 | } |
1389 | void KOMonthView::selectInternalWeekNum ( int n ) | 1389 | void KOMonthView::selectInternalWeekNum ( int n ) |
1390 | { | 1390 | { |
1391 | switchView(); | 1391 | switchView(); |
1392 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1392 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1393 | emit selectMonth (); | 1393 | emit selectMonth (); |
1394 | else | 1394 | else |
1395 | emit selectWeekNum ( n ); | 1395 | emit selectWeekNum ( n ); |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | int KOMonthView::currentWeek() | 1398 | int KOMonthView::currentWeek() |
1399 | { | 1399 | { |
1400 | if ( mShowWeekView ) | 1400 | if ( mShowWeekView ) |
1401 | return mWeekLabelsW[0]->getWeekNum(); | 1401 | return mWeekLabelsW[0]->getWeekNum(); |
1402 | return mWeekLabels[0]->getWeekNum(); | 1402 | return mWeekLabels[0]->getWeekNum(); |
1403 | } | 1403 | } |
1404 | void KOMonthView::switchView() | 1404 | void KOMonthView::switchView() |
1405 | { | 1405 | { |
1406 | if ( selectedCell( ) ) | 1406 | if ( selectedCell( ) ) |
1407 | selectedCell()->deselect(); | 1407 | selectedCell()->deselect(); |
1408 | mShowWeekView = !mShowWeekView; | 1408 | mShowWeekView = !mShowWeekView; |
1409 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1409 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1410 | if ( clPending ) { | 1410 | if ( clPending ) { |
1411 | computeLayout(); | 1411 | computeLayout(); |
1412 | updateConfig(); | 1412 | updateConfig(); |
1413 | } | 1413 | } |
1414 | if ( mShowWeekView ) | 1414 | if ( mShowWeekView ) |
1415 | mWidStack->raiseWidget( mWeekView ); | 1415 | mWidStack->raiseWidget( mWeekView ); |
1416 | else | 1416 | else |
1417 | mWidStack->raiseWidget( mMonthView ); | 1417 | mWidStack->raiseWidget( mMonthView ); |
1418 | clPending = false; | 1418 | clPending = false; |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | int KOMonthView::maxDatesHint() | 1421 | int KOMonthView::maxDatesHint() |
1422 | { | 1422 | { |
1423 | return mNumCells; | 1423 | return mNumCells; |
1424 | } | 1424 | } |
1425 | 1425 | ||
1426 | int KOMonthView::currentDateCount() | 1426 | int KOMonthView::currentDateCount() |
1427 | { | 1427 | { |
1428 | return mNumCells; | 1428 | return mNumCells; |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1431 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1432 | { | 1432 | { |
1433 | QPtrList<Incidence> selected; | 1433 | QPtrList<Incidence> selected; |
1434 | 1434 | ||
1435 | if ( mSelectedCell ) { | 1435 | if ( mSelectedCell ) { |
1436 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1436 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1437 | if ( incidence ) selected.append( incidence ); | 1437 | if ( incidence ) selected.append( incidence ); |
1438 | } | 1438 | } |
1439 | 1439 | ||
1440 | return selected; | 1440 | return selected; |
1441 | } | 1441 | } |
1442 | 1442 | ||
1443 | DateList KOMonthView::selectedDates() | 1443 | DateList KOMonthView::selectedDates() |
1444 | { | 1444 | { |
1445 | DateList selected; | 1445 | DateList selected; |
1446 | 1446 | ||
1447 | if ( mSelectedCell ) { | 1447 | if ( mSelectedCell ) { |
1448 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1448 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1449 | if ( qd.isValid() ) selected.append( qd ); | 1449 | if ( qd.isValid() ) selected.append( qd ); |
1450 | } | 1450 | } |
1451 | 1451 | ||
1452 | return selected; | 1452 | return selected; |
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1455 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1456 | const QDate &td) | 1456 | const QDate &td) |
1457 | { | 1457 | { |
1458 | #ifndef KORG_NOPRINTER | 1458 | #ifndef KORG_NOPRINTER |
1459 | calPrinter->preview(CalPrinter::Month, fd, td); | 1459 | calPrinter->preview(CalPrinter::Month, fd, td); |
1460 | #endif | 1460 | #endif |
1461 | } | 1461 | } |
1462 | 1462 | ||
1463 | void KOMonthView::updateConfig() | 1463 | void KOMonthView::updateConfig() |
1464 | { | 1464 | { |
1465 | 1465 | ||
1466 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1466 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1467 | 1467 | ||
1468 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1468 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1469 | mWeekStartsMonday = true; | 1469 | mWeekStartsMonday = true; |
1470 | } | 1470 | } |
1471 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1471 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1472 | mWidthLongDayLabel = 0; | 1472 | mWidthLongDayLabel = 0; |
1473 | 1473 | ||
1474 | for (int i = 0; i < 7; i++) { | 1474 | for (int i = 0; i < 7; i++) { |
1475 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1475 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1476 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1476 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1477 | } | 1477 | } |
1478 | bool temp = mShowSatSunComp ; | 1478 | bool temp = mShowSatSunComp ; |
1479 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1479 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1480 | if ( ! mShowWeekView ) { | 1480 | if ( ! mShowWeekView ) { |
1481 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1481 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1482 | computeLayout(); | 1482 | computeLayout(); |
1483 | } | 1483 | } |
1484 | updateDayLabels(); | 1484 | updateDayLabels(); |
1485 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1485 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1486 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1486 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1487 | //resizeEvent( 0 ); | 1487 | //resizeEvent( 0 ); |
1488 | for (uint i = 0; i < mCells.count(); ++i) { | 1488 | for (uint i = 0; i < mCells.count(); ++i) { |
1489 | mCells[i]->updateConfig(); | 1489 | mCells[i]->updateConfig(); |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1492 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1493 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1493 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1494 | } | 1494 | } |
1495 | #ifdef DESKTOP_VERSION | 1495 | #ifdef DESKTOP_VERSION |
1496 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1496 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1497 | #endif | 1497 | #endif |
1498 | updateView(); | 1498 | updateView(); |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | void KOMonthView::updateDayLabels() | 1501 | void KOMonthView::updateDayLabels() |
1502 | { | 1502 | { |
1503 | 1503 | ||
1504 | QPtrVector<QLabel> *mDayLabelsT; | 1504 | QPtrVector<QLabel> *mDayLabelsT; |
1505 | 1505 | ||
1506 | mDayLabelsT = &mDayLabelsW; | 1506 | mDayLabelsT = &mDayLabelsW; |
1507 | for (int i = 0; i < 7; i++) { | 1507 | for (int i = 0; i < 7; i++) { |
1508 | { | 1508 | { |
1509 | bool show = mShortDayLabelsW; | 1509 | bool show = mShortDayLabelsW; |
1510 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1510 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1511 | show = true; | 1511 | show = true; |
1512 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1512 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1513 | } | 1513 | } |
1514 | } | 1514 | } |
1515 | mDayLabelsT = &mDayLabels; | 1515 | mDayLabelsT = &mDayLabels; |
1516 | for (int i = 0; i < 7; i++) { | 1516 | for (int i = 0; i < 7; i++) { |
1517 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1517 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1518 | bool show = mShortDayLabelsM; | 1518 | bool show = mShortDayLabelsM; |
1519 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1519 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1520 | show = true; | 1520 | show = true; |
1521 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1521 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1522 | } else { | 1522 | } else { |
1523 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1523 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1524 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1524 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1525 | 1525 | ||
1526 | } | 1526 | } |
1527 | } | 1527 | } |
1528 | 1528 | ||
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | void KOMonthView::clearList() | 1531 | void KOMonthView::clearList() |
1532 | { | 1532 | { |
1533 | unsigned int i; | 1533 | unsigned int i; |
1534 | for( i = 0; i < mCells.size(); ++i ) { | 1534 | for( i = 0; i < mCells.size(); ++i ) { |
1535 | mCells[i]->clear(); | 1535 | mCells[i]->clear(); |
1536 | } | 1536 | } |
1537 | for( i = 0; i < mCellsW.size(); ++i ) { | 1537 | for( i = 0; i < mCellsW.size(); ++i ) { |
1538 | mCellsW[i]->clear(); | 1538 | mCellsW[i]->clear(); |
1539 | } | 1539 | } |
1540 | } | 1540 | } |
1541 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1541 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1542 | { | 1542 | { |
1543 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1543 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1544 | 1544 | ||
1545 | QPtrVector<MonthViewCell> *cells; | 1545 | QPtrVector<MonthViewCell> *cells; |
1546 | QPtrVector<QLabel> *dayLabels; | 1546 | QPtrVector<QLabel> *dayLabels; |
1547 | QPtrVector<KOWeekButton> *weekLabels; | 1547 | QPtrVector<KOWeekButton> *weekLabels; |
1548 | int weekNum = 6; | 1548 | int weekNum = 6; |
1549 | mStartDate = start; | 1549 | mStartDate = start; |
1550 | if ( mShowWeekView ) { | 1550 | if ( mShowWeekView ) { |
1551 | weekNum = 1; | 1551 | weekNum = 1; |
1552 | cells = &mCellsW; | 1552 | cells = &mCellsW; |
1553 | dayLabels = &mDayLabelsW; | 1553 | dayLabels = &mDayLabelsW; |
1554 | weekLabels = &mWeekLabelsW; | 1554 | weekLabels = &mWeekLabelsW; |
1555 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1555 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1556 | mStartDate = mStartDate.addDays( 1 ); | 1556 | mStartDate = mStartDate.addDays( 1 ); |
1557 | } | 1557 | } |
1558 | } else { | 1558 | } else { |
1559 | cells = &mCells; | 1559 | cells = &mCells; |
1560 | dayLabels = &mDayLabels; | 1560 | dayLabels = &mDayLabels; |
1561 | weekLabels = &mWeekLabels; | 1561 | weekLabels = &mWeekLabels; |
1562 | } | 1562 | } |
1563 | 1563 | ||
1564 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1564 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1565 | 1565 | ||
1566 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1566 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1567 | mWeekStartsMonday = true; | 1567 | mWeekStartsMonday = true; |
1568 | } | 1568 | } |
1569 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1569 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1570 | 1570 | ||
1571 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1571 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1572 | mStartDate = mStartDate.addDays( -1 ); | 1572 | mStartDate = mStartDate.addDays( -1 ); |
1573 | } | 1573 | } |
1574 | bool primary = false; | 1574 | bool primary = false; |
1575 | uint i; | 1575 | uint i; |
1576 | for( i = 0; i < (*cells).size(); ++i ) { | 1576 | for( i = 0; i < (*cells).size(); ++i ) { |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 2622d10..0f3aa54 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -1,345 +1,345 @@ | |||
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 MonthViewCell; | 47 | class MonthViewCell; |
48 | class KOWeekButton : public QPushButton | 48 | class KOWeekButton : public QPushButton |
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | public: | 51 | public: |
52 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : | 52 | KOWeekButton( QWidget *parent=0, const char *name=0 ) : |
53 | QPushButton( parent, name) | 53 | QPushButton( parent, name) |
54 | { | 54 | { |
55 | connect( this, SIGNAL( clicked() ), | 55 | connect( this, SIGNAL( clicked() ), |
56 | SLOT( bottonClicked() )); | 56 | SLOT( bottonClicked() )); |
57 | mNumber = -1; | 57 | mNumber = -1; |
58 | } | 58 | } |
59 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} | 59 | void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} |
60 | int getWeekNum() { return mNumber;} | 60 | int getWeekNum() { return mNumber;} |
61 | signals: | 61 | signals: |
62 | void selectWeekNum ( int ); | 62 | void selectWeekNum ( int ); |
63 | private: | 63 | private: |
64 | void focusInEvent ( QFocusEvent * ){;} | 64 | void focusInEvent ( QFocusEvent * ){;} |
65 | int mNumber; | 65 | int mNumber; |
66 | void keyPressEvent ( QKeyEvent * e ) | 66 | void keyPressEvent ( QKeyEvent * e ) |
67 | { | 67 | { |
68 | e->ignore(); | 68 | e->ignore(); |
69 | } | 69 | } |
70 | 70 | ||
71 | private slots : | 71 | private slots : |
72 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } | 72 | void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } |
73 | }; | 73 | }; |
74 | 74 | ||
75 | class KNoScrollListBox: public QListBox | 75 | class KNoScrollListBox: public QListBox |
76 | { | 76 | { |
77 | Q_OBJECT | 77 | Q_OBJECT |
78 | public: | 78 | public: |
79 | KNoScrollListBox(QWidget *parent=0, const char *name=0); | 79 | KNoScrollListBox(QWidget *parent=0, const char *name=0); |
80 | ~KNoScrollListBox(); | 80 | ~KNoScrollListBox(); |
81 | QString getWhatsThisText(QPoint p) ; | 81 | QString getWhatsThisText(QPoint p) ; |
82 | 82 | ||
83 | signals: | 83 | signals: |
84 | void shiftDown(); | 84 | void shiftDown(); |
85 | void shiftUp(); | 85 | void shiftUp(); |
86 | void rightClick(); | 86 | void rightClick(); |
87 | void nextCell(); | 87 | void nextCell(); |
88 | void prevCell(); | 88 | void prevCell(); |
89 | void highligtIncidence( Incidence * , MonthViewCell*, int ); | 89 | void highlightIncidence( Incidence * , MonthViewCell*, int ); |
90 | 90 | ||
91 | protected slots: | 91 | protected slots: |
92 | void oneDown(); | 92 | void oneDown(); |
93 | void keyPressEvent(QKeyEvent *); | 93 | void keyPressEvent(QKeyEvent *); |
94 | void keyReleaseEvent(QKeyEvent *); | 94 | void keyReleaseEvent(QKeyEvent *); |
95 | void mousePressEvent(QMouseEvent *); | 95 | void mousePressEvent(QMouseEvent *); |
96 | void focusInEvent ( QFocusEvent * ); | 96 | void focusInEvent ( QFocusEvent * ); |
97 | void focusOutEvent ( QFocusEvent * ); | 97 | void focusOutEvent ( QFocusEvent * ); |
98 | 98 | ||
99 | private: | 99 | private: |
100 | bool resetOnFocusIn; | 100 | bool resetOnFocusIn; |
101 | KNOWhatsThis * mWT; | 101 | KNOWhatsThis * mWT; |
102 | }; | 102 | }; |
103 | 103 | ||
104 | 104 | ||
105 | class MonthViewItem: public QListBoxItem | 105 | class MonthViewItem: public QListBoxItem |
106 | { | 106 | { |
107 | public: | 107 | public: |
108 | MonthViewItem( Incidence *,const QString & title ); | 108 | MonthViewItem( Incidence *,const QString & title ); |
109 | void recycle( Incidence *incidence, const QString & s); | 109 | void recycle( Incidence *incidence, const QString & s); |
110 | void setRecur(bool on) { mRecur = on; } | 110 | void setRecur(bool on) { mRecur = on; } |
111 | void setAlarm(bool on) { mAlarm = on; } | 111 | void setAlarm(bool on) { mAlarm = on; } |
112 | void setReply(bool on) { mReply = on; } | 112 | void setReply(bool on) { mReply = on; } |
113 | void setMoreInfo(bool on) { mInfo = on; } | 113 | void setMoreInfo(bool on) { mInfo = on; } |
114 | void setMultiDay(int type) { mMultiday = type; } | 114 | void setMultiDay(int type) { mMultiday = type; } |
115 | int multiDay() { return mMultiday; } | 115 | int multiDay() { return mMultiday; } |
116 | void setMultiDayPos(int type) { mdayPos = type; } | 116 | void setMultiDayPos(int type) { mdayPos = type; } |
117 | int gettMultiDayPos() { return mdayPos; } | 117 | int gettMultiDayPos() { return mdayPos; } |
118 | void setBlockRepaint(bool on) { mblockRepaint = on; } | 118 | void setBlockRepaint(bool on) { mblockRepaint = on; } |
119 | bool setHighlighted( Incidence * ); | 119 | bool setHighlighted( Incidence * ); |
120 | 120 | ||
121 | void setPalette(const QPalette &p) { mPalette = p; } | 121 | void setPalette(const QPalette &p) { mPalette = p; } |
122 | QPalette palette() const { return mPalette; } | 122 | QPalette palette() const { return mPalette; } |
123 | bool setHighlightedFalse(); | 123 | bool setHighlightedFalse(); |
124 | Incidence *incidence() const { return mIncidence; } | 124 | Incidence *incidence() const { return mIncidence; } |
125 | 125 | ||
126 | protected: | 126 | protected: |
127 | virtual void paint(QPainter *); | 127 | virtual void paint(QPainter *); |
128 | virtual int height(const QListBox *) const; | 128 | virtual int height(const QListBox *) const; |
129 | virtual int width(const QListBox *) const; | 129 | virtual int width(const QListBox *) const; |
130 | 130 | ||
131 | private: | 131 | private: |
132 | int mdayPos; | 132 | int mdayPos; |
133 | bool isWeekItem; | 133 | bool isWeekItem; |
134 | bool mblockRepaint; | 134 | bool mblockRepaint; |
135 | int mMultiday; | 135 | int mMultiday; |
136 | bool mRecur; | 136 | bool mRecur; |
137 | bool mAlarm; | 137 | bool mAlarm; |
138 | bool mReply; | 138 | bool mReply; |
139 | bool mInfo; | 139 | bool mInfo; |
140 | bool mDisplayHightlighted; | 140 | bool mDisplayHighlighted; |
141 | 141 | ||
142 | QPalette mPalette; | 142 | QPalette mPalette; |
143 | QDate mDate; | 143 | QDate mDate; |
144 | 144 | ||
145 | Incidence *mIncidence; | 145 | Incidence *mIncidence; |
146 | }; | 146 | }; |
147 | 147 | ||
148 | 148 | ||
149 | class KOMonthView; | 149 | class KOMonthView; |
150 | 150 | ||
151 | class MonthViewCell : public KNoScrollListBox | 151 | class MonthViewCell : public KNoScrollListBox |
152 | { | 152 | { |
153 | Q_OBJECT | 153 | Q_OBJECT |
154 | public: | 154 | public: |
155 | MonthViewCell(KOMonthView *,QWidget* ); | 155 | MonthViewCell(KOMonthView *,QWidget* ); |
156 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} | 156 | ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} |
157 | 157 | ||
158 | void setDate( const QDate & ); | 158 | void setDate( const QDate & ); |
159 | QDate date() const; | 159 | QDate date() const; |
160 | 160 | ||
161 | void setPrimary( bool ); | 161 | void setPrimary( bool ); |
162 | bool isPrimary() const; | 162 | bool isPrimary() const; |
163 | 163 | ||
164 | void setHoliday( bool ); | 164 | void setHoliday( bool ); |
165 | void setHoliday( const QString & ); | 165 | void setHoliday( const QString & ); |
166 | 166 | ||
167 | void updateCell(); | 167 | void updateCell(); |
168 | void startUpdateCell(); | 168 | void startUpdateCell(); |
169 | void finishUpdateCell(); | 169 | void finishUpdateCell(); |
170 | void repaintfinishUpdateCell(); | 170 | void repaintfinishUpdateCell(); |
171 | int insertEvent(Event *); | 171 | int insertEvent(Event *); |
172 | void insertTodo(Todo *); | 172 | void insertTodo(Todo *); |
173 | 173 | ||
174 | void updateConfig( bool bigFont = false ); | 174 | void updateConfig( bool bigFont = false ); |
175 | 175 | ||
176 | void enableScrollBars( bool ); | 176 | void enableScrollBars( bool ); |
177 | 177 | ||
178 | Incidence *selectedIncidence(); | 178 | Incidence *selectedIncidence(); |
179 | QDate selectedIncidenceDate(); | 179 | QDate selectedIncidenceDate(); |
180 | QPushButton * dateLabel() { return mLabel; } | 180 | QPushButton * dateLabel() { return mLabel; } |
181 | void deHightLight(); | 181 | void deHighLight(); |
182 | bool doHightLight( Incidence *); | 182 | bool doHighLight( Incidence *); |
183 | void deselect(); | 183 | void deselect(); |
184 | void select(); | 184 | void select(); |
185 | #ifdef DESKTOP_VERSION | 185 | #ifdef DESKTOP_VERSION |
186 | static QToolTipGroup *toolTipGroup(); | 186 | static QToolTipGroup *toolTipGroup(); |
187 | #endif | 187 | #endif |
188 | signals: | 188 | signals: |
189 | void defaultAction( Incidence * ); | 189 | void defaultAction( Incidence * ); |
190 | void newEventSignal( QDateTime ); | 190 | void newEventSignal( QDateTime ); |
191 | void showDaySignal( QDate ); | 191 | void showDaySignal( QDate ); |
192 | 192 | ||
193 | protected: | 193 | protected: |
194 | QStringList mToolTip; | 194 | QStringList mToolTip; |
195 | void resizeEvent( QResizeEvent * ); | 195 | void resizeEvent( QResizeEvent * ); |
196 | 196 | ||
197 | public slots: | 197 | public slots: |
198 | void showDay(); | 198 | void showDay(); |
199 | protected slots: | 199 | protected slots: |
200 | void defaultAction( QListBoxItem * ); | 200 | void defaultAction( QListBoxItem * ); |
201 | void contextMenu( QListBoxItem * ); | 201 | void contextMenu( QListBoxItem * ); |
202 | void selection( QListBoxItem * ); | 202 | void selection( QListBoxItem * ); |
203 | void cellClicked( QListBoxItem * ); | 203 | void cellClicked( QListBoxItem * ); |
204 | void newEvent(); | 204 | void newEvent(); |
205 | 205 | ||
206 | private: | 206 | private: |
207 | int mdayCount; | 207 | int mdayCount; |
208 | QPtrList <MonthViewItem> mAvailItemList; | 208 | QPtrList <MonthViewItem> mAvailItemList; |
209 | KOMonthView *mMonthView; | 209 | KOMonthView *mMonthView; |
210 | int currentPalette; | 210 | int currentPalette; |
211 | 211 | ||
212 | QDate mDate; | 212 | QDate mDate; |
213 | bool mPrimary; | 213 | bool mPrimary; |
214 | bool mHoliday; | 214 | bool mHoliday; |
215 | QString mHolidayString; | 215 | QString mHolidayString; |
216 | 216 | ||
217 | //QLabel *mLabel; | 217 | //QLabel *mLabel; |
218 | QPushButton *mLabel; | 218 | QPushButton *mLabel; |
219 | //QListBox *mItemList; | 219 | //QListBox *mItemList; |
220 | #ifdef DESKTOP_VERSION | 220 | #ifdef DESKTOP_VERSION |
221 | static QToolTipGroup *mToolTipGroup; | 221 | static QToolTipGroup *mToolTipGroup; |
222 | #endif | 222 | #endif |
223 | QSize mLabelSize; | 223 | QSize mLabelSize; |
224 | QSize mLabelBigSize; | 224 | QSize mLabelBigSize; |
225 | QPalette mHolidayPalette; | 225 | QPalette mHolidayPalette; |
226 | QPalette mStandardPalette; | 226 | QPalette mStandardPalette; |
227 | QPalette mPrimaryPalette; | 227 | QPalette mPrimaryPalette; |
228 | QPalette mNonPrimaryPalette; | 228 | QPalette mNonPrimaryPalette; |
229 | void setMyPalette(); | 229 | void setMyPalette(); |
230 | QPalette getPalette (); | 230 | QPalette getPalette (); |
231 | 231 | ||
232 | }; | 232 | }; |
233 | 233 | ||
234 | 234 | ||
235 | class KOMonthView: public KOEventView | 235 | class KOMonthView: public KOEventView |
236 | { | 236 | { |
237 | Q_OBJECT | 237 | Q_OBJECT |
238 | public: | 238 | public: |
239 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); | 239 | KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); |
240 | ~KOMonthView(); | 240 | ~KOMonthView(); |
241 | 241 | ||
242 | /** Returns maximum number of days supported by the komonthview */ | 242 | /** Returns maximum number of days supported by the komonthview */ |
243 | virtual int maxDatesHint(); | 243 | virtual int maxDatesHint(); |
244 | 244 | ||
245 | /** Returns number of currently shown dates. */ | 245 | /** Returns number of currently shown dates. */ |
246 | virtual int currentDateCount(); | 246 | virtual int currentDateCount(); |
247 | 247 | ||
248 | /** returns the currently selected events */ | 248 | /** returns the currently selected events */ |
249 | virtual QPtrList<Incidence> selectedIncidences(); | 249 | virtual QPtrList<Incidence> selectedIncidences(); |
250 | 250 | ||
251 | /** returns dates of the currently selected events */ | 251 | /** returns dates of the currently selected events */ |
252 | virtual DateList selectedDates(); | 252 | virtual DateList selectedDates(); |
253 | 253 | ||
254 | virtual void printPreview(CalPrinter *calPrinter, | 254 | virtual void printPreview(CalPrinter *calPrinter, |
255 | const QDate &, const QDate &); | 255 | const QDate &, const QDate &); |
256 | bool isMonthView() { return !mShowWeekView; } | 256 | bool isMonthView() { return !mShowWeekView; } |
257 | bool isUpdatePossible() { return updatePossible; } | 257 | bool isUpdatePossible() { return updatePossible; } |
258 | 258 | ||
259 | MonthViewCell * selectedCell(); | 259 | MonthViewCell * selectedCell(); |
260 | bool skipResize; | 260 | bool skipResize; |
261 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} | 261 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} |
262 | void clearList(); | 262 | void clearList(); |
263 | public slots: | 263 | public slots: |
264 | void incidenceHighlighted( Incidence *, MonthViewCell*, int ); | 264 | void incidenceHighlighted( Incidence *, MonthViewCell*, int ); |
265 | void nextCell(); | 265 | void nextCell(); |
266 | void prevCell(); | 266 | void prevCell(); |
267 | virtual void updateView(); | 267 | virtual void updateView(); |
268 | virtual void updateConfig(); | 268 | virtual void updateConfig(); |
269 | virtual void showDates(const QDate &start, const QDate &end); | 269 | virtual void showDates(const QDate &start, const QDate &end); |
270 | virtual void showEvents(QPtrList<Event> eventList); | 270 | virtual void showEvents(QPtrList<Event> eventList); |
271 | 271 | ||
272 | void changeEventDisplay(Event *, int); | 272 | void changeEventDisplay(Event *, int); |
273 | 273 | ||
274 | void clearSelection(); | 274 | void clearSelection(); |
275 | 275 | ||
276 | void showContextMenu( Incidence * ); | 276 | void showContextMenu( Incidence * ); |
277 | 277 | ||
278 | void setSelectedCell( MonthViewCell * ); | 278 | void setSelectedCell( MonthViewCell * ); |
279 | void setPopupCell( MonthViewCell * ); | 279 | void setPopupCell( MonthViewCell * ); |
280 | void switchView(); | 280 | void switchView(); |
281 | void setKeyBoardFocus(); | 281 | void setKeyBoardFocus(); |
282 | void setKeyBFocus(); | 282 | void setKeyBFocus(); |
283 | 283 | ||
284 | protected slots: | 284 | protected slots: |
285 | void slotNewTodo(); | 285 | void slotNewTodo(); |
286 | void slotNewEvent(); | 286 | void slotNewEvent(); |
287 | void slotEditJournal(); | 287 | void slotEditJournal(); |
288 | void slotComputeLayout(); | 288 | void slotComputeLayout(); |
289 | void selectInternalWeekNum ( int ); | 289 | void selectInternalWeekNum ( int ); |
290 | void processSelectionChange(); | 290 | void processSelectionChange(); |
291 | signals: | 291 | signals: |
292 | void nextMonth(); | 292 | void nextMonth(); |
293 | void prevMonth(); | 293 | void prevMonth(); |
294 | void selectWeekNum ( int ); | 294 | void selectWeekNum ( int ); |
295 | void selectMonth (); | 295 | void selectMonth (); |
296 | void showDaySignal( QDate ); | 296 | void showDaySignal( QDate ); |
297 | void newTodoSignal( QDateTime, bool ); | 297 | void newTodoSignal( QDateTime, bool ); |
298 | void showJournalSignal( int,QDate ); | 298 | void showJournalSignal( int,QDate ); |
299 | protected: | 299 | protected: |
300 | void resizeEvent(QResizeEvent *); | 300 | void resizeEvent(QResizeEvent *); |
301 | void viewChanged(); | 301 | void viewChanged(); |
302 | void updateDayLabels(); | 302 | void updateDayLabels(); |
303 | 303 | ||
304 | private: | 304 | private: |
305 | QTimer* mComputeLayoutTimer; | 305 | QTimer* mComputeLayoutTimer; |
306 | NavigatorBar* mNavigatorBar; | 306 | NavigatorBar* mNavigatorBar; |
307 | int currentWeek(); | 307 | int currentWeek(); |
308 | bool clPending; | 308 | bool clPending; |
309 | QWidgetStack * mWidStack; | 309 | QWidgetStack * mWidStack; |
310 | QWidget* mMonthView; | 310 | QWidget* mMonthView; |
311 | QWidget* mWeekView; | 311 | QWidget* mWeekView; |
312 | bool mShowWeekView; | 312 | bool mShowWeekView; |
313 | bool updatePossible; | 313 | bool updatePossible; |
314 | int mDaysPerWeek; | 314 | int mDaysPerWeek; |
315 | int mNumWeeks; | 315 | int mNumWeeks; |
316 | int mNumCells; | 316 | int mNumCells; |
317 | //bool mWeekStartsMonday; | 317 | //bool mWeekStartsMonday; |
318 | bool mShowSatSunComp; | 318 | bool mShowSatSunComp; |
319 | void computeLayout(); | 319 | void computeLayout(); |
320 | void computeLayoutWeek(); | 320 | void computeLayoutWeek(); |
321 | 321 | ||
322 | QPtrVector<MonthViewCell> mCells; | 322 | QPtrVector<MonthViewCell> mCells; |
323 | QPtrVector<QLabel> mDayLabels; | 323 | QPtrVector<QLabel> mDayLabels; |
324 | QPtrVector<KOWeekButton> mWeekLabels; | 324 | QPtrVector<KOWeekButton> mWeekLabels; |
325 | QPtrVector<MonthViewCell> mCellsW; | 325 | QPtrVector<MonthViewCell> mCellsW; |
326 | QPtrVector<QLabel> mDayLabelsW; | 326 | QPtrVector<QLabel> mDayLabelsW; |
327 | QPtrVector<KOWeekButton> mWeekLabelsW; | 327 | QPtrVector<KOWeekButton> mWeekLabelsW; |
328 | 328 | ||
329 | bool mShortDayLabelsM; | 329 | bool mShortDayLabelsM; |
330 | bool mShortDayLabelsW; | 330 | bool mShortDayLabelsW; |
331 | int mWidthLongDayLabel; | 331 | int mWidthLongDayLabel; |
332 | 332 | ||
333 | QDate mStartDate; | 333 | QDate mStartDate; |
334 | 334 | ||
335 | MonthViewCell *mSelectedCell; | 335 | MonthViewCell *mSelectedCell; |
336 | MonthViewCell *mPopupCell; | 336 | MonthViewCell *mPopupCell; |
337 | bool mFlagKeyPressed; | 337 | bool mFlagKeyPressed; |
338 | KOEventPopupMenu *mContextMenu; | 338 | KOEventPopupMenu *mContextMenu; |
339 | QPopupMenu *mNewItemMenu; | 339 | QPopupMenu *mNewItemMenu; |
340 | void keyPressEvent ( QKeyEvent * ) ; | 340 | void keyPressEvent ( QKeyEvent * ) ; |
341 | void keyReleaseEvent ( QKeyEvent * ) ; | 341 | void keyReleaseEvent ( QKeyEvent * ) ; |
342 | 342 | ||
343 | }; | 343 | }; |
344 | 344 | ||
345 | #endif | 345 | #endif |