author | zautrix <zautrix> | 2005-03-25 02:15:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-25 02:15:46 (UTC) |
commit | 658354b7112aff72f0fadd924c82b977d803bc27 (patch) (unidiff) | |
tree | da728354015340c16466fbfb3c851d96d6d95196 | |
parent | 7c2e130ddd194f1c4b5365af6999a27c08232f4b (diff) | |
download | kdepimpi-658354b7112aff72f0fadd924c82b977d803bc27.zip kdepimpi-658354b7112aff72f0fadd924c82b977d803bc27.tar.gz kdepimpi-658354b7112aff72f0fadd924c82b977d803bc27.tar.bz2 |
fixes
-rw-r--r-- | korganizer/komonthview.cpp | 88 |
1 files changed, 55 insertions, 33 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 8ee5bc3..050bfb9 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1180 +1,1202 @@ | |||
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-1 ,x+wid, heihei/2-1 ); | 308 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); |
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 | int ret = 10; | ||
315 | if ( lb ) | 316 | if ( lb ) |
316 | return lb->fontMetrics().lineSpacing()+1; | 317 | ret = lb->fontMetrics().lineSpacing()+1; |
317 | return 10; | 318 | return ret; |
318 | } | 319 | } |
319 | 320 | ||
320 | int MonthViewItem::width(const QListBox *lb) const | 321 | int MonthViewItem::width(const QListBox *lb) const |
321 | { | 322 | { |
322 | int size = PIXMAP_SIZE; | 323 | |
323 | if ( QApplication::desktop()->width() < 300 ) | 324 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
324 | size = 3; | 325 | int size = PIXMAP_SIZE; |
325 | int x = 1; | 326 | if ( QApplication::desktop()->width() < 300 ) |
326 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 327 | size = 3; |
327 | if ( mInfo ) { | 328 | int x = 1; |
328 | x += size + 1; | 329 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
329 | } | 330 | if ( mInfo ) { |
330 | if( mRecur ) { | 331 | x += size + 1; |
331 | x += size+1; | 332 | } |
332 | } | 333 | if( mRecur ) { |
333 | if( mAlarm ) { | 334 | x += size+1; |
334 | x += size+1; | 335 | } |
336 | if( mAlarm ) { | ||
337 | x += size+1; | ||
338 | } | ||
339 | if( mReply ) { | ||
340 | x += size+1; | ||
341 | } | ||
335 | } | 342 | } |
336 | if( mReply ) { | 343 | if( mMultiday ) { |
337 | x += size+1; | 344 | x += size+1+2+size/2; |
338 | } | 345 | } |
346 | return( x + lb->fontMetrics().width( text() ) + 1 ); | ||
339 | } | 347 | } |
340 | if( mMultiday ) { | 348 | if ( ! lb ) |
341 | x += size+1+2+size/2; | 349 | return 10; |
342 | } | 350 | //qDebug("ret wid %d ", lb->width()); |
343 | 351 | return lb->width(); | |
344 | return( x + lb->fontMetrics().width( text() ) + 1 ); | ||
345 | } | 352 | } |
346 | 353 | ||
347 | 354 | ||
348 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 355 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
349 | : QWidget( par ), | 356 | : QWidget( par ), |
350 | mMonthView( parent ) | 357 | mMonthView( parent ) |
351 | { | 358 | { |
352 | 359 | ||
353 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 360 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
354 | 361 | ||
355 | // mLabel = new QLabel( this );QPushButton | 362 | // mLabel = new QLabel( this );QPushButton |
356 | mLabel = new QPushButton( this ); | 363 | mLabel = new QPushButton( this ); |
357 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 364 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
358 | //mLabel->setLineWidth( 1 ); | 365 | //mLabel->setLineWidth( 1 ); |
359 | //mLabel->setAlignment( AlignCenter ); | 366 | //mLabel->setAlignment( AlignCenter ); |
360 | mLabel->setFlat( true ); | 367 | mLabel->setFlat( true ); |
361 | mLabel->setFocusPolicy(NoFocus); | 368 | mLabel->setFocusPolicy(NoFocus); |
362 | mItemList = new KNoScrollListBox( this ); | 369 | mItemList = new KNoScrollListBox( this ); |
363 | mItemList->setMinimumSize( 10, 10 ); | 370 | mItemList->setMinimumSize( 10, 10 ); |
364 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 371 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
365 | mItemList->setLineWidth( 1 ); | 372 | mItemList->setLineWidth( 1 ); |
366 | topLayout->addWidget( mItemList ); | 373 | //topLayout->addWidget( mItemList ); |
367 | mLabel->raise(); | 374 | mLabel->raise(); |
368 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 375 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
369 | mStandardPalette = palette(); | 376 | mStandardPalette = palette(); |
370 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 377 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
371 | 378 | ||
372 | enableScrollBars( false ); | 379 | enableScrollBars( false ); |
373 | updateConfig(); | 380 | updateConfig(); |
374 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 381 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
375 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 382 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
376 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 383 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
377 | SLOT( defaultAction( QListBoxItem * ) ) ); | 384 | SLOT( defaultAction( QListBoxItem * ) ) ); |
378 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 385 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
379 | const QPoint &) ), | 386 | const QPoint &) ), |
380 | SLOT( contextMenu( QListBoxItem * ) ) ); | 387 | SLOT( contextMenu( QListBoxItem * ) ) ); |
381 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 388 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
382 | SLOT( selection( QListBoxItem * ) ) ); | 389 | SLOT( selection( QListBoxItem * ) ) ); |
383 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 390 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
384 | SLOT( cellClicked( QListBoxItem * ) ) ); | 391 | SLOT( cellClicked( QListBoxItem * ) ) ); |
385 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 392 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
386 | SLOT( selection( QListBoxItem * ) ) ); | 393 | SLOT( selection( QListBoxItem * ) ) ); |
387 | } | 394 | } |
388 | #ifdef DESKTOP_VERSION | 395 | #ifdef DESKTOP_VERSION |
389 | QToolTipGroup *MonthViewCell::toolTipGroup() | 396 | QToolTipGroup *MonthViewCell::toolTipGroup() |
390 | { | 397 | { |
391 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 398 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
392 | return mToolTipGroup; | 399 | return mToolTipGroup; |
393 | } | 400 | } |
394 | #endif | 401 | #endif |
395 | 402 | ||
396 | void MonthViewCell::setDate( const QDate &date ) | 403 | void MonthViewCell::setDate( const QDate &date ) |
397 | { | 404 | { |
398 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 405 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
399 | mDate = date; | 406 | mDate = date; |
400 | 407 | ||
401 | 408 | ||
402 | 409 | ||
403 | //resizeEvent( 0 ); | 410 | //resizeEvent( 0 ); |
404 | } | 411 | } |
405 | 412 | ||
406 | QDate MonthViewCell::date() const | 413 | QDate MonthViewCell::date() const |
407 | { | 414 | { |
408 | return mDate; | 415 | return mDate; |
409 | } | 416 | } |
410 | 417 | ||
411 | void MonthViewCell::setPrimary( bool primary ) | 418 | void MonthViewCell::setPrimary( bool primary ) |
412 | { | 419 | { |
413 | mPrimary = primary; | 420 | mPrimary = primary; |
414 | //setMyPalette(); | 421 | //setMyPalette(); |
415 | } | 422 | } |
416 | void MonthViewCell::setMyPalette() | 423 | void MonthViewCell::setMyPalette() |
417 | { | 424 | { |
418 | 425 | ||
419 | if ( mHoliday) { | 426 | if ( mHoliday) { |
420 | setPalette( mHolidayPalette ); | 427 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
428 | mItemList->setPalette( mHolidayPalette ); | ||
421 | } else { | 429 | } else { |
422 | if ( mPrimary ) { | 430 | if ( mPrimary ) { |
423 | setPalette( mPrimaryPalette ); | 431 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
432 | mItemList->setPalette( mPrimaryPalette ); | ||
424 | } else { | 433 | } else { |
425 | setPalette( mNonPrimaryPalette ); | 434 | mItemList->setPalette( mNonPrimaryPalette ); |
435 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | ||
426 | } | 436 | } |
427 | } | 437 | } |
428 | QPalette pal = palette(); | 438 | //QPalette pal = palette(); |
429 | 439 | ||
430 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 440 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
431 | } | 441 | } |
432 | QPalette MonthViewCell::getPalette () | 442 | QPalette MonthViewCell::getPalette () |
433 | { | 443 | { |
434 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 444 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
435 | return mStandardPalette; | 445 | return mStandardPalette; |
436 | if ( mHoliday) { | 446 | if ( mHoliday) { |
437 | return mHolidayPalette ; | 447 | return mHolidayPalette ; |
438 | } else { | 448 | } else { |
439 | if ( mPrimary ) { | 449 | if ( mPrimary ) { |
440 | return mPrimaryPalette ; | 450 | return mPrimaryPalette ; |
441 | } | 451 | } |
442 | } | 452 | } |
443 | return mNonPrimaryPalette; | 453 | return mNonPrimaryPalette; |
444 | } | 454 | } |
445 | bool MonthViewCell::isPrimary() const | 455 | bool MonthViewCell::isPrimary() const |
446 | { | 456 | { |
447 | return mPrimary; | 457 | return mPrimary; |
448 | } | 458 | } |
449 | 459 | ||
450 | void MonthViewCell::setHoliday( bool holiday ) | 460 | void MonthViewCell::setHoliday( bool holiday ) |
451 | { | 461 | { |
452 | mHoliday = holiday; | 462 | mHoliday = holiday; |
453 | //setMyPalette(); | 463 | //setMyPalette(); |
454 | } | 464 | } |
455 | 465 | ||
456 | void MonthViewCell::setHoliday( const QString &holiday ) | 466 | void MonthViewCell::setHoliday( const QString &holiday ) |
457 | { | 467 | { |
458 | mHolidayString = holiday; | 468 | mHolidayString = holiday; |
459 | 469 | ||
460 | if ( !holiday.isEmpty() ) { | 470 | if ( !holiday.isEmpty() ) { |
461 | setHoliday( true ); | 471 | setHoliday( true ); |
462 | } | 472 | } |
463 | } | 473 | } |
464 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 474 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
465 | { | 475 | { |
466 | 476 | ||
467 | e->ignore(); | 477 | e->ignore(); |
468 | 478 | ||
469 | } | 479 | } |
470 | 480 | ||
471 | void MonthViewCell::startUpdateCell() | 481 | void MonthViewCell::startUpdateCell() |
472 | { | 482 | { |
473 | 483 | ||
474 | mItemList->setFocusPolicy(NoFocus); | 484 | mItemList->setFocusPolicy(NoFocus); |
475 | if ( !mMonthView->isUpdatePossible() ) | 485 | if ( !mMonthView->isUpdatePossible() ) |
476 | return; | 486 | return; |
477 | 487 | ||
478 | /* | 488 | /* |
479 | if ( !isVisible() ){ | 489 | if ( !isVisible() ){ |
480 | return; | 490 | return; |
481 | } | 491 | } |
482 | */ | 492 | */ |
483 | // qDebug("MonthViewCell::updateCell() "); | 493 | // qDebug("MonthViewCell::updateCell() "); |
484 | setPrimary( mDate.month()%2 ); | 494 | setPrimary( mDate.month()%2 ); |
485 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 495 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
486 | if ( mDate == QDate::currentDate() ) { | 496 | if ( mDate == QDate::currentDate() ) { |
487 | mItemList->setLineWidth( 3 ); | 497 | mItemList->setLineWidth( 3 ); |
488 | } else { | 498 | } else { |
489 | mItemList->setLineWidth( 1 ); | 499 | mItemList->setLineWidth( 1 ); |
490 | } | 500 | } |
491 | mItemList->clear(); | 501 | mItemList->clear(); |
492 | 502 | ||
493 | #ifdef DESKTOP_VERSION | 503 | #ifdef DESKTOP_VERSION |
494 | QToolTip::remove(this); | 504 | QToolTip::remove(this); |
495 | #endif | 505 | #endif |
496 | mToolTip.clear(); | 506 | mToolTip.clear(); |
497 | //qApp->processEvents(); | 507 | //qApp->processEvents(); |
498 | if ( !mHolidayString.isEmpty() ) { | 508 | if ( !mHolidayString.isEmpty() ) { |
499 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 509 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
500 | item->setPalette( mHolidayPalette ); | 510 | item->setPalette( mHolidayPalette ); |
501 | mItemList->insertItem( item ); | 511 | mItemList->insertItem( item ); |
502 | mToolTip.append ( mHolidayString ); | 512 | mToolTip.append ( mHolidayString ); |
503 | } | 513 | } |
504 | } | 514 | } |
505 | 515 | ||
506 | void MonthViewCell::insertEvent(Event *event) | 516 | void MonthViewCell::insertEvent(Event *event) |
507 | { | 517 | { |
508 | QString mToolTipText; | 518 | QString mToolTipText; |
509 | mItemList->setFocusPolicy(WheelFocus); | 519 | mItemList->setFocusPolicy(WheelFocus); |
510 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 520 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
511 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 521 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
512 | return; | 522 | return; |
513 | else | 523 | else |
514 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 524 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
515 | return; | 525 | return; |
516 | } | 526 | } |
517 | 527 | ||
518 | if ( event->isHoliday()) { | 528 | if ( event->isHoliday()) { |
519 | setHoliday( true ); | 529 | setHoliday( true ); |
520 | if ( mDate.dayOfWeek() == 7 ) | 530 | if ( mDate.dayOfWeek() == 7 ) |
521 | mItemList->setLineWidth( 3 ); | 531 | mItemList->setLineWidth( 3 ); |
522 | } | 532 | } |
523 | QString text; | 533 | QString text; |
524 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 534 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
525 | if (event->isMultiDay()) { | 535 | if (event->isMultiDay()) { |
526 | QString prefix = "<->";multiday = 2; | 536 | QString prefix = "<->";multiday = 2; |
527 | QString time; | 537 | QString time; |
528 | if ( event->doesRecur() ) { | 538 | if ( event->doesRecur() ) { |
529 | if ( event->recursOn( mDate) ) { | 539 | if ( event->recursOn( mDate) ) { |
530 | prefix ="->" ;multiday = 1; | 540 | prefix ="->" ;multiday = 1; |
531 | } | 541 | } |
532 | else { | 542 | else { |
533 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 543 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
534 | if ( event->recursOn( mDate.addDays( -days)) ) { | 544 | if ( event->recursOn( mDate.addDays( -days)) ) { |
535 | prefix ="<-" ;multiday = 3; | 545 | prefix ="<-" ;multiday = 3; |
536 | } | 546 | } |
537 | } | 547 | } |
538 | 548 | ||
539 | } else { | 549 | } else { |
540 | if (mDate == event->dtStart().date()) { | 550 | if (mDate == event->dtStart().date()) { |
541 | prefix ="->" ;multiday = 1; | 551 | prefix ="->" ;multiday = 1; |
542 | } else if (mDate == event->dtEnd().date()) { | 552 | } else if (mDate == event->dtEnd().date()) { |
543 | prefix ="<-" ;multiday = 3; | 553 | prefix ="<-" ;multiday = 3; |
544 | } | 554 | } |
545 | } | 555 | } |
546 | if ( !event->doesFloat() ) { | 556 | if ( !event->doesFloat() ) { |
547 | if ( mDate == event->dtStart().date () ) | 557 | if ( mDate == event->dtStart().date () ) |
548 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 558 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
549 | else if ( mDate == event->dtEnd().date () ) | 559 | else if ( mDate == event->dtEnd().date () ) |
550 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 560 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
551 | 561 | ||
552 | } | 562 | } |
553 | text = time + event->summary(); | 563 | text = time + event->summary(); |
554 | mToolTipText += prefix + text; | 564 | mToolTipText += prefix + text; |
555 | } else { | 565 | } else { |
556 | if (event->doesFloat()) { | 566 | if (event->doesFloat()) { |
557 | text = event->summary(); | 567 | text = event->summary(); |
558 | mToolTipText += text; | 568 | mToolTipText += text; |
559 | } | 569 | } |
560 | else { | 570 | else { |
561 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 571 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
562 | text += " " + event->summary(); | 572 | text += " " + event->summary(); |
563 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 573 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
564 | } | 574 | } |
565 | } | 575 | } |
566 | 576 | ||
567 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 577 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
568 | QPalette pal; | 578 | QPalette pal; |
569 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 579 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
570 | QStringList categories = event->categories(); | 580 | QStringList categories = event->categories(); |
571 | QString cat = categories.first(); | 581 | QString cat = categories.first(); |
572 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 582 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
573 | pal = getPalette(); | 583 | pal = getPalette(); |
574 | if (cat.isEmpty()) { | 584 | if (cat.isEmpty()) { |
575 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 585 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
576 | } else { | 586 | } else { |
577 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 587 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
578 | } | 588 | } |
579 | 589 | ||
580 | } else { | 590 | } else { |
581 | if (cat.isEmpty()) { | 591 | if (cat.isEmpty()) { |
582 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 592 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
583 | } else { | 593 | } else { |
584 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 594 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
585 | } | 595 | } |
586 | } | 596 | } |
587 | 597 | ||
588 | } else { | 598 | } else { |
589 | pal = mStandardPalette ; | 599 | pal = mStandardPalette ; |
590 | } | 600 | } |
591 | item->setPalette( pal ); | 601 | item->setPalette( pal ); |
592 | item->setRecur( event->recurrence()->doesRecur() ); | 602 | item->setRecur( event->recurrence()->doesRecur() ); |
593 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 603 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
594 | item->setMoreInfo( event->description().length() > 0 ); | 604 | item->setMoreInfo( event->description().length() > 0 ); |
595 | #ifdef DESKTOP_VERSION | 605 | #ifdef DESKTOP_VERSION |
596 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 606 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
597 | KOPrefs::instance()->email()); | 607 | KOPrefs::instance()->email()); |
598 | if ( me != 0 ) { | 608 | if ( me != 0 ) { |
599 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 609 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
600 | item->setReply(true && multiday < 2); | 610 | item->setReply(true && multiday < 2); |
601 | else | 611 | else |
602 | item->setReply(false); | 612 | item->setReply(false); |
603 | } else | 613 | } else |
604 | item->setReply(false); | 614 | item->setReply(false); |
605 | #endif | 615 | #endif |
606 | item->setMultiDay( multiday ); | 616 | item->setMultiDay( multiday ); |
607 | mItemList->insertItem( item ); | 617 | mItemList->insertItem( item ); |
608 | mToolTip.append( mToolTipText ); | 618 | mToolTip.append( mToolTipText ); |
609 | } | 619 | } |
610 | void MonthViewCell::insertTodo(Todo *todo) | 620 | void MonthViewCell::insertTodo(Todo *todo) |
611 | { | 621 | { |
612 | mItemList->setFocusPolicy(WheelFocus); | 622 | mItemList->setFocusPolicy(WheelFocus); |
613 | QString text; | 623 | QString text; |
614 | if (todo->hasDueDate()) { | 624 | if (todo->hasDueDate()) { |
615 | if (!todo->doesFloat()) { | 625 | if (!todo->doesFloat()) { |
616 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 626 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
617 | text += " "; | 627 | text += " "; |
618 | } | 628 | } |
619 | } | 629 | } |
620 | text += todo->summary(); | 630 | text += todo->summary(); |
621 | 631 | ||
622 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 632 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
623 | //item->setPalette( mStandardPalette ); | 633 | //item->setPalette( mStandardPalette ); |
624 | QPalette pal; | 634 | QPalette pal; |
625 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 635 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
626 | QStringList categories = todo->categories(); | 636 | QStringList categories = todo->categories(); |
627 | QString cat = categories.first(); | 637 | QString cat = categories.first(); |
628 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 638 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
629 | pal = getPalette(); | 639 | pal = getPalette(); |
630 | if (cat.isEmpty()) { | 640 | if (cat.isEmpty()) { |
631 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 641 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
632 | } else { | 642 | } else { |
633 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 643 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
634 | } | 644 | } |
635 | 645 | ||
636 | } else { | 646 | } else { |
637 | if (cat.isEmpty()) { | 647 | if (cat.isEmpty()) { |
638 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 648 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
639 | } else { | 649 | } else { |
640 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 650 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
641 | } | 651 | } |
642 | } | 652 | } |
643 | 653 | ||
644 | } else { | 654 | } else { |
645 | pal = mStandardPalette ; | 655 | pal = mStandardPalette ; |
646 | } | 656 | } |
647 | item->setPalette( pal ); | 657 | item->setPalette( pal ); |
648 | item->setRecur( todo->recurrence()->doesRecur() ); | 658 | item->setRecur( todo->recurrence()->doesRecur() ); |
649 | item->setAlarm( todo->isAlarmEnabled() ); | 659 | item->setAlarm( todo->isAlarmEnabled() ); |
650 | item->setMoreInfo( todo->description().length() > 0 ); | 660 | item->setMoreInfo( todo->description().length() > 0 ); |
651 | mItemList->insertItem( item ); | 661 | mItemList->insertItem( item ); |
652 | mToolTip.append( text ); | 662 | mToolTip.append( text ); |
653 | } | 663 | } |
654 | void MonthViewCell::finishUpdateCell() | 664 | void MonthViewCell::finishUpdateCell() |
655 | { | 665 | { |
656 | #ifdef DESKTOP_VERSION | 666 | #ifdef DESKTOP_VERSION |
657 | if (mToolTip.count() > 0 ) { | 667 | if (mToolTip.count() > 0 ) { |
658 | mToolTip.sort(); | 668 | mToolTip.sort(); |
659 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 669 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
660 | } | 670 | } |
661 | #endif | 671 | #endif |
662 | mItemList->sort(); | 672 | mItemList->sort(); |
663 | //setMyPalette(); | 673 | //setMyPalette(); |
664 | setMyPalette(); | 674 | setMyPalette(); |
665 | QString text; | 675 | QString text; |
666 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 676 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
667 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 677 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
668 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 678 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
669 | mLabel->resize( mLabelBigSize ); | 679 | mLabel->resize( mLabelBigSize ); |
670 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 680 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
671 | } else { | 681 | } else { |
672 | mLabel->resize( mLabelSize ); | 682 | mLabel->resize( mLabelSize ); |
673 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 683 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
674 | } | 684 | } |
675 | 685 | ||
676 | mLabel->setText( text ); | 686 | mLabel->setText( text ); |
677 | resizeEvent( 0 ); | 687 | resizeEvent( 0 ); |
688 | |||
678 | } | 689 | } |
679 | void MonthViewCell::updateCell() | 690 | void MonthViewCell::updateCell() |
680 | { | 691 | { |
681 | //qDebug("MonthViewCell::updateCell() "); | 692 | //qDebug("MonthViewCell::updateCell() "); |
682 | if ( !mMonthView->isUpdatePossible() ) | 693 | if ( !mMonthView->isUpdatePossible() ) |
683 | return; | 694 | return; |
684 | startUpdateCell(); | 695 | startUpdateCell(); |
685 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 696 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
686 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 697 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
687 | Event *event; | 698 | Event *event; |
688 | for( event = events.first(); event; event = events.next() ) { // for event | 699 | for( event = events.first(); event; event = events.next() ) { // for event |
689 | insertEvent(event); | 700 | insertEvent(event); |
690 | } | 701 | } |
691 | // insert due todos | 702 | // insert due todos |
692 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 703 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
693 | Todo *todo; | 704 | Todo *todo; |
694 | for(todo = todos.first(); todo; todo = todos.next()) { | 705 | for(todo = todos.first(); todo; todo = todos.next()) { |
695 | insertTodo( todo ); | 706 | insertTodo( todo ); |
696 | } | 707 | } |
697 | finishUpdateCell(); | 708 | finishUpdateCell(); |
698 | // if ( isVisible()) | 709 | // if ( isVisible()) |
699 | //qApp->processEvents(); | 710 | //qApp->processEvents(); |
700 | } | 711 | } |
701 | 712 | ||
702 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 713 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
703 | { | 714 | { |
704 | 715 | ||
705 | if ( bigFont ) { | 716 | if ( bigFont ) { |
706 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 717 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
707 | int ps = fo.pointSize() + 2; | 718 | int ps = fo.pointSize() + 2; |
708 | if ( ps < 18 ) | 719 | if ( ps < 18 ) |
709 | ps += 2; | 720 | ps += 2; |
710 | fo.setPointSize( ps ); | 721 | fo.setPointSize( ps ); |
711 | setFont( fo ); | 722 | setFont( fo ); |
712 | } else | 723 | } else |
713 | setFont( KOPrefs::instance()->mMonthViewFont ); | 724 | setFont( KOPrefs::instance()->mMonthViewFont ); |
714 | 725 | ||
715 | QFontMetrics fm( font() ); | 726 | QFontMetrics fm( font() ); |
716 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 727 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
717 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 728 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
718 | mHolidayPalette = mStandardPalette; | 729 | mHolidayPalette = mStandardPalette; |
719 | mPrimaryPalette = mStandardPalette; | 730 | mPrimaryPalette = mStandardPalette; |
720 | mNonPrimaryPalette = mStandardPalette; | 731 | mNonPrimaryPalette = mStandardPalette; |
721 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 732 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
722 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 733 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
723 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 734 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
724 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 735 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
725 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 736 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
726 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 737 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
727 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 738 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
728 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 739 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
729 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 740 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
730 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 741 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
731 | } | 742 | } |
732 | //updateCell(); | 743 | //updateCell(); |
733 | } | 744 | } |
734 | 745 | ||
735 | void MonthViewCell::enableScrollBars( bool enabled ) | 746 | void MonthViewCell::enableScrollBars( bool enabled ) |
736 | { | 747 | { |
737 | if ( enabled ) { | 748 | if ( enabled ) { |
738 | mItemList->setVScrollBarMode(QScrollView::Auto); | 749 | //mItemList->setVScrollBarMode(QScrollView::Auto); |
739 | mItemList->setHScrollBarMode(QScrollView::Auto); | 750 | mItemList->setHScrollBarMode(QScrollView::Auto); |
751 | QListBoxItem *fi = mItemList->firstItem (); | ||
752 | if (fi ) { | ||
753 | int hei = mItemList->numRows () * fi->height(mItemList); | ||
754 | if ( hei < height() - mItemList->horizontalScrollBar()->height () ) | ||
755 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | ||
756 | else | ||
757 | mItemList->setVScrollBarMode(QScrollView::Auto); | ||
758 | } | ||
740 | } else { | 759 | } else { |
741 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 760 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
742 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 761 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
743 | } | 762 | } |
744 | } | 763 | } |
745 | 764 | ||
746 | Incidence *MonthViewCell::selectedIncidence() | 765 | Incidence *MonthViewCell::selectedIncidence() |
747 | { | 766 | { |
748 | int index = mItemList->currentItem(); | 767 | int index = mItemList->currentItem(); |
749 | if ( index < 0 ) return 0; | 768 | if ( index < 0 ) return 0; |
750 | 769 | ||
751 | MonthViewItem *item = | 770 | MonthViewItem *item = |
752 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 771 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
753 | 772 | ||
754 | if ( !item ) return 0; | 773 | if ( !item ) return 0; |
755 | 774 | ||
756 | return item->incidence(); | 775 | return item->incidence(); |
757 | } | 776 | } |
758 | 777 | ||
759 | QDate MonthViewCell::selectedIncidenceDate() | 778 | QDate MonthViewCell::selectedIncidenceDate() |
760 | { | 779 | { |
761 | QDate qd; | 780 | QDate qd; |
762 | int index = mItemList->currentItem(); | 781 | int index = mItemList->currentItem(); |
763 | if ( index < 0 ) return qd; | 782 | if ( index < 0 ) return qd; |
764 | 783 | ||
765 | MonthViewItem *item = | 784 | MonthViewItem *item = |
766 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 785 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
767 | 786 | ||
768 | if ( !item ) return qd; | 787 | if ( !item ) return qd; |
769 | 788 | ||
770 | return item->incidenceDate(); | 789 | return item->incidenceDate(); |
771 | } | 790 | } |
772 | 791 | ||
773 | void MonthViewCell::deselect() | 792 | void MonthViewCell::deselect() |
774 | { | 793 | { |
775 | mItemList->clearSelection(); | 794 | mItemList->clearSelection(); |
776 | enableScrollBars( false ); | 795 | enableScrollBars( false ); |
777 | // updateCell(); | 796 | // updateCell(); |
778 | } | 797 | } |
779 | void MonthViewCell::select() | 798 | void MonthViewCell::select() |
780 | { | 799 | { |
781 | ;// updateCell(); | 800 | ;// updateCell(); |
782 | } | 801 | } |
783 | 802 | ||
784 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 803 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
785 | { | 804 | { |
786 | if ( !mMonthView->isUpdatePossible() ) | 805 | if ( !mMonthView->isUpdatePossible() ) |
787 | return; | 806 | return; |
788 | 807 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | |
808 | deselect(); | ||
789 | int size = height() - mLabel->height() - 2; | 809 | int size = height() - mLabel->height() - 2; |
790 | if ( size > 0 ) | 810 | if ( size > 0 ) |
791 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 811 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
792 | size = width() - mLabel->width() -2; | 812 | size = width() - mLabel->width() -2; |
793 | if ( size > 0 ) | 813 | if ( size > 0 ) |
794 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 814 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
795 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 815 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
796 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 816 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
817 | mItemList->resize ( width(), height () ); | ||
818 | |||
797 | } | 819 | } |
798 | 820 | ||
799 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 821 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
800 | { | 822 | { |
801 | if ( !item ) return; | 823 | if ( !item ) return; |
802 | 824 | ||
803 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 825 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
804 | Incidence *incidence = eventItem->incidence(); | 826 | Incidence *incidence = eventItem->incidence(); |
805 | if ( incidence ) mMonthView->defaultAction( incidence ); | 827 | if ( incidence ) mMonthView->defaultAction( incidence ); |
806 | } | 828 | } |
807 | void MonthViewCell::showDay() | 829 | void MonthViewCell::showDay() |
808 | { | 830 | { |
809 | emit showDaySignal( date() ); | 831 | emit showDaySignal( date() ); |
810 | } | 832 | } |
811 | void MonthViewCell::newEvent() | 833 | void MonthViewCell::newEvent() |
812 | { | 834 | { |
813 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 835 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
814 | emit newEventSignal( dt ); | 836 | emit newEventSignal( dt ); |
815 | } | 837 | } |
816 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 838 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
817 | { | 839 | { |
818 | static QListBoxItem * lastClicked = 0; | 840 | static QListBoxItem * lastClicked = 0; |
819 | if ( item == 0 ) { | 841 | if ( item == 0 ) { |
820 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 842 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
821 | emit newEventSignal( dt ); | 843 | emit newEventSignal( dt ); |
822 | return; | 844 | return; |
823 | } | 845 | } |
824 | /* | 846 | /* |
825 | if ( lastClicked ) | 847 | if ( lastClicked ) |
826 | if ( ! item ) { | 848 | if ( ! item ) { |
827 | if ( lastClicked->listBox() != item->listBox() ) | 849 | if ( lastClicked->listBox() != item->listBox() ) |
828 | lastClicked->listBox()->clearSelection(); | 850 | lastClicked->listBox()->clearSelection(); |
829 | } | 851 | } |
830 | */ | 852 | */ |
831 | 853 | ||
832 | mMonthView->setSelectedCell( this ); | 854 | mMonthView->setSelectedCell( this ); |
833 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 855 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
834 | select(); | 856 | select(); |
835 | } | 857 | } |
836 | 858 | ||
837 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 859 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
838 | { | 860 | { |
839 | if ( !item ) return; | 861 | if ( !item ) return; |
840 | 862 | ||
841 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 863 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
842 | Incidence *incidence = eventItem->incidence(); | 864 | Incidence *incidence = eventItem->incidence(); |
843 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 865 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
844 | } | 866 | } |
845 | 867 | ||
846 | void MonthViewCell::selection( QListBoxItem *item ) | 868 | void MonthViewCell::selection( QListBoxItem *item ) |
847 | { | 869 | { |
848 | if ( !item ) return; | 870 | if ( !item ) return; |
849 | 871 | ||
850 | mMonthView->setSelectedCell( this ); | 872 | mMonthView->setSelectedCell( this ); |
851 | } | 873 | } |
852 | 874 | ||
853 | 875 | ||
854 | // ******************************************************************************* | 876 | // ******************************************************************************* |
855 | // ******************************************************************************* | 877 | // ******************************************************************************* |
856 | // ******************************************************************************* | 878 | // ******************************************************************************* |
857 | 879 | ||
858 | 880 | ||
859 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 881 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
860 | : KOEventView( calendar, parent, name ), | 882 | : KOEventView( calendar, parent, name ), |
861 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 883 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
862 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 884 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
863 | { | 885 | { |
864 | mShortDayLabelsM = false; | 886 | mShortDayLabelsM = false; |
865 | mShortDayLabelsW = false; | 887 | mShortDayLabelsW = false; |
866 | skipResize = false; | 888 | skipResize = false; |
867 | clPending = true; | 889 | clPending = true; |
868 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 890 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
869 | mWidStack = new QWidgetStack( this ); | 891 | mWidStack = new QWidgetStack( this ); |
870 | QVBoxLayout* hb = new QVBoxLayout( this ); | 892 | QVBoxLayout* hb = new QVBoxLayout( this ); |
871 | mMonthView = new QWidget( mWidStack ); | 893 | mMonthView = new QWidget( mWidStack ); |
872 | mWeekView = new QWidget( mWidStack ); | 894 | mWeekView = new QWidget( mWidStack ); |
873 | #if QT_VERSION >= 0x030000 | 895 | #if QT_VERSION >= 0x030000 |
874 | mWidStack->addWidget(mMonthView ); | 896 | mWidStack->addWidget(mMonthView ); |
875 | mWidStack->addWidget(mWeekView ); | 897 | mWidStack->addWidget(mWeekView ); |
876 | #else | 898 | #else |
877 | mWidStack->addWidget( mMonthView, 1 ); | 899 | mWidStack->addWidget( mMonthView, 1 ); |
878 | mWidStack->addWidget( mWeekView , 1 ); | 900 | mWidStack->addWidget( mWeekView , 1 ); |
879 | #endif | 901 | #endif |
880 | hb->addWidget( mNavigatorBar ); | 902 | hb->addWidget( mNavigatorBar ); |
881 | hb->addWidget( mWidStack ); | 903 | hb->addWidget( mWidStack ); |
882 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 904 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
883 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 905 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
884 | if ( mShowWeekView ) | 906 | if ( mShowWeekView ) |
885 | mWeekStartsMonday = true; | 907 | mWeekStartsMonday = true; |
886 | updatePossible = false; | 908 | updatePossible = false; |
887 | //updatePossible = true; | 909 | //updatePossible = true; |
888 | mCells.setAutoDelete( true ); | 910 | mCells.setAutoDelete( true ); |
889 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 911 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
890 | mDayLabels.resize( mDaysPerWeek ); | 912 | mDayLabels.resize( mDaysPerWeek ); |
891 | mDayLabelsW.resize( mDaysPerWeek ); | 913 | mDayLabelsW.resize( mDaysPerWeek ); |
892 | QFont bfont = font(); | 914 | QFont bfont = font(); |
893 | if ( QApplication::desktop()->width() < 650 ) { | 915 | if ( QApplication::desktop()->width() < 650 ) { |
894 | bfont.setPointSize( bfont.pointSize() - 2 ); | 916 | bfont.setPointSize( bfont.pointSize() - 2 ); |
895 | } | 917 | } |
896 | bfont.setBold( true ); | 918 | bfont.setBold( true ); |
897 | int i; | 919 | int i; |
898 | 920 | ||
899 | for( i = 0; i < mDaysPerWeek; i++ ) { | 921 | for( i = 0; i < mDaysPerWeek; i++ ) { |
900 | QLabel *label = new QLabel( mMonthView ); | 922 | QLabel *label = new QLabel( mMonthView ); |
901 | label->setFont(bfont); | 923 | label->setFont(bfont); |
902 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 924 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
903 | label->setLineWidth(1); | 925 | label->setLineWidth(1); |
904 | label->setAlignment(AlignCenter); | 926 | label->setAlignment(AlignCenter); |
905 | mDayLabels.insert( i, label ); | 927 | mDayLabels.insert( i, label ); |
906 | label = new QLabel( mWeekView ); | 928 | label = new QLabel( mWeekView ); |
907 | label->setFont(bfont); | 929 | label->setFont(bfont); |
908 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 930 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
909 | label->setLineWidth(1); | 931 | label->setLineWidth(1); |
910 | label->setAlignment(AlignCenter); | 932 | label->setAlignment(AlignCenter); |
911 | mDayLabelsW.insert( i, label ); | 933 | mDayLabelsW.insert( i, label ); |
912 | } | 934 | } |
913 | 935 | ||
914 | bfont.setBold( false ); | 936 | bfont.setBold( false ); |
915 | mWeekLabels.resize( mNumWeeks+1 ); | 937 | mWeekLabels.resize( mNumWeeks+1 ); |
916 | mWeekLabelsW.resize( 2 ); | 938 | mWeekLabelsW.resize( 2 ); |
917 | for( i = 0; i < mNumWeeks+1; i++ ) { | 939 | for( i = 0; i < mNumWeeks+1; i++ ) { |
918 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 940 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
919 | label->setFocusPolicy(NoFocus); | 941 | label->setFocusPolicy(NoFocus); |
920 | label->setFont(bfont); | 942 | label->setFont(bfont); |
921 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 943 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
922 | label->setFlat(true); | 944 | label->setFlat(true); |
923 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 945 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
924 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 946 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
925 | //label->setLineWidth(1); | 947 | //label->setLineWidth(1); |
926 | //label->setAlignment(AlignCenter); | 948 | //label->setAlignment(AlignCenter); |
927 | mWeekLabels.insert( i, label ); | 949 | mWeekLabels.insert( i, label ); |
928 | } | 950 | } |
929 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 951 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
930 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 952 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
931 | 953 | ||
932 | for( i = 0; i < 1+1; i++ ) { | 954 | for( i = 0; i < 1+1; i++ ) { |
933 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 955 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
934 | label->setFocusPolicy(NoFocus); | 956 | label->setFocusPolicy(NoFocus); |
935 | label->setFont(bfont); | 957 | label->setFont(bfont); |
936 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 958 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
937 | label->setFlat(true); | 959 | label->setFlat(true); |
938 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 960 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
939 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 961 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
940 | //label->setLineWidth(1); | 962 | //label->setLineWidth(1); |
941 | //label->setAlignment(AlignCenter); | 963 | //label->setAlignment(AlignCenter); |
942 | mWeekLabelsW.insert( i, label ); | 964 | mWeekLabelsW.insert( i, label ); |
943 | } | 965 | } |
944 | mWeekLabelsW[1]->setText( i18n("W")); | 966 | mWeekLabelsW[1]->setText( i18n("W")); |
945 | 967 | ||
946 | 968 | ||
947 | int row, col; | 969 | int row, col; |
948 | mCells.resize( mNumCells ); | 970 | mCells.resize( mNumCells ); |
949 | for( row = 0; row < mNumWeeks; ++row ) { | 971 | for( row = 0; row < mNumWeeks; ++row ) { |
950 | for( col = 0; col < mDaysPerWeek; ++col ) { | 972 | for( col = 0; col < mDaysPerWeek; ++col ) { |
951 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 973 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
952 | mCells.insert( row * mDaysPerWeek + col, cell ); | 974 | mCells.insert( row * mDaysPerWeek + col, cell ); |
953 | 975 | ||
954 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 976 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
955 | SLOT( defaultAction( Incidence * ) ) ); | 977 | SLOT( defaultAction( Incidence * ) ) ); |
956 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 978 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
957 | SIGNAL( newEventSignal( QDateTime ) ) ); | 979 | SIGNAL( newEventSignal( QDateTime ) ) ); |
958 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 980 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
959 | SIGNAL( showDaySignal( QDate ) ) ); | 981 | SIGNAL( showDaySignal( QDate ) ) ); |
960 | } | 982 | } |
961 | } | 983 | } |
962 | mCellsW.resize( mDaysPerWeek ); | 984 | mCellsW.resize( mDaysPerWeek ); |
963 | for( col = 0; col < mDaysPerWeek; ++col ) { | 985 | for( col = 0; col < mDaysPerWeek; ++col ) { |
964 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 986 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
965 | mCellsW.insert( col, cell ); | 987 | mCellsW.insert( col, cell ); |
966 | 988 | ||
967 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 989 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
968 | SLOT( defaultAction( Incidence * ) ) ); | 990 | SLOT( defaultAction( Incidence * ) ) ); |
969 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 991 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
970 | SIGNAL( newEventSignal( QDateTime ) ) ); | 992 | SIGNAL( newEventSignal( QDateTime ) ) ); |
971 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 993 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
972 | SIGNAL( showDaySignal( QDate ) ) ); | 994 | SIGNAL( showDaySignal( QDate ) ) ); |
973 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 995 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
974 | } | 996 | } |
975 | 997 | ||
976 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 998 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
977 | mContextMenu = eventPopup(); | 999 | mContextMenu = eventPopup(); |
978 | // updateConfig(); //useless here... | 1000 | // updateConfig(); //useless here... |
979 | // ... but we need mWidthLongDayLabel computed | 1001 | // ... but we need mWidthLongDayLabel computed |
980 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1002 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
981 | mWidthLongDayLabel = 0; | 1003 | mWidthLongDayLabel = 0; |
982 | for (int i = 0; i < 7; i++) { | 1004 | for (int i = 0; i < 7; i++) { |
983 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1005 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
984 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1006 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
985 | } | 1007 | } |
986 | 1008 | ||
987 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1009 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
988 | 1010 | ||
989 | #if 0 | 1011 | #if 0 |
990 | if ( mShowWeekView ) | 1012 | if ( mShowWeekView ) |
991 | mWidStack->raiseWidget( mWeekView ); | 1013 | mWidStack->raiseWidget( mWeekView ); |
992 | else | 1014 | else |
993 | mWidStack->raiseWidget( mMonthView ); | 1015 | mWidStack->raiseWidget( mMonthView ); |
994 | #endif | 1016 | #endif |
995 | 1017 | ||
996 | emit incidenceSelected( 0 ); | 1018 | emit incidenceSelected( 0 ); |
997 | 1019 | ||
998 | mComputeLayoutTimer = new QTimer( this ); | 1020 | mComputeLayoutTimer = new QTimer( this ); |
999 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1021 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1000 | 1022 | ||
1001 | 1023 | ||
1002 | #ifndef DESKTOP_VERSION | 1024 | #ifndef DESKTOP_VERSION |
1003 | resize( QApplication::desktop()->size() ); | 1025 | resize( QApplication::desktop()->size() ); |
1004 | #else | 1026 | #else |
1005 | resize(640, 480 ); | 1027 | resize(640, 480 ); |
1006 | updatePossible = true; | 1028 | updatePossible = true; |
1007 | #endif | 1029 | #endif |
1008 | computeLayout(); | 1030 | computeLayout(); |
1009 | 1031 | ||
1010 | if ( mShowWeekView ) | 1032 | if ( mShowWeekView ) |
1011 | mWidStack->raiseWidget( mWeekView ); | 1033 | mWidStack->raiseWidget( mWeekView ); |
1012 | else | 1034 | else |
1013 | mWidStack->raiseWidget( mMonthView ); | 1035 | mWidStack->raiseWidget( mMonthView ); |
1014 | } | 1036 | } |
1015 | 1037 | ||
1016 | KOMonthView::~KOMonthView() | 1038 | KOMonthView::~KOMonthView() |
1017 | { | 1039 | { |
1018 | delete mContextMenu; | 1040 | delete mContextMenu; |
1019 | } | 1041 | } |
1020 | 1042 | ||
1021 | void KOMonthView::selectInternalWeekNum ( int n ) | 1043 | void KOMonthView::selectInternalWeekNum ( int n ) |
1022 | { | 1044 | { |
1023 | switchView(); | 1045 | switchView(); |
1024 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1046 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1025 | emit selectMonth (); | 1047 | emit selectMonth (); |
1026 | else | 1048 | else |
1027 | emit selectWeekNum ( n ); | 1049 | emit selectWeekNum ( n ); |
1028 | } | 1050 | } |
1029 | 1051 | ||
1030 | int KOMonthView::currentWeek() | 1052 | int KOMonthView::currentWeek() |
1031 | { | 1053 | { |
1032 | if ( mShowWeekView ) | 1054 | if ( mShowWeekView ) |
1033 | return mWeekLabelsW[0]->getWeekNum(); | 1055 | return mWeekLabelsW[0]->getWeekNum(); |
1034 | return mWeekLabels[0]->getWeekNum(); | 1056 | return mWeekLabels[0]->getWeekNum(); |
1035 | } | 1057 | } |
1036 | void KOMonthView::switchView() | 1058 | void KOMonthView::switchView() |
1037 | { | 1059 | { |
1038 | if ( selectedCell( ) ) | 1060 | if ( selectedCell( ) ) |
1039 | selectedCell()->deselect(); | 1061 | selectedCell()->deselect(); |
1040 | mShowWeekView = !mShowWeekView; | 1062 | mShowWeekView = !mShowWeekView; |
1041 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1063 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1042 | if ( clPending ) { | 1064 | if ( clPending ) { |
1043 | computeLayout(); | 1065 | computeLayout(); |
1044 | updateConfig(); | 1066 | updateConfig(); |
1045 | } | 1067 | } |
1046 | if ( mShowWeekView ) | 1068 | if ( mShowWeekView ) |
1047 | mWidStack->raiseWidget( mWeekView ); | 1069 | mWidStack->raiseWidget( mWeekView ); |
1048 | else | 1070 | else |
1049 | mWidStack->raiseWidget( mMonthView ); | 1071 | mWidStack->raiseWidget( mMonthView ); |
1050 | clPending = false; | 1072 | clPending = false; |
1051 | } | 1073 | } |
1052 | 1074 | ||
1053 | int KOMonthView::maxDatesHint() | 1075 | int KOMonthView::maxDatesHint() |
1054 | { | 1076 | { |
1055 | return mNumCells; | 1077 | return mNumCells; |
1056 | } | 1078 | } |
1057 | 1079 | ||
1058 | int KOMonthView::currentDateCount() | 1080 | int KOMonthView::currentDateCount() |
1059 | { | 1081 | { |
1060 | return mNumCells; | 1082 | return mNumCells; |
1061 | } | 1083 | } |
1062 | 1084 | ||
1063 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1085 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1064 | { | 1086 | { |
1065 | QPtrList<Incidence> selected; | 1087 | QPtrList<Incidence> selected; |
1066 | 1088 | ||
1067 | if ( mSelectedCell ) { | 1089 | if ( mSelectedCell ) { |
1068 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1090 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1069 | if ( incidence ) selected.append( incidence ); | 1091 | if ( incidence ) selected.append( incidence ); |
1070 | } | 1092 | } |
1071 | 1093 | ||
1072 | return selected; | 1094 | return selected; |
1073 | } | 1095 | } |
1074 | 1096 | ||
1075 | DateList KOMonthView::selectedDates() | 1097 | DateList KOMonthView::selectedDates() |
1076 | { | 1098 | { |
1077 | DateList selected; | 1099 | DateList selected; |
1078 | 1100 | ||
1079 | if ( mSelectedCell ) { | 1101 | if ( mSelectedCell ) { |
1080 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1102 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1081 | if ( qd.isValid() ) selected.append( qd ); | 1103 | if ( qd.isValid() ) selected.append( qd ); |
1082 | } | 1104 | } |
1083 | 1105 | ||
1084 | return selected; | 1106 | return selected; |
1085 | } | 1107 | } |
1086 | 1108 | ||
1087 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1109 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1088 | const QDate &td) | 1110 | const QDate &td) |
1089 | { | 1111 | { |
1090 | #ifndef KORG_NOPRINTER | 1112 | #ifndef KORG_NOPRINTER |
1091 | calPrinter->preview(CalPrinter::Month, fd, td); | 1113 | calPrinter->preview(CalPrinter::Month, fd, td); |
1092 | #endif | 1114 | #endif |
1093 | } | 1115 | } |
1094 | 1116 | ||
1095 | void KOMonthView::updateConfig() | 1117 | void KOMonthView::updateConfig() |
1096 | { | 1118 | { |
1097 | 1119 | ||
1098 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1120 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1099 | 1121 | ||
1100 | if ( mShowWeekView ) { | 1122 | if ( mShowWeekView ) { |
1101 | mWeekStartsMonday = true; | 1123 | mWeekStartsMonday = true; |
1102 | } | 1124 | } |
1103 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1125 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1104 | mWidthLongDayLabel = 0; | 1126 | mWidthLongDayLabel = 0; |
1105 | 1127 | ||
1106 | for (int i = 0; i < 7; i++) { | 1128 | for (int i = 0; i < 7; i++) { |
1107 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1129 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1108 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1130 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1109 | } | 1131 | } |
1110 | bool temp = mShowSatSunComp ; | 1132 | bool temp = mShowSatSunComp ; |
1111 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1133 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1112 | if ( ! mShowWeekView ) { | 1134 | if ( ! mShowWeekView ) { |
1113 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1135 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1114 | computeLayout(); | 1136 | computeLayout(); |
1115 | } | 1137 | } |
1116 | updateDayLabels(); | 1138 | updateDayLabels(); |
1117 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1139 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1118 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1140 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1119 | //resizeEvent( 0 ); | 1141 | //resizeEvent( 0 ); |
1120 | for (uint i = 0; i < mCells.count(); ++i) { | 1142 | for (uint i = 0; i < mCells.count(); ++i) { |
1121 | mCells[i]->updateConfig(); | 1143 | mCells[i]->updateConfig(); |
1122 | } | 1144 | } |
1123 | 1145 | ||
1124 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1146 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1125 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1147 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1126 | } | 1148 | } |
1127 | #ifdef DESKTOP_VERSION | 1149 | #ifdef DESKTOP_VERSION |
1128 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1150 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1129 | #endif | 1151 | #endif |
1130 | updateView(); | 1152 | updateView(); |
1131 | } | 1153 | } |
1132 | 1154 | ||
1133 | void KOMonthView::updateDayLabels() | 1155 | void KOMonthView::updateDayLabels() |
1134 | { | 1156 | { |
1135 | 1157 | ||
1136 | QPtrVector<QLabel> *mDayLabelsT; | 1158 | QPtrVector<QLabel> *mDayLabelsT; |
1137 | 1159 | ||
1138 | mDayLabelsT = &mDayLabelsW; | 1160 | mDayLabelsT = &mDayLabelsW; |
1139 | for (int i = 0; i < 7; i++) { | 1161 | for (int i = 0; i < 7; i++) { |
1140 | if (mWeekStartsMonday) { | 1162 | if (mWeekStartsMonday) { |
1141 | bool show = mShortDayLabelsW; | 1163 | bool show = mShortDayLabelsW; |
1142 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1164 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1143 | show = true; | 1165 | show = true; |
1144 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1166 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1145 | } else { | 1167 | } else { |
1146 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); | 1168 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); |
1147 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); | 1169 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); |
1148 | 1170 | ||
1149 | } | 1171 | } |
1150 | } | 1172 | } |
1151 | mDayLabelsT = &mDayLabels; | 1173 | mDayLabelsT = &mDayLabels; |
1152 | for (int i = 0; i < 7; i++) { | 1174 | for (int i = 0; i < 7; i++) { |
1153 | if (mWeekStartsMonday) { | 1175 | if (mWeekStartsMonday) { |
1154 | bool show = mShortDayLabelsM; | 1176 | bool show = mShortDayLabelsM; |
1155 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1177 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1156 | show = true; | 1178 | show = true; |
1157 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1179 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1158 | } else { | 1180 | } else { |
1159 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1181 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1160 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1182 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1161 | 1183 | ||
1162 | } | 1184 | } |
1163 | } | 1185 | } |
1164 | 1186 | ||
1165 | } | 1187 | } |
1166 | 1188 | ||
1167 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1189 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1168 | { | 1190 | { |
1169 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1191 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1170 | 1192 | ||
1171 | QPtrVector<MonthViewCell> *cells; | 1193 | QPtrVector<MonthViewCell> *cells; |
1172 | QPtrVector<QLabel> *dayLabels; | 1194 | QPtrVector<QLabel> *dayLabels; |
1173 | QPtrVector<KOWeekButton> *weekLabels; | 1195 | QPtrVector<KOWeekButton> *weekLabels; |
1174 | int weekNum = 6; | 1196 | int weekNum = 6; |
1175 | if ( mShowWeekView ) { | 1197 | if ( mShowWeekView ) { |
1176 | weekNum = 1; | 1198 | weekNum = 1; |
1177 | cells = &mCellsW; | 1199 | cells = &mCellsW; |
1178 | dayLabels = &mDayLabelsW; | 1200 | dayLabels = &mDayLabelsW; |
1179 | weekLabels = &mWeekLabelsW; | 1201 | weekLabels = &mWeekLabelsW; |
1180 | } else { | 1202 | } else { |