author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /korganizer/komonthview.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | korganizer/komonthview.cpp | 218 |
1 files changed, 115 insertions, 103 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 85e9166..ca55c43 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,311 +1,323 @@ | |||
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 <q3popupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qnamespace.h> |
24 | #include <qhbox.h> | 24 | #include <q3hbox.h> |
25 | #include <qvbox.h> | 25 | #include <q3vbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <q3widgetstack.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 <q3whatsthis.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 | #include <QDesktopWidget> | ||
37 | //Added by qt3to4: | ||
38 | #include <QResizeEvent> | ||
39 | #include <QLabel> | ||
40 | #include <QPixmap> | ||
41 | #include <QFocusEvent> | ||
42 | #include <QMouseEvent> | ||
43 | #include <QKeyEvent> | ||
44 | #include <Q3VBoxLayout> | ||
45 | #include <Q3Frame> | ||
46 | #include <Q3PointArray> | ||
47 | #include <Q3PtrList> | ||
36 | #endif | 48 | #endif |
37 | 49 | ||
38 | #include <kdebug.h> | 50 | #include <kdebug.h> |
39 | #include <klocale.h> | 51 | #include <klocale.h> |
40 | #include <kglobal.h> | 52 | #include <kglobal.h> |
41 | #include <kconfig.h> | 53 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 54 | #include <kiconloader.h> |
43 | 55 | ||
44 | #include <kcalendarsystem.h> | 56 | #include <kcalendarsystem.h> |
45 | 57 | ||
46 | #ifndef KORG_NOPRINTER | 58 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 59 | #include "calprinter.h" |
48 | #endif | 60 | #endif |
49 | #include "koprefs.h" | 61 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 62 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 63 | #include "kocore.h" |
52 | #endif | 64 | #endif |
53 | #include "koglobals.h" | 65 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 66 | #include <libkcal/kincidenceformatter.h> |
55 | 67 | ||
56 | #include "komonthview.h" | 68 | #include "komonthview.h" |
57 | 69 | ||
58 | #define PIXMAP_SIZE 5 | 70 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 71 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 72 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 73 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 74 | class KNOWhatsThis :public Q3WhatsThis |
63 | { | 75 | { |
64 | public: | 76 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 77 | KNOWhatsThis( KNoScrollListBox* sbox ) : Q3WhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 78 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 79 | ||
68 | protected: | 80 | protected: |
69 | virtual QString text( const QPoint& p) | 81 | virtual QString text( const QPoint& p) |
70 | { | 82 | { |
71 | return _wid->getWhatsThisText(p) ; | 83 | return _wid->getWhatsThisText(p) ; |
72 | }; | 84 | }; |
73 | private: | 85 | private: |
74 | KNoScrollListBox* _wid; | 86 | KNoScrollListBox* _wid; |
75 | 87 | ||
76 | }; | 88 | }; |
77 | 89 | ||
78 | 90 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 91 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 92 | : Q3ListBox(parent, name, Qt::WNoAutoErase) |
81 | { | 93 | { |
82 | #ifndef DESKTOP_VERSION | 94 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 95 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 96 | #endif |
85 | mBlockDeselect = false; | 97 | mBlockDeselect = false; |
86 | mWT = new KNOWhatsThis(this); | 98 | mWT = new KNOWhatsThis(this); |
87 | resetOnFocusIn = true; | 99 | resetOnFocusIn = true; |
88 | setVScrollBarMode(QScrollView::AlwaysOff); | 100 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
89 | setHScrollBarMode(QScrollView::AlwaysOff); | 101 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
90 | } | 102 | } |
91 | KNoScrollListBox::~KNoScrollListBox() | 103 | KNoScrollListBox::~KNoScrollListBox() |
92 | { | 104 | { |
93 | #if QT_VERSION >= 0x030000 | 105 | #if QT_VERSION >= 0x030000 |
94 | 106 | ||
95 | #else | 107 | #else |
96 | delete mWT; | 108 | delete mWT; |
97 | #endif | 109 | #endif |
98 | } | 110 | } |
99 | 111 | ||
100 | 112 | ||
101 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 113 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
102 | { | 114 | { |
103 | QListBox::focusInEvent ( e ); | 115 | Q3ListBox::focusInEvent ( e ); |
104 | if ( count() ){ | 116 | if ( count() ){ |
105 | int ci = currentItem(); | 117 | int ci = currentItem(); |
106 | if ( ci < 0 ) ci = 0; | 118 | if ( ci < 0 ) ci = 0; |
107 | 119 | ||
108 | setCurrentItem( ci ); | 120 | setCurrentItem( ci ); |
109 | setSelected ( ci, true ); | 121 | setSelected ( ci, true ); |
110 | emit highlighted( item ( ci ) ); | 122 | emit highlighted( item ( ci ) ); |
111 | 123 | ||
112 | resetOnFocusIn = true; | 124 | resetOnFocusIn = true; |
113 | 125 | ||
114 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 126 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
115 | QListBoxItem *fi = firstItem (); | 127 | Q3ListBoxItem *fi = firstItem (); |
116 | if (fi ) { | 128 | if (fi ) { |
117 | int ihei = fi->height( this ); | 129 | int ihei = fi->height( this ); |
118 | int hei = numRows () * ihei; | 130 | int hei = numRows () * ihei; |
119 | if ( hei < height() - horizontalScrollBar()->height () ) { | 131 | if ( hei < height() - horizontalScrollBar()->height () ) { |
120 | setVScrollBarMode(QScrollView::AlwaysOff); | 132 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
121 | } | 133 | } |
122 | else | 134 | else |
123 | setVScrollBarMode(QScrollView::Auto); | 135 | setVScrollBarMode(Q3ScrollView::Auto); |
124 | if ( ihei *3 > height() ) { | 136 | if ( ihei *3 > height() ) { |
125 | setHScrollBarMode(QScrollView::AlwaysOff); | 137 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
126 | } | 138 | } |
127 | else { | 139 | else { |
128 | setHScrollBarMode(QScrollView::Auto); | 140 | setHScrollBarMode(Q3ScrollView::Auto); |
129 | } | 141 | } |
130 | } else { | 142 | } else { |
131 | setVScrollBarMode(QScrollView::Auto); | 143 | setVScrollBarMode(Q3ScrollView::Auto); |
132 | setHScrollBarMode(QScrollView::Auto); | 144 | setHScrollBarMode(Q3ScrollView::Auto); |
133 | } | 145 | } |
134 | } | 146 | } |
135 | } | 147 | } |
136 | } | 148 | } |
137 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 149 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
138 | { | 150 | { |
139 | if ( ! mBlockDeselect ) { | 151 | if ( ! mBlockDeselect ) { |
140 | int i = currentItem (); | 152 | int i = currentItem (); |
141 | if ( i >= 0 ) { | 153 | if ( i >= 0 ) { |
142 | setSelected ( i, false ); | 154 | setSelected ( i, false ); |
143 | } | 155 | } |
144 | QListBox::focusOutEvent ( e ); | 156 | Q3ListBox::focusOutEvent ( e ); |
145 | } | 157 | } |
146 | setVScrollBarMode(QScrollView::AlwaysOff); | 158 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
147 | setHScrollBarMode(QScrollView::AlwaysOff); | 159 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
148 | if ( ! mBlockDeselect ) | 160 | if ( ! mBlockDeselect ) |
149 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); | 161 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); |
150 | mBlockDeselect = false; | 162 | mBlockDeselect = false; |
151 | } | 163 | } |
152 | 164 | ||
153 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 165 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
154 | { | 166 | { |
155 | QListBoxItem* item = itemAt ( p ); | 167 | Q3ListBoxItem* item = itemAt ( p ); |
156 | if ( ! item ) { | 168 | if ( ! item ) { |
157 | return i18n("Click in the cell\nto add an event!"); | 169 | return i18n("Click in the cell\nto add an event!"); |
158 | } | 170 | } |
159 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 171 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
160 | KOPrefs::instance()->mWTshowDetails, | 172 | KOPrefs::instance()->mWTshowDetails, |
161 | KOPrefs::instance()->mWTshowCreated, | 173 | KOPrefs::instance()->mWTshowCreated, |
162 | KOPrefs::instance()->mWTshowChanged); | 174 | KOPrefs::instance()->mWTshowChanged); |
163 | } | 175 | } |
164 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 176 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
165 | { | 177 | { |
166 | //qDebug("KNoScrollListBox::keyPressEvent "); | 178 | //qDebug("KNoScrollListBox::keyPressEvent "); |
167 | switch(e->key()) { | 179 | switch(e->key()) { |
168 | case Key_Right: | 180 | case Qt::Key_Right: |
169 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 181 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
170 | { | 182 | { |
171 | e->ignore(); | 183 | e->ignore(); |
172 | return; | 184 | return; |
173 | } | 185 | } |
174 | scrollBy(10,0); | 186 | scrollBy(10,0); |
175 | break; | 187 | break; |
176 | case Key_Left: | 188 | case Qt::Key_Left: |
177 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 189 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
178 | { | 190 | { |
179 | e->ignore(); | 191 | e->ignore(); |
180 | return; | 192 | return; |
181 | } | 193 | } |
182 | scrollBy(-10,0); | 194 | scrollBy(-10,0); |
183 | break; | 195 | break; |
184 | case Key_Up: | 196 | case Qt::Key_Up: |
185 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 197 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
186 | e->ignore(); | 198 | e->ignore(); |
187 | break; | 199 | break; |
188 | } | 200 | } |
189 | if ( count() ) { | 201 | if ( count() ) { |
190 | if ( currentItem() == 0 ) { | 202 | if ( currentItem() == 0 ) { |
191 | emit prevCell(); | 203 | emit prevCell(); |
192 | } else { | 204 | } else { |
193 | setCurrentItem((currentItem()+count()-1)%count()); | 205 | setCurrentItem((currentItem()+count()-1)%count()); |
194 | if(!itemVisible(currentItem())) { | 206 | if(!itemVisible(currentItem())) { |
195 | if((unsigned int) currentItem() == (count()-1)) { | 207 | if((unsigned int) currentItem() == (count()-1)) { |
196 | setTopItem(currentItem()-numItemsVisible()+1); | 208 | setTopItem(currentItem()-numItemsVisible()+1); |
197 | } else { | 209 | } else { |
198 | setTopItem(topItem()-1); | 210 | setTopItem(topItem()-1); |
199 | } | 211 | } |
200 | } | 212 | } |
201 | } | 213 | } |
202 | } | 214 | } |
203 | break; | 215 | break; |
204 | case Key_Down: | 216 | case Qt::Key_Down: |
205 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 217 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
206 | e->ignore(); | 218 | e->ignore(); |
207 | break; | 219 | break; |
208 | } | 220 | } |
209 | if ( count () ) { | 221 | if ( count () ) { |
210 | if ( ((uint)currentItem()+1) == count () ) { | 222 | if ( ((uint)currentItem()+1) == count () ) { |
211 | emit nextCell(); | 223 | emit nextCell(); |
212 | } else { | 224 | } else { |
213 | setCurrentItem((currentItem()+1)%count()); | 225 | setCurrentItem((currentItem()+1)%count()); |
214 | if(!itemVisible(currentItem())) { | 226 | if(!itemVisible(currentItem())) { |
215 | if(currentItem() == 0) { | 227 | if(currentItem() == 0) { |
216 | setTopItem(0); | 228 | setTopItem(0); |
217 | } else { | 229 | } else { |
218 | setTopItem(topItem()+1); | 230 | setTopItem(topItem()+1); |
219 | } | 231 | } |
220 | } | 232 | } |
221 | } | 233 | } |
222 | } | 234 | } |
223 | break; | 235 | break; |
224 | case Key_I: | 236 | case Qt::Key_I: |
225 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 237 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
226 | e->ignore(); | 238 | e->ignore(); |
227 | break; | 239 | break; |
228 | case Key_Return: | 240 | case Qt::Key_Return: |
229 | case Key_Enter: | 241 | case Qt::Key_Enter: |
230 | { | 242 | { |
231 | if ( currentItem() >= 0 ) { | 243 | if ( currentItem() >= 0 ) { |
232 | emit doubleClicked( item( currentItem() ) ); | 244 | emit doubleClicked( item( currentItem() ) ); |
233 | e->accept(); | 245 | e->accept(); |
234 | } else { | 246 | } else { |
235 | e->ignore(); | 247 | e->ignore(); |
236 | } | 248 | } |
237 | } | 249 | } |
238 | break; | 250 | break; |
239 | case Key_Shift: | 251 | case Qt::Key_Shift: |
240 | emit shiftDown(); | 252 | emit shiftDown(); |
241 | break; | 253 | break; |
242 | default: | 254 | default: |
243 | e->ignore(); | 255 | e->ignore(); |
244 | break; | 256 | break; |
245 | } | 257 | } |
246 | } | 258 | } |
247 | 259 | ||
248 | void KNoScrollListBox::oneDown() | 260 | void KNoScrollListBox::oneDown() |
249 | { | 261 | { |
250 | if ( count () ) { | 262 | if ( count () ) { |
251 | if ( ((uint)currentItem()+1) == count () ) { | 263 | if ( ((uint)currentItem()+1) == count () ) { |
252 | emit nextCell(); | 264 | emit nextCell(); |
253 | } else { | 265 | } else { |
254 | resetOnFocusIn = false; | 266 | resetOnFocusIn = false; |
255 | setCurrentItem((currentItem()+1)%count()); | 267 | setCurrentItem((currentItem()+1)%count()); |
256 | if(!itemVisible(currentItem())) { | 268 | if(!itemVisible(currentItem())) { |
257 | if(currentItem() == 0) { | 269 | if(currentItem() == 0) { |
258 | setTopItem(0); | 270 | setTopItem(0); |
259 | } else { | 271 | } else { |
260 | setTopItem(topItem()+1); | 272 | setTopItem(topItem()+1); |
261 | } | 273 | } |
262 | } | 274 | } |
263 | } | 275 | } |
264 | } | 276 | } |
265 | } | 277 | } |
266 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 278 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
267 | { | 279 | { |
268 | switch(e->key()) { | 280 | switch(e->key()) { |
269 | case Key_Shift: | 281 | case Qt::Key_Shift: |
270 | emit shiftUp(); | 282 | emit shiftUp(); |
271 | break; | 283 | break; |
272 | default: | 284 | default: |
273 | break; | 285 | break; |
274 | } | 286 | } |
275 | } | 287 | } |
276 | 288 | ||
277 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 289 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
278 | { | 290 | { |
279 | QListBox::mousePressEvent(e); | 291 | Q3ListBox::mousePressEvent(e); |
280 | 292 | ||
281 | if(e->button() == RightButton) { | 293 | if(e->button() == Qt::RightButton) { |
282 | emit rightClick(); | 294 | emit rightClick(); |
283 | } | 295 | } |
284 | } | 296 | } |
285 | 297 | ||
286 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) | 298 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) |
287 | : QListBoxItem() | 299 | : Q3ListBoxItem() |
288 | { | 300 | { |
289 | mblockRepaint = true; | 301 | mblockRepaint = true; |
290 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 302 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
291 | recycle( incidence, s ); | 303 | recycle( incidence, s ); |
292 | } | 304 | } |
293 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) | 305 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) |
294 | { | 306 | { |
295 | mDisplayHighlighted = false; | 307 | mDisplayHighlighted = false; |
296 | setText( s ); | 308 | setText( s ); |
297 | mMultiday = 0; | 309 | mMultiday = 0; |
298 | mIncidence = incidence; | 310 | mIncidence = incidence; |
299 | mRecur = false; | 311 | mRecur = false; |
300 | mAlarm = false; | 312 | mAlarm = false; |
301 | mReply = false; | 313 | mReply = false; |
302 | mInfo = false; | 314 | mInfo = false; |
303 | mdayPos = 0; | 315 | mdayPos = 0; |
304 | } | 316 | } |
305 | 317 | ||
306 | bool MonthViewItem::setHighlightedFalse() | 318 | bool MonthViewItem::setHighlightedFalse() |
307 | { | 319 | { |
308 | if ( !mDisplayHighlighted ) | 320 | if ( !mDisplayHighlighted ) |
309 | return false; | 321 | return false; |
310 | mDisplayHighlighted = false; | 322 | mDisplayHighlighted = false; |
311 | return true; | 323 | return true; |
@@ -374,56 +386,56 @@ void MonthViewItem::paint(QPainter *p) | |||
374 | p->fillRect ( x, y,size,size, Qt::yellow ); | 386 | p->fillRect ( x, y,size,size, Qt::yellow ); |
375 | x += size + 1; | 387 | x += size + 1; |
376 | } | 388 | } |
377 | } | 389 | } |
378 | 390 | ||
379 | 391 | ||
380 | 392 | ||
381 | 393 | ||
382 | if ( sel ) p->setPen( Qt::white ); | 394 | if ( sel ) p->setPen( Qt::white ); |
383 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); | 395 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); |
384 | 396 | ||
385 | #if 0 | 397 | #if 0 |
386 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 398 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
387 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 399 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
388 | #endif | 400 | #endif |
389 | QColor textColor = p->pen().color(); | 401 | QColor textColor = p->pen().color(); |
390 | 402 | ||
391 | 403 | ||
392 | if ( mMultiday ) { | 404 | if ( mMultiday ) { |
393 | int yyy = y+(size/2); | 405 | int yyy = y+(size/2); |
394 | int sizeM = size+2; | 406 | int sizeM = size+2; |
395 | p->setBrush( QBrush( textColor ) ); | 407 | p->setBrush( QBrush( textColor ) ); |
396 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 408 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
397 | if ( mMultiday == 2 || mMultiday == 3 ) { | 409 | if ( mMultiday == 2 || mMultiday == 3 ) { |
398 | QPointArray pa ( 3 ); | 410 | Q3PointArray pa ( 3 ); |
399 | pa.setPoint (0, x, yyy ); | 411 | pa.setPoint (0, x, yyy ); |
400 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 412 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
401 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 413 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
402 | p->drawPolygon( pa ); | 414 | p->drawPolygon( pa ); |
403 | } | 415 | } |
404 | if ( mMultiday == 2 || mMultiday == 1 ) { | 416 | if ( mMultiday == 2 || mMultiday == 1 ) { |
405 | QPointArray pa ( 3 ); | 417 | Q3PointArray pa ( 3 ); |
406 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 418 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
407 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 419 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
408 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 420 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
409 | p->drawPolygon( pa ); | 421 | p->drawPolygon( pa ); |
410 | } | 422 | } |
411 | if ( mMultiday == 1 ) { | 423 | if ( mMultiday == 1 ) { |
412 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 424 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
413 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 425 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
414 | } | 426 | } |
415 | if ( mMultiday == 3 ) { | 427 | if ( mMultiday == 3 ) { |
416 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 428 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
417 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 429 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
418 | 430 | ||
419 | } | 431 | } |
420 | x += sizeM/2 + 1; | 432 | x += sizeM/2 + 1; |
421 | x += sizeM + 1; | 433 | x += sizeM + 1; |
422 | } | 434 | } |
423 | 435 | ||
424 | if ( mIncidence->typeID() == todoID ){ | 436 | if ( mIncidence->typeID() == todoID ){ |
425 | Todo* td = ( Todo* ) mIncidence; | 437 | Todo* td = ( Todo* ) mIncidence; |
426 | if ( td->isCompleted() ) { | 438 | if ( td->isCompleted() ) { |
427 | int half = size/2; | 439 | int half = size/2; |
428 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 440 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
429 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 441 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
@@ -441,132 +453,132 @@ void MonthViewItem::paint(QPainter *p) | |||
441 | int pmheight = size; | 453 | int pmheight = size; |
442 | if( pmheight < fm.height() ) | 454 | if( pmheight < fm.height() ) |
443 | yPos = fm.ascent() + fm.leading()/2; | 455 | yPos = fm.ascent() + fm.leading()/2; |
444 | else | 456 | else |
445 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 457 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
446 | 458 | ||
447 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 459 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
448 | p->drawText( x, yPos, text() ); | 460 | p->drawText( x, yPos, text() ); |
449 | if ( mIncidence->cancelled() ) { | 461 | if ( mIncidence->cancelled() ) { |
450 | int wid = fm.width( text() ); | 462 | int wid = fm.width( text() ); |
451 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 463 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
452 | } | 464 | } |
453 | } else { | 465 | } else { |
454 | QString pText = text(); | 466 | QString pText = text(); |
455 | if( pText.mid(2,1) == ":" ) | 467 | if( pText.mid(2,1) == ":" ) |
456 | pText = pText.mid( 6 ); | 468 | pText = pText.mid( 6 ); |
457 | p->drawText( x, yPos, pText ); | 469 | p->drawText( x, yPos, pText ); |
458 | if ( mIncidence->cancelled() ) { | 470 | if ( mIncidence->cancelled() ) { |
459 | int wid = fm.width( pText ); | 471 | int wid = fm.width( pText ); |
460 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 472 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
461 | } | 473 | } |
462 | } | 474 | } |
463 | } | 475 | } |
464 | 476 | ||
465 | int MonthViewItem::height(const QListBox *lb) const | 477 | int MonthViewItem::height(const Q3ListBox *lb) const |
466 | { | 478 | { |
467 | int ret = 10; | 479 | int ret = 10; |
468 | if ( lb ) | 480 | if ( lb ) |
469 | ret = lb->fontMetrics().lineSpacing()+1; | 481 | ret = lb->fontMetrics().lineSpacing()+1; |
470 | return ret; | 482 | return ret; |
471 | } | 483 | } |
472 | 484 | ||
473 | int MonthViewItem::width(const QListBox *lb) const | 485 | int MonthViewItem::width(const Q3ListBox *lb) const |
474 | { | 486 | { |
475 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 487 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
476 | int size = PIXMAP_SIZE; | 488 | int size = PIXMAP_SIZE; |
477 | if ( QApplication::desktop()->width() < 300 ) | 489 | if ( QApplication::desktop()->width() < 300 ) |
478 | size = 3; | 490 | size = 3; |
479 | int x = 1; | 491 | int x = 1; |
480 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 492 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
481 | if ( mInfo ) { | 493 | if ( mInfo ) { |
482 | x += size + 1; | 494 | x += size + 1; |
483 | } | 495 | } |
484 | if( mRecur ) { | 496 | if( mRecur ) { |
485 | x += size+1; | 497 | x += size+1; |
486 | } | 498 | } |
487 | if( mAlarm ) { | 499 | if( mAlarm ) { |
488 | x += size+1; | 500 | x += size+1; |
489 | } | 501 | } |
490 | if( mReply ) { | 502 | if( mReply ) { |
491 | x += size+1; | 503 | x += size+1; |
492 | } | 504 | } |
493 | } | 505 | } |
494 | if( mMultiday ) { | 506 | if( mMultiday ) { |
495 | x += size+1+2+size/2; | 507 | x += size+1+2+size/2; |
496 | } | 508 | } |
497 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 509 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
498 | } | 510 | } |
499 | if ( ! lb ) | 511 | if ( ! lb ) |
500 | return 10; | 512 | return 10; |
501 | return lb->width(); | 513 | return lb->width(); |
502 | } | 514 | } |
503 | 515 | ||
504 | 516 | ||
505 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 517 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
506 | : KNoScrollListBox( par ), | 518 | : KNoScrollListBox( par ), |
507 | mMonthView( parent ) | 519 | mMonthView( parent ) |
508 | { | 520 | { |
509 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 521 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
510 | currentPalette = 0; | 522 | currentPalette = 0; |
511 | // mLabel = new QLabel( this );QPushButton | 523 | // mLabel = new QLabel( this );QPushButton |
512 | mLabel = new QPushButton( this ); | 524 | mLabel = new QPushButton( this ); |
513 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 525 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
514 | //mLabel->setLineWidth( 1 ); | 526 | //mLabel->setLineWidth( 1 ); |
515 | //mLabel->setAlignment( AlignCenter ); | 527 | //mLabel->setAlignment( AlignCenter ); |
516 | mLabel->setFlat( true ); | 528 | mLabel->setFlat( true ); |
517 | mLabel->setFocusPolicy(NoFocus); | 529 | mLabel->setFocusPolicy(Qt::NoFocus); |
518 | //mItemList = new KNoScrollListBox( this ); | 530 | //mItemList = new KNoScrollListBox( this ); |
519 | setMinimumSize( 10, 10 ); | 531 | setMinimumSize( 10, 10 ); |
520 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 532 | setFrameStyle( Q3Frame::Panel | Q3Frame::Plain ); |
521 | setLineWidth( 1 ); | 533 | setLineWidth( 1 ); |
522 | //topLayout->addWidget( mItemList ); | 534 | //topLayout->addWidget( mItemList ); |
523 | mLabel->raise(); | 535 | mLabel->raise(); |
524 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 536 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
525 | mStandardPalette = palette(); | 537 | mStandardPalette = palette(); |
526 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 538 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
527 | 539 | ||
528 | enableScrollBars( false ); | 540 | enableScrollBars( false ); |
529 | updateConfig(); | 541 | updateConfig(); |
530 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 542 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
531 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 543 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
532 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 544 | connect( this , SIGNAL( doubleClicked( Q3ListBoxItem *) ), |
533 | SLOT( defaultAction( QListBoxItem * ) ) ); | 545 | SLOT( defaultAction( Q3ListBoxItem * ) ) ); |
534 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 546 | connect( this, SIGNAL( rightButtonPressed( Q3ListBoxItem *, |
535 | const QPoint &) ), | 547 | const QPoint &) ), |
536 | SLOT( contextMenu( QListBoxItem * ) ) ); | 548 | SLOT( contextMenu( Q3ListBoxItem * ) ) ); |
537 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 549 | connect( this, SIGNAL( highlighted( Q3ListBoxItem *) ), |
538 | SLOT( selection( QListBoxItem * ) ) ); | 550 | SLOT( selection( Q3ListBoxItem * ) ) ); |
539 | 551 | ||
540 | /* | 552 | /* |
541 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 553 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
542 | SLOT( selection( QListBoxItem * ) ) ); | 554 | SLOT( selection( QListBoxItem * ) ) ); |
543 | */ | 555 | */ |
544 | } | 556 | } |
545 | #ifdef DESKTOP_VERSION | 557 | #ifdef DESKTOP_VERSION |
546 | QToolTipGroup *MonthViewCell::toolTipGroup() | 558 | QToolTipGroup *MonthViewCell::toolTipGroup() |
547 | { | 559 | { |
548 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 560 | /* TODO:hacker: if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); */ |
549 | return mToolTipGroup; | 561 | return mToolTipGroup; |
550 | } | 562 | } |
551 | #endif | 563 | #endif |
552 | 564 | ||
553 | void MonthViewCell::setDate( const QDate &date ) | 565 | void MonthViewCell::setDate( const QDate &date ) |
554 | { | 566 | { |
555 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 567 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
556 | mDate = date; | 568 | mDate = date; |
557 | 569 | ||
558 | 570 | ||
559 | 571 | ||
560 | //resizeEvent( 0 ); | 572 | //resizeEvent( 0 ); |
561 | } | 573 | } |
562 | 574 | ||
563 | QDate MonthViewCell::date() const | 575 | QDate MonthViewCell::date() const |
564 | { | 576 | { |
565 | return mDate; | 577 | return mDate; |
566 | } | 578 | } |
567 | 579 | ||
568 | void MonthViewCell::setPrimary( bool primary ) | 580 | void MonthViewCell::setPrimary( bool primary ) |
569 | { | 581 | { |
570 | mPrimary = primary; | 582 | mPrimary = primary; |
571 | //setMyPalette(); | 583 | //setMyPalette(); |
572 | } | 584 | } |
@@ -616,49 +628,49 @@ QPalette MonthViewCell::getPalette () | |||
616 | bool MonthViewCell::isPrimary() const | 628 | bool MonthViewCell::isPrimary() const |
617 | { | 629 | { |
618 | return mPrimary; | 630 | return mPrimary; |
619 | } | 631 | } |
620 | 632 | ||
621 | void MonthViewCell::setHoliday( bool holiday ) | 633 | void MonthViewCell::setHoliday( bool holiday ) |
622 | { | 634 | { |
623 | mHoliday = holiday; | 635 | mHoliday = holiday; |
624 | //setMyPalette(); | 636 | //setMyPalette(); |
625 | } | 637 | } |
626 | 638 | ||
627 | void MonthViewCell::setHoliday( const QString &holiday ) | 639 | void MonthViewCell::setHoliday( const QString &holiday ) |
628 | { | 640 | { |
629 | mHolidayString = holiday; | 641 | mHolidayString = holiday; |
630 | 642 | ||
631 | if ( !holiday.isEmpty() ) { | 643 | if ( !holiday.isEmpty() ) { |
632 | setHoliday( true ); | 644 | setHoliday( true ); |
633 | } | 645 | } |
634 | } | 646 | } |
635 | 647 | ||
636 | void MonthViewCell::startUpdateCell() | 648 | void MonthViewCell::startUpdateCell() |
637 | { | 649 | { |
638 | blockSignals( true ); | 650 | blockSignals( true ); |
639 | mdayCount = 0; | 651 | mdayCount = 0; |
640 | setFocusPolicy(NoFocus); | 652 | setFocusPolicy(Qt::NoFocus); |
641 | if ( !mMonthView->isUpdatePossible() ) | 653 | if ( !mMonthView->isUpdatePossible() ) |
642 | return; | 654 | return; |
643 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 655 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
644 | while ( mitem ) { | 656 | while ( mitem ) { |
645 | mitem->setBlockRepaint( true ); | 657 | mitem->setBlockRepaint( true ); |
646 | mitem = (MonthViewItem *)mitem->next(); | 658 | mitem = (MonthViewItem *)mitem->next(); |
647 | } | 659 | } |
648 | if ( mAvailItemList.count() > 20 ) { | 660 | if ( mAvailItemList.count() > 20 ) { |
649 | mAvailItemList.setAutoDelete( true ); | 661 | mAvailItemList.setAutoDelete( true ); |
650 | mAvailItemList.clear(); | 662 | mAvailItemList.clear(); |
651 | mAvailItemList.setAutoDelete( false ); | 663 | mAvailItemList.setAutoDelete( false ); |
652 | clear(); | 664 | clear(); |
653 | } | 665 | } |
654 | 666 | ||
655 | setPrimary( mDate.month()%2 ); | 667 | setPrimary( mDate.month()%2 ); |
656 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 668 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
657 | if ( mDate == QDate::currentDate() ) { | 669 | if ( mDate == QDate::currentDate() ) { |
658 | setLineWidth( 3 ); | 670 | setLineWidth( 3 ); |
659 | } else { | 671 | } else { |
660 | setLineWidth( 1 ); | 672 | setLineWidth( 1 ); |
661 | } | 673 | } |
662 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 674 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
663 | //clear(); | 675 | //clear(); |
664 | while ( CurrentAvailItem ) { | 676 | while ( CurrentAvailItem ) { |
@@ -671,49 +683,49 @@ void MonthViewCell::startUpdateCell() | |||
671 | } | 683 | } |
672 | 684 | ||
673 | #ifdef DESKTOP_VERSION | 685 | #ifdef DESKTOP_VERSION |
674 | QToolTip::remove(this); | 686 | QToolTip::remove(this); |
675 | #endif | 687 | #endif |
676 | mToolTip.clear(); | 688 | mToolTip.clear(); |
677 | //qApp->processEvents(); | 689 | //qApp->processEvents(); |
678 | #if 0 | 690 | #if 0 |
679 | if ( !mHolidayString.isEmpty() ) { | 691 | if ( !mHolidayString.isEmpty() ) { |
680 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 692 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
681 | item->setPalette( mHolidayPalette ); | 693 | item->setPalette( mHolidayPalette ); |
682 | insertItem( item ); | 694 | insertItem( item ); |
683 | mToolTip.append ( mHolidayString ); | 695 | mToolTip.append ( mHolidayString ); |
684 | } | 696 | } |
685 | #endif | 697 | #endif |
686 | } | 698 | } |
687 | 699 | ||
688 | int MonthViewCell::insertEvent(Event *event) | 700 | int MonthViewCell::insertEvent(Event *event) |
689 | { | 701 | { |
690 | bool useToolTips = true; | 702 | bool useToolTips = true; |
691 | #ifndef DESKTOP_VERSION | 703 | #ifndef DESKTOP_VERSION |
692 | useToolTips = false; | 704 | useToolTips = false; |
693 | #endif | 705 | #endif |
694 | QString mToolTipText; | 706 | QString mToolTipText; |
695 | setFocusPolicy(WheelFocus); | 707 | setFocusPolicy(Qt::WheelFocus); |
696 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 708 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
697 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 709 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
698 | return mdayCount; | 710 | return mdayCount; |
699 | else | 711 | else |
700 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 712 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
701 | return mdayCount; | 713 | return mdayCount; |
702 | } | 714 | } |
703 | 715 | ||
704 | if ( event->isHoliday()) { | 716 | if ( event->isHoliday()) { |
705 | setHoliday( true ); | 717 | setHoliday( true ); |
706 | if ( mDate.dayOfWeek() == 7 ) | 718 | if ( mDate.dayOfWeek() == 7 ) |
707 | setLineWidth( 3 ); | 719 | setLineWidth( 3 ); |
708 | } | 720 | } |
709 | QString text; | 721 | QString text; |
710 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 722 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
711 | if (event->isMultiDay()) { | 723 | if (event->isMultiDay()) { |
712 | QString prefix = "<->";multiday = 2; | 724 | QString prefix = "<->";multiday = 2; |
713 | QString time; | 725 | QString time; |
714 | if ( event->doesRecur() ) { | 726 | if ( event->doesRecur() ) { |
715 | if ( event->recursOn( mDate) ) { | 727 | if ( event->recursOn( mDate) ) { |
716 | prefix ="->" ;multiday = 1; | 728 | prefix ="->" ;multiday = 1; |
717 | } | 729 | } |
718 | else { | 730 | else { |
719 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 731 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
@@ -813,65 +825,65 @@ int MonthViewCell::insertEvent(Event *event) | |||
813 | KOPrefs::instance()->email()); | 825 | KOPrefs::instance()->email()); |
814 | if ( me != 0 ) { | 826 | if ( me != 0 ) { |
815 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 827 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
816 | item->setReply(true && multiday < 2); | 828 | item->setReply(true && multiday < 2); |
817 | else | 829 | else |
818 | item->setReply(false); | 830 | item->setReply(false); |
819 | } else | 831 | } else |
820 | item->setReply(false); | 832 | item->setReply(false); |
821 | #endif | 833 | #endif |
822 | 834 | ||
823 | item->setMultiDay( multiday ); | 835 | item->setMultiDay( multiday ); |
824 | if ( multiday ) { | 836 | if ( multiday ) { |
825 | insertItem( item ,mdayCount); | 837 | insertItem( item ,mdayCount); |
826 | ++mdayCount; | 838 | ++mdayCount; |
827 | } else { | 839 | } else { |
828 | uint i = mdayCount; | 840 | uint i = mdayCount; |
829 | uint pos = mdayCount; | 841 | uint pos = mdayCount; |
830 | uint itcount = count(); | 842 | uint itcount = count(); |
831 | if ( itcount > 1000 ) { | 843 | if ( itcount > 1000 ) { |
832 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 844 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
833 | itcount = 0; | 845 | itcount = 0; |
834 | } | 846 | } |
835 | for ( i = pos; i < itcount;++i ) { | 847 | for ( i = pos; i < itcount;++i ) { |
836 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 848 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
837 | QListBoxItem* it = this->item ( i ); | 849 | Q3ListBoxItem* it = this->item ( i ); |
838 | if ( it && text < it->text() ) { | 850 | if ( it && text < it->text() ) { |
839 | pos = i; | 851 | pos = i; |
840 | break; | 852 | break; |
841 | } | 853 | } |
842 | ++pos; | 854 | ++pos; |
843 | } | 855 | } |
844 | insertItem( item ,pos); | 856 | insertItem( item ,pos); |
845 | } | 857 | } |
846 | if ( useToolTips ) { | 858 | if ( useToolTips ) { |
847 | mToolTip.append( mToolTipText ); | 859 | mToolTip.append( mToolTipText ); |
848 | } | 860 | } |
849 | return mdayCount; | 861 | return mdayCount; |
850 | } | 862 | } |
851 | void MonthViewCell::insertTodo(Todo *todo) | 863 | void MonthViewCell::insertTodo(Todo *todo) |
852 | { | 864 | { |
853 | setFocusPolicy(WheelFocus); | 865 | setFocusPolicy(Qt::WheelFocus); |
854 | QString text; | 866 | QString text; |
855 | if (todo->hasDueDate()) { | 867 | if (todo->hasDueDate()) { |
856 | if (!todo->doesFloat()) { | 868 | if (!todo->doesFloat()) { |
857 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 869 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
858 | text += " "; | 870 | text += " "; |
859 | } | 871 | } |
860 | } | 872 | } |
861 | text += todo->summary(); | 873 | text += todo->summary(); |
862 | MonthViewItem *item ; | 874 | MonthViewItem *item ; |
863 | if ( mAvailItemList.count() ) { | 875 | if ( mAvailItemList.count() ) { |
864 | item = mAvailItemList.first(); | 876 | item = mAvailItemList.first(); |
865 | mAvailItemList.remove( item ); | 877 | mAvailItemList.remove( item ); |
866 | item->recycle( todo, text ); | 878 | item->recycle( todo, text ); |
867 | } else { | 879 | } else { |
868 | item = new MonthViewItem( todo, text ); | 880 | item = new MonthViewItem( todo, text ); |
869 | } | 881 | } |
870 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 882 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
871 | //item->setPalette( mStandardPalette ); | 883 | //item->setPalette( mStandardPalette ); |
872 | QPalette pal; | 884 | QPalette pal; |
873 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 885 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
874 | QStringList categories = todo->categories(); | 886 | QStringList categories = todo->categories(); |
875 | QString cat = categories.first(); | 887 | QString cat = categories.first(); |
876 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 888 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
877 | pal = getPalette(); | 889 | pal = getPalette(); |
@@ -901,140 +913,140 @@ void MonthViewCell::insertTodo(Todo *todo) | |||
901 | item->setMoreInfo( todo->description().length() > 0 ); | 913 | item->setMoreInfo( todo->description().length() > 0 ); |
902 | insertItem( item , count()); | 914 | insertItem( item , count()); |
903 | #ifdef DESKTOP_VERSION | 915 | #ifdef DESKTOP_VERSION |
904 | mToolTip.append( text ); | 916 | mToolTip.append( text ); |
905 | #endif | 917 | #endif |
906 | } | 918 | } |
907 | void MonthViewCell::repaintfinishUpdateCell() | 919 | void MonthViewCell::repaintfinishUpdateCell() |
908 | { | 920 | { |
909 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 921 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
910 | while ( mitem ) { | 922 | while ( mitem ) { |
911 | mitem->setBlockRepaint( false ); | 923 | mitem->setBlockRepaint( false ); |
912 | updateItem ( mitem ); | 924 | updateItem ( mitem ); |
913 | mitem = (MonthViewItem *)mitem->next(); | 925 | mitem = (MonthViewItem *)mitem->next(); |
914 | } | 926 | } |
915 | blockSignals( false ); | 927 | blockSignals( false ); |
916 | } | 928 | } |
917 | void MonthViewCell::finishUpdateCell() | 929 | void MonthViewCell::finishUpdateCell() |
918 | { | 930 | { |
919 | 931 | ||
920 | 932 | ||
921 | 933 | ||
922 | #ifdef DESKTOP_VERSION | 934 | #ifdef DESKTOP_VERSION |
923 | if (mToolTip.count() > 0 ) { | 935 | if (mToolTip.count() > 0 ) { |
924 | mToolTip.sort(); | 936 | mToolTip.sort(); |
925 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 937 | /* TODO: hacker: QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); */ |
926 | } | 938 | } |
927 | #endif | 939 | #endif |
928 | //sort(); | 940 | //sort(); |
929 | //setMyPalette(); | 941 | //setMyPalette(); |
930 | setMyPalette(); | 942 | setMyPalette(); |
931 | 943 | ||
932 | resizeEvent( 0 ); | 944 | resizeEvent( 0 ); |
933 | 945 | ||
934 | } | 946 | } |
935 | void MonthViewCell::updateCell() | 947 | void MonthViewCell::updateCell() |
936 | { | 948 | { |
937 | if ( !mMonthView->isUpdatePossible() ) | 949 | if ( !mMonthView->isUpdatePossible() ) |
938 | return; | 950 | return; |
939 | startUpdateCell(); | 951 | startUpdateCell(); |
940 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 952 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
941 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 953 | Q3PtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
942 | Event *event; | 954 | Event *event; |
943 | for( event = events.first(); event; event = events.next() ) { // for event | 955 | for( event = events.first(); event; event = events.next() ) { // for event |
944 | insertEvent(event); | 956 | insertEvent(event); |
945 | } | 957 | } |
946 | // insert due todos | 958 | // insert due todos |
947 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 959 | Q3PtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
948 | Todo *todo; | 960 | Todo *todo; |
949 | for(todo = todos.first(); todo; todo = todos.next()) { | 961 | for(todo = todos.first(); todo; todo = todos.next()) { |
950 | insertTodo( todo ); | 962 | insertTodo( todo ); |
951 | } | 963 | } |
952 | finishUpdateCell(); | 964 | finishUpdateCell(); |
953 | // if ( isVisible()) | 965 | // if ( isVisible()) |
954 | //qApp->processEvents(); | 966 | //qApp->processEvents(); |
955 | } | 967 | } |
956 | 968 | ||
957 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 969 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
958 | { | 970 | { |
959 | 971 | ||
960 | if ( bigFont ) { | 972 | if ( bigFont ) { |
961 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 973 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
962 | int ps = fo.pointSize() + 2; | 974 | int ps = fo.pointSize() + 2; |
963 | if ( ps < 18 ) | 975 | if ( ps < 18 ) |
964 | ps += 2; | 976 | ps += 2; |
965 | fo.setPointSize( ps ); | 977 | fo.setPointSize( ps ); |
966 | setFont( fo ); | 978 | setFont( fo ); |
967 | } else | 979 | } else |
968 | setFont( KOPrefs::instance()->mMonthViewFont ); | 980 | setFont( KOPrefs::instance()->mMonthViewFont ); |
969 | 981 | ||
970 | QFontMetrics fm( font() ); | 982 | QFontMetrics fm( font() ); |
971 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 983 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
972 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 984 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
973 | mHolidayPalette = mStandardPalette; | 985 | mHolidayPalette = mStandardPalette; |
974 | mPrimaryPalette = mStandardPalette; | 986 | mPrimaryPalette = mStandardPalette; |
975 | mNonPrimaryPalette = mStandardPalette; | 987 | mNonPrimaryPalette = mStandardPalette; |
976 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 988 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
977 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 989 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
978 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 990 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
979 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 991 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
980 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 992 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
981 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 993 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
982 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 994 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
983 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 995 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
984 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 996 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
985 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 997 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
986 | } | 998 | } |
987 | //updateCell(); | 999 | //updateCell(); |
988 | } | 1000 | } |
989 | 1001 | ||
990 | void MonthViewCell::enableScrollBars( bool enabled ) | 1002 | void MonthViewCell::enableScrollBars( bool enabled ) |
991 | { | 1003 | { |
992 | 1004 | ||
993 | return; | 1005 | return; |
994 | if ( enabled ) { | 1006 | if ( enabled ) { |
995 | QListBoxItem *fi = firstItem (); | 1007 | Q3ListBoxItem *fi = firstItem (); |
996 | if (fi ) { | 1008 | if (fi ) { |
997 | int ihei = fi->height( this ); | 1009 | int ihei = fi->height( this ); |
998 | int hei = numRows () * ihei; | 1010 | int hei = numRows () * ihei; |
999 | if ( hei < height() - horizontalScrollBar()->height () ) { | 1011 | if ( hei < height() - horizontalScrollBar()->height () ) { |
1000 | setVScrollBarMode(QScrollView::AlwaysOff); | 1012 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
1001 | } | 1013 | } |
1002 | else | 1014 | else |
1003 | setVScrollBarMode(QScrollView::Auto); | 1015 | setVScrollBarMode(Q3ScrollView::Auto); |
1004 | if ( ihei *3 > height() ) { | 1016 | if ( ihei *3 > height() ) { |
1005 | setHScrollBarMode(QScrollView::AlwaysOff); | 1017 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
1006 | } | 1018 | } |
1007 | else { | 1019 | else { |
1008 | setHScrollBarMode(QScrollView::Auto); | 1020 | setHScrollBarMode(Q3ScrollView::Auto); |
1009 | } | 1021 | } |
1010 | } else { | 1022 | } else { |
1011 | setVScrollBarMode(QScrollView::Auto); | 1023 | setVScrollBarMode(Q3ScrollView::Auto); |
1012 | setHScrollBarMode(QScrollView::Auto); | 1024 | setHScrollBarMode(Q3ScrollView::Auto); |
1013 | } | 1025 | } |
1014 | } else { | 1026 | } else { |
1015 | setVScrollBarMode(QScrollView::AlwaysOff); | 1027 | setVScrollBarMode(Q3ScrollView::AlwaysOff); |
1016 | setHScrollBarMode(QScrollView::AlwaysOff); | 1028 | setHScrollBarMode(Q3ScrollView::AlwaysOff); |
1017 | } | 1029 | } |
1018 | } | 1030 | } |
1019 | 1031 | ||
1020 | Incidence *MonthViewCell::selectedIncidence() | 1032 | Incidence *MonthViewCell::selectedIncidence() |
1021 | { | 1033 | { |
1022 | int index = currentItem(); | 1034 | int index = currentItem(); |
1023 | if ( index < 0 ) return 0; | 1035 | if ( index < 0 ) return 0; |
1024 | 1036 | ||
1025 | MonthViewItem *mitem = | 1037 | MonthViewItem *mitem = |
1026 | static_cast<MonthViewItem *>( item( index ) ); | 1038 | static_cast<MonthViewItem *>( item( index ) ); |
1027 | 1039 | ||
1028 | if ( !mitem ) return 0; | 1040 | if ( !mitem ) return 0; |
1029 | 1041 | ||
1030 | return mitem->incidence(); | 1042 | return mitem->incidence(); |
1031 | } | 1043 | } |
1032 | 1044 | ||
1033 | QDate MonthViewCell::selectedIncidenceDate() | 1045 | QDate MonthViewCell::selectedIncidenceDate() |
1034 | { | 1046 | { |
1035 | QDate qd; | 1047 | QDate qd; |
1036 | int index = currentItem(); | 1048 | int index = currentItem(); |
1037 | if ( index < 0 ) return qd; | 1049 | if ( index < 0 ) return qd; |
1038 | return mDate; | 1050 | return mDate; |
1039 | } | 1051 | } |
1040 | 1052 | ||
@@ -1062,99 +1074,99 @@ void MonthViewCell::resizeEvent ( QResizeEvent * e ) | |||
1062 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 1074 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1063 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1075 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1064 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); | 1076 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); |
1065 | mLabel->resize( mLabelBigSize ); | 1077 | mLabel->resize( mLabelBigSize ); |
1066 | } else { | 1078 | } else { |
1067 | mLabel->resize( mLabelSize ); | 1079 | mLabel->resize( mLabelSize ); |
1068 | text = QString::number( mDate.day() ); | 1080 | text = QString::number( mDate.day() ); |
1069 | } | 1081 | } |
1070 | mLabel->setText( text ); | 1082 | mLabel->setText( text ); |
1071 | 1083 | ||
1072 | int size = height() - mLabel->height() - lineWidth()-1; | 1084 | int size = height() - mLabel->height() - lineWidth()-1; |
1073 | //qDebug("LW %d ", lineWidth()); | 1085 | //qDebug("LW %d ", lineWidth()); |
1074 | if ( size > 0 ) | 1086 | if ( size > 0 ) |
1075 | verticalScrollBar()->setMaximumHeight( size ); | 1087 | verticalScrollBar()->setMaximumHeight( size ); |
1076 | size = width() - mLabel->width() -lineWidth()-1; | 1088 | size = width() - mLabel->width() -lineWidth()-1; |
1077 | if ( size > 0 ) | 1089 | if ( size > 0 ) |
1078 | horizontalScrollBar()->setMaximumWidth( size ); | 1090 | horizontalScrollBar()->setMaximumWidth( size ); |
1079 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1091 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1080 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1092 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1081 | // mItemList->resize ( width(), height () ); | 1093 | // mItemList->resize ( width(), height () ); |
1082 | if ( e ) | 1094 | if ( e ) |
1083 | KNoScrollListBox::resizeEvent ( e ); | 1095 | KNoScrollListBox::resizeEvent ( e ); |
1084 | } | 1096 | } |
1085 | 1097 | ||
1086 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1098 | void MonthViewCell::defaultAction( Q3ListBoxItem *item ) |
1087 | { | 1099 | { |
1088 | 1100 | ||
1089 | if ( !item ) { | 1101 | if ( !item ) { |
1090 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1102 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1091 | emit newEventSignal( dt ); | 1103 | emit newEventSignal( dt ); |
1092 | return; | 1104 | return; |
1093 | } | 1105 | } |
1094 | 1106 | ||
1095 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1107 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1096 | Incidence *incidence = eventItem->incidence(); | 1108 | Incidence *incidence = eventItem->incidence(); |
1097 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1109 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1098 | } | 1110 | } |
1099 | void MonthViewCell::showDay() | 1111 | void MonthViewCell::showDay() |
1100 | { | 1112 | { |
1101 | emit showDaySignal( date() ); | 1113 | emit showDaySignal( date() ); |
1102 | } | 1114 | } |
1103 | void MonthViewCell::newEvent() | 1115 | void MonthViewCell::newEvent() |
1104 | { | 1116 | { |
1105 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1117 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1106 | emit newEventSignal( dt ); | 1118 | emit newEventSignal( dt ); |
1107 | } | 1119 | } |
1108 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1120 | void MonthViewCell::cellClicked( Q3ListBoxItem *item ) |
1109 | { | 1121 | { |
1110 | mMonthView->setSelectedCell( this ); | 1122 | mMonthView->setSelectedCell( this ); |
1111 | if ( item == 0 ) { | 1123 | if ( item == 0 ) { |
1112 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1124 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1113 | emit newEventSignal( dt ); | 1125 | emit newEventSignal( dt ); |
1114 | return; | 1126 | return; |
1115 | } | 1127 | } |
1116 | 1128 | ||
1117 | } | 1129 | } |
1118 | 1130 | ||
1119 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1131 | void MonthViewCell::contextMenu( Q3ListBoxItem *item ) |
1120 | { | 1132 | { |
1121 | mMonthView->setPopupCell( this ); | 1133 | mMonthView->setPopupCell( this ); |
1122 | if ( !item ) { | 1134 | if ( !item ) { |
1123 | mMonthView->showContextMenu( 0 ); | 1135 | mMonthView->showContextMenu( 0 ); |
1124 | return; | 1136 | return; |
1125 | } | 1137 | } |
1126 | //selection( item ); | 1138 | //selection( item ); |
1127 | //qApp->processEvents(); | 1139 | //qApp->processEvents(); |
1128 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1140 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1129 | Incidence *incidence = eventItem->incidence(); | 1141 | Incidence *incidence = eventItem->incidence(); |
1130 | if ( incidence ) { | 1142 | if ( incidence ) { |
1131 | mBlockDeselect = true; | 1143 | mBlockDeselect = true; |
1132 | mMonthView->showContextMenu( incidence ); | 1144 | mMonthView->showContextMenu( incidence ); |
1133 | } | 1145 | } |
1134 | } | 1146 | } |
1135 | 1147 | ||
1136 | void MonthViewCell::selection( QListBoxItem *item ) | 1148 | void MonthViewCell::selection( Q3ListBoxItem *item ) |
1137 | { | 1149 | { |
1138 | if ( !item ) { | 1150 | if ( !item ) { |
1139 | emit highlightIncidence( 0 , this, 0 ); | 1151 | emit highlightIncidence( 0 , this, 0 ); |
1140 | return; | 1152 | return; |
1141 | } | 1153 | } |
1142 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1154 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1143 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); | 1155 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1144 | mMonthView->setSelectedCell( this ); | 1156 | mMonthView->setSelectedCell( this ); |
1145 | } | 1157 | } |
1146 | 1158 | ||
1147 | void MonthViewCell::deHighLight() | 1159 | void MonthViewCell::deHighLight() |
1148 | { | 1160 | { |
1149 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1161 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1150 | while ( mitem ) { | 1162 | while ( mitem ) { |
1151 | if ( mitem->setHighlightedFalse() ) | 1163 | if ( mitem->setHighlightedFalse() ) |
1152 | updateItem ( mitem ); | 1164 | updateItem ( mitem ); |
1153 | mitem = (MonthViewItem *)mitem->next(); | 1165 | mitem = (MonthViewItem *)mitem->next(); |
1154 | } | 1166 | } |
1155 | } | 1167 | } |
1156 | // returns true if no inc found | 1168 | // returns true if no inc found |
1157 | bool MonthViewCell::doHighLight( Incidence * inc ) | 1169 | bool MonthViewCell::doHighLight( Incidence * inc ) |
1158 | { | 1170 | { |
1159 | 1171 | ||
1160 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1172 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
@@ -1164,189 +1176,189 @@ bool MonthViewCell::doHighLight( Incidence * inc ) | |||
1164 | updateItem ( mitem ); | 1176 | updateItem ( mitem ); |
1165 | return false; | 1177 | return false; |
1166 | } | 1178 | } |
1167 | mitem = (MonthViewItem *)mitem->next(); | 1179 | mitem = (MonthViewItem *)mitem->next(); |
1168 | } | 1180 | } |
1169 | return true; | 1181 | return true; |
1170 | } | 1182 | } |
1171 | // ******************************************************************************* | 1183 | // ******************************************************************************* |
1172 | // ******************************************************************************* | 1184 | // ******************************************************************************* |
1173 | // ******************************************************************************* | 1185 | // ******************************************************************************* |
1174 | 1186 | ||
1175 | 1187 | ||
1176 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1188 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1177 | : KOEventView( calendar, parent, name ), | 1189 | : KOEventView( calendar, parent, name ), |
1178 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1190 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1179 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1191 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1180 | { | 1192 | { |
1181 | mFlagKeyPressed = false; | 1193 | mFlagKeyPressed = false; |
1182 | mShortDayLabelsM = false; | 1194 | mShortDayLabelsM = false; |
1183 | mShortDayLabelsW = false; | 1195 | mShortDayLabelsW = false; |
1184 | skipResize = false; | 1196 | skipResize = false; |
1185 | clPending = true; | 1197 | clPending = true; |
1186 | mPopupCell = 0; | 1198 | mPopupCell = 0; |
1187 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1199 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1188 | mWidStack = new QWidgetStack( this ); | 1200 | mWidStack = new Q3WidgetStack( this ); |
1189 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1201 | Q3VBoxLayout* hb = new Q3VBoxLayout( this ); |
1190 | mMonthView = new QWidget( mWidStack ); | 1202 | mMonthView = new QWidget( mWidStack ); |
1191 | mWeekView = new QWidget( mWidStack ); | 1203 | mWeekView = new QWidget( mWidStack ); |
1192 | #if QT_VERSION >= 0x030000 | 1204 | #if QT_VERSION >= 0x030000 |
1193 | mWidStack->addWidget(mMonthView ); | 1205 | mWidStack->addWidget(mMonthView ); |
1194 | mWidStack->addWidget(mWeekView ); | 1206 | mWidStack->addWidget(mWeekView ); |
1195 | #else | 1207 | #else |
1196 | mWidStack->addWidget( mMonthView, 1 ); | 1208 | mWidStack->addWidget( mMonthView, 1 ); |
1197 | mWidStack->addWidget( mWeekView , 1 ); | 1209 | mWidStack->addWidget( mWeekView , 1 ); |
1198 | #endif | 1210 | #endif |
1199 | hb->addWidget( mNavigatorBar ); | 1211 | hb->addWidget( mNavigatorBar ); |
1200 | hb->addWidget( mWidStack ); | 1212 | hb->addWidget( mWidStack ); |
1201 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1213 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1202 | updatePossible = false; | 1214 | updatePossible = false; |
1203 | //updatePossible = true; | 1215 | //updatePossible = true; |
1204 | mCells.setAutoDelete( true ); | 1216 | mCells.setAutoDelete( true ); |
1205 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1217 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1206 | mDayLabels.resize( mDaysPerWeek ); | 1218 | mDayLabels.resize( mDaysPerWeek ); |
1207 | mDayLabelsW.resize( mDaysPerWeek ); | 1219 | mDayLabelsW.resize( mDaysPerWeek ); |
1208 | QFont bfont = font(); | 1220 | QFont bfont = font(); |
1209 | if ( QApplication::desktop()->width() < 650 ) { | 1221 | if ( QApplication::desktop()->width() < 650 ) { |
1210 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1222 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1211 | } | 1223 | } |
1212 | bfont.setBold( true ); | 1224 | bfont.setBold( true ); |
1213 | int i; | 1225 | int i; |
1214 | 1226 | ||
1215 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1227 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1216 | QLabel *label = new QLabel( mMonthView ); | 1228 | QLabel *label = new QLabel( mMonthView ); |
1217 | label->setFont(bfont); | 1229 | label->setFont(bfont); |
1218 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1230 | label->setFrameStyle(Q3Frame::Panel|Q3Frame::Raised); |
1219 | label->setLineWidth(1); | 1231 | label->setLineWidth(1); |
1220 | label->setAlignment(AlignCenter); | 1232 | label->setAlignment(Qt::AlignCenter); |
1221 | mDayLabels.insert( i, label ); | 1233 | mDayLabels.insert( i, label ); |
1222 | label = new QLabel( mWeekView ); | 1234 | label = new QLabel( mWeekView ); |
1223 | label->setFont(bfont); | 1235 | label->setFont(bfont); |
1224 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1236 | label->setFrameStyle(Q3Frame::Panel|Q3Frame::Raised); |
1225 | label->setLineWidth(1); | 1237 | label->setLineWidth(1); |
1226 | label->setAlignment(AlignCenter); | 1238 | label->setAlignment(Qt::AlignCenter); |
1227 | mDayLabelsW.insert( i, label ); | 1239 | mDayLabelsW.insert( i, label ); |
1228 | } | 1240 | } |
1229 | 1241 | ||
1230 | bfont.setBold( false ); | 1242 | bfont.setBold( false ); |
1231 | mWeekLabels.resize( mNumWeeks+1 ); | 1243 | mWeekLabels.resize( mNumWeeks+1 ); |
1232 | mWeekLabelsW.resize( 2 ); | 1244 | mWeekLabelsW.resize( 2 ); |
1233 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1245 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1234 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1246 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1235 | label->setFocusPolicy(NoFocus); | 1247 | label->setFocusPolicy(Qt::NoFocus); |
1236 | label->setFont(bfont); | 1248 | label->setFont(bfont); |
1237 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1249 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1238 | label->setFlat(true); | 1250 | label->setFlat(true); |
1239 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1251 | Q3WhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1240 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1252 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1241 | //label->setLineWidth(1); | 1253 | //label->setLineWidth(1); |
1242 | //label->setAlignment(AlignCenter); | 1254 | //label->setAlignment(AlignCenter); |
1243 | mWeekLabels.insert( i, label ); | 1255 | mWeekLabels.insert( i, label ); |
1244 | } | 1256 | } |
1245 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1257 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1246 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1258 | mWeekLabels[mNumWeeks]->setFocusPolicy(Qt::WheelFocus); |
1247 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1259 | Q3WhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1248 | 1260 | ||
1249 | for( i = 0; i < 1+1; i++ ) { | 1261 | for( i = 0; i < 1+1; i++ ) { |
1250 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1262 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1251 | label->setFocusPolicy(NoFocus); | 1263 | label->setFocusPolicy(Qt::NoFocus); |
1252 | label->setFont(bfont); | 1264 | label->setFont(bfont); |
1253 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1265 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1254 | label->setFlat(true); | 1266 | label->setFlat(true); |
1255 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1267 | Q3WhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1256 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1268 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1257 | //label->setLineWidth(1); | 1269 | //label->setLineWidth(1); |
1258 | //label->setAlignment(AlignCenter); | 1270 | //label->setAlignment(AlignCenter); |
1259 | mWeekLabelsW.insert( i, label ); | 1271 | mWeekLabelsW.insert( i, label ); |
1260 | } | 1272 | } |
1261 | mWeekLabelsW[1]->setText( i18n("W")); | 1273 | mWeekLabelsW[1]->setText( i18n("W")); |
1262 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1274 | mWeekLabelsW[1]->setFocusPolicy(Qt::WheelFocus); |
1263 | 1275 | ||
1264 | 1276 | ||
1265 | int row, col; | 1277 | int row, col; |
1266 | mCells.resize( mNumCells ); | 1278 | mCells.resize( mNumCells ); |
1267 | for( row = 0; row < mNumWeeks; ++row ) { | 1279 | for( row = 0; row < mNumWeeks; ++row ) { |
1268 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1280 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1269 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1281 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1270 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1282 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1271 | 1283 | ||
1272 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1284 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1273 | SLOT( defaultAction( Incidence * ) ) ); | 1285 | SLOT( defaultAction( Incidence * ) ) ); |
1274 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1286 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1275 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1287 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1276 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1288 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1277 | SIGNAL( showDaySignal( QDate ) ) ); | 1289 | SIGNAL( showDaySignal( QDate ) ) ); |
1278 | connect( cell, SIGNAL( nextCell() ), | 1290 | connect( cell, SIGNAL( nextCell() ), |
1279 | SLOT( nextCell() ) ); | 1291 | SLOT( nextCell() ) ); |
1280 | connect( cell, SIGNAL( prevCell() ), | 1292 | connect( cell, SIGNAL( prevCell() ), |
1281 | SLOT( prevCell() ) ); | 1293 | SLOT( prevCell() ) ); |
1282 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1294 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1283 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1295 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1284 | } | 1296 | } |
1285 | } | 1297 | } |
1286 | mCellsW.resize( mDaysPerWeek ); | 1298 | mCellsW.resize( mDaysPerWeek ); |
1287 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1299 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1288 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1300 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1289 | mCellsW.insert( col, cell ); | 1301 | mCellsW.insert( col, cell ); |
1290 | 1302 | ||
1291 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1303 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1292 | SLOT( defaultAction( Incidence * ) ) ); | 1304 | SLOT( defaultAction( Incidence * ) ) ); |
1293 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1305 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1294 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1306 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1295 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1307 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1296 | SIGNAL( showDaySignal( QDate ) ) ); | 1308 | SIGNAL( showDaySignal( QDate ) ) ); |
1297 | connect( cell, SIGNAL( nextCell() ), | 1309 | connect( cell, SIGNAL( nextCell() ), |
1298 | SLOT( nextCell() ) ); | 1310 | SLOT( nextCell() ) ); |
1299 | connect( cell, SIGNAL( prevCell() ), | 1311 | connect( cell, SIGNAL( prevCell() ), |
1300 | SLOT( prevCell() ) ); | 1312 | SLOT( prevCell() ) ); |
1301 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1313 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1302 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1314 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1303 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1315 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1304 | } | 1316 | } |
1305 | 1317 | ||
1306 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1318 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1307 | mContextMenu = eventPopup(); | 1319 | mContextMenu = eventPopup(); |
1308 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1320 | mContextMenu->addAdditionalItem(QIcon(QPixmap()), |
1309 | i18n("New Event..."),this, | 1321 | i18n("New Event..."),this, |
1310 | SLOT(slotNewEvent()),false); | 1322 | SLOT(slotNewEvent()),false); |
1311 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1323 | mContextMenu->addAdditionalItem(QIcon(QPixmap()), |
1312 | i18n("New Todo..."),this, | 1324 | i18n("New Todo..."),this, |
1313 | SLOT(slotNewTodo()),false); | 1325 | SLOT(slotNewTodo()),false); |
1314 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1326 | mContextMenu->addAdditionalItem(QIcon(QPixmap()), |
1315 | i18n("Journal"),this, | 1327 | i18n("Journal"),this, |
1316 | SLOT(slotEditJournal()),false); | 1328 | SLOT(slotEditJournal()),false); |
1317 | 1329 | ||
1318 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, | 1330 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, |
1319 | SLOT( catChanged( Incidence * ) )); | 1331 | SLOT( catChanged( Incidence * ) )); |
1320 | 1332 | ||
1321 | 1333 | ||
1322 | QString pathString = ""; | 1334 | QString pathString = ""; |
1323 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1335 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1324 | if ( QApplication::desktop()->width() < 480 ) | 1336 | if ( QApplication::desktop()->width() < 480 ) |
1325 | pathString += "icons16/"; | 1337 | pathString += "icons16/"; |
1326 | } else | 1338 | } else |
1327 | pathString += "iconsmini/"; | 1339 | pathString += "iconsmini/"; |
1328 | mNewItemMenu = new QPopupMenu( this ); | 1340 | mNewItemMenu = new Q3PopupMenu( this ); |
1329 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1341 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1330 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1342 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1331 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1343 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1332 | 1344 | ||
1333 | // updateConfig(); //useless here... | 1345 | // updateConfig(); //useless here... |
1334 | // ... but we need mWidthLongDayLabel computed | 1346 | // ... but we need mWidthLongDayLabel computed |
1335 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1347 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1336 | mWidthLongDayLabel = 0; | 1348 | mWidthLongDayLabel = 0; |
1337 | for (int i = 0; i < 7; i++) { | 1349 | for (int i = 0; i < 7; i++) { |
1338 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1350 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1339 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1351 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1340 | } | 1352 | } |
1341 | 1353 | ||
1342 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1354 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1343 | 1355 | ||
1344 | #if 0 | 1356 | #if 0 |
1345 | if ( mShowWeekView ) | 1357 | if ( mShowWeekView ) |
1346 | mWidStack->raiseWidget( mWeekView ); | 1358 | mWidStack->raiseWidget( mWeekView ); |
1347 | else | 1359 | else |
1348 | mWidStack->raiseWidget( mMonthView ); | 1360 | mWidStack->raiseWidget( mMonthView ); |
1349 | #endif | 1361 | #endif |
1350 | 1362 | ||
1351 | emit incidenceSelected( 0 ); | 1363 | emit incidenceSelected( 0 ); |
1352 | 1364 | ||
@@ -1376,49 +1388,49 @@ KOMonthView::~KOMonthView() | |||
1376 | void KOMonthView::catChanged( Incidence * ) | 1388 | void KOMonthView::catChanged( Incidence * ) |
1377 | { | 1389 | { |
1378 | updateView(); | 1390 | updateView(); |
1379 | } | 1391 | } |
1380 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | 1392 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) |
1381 | { | 1393 | { |
1382 | static Incidence * lastInc = 0; | 1394 | static Incidence * lastInc = 0; |
1383 | static MonthViewCell * lastCell = 0; | 1395 | static MonthViewCell * lastCell = 0; |
1384 | 1396 | ||
1385 | if ( lastInc == inc && lastCell == mc ) | 1397 | if ( lastInc == inc && lastCell == mc ) |
1386 | return; | 1398 | return; |
1387 | lastInc = inc; | 1399 | lastInc = inc; |
1388 | lastCell = mc; | 1400 | lastCell = mc; |
1389 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1401 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1390 | 1402 | ||
1391 | bool weekview = false; | 1403 | bool weekview = false; |
1392 | uint index = 0; | 1404 | uint index = 0; |
1393 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1405 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1394 | if ( mCellsW[i] == mc ) { | 1406 | if ( mCellsW[i] == mc ) { |
1395 | weekview = true; | 1407 | weekview = true; |
1396 | index = i; | 1408 | index = i; |
1397 | break; | 1409 | break; |
1398 | } | 1410 | } |
1399 | } | 1411 | } |
1400 | QPtrVector<MonthViewCell> *cells; | 1412 | Q3PtrVector<MonthViewCell> *cells; |
1401 | if ( weekview ) | 1413 | if ( weekview ) |
1402 | cells = &mCellsW; | 1414 | cells = &mCellsW; |
1403 | else { | 1415 | else { |
1404 | for (uint i = 0; i < mCells.count(); ++i) { | 1416 | for (uint i = 0; i < mCells.count(); ++i) { |
1405 | if ( mCells[i] == mc ) { | 1417 | if ( mCells[i] == mc ) { |
1406 | index = i; | 1418 | index = i; |
1407 | break; | 1419 | break; |
1408 | } | 1420 | } |
1409 | } | 1421 | } |
1410 | cells = &mCells; | 1422 | cells = &mCells; |
1411 | } | 1423 | } |
1412 | for (uint i = 0; i < (*cells).count(); ++i) { | 1424 | for (uint i = 0; i < (*cells).count(); ++i) { |
1413 | (*cells)[i]->deHighLight(); | 1425 | (*cells)[i]->deHighLight(); |
1414 | } | 1426 | } |
1415 | if ( ! inc ) | 1427 | if ( ! inc ) |
1416 | return; | 1428 | return; |
1417 | 1429 | ||
1418 | uint count = (*cells).count(); | 1430 | uint count = (*cells).count(); |
1419 | bool goLeft = (mday > 1 && index > 0); | 1431 | bool goLeft = (mday > 1 && index > 0); |
1420 | bool goRight = (mday < 3 && mday > 0 && index < count -1); | 1432 | bool goRight = (mday < 3 && mday > 0 && index < count -1); |
1421 | for (uint iii = 1; iii < count; ++iii) { | 1433 | for (uint iii = 1; iii < count; ++iii) { |
1422 | if ( goLeft ) { | 1434 | if ( goLeft ) { |
1423 | int left = index - iii; | 1435 | int left = index - iii; |
1424 | if ( left >= 0 ) { | 1436 | if ( left >= 0 ) { |
@@ -1474,51 +1486,51 @@ void KOMonthView::switchView() | |||
1474 | selectedCell()->deselect(); | 1486 | selectedCell()->deselect(); |
1475 | mShowWeekView = !mShowWeekView; | 1487 | mShowWeekView = !mShowWeekView; |
1476 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1488 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1477 | if ( clPending ) { | 1489 | if ( clPending ) { |
1478 | computeLayout(); | 1490 | computeLayout(); |
1479 | updateConfig(); | 1491 | updateConfig(); |
1480 | } | 1492 | } |
1481 | if ( mShowWeekView ) | 1493 | if ( mShowWeekView ) |
1482 | mWidStack->raiseWidget( mWeekView ); | 1494 | mWidStack->raiseWidget( mWeekView ); |
1483 | else | 1495 | else |
1484 | mWidStack->raiseWidget( mMonthView ); | 1496 | mWidStack->raiseWidget( mMonthView ); |
1485 | clPending = false; | 1497 | clPending = false; |
1486 | } | 1498 | } |
1487 | 1499 | ||
1488 | int KOMonthView::maxDatesHint() | 1500 | int KOMonthView::maxDatesHint() |
1489 | { | 1501 | { |
1490 | return mNumCells; | 1502 | return mNumCells; |
1491 | } | 1503 | } |
1492 | 1504 | ||
1493 | int KOMonthView::currentDateCount() | 1505 | int KOMonthView::currentDateCount() |
1494 | { | 1506 | { |
1495 | return mNumCells; | 1507 | return mNumCells; |
1496 | } | 1508 | } |
1497 | 1509 | ||
1498 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1510 | Q3PtrList<Incidence> KOMonthView::selectedIncidences() |
1499 | { | 1511 | { |
1500 | QPtrList<Incidence> selected; | 1512 | Q3PtrList<Incidence> selected; |
1501 | 1513 | ||
1502 | if ( mSelectedCell ) { | 1514 | if ( mSelectedCell ) { |
1503 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1515 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1504 | if ( incidence ) selected.append( incidence ); | 1516 | if ( incidence ) selected.append( incidence ); |
1505 | } | 1517 | } |
1506 | 1518 | ||
1507 | return selected; | 1519 | return selected; |
1508 | } | 1520 | } |
1509 | 1521 | ||
1510 | DateList KOMonthView::selectedDates() | 1522 | DateList KOMonthView::selectedDates() |
1511 | { | 1523 | { |
1512 | DateList selected; | 1524 | DateList selected; |
1513 | 1525 | ||
1514 | if ( mSelectedCell ) { | 1526 | if ( mSelectedCell ) { |
1515 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1527 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1516 | if ( qd.isValid() ) selected.append( qd ); | 1528 | if ( qd.isValid() ) selected.append( qd ); |
1517 | } | 1529 | } |
1518 | 1530 | ||
1519 | return selected; | 1531 | return selected; |
1520 | } | 1532 | } |
1521 | #if 0 | 1533 | #if 0 |
1522 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1534 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1523 | const QDate &td) | 1535 | const QDate &td) |
1524 | { | 1536 | { |
@@ -1540,100 +1552,100 @@ void KOMonthView::updateConfig() | |||
1540 | 1552 | ||
1541 | for (int i = 0; i < 7; i++) { | 1553 | for (int i = 0; i < 7; i++) { |
1542 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1554 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1543 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1555 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1544 | } | 1556 | } |
1545 | bool temp = mShowSatSunComp ; | 1557 | bool temp = mShowSatSunComp ; |
1546 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1558 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1547 | if ( ! mShowWeekView ) { | 1559 | if ( ! mShowWeekView ) { |
1548 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1560 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1549 | computeLayout(); | 1561 | computeLayout(); |
1550 | } else | 1562 | } else |
1551 | doComputeLayoutWeek(); | 1563 | doComputeLayoutWeek(); |
1552 | updateDayLabels(); | 1564 | updateDayLabels(); |
1553 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1565 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1554 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1566 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1555 | //resizeEvent( 0 ); | 1567 | //resizeEvent( 0 ); |
1556 | for (uint i = 0; i < mCells.count(); ++i) { | 1568 | for (uint i = 0; i < mCells.count(); ++i) { |
1557 | mCells[i]->updateConfig(); | 1569 | mCells[i]->updateConfig(); |
1558 | } | 1570 | } |
1559 | 1571 | ||
1560 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1572 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1561 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1573 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1562 | } | 1574 | } |
1563 | #ifdef DESKTOP_VERSION | 1575 | #ifdef DESKTOP_VERSION |
1564 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1576 | /* TODO:hacker: MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); */ |
1565 | #endif | 1577 | #endif |
1566 | updateView(); | 1578 | updateView(); |
1567 | } | 1579 | } |
1568 | 1580 | ||
1569 | void KOMonthView::updateDayLabels() | 1581 | void KOMonthView::updateDayLabels() |
1570 | { | 1582 | { |
1571 | 1583 | ||
1572 | QPtrVector<QLabel> *mDayLabelsT; | 1584 | Q3PtrVector<QLabel> *mDayLabelsT; |
1573 | 1585 | ||
1574 | mDayLabelsT = &mDayLabelsW; | 1586 | mDayLabelsT = &mDayLabelsW; |
1575 | for (int i = 0; i < 7; i++) { | 1587 | for (int i = 0; i < 7; i++) { |
1576 | { | 1588 | { |
1577 | bool show = mShortDayLabelsW; | 1589 | bool show = mShortDayLabelsW; |
1578 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1590 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1579 | show = true; | 1591 | show = true; |
1580 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1592 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1581 | } | 1593 | } |
1582 | } | 1594 | } |
1583 | mDayLabelsT = &mDayLabels; | 1595 | mDayLabelsT = &mDayLabels; |
1584 | for (int i = 0; i < 7; i++) { | 1596 | for (int i = 0; i < 7; i++) { |
1585 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1597 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1586 | bool show = mShortDayLabelsM; | 1598 | bool show = mShortDayLabelsM; |
1587 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1599 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1588 | show = true; | 1600 | show = true; |
1589 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1601 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1590 | } else { | 1602 | } else { |
1591 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1603 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1592 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1604 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1593 | 1605 | ||
1594 | } | 1606 | } |
1595 | } | 1607 | } |
1596 | 1608 | ||
1597 | } | 1609 | } |
1598 | 1610 | ||
1599 | void KOMonthView::clearList() | 1611 | void KOMonthView::clearList() |
1600 | { | 1612 | { |
1601 | unsigned int i; | 1613 | unsigned int i; |
1602 | for( i = 0; i < mCells.size(); ++i ) { | 1614 | for( i = 0; i < mCells.size(); ++i ) { |
1603 | mCells[i]->clear(); | 1615 | mCells[i]->clear(); |
1604 | } | 1616 | } |
1605 | for( i = 0; i < mCellsW.size(); ++i ) { | 1617 | for( i = 0; i < mCellsW.size(); ++i ) { |
1606 | mCellsW[i]->clear(); | 1618 | mCellsW[i]->clear(); |
1607 | } | 1619 | } |
1608 | } | 1620 | } |
1609 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1621 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1610 | { | 1622 | { |
1611 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1623 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1612 | 1624 | ||
1613 | QPtrVector<MonthViewCell> *cells; | 1625 | Q3PtrVector<MonthViewCell> *cells; |
1614 | QPtrVector<QLabel> *dayLabels; | 1626 | Q3PtrVector<QLabel> *dayLabels; |
1615 | QPtrVector<KOWeekButton> *weekLabels; | 1627 | Q3PtrVector<KOWeekButton> *weekLabels; |
1616 | uint weekNum = 6; | 1628 | uint weekNum = 6; |
1617 | mStartDate = start; | 1629 | mStartDate = start; |
1618 | if ( mShowWeekView ) { | 1630 | if ( mShowWeekView ) { |
1619 | weekNum = 1; | 1631 | weekNum = 1; |
1620 | cells = &mCellsW; | 1632 | cells = &mCellsW; |
1621 | dayLabels = &mDayLabelsW; | 1633 | dayLabels = &mDayLabelsW; |
1622 | weekLabels = &mWeekLabelsW; | 1634 | weekLabels = &mWeekLabelsW; |
1623 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1635 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1624 | mStartDate = mStartDate.addDays( 1 ); | 1636 | mStartDate = mStartDate.addDays( 1 ); |
1625 | } | 1637 | } |
1626 | } else { | 1638 | } else { |
1627 | cells = &mCells; | 1639 | cells = &mCells; |
1628 | dayLabels = &mDayLabels; | 1640 | dayLabels = &mDayLabels; |
1629 | weekLabels = &mWeekLabels; | 1641 | weekLabels = &mWeekLabels; |
1630 | } | 1642 | } |
1631 | 1643 | ||
1632 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1644 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1633 | 1645 | ||
1634 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1646 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1635 | mWeekStartsMonday = true; | 1647 | mWeekStartsMonday = true; |
1636 | } | 1648 | } |
1637 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1649 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1638 | 1650 | ||
1639 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1651 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
@@ -1647,86 +1659,86 @@ void KOMonthView::showDates(const QDate &start, const QDate &) | |||
1647 | #ifndef KORG_NOPLUGINS | 1659 | #ifndef KORG_NOPLUGINS |
1648 | // add holiday, if present | 1660 | // add holiday, if present |
1649 | QString hstring(KOCore::self()->holiday(date)); | 1661 | QString hstring(KOCore::self()->holiday(date)); |
1650 | (*cells)[i]->setHoliday( hstring ); | 1662 | (*cells)[i]->setHoliday( hstring ); |
1651 | #endif | 1663 | #endif |
1652 | 1664 | ||
1653 | } | 1665 | } |
1654 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1666 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1655 | for( i = 0; i < weekNum; ++i ) { | 1667 | for( i = 0; i < weekNum; ++i ) { |
1656 | int wno; | 1668 | int wno; |
1657 | // remember, according to ISO 8601, the first week of the year is the | 1669 | // remember, according to ISO 8601, the first week of the year is the |
1658 | // first week that contains a thursday. Thus we must subtract off 4, | 1670 | // first week that contains a thursday. Thus we must subtract off 4, |
1659 | // not just 1. | 1671 | // not just 1. |
1660 | int dayOfYear = date.dayOfYear(); | 1672 | int dayOfYear = date.dayOfYear(); |
1661 | if (dayOfYear % 7 != 0) | 1673 | if (dayOfYear % 7 != 0) |
1662 | wno = dayOfYear / 7 + 1; | 1674 | wno = dayOfYear / 7 + 1; |
1663 | else | 1675 | else |
1664 | wno =dayOfYear / 7; | 1676 | wno =dayOfYear / 7; |
1665 | (*weekLabels)[i]->setWeekNum( wno ); | 1677 | (*weekLabels)[i]->setWeekNum( wno ); |
1666 | date = date.addDays( 7 ); | 1678 | date = date.addDays( 7 ); |
1667 | } | 1679 | } |
1668 | updateView(); | 1680 | updateView(); |
1669 | } | 1681 | } |
1670 | 1682 | ||
1671 | void KOMonthView::showEvents(QPtrList<Event>) | 1683 | void KOMonthView::showEvents(Q3PtrList<Event>) |
1672 | { | 1684 | { |
1673 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1685 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1674 | } | 1686 | } |
1675 | 1687 | ||
1676 | void KOMonthView::changeEventDisplay(Event *, int) | 1688 | void KOMonthView::changeEventDisplay(Event *, int) |
1677 | { | 1689 | { |
1678 | // this should be re-written to be much more efficient, but this | 1690 | // this should be re-written to be much more efficient, but this |
1679 | // quick-and-dirty-hack gets the job done for right now. | 1691 | // quick-and-dirty-hack gets the job done for right now. |
1680 | //qDebug("KOMonthView::changeEventDisplay "); | 1692 | //qDebug("KOMonthView::changeEventDisplay "); |
1681 | updateView(); | 1693 | updateView(); |
1682 | } | 1694 | } |
1683 | 1695 | ||
1684 | void KOMonthView::updateView() | 1696 | void KOMonthView::updateView() |
1685 | { | 1697 | { |
1686 | 1698 | ||
1687 | if ( !updatePossible ) | 1699 | if ( !updatePossible ) |
1688 | return; | 1700 | return; |
1689 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1701 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1690 | //QTime ti; | 1702 | //QTime ti; |
1691 | //ti.start(); | 1703 | //ti.start(); |
1692 | clearSelection(); | 1704 | clearSelection(); |
1693 | QPtrVector<MonthViewCell> *cells; | 1705 | Q3PtrVector<MonthViewCell> *cells; |
1694 | if ( mShowWeekView ) { | 1706 | if ( mShowWeekView ) { |
1695 | cells = &mCellsW; | 1707 | cells = &mCellsW; |
1696 | } else { | 1708 | } else { |
1697 | cells = &mCells; | 1709 | cells = &mCells; |
1698 | } | 1710 | } |
1699 | #if 1 | 1711 | #if 1 |
1700 | int i; | 1712 | int i; |
1701 | int timeSpan = (*cells).size()-1; | 1713 | int timeSpan = (*cells).size()-1; |
1702 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1714 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1703 | timeSpan = 6; | 1715 | timeSpan = 6; |
1704 | for( i = 0; i < timeSpan + 1; ++i ) { | 1716 | for( i = 0; i < timeSpan + 1; ++i ) { |
1705 | (*cells)[i]->startUpdateCell(); | 1717 | (*cells)[i]->startUpdateCell(); |
1706 | } | 1718 | } |
1707 | 1719 | ||
1708 | QPtrList<Event> events = calendar()->events(); | 1720 | Q3PtrList<Event> events = calendar()->events(); |
1709 | Event *event; | 1721 | Event *event; |
1710 | QDateTime dt; | 1722 | QDateTime dt; |
1711 | QDate endDate = mStartDate.addDays( timeSpan ); | 1723 | QDate endDate = mStartDate.addDays( timeSpan ); |
1712 | for( event = events.first(); event; event = events.next() ) { // for event | 1724 | for( event = events.first(); event; event = events.next() ) { // for event |
1713 | if ( event->doesRecur() ) { | 1725 | if ( event->doesRecur() ) { |
1714 | bool last; | 1726 | bool last; |
1715 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1727 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1716 | QDateTime incidenceEnd; | 1728 | QDateTime incidenceEnd; |
1717 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1729 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1718 | bool invalid = false; | 1730 | bool invalid = false; |
1719 | while( true ) { | 1731 | while( true ) { |
1720 | if ( incidenceStart.isValid() ) { | 1732 | if ( incidenceStart.isValid() ) { |
1721 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1733 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1722 | int st = incidenceStart.date().daysTo( endDate ); | 1734 | int st = incidenceStart.date().daysTo( endDate ); |
1723 | if ( st >= 0 ) { // start before timeend | 1735 | if ( st >= 0 ) { // start before timeend |
1724 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1736 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1725 | if ( end >= 0 ) { // end after timestart --- got one! | 1737 | if ( end >= 0 ) { // end after timestart --- got one! |
1726 | //normalize | 1738 | //normalize |
1727 | st = timeSpan - st; | 1739 | st = timeSpan - st; |
1728 | if ( st < 0 ) st = 0; | 1740 | if ( st < 0 ) st = 0; |
1729 | if ( end > timeSpan ) end = timeSpan; | 1741 | if ( end > timeSpan ) end = timeSpan; |
1730 | int iii; | 1742 | int iii; |
1731 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1743 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1732 | for ( iii = st;iii<= end;++iii) | 1744 | for ( iii = st;iii<= end;++iii) |
@@ -1748,49 +1760,49 @@ void KOMonthView::updateView() | |||
1748 | break; | 1760 | break; |
1749 | if ( incidenceStart.date() > endDate ) | 1761 | if ( incidenceStart.date() > endDate ) |
1750 | break; | 1762 | break; |
1751 | } | 1763 | } |
1752 | } else { // no recur | 1764 | } else { // no recur |
1753 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1765 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1754 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1766 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1755 | continue; | 1767 | continue; |
1756 | int st = event->dtStart().date().daysTo( endDate ); | 1768 | int st = event->dtStart().date().daysTo( endDate ); |
1757 | if ( st >= 0 ) { // start before timeend | 1769 | if ( st >= 0 ) { // start before timeend |
1758 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1770 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1759 | if ( end >= 0 ) { // end after timestart --- got one! | 1771 | if ( end >= 0 ) { // end after timestart --- got one! |
1760 | //normalize | 1772 | //normalize |
1761 | st = timeSpan - st; | 1773 | st = timeSpan - st; |
1762 | if ( st < 0 ) st = 0; | 1774 | if ( st < 0 ) st = 0; |
1763 | if ( end > timeSpan ) end = timeSpan; | 1775 | if ( end > timeSpan ) end = timeSpan; |
1764 | int iii; | 1776 | int iii; |
1765 | for ( iii = st;iii<= end;++iii) | 1777 | for ( iii = st;iii<= end;++iii) |
1766 | (*cells)[iii]->insertEvent( event ); | 1778 | (*cells)[iii]->insertEvent( event ); |
1767 | } | 1779 | } |
1768 | } | 1780 | } |
1769 | } | 1781 | } |
1770 | } | 1782 | } |
1771 | // insert due todos | 1783 | // insert due todos |
1772 | QPtrList<Todo> todos = calendar()->todos( ); | 1784 | Q3PtrList<Todo> todos = calendar()->todos( ); |
1773 | Todo *todo; | 1785 | Todo *todo; |
1774 | for(todo = todos.first(); todo; todo = todos.next()) { | 1786 | for(todo = todos.first(); todo; todo = todos.next()) { |
1775 | //insertTodo( todo ); | 1787 | //insertTodo( todo ); |
1776 | if ( todo->hasDueDate() ) { | 1788 | if ( todo->hasDueDate() ) { |
1777 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1789 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1778 | if ( day >= 0 && day < timeSpan + 1) { | 1790 | if ( day >= 0 && day < timeSpan + 1) { |
1779 | (*cells)[day]->insertTodo( todo ); | 1791 | (*cells)[day]->insertTodo( todo ); |
1780 | } | 1792 | } |
1781 | } | 1793 | } |
1782 | } | 1794 | } |
1783 | 1795 | ||
1784 | for( i = 0; i < timeSpan+1; ++i ) { | 1796 | for( i = 0; i < timeSpan+1; ++i ) { |
1785 | (*cells)[i]->finishUpdateCell(); | 1797 | (*cells)[i]->finishUpdateCell(); |
1786 | } | 1798 | } |
1787 | processSelectionChange(); | 1799 | processSelectionChange(); |
1788 | //qApp->processEvents(); | 1800 | //qApp->processEvents(); |
1789 | for( i = 0; i < timeSpan+1; ++i ) { | 1801 | for( i = 0; i < timeSpan+1; ++i ) { |
1790 | //(*cells)[i]->repaintfinishUpdateCell(); | 1802 | //(*cells)[i]->repaintfinishUpdateCell(); |
1791 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); | 1803 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); |
1792 | } | 1804 | } |
1793 | setKeyBFocus(); | 1805 | setKeyBFocus(); |
1794 | #else | 1806 | #else |
1795 | // old code | 1807 | // old code |
1796 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1808 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
@@ -2204,115 +2216,115 @@ void KOMonthView::showContextMenu( Incidence *incidence ) | |||
2204 | } | 2216 | } |
2205 | MonthViewCell * KOMonthView::selectedCell( ) | 2217 | MonthViewCell * KOMonthView::selectedCell( ) |
2206 | { | 2218 | { |
2207 | return mSelectedCell; | 2219 | return mSelectedCell; |
2208 | } | 2220 | } |
2209 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 2221 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
2210 | { | 2222 | { |
2211 | //qDebug("KOMonthView::setSelectedCell %d", cell); | 2223 | //qDebug("KOMonthView::setSelectedCell %d", cell); |
2212 | if ( mSelectedCell && mSelectedCell != cell ) { | 2224 | if ( mSelectedCell && mSelectedCell != cell ) { |
2213 | MonthViewCell * mvc = mSelectedCell; | 2225 | MonthViewCell * mvc = mSelectedCell; |
2214 | mSelectedCell = cell; | 2226 | mSelectedCell = cell; |
2215 | mvc->deselect(); | 2227 | mvc->deselect(); |
2216 | } else | 2228 | } else |
2217 | mSelectedCell = cell; | 2229 | mSelectedCell = cell; |
2218 | // if ( mSelectedCell ) | 2230 | // if ( mSelectedCell ) |
2219 | // mSelectedCell->select(); | 2231 | // mSelectedCell->select(); |
2220 | if ( !mSelectedCell ) | 2232 | if ( !mSelectedCell ) |
2221 | emit incidenceSelected( 0 ); | 2233 | emit incidenceSelected( 0 ); |
2222 | else | 2234 | else |
2223 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 2235 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
2224 | } | 2236 | } |
2225 | 2237 | ||
2226 | void KOMonthView::processSelectionChange() | 2238 | void KOMonthView::processSelectionChange() |
2227 | { | 2239 | { |
2228 | QPtrList<Incidence> incidences = selectedIncidences(); | 2240 | Q3PtrList<Incidence> incidences = selectedIncidences(); |
2229 | if (incidences.count() > 0) { | 2241 | if (incidences.count() > 0) { |
2230 | emit incidenceSelected( incidences.first() ); | 2242 | emit incidenceSelected( incidences.first() ); |
2231 | } else { | 2243 | } else { |
2232 | emit incidenceSelected( 0 ); | 2244 | emit incidenceSelected( 0 ); |
2233 | clearSelection(); | 2245 | clearSelection(); |
2234 | } | 2246 | } |
2235 | } | 2247 | } |
2236 | 2248 | ||
2237 | void KOMonthView::clearSelection() | 2249 | void KOMonthView::clearSelection() |
2238 | { | 2250 | { |
2239 | if ( mSelectedCell ) { | 2251 | if ( mSelectedCell ) { |
2240 | mSelectedCell->deselect(); | 2252 | mSelectedCell->deselect(); |
2241 | mSelectedCell = 0; | 2253 | mSelectedCell = 0; |
2242 | } | 2254 | } |
2243 | } | 2255 | } |
2244 | 2256 | ||
2245 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 2257 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
2246 | { | 2258 | { |
2247 | if ( !e->isAutoRepeat() ) { | 2259 | if ( !e->isAutoRepeat() ) { |
2248 | mFlagKeyPressed = false; | 2260 | mFlagKeyPressed = false; |
2249 | } | 2261 | } |
2250 | } | 2262 | } |
2251 | 2263 | ||
2252 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 2264 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
2253 | { | 2265 | { |
2254 | 2266 | ||
2255 | qApp->processEvents(); | 2267 | qApp->processEvents(); |
2256 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2268 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2257 | //e->ignore(); | 2269 | //e->ignore(); |
2258 | e->accept(); | 2270 | e->accept(); |
2259 | return; | 2271 | return; |
2260 | } | 2272 | } |
2261 | if (! e->isAutoRepeat() ) | 2273 | if (! e->isAutoRepeat() ) |
2262 | mFlagKeyPressed = true; | 2274 | mFlagKeyPressed = true; |
2263 | switch(e->key()) { | 2275 | switch(e->key()) { |
2264 | case Key_Up: | 2276 | case Qt::Key_Up: |
2265 | { | 2277 | { |
2266 | if ( mShowWeekView ) { | 2278 | if ( mShowWeekView ) { |
2267 | emit selectWeekNum ( currentWeek() - 1 ); | 2279 | emit selectWeekNum ( currentWeek() - 1 ); |
2268 | } | 2280 | } |
2269 | else { | 2281 | else { |
2270 | emit prevMonth(); | 2282 | emit prevMonth(); |
2271 | } | 2283 | } |
2272 | } | 2284 | } |
2273 | e->accept(); | 2285 | e->accept(); |
2274 | break; | 2286 | break; |
2275 | case Key_Down: | 2287 | case Qt::Key_Down: |
2276 | { | 2288 | { |
2277 | if ( mShowWeekView ) { | 2289 | if ( mShowWeekView ) { |
2278 | emit selectWeekNum ( currentWeek() +1); | 2290 | emit selectWeekNum ( currentWeek() +1); |
2279 | } | 2291 | } |
2280 | else { | 2292 | else { |
2281 | emit nextMonth(); | 2293 | emit nextMonth(); |
2282 | } | 2294 | } |
2283 | 2295 | ||
2284 | } | 2296 | } |
2285 | e->accept(); | 2297 | e->accept(); |
2286 | break; | 2298 | break; |
2287 | case Key_Return: | 2299 | case Qt::Key_Return: |
2288 | case Key_Enter: | 2300 | case Qt::Key_Enter: |
2289 | { | 2301 | { |
2290 | selectInternalWeekNum ( currentWeek() ); | 2302 | selectInternalWeekNum ( currentWeek() ); |
2291 | } | 2303 | } |
2292 | e->accept(); | 2304 | e->accept(); |
2293 | break; | 2305 | break; |
2294 | case Key_D: | 2306 | case Qt::Key_D: |
2295 | if ( mSelectedCell ) { | 2307 | if ( mSelectedCell ) { |
2296 | mSelectedCell->showDay(); | 2308 | mSelectedCell->showDay(); |
2297 | e->accept(); | 2309 | e->accept(); |
2298 | } else { | 2310 | } else { |
2299 | e->ignore(); | 2311 | e->ignore(); |
2300 | } | 2312 | } |
2301 | break; | 2313 | break; |
2302 | default: | 2314 | default: |
2303 | e->ignore(); | 2315 | e->ignore(); |
2304 | break; | 2316 | break; |
2305 | } | 2317 | } |
2306 | } | 2318 | } |
2307 | 2319 | ||
2308 | void KOMonthView::nextCell() | 2320 | void KOMonthView::nextCell() |
2309 | { | 2321 | { |
2310 | focusNextPrevChild ( true ); | 2322 | focusNextPrevChild ( true ); |
2311 | } | 2323 | } |
2312 | void KOMonthView::prevCell() | 2324 | void KOMonthView::prevCell() |
2313 | { | 2325 | { |
2314 | focusNextPrevChild ( false ); | 2326 | focusNextPrevChild ( false ); |
2315 | } | 2327 | } |
2316 | 2328 | ||
2317 | void KOMonthView::slotNewTodo() | 2329 | void KOMonthView::slotNewTodo() |
2318 | { | 2330 | { |