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