author | zautrix <zautrix> | 2005-03-29 00:10:48 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-29 00:10:48 (UTC) |
commit | a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46 (patch) (unidiff) | |
tree | b9f1b2710da1cd0105382831ac0a3e3d7d44f09c /korganizer | |
parent | 4e7c45695672ecdbd0cd14cac0ea29a8e134ee78 (diff) | |
download | kdepimpi-a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46.zip kdepimpi-a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46.tar.gz kdepimpi-a5d52c19d2cd9b008e5cf41d5c7d2c193df7ee46.tar.bz2 |
fix
-rw-r--r-- | korganizer/komonthview.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index d825493..940d288 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,938 +1,944 @@ | |||
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 | if ( count() ) { |
128 | if(!itemVisible(currentItem())) { | 128 | setCurrentItem((currentItem()+count()-1)%count()); |
129 | if((unsigned int) currentItem() == (count()-1)) { | 129 | if(!itemVisible(currentItem())) { |
130 | setTopItem(currentItem()-numItemsVisible()+1); | 130 | if((unsigned int) currentItem() == (count()-1)) { |
131 | } else { | 131 | setTopItem(currentItem()-numItemsVisible()+1); |
132 | setTopItem(topItem()-1); | 132 | } else { |
133 | setTopItem(topItem()-1); | ||
134 | } | ||
133 | } | 135 | } |
134 | } | 136 | } |
135 | break; | 137 | break; |
136 | case Key_Down: | 138 | case Key_Down: |
137 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 139 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
138 | e->ignore(); | 140 | e->ignore(); |
139 | break; | 141 | break; |
140 | } | 142 | } |
141 | setCurrentItem((currentItem()+1)%count()); | 143 | if ( count () ) { |
142 | if(!itemVisible(currentItem())) { | 144 | setCurrentItem((currentItem()+1)%count()); |
143 | if(currentItem() == 0) { | 145 | if(!itemVisible(currentItem())) { |
144 | setTopItem(0); | 146 | if(currentItem() == 0) { |
145 | } else { | 147 | setTopItem(0); |
146 | setTopItem(topItem()+1); | 148 | } else { |
149 | setTopItem(topItem()+1); | ||
150 | } | ||
147 | } | 151 | } |
148 | } | 152 | } |
149 | break; | 153 | break; |
150 | case Key_I: | 154 | case Key_I: |
151 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 155 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); |
152 | e->ignore(); | 156 | e->ignore(); |
153 | break; | 157 | break; |
154 | case Key_Shift: | 158 | case Key_Shift: |
155 | emit shiftDown(); | 159 | emit shiftDown(); |
156 | break; | 160 | break; |
157 | default: | 161 | default: |
158 | e->ignore(); | 162 | e->ignore(); |
159 | break; | 163 | break; |
160 | } | 164 | } |
161 | } | 165 | } |
162 | 166 | ||
163 | void KNoScrollListBox::oneDown() | 167 | void KNoScrollListBox::oneDown() |
164 | { | 168 | { |
165 | setCurrentItem((currentItem()+1)%count()); | 169 | if ( count () ) { |
166 | if(!itemVisible(currentItem())) { | 170 | setCurrentItem((currentItem()+1)%count()); |
167 | if(currentItem() == 0) { | 171 | if(!itemVisible(currentItem())) { |
168 | setTopItem(0); | 172 | if(currentItem() == 0) { |
169 | } else { | 173 | setTopItem(0); |
170 | setTopItem(topItem()+1); | 174 | } else { |
175 | setTopItem(topItem()+1); | ||
176 | } | ||
171 | } | 177 | } |
172 | } | 178 | } |
173 | } | 179 | } |
174 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 180 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
175 | { | 181 | { |
176 | switch(e->key()) { | 182 | switch(e->key()) { |
177 | case Key_Shift: | 183 | case Key_Shift: |
178 | emit shiftUp(); | 184 | emit shiftUp(); |
179 | break; | 185 | break; |
180 | default: | 186 | default: |
181 | break; | 187 | break; |
182 | } | 188 | } |
183 | } | 189 | } |
184 | 190 | ||
185 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 191 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
186 | { | 192 | { |
187 | QListBox::mousePressEvent(e); | 193 | QListBox::mousePressEvent(e); |
188 | 194 | ||
189 | if(e->button() == RightButton) { | 195 | if(e->button() == RightButton) { |
190 | emit rightClick(); | 196 | emit rightClick(); |
191 | } | 197 | } |
192 | } | 198 | } |
193 | 199 | ||
194 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 200 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
195 | : QListBoxItem() | 201 | : QListBoxItem() |
196 | { | 202 | { |
197 | mblockRepaint = true; | 203 | mblockRepaint = true; |
198 | setText( s ); | 204 | setText( s ); |
199 | mMultiday = 0; | 205 | mMultiday = 0; |
200 | mIncidence = incidence; | 206 | mIncidence = incidence; |
201 | mDate = qd; | 207 | mDate = qd; |
202 | mRecur = false; | 208 | mRecur = false; |
203 | mAlarm = false; | 209 | mAlarm = false; |
204 | mReply = false; | 210 | mReply = false; |
205 | mInfo = false; | 211 | mInfo = false; |
206 | //qDebug("NEWWWWWWWWWWWWW "); | 212 | //qDebug("NEWWWWWWWWWWWWW "); |
207 | } | 213 | } |
208 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 214 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
209 | { | 215 | { |
210 | setText( s ); | 216 | setText( s ); |
211 | mMultiday = 0; | 217 | mMultiday = 0; |
212 | mIncidence = incidence; | 218 | mIncidence = incidence; |
213 | mDate = qd; | 219 | mDate = qd; |
214 | mRecur = false; | 220 | mRecur = false; |
215 | mAlarm = false; | 221 | mAlarm = false; |
216 | mReply = false; | 222 | mReply = false; |
217 | mInfo = false; | 223 | mInfo = false; |
218 | //qDebug("recucleeeeeeeeeeeeeeeee "); | 224 | //qDebug("recucleeeeeeeeeeeeeeeee "); |
219 | } | 225 | } |
220 | 226 | ||
221 | void MonthViewItem::paint(QPainter *p) | 227 | void MonthViewItem::paint(QPainter *p) |
222 | { | 228 | { |
223 | if ( mblockRepaint ) { | 229 | if ( mblockRepaint ) { |
224 | //qDebug("block "); | 230 | //qDebug("block "); |
225 | return; | 231 | return; |
226 | } | 232 | } |
227 | //qDebug("NON block "); | 233 | //qDebug("NON block "); |
228 | #if QT_VERSION >= 0x030000 | 234 | #if QT_VERSION >= 0x030000 |
229 | bool sel = isSelected(); | 235 | bool sel = isSelected(); |
230 | #else | 236 | #else |
231 | bool sel = selected(); | 237 | bool sel = selected(); |
232 | #endif | 238 | #endif |
233 | 239 | ||
234 | 240 | ||
235 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 241 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
236 | { | 242 | { |
237 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 243 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
238 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 244 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
239 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 245 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
240 | } | 246 | } |
241 | int x = 1; | 247 | int x = 1; |
242 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 248 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
243 | int size = PIXMAP_SIZE; | 249 | int size = PIXMAP_SIZE; |
244 | if ( QApplication::desktop()->width() < 300 ) | 250 | if ( QApplication::desktop()->width() < 300 ) |
245 | size = 3; | 251 | size = 3; |
246 | int heihei = height( listBox () ); | 252 | int heihei = height( listBox () ); |
247 | int y = (heihei - size -1 ) /2; | 253 | int y = (heihei - size -1 ) /2; |
248 | 254 | ||
249 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 255 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
250 | if ( mInfo ) { | 256 | if ( mInfo ) { |
251 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 257 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
252 | x += size + 1; | 258 | x += size + 1; |
253 | } | 259 | } |
254 | if ( mRecur ) { | 260 | if ( mRecur ) { |
255 | p->fillRect ( x, y,size,size, Qt::blue ); | 261 | p->fillRect ( x, y,size,size, Qt::blue ); |
256 | x += size + 1; | 262 | x += size + 1; |
257 | } | 263 | } |
258 | if ( mAlarm ) { | 264 | if ( mAlarm ) { |
259 | p->fillRect ( x, y,size,size, Qt::red ); | 265 | p->fillRect ( x, y,size,size, Qt::red ); |
260 | x += size + 1; | 266 | x += size + 1; |
261 | } | 267 | } |
262 | if ( mReply ) { | 268 | if ( mReply ) { |
263 | p->fillRect ( x, y,size,size, Qt::yellow ); | 269 | p->fillRect ( x, y,size,size, Qt::yellow ); |
264 | x += size + 1; | 270 | x += size + 1; |
265 | } | 271 | } |
266 | } | 272 | } |
267 | if ( mMultiday ) { | 273 | if ( mMultiday ) { |
268 | int yyy = y+(size/2); | 274 | int yyy = y+(size/2); |
269 | int sizeM = size+2; | 275 | int sizeM = size+2; |
270 | p->setBrush( QBrush::SolidPattern ); | 276 | p->setBrush( QBrush::SolidPattern ); |
271 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 277 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
272 | if ( mMultiday == 2 || mMultiday == 3 ) { | 278 | if ( mMultiday == 2 || mMultiday == 3 ) { |
273 | QPointArray pa ( 3 ); | 279 | QPointArray pa ( 3 ); |
274 | pa.setPoint (0, x, yyy ); | 280 | pa.setPoint (0, x, yyy ); |
275 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 281 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
276 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 282 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
277 | p->drawPolygon( pa ); | 283 | p->drawPolygon( pa ); |
278 | } | 284 | } |
279 | if ( mMultiday == 2 || mMultiday == 1 ) { | 285 | if ( mMultiday == 2 || mMultiday == 1 ) { |
280 | QPointArray pa ( 3 ); | 286 | QPointArray pa ( 3 ); |
281 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 287 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
282 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 288 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
283 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 289 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
284 | p->drawPolygon( pa ); | 290 | p->drawPolygon( pa ); |
285 | } | 291 | } |
286 | if ( mMultiday == 1 ) { | 292 | if ( mMultiday == 1 ) { |
287 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 293 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
288 | 294 | ||
289 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 295 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
290 | } | 296 | } |
291 | if ( mMultiday == 3 ) { | 297 | if ( mMultiday == 3 ) { |
292 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 298 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
293 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 299 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
294 | 300 | ||
295 | } | 301 | } |
296 | x += sizeM/2 + 1; | 302 | x += sizeM/2 + 1; |
297 | x += sizeM + 1; | 303 | x += sizeM + 1; |
298 | } | 304 | } |
299 | 305 | ||
300 | if ( mIncidence->type() == "Todo" ){ | 306 | if ( mIncidence->type() == "Todo" ){ |
301 | Todo* td = ( Todo* ) mIncidence; | 307 | Todo* td = ( Todo* ) mIncidence; |
302 | if ( td->isCompleted() ) { | 308 | if ( td->isCompleted() ) { |
303 | int half = size/2; | 309 | int half = size/2; |
304 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 310 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
305 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 311 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
306 | x += half+half + 4; | 312 | x += half+half + 4; |
307 | 313 | ||
308 | } else { | 314 | } else { |
309 | int val = td->percentComplete()/20; | 315 | int val = td->percentComplete()/20; |
310 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); | 316 | p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); |
311 | p->drawRect ( x, y-1,7,size+2); | 317 | p->drawRect ( x, y-1,7,size+2); |
312 | x += size + 3; | 318 | x += size + 3; |
313 | } | 319 | } |
314 | } | 320 | } |
315 | QFontMetrics fm = p->fontMetrics(); | 321 | QFontMetrics fm = p->fontMetrics(); |
316 | int yPos; | 322 | int yPos; |
317 | int pmheight = size; | 323 | int pmheight = size; |
318 | if( pmheight < fm.height() ) | 324 | if( pmheight < fm.height() ) |
319 | yPos = fm.ascent() + fm.leading()/2; | 325 | yPos = fm.ascent() + fm.leading()/2; |
320 | else | 326 | else |
321 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 327 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
322 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 328 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
323 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 329 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
324 | p->drawText( x, yPos, text() ); | 330 | p->drawText( x, yPos, text() ); |
325 | if ( mIncidence->cancelled() ) { | 331 | if ( mIncidence->cancelled() ) { |
326 | int wid = fm.width( text() ); | 332 | int wid = fm.width( text() ); |
327 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); | 333 | p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); |
328 | } | 334 | } |
329 | 335 | ||
330 | } | 336 | } |
331 | 337 | ||
332 | int MonthViewItem::height(const QListBox *lb) const | 338 | int MonthViewItem::height(const QListBox *lb) const |
333 | { | 339 | { |
334 | int ret = 10; | 340 | int ret = 10; |
335 | if ( lb ) | 341 | if ( lb ) |
336 | ret = lb->fontMetrics().lineSpacing()+1; | 342 | ret = lb->fontMetrics().lineSpacing()+1; |
337 | return ret; | 343 | return ret; |
338 | } | 344 | } |
339 | 345 | ||
340 | int MonthViewItem::width(const QListBox *lb) const | 346 | int MonthViewItem::width(const QListBox *lb) const |
341 | { | 347 | { |
342 | 348 | ||
343 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 349 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
344 | int size = PIXMAP_SIZE; | 350 | int size = PIXMAP_SIZE; |
345 | if ( QApplication::desktop()->width() < 300 ) | 351 | if ( QApplication::desktop()->width() < 300 ) |
346 | size = 3; | 352 | size = 3; |
347 | int x = 1; | 353 | int x = 1; |
348 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 354 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
349 | if ( mInfo ) { | 355 | if ( mInfo ) { |
350 | x += size + 1; | 356 | x += size + 1; |
351 | } | 357 | } |
352 | if( mRecur ) { | 358 | if( mRecur ) { |
353 | x += size+1; | 359 | x += size+1; |
354 | } | 360 | } |
355 | if( mAlarm ) { | 361 | if( mAlarm ) { |
356 | x += size+1; | 362 | x += size+1; |
357 | } | 363 | } |
358 | if( mReply ) { | 364 | if( mReply ) { |
359 | x += size+1; | 365 | x += size+1; |
360 | } | 366 | } |
361 | } | 367 | } |
362 | if( mMultiday ) { | 368 | if( mMultiday ) { |
363 | x += size+1+2+size/2; | 369 | x += size+1+2+size/2; |
364 | } | 370 | } |
365 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 371 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
366 | } | 372 | } |
367 | if ( ! lb ) | 373 | if ( ! lb ) |
368 | return 10; | 374 | return 10; |
369 | //qDebug("ret wid %d ", lb->width()); | 375 | //qDebug("ret wid %d ", lb->width()); |
370 | return lb->width(); | 376 | return lb->width(); |
371 | } | 377 | } |
372 | 378 | ||
373 | 379 | ||
374 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 380 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
375 | : KNoScrollListBox( par ), | 381 | : KNoScrollListBox( par ), |
376 | mMonthView( parent ) | 382 | mMonthView( parent ) |
377 | { | 383 | { |
378 | 384 | ||
379 | mCurrentAvailItem = 0; | 385 | mCurrentAvailItem = 0; |
380 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 386 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
381 | currentPalette = 0; | 387 | currentPalette = 0; |
382 | // mLabel = new QLabel( this );QPushButton | 388 | // mLabel = new QLabel( this );QPushButton |
383 | mLabel = new QPushButton( this ); | 389 | mLabel = new QPushButton( this ); |
384 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 390 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
385 | //mLabel->setLineWidth( 1 ); | 391 | //mLabel->setLineWidth( 1 ); |
386 | //mLabel->setAlignment( AlignCenter ); | 392 | //mLabel->setAlignment( AlignCenter ); |
387 | mLabel->setFlat( true ); | 393 | mLabel->setFlat( true ); |
388 | mLabel->setFocusPolicy(NoFocus); | 394 | mLabel->setFocusPolicy(NoFocus); |
389 | //mItemList = new KNoScrollListBox( this ); | 395 | //mItemList = new KNoScrollListBox( this ); |
390 | setMinimumSize( 10, 10 ); | 396 | setMinimumSize( 10, 10 ); |
391 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 397 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
392 | setLineWidth( 1 ); | 398 | setLineWidth( 1 ); |
393 | //topLayout->addWidget( mItemList ); | 399 | //topLayout->addWidget( mItemList ); |
394 | mLabel->raise(); | 400 | mLabel->raise(); |
395 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 401 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
396 | mStandardPalette = palette(); | 402 | mStandardPalette = palette(); |
397 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 403 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
398 | 404 | ||
399 | enableScrollBars( false ); | 405 | enableScrollBars( false ); |
400 | updateConfig(); | 406 | updateConfig(); |
401 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 407 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
402 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 408 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
403 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 409 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
404 | SLOT( defaultAction( QListBoxItem * ) ) ); | 410 | SLOT( defaultAction( QListBoxItem * ) ) ); |
405 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 411 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
406 | const QPoint &) ), | 412 | const QPoint &) ), |
407 | SLOT( contextMenu( QListBoxItem * ) ) ); | 413 | SLOT( contextMenu( QListBoxItem * ) ) ); |
408 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 414 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
409 | SLOT( selection( QListBoxItem * ) ) ); | 415 | SLOT( selection( QListBoxItem * ) ) ); |
410 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 416 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
411 | SLOT( cellClicked( QListBoxItem * ) ) ); | 417 | SLOT( cellClicked( QListBoxItem * ) ) ); |
412 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 418 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
413 | SLOT( selection( QListBoxItem * ) ) ); | 419 | SLOT( selection( QListBoxItem * ) ) ); |
414 | } | 420 | } |
415 | #ifdef DESKTOP_VERSION | 421 | #ifdef DESKTOP_VERSION |
416 | QToolTipGroup *MonthViewCell::toolTipGroup() | 422 | QToolTipGroup *MonthViewCell::toolTipGroup() |
417 | { | 423 | { |
418 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 424 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
419 | return mToolTipGroup; | 425 | return mToolTipGroup; |
420 | } | 426 | } |
421 | #endif | 427 | #endif |
422 | 428 | ||
423 | void MonthViewCell::setDate( const QDate &date ) | 429 | void MonthViewCell::setDate( const QDate &date ) |
424 | { | 430 | { |
425 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 431 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
426 | mDate = date; | 432 | mDate = date; |
427 | 433 | ||
428 | 434 | ||
429 | 435 | ||
430 | //resizeEvent( 0 ); | 436 | //resizeEvent( 0 ); |
431 | } | 437 | } |
432 | 438 | ||
433 | QDate MonthViewCell::date() const | 439 | QDate MonthViewCell::date() const |
434 | { | 440 | { |
435 | return mDate; | 441 | return mDate; |
436 | } | 442 | } |
437 | 443 | ||
438 | void MonthViewCell::setPrimary( bool primary ) | 444 | void MonthViewCell::setPrimary( bool primary ) |
439 | { | 445 | { |
440 | mPrimary = primary; | 446 | mPrimary = primary; |
441 | //setMyPalette(); | 447 | //setMyPalette(); |
442 | } | 448 | } |
443 | void MonthViewCell::setMyPalette() | 449 | void MonthViewCell::setMyPalette() |
444 | { | 450 | { |
445 | 451 | ||
446 | if ( mHoliday) { | 452 | if ( mHoliday) { |
447 | if ( currentPalette == 1 ) return; | 453 | if ( currentPalette == 1 ) return; |
448 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 454 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
449 | setPalette( mHolidayPalette ); | 455 | setPalette( mHolidayPalette ); |
450 | //mLabel->setPalette( mHolidayPalette ); | 456 | //mLabel->setPalette( mHolidayPalette ); |
451 | currentPalette = 1; | 457 | currentPalette = 1; |
452 | 458 | ||
453 | } else { | 459 | } else { |
454 | if ( mPrimary ) { | 460 | if ( mPrimary ) { |
455 | if ( currentPalette == 2 ) return; | 461 | if ( currentPalette == 2 ) return; |
456 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 462 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
457 | //mLabel->setPalette( mPrimaryPalette ); | 463 | //mLabel->setPalette( mPrimaryPalette ); |
458 | setPalette( mPrimaryPalette ); | 464 | setPalette( mPrimaryPalette ); |
459 | currentPalette = 2; | 465 | currentPalette = 2; |
460 | 466 | ||
461 | } else { | 467 | } else { |
462 | if ( currentPalette == 3 ) return; | 468 | if ( currentPalette == 3 ) return; |
463 | setPalette( mNonPrimaryPalette ); | 469 | setPalette( mNonPrimaryPalette ); |
464 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 470 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
465 | //mLabel->setPalette( mNonPrimaryPalette );; | 471 | //mLabel->setPalette( mNonPrimaryPalette );; |
466 | currentPalette = 3; | 472 | currentPalette = 3; |
467 | } | 473 | } |
468 | } | 474 | } |
469 | //QPalette pal = palette(); | 475 | //QPalette pal = palette(); |
470 | 476 | ||
471 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 477 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
472 | } | 478 | } |
473 | QPalette MonthViewCell::getPalette () | 479 | QPalette MonthViewCell::getPalette () |
474 | { | 480 | { |
475 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 481 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
476 | return mStandardPalette; | 482 | return mStandardPalette; |
477 | if ( mHoliday) { | 483 | if ( mHoliday) { |
478 | return mHolidayPalette ; | 484 | return mHolidayPalette ; |
479 | } else { | 485 | } else { |
480 | if ( mPrimary ) { | 486 | if ( mPrimary ) { |
481 | return mPrimaryPalette ; | 487 | return mPrimaryPalette ; |
482 | } | 488 | } |
483 | } | 489 | } |
484 | return mNonPrimaryPalette; | 490 | return mNonPrimaryPalette; |
485 | } | 491 | } |
486 | bool MonthViewCell::isPrimary() const | 492 | bool MonthViewCell::isPrimary() const |
487 | { | 493 | { |
488 | return mPrimary; | 494 | return mPrimary; |
489 | } | 495 | } |
490 | 496 | ||
491 | void MonthViewCell::setHoliday( bool holiday ) | 497 | void MonthViewCell::setHoliday( bool holiday ) |
492 | { | 498 | { |
493 | mHoliday = holiday; | 499 | mHoliday = holiday; |
494 | //setMyPalette(); | 500 | //setMyPalette(); |
495 | } | 501 | } |
496 | 502 | ||
497 | void MonthViewCell::setHoliday( const QString &holiday ) | 503 | void MonthViewCell::setHoliday( const QString &holiday ) |
498 | { | 504 | { |
499 | mHolidayString = holiday; | 505 | mHolidayString = holiday; |
500 | 506 | ||
501 | if ( !holiday.isEmpty() ) { | 507 | if ( !holiday.isEmpty() ) { |
502 | setHoliday( true ); | 508 | setHoliday( true ); |
503 | } | 509 | } |
504 | } | 510 | } |
505 | 511 | ||
506 | void MonthViewCell::startUpdateCell() | 512 | void MonthViewCell::startUpdateCell() |
507 | { | 513 | { |
508 | 514 | ||
509 | setFocusPolicy(NoFocus); | 515 | setFocusPolicy(NoFocus); |
510 | if ( !mMonthView->isUpdatePossible() ) | 516 | if ( !mMonthView->isUpdatePossible() ) |
511 | return; | 517 | return; |
512 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 518 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
513 | while ( mitem ) { | 519 | while ( mitem ) { |
514 | mitem->setBlockRepaint( true ); | 520 | mitem->setBlockRepaint( true ); |
515 | mitem = (MonthViewItem *)mitem->next(); | 521 | mitem = (MonthViewItem *)mitem->next(); |
516 | } | 522 | } |
517 | if ( mAvailItemList.count() > 20 ) { | 523 | if ( mAvailItemList.count() > 20 ) { |
518 | mAvailItemList.setAutoDelete( true ); | 524 | mAvailItemList.setAutoDelete( true ); |
519 | mAvailItemList.clear(); | 525 | mAvailItemList.clear(); |
520 | mAvailItemList.setAutoDelete( false ); | 526 | mAvailItemList.setAutoDelete( false ); |
521 | } | 527 | } |
522 | /* | 528 | /* |
523 | if ( !isVisible() ){ | 529 | if ( !isVisible() ){ |
524 | return; | 530 | return; |
525 | } | 531 | } |
526 | */ | 532 | */ |
527 | // qDebug("MonthViewCell::updateCell() "); | 533 | // qDebug("MonthViewCell::updateCell() "); |
528 | setPrimary( mDate.month()%2 ); | 534 | setPrimary( mDate.month()%2 ); |
529 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 535 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
530 | if ( mDate == QDate::currentDate() ) { | 536 | if ( mDate == QDate::currentDate() ) { |
531 | setLineWidth( 3 ); | 537 | setLineWidth( 3 ); |
532 | } else { | 538 | } else { |
533 | setLineWidth( 1 ); | 539 | setLineWidth( 1 ); |
534 | } | 540 | } |
535 | mCurrentAvailItem = (MonthViewItem*) firstItem (); | 541 | mCurrentAvailItem = (MonthViewItem*) firstItem (); |
536 | //clear(); | 542 | //clear(); |
537 | 543 | ||
538 | #ifdef DESKTOP_VERSION | 544 | #ifdef DESKTOP_VERSION |
539 | QToolTip::remove(this); | 545 | QToolTip::remove(this); |
540 | #endif | 546 | #endif |
541 | mToolTip.clear(); | 547 | mToolTip.clear(); |
542 | //qApp->processEvents(); | 548 | //qApp->processEvents(); |
543 | #if 0 | 549 | #if 0 |
544 | if ( !mHolidayString.isEmpty() ) { | 550 | if ( !mHolidayString.isEmpty() ) { |
545 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 551 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
546 | item->setPalette( mHolidayPalette ); | 552 | item->setPalette( mHolidayPalette ); |
547 | insertItem( item ); | 553 | insertItem( item ); |
548 | mToolTip.append ( mHolidayString ); | 554 | mToolTip.append ( mHolidayString ); |
549 | } | 555 | } |
550 | #endif | 556 | #endif |
551 | } | 557 | } |
552 | 558 | ||
553 | void MonthViewCell::insertEvent(Event *event) | 559 | void MonthViewCell::insertEvent(Event *event) |
554 | { | 560 | { |
555 | QString mToolTipText; | 561 | QString mToolTipText; |
556 | bool insertNewItem = false; | 562 | bool insertNewItem = false; |
557 | setFocusPolicy(WheelFocus); | 563 | setFocusPolicy(WheelFocus); |
558 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 564 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
559 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 565 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
560 | return; | 566 | return; |
561 | else | 567 | else |
562 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 568 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
563 | return; | 569 | return; |
564 | } | 570 | } |
565 | 571 | ||
566 | if ( event->isHoliday()) { | 572 | if ( event->isHoliday()) { |
567 | setHoliday( true ); | 573 | setHoliday( true ); |
568 | if ( mDate.dayOfWeek() == 7 ) | 574 | if ( mDate.dayOfWeek() == 7 ) |
569 | setLineWidth( 3 ); | 575 | setLineWidth( 3 ); |
570 | } | 576 | } |
571 | QString text; | 577 | QString text; |
572 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 578 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
573 | if (event->isMultiDay()) { | 579 | if (event->isMultiDay()) { |
574 | QString prefix = "<->";multiday = 2; | 580 | QString prefix = "<->";multiday = 2; |
575 | QString time; | 581 | QString time; |
576 | if ( event->doesRecur() ) { | 582 | if ( event->doesRecur() ) { |
577 | if ( event->recursOn( mDate) ) { | 583 | if ( event->recursOn( mDate) ) { |
578 | prefix ="->" ;multiday = 1; | 584 | prefix ="->" ;multiday = 1; |
579 | } | 585 | } |
580 | else { | 586 | else { |
581 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 587 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
582 | if ( event->recursOn( mDate.addDays( -days)) ) { | 588 | if ( event->recursOn( mDate.addDays( -days)) ) { |
583 | prefix ="<-" ;multiday = 3; | 589 | prefix ="<-" ;multiday = 3; |
584 | } | 590 | } |
585 | } | 591 | } |
586 | 592 | ||
587 | } else { | 593 | } else { |
588 | if (mDate == event->dtStart().date()) { | 594 | if (mDate == event->dtStart().date()) { |
589 | prefix ="->" ;multiday = 1; | 595 | prefix ="->" ;multiday = 1; |
590 | } else if (mDate == event->dtEnd().date()) { | 596 | } else if (mDate == event->dtEnd().date()) { |
591 | prefix ="<-" ;multiday = 3; | 597 | prefix ="<-" ;multiday = 3; |
592 | } | 598 | } |
593 | } | 599 | } |
594 | if ( !event->doesFloat() ) { | 600 | if ( !event->doesFloat() ) { |
595 | if ( mDate == event->dtStart().date () ) | 601 | if ( mDate == event->dtStart().date () ) |
596 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 602 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
597 | else if ( mDate == event->dtEnd().date () ) | 603 | else if ( mDate == event->dtEnd().date () ) |
598 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 604 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
599 | 605 | ||
600 | } | 606 | } |
601 | text = time + event->summary(); | 607 | text = time + event->summary(); |
602 | mToolTipText += prefix + text; | 608 | mToolTipText += prefix + text; |
603 | } else { | 609 | } else { |
604 | if (event->doesFloat()) { | 610 | if (event->doesFloat()) { |
605 | text = event->summary(); | 611 | text = event->summary(); |
606 | mToolTipText += text; | 612 | mToolTipText += text; |
607 | } | 613 | } |
608 | else { | 614 | else { |
609 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 615 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
610 | text += " " + event->summary(); | 616 | text += " " + event->summary(); |
611 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 617 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
612 | } | 618 | } |
613 | } | 619 | } |
614 | MonthViewItem *item ; | 620 | MonthViewItem *item ; |
615 | if ( mCurrentAvailItem ) { | 621 | if ( mCurrentAvailItem ) { |
616 | item = mCurrentAvailItem; | 622 | item = mCurrentAvailItem; |
617 | mCurrentAvailItem = (MonthViewItem*) item->next(); | 623 | mCurrentAvailItem = (MonthViewItem*) item->next(); |
618 | item->recycle( event, mDate, text ); | 624 | item->recycle( event, mDate, text ); |
619 | } else { | 625 | } else { |
620 | if ( mAvailItemList.count() ) { | 626 | if ( mAvailItemList.count() ) { |
621 | item = mAvailItemList.first(); | 627 | item = mAvailItemList.first(); |
622 | mAvailItemList.remove( item ); | 628 | mAvailItemList.remove( item ); |
623 | item->recycle( event, mDate, text ); | 629 | item->recycle( event, mDate, text ); |
624 | insertNewItem = true; | 630 | insertNewItem = true; |
625 | } else { | 631 | } else { |
626 | insertNewItem = true; | 632 | insertNewItem = true; |
627 | item = new MonthViewItem( event, mDate, text ); | 633 | item = new MonthViewItem( event, mDate, text ); |
628 | } | 634 | } |
629 | } | 635 | } |
630 | QPalette pal; | 636 | QPalette pal; |
631 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 637 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
632 | QStringList categories = event->categories(); | 638 | QStringList categories = event->categories(); |
633 | QString cat = categories.first(); | 639 | QString cat = categories.first(); |
634 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 640 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
635 | pal = getPalette(); | 641 | pal = getPalette(); |
636 | if (cat.isEmpty()) { | 642 | if (cat.isEmpty()) { |
637 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 643 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
638 | } else { | 644 | } else { |
639 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 645 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
640 | } | 646 | } |
641 | 647 | ||
642 | } else { | 648 | } else { |
643 | if (cat.isEmpty()) { | 649 | if (cat.isEmpty()) { |
644 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 650 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
645 | } else { | 651 | } else { |
646 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 652 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
647 | } | 653 | } |
648 | } | 654 | } |
649 | 655 | ||
650 | } else { | 656 | } else { |
651 | pal = mStandardPalette ; | 657 | pal = mStandardPalette ; |
652 | } | 658 | } |
653 | item->setPalette( pal ); | 659 | item->setPalette( pal ); |
654 | item->setRecur( event->recurrence()->doesRecur() ); | 660 | item->setRecur( event->recurrence()->doesRecur() ); |
655 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 661 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
656 | item->setMoreInfo( event->description().length() > 0 ); | 662 | item->setMoreInfo( event->description().length() > 0 ); |
657 | #ifdef DESKTOP_VERSION | 663 | #ifdef DESKTOP_VERSION |
658 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 664 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
659 | KOPrefs::instance()->email()); | 665 | KOPrefs::instance()->email()); |
660 | if ( me != 0 ) { | 666 | if ( me != 0 ) { |
661 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 667 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
662 | item->setReply(true && multiday < 2); | 668 | item->setReply(true && multiday < 2); |
663 | else | 669 | else |
664 | item->setReply(false); | 670 | item->setReply(false); |
665 | } else | 671 | } else |
666 | item->setReply(false); | 672 | item->setReply(false); |
667 | #endif | 673 | #endif |
668 | item->setMultiDay( multiday ); | 674 | item->setMultiDay( multiday ); |
669 | if ( insertNewItem) | 675 | if ( insertNewItem) |
670 | insertItem( item ); | 676 | insertItem( item ); |
671 | mToolTip.append( mToolTipText ); | 677 | mToolTip.append( mToolTipText ); |
672 | } | 678 | } |
673 | void MonthViewCell::insertTodo(Todo *todo) | 679 | void MonthViewCell::insertTodo(Todo *todo) |
674 | { | 680 | { |
675 | bool insertNewItem = false; | 681 | bool insertNewItem = false; |
676 | setFocusPolicy(WheelFocus); | 682 | setFocusPolicy(WheelFocus); |
677 | QString text; | 683 | QString text; |
678 | if (todo->hasDueDate()) { | 684 | if (todo->hasDueDate()) { |
679 | if (!todo->doesFloat()) { | 685 | if (!todo->doesFloat()) { |
680 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 686 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
681 | text += " "; | 687 | text += " "; |
682 | } | 688 | } |
683 | } | 689 | } |
684 | text += todo->summary(); | 690 | text += todo->summary(); |
685 | MonthViewItem *item ; | 691 | MonthViewItem *item ; |
686 | if ( mCurrentAvailItem ) { | 692 | if ( mCurrentAvailItem ) { |
687 | item = mCurrentAvailItem; | 693 | item = mCurrentAvailItem; |
688 | mCurrentAvailItem = (MonthViewItem*) item->next(); | 694 | mCurrentAvailItem = (MonthViewItem*) item->next(); |
689 | item->recycle( todo, mDate, text ); | 695 | item->recycle( todo, mDate, text ); |
690 | } else { | 696 | } else { |
691 | if ( mAvailItemList.count() ) { | 697 | if ( mAvailItemList.count() ) { |
692 | item = mAvailItemList.first(); | 698 | item = mAvailItemList.first(); |
693 | mAvailItemList.remove( item ); | 699 | mAvailItemList.remove( item ); |
694 | item->recycle( todo, mDate, text ); | 700 | item->recycle( todo, mDate, text ); |
695 | insertNewItem = true; | 701 | insertNewItem = true; |
696 | } else { | 702 | } else { |
697 | insertNewItem = true; | 703 | insertNewItem = true; |
698 | item = new MonthViewItem( todo, mDate, text ); | 704 | item = new MonthViewItem( todo, mDate, text ); |
699 | } | 705 | } |
700 | } | 706 | } |
701 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 707 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
702 | //item->setPalette( mStandardPalette ); | 708 | //item->setPalette( mStandardPalette ); |
703 | QPalette pal; | 709 | QPalette pal; |
704 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 710 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
705 | QStringList categories = todo->categories(); | 711 | QStringList categories = todo->categories(); |
706 | QString cat = categories.first(); | 712 | QString cat = categories.first(); |
707 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 713 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
708 | pal = getPalette(); | 714 | pal = getPalette(); |
709 | if (cat.isEmpty()) { | 715 | if (cat.isEmpty()) { |
710 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 716 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
711 | } else { | 717 | } else { |
712 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 718 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
713 | } | 719 | } |
714 | 720 | ||
715 | } else { | 721 | } else { |
716 | if (cat.isEmpty()) { | 722 | if (cat.isEmpty()) { |
717 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 723 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
718 | } else { | 724 | } else { |
719 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 725 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
720 | } | 726 | } |
721 | } | 727 | } |
722 | 728 | ||
723 | } else { | 729 | } else { |
724 | pal = mStandardPalette ; | 730 | pal = mStandardPalette ; |
725 | } | 731 | } |
726 | item->setPalette( pal ); | 732 | item->setPalette( pal ); |
727 | item->setRecur( todo->recurrence()->doesRecur() ); | 733 | item->setRecur( todo->recurrence()->doesRecur() ); |
728 | item->setAlarm( todo->isAlarmEnabled() ); | 734 | item->setAlarm( todo->isAlarmEnabled() ); |
729 | item->setMoreInfo( todo->description().length() > 0 ); | 735 | item->setMoreInfo( todo->description().length() > 0 ); |
730 | if ( insertNewItem) | 736 | if ( insertNewItem) |
731 | insertItem( item ); | 737 | insertItem( item ); |
732 | mToolTip.append( text ); | 738 | mToolTip.append( text ); |
733 | } | 739 | } |
734 | void MonthViewCell::repaintfinishUpdateCell() | 740 | void MonthViewCell::repaintfinishUpdateCell() |
735 | { | 741 | { |
736 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 742 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
737 | while ( mitem ) { | 743 | while ( mitem ) { |
738 | mitem->setBlockRepaint( false ); | 744 | mitem->setBlockRepaint( false ); |
739 | updateItem ( mitem ); | 745 | updateItem ( mitem ); |
740 | mitem = (MonthViewItem *)mitem->next(); | 746 | mitem = (MonthViewItem *)mitem->next(); |
741 | } | 747 | } |
742 | } | 748 | } |
743 | void MonthViewCell::finishUpdateCell() | 749 | void MonthViewCell::finishUpdateCell() |
744 | { | 750 | { |
745 | while ( mCurrentAvailItem ) { | 751 | while ( mCurrentAvailItem ) { |
746 | MonthViewItem *item = mCurrentAvailItem; | 752 | MonthViewItem *item = mCurrentAvailItem; |
747 | mCurrentAvailItem = (MonthViewItem *)item->next(); | 753 | mCurrentAvailItem = (MonthViewItem *)item->next(); |
748 | mAvailItemList.append( item ); | 754 | mAvailItemList.append( item ); |
749 | takeItem ( item ); | 755 | takeItem ( item ); |
750 | } | 756 | } |
751 | 757 | ||
752 | 758 | ||
753 | #ifdef DESKTOP_VERSION | 759 | #ifdef DESKTOP_VERSION |
754 | if (mToolTip.count() > 0 ) { | 760 | if (mToolTip.count() > 0 ) { |
755 | mToolTip.sort(); | 761 | mToolTip.sort(); |
756 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 762 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
757 | } | 763 | } |
758 | #endif | 764 | #endif |
759 | sort(); | 765 | sort(); |
760 | //setMyPalette(); | 766 | //setMyPalette(); |
761 | setMyPalette(); | 767 | setMyPalette(); |
762 | 768 | ||
763 | resizeEvent( 0 ); | 769 | resizeEvent( 0 ); |
764 | 770 | ||
765 | } | 771 | } |
766 | void MonthViewCell::updateCell() | 772 | void MonthViewCell::updateCell() |
767 | { | 773 | { |
768 | //qDebug("MonthViewCell::updateCell() "); | 774 | //qDebug("MonthViewCell::updateCell() "); |
769 | if ( !mMonthView->isUpdatePossible() ) | 775 | if ( !mMonthView->isUpdatePossible() ) |
770 | return; | 776 | return; |
771 | startUpdateCell(); | 777 | startUpdateCell(); |
772 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 778 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
773 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 779 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
774 | Event *event; | 780 | Event *event; |
775 | for( event = events.first(); event; event = events.next() ) { // for event | 781 | for( event = events.first(); event; event = events.next() ) { // for event |
776 | insertEvent(event); | 782 | insertEvent(event); |
777 | } | 783 | } |
778 | // insert due todos | 784 | // insert due todos |
779 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 785 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
780 | Todo *todo; | 786 | Todo *todo; |
781 | for(todo = todos.first(); todo; todo = todos.next()) { | 787 | for(todo = todos.first(); todo; todo = todos.next()) { |
782 | insertTodo( todo ); | 788 | insertTodo( todo ); |
783 | } | 789 | } |
784 | finishUpdateCell(); | 790 | finishUpdateCell(); |
785 | // if ( isVisible()) | 791 | // if ( isVisible()) |
786 | //qApp->processEvents(); | 792 | //qApp->processEvents(); |
787 | } | 793 | } |
788 | 794 | ||
789 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 795 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
790 | { | 796 | { |
791 | 797 | ||
792 | if ( bigFont ) { | 798 | if ( bigFont ) { |
793 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 799 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
794 | int ps = fo.pointSize() + 2; | 800 | int ps = fo.pointSize() + 2; |
795 | if ( ps < 18 ) | 801 | if ( ps < 18 ) |
796 | ps += 2; | 802 | ps += 2; |
797 | fo.setPointSize( ps ); | 803 | fo.setPointSize( ps ); |
798 | setFont( fo ); | 804 | setFont( fo ); |
799 | } else | 805 | } else |
800 | setFont( KOPrefs::instance()->mMonthViewFont ); | 806 | setFont( KOPrefs::instance()->mMonthViewFont ); |
801 | 807 | ||
802 | QFontMetrics fm( font() ); | 808 | QFontMetrics fm( font() ); |
803 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 809 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
804 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 810 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
805 | mHolidayPalette = mStandardPalette; | 811 | mHolidayPalette = mStandardPalette; |
806 | mPrimaryPalette = mStandardPalette; | 812 | mPrimaryPalette = mStandardPalette; |
807 | mNonPrimaryPalette = mStandardPalette; | 813 | mNonPrimaryPalette = mStandardPalette; |
808 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 814 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
809 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 815 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
810 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 816 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
811 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 817 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
812 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 818 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
813 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 819 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
814 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 820 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
815 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 821 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
816 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 822 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
817 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 823 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
818 | } | 824 | } |
819 | //updateCell(); | 825 | //updateCell(); |
820 | } | 826 | } |
821 | 827 | ||
822 | void MonthViewCell::enableScrollBars( bool enabled ) | 828 | void MonthViewCell::enableScrollBars( bool enabled ) |
823 | { | 829 | { |
824 | if ( enabled ) { | 830 | if ( enabled ) { |
825 | QListBoxItem *fi = firstItem (); | 831 | QListBoxItem *fi = firstItem (); |
826 | if (fi ) { | 832 | if (fi ) { |
827 | int ihei = fi->height( this ); | 833 | int ihei = fi->height( this ); |
828 | int hei = numRows () * ihei; | 834 | int hei = numRows () * ihei; |
829 | if ( hei < height() - horizontalScrollBar()->height () ) { | 835 | if ( hei < height() - horizontalScrollBar()->height () ) { |
830 | setVScrollBarMode(QScrollView::AlwaysOff); | 836 | setVScrollBarMode(QScrollView::AlwaysOff); |
831 | } | 837 | } |
832 | else | 838 | else |
833 | setVScrollBarMode(QScrollView::Auto); | 839 | setVScrollBarMode(QScrollView::Auto); |
834 | if ( ihei *3 > height() ) | 840 | if ( ihei *3 > height() ) |
835 | setHScrollBarMode(QScrollView::AlwaysOff); | 841 | setHScrollBarMode(QScrollView::AlwaysOff); |
836 | else | 842 | else |
837 | setHScrollBarMode(QScrollView::Auto); | 843 | setHScrollBarMode(QScrollView::Auto); |
838 | } else { | 844 | } else { |
839 | setVScrollBarMode(QScrollView::Auto); | 845 | setVScrollBarMode(QScrollView::Auto); |
840 | setHScrollBarMode(QScrollView::Auto); | 846 | setHScrollBarMode(QScrollView::Auto); |
841 | } | 847 | } |
842 | } else { | 848 | } else { |
843 | setVScrollBarMode(QScrollView::AlwaysOff); | 849 | setVScrollBarMode(QScrollView::AlwaysOff); |
844 | setHScrollBarMode(QScrollView::AlwaysOff); | 850 | setHScrollBarMode(QScrollView::AlwaysOff); |
845 | } | 851 | } |
846 | } | 852 | } |
847 | 853 | ||
848 | Incidence *MonthViewCell::selectedIncidence() | 854 | Incidence *MonthViewCell::selectedIncidence() |
849 | { | 855 | { |
850 | int index = currentItem(); | 856 | int index = currentItem(); |
851 | if ( index < 0 ) return 0; | 857 | if ( index < 0 ) return 0; |
852 | 858 | ||
853 | MonthViewItem *mitem = | 859 | MonthViewItem *mitem = |
854 | static_cast<MonthViewItem *>( item( index ) ); | 860 | static_cast<MonthViewItem *>( item( index ) ); |
855 | 861 | ||
856 | if ( !mitem ) return 0; | 862 | if ( !mitem ) return 0; |
857 | 863 | ||
858 | return mitem->incidence(); | 864 | return mitem->incidence(); |
859 | } | 865 | } |
860 | 866 | ||
861 | QDate MonthViewCell::selectedIncidenceDate() | 867 | QDate MonthViewCell::selectedIncidenceDate() |
862 | { | 868 | { |
863 | QDate qd; | 869 | QDate qd; |
864 | int index = currentItem(); | 870 | int index = currentItem(); |
865 | if ( index < 0 ) return qd; | 871 | if ( index < 0 ) return qd; |
866 | 872 | ||
867 | MonthViewItem *mitem = | 873 | MonthViewItem *mitem = |
868 | static_cast<MonthViewItem *>( item( index ) ); | 874 | static_cast<MonthViewItem *>( item( index ) ); |
869 | 875 | ||
870 | if ( !mitem ) return qd; | 876 | if ( !mitem ) return qd; |
871 | 877 | ||
872 | return mitem->incidenceDate(); | 878 | return mitem->incidenceDate(); |
873 | } | 879 | } |
874 | 880 | ||
875 | void MonthViewCell::deselect() | 881 | void MonthViewCell::deselect() |
876 | { | 882 | { |
877 | clearSelection(); | 883 | clearSelection(); |
878 | enableScrollBars( false ); | 884 | enableScrollBars( false ); |
879 | // updateCell(); | 885 | // updateCell(); |
880 | } | 886 | } |
881 | void MonthViewCell::select() | 887 | void MonthViewCell::select() |
882 | { | 888 | { |
883 | ;// updateCell(); | 889 | ;// updateCell(); |
884 | } | 890 | } |
885 | 891 | ||
886 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 892 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
887 | { | 893 | { |
888 | if ( !mMonthView->isUpdatePossible() ) | 894 | if ( !mMonthView->isUpdatePossible() ) |
889 | return; | 895 | return; |
890 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 896 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
891 | deselect(); | 897 | deselect(); |
892 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 898 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
893 | 899 | ||
894 | QString text; | 900 | QString text; |
895 | mLabel->setText( text ); | 901 | mLabel->setText( text ); |
896 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 902 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
897 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 903 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
898 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 904 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
899 | mLabel->resize( mLabelBigSize ); | 905 | mLabel->resize( mLabelBigSize ); |
900 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 906 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
901 | } else { | 907 | } else { |
902 | mLabel->resize( mLabelSize ); | 908 | mLabel->resize( mLabelSize ); |
903 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 909 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
904 | } | 910 | } |
905 | mLabel->setText( text ); | 911 | mLabel->setText( text ); |
906 | 912 | ||
907 | int size = height() - mLabel->height() - lineWidth()-1; | 913 | int size = height() - mLabel->height() - lineWidth()-1; |
908 | //qDebug("LW %d ", lineWidth()); | 914 | //qDebug("LW %d ", lineWidth()); |
909 | if ( size > 0 ) | 915 | if ( size > 0 ) |
910 | verticalScrollBar()->setMaximumHeight( size ); | 916 | verticalScrollBar()->setMaximumHeight( size ); |
911 | size = width() - mLabel->width() -lineWidth()-1; | 917 | size = width() - mLabel->width() -lineWidth()-1; |
912 | if ( size > 0 ) | 918 | if ( size > 0 ) |
913 | horizontalScrollBar()->setMaximumWidth( size ); | 919 | horizontalScrollBar()->setMaximumWidth( size ); |
914 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 920 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
915 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 921 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
916 | // mItemList->resize ( width(), height () ); | 922 | // mItemList->resize ( width(), height () ); |
917 | if ( e ) | 923 | if ( e ) |
918 | KNoScrollListBox::resizeEvent ( e ); | 924 | KNoScrollListBox::resizeEvent ( e ); |
919 | } | 925 | } |
920 | 926 | ||
921 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 927 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
922 | { | 928 | { |
923 | if ( !item ) return; | 929 | if ( !item ) return; |
924 | 930 | ||
925 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 931 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
926 | Incidence *incidence = eventItem->incidence(); | 932 | Incidence *incidence = eventItem->incidence(); |
927 | if ( incidence ) mMonthView->defaultAction( incidence ); | 933 | if ( incidence ) mMonthView->defaultAction( incidence ); |
928 | } | 934 | } |
929 | void MonthViewCell::showDay() | 935 | void MonthViewCell::showDay() |
930 | { | 936 | { |
931 | emit showDaySignal( date() ); | 937 | emit showDaySignal( date() ); |
932 | } | 938 | } |
933 | void MonthViewCell::newEvent() | 939 | void MonthViewCell::newEvent() |
934 | { | 940 | { |
935 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 941 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
936 | emit newEventSignal( dt ); | 942 | emit newEventSignal( dt ); |
937 | } | 943 | } |
938 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 944 | void MonthViewCell::cellClicked( QListBoxItem *item ) |