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