author | zautrix <zautrix> | 2005-07-09 14:48:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-09 14:48:54 (UTC) |
commit | 875884b2517f9b82153a14852c0f1676f985494f (patch) (unidiff) | |
tree | 89e1c773a2fdae7a4f2e2fb9ba9d4c59e921d60f | |
parent | fa7a30172aa502aaa9e81868e5960efba76cbb0d (diff) | |
download | kdepimpi-875884b2517f9b82153a14852c0f1676f985494f.zip kdepimpi-875884b2517f9b82153a14852c0f1676f985494f.tar.gz kdepimpi-875884b2517f9b82153a14852c0f1676f985494f.tar.bz2 |
layout fixes
-rw-r--r-- | korganizer/komonthview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index b5a59af..498d9b0 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,2324 +1,2324 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | resetOnFocusIn = true; | 86 | resetOnFocusIn = true; |
87 | setVScrollBarMode(QScrollView::AlwaysOff); | 87 | setVScrollBarMode(QScrollView::AlwaysOff); |
88 | setHScrollBarMode(QScrollView::AlwaysOff); | 88 | setHScrollBarMode(QScrollView::AlwaysOff); |
89 | } | 89 | } |
90 | KNoScrollListBox::~KNoScrollListBox() | 90 | KNoScrollListBox::~KNoScrollListBox() |
91 | { | 91 | { |
92 | #if QT_VERSION >= 0x030000 | 92 | #if QT_VERSION >= 0x030000 |
93 | 93 | ||
94 | #else | 94 | #else |
95 | delete mWT; | 95 | delete mWT; |
96 | #endif | 96 | #endif |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
101 | { | 101 | { |
102 | QListBox::focusInEvent ( e ); | 102 | QListBox::focusInEvent ( e ); |
103 | if ( count() ){ | 103 | if ( count() ){ |
104 | int ci = currentItem(); | 104 | int ci = currentItem(); |
105 | if ( ci < 0 ) ci = 0; | 105 | if ( ci < 0 ) ci = 0; |
106 | 106 | ||
107 | setCurrentItem( ci ); | 107 | setCurrentItem( ci ); |
108 | setSelected ( ci, true ); | 108 | setSelected ( ci, true ); |
109 | emit highlighted( item ( ci ) ); | 109 | emit highlighted( item ( ci ) ); |
110 | 110 | ||
111 | resetOnFocusIn = true; | 111 | resetOnFocusIn = true; |
112 | 112 | ||
113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
114 | QListBoxItem *fi = firstItem (); | 114 | QListBoxItem *fi = firstItem (); |
115 | if (fi ) { | 115 | if (fi ) { |
116 | int ihei = fi->height( this ); | 116 | int ihei = fi->height( this ); |
117 | int hei = numRows () * ihei; | 117 | int hei = numRows () * ihei; |
118 | if ( hei < height() - horizontalScrollBar()->height () ) { | 118 | if ( hei < height() - horizontalScrollBar()->height () ) { |
119 | setVScrollBarMode(QScrollView::AlwaysOff); | 119 | setVScrollBarMode(QScrollView::AlwaysOff); |
120 | } | 120 | } |
121 | else | 121 | else |
122 | setVScrollBarMode(QScrollView::Auto); | 122 | setVScrollBarMode(QScrollView::Auto); |
123 | if ( ihei *3 > height() ) { | 123 | if ( ihei *3 > height() ) { |
124 | setHScrollBarMode(QScrollView::AlwaysOff); | 124 | setHScrollBarMode(QScrollView::AlwaysOff); |
125 | } | 125 | } |
126 | else { | 126 | else { |
127 | setHScrollBarMode(QScrollView::Auto); | 127 | setHScrollBarMode(QScrollView::Auto); |
128 | } | 128 | } |
129 | } else { | 129 | } else { |
130 | setVScrollBarMode(QScrollView::Auto); | 130 | setVScrollBarMode(QScrollView::Auto); |
131 | setHScrollBarMode(QScrollView::Auto); | 131 | setHScrollBarMode(QScrollView::Auto); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
137 | { | 137 | { |
138 | int i = currentItem (); | 138 | int i = currentItem (); |
139 | if ( i >= 0 ) { | 139 | if ( i >= 0 ) { |
140 | setSelected ( i, false ); | 140 | setSelected ( i, false ); |
141 | } | 141 | } |
142 | QListBox::focusOutEvent ( e ); | 142 | QListBox::focusOutEvent ( e ); |
143 | setVScrollBarMode(QScrollView::AlwaysOff); | 143 | setVScrollBarMode(QScrollView::AlwaysOff); |
144 | setHScrollBarMode(QScrollView::AlwaysOff); | 144 | setHScrollBarMode(QScrollView::AlwaysOff); |
145 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); | 145 | emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); |
146 | } | 146 | } |
147 | 147 | ||
148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 148 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
149 | { | 149 | { |
150 | QListBoxItem* item = itemAt ( p ); | 150 | QListBoxItem* item = itemAt ( p ); |
151 | if ( ! item ) { | 151 | if ( ! item ) { |
152 | return i18n("Click in the cell\nto add an event!"); | 152 | return i18n("Click in the cell\nto add an event!"); |
153 | } | 153 | } |
154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 154 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
155 | KOPrefs::instance()->mWTshowDetails, | 155 | KOPrefs::instance()->mWTshowDetails, |
156 | KOPrefs::instance()->mWTshowCreated, | 156 | KOPrefs::instance()->mWTshowCreated, |
157 | KOPrefs::instance()->mWTshowChanged); | 157 | KOPrefs::instance()->mWTshowChanged); |
158 | } | 158 | } |
159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 159 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
160 | { | 160 | { |
161 | //qDebug("KNoScrollListBox::keyPressEvent "); | 161 | //qDebug("KNoScrollListBox::keyPressEvent "); |
162 | switch(e->key()) { | 162 | switch(e->key()) { |
163 | case Key_Right: | 163 | case Key_Right: |
164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 164 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
165 | { | 165 | { |
166 | e->ignore(); | 166 | e->ignore(); |
167 | return; | 167 | return; |
168 | } | 168 | } |
169 | scrollBy(10,0); | 169 | scrollBy(10,0); |
170 | break; | 170 | break; |
171 | case Key_Left: | 171 | case Key_Left: |
172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 172 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
173 | { | 173 | { |
174 | e->ignore(); | 174 | e->ignore(); |
175 | return; | 175 | return; |
176 | } | 176 | } |
177 | scrollBy(-10,0); | 177 | scrollBy(-10,0); |
178 | break; | 178 | break; |
179 | case Key_Up: | 179 | case Key_Up: |
180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 180 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
181 | e->ignore(); | 181 | e->ignore(); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | if ( count() ) { | 184 | if ( count() ) { |
185 | if ( currentItem() == 0 ) { | 185 | if ( currentItem() == 0 ) { |
186 | emit prevCell(); | 186 | emit prevCell(); |
187 | } else { | 187 | } else { |
188 | setCurrentItem((currentItem()+count()-1)%count()); | 188 | setCurrentItem((currentItem()+count()-1)%count()); |
189 | if(!itemVisible(currentItem())) { | 189 | if(!itemVisible(currentItem())) { |
190 | if((unsigned int) currentItem() == (count()-1)) { | 190 | if((unsigned int) currentItem() == (count()-1)) { |
191 | setTopItem(currentItem()-numItemsVisible()+1); | 191 | setTopItem(currentItem()-numItemsVisible()+1); |
192 | } else { | 192 | } else { |
193 | setTopItem(topItem()-1); | 193 | setTopItem(topItem()-1); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
197 | } | 197 | } |
198 | break; | 198 | break; |
199 | case Key_Down: | 199 | case Key_Down: |
200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 200 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
201 | e->ignore(); | 201 | e->ignore(); |
202 | break; | 202 | break; |
203 | } | 203 | } |
204 | if ( count () ) { | 204 | if ( count () ) { |
205 | if ( ((uint)currentItem()+1) == count () ) { | 205 | if ( ((uint)currentItem()+1) == count () ) { |
206 | emit nextCell(); | 206 | emit nextCell(); |
207 | } else { | 207 | } else { |
208 | setCurrentItem((currentItem()+1)%count()); | 208 | setCurrentItem((currentItem()+1)%count()); |
209 | if(!itemVisible(currentItem())) { | 209 | if(!itemVisible(currentItem())) { |
210 | if(currentItem() == 0) { | 210 | if(currentItem() == 0) { |
211 | setTopItem(0); | 211 | setTopItem(0); |
212 | } else { | 212 | } else { |
213 | setTopItem(topItem()+1); | 213 | setTopItem(topItem()+1); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | } | 217 | } |
218 | break; | 218 | break; |
219 | case Key_I: | 219 | case Key_I: |
220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 220 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
221 | e->ignore(); | 221 | e->ignore(); |
222 | break; | 222 | break; |
223 | case Key_Return: | 223 | case Key_Return: |
224 | case Key_Enter: | 224 | case Key_Enter: |
225 | { | 225 | { |
226 | if ( currentItem() >= 0 ) { | 226 | if ( currentItem() >= 0 ) { |
227 | emit doubleClicked( item( currentItem() ) ); | 227 | emit doubleClicked( item( currentItem() ) ); |
228 | e->accept(); | 228 | e->accept(); |
229 | } else { | 229 | } else { |
230 | e->ignore(); | 230 | e->ignore(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | case Key_Shift: | 234 | case Key_Shift: |
235 | emit shiftDown(); | 235 | emit shiftDown(); |
236 | break; | 236 | break; |
237 | default: | 237 | default: |
238 | e->ignore(); | 238 | e->ignore(); |
239 | break; | 239 | break; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | void KNoScrollListBox::oneDown() | 243 | void KNoScrollListBox::oneDown() |
244 | { | 244 | { |
245 | if ( count () ) { | 245 | if ( count () ) { |
246 | if ( ((uint)currentItem()+1) == count () ) { | 246 | if ( ((uint)currentItem()+1) == count () ) { |
247 | emit nextCell(); | 247 | emit nextCell(); |
248 | } else { | 248 | } else { |
249 | resetOnFocusIn = false; | 249 | resetOnFocusIn = false; |
250 | setCurrentItem((currentItem()+1)%count()); | 250 | setCurrentItem((currentItem()+1)%count()); |
251 | if(!itemVisible(currentItem())) { | 251 | if(!itemVisible(currentItem())) { |
252 | if(currentItem() == 0) { | 252 | if(currentItem() == 0) { |
253 | setTopItem(0); | 253 | setTopItem(0); |
254 | } else { | 254 | } else { |
255 | setTopItem(topItem()+1); | 255 | setTopItem(topItem()+1); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | } | 260 | } |
261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 261 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
262 | { | 262 | { |
263 | switch(e->key()) { | 263 | switch(e->key()) { |
264 | case Key_Shift: | 264 | case Key_Shift: |
265 | emit shiftUp(); | 265 | emit shiftUp(); |
266 | break; | 266 | break; |
267 | default: | 267 | default: |
268 | break; | 268 | break; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 272 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
273 | { | 273 | { |
274 | QListBox::mousePressEvent(e); | 274 | QListBox::mousePressEvent(e); |
275 | 275 | ||
276 | if(e->button() == RightButton) { | 276 | if(e->button() == RightButton) { |
277 | emit rightClick(); | 277 | emit rightClick(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) | 281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) |
282 | : QListBoxItem() | 282 | : QListBoxItem() |
283 | { | 283 | { |
284 | mblockRepaint = true; | 284 | mblockRepaint = true; |
285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
286 | recycle( incidence, s ); | 286 | recycle( incidence, s ); |
287 | } | 287 | } |
288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) | 288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) |
289 | { | 289 | { |
290 | mDisplayHighlighted = false; | 290 | mDisplayHighlighted = false; |
291 | setText( s ); | 291 | setText( s ); |
292 | mMultiday = 0; | 292 | mMultiday = 0; |
293 | mIncidence = incidence; | 293 | mIncidence = incidence; |
294 | mRecur = false; | 294 | mRecur = false; |
295 | mAlarm = false; | 295 | mAlarm = false; |
296 | mReply = false; | 296 | mReply = false; |
297 | mInfo = false; | 297 | mInfo = false; |
298 | mdayPos = 0; | 298 | mdayPos = 0; |
299 | } | 299 | } |
300 | 300 | ||
301 | bool MonthViewItem::setHighlightedFalse() | 301 | bool MonthViewItem::setHighlightedFalse() |
302 | { | 302 | { |
303 | if ( !mDisplayHighlighted ) | 303 | if ( !mDisplayHighlighted ) |
304 | return false; | 304 | return false; |
305 | mDisplayHighlighted = false; | 305 | mDisplayHighlighted = false; |
306 | return true; | 306 | return true; |
307 | } | 307 | } |
308 | 308 | ||
309 | bool MonthViewItem::setHighlighted( Incidence * inc ) | 309 | bool MonthViewItem::setHighlighted( Incidence * inc ) |
310 | { | 310 | { |
311 | if ( inc == mIncidence ) { | 311 | if ( inc == mIncidence ) { |
312 | if ( mDisplayHighlighted ) | 312 | if ( mDisplayHighlighted ) |
313 | return false; | 313 | return false; |
314 | mDisplayHighlighted = true; | 314 | mDisplayHighlighted = true; |
315 | return true; | 315 | return true; |
316 | } else { | 316 | } else { |
317 | if ( !mDisplayHighlighted ) | 317 | if ( !mDisplayHighlighted ) |
318 | return false; | 318 | return false; |
319 | mDisplayHighlighted = false; | 319 | mDisplayHighlighted = false; |
320 | return true; | 320 | return true; |
321 | } | 321 | } |
322 | return false; | 322 | return false; |
323 | } | 323 | } |
324 | void MonthViewItem::paint(QPainter *p) | 324 | void MonthViewItem::paint(QPainter *p) |
325 | { | 325 | { |
326 | if ( mblockRepaint || !mIncidence ) { | 326 | if ( mblockRepaint || !mIncidence ) { |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | #if QT_VERSION >= 0x030000 | 329 | #if QT_VERSION >= 0x030000 |
330 | bool sel = isSelected(); | 330 | bool sel = isSelected(); |
331 | #else | 331 | #else |
332 | bool sel = selected(); | 332 | bool sel = selected(); |
333 | #endif | 333 | #endif |
334 | int heihei = height( listBox () ); | 334 | int heihei = height( listBox () ); |
335 | int x = 1; | 335 | int x = 1; |
336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) | 336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) |
337 | { | 337 | { |
338 | 338 | ||
339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 339 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
340 | sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); | 340 | sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); |
341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); | 341 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); |
342 | } | 342 | } |
343 | 343 | ||
344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
345 | int size = PIXMAP_SIZE; | 345 | int size = PIXMAP_SIZE; |
346 | if ( QApplication::desktop()->width() < 300 ) | 346 | if ( QApplication::desktop()->width() < 300 ) |
347 | size = 3; | 347 | size = 3; |
348 | int y = (heihei - size -1 ) /2; | 348 | int y = (heihei - size -1 ) /2; |
349 | 349 | ||
350 | if ( mIncidence->calID() > 1 ) { | 350 | if ( mIncidence->calID() > 1 ) { |
351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
352 | p->drawRect ( x, y-2,size,size+4); | 352 | p->drawRect ( x, y-2,size,size+4); |
353 | x += size + 1; | 353 | x += size + 1; |
354 | } | 354 | } |
355 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 355 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
356 | if ( mInfo ) { | 356 | if ( mInfo ) { |
357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
358 | x += size + 1; | 358 | x += size + 1; |
359 | } | 359 | } |
360 | if ( mRecur ) { | 360 | if ( mRecur ) { |
361 | p->fillRect ( x, y,size,size, Qt::blue ); | 361 | p->fillRect ( x, y,size,size, Qt::blue ); |
362 | x += size + 1; | 362 | x += size + 1; |
363 | } | 363 | } |
364 | if ( mAlarm ) { | 364 | if ( mAlarm ) { |
365 | p->fillRect ( x, y,size,size, Qt::red ); | 365 | p->fillRect ( x, y,size,size, Qt::red ); |
366 | x += size + 1; | 366 | x += size + 1; |
367 | } | 367 | } |
368 | if ( mReply ) { | 368 | if ( mReply ) { |
369 | p->fillRect ( x, y,size,size, Qt::yellow ); | 369 | p->fillRect ( x, y,size,size, Qt::yellow ); |
370 | x += size + 1; | 370 | x += size + 1; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | 375 | ||
376 | 376 | ||
377 | if ( sel ) p->setPen( Qt::white ); | 377 | if ( sel ) p->setPen( Qt::white ); |
378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); | 378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); |
379 | 379 | ||
380 | #if 0 | 380 | #if 0 |
381 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 381 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
383 | #endif | 383 | #endif |
384 | QColor textColor = p->pen().color(); | 384 | QColor textColor = p->pen().color(); |
385 | 385 | ||
386 | 386 | ||
387 | if ( mMultiday ) { | 387 | if ( mMultiday ) { |
388 | int yyy = y+(size/2); | 388 | int yyy = y+(size/2); |
389 | int sizeM = size+2; | 389 | int sizeM = size+2; |
390 | p->setBrush( QBrush( textColor ) ); | 390 | p->setBrush( QBrush( textColor ) ); |
391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
392 | if ( mMultiday == 2 || mMultiday == 3 ) { | 392 | if ( mMultiday == 2 || mMultiday == 3 ) { |
393 | QPointArray pa ( 3 ); | 393 | QPointArray pa ( 3 ); |
394 | pa.setPoint (0, x, yyy ); | 394 | pa.setPoint (0, x, yyy ); |
395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
397 | p->drawPolygon( pa ); | 397 | p->drawPolygon( pa ); |
398 | } | 398 | } |
399 | if ( mMultiday == 2 || mMultiday == 1 ) { | 399 | if ( mMultiday == 2 || mMultiday == 1 ) { |
400 | QPointArray pa ( 3 ); | 400 | QPointArray pa ( 3 ); |
401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
404 | p->drawPolygon( pa ); | 404 | p->drawPolygon( pa ); |
405 | } | 405 | } |
406 | if ( mMultiday == 1 ) { | 406 | if ( mMultiday == 1 ) { |
407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
409 | } | 409 | } |
410 | if ( mMultiday == 3 ) { | 410 | if ( mMultiday == 3 ) { |
411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
413 | 413 | ||
414 | } | 414 | } |
415 | x += sizeM/2 + 1; | 415 | x += sizeM/2 + 1; |
416 | x += sizeM + 1; | 416 | x += sizeM + 1; |
417 | } | 417 | } |
418 | 418 | ||
419 | if ( mIncidence->typeID() == todoID ){ | 419 | if ( mIncidence->typeID() == todoID ){ |
420 | Todo* td = ( Todo* ) mIncidence; | 420 | Todo* td = ( Todo* ) mIncidence; |
421 | if ( td->isCompleted() ) { | 421 | if ( td->isCompleted() ) { |
422 | int half = size/2; | 422 | int half = size/2; |
423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
425 | x += half+half + 4; | 425 | x += half+half + 4; |
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | int val = td->percentComplete()/20; | 428 | int val = td->percentComplete()/20; |
429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); | 429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); |
430 | p->drawRect ( x, y-2,7,size+4); | 430 | p->drawRect ( x, y-2,7,size+4); |
431 | x += size + 3; | 431 | x += size + 3; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | QFontMetrics fm = p->fontMetrics(); | 434 | QFontMetrics fm = p->fontMetrics(); |
435 | int yPos; | 435 | int yPos; |
436 | int pmheight = size; | 436 | int pmheight = size; |
437 | if( pmheight < fm.height() ) | 437 | if( pmheight < fm.height() ) |
438 | yPos = fm.ascent() + fm.leading()/2; | 438 | yPos = fm.ascent() + fm.leading()/2; |
439 | else | 439 | else |
440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
441 | 441 | ||
442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
443 | p->drawText( x, yPos, text() ); | 443 | p->drawText( x, yPos, text() ); |
444 | if ( mIncidence->cancelled() ) { | 444 | if ( mIncidence->cancelled() ) { |
445 | int wid = fm.width( text() ); | 445 | int wid = fm.width( text() ); |
446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
447 | } | 447 | } |
448 | } else { | 448 | } else { |
449 | QString pText = text(); | 449 | QString pText = text(); |
450 | if( pText.mid(2,1) == ":" ) | 450 | if( pText.mid(2,1) == ":" ) |
451 | pText = pText.mid( 6 ); | 451 | pText = pText.mid( 6 ); |
452 | p->drawText( x, yPos, pText ); | 452 | p->drawText( x, yPos, pText ); |
453 | if ( mIncidence->cancelled() ) { | 453 | if ( mIncidence->cancelled() ) { |
454 | int wid = fm.width( pText ); | 454 | int wid = fm.width( pText ); |
455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | int MonthViewItem::height(const QListBox *lb) const | 460 | int MonthViewItem::height(const QListBox *lb) const |
461 | { | 461 | { |
462 | int ret = 10; | 462 | int ret = 10; |
463 | if ( lb ) | 463 | if ( lb ) |
464 | ret = lb->fontMetrics().lineSpacing()+1; | 464 | ret = lb->fontMetrics().lineSpacing()+1; |
465 | return ret; | 465 | return ret; |
466 | } | 466 | } |
467 | 467 | ||
468 | int MonthViewItem::width(const QListBox *lb) const | 468 | int MonthViewItem::width(const QListBox *lb) const |
469 | { | 469 | { |
470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
471 | int size = PIXMAP_SIZE; | 471 | int size = PIXMAP_SIZE; |
472 | if ( QApplication::desktop()->width() < 300 ) | 472 | if ( QApplication::desktop()->width() < 300 ) |
473 | size = 3; | 473 | size = 3; |
474 | int x = 1; | 474 | int x = 1; |
475 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 475 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
476 | if ( mInfo ) { | 476 | if ( mInfo ) { |
477 | x += size + 1; | 477 | x += size + 1; |
478 | } | 478 | } |
479 | if( mRecur ) { | 479 | if( mRecur ) { |
480 | x += size+1; | 480 | x += size+1; |
481 | } | 481 | } |
482 | if( mAlarm ) { | 482 | if( mAlarm ) { |
483 | x += size+1; | 483 | x += size+1; |
484 | } | 484 | } |
485 | if( mReply ) { | 485 | if( mReply ) { |
486 | x += size+1; | 486 | x += size+1; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | if( mMultiday ) { | 489 | if( mMultiday ) { |
490 | x += size+1+2+size/2; | 490 | x += size+1+2+size/2; |
491 | } | 491 | } |
492 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 492 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
493 | } | 493 | } |
494 | if ( ! lb ) | 494 | if ( ! lb ) |
495 | return 10; | 495 | return 10; |
496 | return lb->width(); | 496 | return lb->width(); |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
501 | : KNoScrollListBox( par ), | 501 | : KNoScrollListBox( par ), |
502 | mMonthView( parent ) | 502 | mMonthView( parent ) |
503 | { | 503 | { |
504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
505 | currentPalette = 0; | 505 | currentPalette = 0; |
506 | // mLabel = new QLabel( this );QPushButton | 506 | // mLabel = new QLabel( this );QPushButton |
507 | mLabel = new QPushButton( this ); | 507 | mLabel = new QPushButton( this ); |
508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
509 | //mLabel->setLineWidth( 1 ); | 509 | //mLabel->setLineWidth( 1 ); |
510 | //mLabel->setAlignment( AlignCenter ); | 510 | //mLabel->setAlignment( AlignCenter ); |
511 | mLabel->setFlat( true ); | 511 | mLabel->setFlat( true ); |
512 | mLabel->setFocusPolicy(NoFocus); | 512 | mLabel->setFocusPolicy(NoFocus); |
513 | //mItemList = new KNoScrollListBox( this ); | 513 | //mItemList = new KNoScrollListBox( this ); |
514 | setMinimumSize( 10, 10 ); | 514 | setMinimumSize( 10, 10 ); |
515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
516 | setLineWidth( 1 ); | 516 | setLineWidth( 1 ); |
517 | //topLayout->addWidget( mItemList ); | 517 | //topLayout->addWidget( mItemList ); |
518 | mLabel->raise(); | 518 | mLabel->raise(); |
519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
520 | mStandardPalette = palette(); | 520 | mStandardPalette = palette(); |
521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
522 | 522 | ||
523 | enableScrollBars( false ); | 523 | enableScrollBars( false ); |
524 | updateConfig(); | 524 | updateConfig(); |
525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
528 | SLOT( defaultAction( QListBoxItem * ) ) ); | 528 | SLOT( defaultAction( QListBoxItem * ) ) ); |
529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
530 | const QPoint &) ), | 530 | const QPoint &) ), |
531 | SLOT( contextMenu( QListBoxItem * ) ) ); | 531 | SLOT( contextMenu( QListBoxItem * ) ) ); |
532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
533 | SLOT( selection( QListBoxItem * ) ) ); | 533 | SLOT( selection( QListBoxItem * ) ) ); |
534 | 534 | ||
535 | /* | 535 | /* |
536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
537 | SLOT( selection( QListBoxItem * ) ) ); | 537 | SLOT( selection( QListBoxItem * ) ) ); |
538 | */ | 538 | */ |
539 | } | 539 | } |
540 | #ifdef DESKTOP_VERSION | 540 | #ifdef DESKTOP_VERSION |
541 | QToolTipGroup *MonthViewCell::toolTipGroup() | 541 | QToolTipGroup *MonthViewCell::toolTipGroup() |
542 | { | 542 | { |
543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
544 | return mToolTipGroup; | 544 | return mToolTipGroup; |
545 | } | 545 | } |
546 | #endif | 546 | #endif |
547 | 547 | ||
548 | void MonthViewCell::setDate( const QDate &date ) | 548 | void MonthViewCell::setDate( const QDate &date ) |
549 | { | 549 | { |
550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
551 | mDate = date; | 551 | mDate = date; |
552 | 552 | ||
553 | 553 | ||
554 | 554 | ||
555 | //resizeEvent( 0 ); | 555 | //resizeEvent( 0 ); |
556 | } | 556 | } |
557 | 557 | ||
558 | QDate MonthViewCell::date() const | 558 | QDate MonthViewCell::date() const |
559 | { | 559 | { |
560 | return mDate; | 560 | return mDate; |
561 | } | 561 | } |
562 | 562 | ||
563 | void MonthViewCell::setPrimary( bool primary ) | 563 | void MonthViewCell::setPrimary( bool primary ) |
564 | { | 564 | { |
565 | mPrimary = primary; | 565 | mPrimary = primary; |
566 | //setMyPalette(); | 566 | //setMyPalette(); |
567 | } | 567 | } |
568 | void MonthViewCell::setMyPalette() | 568 | void MonthViewCell::setMyPalette() |
569 | { | 569 | { |
570 | 570 | ||
571 | if ( mHoliday) { | 571 | if ( mHoliday) { |
572 | if ( currentPalette == 1 ) return; | 572 | if ( currentPalette == 1 ) return; |
573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
574 | setPalette( mHolidayPalette ); | 574 | setPalette( mHolidayPalette ); |
575 | //mLabel->setPalette( mHolidayPalette ); | 575 | //mLabel->setPalette( mHolidayPalette ); |
576 | currentPalette = 1; | 576 | currentPalette = 1; |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | if ( mPrimary ) { | 579 | if ( mPrimary ) { |
580 | if ( currentPalette == 2 ) return; | 580 | if ( currentPalette == 2 ) return; |
581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
582 | //mLabel->setPalette( mPrimaryPalette ); | 582 | //mLabel->setPalette( mPrimaryPalette ); |
583 | setPalette( mPrimaryPalette ); | 583 | setPalette( mPrimaryPalette ); |
584 | currentPalette = 2; | 584 | currentPalette = 2; |
585 | 585 | ||
586 | } else { | 586 | } else { |
587 | if ( currentPalette == 3 ) return; | 587 | if ( currentPalette == 3 ) return; |
588 | setPalette( mNonPrimaryPalette ); | 588 | setPalette( mNonPrimaryPalette ); |
589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
590 | //mLabel->setPalette( mNonPrimaryPalette );; | 590 | //mLabel->setPalette( mNonPrimaryPalette );; |
591 | currentPalette = 3; | 591 | currentPalette = 3; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | //QPalette pal = palette(); | 594 | //QPalette pal = palette(); |
595 | 595 | ||
596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
597 | } | 597 | } |
598 | QPalette MonthViewCell::getPalette () | 598 | QPalette MonthViewCell::getPalette () |
599 | { | 599 | { |
600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
601 | return mStandardPalette; | 601 | return mStandardPalette; |
602 | if ( mHoliday) { | 602 | if ( mHoliday) { |
603 | return mHolidayPalette ; | 603 | return mHolidayPalette ; |
604 | } else { | 604 | } else { |
605 | if ( mPrimary ) { | 605 | if ( mPrimary ) { |
606 | return mPrimaryPalette ; | 606 | return mPrimaryPalette ; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | return mNonPrimaryPalette; | 609 | return mNonPrimaryPalette; |
610 | } | 610 | } |
611 | bool MonthViewCell::isPrimary() const | 611 | bool MonthViewCell::isPrimary() const |
612 | { | 612 | { |
613 | return mPrimary; | 613 | return mPrimary; |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::setHoliday( bool holiday ) | 616 | void MonthViewCell::setHoliday( bool holiday ) |
617 | { | 617 | { |
618 | mHoliday = holiday; | 618 | mHoliday = holiday; |
619 | //setMyPalette(); | 619 | //setMyPalette(); |
620 | } | 620 | } |
621 | 621 | ||
622 | void MonthViewCell::setHoliday( const QString &holiday ) | 622 | void MonthViewCell::setHoliday( const QString &holiday ) |
623 | { | 623 | { |
624 | mHolidayString = holiday; | 624 | mHolidayString = holiday; |
625 | 625 | ||
626 | if ( !holiday.isEmpty() ) { | 626 | if ( !holiday.isEmpty() ) { |
627 | setHoliday( true ); | 627 | setHoliday( true ); |
628 | } | 628 | } |
629 | } | 629 | } |
630 | 630 | ||
631 | void MonthViewCell::startUpdateCell() | 631 | void MonthViewCell::startUpdateCell() |
632 | { | 632 | { |
633 | blockSignals( true ); | 633 | blockSignals( true ); |
634 | mdayCount = 0; | 634 | mdayCount = 0; |
635 | setFocusPolicy(NoFocus); | 635 | setFocusPolicy(NoFocus); |
636 | if ( !mMonthView->isUpdatePossible() ) | 636 | if ( !mMonthView->isUpdatePossible() ) |
637 | return; | 637 | return; |
638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
639 | while ( mitem ) { | 639 | while ( mitem ) { |
640 | mitem->setBlockRepaint( true ); | 640 | mitem->setBlockRepaint( true ); |
641 | mitem = (MonthViewItem *)mitem->next(); | 641 | mitem = (MonthViewItem *)mitem->next(); |
642 | } | 642 | } |
643 | if ( mAvailItemList.count() > 20 ) { | 643 | if ( mAvailItemList.count() > 20 ) { |
644 | mAvailItemList.setAutoDelete( true ); | 644 | mAvailItemList.setAutoDelete( true ); |
645 | mAvailItemList.clear(); | 645 | mAvailItemList.clear(); |
646 | mAvailItemList.setAutoDelete( false ); | 646 | mAvailItemList.setAutoDelete( false ); |
647 | clear(); | 647 | clear(); |
648 | } | 648 | } |
649 | 649 | ||
650 | setPrimary( mDate.month()%2 ); | 650 | setPrimary( mDate.month()%2 ); |
651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
652 | if ( mDate == QDate::currentDate() ) { | 652 | if ( mDate == QDate::currentDate() ) { |
653 | setLineWidth( 3 ); | 653 | setLineWidth( 3 ); |
654 | } else { | 654 | } else { |
655 | setLineWidth( 1 ); | 655 | setLineWidth( 1 ); |
656 | } | 656 | } |
657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
658 | //clear(); | 658 | //clear(); |
659 | while ( CurrentAvailItem ) { | 659 | while ( CurrentAvailItem ) { |
660 | MonthViewItem *item = CurrentAvailItem; | 660 | MonthViewItem *item = CurrentAvailItem; |
661 | //item->setHighlightedFalse(); | 661 | //item->setHighlightedFalse(); |
662 | item->recycle( 0, ""); | 662 | item->recycle( 0, ""); |
663 | CurrentAvailItem = (MonthViewItem *)item->next(); | 663 | CurrentAvailItem = (MonthViewItem *)item->next(); |
664 | mAvailItemList.append( item ); | 664 | mAvailItemList.append( item ); |
665 | takeItem ( item ); | 665 | takeItem ( item ); |
666 | } | 666 | } |
667 | 667 | ||
668 | #ifdef DESKTOP_VERSION | 668 | #ifdef DESKTOP_VERSION |
669 | QToolTip::remove(this); | 669 | QToolTip::remove(this); |
670 | #endif | 670 | #endif |
671 | mToolTip.clear(); | 671 | mToolTip.clear(); |
672 | //qApp->processEvents(); | 672 | //qApp->processEvents(); |
673 | #if 0 | 673 | #if 0 |
674 | if ( !mHolidayString.isEmpty() ) { | 674 | if ( !mHolidayString.isEmpty() ) { |
675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
676 | item->setPalette( mHolidayPalette ); | 676 | item->setPalette( mHolidayPalette ); |
677 | insertItem( item ); | 677 | insertItem( item ); |
678 | mToolTip.append ( mHolidayString ); | 678 | mToolTip.append ( mHolidayString ); |
679 | } | 679 | } |
680 | #endif | 680 | #endif |
681 | } | 681 | } |
682 | 682 | ||
683 | int MonthViewCell::insertEvent(Event *event) | 683 | int MonthViewCell::insertEvent(Event *event) |
684 | { | 684 | { |
685 | bool useToolTips = true; | 685 | bool useToolTips = true; |
686 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
687 | useToolTips = false; | 687 | useToolTips = false; |
688 | #endif | 688 | #endif |
689 | QString mToolTipText; | 689 | QString mToolTipText; |
690 | setFocusPolicy(WheelFocus); | 690 | setFocusPolicy(WheelFocus); |
691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
693 | return mdayCount; | 693 | return mdayCount; |
694 | else | 694 | else |
695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
696 | return mdayCount; | 696 | return mdayCount; |
697 | } | 697 | } |
698 | 698 | ||
699 | if ( event->isHoliday()) { | 699 | if ( event->isHoliday()) { |
700 | setHoliday( true ); | 700 | setHoliday( true ); |
701 | if ( mDate.dayOfWeek() == 7 ) | 701 | if ( mDate.dayOfWeek() == 7 ) |
702 | setLineWidth( 3 ); | 702 | setLineWidth( 3 ); |
703 | } | 703 | } |
704 | QString text; | 704 | QString text; |
705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
706 | if (event->isMultiDay()) { | 706 | if (event->isMultiDay()) { |
707 | QString prefix = "<->";multiday = 2; | 707 | QString prefix = "<->";multiday = 2; |
708 | QString time; | 708 | QString time; |
709 | if ( event->doesRecur() ) { | 709 | if ( event->doesRecur() ) { |
710 | if ( event->recursOn( mDate) ) { | 710 | if ( event->recursOn( mDate) ) { |
711 | prefix ="->" ;multiday = 1; | 711 | prefix ="->" ;multiday = 1; |
712 | } | 712 | } |
713 | else { | 713 | else { |
714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
715 | if ( event->recursOn( mDate.addDays( -days)) ) { | 715 | if ( event->recursOn( mDate.addDays( -days)) ) { |
716 | prefix ="<-" ;multiday = 3; | 716 | prefix ="<-" ;multiday = 3; |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | } else { | 720 | } else { |
721 | if (mDate == event->dtStart().date()) { | 721 | if (mDate == event->dtStart().date()) { |
722 | prefix ="->" ;multiday = 1; | 722 | prefix ="->" ;multiday = 1; |
723 | } else if (mDate == event->dtEnd().date()) { | 723 | } else if (mDate == event->dtEnd().date()) { |
724 | prefix ="<-" ;multiday = 3; | 724 | prefix ="<-" ;multiday = 3; |
725 | } | 725 | } |
726 | } | 726 | } |
727 | if ( !event->doesFloat() ) { | 727 | if ( !event->doesFloat() ) { |
728 | if ( mDate == event->dtStart().date () ) | 728 | if ( mDate == event->dtStart().date () ) |
729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
730 | else if ( mDate == event->dtEnd().date () ) | 730 | else if ( mDate == event->dtEnd().date () ) |
731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
732 | 732 | ||
733 | } | 733 | } |
734 | text = time + event->summary(); | 734 | text = time + event->summary(); |
735 | if ( useToolTips ) | 735 | if ( useToolTips ) |
736 | mToolTipText += prefix + text; | 736 | mToolTipText += prefix + text; |
737 | } else { | 737 | } else { |
738 | if (event->doesFloat()) { | 738 | if (event->doesFloat()) { |
739 | text = event->summary(); | 739 | text = event->summary(); |
740 | if ( useToolTips ) | 740 | if ( useToolTips ) |
741 | mToolTipText += text; | 741 | mToolTipText += text; |
742 | } | 742 | } |
743 | else { | 743 | else { |
744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
745 | text += " " + event->summary(); | 745 | text += " " + event->summary(); |
746 | if ( useToolTips ) | 746 | if ( useToolTips ) |
747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
748 | } | 748 | } |
749 | } | 749 | } |
750 | if ( useToolTips && ! event->location().isEmpty() ) { | 750 | if ( useToolTips && ! event->location().isEmpty() ) { |
751 | mToolTipText += " (" + event->location() +")"; | 751 | mToolTipText += " (" + event->location() +")"; |
752 | } | 752 | } |
753 | MonthViewItem *item ; | 753 | MonthViewItem *item ; |
754 | 754 | ||
755 | if ( mAvailItemList.count() ) { | 755 | if ( mAvailItemList.count() ) { |
756 | item = mAvailItemList.first(); | 756 | item = mAvailItemList.first(); |
757 | mAvailItemList.remove( item ); | 757 | mAvailItemList.remove( item ); |
758 | item->recycle( event, text ); | 758 | item->recycle( event, text ); |
759 | } else { | 759 | } else { |
760 | item = new MonthViewItem( event, text ); | 760 | item = new MonthViewItem( event, text ); |
761 | } | 761 | } |
762 | 762 | ||
763 | QPalette pal; | 763 | QPalette pal; |
764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
765 | QStringList categories = event->categories(); | 765 | QStringList categories = event->categories(); |
766 | QString cat = categories.first(); | 766 | QString cat = categories.first(); |
767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
768 | pal = getPalette(); | 768 | pal = getPalette(); |
769 | if (cat.isEmpty()) { | 769 | if (cat.isEmpty()) { |
770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); | 771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); |
772 | } else { | 772 | } else { |
773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
774 | } | 774 | } |
775 | 775 | ||
776 | } else { | 776 | } else { |
777 | if (cat.isEmpty()) { | 777 | if (cat.isEmpty()) { |
778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); | 779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); |
780 | } else { | 780 | } else { |
781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | } else { | 785 | } else { |
786 | pal = mStandardPalette ; | 786 | pal = mStandardPalette ; |
787 | } | 787 | } |
788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
789 | item->setPalette( pal ); | 789 | item->setPalette( pal ); |
790 | item->setRecur( event->recurrence()->doesRecur() ); | 790 | item->setRecur( event->recurrence()->doesRecur() ); |
791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); | 791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); |
792 | item->setMoreInfo( event->description().length() > 0 ); | 792 | item->setMoreInfo( event->description().length() > 0 ); |
793 | #ifdef DESKTOP_VERSION | 793 | #ifdef DESKTOP_VERSION |
794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
795 | KOPrefs::instance()->email()); | 795 | KOPrefs::instance()->email()); |
796 | if ( me != 0 ) { | 796 | if ( me != 0 ) { |
797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
798 | item->setReply(true && multiday < 2); | 798 | item->setReply(true && multiday < 2); |
799 | else | 799 | else |
800 | item->setReply(false); | 800 | item->setReply(false); |
801 | } else | 801 | } else |
802 | item->setReply(false); | 802 | item->setReply(false); |
803 | #endif | 803 | #endif |
804 | 804 | ||
805 | item->setMultiDay( multiday ); | 805 | item->setMultiDay( multiday ); |
806 | if ( multiday ) { | 806 | if ( multiday ) { |
807 | insertItem( item ,mdayCount); | 807 | insertItem( item ,mdayCount); |
808 | ++mdayCount; | 808 | ++mdayCount; |
809 | } else { | 809 | } else { |
810 | uint i = mdayCount; | 810 | uint i = mdayCount; |
811 | uint pos = mdayCount; | 811 | uint pos = mdayCount; |
812 | uint itcount = count(); | 812 | uint itcount = count(); |
813 | if ( itcount > 1000 ) { | 813 | if ( itcount > 1000 ) { |
814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
815 | itcount = 0; | 815 | itcount = 0; |
816 | } | 816 | } |
817 | for ( i = pos; i < itcount;++i ) { | 817 | for ( i = pos; i < itcount;++i ) { |
818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
819 | QListBoxItem* it = this->item ( i ); | 819 | QListBoxItem* it = this->item ( i ); |
820 | if ( it && text < it->text() ) { | 820 | if ( it && text < it->text() ) { |
821 | pos = i; | 821 | pos = i; |
822 | break; | 822 | break; |
823 | } | 823 | } |
824 | ++pos; | 824 | ++pos; |
825 | } | 825 | } |
826 | insertItem( item ,pos); | 826 | insertItem( item ,pos); |
827 | } | 827 | } |
828 | if ( useToolTips ) { | 828 | if ( useToolTips ) { |
829 | mToolTip.append( mToolTipText ); | 829 | mToolTip.append( mToolTipText ); |
830 | } | 830 | } |
831 | return mdayCount; | 831 | return mdayCount; |
832 | } | 832 | } |
833 | void MonthViewCell::insertTodo(Todo *todo) | 833 | void MonthViewCell::insertTodo(Todo *todo) |
834 | { | 834 | { |
835 | setFocusPolicy(WheelFocus); | 835 | setFocusPolicy(WheelFocus); |
836 | QString text; | 836 | QString text; |
837 | if (todo->hasDueDate()) { | 837 | if (todo->hasDueDate()) { |
838 | if (!todo->doesFloat()) { | 838 | if (!todo->doesFloat()) { |
839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
840 | text += " "; | 840 | text += " "; |
841 | } | 841 | } |
842 | } | 842 | } |
843 | text += todo->summary(); | 843 | text += todo->summary(); |
844 | MonthViewItem *item ; | 844 | MonthViewItem *item ; |
845 | if ( mAvailItemList.count() ) { | 845 | if ( mAvailItemList.count() ) { |
846 | item = mAvailItemList.first(); | 846 | item = mAvailItemList.first(); |
847 | mAvailItemList.remove( item ); | 847 | mAvailItemList.remove( item ); |
848 | item->recycle( todo, text ); | 848 | item->recycle( todo, text ); |
849 | } else { | 849 | } else { |
850 | item = new MonthViewItem( todo, text ); | 850 | item = new MonthViewItem( todo, text ); |
851 | } | 851 | } |
852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
853 | //item->setPalette( mStandardPalette ); | 853 | //item->setPalette( mStandardPalette ); |
854 | QPalette pal; | 854 | QPalette pal; |
855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
856 | QStringList categories = todo->categories(); | 856 | QStringList categories = todo->categories(); |
857 | QString cat = categories.first(); | 857 | QString cat = categories.first(); |
858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
859 | pal = getPalette(); | 859 | pal = getPalette(); |
860 | if (cat.isEmpty()) { | 860 | if (cat.isEmpty()) { |
861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); | 862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); |
863 | } else { | 863 | } else { |
864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
865 | } | 865 | } |
866 | 866 | ||
867 | } else { | 867 | } else { |
868 | if (cat.isEmpty()) { | 868 | if (cat.isEmpty()) { |
869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); | 870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); |
871 | } else { | 871 | } else { |
872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | 875 | ||
876 | } else { | 876 | } else { |
877 | pal = mStandardPalette ; | 877 | pal = mStandardPalette ; |
878 | } | 878 | } |
879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
880 | item->setPalette( pal ); | 880 | item->setPalette( pal ); |
881 | item->setRecur( todo->recurrence()->doesRecur() ); | 881 | item->setRecur( todo->recurrence()->doesRecur() ); |
882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); | 882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); |
883 | item->setMoreInfo( todo->description().length() > 0 ); | 883 | item->setMoreInfo( todo->description().length() > 0 ); |
884 | insertItem( item , count()); | 884 | insertItem( item , count()); |
885 | #ifdef DESKTOP_VERSION | 885 | #ifdef DESKTOP_VERSION |
886 | mToolTip.append( text ); | 886 | mToolTip.append( text ); |
887 | #endif | 887 | #endif |
888 | } | 888 | } |
889 | void MonthViewCell::repaintfinishUpdateCell() | 889 | void MonthViewCell::repaintfinishUpdateCell() |
890 | { | 890 | { |
891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
892 | while ( mitem ) { | 892 | while ( mitem ) { |
893 | mitem->setBlockRepaint( false ); | 893 | mitem->setBlockRepaint( false ); |
894 | updateItem ( mitem ); | 894 | updateItem ( mitem ); |
895 | mitem = (MonthViewItem *)mitem->next(); | 895 | mitem = (MonthViewItem *)mitem->next(); |
896 | } | 896 | } |
897 | blockSignals( false ); | 897 | blockSignals( false ); |
898 | } | 898 | } |
899 | void MonthViewCell::finishUpdateCell() | 899 | void MonthViewCell::finishUpdateCell() |
900 | { | 900 | { |
901 | 901 | ||
902 | 902 | ||
903 | 903 | ||
904 | #ifdef DESKTOP_VERSION | 904 | #ifdef DESKTOP_VERSION |
905 | if (mToolTip.count() > 0 ) { | 905 | if (mToolTip.count() > 0 ) { |
906 | mToolTip.sort(); | 906 | mToolTip.sort(); |
907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
908 | } | 908 | } |
909 | #endif | 909 | #endif |
910 | //sort(); | 910 | //sort(); |
911 | //setMyPalette(); | 911 | //setMyPalette(); |
912 | setMyPalette(); | 912 | setMyPalette(); |
913 | 913 | ||
914 | resizeEvent( 0 ); | 914 | resizeEvent( 0 ); |
915 | 915 | ||
916 | } | 916 | } |
917 | void MonthViewCell::updateCell() | 917 | void MonthViewCell::updateCell() |
918 | { | 918 | { |
919 | if ( !mMonthView->isUpdatePossible() ) | 919 | if ( !mMonthView->isUpdatePossible() ) |
920 | return; | 920 | return; |
921 | startUpdateCell(); | 921 | startUpdateCell(); |
922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
924 | Event *event; | 924 | Event *event; |
925 | for( event = events.first(); event; event = events.next() ) { // for event | 925 | for( event = events.first(); event; event = events.next() ) { // for event |
926 | insertEvent(event); | 926 | insertEvent(event); |
927 | } | 927 | } |
928 | // insert due todos | 928 | // insert due todos |
929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
930 | Todo *todo; | 930 | Todo *todo; |
931 | for(todo = todos.first(); todo; todo = todos.next()) { | 931 | for(todo = todos.first(); todo; todo = todos.next()) { |
932 | insertTodo( todo ); | 932 | insertTodo( todo ); |
933 | } | 933 | } |
934 | finishUpdateCell(); | 934 | finishUpdateCell(); |
935 | // if ( isVisible()) | 935 | // if ( isVisible()) |
936 | //qApp->processEvents(); | 936 | //qApp->processEvents(); |
937 | } | 937 | } |
938 | 938 | ||
939 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 939 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
940 | { | 940 | { |
941 | 941 | ||
942 | if ( bigFont ) { | 942 | if ( bigFont ) { |
943 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 943 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
944 | int ps = fo.pointSize() + 2; | 944 | int ps = fo.pointSize() + 2; |
945 | if ( ps < 18 ) | 945 | if ( ps < 18 ) |
946 | ps += 2; | 946 | ps += 2; |
947 | fo.setPointSize( ps ); | 947 | fo.setPointSize( ps ); |
948 | setFont( fo ); | 948 | setFont( fo ); |
949 | } else | 949 | } else |
950 | setFont( KOPrefs::instance()->mMonthViewFont ); | 950 | setFont( KOPrefs::instance()->mMonthViewFont ); |
951 | 951 | ||
952 | QFontMetrics fm( font() ); | 952 | QFontMetrics fm( font() ); |
953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
955 | mHolidayPalette = mStandardPalette; | 955 | mHolidayPalette = mStandardPalette; |
956 | mPrimaryPalette = mStandardPalette; | 956 | mPrimaryPalette = mStandardPalette; |
957 | mNonPrimaryPalette = mStandardPalette; | 957 | mNonPrimaryPalette = mStandardPalette; |
958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
968 | } | 968 | } |
969 | //updateCell(); | 969 | //updateCell(); |
970 | } | 970 | } |
971 | 971 | ||
972 | void MonthViewCell::enableScrollBars( bool enabled ) | 972 | void MonthViewCell::enableScrollBars( bool enabled ) |
973 | { | 973 | { |
974 | 974 | ||
975 | return; | 975 | return; |
976 | if ( enabled ) { | 976 | if ( enabled ) { |
977 | QListBoxItem *fi = firstItem (); | 977 | QListBoxItem *fi = firstItem (); |
978 | if (fi ) { | 978 | if (fi ) { |
979 | int ihei = fi->height( this ); | 979 | int ihei = fi->height( this ); |
980 | int hei = numRows () * ihei; | 980 | int hei = numRows () * ihei; |
981 | if ( hei < height() - horizontalScrollBar()->height () ) { | 981 | if ( hei < height() - horizontalScrollBar()->height () ) { |
982 | setVScrollBarMode(QScrollView::AlwaysOff); | 982 | setVScrollBarMode(QScrollView::AlwaysOff); |
983 | } | 983 | } |
984 | else | 984 | else |
985 | setVScrollBarMode(QScrollView::Auto); | 985 | setVScrollBarMode(QScrollView::Auto); |
986 | if ( ihei *3 > height() ) { | 986 | if ( ihei *3 > height() ) { |
987 | setHScrollBarMode(QScrollView::AlwaysOff); | 987 | setHScrollBarMode(QScrollView::AlwaysOff); |
988 | } | 988 | } |
989 | else { | 989 | else { |
990 | setHScrollBarMode(QScrollView::Auto); | 990 | setHScrollBarMode(QScrollView::Auto); |
991 | } | 991 | } |
992 | } else { | 992 | } else { |
993 | setVScrollBarMode(QScrollView::Auto); | 993 | setVScrollBarMode(QScrollView::Auto); |
994 | setHScrollBarMode(QScrollView::Auto); | 994 | setHScrollBarMode(QScrollView::Auto); |
995 | } | 995 | } |
996 | } else { | 996 | } else { |
997 | setVScrollBarMode(QScrollView::AlwaysOff); | 997 | setVScrollBarMode(QScrollView::AlwaysOff); |
998 | setHScrollBarMode(QScrollView::AlwaysOff); | 998 | setHScrollBarMode(QScrollView::AlwaysOff); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | Incidence *MonthViewCell::selectedIncidence() | 1002 | Incidence *MonthViewCell::selectedIncidence() |
1003 | { | 1003 | { |
1004 | int index = currentItem(); | 1004 | int index = currentItem(); |
1005 | if ( index < 0 ) return 0; | 1005 | if ( index < 0 ) return 0; |
1006 | 1006 | ||
1007 | MonthViewItem *mitem = | 1007 | MonthViewItem *mitem = |
1008 | static_cast<MonthViewItem *>( item( index ) ); | 1008 | static_cast<MonthViewItem *>( item( index ) ); |
1009 | 1009 | ||
1010 | if ( !mitem ) return 0; | 1010 | if ( !mitem ) return 0; |
1011 | 1011 | ||
1012 | return mitem->incidence(); | 1012 | return mitem->incidence(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | QDate MonthViewCell::selectedIncidenceDate() | 1015 | QDate MonthViewCell::selectedIncidenceDate() |
1016 | { | 1016 | { |
1017 | QDate qd; | 1017 | QDate qd; |
1018 | int index = currentItem(); | 1018 | int index = currentItem(); |
1019 | if ( index < 0 ) return qd; | 1019 | if ( index < 0 ) return qd; |
1020 | return mDate; | 1020 | return mDate; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void MonthViewCell::deselect() | 1023 | void MonthViewCell::deselect() |
1024 | { | 1024 | { |
1025 | clearSelection(); | 1025 | clearSelection(); |
1026 | enableScrollBars( false ); | 1026 | enableScrollBars( false ); |
1027 | // updateCell(); | 1027 | // updateCell(); |
1028 | } | 1028 | } |
1029 | void MonthViewCell::select() | 1029 | void MonthViewCell::select() |
1030 | { | 1030 | { |
1031 | ;// updateCell(); | 1031 | ;// updateCell(); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
1035 | { | 1035 | { |
1036 | if ( !mMonthView->isUpdatePossible() ) | 1036 | if ( !mMonthView->isUpdatePossible() ) |
1037 | return; | 1037 | return; |
1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
1039 | deselect(); | 1039 | deselect(); |
1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
1041 | 1041 | ||
1042 | QString text; | 1042 | QString text; |
1043 | //mLabel->setText( text ); | 1043 | //mLabel->setText( text ); |
1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); | 1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); |
1047 | mLabel->resize( mLabelBigSize ); | 1047 | mLabel->resize( mLabelBigSize ); |
1048 | } else { | 1048 | } else { |
1049 | mLabel->resize( mLabelSize ); | 1049 | mLabel->resize( mLabelSize ); |
1050 | text = QString::number( mDate.day() ); | 1050 | text = QString::number( mDate.day() ); |
1051 | } | 1051 | } |
1052 | mLabel->setText( text ); | 1052 | mLabel->setText( text ); |
1053 | 1053 | ||
1054 | int size = height() - mLabel->height() - lineWidth()-1; | 1054 | int size = height() - mLabel->height() - lineWidth()-1; |
1055 | //qDebug("LW %d ", lineWidth()); | 1055 | //qDebug("LW %d ", lineWidth()); |
1056 | if ( size > 0 ) | 1056 | if ( size > 0 ) |
1057 | verticalScrollBar()->setMaximumHeight( size ); | 1057 | verticalScrollBar()->setMaximumHeight( size ); |
1058 | size = width() - mLabel->width() -lineWidth()-1; | 1058 | size = width() - mLabel->width() -lineWidth()-1; |
1059 | if ( size > 0 ) | 1059 | if ( size > 0 ) |
1060 | horizontalScrollBar()->setMaximumWidth( size ); | 1060 | horizontalScrollBar()->setMaximumWidth( size ); |
1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1063 | // mItemList->resize ( width(), height () ); | 1063 | // mItemList->resize ( width(), height () ); |
1064 | if ( e ) | 1064 | if ( e ) |
1065 | KNoScrollListBox::resizeEvent ( e ); | 1065 | KNoScrollListBox::resizeEvent ( e ); |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1069 | { | 1069 | { |
1070 | 1070 | ||
1071 | if ( !item ) { | 1071 | if ( !item ) { |
1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1073 | emit newEventSignal( dt ); | 1073 | emit newEventSignal( dt ); |
1074 | return; | 1074 | return; |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1078 | Incidence *incidence = eventItem->incidence(); | 1078 | Incidence *incidence = eventItem->incidence(); |
1079 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1079 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1080 | } | 1080 | } |
1081 | void MonthViewCell::showDay() | 1081 | void MonthViewCell::showDay() |
1082 | { | 1082 | { |
1083 | emit showDaySignal( date() ); | 1083 | emit showDaySignal( date() ); |
1084 | } | 1084 | } |
1085 | void MonthViewCell::newEvent() | 1085 | void MonthViewCell::newEvent() |
1086 | { | 1086 | { |
1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1088 | emit newEventSignal( dt ); | 1088 | emit newEventSignal( dt ); |
1089 | } | 1089 | } |
1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1091 | { | 1091 | { |
1092 | mMonthView->setSelectedCell( this ); | 1092 | mMonthView->setSelectedCell( this ); |
1093 | if ( item == 0 ) { | 1093 | if ( item == 0 ) { |
1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1095 | emit newEventSignal( dt ); | 1095 | emit newEventSignal( dt ); |
1096 | return; | 1096 | return; |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1102 | { | 1102 | { |
1103 | mMonthView->setPopupCell( this ); | 1103 | mMonthView->setPopupCell( this ); |
1104 | if ( !item ) { | 1104 | if ( !item ) { |
1105 | mMonthView->showContextMenu( 0 ); | 1105 | mMonthView->showContextMenu( 0 ); |
1106 | return; | 1106 | return; |
1107 | } | 1107 | } |
1108 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1108 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1109 | Incidence *incidence = eventItem->incidence(); | 1109 | Incidence *incidence = eventItem->incidence(); |
1110 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1110 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | void MonthViewCell::selection( QListBoxItem *item ) | 1113 | void MonthViewCell::selection( QListBoxItem *item ) |
1114 | { | 1114 | { |
1115 | if ( !item ) { | 1115 | if ( !item ) { |
1116 | emit highlightIncidence( 0 , this, 0 ); | 1116 | emit highlightIncidence( 0 , this, 0 ); |
1117 | return; | 1117 | return; |
1118 | } | 1118 | } |
1119 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1119 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1120 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); | 1120 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1121 | mMonthView->setSelectedCell( this ); | 1121 | mMonthView->setSelectedCell( this ); |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | void MonthViewCell::deHighLight() | 1124 | void MonthViewCell::deHighLight() |
1125 | { | 1125 | { |
1126 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1126 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1127 | while ( mitem ) { | 1127 | while ( mitem ) { |
1128 | if ( mitem->setHighlightedFalse() ) | 1128 | if ( mitem->setHighlightedFalse() ) |
1129 | updateItem ( mitem ); | 1129 | updateItem ( mitem ); |
1130 | mitem = (MonthViewItem *)mitem->next(); | 1130 | mitem = (MonthViewItem *)mitem->next(); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | // returns true if no inc found | 1133 | // returns true if no inc found |
1134 | bool MonthViewCell::doHighLight( Incidence * inc ) | 1134 | bool MonthViewCell::doHighLight( Incidence * inc ) |
1135 | { | 1135 | { |
1136 | 1136 | ||
1137 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1137 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1138 | while ( mitem ) { | 1138 | while ( mitem ) { |
1139 | if ( mitem->incidence() == inc ) { | 1139 | if ( mitem->incidence() == inc ) { |
1140 | if ( mitem->setHighlighted( inc ) ) | 1140 | if ( mitem->setHighlighted( inc ) ) |
1141 | updateItem ( mitem ); | 1141 | updateItem ( mitem ); |
1142 | return false; | 1142 | return false; |
1143 | } | 1143 | } |
1144 | mitem = (MonthViewItem *)mitem->next(); | 1144 | mitem = (MonthViewItem *)mitem->next(); |
1145 | } | 1145 | } |
1146 | return true; | 1146 | return true; |
1147 | } | 1147 | } |
1148 | // ******************************************************************************* | 1148 | // ******************************************************************************* |
1149 | // ******************************************************************************* | 1149 | // ******************************************************************************* |
1150 | // ******************************************************************************* | 1150 | // ******************************************************************************* |
1151 | 1151 | ||
1152 | 1152 | ||
1153 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1153 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1154 | : KOEventView( calendar, parent, name ), | 1154 | : KOEventView( calendar, parent, name ), |
1155 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1155 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1156 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1156 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1157 | { | 1157 | { |
1158 | mFlagKeyPressed = false; | 1158 | mFlagKeyPressed = false; |
1159 | mShortDayLabelsM = false; | 1159 | mShortDayLabelsM = false; |
1160 | mShortDayLabelsW = false; | 1160 | mShortDayLabelsW = false; |
1161 | skipResize = false; | 1161 | skipResize = false; |
1162 | clPending = true; | 1162 | clPending = true; |
1163 | mPopupCell = 0; | 1163 | mPopupCell = 0; |
1164 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1164 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1165 | mWidStack = new QWidgetStack( this ); | 1165 | mWidStack = new QWidgetStack( this ); |
1166 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1166 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1167 | mMonthView = new QWidget( mWidStack ); | 1167 | mMonthView = new QWidget( mWidStack ); |
1168 | mWeekView = new QWidget( mWidStack ); | 1168 | mWeekView = new QWidget( mWidStack ); |
1169 | #if QT_VERSION >= 0x030000 | 1169 | #if QT_VERSION >= 0x030000 |
1170 | mWidStack->addWidget(mMonthView ); | 1170 | mWidStack->addWidget(mMonthView ); |
1171 | mWidStack->addWidget(mWeekView ); | 1171 | mWidStack->addWidget(mWeekView ); |
1172 | #else | 1172 | #else |
1173 | mWidStack->addWidget( mMonthView, 1 ); | 1173 | mWidStack->addWidget( mMonthView, 1 ); |
1174 | mWidStack->addWidget( mWeekView , 1 ); | 1174 | mWidStack->addWidget( mWeekView , 1 ); |
1175 | #endif | 1175 | #endif |
1176 | hb->addWidget( mNavigatorBar ); | 1176 | hb->addWidget( mNavigatorBar ); |
1177 | hb->addWidget( mWidStack ); | 1177 | hb->addWidget( mWidStack ); |
1178 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1178 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1179 | updatePossible = false; | 1179 | updatePossible = false; |
1180 | //updatePossible = true; | 1180 | //updatePossible = true; |
1181 | mCells.setAutoDelete( true ); | 1181 | mCells.setAutoDelete( true ); |
1182 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1182 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1183 | mDayLabels.resize( mDaysPerWeek ); | 1183 | mDayLabels.resize( mDaysPerWeek ); |
1184 | mDayLabelsW.resize( mDaysPerWeek ); | 1184 | mDayLabelsW.resize( mDaysPerWeek ); |
1185 | QFont bfont = font(); | 1185 | QFont bfont = font(); |
1186 | if ( QApplication::desktop()->width() < 650 ) { | 1186 | if ( QApplication::desktop()->width() < 650 ) { |
1187 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1187 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1188 | } | 1188 | } |
1189 | bfont.setBold( true ); | 1189 | bfont.setBold( true ); |
1190 | int i; | 1190 | int i; |
1191 | 1191 | ||
1192 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1192 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1193 | QLabel *label = new QLabel( mMonthView ); | 1193 | QLabel *label = new QLabel( mMonthView ); |
1194 | label->setFont(bfont); | 1194 | label->setFont(bfont); |
1195 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1195 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1196 | label->setLineWidth(1); | 1196 | label->setLineWidth(1); |
1197 | label->setAlignment(AlignCenter); | 1197 | label->setAlignment(AlignCenter); |
1198 | mDayLabels.insert( i, label ); | 1198 | mDayLabels.insert( i, label ); |
1199 | label = new QLabel( mWeekView ); | 1199 | label = new QLabel( mWeekView ); |
1200 | label->setFont(bfont); | 1200 | label->setFont(bfont); |
1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1202 | label->setLineWidth(1); | 1202 | label->setLineWidth(1); |
1203 | label->setAlignment(AlignCenter); | 1203 | label->setAlignment(AlignCenter); |
1204 | mDayLabelsW.insert( i, label ); | 1204 | mDayLabelsW.insert( i, label ); |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | bfont.setBold( false ); | 1207 | bfont.setBold( false ); |
1208 | mWeekLabels.resize( mNumWeeks+1 ); | 1208 | mWeekLabels.resize( mNumWeeks+1 ); |
1209 | mWeekLabelsW.resize( 2 ); | 1209 | mWeekLabelsW.resize( 2 ); |
1210 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1210 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1211 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1211 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1212 | label->setFocusPolicy(NoFocus); | 1212 | label->setFocusPolicy(NoFocus); |
1213 | label->setFont(bfont); | 1213 | label->setFont(bfont); |
1214 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1214 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1215 | label->setFlat(true); | 1215 | label->setFlat(true); |
1216 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1216 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1217 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1217 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1218 | //label->setLineWidth(1); | 1218 | //label->setLineWidth(1); |
1219 | //label->setAlignment(AlignCenter); | 1219 | //label->setAlignment(AlignCenter); |
1220 | mWeekLabels.insert( i, label ); | 1220 | mWeekLabels.insert( i, label ); |
1221 | } | 1221 | } |
1222 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1222 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1223 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1223 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1224 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1224 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1225 | 1225 | ||
1226 | for( i = 0; i < 1+1; i++ ) { | 1226 | for( i = 0; i < 1+1; i++ ) { |
1227 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1227 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1228 | label->setFocusPolicy(NoFocus); | 1228 | label->setFocusPolicy(NoFocus); |
1229 | label->setFont(bfont); | 1229 | label->setFont(bfont); |
1230 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1230 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1231 | label->setFlat(true); | 1231 | label->setFlat(true); |
1232 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1232 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1233 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1233 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1234 | //label->setLineWidth(1); | 1234 | //label->setLineWidth(1); |
1235 | //label->setAlignment(AlignCenter); | 1235 | //label->setAlignment(AlignCenter); |
1236 | mWeekLabelsW.insert( i, label ); | 1236 | mWeekLabelsW.insert( i, label ); |
1237 | } | 1237 | } |
1238 | mWeekLabelsW[1]->setText( i18n("W")); | 1238 | mWeekLabelsW[1]->setText( i18n("W")); |
1239 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1239 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1240 | 1240 | ||
1241 | 1241 | ||
1242 | int row, col; | 1242 | int row, col; |
1243 | mCells.resize( mNumCells ); | 1243 | mCells.resize( mNumCells ); |
1244 | for( row = 0; row < mNumWeeks; ++row ) { | 1244 | for( row = 0; row < mNumWeeks; ++row ) { |
1245 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1245 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1246 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1246 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1247 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1247 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1248 | 1248 | ||
1249 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1249 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1250 | SLOT( defaultAction( Incidence * ) ) ); | 1250 | SLOT( defaultAction( Incidence * ) ) ); |
1251 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1251 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1252 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1252 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1253 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1253 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1254 | SIGNAL( showDaySignal( QDate ) ) ); | 1254 | SIGNAL( showDaySignal( QDate ) ) ); |
1255 | connect( cell, SIGNAL( nextCell() ), | 1255 | connect( cell, SIGNAL( nextCell() ), |
1256 | SLOT( nextCell() ) ); | 1256 | SLOT( nextCell() ) ); |
1257 | connect( cell, SIGNAL( prevCell() ), | 1257 | connect( cell, SIGNAL( prevCell() ), |
1258 | SLOT( prevCell() ) ); | 1258 | SLOT( prevCell() ) ); |
1259 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1259 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1260 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1260 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1261 | } | 1261 | } |
1262 | } | 1262 | } |
1263 | mCellsW.resize( mDaysPerWeek ); | 1263 | mCellsW.resize( mDaysPerWeek ); |
1264 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1264 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1265 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1265 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1266 | mCellsW.insert( col, cell ); | 1266 | mCellsW.insert( col, cell ); |
1267 | 1267 | ||
1268 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1268 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1269 | SLOT( defaultAction( Incidence * ) ) ); | 1269 | SLOT( defaultAction( Incidence * ) ) ); |
1270 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1270 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1271 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1271 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1272 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1272 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1273 | SIGNAL( showDaySignal( QDate ) ) ); | 1273 | SIGNAL( showDaySignal( QDate ) ) ); |
1274 | connect( cell, SIGNAL( nextCell() ), | 1274 | connect( cell, SIGNAL( nextCell() ), |
1275 | SLOT( nextCell() ) ); | 1275 | SLOT( nextCell() ) ); |
1276 | connect( cell, SIGNAL( prevCell() ), | 1276 | connect( cell, SIGNAL( prevCell() ), |
1277 | SLOT( prevCell() ) ); | 1277 | SLOT( prevCell() ) ); |
1278 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1278 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1279 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1279 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1280 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1280 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1281 | } | 1281 | } |
1282 | 1282 | ||
1283 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1283 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1284 | mContextMenu = eventPopup(); | 1284 | mContextMenu = eventPopup(); |
1285 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1285 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1286 | i18n("New Event..."),this, | 1286 | i18n("New Event..."),this, |
1287 | SLOT(slotNewEvent()),false); | 1287 | SLOT(slotNewEvent()),false); |
1288 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1288 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1289 | i18n("New Todo..."),this, | 1289 | i18n("New Todo..."),this, |
1290 | SLOT(slotNewTodo()),false); | 1290 | SLOT(slotNewTodo()),false); |
1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1292 | i18n("Journal"),this, | 1292 | i18n("Journal"),this, |
1293 | SLOT(slotEditJournal()),false); | 1293 | SLOT(slotEditJournal()),false); |
1294 | 1294 | ||
1295 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, | 1295 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, |
1296 | SLOT( catChanged( Incidence * ) )); | 1296 | SLOT( catChanged( Incidence * ) )); |
1297 | 1297 | ||
1298 | 1298 | ||
1299 | QString pathString = ""; | 1299 | QString pathString = ""; |
1300 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1300 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1301 | if ( QApplication::desktop()->width() < 480 ) | 1301 | if ( QApplication::desktop()->width() < 480 ) |
1302 | pathString += "icons16/"; | 1302 | pathString += "icons16/"; |
1303 | } else | 1303 | } else |
1304 | pathString += "iconsmini/"; | 1304 | pathString += "iconsmini/"; |
1305 | mNewItemMenu = new QPopupMenu( this ); | 1305 | mNewItemMenu = new QPopupMenu( this ); |
1306 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1306 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1307 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1307 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1309 | 1309 | ||
1310 | // updateConfig(); //useless here... | 1310 | // updateConfig(); //useless here... |
1311 | // ... but we need mWidthLongDayLabel computed | 1311 | // ... but we need mWidthLongDayLabel computed |
1312 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1312 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1313 | mWidthLongDayLabel = 0; | 1313 | mWidthLongDayLabel = 0; |
1314 | for (int i = 0; i < 7; i++) { | 1314 | for (int i = 0; i < 7; i++) { |
1315 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1315 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1316 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1316 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1319 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1320 | 1320 | ||
1321 | #if 0 | 1321 | #if 0 |
1322 | if ( mShowWeekView ) | 1322 | if ( mShowWeekView ) |
1323 | mWidStack->raiseWidget( mWeekView ); | 1323 | mWidStack->raiseWidget( mWeekView ); |
1324 | else | 1324 | else |
1325 | mWidStack->raiseWidget( mMonthView ); | 1325 | mWidStack->raiseWidget( mMonthView ); |
1326 | #endif | 1326 | #endif |
1327 | 1327 | ||
1328 | emit incidenceSelected( 0 ); | 1328 | emit incidenceSelected( 0 ); |
1329 | 1329 | ||
1330 | mComputeLayoutTimer = new QTimer( this ); | 1330 | mComputeLayoutTimer = new QTimer( this ); |
1331 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1331 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1332 | 1332 | ||
1333 | 1333 | ||
1334 | #ifndef DESKTOP_VERSION | 1334 | #ifndef DESKTOP_VERSION |
1335 | resize( QApplication::desktop()->size() ); | 1335 | resize( QApplication::desktop()->size() ); |
1336 | #else | 1336 | #else |
1337 | resize(640, 480 ); | 1337 | resize(640, 480 ); |
1338 | updatePossible = true; | 1338 | updatePossible = true; |
1339 | #endif | 1339 | #endif |
1340 | computeLayout(); | 1340 | computeLayout(); |
1341 | 1341 | ||
1342 | if ( mShowWeekView ) | 1342 | if ( mShowWeekView ) |
1343 | mWidStack->raiseWidget( mWeekView ); | 1343 | mWidStack->raiseWidget( mWeekView ); |
1344 | else | 1344 | else |
1345 | mWidStack->raiseWidget( mMonthView ); | 1345 | mWidStack->raiseWidget( mMonthView ); |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | KOMonthView::~KOMonthView() | 1348 | KOMonthView::~KOMonthView() |
1349 | { | 1349 | { |
1350 | delete mContextMenu; | 1350 | delete mContextMenu; |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | void KOMonthView::catChanged( Incidence * ) | 1353 | void KOMonthView::catChanged( Incidence * ) |
1354 | { | 1354 | { |
1355 | updateView(); | 1355 | updateView(); |
1356 | } | 1356 | } |
1357 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | 1357 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) |
1358 | { | 1358 | { |
1359 | static Incidence * lastInc = 0; | 1359 | static Incidence * lastInc = 0; |
1360 | static MonthViewCell * lastCell = 0; | 1360 | static MonthViewCell * lastCell = 0; |
1361 | 1361 | ||
1362 | if ( lastInc == inc && lastCell == mc ) | 1362 | if ( lastInc == inc && lastCell == mc ) |
1363 | return; | 1363 | return; |
1364 | lastInc = inc; | 1364 | lastInc = inc; |
1365 | lastCell = mc; | 1365 | lastCell = mc; |
1366 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1366 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1367 | 1367 | ||
1368 | bool weekview = false; | 1368 | bool weekview = false; |
1369 | uint index = 0; | 1369 | uint index = 0; |
1370 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1370 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1371 | if ( mCellsW[i] == mc ) { | 1371 | if ( mCellsW[i] == mc ) { |
1372 | weekview = true; | 1372 | weekview = true; |
1373 | index = i; | 1373 | index = i; |
1374 | break; | 1374 | break; |
1375 | } | 1375 | } |
1376 | } | 1376 | } |
1377 | QPtrVector<MonthViewCell> *cells; | 1377 | QPtrVector<MonthViewCell> *cells; |
1378 | if ( weekview ) | 1378 | if ( weekview ) |
1379 | cells = &mCellsW; | 1379 | cells = &mCellsW; |
1380 | else { | 1380 | else { |
1381 | for (uint i = 0; i < mCells.count(); ++i) { | 1381 | for (uint i = 0; i < mCells.count(); ++i) { |
1382 | if ( mCells[i] == mc ) { | 1382 | if ( mCells[i] == mc ) { |
1383 | index = i; | 1383 | index = i; |
1384 | break; | 1384 | break; |
1385 | } | 1385 | } |
1386 | } | 1386 | } |
1387 | cells = &mCells; | 1387 | cells = &mCells; |
1388 | } | 1388 | } |
1389 | for (uint i = 0; i < (*cells).count(); ++i) { | 1389 | for (uint i = 0; i < (*cells).count(); ++i) { |
1390 | (*cells)[i]->deHighLight(); | 1390 | (*cells)[i]->deHighLight(); |
1391 | } | 1391 | } |
1392 | if ( ! inc ) | 1392 | if ( ! inc ) |
1393 | return; | 1393 | return; |
1394 | 1394 | ||
1395 | uint count = (*cells).count(); | 1395 | uint count = (*cells).count(); |
1396 | bool goLeft = (mday > 1 && index > 0); | 1396 | bool goLeft = (mday > 1 && index > 0); |
1397 | bool goRight = (mday < 3 && mday > 0 && index < count -1); | 1397 | bool goRight = (mday < 3 && mday > 0 && index < count -1); |
1398 | for (uint iii = 1; iii < count; ++iii) { | 1398 | for (uint iii = 1; iii < count; ++iii) { |
1399 | if ( goLeft ) { | 1399 | if ( goLeft ) { |
1400 | int left = index - iii; | 1400 | int left = index - iii; |
1401 | if ( left >= 0 ) { | 1401 | if ( left >= 0 ) { |
1402 | if ( (*cells)[(uint)left]->doHighLight(inc) ) | 1402 | if ( (*cells)[(uint)left]->doHighLight(inc) ) |
1403 | goLeft = false; | 1403 | goLeft = false; |
1404 | } else | 1404 | } else |
1405 | goLeft = false; | 1405 | goLeft = false; |
1406 | } | 1406 | } |
1407 | if ( goRight ) { | 1407 | if ( goRight ) { |
1408 | uint right = index + iii; | 1408 | uint right = index + iii; |
1409 | if ( right < count ) { | 1409 | if ( right < count ) { |
1410 | if ( (*cells)[right]->doHighLight(inc) ) | 1410 | if ( (*cells)[right]->doHighLight(inc) ) |
1411 | goRight = false; | 1411 | goRight = false; |
1412 | 1412 | ||
1413 | } else | 1413 | } else |
1414 | goRight = false; | 1414 | goRight = false; |
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | } | 1417 | } |
1418 | #if 0 | 1418 | #if 0 |
1419 | if ( mday > 1 && index > 0 ) | 1419 | if ( mday > 1 && index > 0 ) |
1420 | for (int i = index-1; i >= 0; --i) { | 1420 | for (int i = index-1; i >= 0; --i) { |
1421 | //qDebug("index %d iii %d ", index, i); | 1421 | //qDebug("index %d iii %d ", index, i); |
1422 | if ( (*cells)[(uint)i]->doHighLight(inc) ) | 1422 | if ( (*cells)[(uint)i]->doHighLight(inc) ) |
1423 | break; | 1423 | break; |
1424 | } | 1424 | } |
1425 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) | 1425 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) |
1426 | for (uint i = index+1; i < (*cells).count(); ++i) { | 1426 | for (uint i = index+1; i < (*cells).count(); ++i) { |
1427 | if ( (*cells)[i]->doHighLight(inc) ) | 1427 | if ( (*cells)[i]->doHighLight(inc) ) |
1428 | break; | 1428 | break; |
1429 | } | 1429 | } |
1430 | #endif | 1430 | #endif |
1431 | 1431 | ||
1432 | } | 1432 | } |
1433 | void KOMonthView::selectInternalWeekNum ( int n ) | 1433 | void KOMonthView::selectInternalWeekNum ( int n ) |
1434 | { | 1434 | { |
1435 | switchView(); | 1435 | switchView(); |
1436 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1436 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1437 | emit selectMonth (); | 1437 | emit selectMonth (); |
1438 | else | 1438 | else |
1439 | emit selectWeekNum ( n ); | 1439 | emit selectWeekNum ( n ); |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | int KOMonthView::currentWeek() | 1442 | int KOMonthView::currentWeek() |
1443 | { | 1443 | { |
1444 | if ( mShowWeekView ) | 1444 | if ( mShowWeekView ) |
1445 | return mWeekLabelsW[0]->getWeekNum(); | 1445 | return mWeekLabelsW[0]->getWeekNum(); |
1446 | return mWeekLabels[0]->getWeekNum(); | 1446 | return mWeekLabels[0]->getWeekNum(); |
1447 | } | 1447 | } |
1448 | void KOMonthView::switchView() | 1448 | void KOMonthView::switchView() |
1449 | { | 1449 | { |
1450 | if ( selectedCell( ) ) | 1450 | if ( selectedCell( ) ) |
1451 | selectedCell()->deselect(); | 1451 | selectedCell()->deselect(); |
1452 | mShowWeekView = !mShowWeekView; | 1452 | mShowWeekView = !mShowWeekView; |
1453 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1453 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1454 | if ( clPending ) { | 1454 | if ( clPending ) { |
1455 | computeLayout(); | 1455 | computeLayout(); |
1456 | updateConfig(); | 1456 | updateConfig(); |
1457 | } | 1457 | } |
1458 | if ( mShowWeekView ) | 1458 | if ( mShowWeekView ) |
1459 | mWidStack->raiseWidget( mWeekView ); | 1459 | mWidStack->raiseWidget( mWeekView ); |
1460 | else | 1460 | else |
1461 | mWidStack->raiseWidget( mMonthView ); | 1461 | mWidStack->raiseWidget( mMonthView ); |
1462 | clPending = false; | 1462 | clPending = false; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | int KOMonthView::maxDatesHint() | 1465 | int KOMonthView::maxDatesHint() |
1466 | { | 1466 | { |
1467 | return mNumCells; | 1467 | return mNumCells; |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | int KOMonthView::currentDateCount() | 1470 | int KOMonthView::currentDateCount() |
1471 | { | 1471 | { |
1472 | return mNumCells; | 1472 | return mNumCells; |
1473 | } | 1473 | } |
1474 | 1474 | ||
1475 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1475 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1476 | { | 1476 | { |
1477 | QPtrList<Incidence> selected; | 1477 | QPtrList<Incidence> selected; |
1478 | 1478 | ||
1479 | if ( mSelectedCell ) { | 1479 | if ( mSelectedCell ) { |
1480 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1480 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1481 | if ( incidence ) selected.append( incidence ); | 1481 | if ( incidence ) selected.append( incidence ); |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | return selected; | 1484 | return selected; |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | DateList KOMonthView::selectedDates() | 1487 | DateList KOMonthView::selectedDates() |
1488 | { | 1488 | { |
1489 | DateList selected; | 1489 | DateList selected; |
1490 | 1490 | ||
1491 | if ( mSelectedCell ) { | 1491 | if ( mSelectedCell ) { |
1492 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1492 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1493 | if ( qd.isValid() ) selected.append( qd ); | 1493 | if ( qd.isValid() ) selected.append( qd ); |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | return selected; | 1496 | return selected; |
1497 | } | 1497 | } |
1498 | #if 0 | 1498 | #if 0 |
1499 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1499 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1500 | const QDate &td) | 1500 | const QDate &td) |
1501 | { | 1501 | { |
1502 | #ifndef KORG_NOPRINTER | 1502 | #ifndef KORG_NOPRINTER |
1503 | calPrinter->preview(CalPrinter::Month, fd, td); | 1503 | calPrinter->preview(CalPrinter::Month, fd, td); |
1504 | #endif | 1504 | #endif |
1505 | } | 1505 | } |
1506 | #endif | 1506 | #endif |
1507 | void KOMonthView::updateConfig() | 1507 | void KOMonthView::updateConfig() |
1508 | { | 1508 | { |
1509 | 1509 | ||
1510 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1510 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1511 | 1511 | ||
1512 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1512 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1513 | mWeekStartsMonday = true; | 1513 | mWeekStartsMonday = true; |
1514 | } | 1514 | } |
1515 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1515 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1516 | mWidthLongDayLabel = 0; | 1516 | mWidthLongDayLabel = 0; |
1517 | 1517 | ||
1518 | for (int i = 0; i < 7; i++) { | 1518 | for (int i = 0; i < 7; i++) { |
1519 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1519 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1520 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1520 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1521 | } | 1521 | } |
1522 | bool temp = mShowSatSunComp ; | 1522 | bool temp = mShowSatSunComp ; |
1523 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1523 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1524 | if ( ! mShowWeekView ) { | 1524 | if ( ! mShowWeekView ) { |
1525 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1525 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1526 | computeLayout(); | 1526 | computeLayout(); |
1527 | } else | 1527 | } else |
1528 | doComputeLayoutWeek(); | 1528 | doComputeLayoutWeek(); |
1529 | updateDayLabels(); | 1529 | updateDayLabels(); |
1530 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1530 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1531 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1531 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1532 | //resizeEvent( 0 ); | 1532 | //resizeEvent( 0 ); |
1533 | for (uint i = 0; i < mCells.count(); ++i) { | 1533 | for (uint i = 0; i < mCells.count(); ++i) { |
1534 | mCells[i]->updateConfig(); | 1534 | mCells[i]->updateConfig(); |
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1537 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1538 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1538 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1539 | } | 1539 | } |
1540 | #ifdef DESKTOP_VERSION | 1540 | #ifdef DESKTOP_VERSION |
1541 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1541 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1542 | #endif | 1542 | #endif |
1543 | updateView(); | 1543 | updateView(); |
1544 | } | 1544 | } |
1545 | 1545 | ||
1546 | void KOMonthView::updateDayLabels() | 1546 | void KOMonthView::updateDayLabels() |
1547 | { | 1547 | { |
1548 | 1548 | ||
1549 | QPtrVector<QLabel> *mDayLabelsT; | 1549 | QPtrVector<QLabel> *mDayLabelsT; |
1550 | 1550 | ||
1551 | mDayLabelsT = &mDayLabelsW; | 1551 | mDayLabelsT = &mDayLabelsW; |
1552 | for (int i = 0; i < 7; i++) { | 1552 | for (int i = 0; i < 7; i++) { |
1553 | { | 1553 | { |
1554 | bool show = mShortDayLabelsW; | 1554 | bool show = mShortDayLabelsW; |
1555 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1555 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1556 | show = true; | 1556 | show = true; |
1557 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1557 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1558 | } | 1558 | } |
1559 | } | 1559 | } |
1560 | mDayLabelsT = &mDayLabels; | 1560 | mDayLabelsT = &mDayLabels; |
1561 | for (int i = 0; i < 7; i++) { | 1561 | for (int i = 0; i < 7; i++) { |
1562 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1562 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1563 | bool show = mShortDayLabelsM; | 1563 | bool show = mShortDayLabelsM; |
1564 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1564 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1565 | show = true; | 1565 | show = true; |
1566 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1566 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1567 | } else { | 1567 | } else { |
1568 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1568 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1569 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1569 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1570 | 1570 | ||
1571 | } | 1571 | } |
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | void KOMonthView::clearList() | 1576 | void KOMonthView::clearList() |
1577 | { | 1577 | { |
1578 | unsigned int i; | 1578 | unsigned int i; |
1579 | for( i = 0; i < mCells.size(); ++i ) { | 1579 | for( i = 0; i < mCells.size(); ++i ) { |
1580 | mCells[i]->clear(); | 1580 | mCells[i]->clear(); |
1581 | } | 1581 | } |
1582 | for( i = 0; i < mCellsW.size(); ++i ) { | 1582 | for( i = 0; i < mCellsW.size(); ++i ) { |
1583 | mCellsW[i]->clear(); | 1583 | mCellsW[i]->clear(); |
1584 | } | 1584 | } |
1585 | } | 1585 | } |
1586 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1586 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1587 | { | 1587 | { |
1588 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1588 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1589 | 1589 | ||
1590 | QPtrVector<MonthViewCell> *cells; | 1590 | QPtrVector<MonthViewCell> *cells; |
1591 | QPtrVector<QLabel> *dayLabels; | 1591 | QPtrVector<QLabel> *dayLabels; |
1592 | QPtrVector<KOWeekButton> *weekLabels; | 1592 | QPtrVector<KOWeekButton> *weekLabels; |
1593 | uint weekNum = 6; | 1593 | uint weekNum = 6; |
1594 | mStartDate = start; | 1594 | mStartDate = start; |
1595 | if ( mShowWeekView ) { | 1595 | if ( mShowWeekView ) { |
1596 | weekNum = 1; | 1596 | weekNum = 1; |
1597 | cells = &mCellsW; | 1597 | cells = &mCellsW; |
1598 | dayLabels = &mDayLabelsW; | 1598 | dayLabels = &mDayLabelsW; |
1599 | weekLabels = &mWeekLabelsW; | 1599 | weekLabels = &mWeekLabelsW; |
1600 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1600 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1601 | mStartDate = mStartDate.addDays( 1 ); | 1601 | mStartDate = mStartDate.addDays( 1 ); |
1602 | } | 1602 | } |
1603 | } else { | 1603 | } else { |
1604 | cells = &mCells; | 1604 | cells = &mCells; |
1605 | dayLabels = &mDayLabels; | 1605 | dayLabels = &mDayLabels; |
1606 | weekLabels = &mWeekLabels; | 1606 | weekLabels = &mWeekLabels; |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1609 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1610 | 1610 | ||
1611 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1611 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1612 | mWeekStartsMonday = true; | 1612 | mWeekStartsMonday = true; |
1613 | } | 1613 | } |
1614 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1614 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1615 | 1615 | ||
1616 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1616 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1617 | mStartDate = mStartDate.addDays( -1 ); | 1617 | mStartDate = mStartDate.addDays( -1 ); |
1618 | } | 1618 | } |
1619 | uint i; | 1619 | uint i; |
1620 | for( i = 0; i < (*cells).size(); ++i ) { | 1620 | for( i = 0; i < (*cells).size(); ++i ) { |
1621 | QDate date = mStartDate.addDays( i ); | 1621 | QDate date = mStartDate.addDays( i ); |
1622 | (*cells)[i]->setDate( date ); | 1622 | (*cells)[i]->setDate( date ); |
1623 | 1623 | ||
1624 | #ifndef KORG_NOPLUGINS | 1624 | #ifndef KORG_NOPLUGINS |
1625 | // add holiday, if present | 1625 | // add holiday, if present |
1626 | QString hstring(KOCore::self()->holiday(date)); | 1626 | QString hstring(KOCore::self()->holiday(date)); |
1627 | (*cells)[i]->setHoliday( hstring ); | 1627 | (*cells)[i]->setHoliday( hstring ); |
1628 | #endif | 1628 | #endif |
1629 | 1629 | ||
1630 | } | 1630 | } |
1631 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1631 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1632 | for( i = 0; i < weekNum; ++i ) { | 1632 | for( i = 0; i < weekNum; ++i ) { |
1633 | int wno; | 1633 | int wno; |
1634 | // remember, according to ISO 8601, the first week of the year is the | 1634 | // remember, according to ISO 8601, the first week of the year is the |
1635 | // first week that contains a thursday. Thus we must subtract off 4, | 1635 | // first week that contains a thursday. Thus we must subtract off 4, |
1636 | // not just 1. | 1636 | // not just 1. |
1637 | int dayOfYear = date.dayOfYear(); | 1637 | int dayOfYear = date.dayOfYear(); |
1638 | if (dayOfYear % 7 != 0) | 1638 | if (dayOfYear % 7 != 0) |
1639 | wno = dayOfYear / 7 + 1; | 1639 | wno = dayOfYear / 7 + 1; |
1640 | else | 1640 | else |
1641 | wno =dayOfYear / 7; | 1641 | wno =dayOfYear / 7; |
1642 | (*weekLabels)[i]->setWeekNum( wno ); | 1642 | (*weekLabels)[i]->setWeekNum( wno ); |
1643 | date = date.addDays( 7 ); | 1643 | date = date.addDays( 7 ); |
1644 | } | 1644 | } |
1645 | updateView(); | 1645 | updateView(); |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | void KOMonthView::showEvents(QPtrList<Event>) | 1648 | void KOMonthView::showEvents(QPtrList<Event>) |
1649 | { | 1649 | { |
1650 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1650 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | void KOMonthView::changeEventDisplay(Event *, int) | 1653 | void KOMonthView::changeEventDisplay(Event *, int) |
1654 | { | 1654 | { |
1655 | // this should be re-written to be much more efficient, but this | 1655 | // this should be re-written to be much more efficient, but this |
1656 | // quick-and-dirty-hack gets the job done for right now. | 1656 | // quick-and-dirty-hack gets the job done for right now. |
1657 | //qDebug("KOMonthView::changeEventDisplay "); | 1657 | //qDebug("KOMonthView::changeEventDisplay "); |
1658 | updateView(); | 1658 | updateView(); |
1659 | } | 1659 | } |
1660 | 1660 | ||
1661 | void KOMonthView::updateView() | 1661 | void KOMonthView::updateView() |
1662 | { | 1662 | { |
1663 | 1663 | ||
1664 | if ( !updatePossible ) | 1664 | if ( !updatePossible ) |
1665 | return; | 1665 | return; |
1666 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1666 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1667 | //QTime ti; | 1667 | //QTime ti; |
1668 | //ti.start(); | 1668 | //ti.start(); |
1669 | clearSelection(); | 1669 | clearSelection(); |
1670 | QPtrVector<MonthViewCell> *cells; | 1670 | QPtrVector<MonthViewCell> *cells; |
1671 | if ( mShowWeekView ) { | 1671 | if ( mShowWeekView ) { |
1672 | cells = &mCellsW; | 1672 | cells = &mCellsW; |
1673 | } else { | 1673 | } else { |
1674 | cells = &mCells; | 1674 | cells = &mCells; |
1675 | } | 1675 | } |
1676 | #if 1 | 1676 | #if 1 |
1677 | int i; | 1677 | int i; |
1678 | int timeSpan = (*cells).size()-1; | 1678 | int timeSpan = (*cells).size()-1; |
1679 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1679 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1680 | timeSpan = 6; | 1680 | timeSpan = 6; |
1681 | for( i = 0; i < timeSpan + 1; ++i ) { | 1681 | for( i = 0; i < timeSpan + 1; ++i ) { |
1682 | (*cells)[i]->startUpdateCell(); | 1682 | (*cells)[i]->startUpdateCell(); |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | QPtrList<Event> events = calendar()->events(); | 1685 | QPtrList<Event> events = calendar()->events(); |
1686 | Event *event; | 1686 | Event *event; |
1687 | QDateTime dt; | 1687 | QDateTime dt; |
1688 | QDate endDate = mStartDate.addDays( timeSpan ); | 1688 | QDate endDate = mStartDate.addDays( timeSpan ); |
1689 | for( event = events.first(); event; event = events.next() ) { // for event | 1689 | for( event = events.first(); event; event = events.next() ) { // for event |
1690 | if ( event->doesRecur() ) { | 1690 | if ( event->doesRecur() ) { |
1691 | bool last; | 1691 | bool last; |
1692 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1692 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1693 | QDateTime incidenceEnd; | 1693 | QDateTime incidenceEnd; |
1694 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1694 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1695 | bool invalid = false; | 1695 | bool invalid = false; |
1696 | while( true ) { | 1696 | while( true ) { |
1697 | if ( incidenceStart.isValid() ) { | 1697 | if ( incidenceStart.isValid() ) { |
1698 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1698 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1699 | int st = incidenceStart.date().daysTo( endDate ); | 1699 | int st = incidenceStart.date().daysTo( endDate ); |
1700 | if ( st >= 0 ) { // start before timeend | 1700 | if ( st >= 0 ) { // start before timeend |
1701 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1701 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1702 | if ( end >= 0 ) { // end after timestart --- got one! | 1702 | if ( end >= 0 ) { // end after timestart --- got one! |
1703 | //normalize | 1703 | //normalize |
1704 | st = timeSpan - st; | 1704 | st = timeSpan - st; |
1705 | if ( st < 0 ) st = 0; | 1705 | if ( st < 0 ) st = 0; |
1706 | if ( end > timeSpan ) end = timeSpan; | 1706 | if ( end > timeSpan ) end = timeSpan; |
1707 | int iii; | 1707 | int iii; |
1708 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1708 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1709 | for ( iii = st;iii<= end;++iii) | 1709 | for ( iii = st;iii<= end;++iii) |
1710 | (*cells)[iii]->insertEvent( event ); | 1710 | (*cells)[iii]->insertEvent( event ); |
1711 | } | 1711 | } |
1712 | } | 1712 | } |
1713 | } else { | 1713 | } else { |
1714 | if ( invalid ) | 1714 | if ( invalid ) |
1715 | break; | 1715 | break; |
1716 | invalid = true; | 1716 | invalid = true; |
1717 | //qDebug("invalid %s", event->summary().latin1()); | 1717 | //qDebug("invalid %s", event->summary().latin1()); |
1718 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1718 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1719 | } | 1719 | } |
1720 | if ( last ) | 1720 | if ( last ) |
1721 | break; | 1721 | break; |
1722 | bool ok; | 1722 | bool ok; |
1723 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1723 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1724 | if ( ! ok ) | 1724 | if ( ! ok ) |
1725 | break; | 1725 | break; |
1726 | if ( incidenceStart.date() > endDate ) | 1726 | if ( incidenceStart.date() > endDate ) |
1727 | break; | 1727 | break; |
1728 | } | 1728 | } |
1729 | } else { // no recur | 1729 | } else { // no recur |
1730 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1730 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1731 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1731 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1732 | continue; | 1732 | continue; |
1733 | int st = event->dtStart().date().daysTo( endDate ); | 1733 | int st = event->dtStart().date().daysTo( endDate ); |
1734 | if ( st >= 0 ) { // start before timeend | 1734 | if ( st >= 0 ) { // start before timeend |
1735 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1735 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1736 | if ( end >= 0 ) { // end after timestart --- got one! | 1736 | if ( end >= 0 ) { // end after timestart --- got one! |
1737 | //normalize | 1737 | //normalize |
1738 | st = timeSpan - st; | 1738 | st = timeSpan - st; |
1739 | if ( st < 0 ) st = 0; | 1739 | if ( st < 0 ) st = 0; |
1740 | if ( end > timeSpan ) end = timeSpan; | 1740 | if ( end > timeSpan ) end = timeSpan; |
1741 | int iii; | 1741 | int iii; |
1742 | for ( iii = st;iii<= end;++iii) | 1742 | for ( iii = st;iii<= end;++iii) |
1743 | (*cells)[iii]->insertEvent( event ); | 1743 | (*cells)[iii]->insertEvent( event ); |
1744 | } | 1744 | } |
1745 | } | 1745 | } |
1746 | } | 1746 | } |
1747 | } | 1747 | } |
1748 | // insert due todos | 1748 | // insert due todos |
1749 | QPtrList<Todo> todos = calendar()->todos( ); | 1749 | QPtrList<Todo> todos = calendar()->todos( ); |
1750 | Todo *todo; | 1750 | Todo *todo; |
1751 | for(todo = todos.first(); todo; todo = todos.next()) { | 1751 | for(todo = todos.first(); todo; todo = todos.next()) { |
1752 | //insertTodo( todo ); | 1752 | //insertTodo( todo ); |
1753 | if ( todo->hasDueDate() ) { | 1753 | if ( todo->hasDueDate() ) { |
1754 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1754 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1755 | if ( day >= 0 && day < timeSpan + 1) { | 1755 | if ( day >= 0 && day < timeSpan + 1) { |
1756 | (*cells)[day]->insertTodo( todo ); | 1756 | (*cells)[day]->insertTodo( todo ); |
1757 | } | 1757 | } |
1758 | } | 1758 | } |
1759 | } | 1759 | } |
1760 | 1760 | ||
1761 | for( i = 0; i < timeSpan+1; ++i ) { | 1761 | for( i = 0; i < timeSpan+1; ++i ) { |
1762 | (*cells)[i]->finishUpdateCell(); | 1762 | (*cells)[i]->finishUpdateCell(); |
1763 | } | 1763 | } |
1764 | processSelectionChange(); | 1764 | processSelectionChange(); |
1765 | //qApp->processEvents(); | 1765 | //qApp->processEvents(); |
1766 | for( i = 0; i < timeSpan+1; ++i ) { | 1766 | for( i = 0; i < timeSpan+1; ++i ) { |
1767 | //(*cells)[i]->repaintfinishUpdateCell(); | 1767 | //(*cells)[i]->repaintfinishUpdateCell(); |
1768 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); | 1768 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); |
1769 | } | 1769 | } |
1770 | setKeyBFocus(); | 1770 | setKeyBFocus(); |
1771 | #else | 1771 | #else |
1772 | // old code | 1772 | // old code |
1773 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1773 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1774 | int i; | 1774 | int i; |
1775 | for( i = 0; i < (*cells).count(); ++i ) { | 1775 | for( i = 0; i < (*cells).count(); ++i ) { |
1776 | (*cells)[i]->updateCell(); | 1776 | (*cells)[i]->updateCell(); |
1777 | } | 1777 | } |
1778 | 1778 | ||
1779 | //qDebug("KOMonthView::updateView() "); | 1779 | //qDebug("KOMonthView::updateView() "); |
1780 | processSelectionChange(); | 1780 | processSelectionChange(); |
1781 | // qDebug("---------------------------------------------------------------------+ "); | 1781 | // qDebug("---------------------------------------------------------------------+ "); |
1782 | (*cells)[0]->setFocus(); | 1782 | (*cells)[0]->setFocus(); |
1783 | #endif | 1783 | #endif |
1784 | 1784 | ||
1785 | //qDebug("update time %d ", ti.elapsed()); | 1785 | //qDebug("update time %d ", ti.elapsed()); |
1786 | } | 1786 | } |
1787 | 1787 | ||
1788 | void KOMonthView::setKeyBoardFocus() | 1788 | void KOMonthView::setKeyBoardFocus() |
1789 | { | 1789 | { |
1790 | //qDebug("KOMonthView::setKeyBoardFocus() "); | 1790 | //qDebug("KOMonthView::setKeyBoardFocus() "); |
1791 | bool shootAgain = false; | 1791 | bool shootAgain = false; |
1792 | if ( mShowWeekView ) { | 1792 | if ( mShowWeekView ) { |
1793 | shootAgain = !mWeekLabelsW[1]->hasFocus(); | 1793 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1794 | mWeekLabelsW[1]->setFocus(); | 1794 | mWeekLabelsW[1]->setFocus(); |
1795 | } | 1795 | } |
1796 | else { | 1796 | else { |
1797 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); | 1797 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1798 | mWeekLabels[mNumWeeks]->setFocus(); | 1798 | mWeekLabels[mNumWeeks]->setFocus(); |
1799 | } | 1799 | } |
1800 | --mKBFcounter; | 1800 | --mKBFcounter; |
1801 | if ( shootAgain && mKBFcounter > 0 ) { | 1801 | if ( shootAgain && mKBFcounter > 0 ) { |
1802 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); | 1802 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); |
1803 | } | 1803 | } |
1804 | } | 1804 | } |
1805 | void KOMonthView::setKeyBFocus() | 1805 | void KOMonthView::setKeyBFocus() |
1806 | { | 1806 | { |
1807 | //qDebug("KOMonthView::setKeyBFocus() "); | 1807 | //qDebug("KOMonthView::setKeyBFocus() "); |
1808 | mKBFcounter = 10; | 1808 | mKBFcounter = 10; |
1809 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1809 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1810 | } | 1810 | } |
1811 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1811 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1812 | { | 1812 | { |
1813 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1813 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1814 | if ( isVisible() ) { | 1814 | if ( isVisible() ) { |
1815 | //qDebug("KOMonthView::isVisible "); | 1815 | //qDebug("KOMonthView::isVisible "); |
1816 | slotComputeLayout(); | 1816 | slotComputeLayout(); |
1817 | } else | 1817 | } else |
1818 | mComputeLayoutTimer->start( 100 ); | 1818 | mComputeLayoutTimer->start( 100 ); |
1819 | if ( e ) | 1819 | if ( e ) |
1820 | KOEventView::resizeEvent( e ); | 1820 | KOEventView::resizeEvent( e ); |
1821 | } | 1821 | } |
1822 | 1822 | ||
1823 | void KOMonthView::slotComputeLayout() | 1823 | void KOMonthView::slotComputeLayout() |
1824 | { | 1824 | { |
1825 | mComputeLayoutTimer->stop(); | 1825 | mComputeLayoutTimer->stop(); |
1826 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1826 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1827 | computeLayout(); | 1827 | computeLayout(); |
1828 | clPending = true; | 1828 | clPending = true; |
1829 | setKeyBFocus(); | 1829 | setKeyBFocus(); |
1830 | } | 1830 | } |
1831 | 1831 | ||
1832 | void KOMonthView::doComputeLayoutWeek() | 1832 | void KOMonthView::doComputeLayoutWeek() |
1833 | { | 1833 | { |
1834 | 1834 | ||
1835 | int daysToShow; | 1835 | int daysToShow; |
1836 | bool combinedSatSun = false; | 1836 | bool combinedSatSun = false; |
1837 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1837 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1838 | daysToShow = 6; | 1838 | daysToShow = 6; |
1839 | combinedSatSun = true; | 1839 | combinedSatSun = true; |
1840 | } | 1840 | } |
1841 | int wid = width();//e | 1841 | int wid = width();//e |
1842 | int hei = height()-1-mNavigatorBar->height(); | 1842 | int hei = height()-1-mNavigatorBar->height(); |
1843 | #ifdef DESKTOP_VERSION | 1843 | #ifdef DESKTOP_VERSION |
1844 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { | 1844 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { |
1845 | daysToShow = 2; | 1845 | daysToShow = 2; |
1846 | } else | 1846 | } else |
1847 | #endif | 1847 | #endif |
1848 | { | 1848 | { |
1849 | if ( wid < hei ) | 1849 | if ( wid < hei + 40 ) |
1850 | daysToShow = 2; | 1850 | daysToShow = 2; |
1851 | else | 1851 | else |
1852 | daysToShow = 3; | 1852 | daysToShow = 3; |
1853 | } | 1853 | } |
1854 | bool landscape = (daysToShow == 3); | 1854 | bool landscape = (daysToShow == 3); |
1855 | mShowSatSunComp = true; | 1855 | mShowSatSunComp = true; |
1856 | combinedSatSun = true; | 1856 | combinedSatSun = true; |
1857 | 1857 | ||
1858 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1858 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1859 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1859 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1860 | int weeklabelwid = fm.width( "888" ); | 1860 | int weeklabelwid = fm.width( "888" ); |
1861 | wid -= weeklabelwid; | 1861 | wid -= weeklabelwid; |
1862 | 1862 | ||
1863 | int colWid = wid / daysToShow; | 1863 | int colWid = wid / daysToShow; |
1864 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1864 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1865 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1865 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1866 | int colModulo = wid % daysToShow; | 1866 | int colModulo = wid % daysToShow; |
1867 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1867 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1868 | //qDebug("rowmod %d ", rowModulo); | 1868 | //qDebug("rowmod %d ", rowModulo); |
1869 | int i; | 1869 | int i; |
1870 | int x,y,w,h; | 1870 | int x,y,w,h; |
1871 | x= 0; | 1871 | x= 0; |
1872 | y= 0; | 1872 | y= 0; |
1873 | w = colWid; | 1873 | w = colWid; |
1874 | h = dayLabelHei ; | 1874 | h = dayLabelHei ; |
1875 | for ( i = 0; i < 7; i++) { | 1875 | for ( i = 0; i < 7; i++) { |
1876 | if ( i && !( i % daysToShow) && i < 6) { | 1876 | if ( i && !( i % daysToShow) && i < 6) { |
1877 | y += hei/(5-daysToShow); | 1877 | y += hei/(5-daysToShow); |
1878 | x = 0; | 1878 | x = 0; |
1879 | w = colWid; | 1879 | w = colWid; |
1880 | } | 1880 | } |
1881 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1881 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1882 | ++w; | 1882 | ++w; |
1883 | } | 1883 | } |
1884 | int xC,yC,wC,hC; | 1884 | int xC,yC,wC,hC; |
1885 | if ( i >= 5 ) { | 1885 | if ( i >= 5 ) { |
1886 | int wi = width() - x - weeklabelwid; | 1886 | int wi = width() - x - weeklabelwid; |
1887 | if ( i == 5 ) { | 1887 | if ( i == 5 ) { |
1888 | xC = x+weeklabelwid; | 1888 | xC = x+weeklabelwid; |
1889 | yC = y; | 1889 | yC = y; |
1890 | wC = wi/2+wi%2; | 1890 | wC = wi/2+wi%2; |
1891 | hC = h; | 1891 | hC = h; |
1892 | } else { | 1892 | } else { |
1893 | xC = x+weeklabelwid; | 1893 | xC = x+weeklabelwid; |
1894 | yC = y; | 1894 | yC = y; |
1895 | wC = wi; | 1895 | wC = wi; |
1896 | hC = h; | 1896 | hC = h; |
1897 | } | 1897 | } |
1898 | x = x - w + wi - (wi/2 ); | 1898 | x = x - w + wi - (wi/2 ); |
1899 | } | 1899 | } |
1900 | else { | 1900 | else { |
1901 | int wi = w; | 1901 | int wi = w; |
1902 | if ( !(( i+1) % daysToShow)) { | 1902 | if ( !(( i+1) % daysToShow)) { |
1903 | wi = width() - x - weeklabelwid; | 1903 | wi = width() - x - weeklabelwid; |
1904 | } | 1904 | } |
1905 | xC = x+weeklabelwid; | 1905 | xC = x+weeklabelwid; |
1906 | yC = y; | 1906 | yC = y; |
1907 | wC = wi; | 1907 | wC = wi; |
1908 | hC = h; | 1908 | hC = h; |
1909 | } | 1909 | } |
1910 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); | 1910 | mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); |
1911 | 1911 | ||
1912 | 1912 | ||
1913 | x += w; | 1913 | x += w; |
1914 | } | 1914 | } |
1915 | x= 0; | 1915 | x= 0; |
1916 | y= dayLabelHei; | 1916 | y= dayLabelHei; |
1917 | w = colWid; | 1917 | w = colWid; |
1918 | h = cellHei; | 1918 | h = cellHei; |
1919 | int max = 0; | 1919 | int max = 0; |
1920 | int w_count = mCellsW.count(); | 1920 | int w_count = mCellsW.count(); |
1921 | for ( i = 0; i < w_count; ++i) { | 1921 | for ( i = 0; i < w_count; ++i) { |
1922 | if ( i > 6 ) { | 1922 | if ( i > 6 ) { |
1923 | mCellsW[i]->hide(); | 1923 | mCellsW[i]->hide(); |
1924 | continue; | 1924 | continue; |
1925 | } | 1925 | } |
1926 | 1926 | ||
1927 | w = colWid; | 1927 | w = colWid; |
1928 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1928 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1929 | ++w; | 1929 | ++w; |
1930 | } | 1930 | } |
1931 | if ( i == (daysToShow-1-rowModulo)*7) | 1931 | if ( i == (daysToShow-1-rowModulo)*7) |
1932 | ++h; | 1932 | ++h; |
1933 | 1933 | ||
1934 | int xC,yC,wC,hC; | 1934 | int xC,yC,wC,hC; |
1935 | if ( i >= 5 ) { | 1935 | if ( i >= 5 ) { |
1936 | if ( i ==5 ) { | 1936 | if ( i ==5 ) { |
1937 | max = h/2; | 1937 | max = h/2; |
1938 | xC = x+weeklabelwid; | 1938 | xC = x+weeklabelwid; |
1939 | yC = y; | 1939 | yC = y; |
1940 | wC = w; | 1940 | wC = w; |
1941 | hC = max; | 1941 | hC = max; |
1942 | x -= w ;y += h/2; | 1942 | x -= w ;y += h/2; |
1943 | } else { | 1943 | } else { |
1944 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1944 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1945 | ++w; | 1945 | ++w; |
1946 | } | 1946 | } |
1947 | max = h-h/2; | 1947 | max = h-h/2; |
1948 | xC = x+weeklabelwid; | 1948 | xC = x+weeklabelwid; |
1949 | yC = y; | 1949 | yC = y; |
1950 | wC = w; | 1950 | wC = w; |
1951 | hC = max; | 1951 | hC = max; |
1952 | y -= h/2; | 1952 | y -= h/2; |
1953 | } | 1953 | } |
1954 | } else { | 1954 | } else { |
1955 | max = h; | 1955 | max = h; |
1956 | xC = x+weeklabelwid; | 1956 | xC = x+weeklabelwid; |
1957 | yC = y; | 1957 | yC = y; |
1958 | wC = w; | 1958 | wC = w; |
1959 | hC = h; | 1959 | hC = h; |
1960 | } | 1960 | } |
1961 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); | 1961 | mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); |
1962 | 1962 | ||
1963 | 1963 | ||
1964 | x += w; | 1964 | x += w; |
1965 | if ( x + w/2 > wid ) { | 1965 | if ( x + w/2 > wid ) { |
1966 | x = 0; | 1966 | x = 0; |
1967 | y += h+dayLabelHei ; | 1967 | y += h+dayLabelHei ; |
1968 | } | 1968 | } |
1969 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1969 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1970 | } | 1970 | } |
1971 | y= dayLabelHei; | 1971 | y= dayLabelHei; |
1972 | h = cellHei ; | 1972 | h = cellHei ; |
1973 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1973 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1974 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1974 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1975 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1975 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1976 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1976 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1977 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1977 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1978 | updateDayLabels(); | 1978 | updateDayLabels(); |
1979 | //bool forceUpdate = !updatePossible; | 1979 | //bool forceUpdate = !updatePossible; |
1980 | updatePossible = true; | 1980 | updatePossible = true; |
1981 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1981 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1982 | //if ( forceUpdate ) | 1982 | //if ( forceUpdate ) |
1983 | // updateView(); | 1983 | // updateView(); |
1984 | } | 1984 | } |
1985 | void KOMonthView::computeLayoutWeek() | 1985 | void KOMonthView::computeLayoutWeek() |
1986 | { | 1986 | { |
1987 | static int lastWid = 0; | 1987 | static int lastWid = 0; |
1988 | static int lastHei = 0; | 1988 | static int lastHei = 0; |
1989 | int tWid = topLevelWidget()->size().width(); | 1989 | int tWid = topLevelWidget()->size().width(); |
1990 | int tHei = topLevelWidget()->size().height(); | 1990 | int tHei = topLevelWidget()->size().height(); |
1991 | int wid = width();//e | 1991 | int wid = width();//e |
1992 | int hei = height()-1-mNavigatorBar->height(); | 1992 | int hei = height()-1-mNavigatorBar->height(); |
1993 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1993 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1994 | return; | 1994 | return; |
1995 | 1995 | ||
1996 | if ( lastWid == width() && lastHei == height() ) { | 1996 | if ( lastWid == width() && lastHei == height() ) { |
1997 | //qDebug("KOListWeekView::No compute layout needed "); | 1997 | //qDebug("KOListWeekView::No compute layout needed "); |
1998 | return; | 1998 | return; |
1999 | } | 1999 | } |
2000 | lastWid = width(); | 2000 | lastWid = width(); |
2001 | lastHei = height(); | 2001 | lastHei = height(); |
2002 | doComputeLayoutWeek(); | 2002 | doComputeLayoutWeek(); |
2003 | } | 2003 | } |
2004 | int KOMonthView::mapWeekLayout( int index, bool landscape ) | 2004 | int KOMonthView::mapWeekLayout( int index, bool landscape ) |
2005 | { | 2005 | { |
2006 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) | 2006 | if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) |
2007 | return index; | 2007 | return index; |
2008 | int diff = 0; | 2008 | int diff = 0; |
2009 | if ( !landscape ) diff = 1; | 2009 | if ( !landscape ) diff = 1; |
2010 | switch( index ) { | 2010 | switch( index ) { |
2011 | case 0: | 2011 | case 0: |
2012 | case 5: | 2012 | case 5: |
2013 | case 6: | 2013 | case 6: |
2014 | return index; | 2014 | return index; |
2015 | break; | 2015 | break; |
2016 | case 1: | 2016 | case 1: |
2017 | return 2+diff; | 2017 | return 2+diff; |
2018 | break; | 2018 | break; |
2019 | case 2: | 2019 | case 2: |
2020 | return 4-(3*diff); | 2020 | return 4-(3*diff); |
2021 | break; | 2021 | break; |
2022 | case 3: | 2022 | case 3: |
2023 | return 1+(3*diff); | 2023 | return 1+(3*diff); |
2024 | break; | 2024 | break; |
2025 | case 4: | 2025 | case 4: |
2026 | return 3-diff; | 2026 | return 3-diff; |
2027 | break; | 2027 | break; |
2028 | default: | 2028 | default: |
2029 | qDebug("KO: Error in mapping week layout "); | 2029 | qDebug("KO: Error in mapping week layout "); |
2030 | return index; | 2030 | return index; |
2031 | break; | 2031 | break; |
2032 | } | 2032 | } |
2033 | return index; | 2033 | return index; |
2034 | } | 2034 | } |
2035 | void KOMonthView::computeLayout() | 2035 | void KOMonthView::computeLayout() |
2036 | { | 2036 | { |
2037 | 2037 | ||
2038 | 2038 | ||
2039 | static int lastWid = 0; | 2039 | static int lastWid = 0; |
2040 | static int lastHei = 0; | 2040 | static int lastHei = 0; |
2041 | 2041 | ||
2042 | if ( mShowWeekView ){ | 2042 | if ( mShowWeekView ){ |
2043 | computeLayoutWeek(); | 2043 | computeLayoutWeek(); |
2044 | return; | 2044 | return; |
2045 | } | 2045 | } |
2046 | int daysToShow = 7; | 2046 | int daysToShow = 7; |
2047 | bool combinedSatSun = false; | 2047 | bool combinedSatSun = false; |
2048 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 2048 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
2049 | daysToShow = 6; | 2049 | daysToShow = 6; |
2050 | combinedSatSun = true; | 2050 | combinedSatSun = true; |
2051 | } | 2051 | } |
2052 | int tWid = topLevelWidget()->size().width(); | 2052 | int tWid = topLevelWidget()->size().width(); |
2053 | int tHei = topLevelWidget()->size().height(); | 2053 | int tHei = topLevelWidget()->size().height(); |
2054 | 2054 | ||
2055 | int wid = width();//e | 2055 | int wid = width();//e |
2056 | int hei = height()-1-mNavigatorBar->height(); | 2056 | int hei = height()-1-mNavigatorBar->height(); |
2057 | 2057 | ||
2058 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 2058 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
2059 | return; | 2059 | return; |
2060 | } | 2060 | } |
2061 | if ( lastWid == width() && lastHei == height() ){ | 2061 | if ( lastWid == width() && lastHei == height() ){ |
2062 | //qDebug("KOMonthview::No compute layout needed "); | 2062 | //qDebug("KOMonthview::No compute layout needed "); |
2063 | return; | 2063 | return; |
2064 | } | 2064 | } |
2065 | 2065 | ||
2066 | lastWid = width(); | 2066 | lastWid = width(); |
2067 | lastHei = height(); | 2067 | lastHei = height(); |
2068 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 2068 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
2069 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 2069 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
2070 | int weeklabelwid = fm.width( "888" ); | 2070 | int weeklabelwid = fm.width( "888" ); |
2071 | wid -= weeklabelwid; | 2071 | wid -= weeklabelwid; |
2072 | 2072 | ||
2073 | int colWid = wid / daysToShow; | 2073 | int colWid = wid / daysToShow; |
2074 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 2074 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
2075 | int cellHei = (hei - dayLabelHei) /6; | 2075 | int cellHei = (hei - dayLabelHei) /6; |
2076 | int colModulo = wid % daysToShow; | 2076 | int colModulo = wid % daysToShow; |
2077 | int rowModulo = (hei- dayLabelHei) % 6; | 2077 | int rowModulo = (hei- dayLabelHei) % 6; |
2078 | //qDebug("rowmod %d ", rowModulo); | 2078 | //qDebug("rowmod %d ", rowModulo); |
2079 | int i; | 2079 | int i; |
2080 | int x,y,w,h; | 2080 | int x,y,w,h; |
2081 | x= 0; | 2081 | x= 0; |
2082 | y= 0; | 2082 | y= 0; |
2083 | w = colWid; | 2083 | w = colWid; |
2084 | h = dayLabelHei ; | 2084 | h = dayLabelHei ; |
2085 | for ( i = 0; i < 7; i++) { | 2085 | for ( i = 0; i < 7; i++) { |
2086 | if ( i == daysToShow-colModulo ) | 2086 | if ( i == daysToShow-colModulo ) |
2087 | ++w; | 2087 | ++w; |
2088 | if ( combinedSatSun ) { | 2088 | if ( combinedSatSun ) { |
2089 | if ( i >= daysToShow-1 ) { | 2089 | if ( i >= daysToShow-1 ) { |
2090 | 2090 | ||
2091 | if ( i == 6 ) | 2091 | if ( i == 6 ) |
2092 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); | 2092 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); |
2093 | else | 2093 | else |
2094 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 2094 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
2095 | x -= w/2 ; | 2095 | x -= w/2 ; |
2096 | } | 2096 | } |
2097 | else | 2097 | else |
2098 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2098 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2099 | } else | 2099 | } else |
2100 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 2100 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
2101 | x += w; | 2101 | x += w; |
2102 | } | 2102 | } |
2103 | x= 0; | 2103 | x= 0; |
2104 | y= dayLabelHei; | 2104 | y= dayLabelHei; |
2105 | w = colWid; | 2105 | w = colWid; |
2106 | h = cellHei ; | 2106 | h = cellHei ; |
2107 | int max = 0; | 2107 | int max = 0; |
2108 | int mc_count = mCells.count(); | 2108 | int mc_count = mCells.count(); |
2109 | for ( i = 0; i < mc_count; ++i) { | 2109 | for ( i = 0; i < mc_count; ++i) { |
2110 | //qDebug("iii %d ", i); | 2110 | //qDebug("iii %d ", i); |
2111 | w = colWid; | 2111 | w = colWid; |
2112 | if ( ((i) % 7) >= 7-colModulo ) { | 2112 | if ( ((i) % 7) >= 7-colModulo ) { |
2113 | ++w; | 2113 | ++w; |
2114 | } | 2114 | } |
2115 | if ( i == (6-rowModulo)*7) | 2115 | if ( i == (6-rowModulo)*7) |
2116 | ++h; | 2116 | ++h; |
2117 | if ( combinedSatSun ) { | 2117 | if ( combinedSatSun ) { |
2118 | if ( (i)%7 >= daysToShow-1 ) { | 2118 | if ( (i)%7 >= daysToShow-1 ) { |
2119 | if ( (i)%7 == daysToShow-1 ) { | 2119 | if ( (i)%7 == daysToShow-1 ) { |
2120 | w = width()-x-weeklabelwid; | 2120 | w = width()-x-weeklabelwid; |
2121 | max = h/2; | 2121 | max = h/2; |
2122 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2122 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2123 | x -= w ;y += h/2; | 2123 | x -= w ;y += h/2; |
2124 | } else { | 2124 | } else { |
2125 | w = width()-x-weeklabelwid; | 2125 | w = width()-x-weeklabelwid; |
2126 | max = h-h/2; | 2126 | max = h-h/2; |
2127 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 2127 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
2128 | y -= h/2; | 2128 | y -= h/2; |
2129 | } | 2129 | } |
2130 | } else { | 2130 | } else { |
2131 | max = h; | 2131 | max = h; |
2132 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2132 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2133 | } | 2133 | } |
2134 | 2134 | ||
2135 | } | 2135 | } |
2136 | else { | 2136 | else { |
2137 | max = h; | 2137 | max = h; |
2138 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 2138 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
2139 | } | 2139 | } |
2140 | x += w; | 2140 | x += w; |
2141 | if ( x + w/2 > wid ) { | 2141 | if ( x + w/2 > wid ) { |
2142 | x = 0; | 2142 | x = 0; |
2143 | y += h; | 2143 | y += h; |
2144 | } | 2144 | } |
2145 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 2145 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
2146 | } | 2146 | } |
2147 | y= dayLabelHei; | 2147 | y= dayLabelHei; |
2148 | h = cellHei ; | 2148 | h = cellHei ; |
2149 | for ( i = 0; i < 6; i++) { | 2149 | for ( i = 0; i < 6; i++) { |
2150 | if ( i == (6-rowModulo)) | 2150 | if ( i == (6-rowModulo)) |
2151 | ++h; | 2151 | ++h; |
2152 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 2152 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
2153 | y += h; | 2153 | y += h; |
2154 | } | 2154 | } |
2155 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 2155 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
2156 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 2156 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
2157 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 2157 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
2158 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 2158 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
2159 | updateDayLabels(); | 2159 | updateDayLabels(); |
2160 | //bool forceUpdate = !updatePossible; | 2160 | //bool forceUpdate = !updatePossible; |
2161 | updatePossible = true; | 2161 | updatePossible = true; |
2162 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 2162 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
2163 | } | 2163 | } |
2164 | 2164 | ||
2165 | void KOMonthView::showContextMenu( Incidence *incidence ) | 2165 | void KOMonthView::showContextMenu( Incidence *incidence ) |
2166 | { | 2166 | { |
2167 | if( incidence ) | 2167 | if( incidence ) |
2168 | mContextMenu->showIncidencePopup(incidence); | 2168 | mContextMenu->showIncidencePopup(incidence); |
2169 | else { | 2169 | else { |
2170 | //qDebug("KOMonthView::showContextMenu "); | 2170 | //qDebug("KOMonthView::showContextMenu "); |
2171 | mNewItemMenu->popup(QCursor::pos()); | 2171 | mNewItemMenu->popup(QCursor::pos()); |
2172 | } | 2172 | } |
2173 | /* | 2173 | /* |
2174 | if( incidence && incidence->typeID() == eventID ) { | 2174 | if( incidence && incidence->typeID() == eventID ) { |
2175 | Event *event = static_cast<Event *>(incidence); | 2175 | Event *event = static_cast<Event *>(incidence); |
2176 | mContextMenu->showEventPopup(event); | 2176 | mContextMenu->showEventPopup(event); |
2177 | } else { | 2177 | } else { |
2178 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 2178 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
2179 | } | 2179 | } |
2180 | */ | 2180 | */ |
2181 | } | 2181 | } |
2182 | MonthViewCell * KOMonthView::selectedCell( ) | 2182 | MonthViewCell * KOMonthView::selectedCell( ) |
2183 | { | 2183 | { |
2184 | return mSelectedCell; | 2184 | return mSelectedCell; |
2185 | } | 2185 | } |
2186 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 2186 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
2187 | { | 2187 | { |
2188 | //qDebug("KOMonthView::setSelectedCell %d", cell); | 2188 | //qDebug("KOMonthView::setSelectedCell %d", cell); |
2189 | if ( mSelectedCell && mSelectedCell != cell ) { | 2189 | if ( mSelectedCell && mSelectedCell != cell ) { |
2190 | MonthViewCell * mvc = mSelectedCell; | 2190 | MonthViewCell * mvc = mSelectedCell; |
2191 | mSelectedCell = cell; | 2191 | mSelectedCell = cell; |
2192 | mvc->deselect(); | 2192 | mvc->deselect(); |
2193 | } else | 2193 | } else |
2194 | mSelectedCell = cell; | 2194 | mSelectedCell = cell; |
2195 | // if ( mSelectedCell ) | 2195 | // if ( mSelectedCell ) |
2196 | // mSelectedCell->select(); | 2196 | // mSelectedCell->select(); |
2197 | if ( !mSelectedCell ) | 2197 | if ( !mSelectedCell ) |
2198 | emit incidenceSelected( 0 ); | 2198 | emit incidenceSelected( 0 ); |
2199 | else | 2199 | else |
2200 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 2200 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
2201 | } | 2201 | } |
2202 | 2202 | ||
2203 | void KOMonthView::processSelectionChange() | 2203 | void KOMonthView::processSelectionChange() |
2204 | { | 2204 | { |
2205 | QPtrList<Incidence> incidences = selectedIncidences(); | 2205 | QPtrList<Incidence> incidences = selectedIncidences(); |
2206 | if (incidences.count() > 0) { | 2206 | if (incidences.count() > 0) { |
2207 | emit incidenceSelected( incidences.first() ); | 2207 | emit incidenceSelected( incidences.first() ); |
2208 | } else { | 2208 | } else { |
2209 | emit incidenceSelected( 0 ); | 2209 | emit incidenceSelected( 0 ); |
2210 | clearSelection(); | 2210 | clearSelection(); |
2211 | } | 2211 | } |
2212 | } | 2212 | } |
2213 | 2213 | ||
2214 | void KOMonthView::clearSelection() | 2214 | void KOMonthView::clearSelection() |
2215 | { | 2215 | { |
2216 | if ( mSelectedCell ) { | 2216 | if ( mSelectedCell ) { |
2217 | mSelectedCell->deselect(); | 2217 | mSelectedCell->deselect(); |
2218 | mSelectedCell = 0; | 2218 | mSelectedCell = 0; |
2219 | } | 2219 | } |
2220 | } | 2220 | } |
2221 | 2221 | ||
2222 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 2222 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
2223 | { | 2223 | { |
2224 | if ( !e->isAutoRepeat() ) { | 2224 | if ( !e->isAutoRepeat() ) { |
2225 | mFlagKeyPressed = false; | 2225 | mFlagKeyPressed = false; |
2226 | } | 2226 | } |
2227 | } | 2227 | } |
2228 | 2228 | ||
2229 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 2229 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
2230 | { | 2230 | { |
2231 | 2231 | ||
2232 | qApp->processEvents(); | 2232 | qApp->processEvents(); |
2233 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2233 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2234 | //e->ignore(); | 2234 | //e->ignore(); |
2235 | e->accept(); | 2235 | e->accept(); |
2236 | return; | 2236 | return; |
2237 | } | 2237 | } |
2238 | if (! e->isAutoRepeat() ) | 2238 | if (! e->isAutoRepeat() ) |
2239 | mFlagKeyPressed = true; | 2239 | mFlagKeyPressed = true; |
2240 | switch(e->key()) { | 2240 | switch(e->key()) { |
2241 | case Key_Up: | 2241 | case Key_Up: |
2242 | { | 2242 | { |
2243 | if ( mShowWeekView ) { | 2243 | if ( mShowWeekView ) { |
2244 | emit selectWeekNum ( currentWeek() - 1 ); | 2244 | emit selectWeekNum ( currentWeek() - 1 ); |
2245 | } | 2245 | } |
2246 | else { | 2246 | else { |
2247 | emit prevMonth(); | 2247 | emit prevMonth(); |
2248 | } | 2248 | } |
2249 | } | 2249 | } |
2250 | e->accept(); | 2250 | e->accept(); |
2251 | break; | 2251 | break; |
2252 | case Key_Down: | 2252 | case Key_Down: |
2253 | { | 2253 | { |
2254 | if ( mShowWeekView ) { | 2254 | if ( mShowWeekView ) { |
2255 | emit selectWeekNum ( currentWeek() +1); | 2255 | emit selectWeekNum ( currentWeek() +1); |
2256 | } | 2256 | } |
2257 | else { | 2257 | else { |
2258 | emit nextMonth(); | 2258 | emit nextMonth(); |
2259 | } | 2259 | } |
2260 | 2260 | ||
2261 | } | 2261 | } |
2262 | e->accept(); | 2262 | e->accept(); |
2263 | break; | 2263 | break; |
2264 | case Key_Return: | 2264 | case Key_Return: |
2265 | case Key_Enter: | 2265 | case Key_Enter: |
2266 | { | 2266 | { |
2267 | selectInternalWeekNum ( currentWeek() ); | 2267 | selectInternalWeekNum ( currentWeek() ); |
2268 | } | 2268 | } |
2269 | e->accept(); | 2269 | e->accept(); |
2270 | break; | 2270 | break; |
2271 | case Key_D: | 2271 | case Key_D: |
2272 | if ( mSelectedCell ) { | 2272 | if ( mSelectedCell ) { |
2273 | mSelectedCell->showDay(); | 2273 | mSelectedCell->showDay(); |
2274 | e->accept(); | 2274 | e->accept(); |
2275 | } else { | 2275 | } else { |
2276 | e->ignore(); | 2276 | e->ignore(); |
2277 | } | 2277 | } |
2278 | break; | 2278 | break; |
2279 | default: | 2279 | default: |
2280 | e->ignore(); | 2280 | e->ignore(); |
2281 | break; | 2281 | break; |
2282 | } | 2282 | } |
2283 | } | 2283 | } |
2284 | 2284 | ||
2285 | void KOMonthView::nextCell() | 2285 | void KOMonthView::nextCell() |
2286 | { | 2286 | { |
2287 | focusNextPrevChild ( true ); | 2287 | focusNextPrevChild ( true ); |
2288 | } | 2288 | } |
2289 | void KOMonthView::prevCell() | 2289 | void KOMonthView::prevCell() |
2290 | { | 2290 | { |
2291 | focusNextPrevChild ( false ); | 2291 | focusNextPrevChild ( false ); |
2292 | } | 2292 | } |
2293 | 2293 | ||
2294 | void KOMonthView::slotNewTodo() | 2294 | void KOMonthView::slotNewTodo() |
2295 | { | 2295 | { |
2296 | //qDebug("KOMonthView::slotNewTodo() "); | 2296 | //qDebug("KOMonthView::slotNewTodo() "); |
2297 | if ( mPopupCell ){ | 2297 | if ( mPopupCell ){ |
2298 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2298 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2299 | emit newTodoSignal(dt,true); | 2299 | emit newTodoSignal(dt,true); |
2300 | } | 2300 | } |
2301 | mPopupCell = 0; | 2301 | mPopupCell = 0; |
2302 | } | 2302 | } |
2303 | void KOMonthView::slotNewEvent() | 2303 | void KOMonthView::slotNewEvent() |
2304 | { | 2304 | { |
2305 | if ( mPopupCell ) { | 2305 | if ( mPopupCell ) { |
2306 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2306 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2307 | emit newEventSignal( dt ); | 2307 | emit newEventSignal( dt ); |
2308 | } | 2308 | } |
2309 | //qDebug("KOMonthView::slotNewEvent() "); | 2309 | //qDebug("KOMonthView::slotNewEvent() "); |
2310 | mPopupCell = 0; | 2310 | mPopupCell = 0; |
2311 | } | 2311 | } |
2312 | 2312 | ||
2313 | void KOMonthView::slotEditJournal() | 2313 | void KOMonthView::slotEditJournal() |
2314 | { | 2314 | { |
2315 | if ( mPopupCell ) | 2315 | if ( mPopupCell ) |
2316 | emit showJournalSignal( 7, mPopupCell->date() ); | 2316 | emit showJournalSignal( 7, mPopupCell->date() ); |
2317 | //qDebug("KOMonthView::slotEditJournal() "); | 2317 | //qDebug("KOMonthView::slotEditJournal() "); |
2318 | mPopupCell = 0; | 2318 | mPopupCell = 0; |
2319 | } | 2319 | } |
2320 | 2320 | ||
2321 | void KOMonthView::setPopupCell( MonthViewCell * c) | 2321 | void KOMonthView::setPopupCell( MonthViewCell * c) |
2322 | { | 2322 | { |
2323 | mPopupCell = c; | 2323 | mPopupCell = c; |
2324 | } | 2324 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index c2ad886..add1819 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1711 +1,1711 @@ | |||
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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | 31 | ||
32 | #include <qinputdialog.h> | 32 | #include <qinputdialog.h> |
33 | 33 | ||
34 | #include <qvbox.h> | 34 | #include <qvbox.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kdateedit.h> | 39 | #include <kdateedit.h> |
40 | #include "ktimeedit.h" | 40 | #include "ktimeedit.h" |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | 43 | ||
44 | #include <libkcal/icaldrag.h> | 44 | #include <libkcal/icaldrag.h> |
45 | #include <libkcal/vcaldrag.h> | 45 | #include <libkcal/vcaldrag.h> |
46 | #include <libkcal/calfilter.h> | 46 | #include <libkcal/calfilter.h> |
47 | #include <libkcal/dndfactory.h> | 47 | #include <libkcal/dndfactory.h> |
48 | #include <libkcal/calendarresources.h> | 48 | #include <libkcal/calendarresources.h> |
49 | #include <libkcal/resourcecalendar.h> | 49 | #include <libkcal/resourcecalendar.h> |
50 | #include <kresources/resourceselectdialog.h> | 50 | #include <kresources/resourceselectdialog.h> |
51 | #include <libkcal/kincidenceformatter.h> | 51 | #include <libkcal/kincidenceformatter.h> |
52 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 53 | #include <qpe/qpeapplication.h> |
54 | #else | 54 | #else |
55 | #include <qapplication.h> | 55 | #include <qapplication.h> |
56 | #endif | 56 | #endif |
57 | #ifndef KORG_NOPRINTER | 57 | #ifndef KORG_NOPRINTER |
58 | #include "calprinter.h" | 58 | #include "calprinter.h" |
59 | #endif | 59 | #endif |
60 | #include "docprefs.h" | 60 | #include "docprefs.h" |
61 | 61 | ||
62 | #include "kotodoview.h" | 62 | #include "kotodoview.h" |
63 | using namespace KOrg; | 63 | using namespace KOrg; |
64 | 64 | ||
65 | 65 | ||
66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : | 66 | KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : |
67 | QDialog( parent, name, true ) | 67 | QDialog( parent, name, true ) |
68 | { | 68 | { |
69 | mStopAll = true; | 69 | mStopAll = true; |
70 | setCaption( i18n("Start todo") ); | 70 | setCaption( i18n("Start todo") ); |
71 | QVBoxLayout* lay = new QVBoxLayout( this ); | 71 | QVBoxLayout* lay = new QVBoxLayout( this ); |
72 | lay->setSpacing( 3 ); | 72 | lay->setSpacing( 3 ); |
73 | lay->setMargin( 3 ); | 73 | lay->setMargin( 3 ); |
74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); | 74 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); |
75 | lay->addWidget( lab ); | 75 | lay->addWidget( lab ); |
76 | lab->setAlignment( AlignCenter ); | 76 | lab->setAlignment( AlignCenter ); |
77 | 77 | ||
78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); | 78 | QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); |
79 | lay->addWidget( ok ); | 79 | lay->addWidget( ok ); |
80 | ok->setDefault( true ); | 80 | ok->setDefault( true ); |
81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); | 81 | QPushButton * start = new QPushButton( i18n("Start todo"), this ); |
82 | lay->addWidget( start ); | 82 | lay->addWidget( start ); |
83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); | 83 | QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); |
84 | lay->addWidget( cancel ); | 84 | lay->addWidget( cancel ); |
85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 85 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); | 86 | connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); |
87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 87 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
88 | resize( sizeHint() ); | 88 | resize( sizeHint() ); |
89 | 89 | ||
90 | } | 90 | } |
91 | void KOStartTodoPrefs::doStop() | 91 | void KOStartTodoPrefs::doStop() |
92 | { | 92 | { |
93 | mStopAll = false; | 93 | mStopAll = false; |
94 | accept(); | 94 | accept(); |
95 | } | 95 | } |
96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : | 96 | KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : |
97 | QDialog( parent, name, true ) | 97 | QDialog( parent, name, true ) |
98 | { | 98 | { |
99 | mTodo = todo; | 99 | mTodo = todo; |
100 | setCaption( i18n("Stop todo") ); | 100 | setCaption( i18n("Stop todo") ); |
101 | QVBoxLayout* lay = new QVBoxLayout( this ); | 101 | QVBoxLayout* lay = new QVBoxLayout( this ); |
102 | lay->setSpacing( 3 ); | 102 | lay->setSpacing( 3 ); |
103 | lay->setMargin( 3 ); | 103 | lay->setMargin( 3 ); |
104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); | 104 | QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); |
105 | lay->addWidget( lab ); | 105 | lay->addWidget( lab ); |
106 | lab->setAlignment( AlignHCenter ); | 106 | lab->setAlignment( AlignHCenter ); |
107 | lab = new QLabel( i18n("Additional Comment:"), this ); | 107 | lab = new QLabel( i18n("Additional Comment:"), this ); |
108 | lay->addWidget( lab ); | 108 | lay->addWidget( lab ); |
109 | mComment = new QLineEdit( this ); | 109 | mComment = new QLineEdit( this ); |
110 | lay->addWidget( mComment ); | 110 | lay->addWidget( mComment ); |
111 | QHBox * start = new QHBox ( this ); | 111 | QHBox * start = new QHBox ( this ); |
112 | lay->addWidget( start ); | 112 | lay->addWidget( start ); |
113 | lab = new QLabel( i18n("Start:"), start ); | 113 | lab = new QLabel( i18n("Start:"), start ); |
114 | QHBox * end = new QHBox ( this ); | 114 | QHBox * end = new QHBox ( this ); |
115 | lay->addWidget( end ); | 115 | lay->addWidget( end ); |
116 | lab = new QLabel( i18n("End:"), end ); | 116 | lab = new QLabel( i18n("End:"), end ); |
117 | sde = new KDateEdit( start ); | 117 | sde = new KDateEdit( start ); |
118 | ste = new KOTimeEdit( start ); | 118 | ste = new KOTimeEdit( start ); |
119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); | 119 | connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); |
120 | ede = new KDateEdit( end ); | 120 | ede = new KDateEdit( end ); |
121 | ete = new KOTimeEdit(end ); | 121 | ete = new KOTimeEdit(end ); |
122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); | 122 | connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); |
123 | sde->setDate( mTodo->runStart().date() ); | 123 | sde->setDate( mTodo->runStart().date() ); |
124 | ste->setTime( mTodo->runStart().time() ); | 124 | ste->setTime( mTodo->runStart().time() ); |
125 | ede->setDate( QDate::currentDate()); | 125 | ede->setDate( QDate::currentDate()); |
126 | ete->setTime( QTime::currentTime() ); | 126 | ete->setTime( QTime::currentTime() ); |
127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); | 127 | QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); |
128 | lay->addWidget( ok ); | 128 | lay->addWidget( ok ); |
129 | ok->setDefault( true ); | 129 | ok->setDefault( true ); |
130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); | 130 | QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); |
131 | lay->addWidget( cancel ); | 131 | lay->addWidget( cancel ); |
132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 132 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 133 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
134 | ok = new QPushButton( i18n("Stop - do not save"), this ); | 134 | ok = new QPushButton( i18n("Stop - do not save"), this ); |
135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); | 135 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); |
136 | lay->addWidget( ok ); | 136 | lay->addWidget( ok ); |
137 | if (QApplication::desktop()->width() < 320 ) | 137 | if (QApplication::desktop()->width() < 320 ) |
138 | resize( 240, sizeHint().height() ); | 138 | resize( 240, sizeHint().height() ); |
139 | else | 139 | else |
140 | resize( 320, sizeHint().height() ); | 140 | resize( 320, sizeHint().height() ); |
141 | 141 | ||
142 | } | 142 | } |
143 | 143 | ||
144 | void KOStopTodoPrefs::accept() | 144 | void KOStopTodoPrefs::accept() |
145 | { | 145 | { |
146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); | 146 | QDateTime start = QDateTime( sde->date(), ste->getTime() ); |
147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); | 147 | QDateTime stop = QDateTime( ede->date(), ete->getTime() ); |
148 | if ( start > stop ) { | 148 | if ( start > stop ) { |
149 | KMessageBox::sorry(this, | 149 | KMessageBox::sorry(this, |
150 | i18n("The start time is\nafter the end time!"), | 150 | i18n("The start time is\nafter the end time!"), |
151 | i18n("Time mismatch!")); | 151 | i18n("Time mismatch!")); |
152 | return; | 152 | return; |
153 | } | 153 | } |
154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); | 154 | mTodo->saveRunningInfo( mComment->text(), start, stop ); |
155 | QDialog::accept(); | 155 | QDialog::accept(); |
156 | } | 156 | } |
157 | void KOStopTodoPrefs::doNotSave() | 157 | void KOStopTodoPrefs::doNotSave() |
158 | { | 158 | { |
159 | int result = KMessageBox::warningContinueCancel(this, | 159 | int result = KMessageBox::warningContinueCancel(this, |
160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); | 160 | i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); |
161 | if (result != KMessageBox::Continue) return; | 161 | if (result != KMessageBox::Continue) return; |
162 | mTodo->stopRunning(); | 162 | mTodo->stopRunning(); |
163 | QDialog::accept(); | 163 | QDialog::accept(); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | class KOTodoViewWhatsThis :public QWhatsThis | 167 | class KOTodoViewWhatsThis :public QWhatsThis |
168 | { | 168 | { |
169 | public: | 169 | public: |
170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 170 | KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
171 | 171 | ||
172 | protected: | 172 | protected: |
173 | virtual QString text( const QPoint& p) | 173 | virtual QString text( const QPoint& p) |
174 | { | 174 | { |
175 | return _view->getWhatsThisText(p) ; | 175 | return _view->getWhatsThisText(p) ; |
176 | } | 176 | } |
177 | private: | 177 | private: |
178 | QWidget* _wid; | 178 | QWidget* _wid; |
179 | KOTodoView * _view; | 179 | KOTodoView * _view; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, | 182 | KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, |
183 | const char *name) : | 183 | const char *name) : |
184 | KListView(parent,name) | 184 | KListView(parent,name) |
185 | { | 185 | { |
186 | mName = QString ( name ); | 186 | mName = QString ( name ); |
187 | mCalendar = calendar; | 187 | mCalendar = calendar; |
188 | #ifndef DESKTOP_VERSION | 188 | #ifndef DESKTOP_VERSION |
189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 189 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
190 | #endif | 190 | #endif |
191 | mOldCurrent = 0; | 191 | mOldCurrent = 0; |
192 | mMousePressed = false; | 192 | mMousePressed = false; |
193 | 193 | ||
194 | setAcceptDrops(true); | 194 | setAcceptDrops(true); |
195 | viewport()->setAcceptDrops(true); | 195 | viewport()->setAcceptDrops(true); |
196 | int size = 16; | 196 | int size = 16; |
197 | if (qApp->desktop()->width() < 300 ) | 197 | if (qApp->desktop()->width() < 300 ) |
198 | size = 12; | 198 | size = 12; |
199 | setTreeStepSize( size + 6 ); | 199 | setTreeStepSize( size + 6 ); |
200 | 200 | ||
201 | } | 201 | } |
202 | 202 | ||
203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 203 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
204 | { | 204 | { |
205 | #ifndef KORG_NODND | 205 | #ifndef KORG_NODND |
206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 206 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 207 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
208 | !QTextDrag::canDecode( e ) ) { | 208 | !QTextDrag::canDecode( e ) ) { |
209 | e->ignore(); | 209 | e->ignore(); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | 212 | ||
213 | mOldCurrent = currentItem(); | 213 | mOldCurrent = currentItem(); |
214 | #endif | 214 | #endif |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 218 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
219 | { | 219 | { |
220 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 221 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
222 | 222 | ||
223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 223 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
224 | !QTextDrag::canDecode( e ) ) { | 224 | !QTextDrag::canDecode( e ) ) { |
225 | e->ignore(); | 225 | e->ignore(); |
226 | return; | 226 | return; |
227 | } | 227 | } |
228 | 228 | ||
229 | e->accept(); | 229 | e->accept(); |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
232 | 232 | ||
233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 233 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
234 | { | 234 | { |
235 | #ifndef KORG_NODND | 235 | #ifndef KORG_NODND |
236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 236 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
237 | 237 | ||
238 | setCurrentItem(mOldCurrent); | 238 | setCurrentItem(mOldCurrent); |
239 | setSelected(mOldCurrent,true); | 239 | setSelected(mOldCurrent,true); |
240 | #endif | 240 | #endif |
241 | } | 241 | } |
242 | 242 | ||
243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 243 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
244 | { | 244 | { |
245 | #ifndef KORG_NODND | 245 | #ifndef KORG_NODND |
246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 246 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
247 | 247 | ||
248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 248 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
249 | !QTextDrag::canDecode( e ) ) { | 249 | !QTextDrag::canDecode( e ) ) { |
250 | e->ignore(); | 250 | e->ignore(); |
251 | return; | 251 | return; |
252 | } | 252 | } |
253 | 253 | ||
254 | DndFactory factory( mCalendar ); | 254 | DndFactory factory( mCalendar ); |
255 | Todo *todo = factory.createDropTodo(e); | 255 | Todo *todo = factory.createDropTodo(e); |
256 | 256 | ||
257 | if (todo) { | 257 | if (todo) { |
258 | e->acceptAction(); | 258 | e->acceptAction(); |
259 | 259 | ||
260 | KOTodoViewItem *destination = | 260 | KOTodoViewItem *destination = |
261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 261 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
262 | Todo *destinationEvent = 0; | 262 | Todo *destinationEvent = 0; |
263 | if (destination) destinationEvent = destination->todo(); | 263 | if (destination) destinationEvent = destination->todo(); |
264 | 264 | ||
265 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 265 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
266 | 266 | ||
267 | if(existingTodo) { | 267 | if(existingTodo) { |
268 | Incidence *to = destinationEvent; | 268 | Incidence *to = destinationEvent; |
269 | while(to) { | 269 | while(to) { |
270 | if (to->uid() == todo->uid()) { | 270 | if (to->uid() == todo->uid()) { |
271 | KMessageBox::sorry(this, | 271 | KMessageBox::sorry(this, |
272 | i18n("Cannot move Todo to itself\nor a child of itself"), | 272 | i18n("Cannot move Todo to itself\nor a child of itself"), |
273 | i18n("Drop Todo")); | 273 | i18n("Drop Todo")); |
274 | delete todo; | 274 | delete todo; |
275 | return; | 275 | return; |
276 | } | 276 | } |
277 | to = to->relatedTo(); | 277 | to = to->relatedTo(); |
278 | } | 278 | } |
279 | internalDrop = true; | 279 | internalDrop = true; |
280 | if ( destinationEvent ) | 280 | if ( destinationEvent ) |
281 | reparentTodoSignal( destinationEvent, existingTodo ); | 281 | reparentTodoSignal( destinationEvent, existingTodo ); |
282 | else | 282 | else |
283 | unparentTodoSignal(existingTodo); | 283 | unparentTodoSignal(existingTodo); |
284 | delete todo; | 284 | delete todo; |
285 | } else { | 285 | } else { |
286 | mCalendar->addTodo(todo); | 286 | mCalendar->addTodo(todo); |
287 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 287 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
288 | if ( destinationEvent ) | 288 | if ( destinationEvent ) |
289 | reparentTodoSignal( destinationEvent, todo ); | 289 | reparentTodoSignal( destinationEvent, todo ); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | else { | 292 | else { |
293 | QString text; | 293 | QString text; |
294 | if (QTextDrag::decode(e,text)) { | 294 | if (QTextDrag::decode(e,text)) { |
295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 295 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 296 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
297 | qDebug("Dropped : " + text); | 297 | qDebug("Dropped : " + text); |
298 | QStringList emails = QStringList::split(",",text); | 298 | QStringList emails = QStringList::split(",",text); |
299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 299 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
300 | int pos = (*it).find("<"); | 300 | int pos = (*it).find("<"); |
301 | QString name = (*it).left(pos); | 301 | QString name = (*it).left(pos); |
302 | QString email = (*it).mid(pos); | 302 | QString email = (*it).mid(pos); |
303 | if (!email.isEmpty() && todoi) { | 303 | if (!email.isEmpty() && todoi) { |
304 | todoi->todo()->addAttendee(new Attendee(name,email)); | 304 | todoi->todo()->addAttendee(new Attendee(name,email)); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | else { | 308 | else { |
309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 309 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
310 | e->ignore(); | 310 | e->ignore(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | #endif | 313 | #endif |
314 | } | 314 | } |
315 | void KOTodoListView::wheelEvent (QWheelEvent *e) | 315 | void KOTodoListView::wheelEvent (QWheelEvent *e) |
316 | { | 316 | { |
317 | QListView::wheelEvent (e); | 317 | QListView::wheelEvent (e); |
318 | } | 318 | } |
319 | 319 | ||
320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 320 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
321 | { | 321 | { |
322 | 322 | ||
323 | QPoint p(contentsToViewport(e->pos())); | 323 | QPoint p(contentsToViewport(e->pos())); |
324 | QListViewItem *i = itemAt(p); | 324 | QListViewItem *i = itemAt(p); |
325 | bool rootClicked = true; | 325 | bool rootClicked = true; |
326 | if (i) { | 326 | if (i) { |
327 | // if the user clicked into the root decoration of the item, don't | 327 | // if the user clicked into the root decoration of the item, don't |
328 | // try to start a drag! | 328 | // try to start a drag! |
329 | int X = p.x(); | 329 | int X = p.x(); |
330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | 330 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); |
331 | if (X > header()->sectionPos(0) + | 331 | if (X > header()->sectionPos(0) + |
332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 332 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
333 | itemMargin() +i->height()|| | 333 | itemMargin() +i->height()|| |
334 | X < header()->sectionPos(0)) { | 334 | X < header()->sectionPos(0)) { |
335 | rootClicked = false; | 335 | rootClicked = false; |
336 | } | 336 | } |
337 | } else { | 337 | } else { |
338 | rootClicked = false; | 338 | rootClicked = false; |
339 | } | 339 | } |
340 | #ifndef KORG_NODND | 340 | #ifndef KORG_NODND |
341 | mMousePressed = false; | 341 | mMousePressed = false; |
342 | if (! rootClicked && !( e->button() == RightButton) ) { | 342 | if (! rootClicked && !( e->button() == RightButton) ) { |
343 | mPressPos = e->pos(); | 343 | mPressPos = e->pos(); |
344 | mMousePressed = true; | 344 | mMousePressed = true; |
345 | } else { | 345 | } else { |
346 | mMousePressed = false; | 346 | mMousePressed = false; |
347 | } | 347 | } |
348 | #endif | 348 | #endif |
349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); | 349 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
350 | #ifndef DESKTOP_VERSION | 350 | #ifndef DESKTOP_VERSION |
351 | if (!( e->button() == RightButton && rootClicked) ) | 351 | if (!( e->button() == RightButton && rootClicked) ) |
352 | QListView::contentsMousePressEvent(e); | 352 | QListView::contentsMousePressEvent(e); |
353 | #else | 353 | #else |
354 | QListView::contentsMousePressEvent(e); | 354 | QListView::contentsMousePressEvent(e); |
355 | #endif | 355 | #endif |
356 | } | 356 | } |
357 | void KOTodoListView::paintEvent(QPaintEvent* e) | 357 | void KOTodoListView::paintEvent(QPaintEvent* e) |
358 | { | 358 | { |
359 | emit paintNeeded(); | 359 | emit paintNeeded(); |
360 | QListView::paintEvent( e); | 360 | QListView::paintEvent( e); |
361 | } | 361 | } |
362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 362 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
363 | { | 363 | { |
364 | 364 | ||
365 | #ifndef KORG_NODND | 365 | #ifndef KORG_NODND |
366 | //QListView::contentsMouseMoveEvent(e); | 366 | //QListView::contentsMouseMoveEvent(e); |
367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 367 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
368 | QApplication::startDragDistance()*3) { | 368 | QApplication::startDragDistance()*3) { |
369 | mMousePressed = false; | 369 | mMousePressed = false; |
370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 370 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
371 | if (item) { | 371 | if (item) { |
372 | DndFactory factory( mCalendar ); | 372 | DndFactory factory( mCalendar ); |
373 | ICalDrag *vd = factory.createDrag( | 373 | ICalDrag *vd = factory.createDrag( |
374 | ((KOTodoViewItem *)item)->todo(),viewport()); | 374 | ((KOTodoViewItem *)item)->todo(),viewport()); |
375 | internalDrop = false; | 375 | internalDrop = false; |
376 | // we cannot do any senseful here, because the DnD is still broken in Qt | 376 | // we cannot do any senseful here, because the DnD is still broken in Qt |
377 | if (vd->drag()) { | 377 | if (vd->drag()) { |
378 | if ( !internalDrop ) { | 378 | if ( !internalDrop ) { |
379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 379 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
380 | qDebug("Dnd: External move: Delete drag source "); | 380 | qDebug("Dnd: External move: Delete drag source "); |
381 | } else | 381 | } else |
382 | qDebug("Dnd: Internal move "); | 382 | qDebug("Dnd: Internal move "); |
383 | 383 | ||
384 | } else { | 384 | } else { |
385 | if ( !internalDrop ) { | 385 | if ( !internalDrop ) { |
386 | qDebug("Dnd: External Copy"); | 386 | qDebug("Dnd: External Copy"); |
387 | } else | 387 | } else |
388 | qDebug("DnD: Internal copy: Copy pending"); | 388 | qDebug("DnD: Internal copy: Copy pending"); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | } | 391 | } |
392 | #endif | 392 | #endif |
393 | } | 393 | } |
394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) | 394 | void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) |
395 | { | 395 | { |
396 | if ( !e->isAutoRepeat() ) { | 396 | if ( !e->isAutoRepeat() ) { |
397 | mFlagKeyPressed = false; | 397 | mFlagKeyPressed = false; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 402 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
403 | { | 403 | { |
404 | qApp->processEvents(); | 404 | qApp->processEvents(); |
405 | if ( !isVisible() ) { | 405 | if ( !isVisible() ) { |
406 | e->ignore(); | 406 | e->ignore(); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 409 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
410 | e->ignore(); | 410 | e->ignore(); |
411 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 411 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
412 | return; | 412 | return; |
413 | } | 413 | } |
414 | if (! e->isAutoRepeat() ) | 414 | if (! e->isAutoRepeat() ) |
415 | mFlagKeyPressed = true; | 415 | mFlagKeyPressed = true; |
416 | QListViewItem* cn; | 416 | QListViewItem* cn; |
417 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 417 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
418 | cn = currentItem(); | 418 | cn = currentItem(); |
419 | if ( cn ) { | 419 | if ( cn ) { |
420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 420 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
421 | if ( ci ){ | 421 | if ( ci ){ |
422 | if ( e->state() == ShiftButton ) | 422 | if ( e->state() == ShiftButton ) |
423 | ci->setOn( false ); | 423 | ci->setOn( false ); |
424 | else | 424 | else |
425 | ci->setOn( true ); | 425 | ci->setOn( true ); |
426 | cn = cn->itemBelow(); | 426 | cn = cn->itemBelow(); |
427 | if ( cn ) { | 427 | if ( cn ) { |
428 | setCurrentItem ( cn ); | 428 | setCurrentItem ( cn ); |
429 | ensureItemVisible ( cn ); | 429 | ensureItemVisible ( cn ); |
430 | } | 430 | } |
431 | 431 | ||
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | return; | 435 | return; |
436 | } | 436 | } |
437 | 437 | ||
438 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 438 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
439 | switch ( e->key() ) { | 439 | switch ( e->key() ) { |
440 | case Qt::Key_Down: | 440 | case Qt::Key_Down: |
441 | case Qt::Key_Up: | 441 | case Qt::Key_Up: |
442 | QListView::keyPressEvent ( e ); | 442 | QListView::keyPressEvent ( e ); |
443 | break; | 443 | break; |
444 | case Qt::Key_Left: | 444 | case Qt::Key_Left: |
445 | case Qt::Key_Right: | 445 | case Qt::Key_Right: |
446 | QListView::keyPressEvent ( e ); | 446 | QListView::keyPressEvent ( e ); |
447 | e->accept(); | 447 | e->accept(); |
448 | return; | 448 | return; |
449 | break; | 449 | break; |
450 | default: | 450 | default: |
451 | e->ignore(); | 451 | e->ignore(); |
452 | break; | 452 | break; |
453 | } | 453 | } |
454 | return; | 454 | return; |
455 | } | 455 | } |
456 | e->ignore(); | 456 | e->ignore(); |
457 | } | 457 | } |
458 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 458 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
459 | { | 459 | { |
460 | QListView::contentsMouseReleaseEvent(e); | 460 | QListView::contentsMouseReleaseEvent(e); |
461 | mMousePressed = false; | 461 | mMousePressed = false; |
462 | } | 462 | } |
463 | 463 | ||
464 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 464 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
465 | { | 465 | { |
466 | if (!e) return; | 466 | if (!e) return; |
467 | 467 | ||
468 | QPoint vp = contentsToViewport(e->pos()); | 468 | QPoint vp = contentsToViewport(e->pos()); |
469 | 469 | ||
470 | QListViewItem *item = itemAt(vp); | 470 | QListViewItem *item = itemAt(vp); |
471 | 471 | ||
472 | emit double_Clicked(item); | 472 | emit double_Clicked(item); |
473 | if (!item) return; | 473 | if (!item) return; |
474 | 474 | ||
475 | emit doubleClicked(item,vp,0); | 475 | emit doubleClicked(item,vp,0); |
476 | } | 476 | } |
477 | 477 | ||
478 | ///////////////////////////////////////////////////////////////////////////// | 478 | ///////////////////////////////////////////////////////////////////////////// |
479 | 479 | ||
480 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 480 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
481 | QLineEdit(parent) | 481 | QLineEdit(parent) |
482 | { | 482 | { |
483 | setText(i18n("Click to add new Todo")); | 483 | setText(i18n("Click to add new Todo")); |
484 | } | 484 | } |
485 | 485 | ||
486 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 486 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
487 | { | 487 | { |
488 | if ( text()==i18n("Click to add new Todo") ) | 488 | if ( text()==i18n("Click to add new Todo") ) |
489 | setText(""); | 489 | setText(""); |
490 | QLineEdit::focusInEvent(ev); | 490 | QLineEdit::focusInEvent(ev); |
491 | } | 491 | } |
492 | 492 | ||
493 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 493 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
494 | { | 494 | { |
495 | setText(i18n("Click to add new Todo")); | 495 | setText(i18n("Click to add new Todo")); |
496 | QLineEdit::focusOutEvent(ev); | 496 | QLineEdit::focusOutEvent(ev); |
497 | } | 497 | } |
498 | 498 | ||
499 | ///////////////////////////////////////////////////////////////////////////// | 499 | ///////////////////////////////////////////////////////////////////////////// |
500 | 500 | ||
501 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 501 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
502 | KOrg::BaseView(calendar,parent,name) | 502 | KOrg::BaseView(calendar,parent,name) |
503 | { | 503 | { |
504 | mCategoryPopupMenu = 0; | 504 | mCategoryPopupMenu = 0; |
505 | mPendingUpdateBeforeRepaint = false; | 505 | mPendingUpdateBeforeRepaint = false; |
506 | isFlatDisplay = false; | 506 | isFlatDisplay = false; |
507 | mNavigator = 0; | 507 | mNavigator = 0; |
508 | QBoxLayout *topLayout = new QVBoxLayout(this); | 508 | QBoxLayout *topLayout = new QVBoxLayout(this); |
509 | mName = QString ( name ); | 509 | mName = QString ( name ); |
510 | mBlockUpdate = false; | 510 | mBlockUpdate = false; |
511 | mQuickBar = new QWidget( this ); | 511 | mQuickBar = new QWidget( this ); |
512 | topLayout->addWidget(mQuickBar); | 512 | topLayout->addWidget(mQuickBar); |
513 | 513 | ||
514 | mQuickAdd = new KOQuickTodo(mQuickBar); | 514 | mQuickAdd = new KOQuickTodo(mQuickBar); |
515 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); | 515 | QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); |
516 | quickLayout->addWidget( mQuickAdd ); | 516 | quickLayout->addWidget( mQuickAdd ); |
517 | QPushButton * flat = new QPushButton( "F",mQuickBar ); | 517 | QPushButton * flat = new QPushButton( "F",mQuickBar ); |
518 | int fixwid = flat->sizeHint().height(); | 518 | int fixwid = flat->sizeHint().height(); |
519 | if ( QApplication::desktop()->width() > 320 ) | 519 | if ( QApplication::desktop()->width() >= 800 ) |
520 | fixwid *= 2; | 520 | fixwid *= 2; |
521 | flat->setFixedWidth( fixwid ); | 521 | flat->setFixedWidth( fixwid ); |
522 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); | 522 | connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); |
523 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); | 523 | QPushButton * allopen = new QPushButton( "O",mQuickBar ); |
524 | allopen->setFixedWidth( fixwid ); | 524 | allopen->setFixedWidth( fixwid ); |
525 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); | 525 | connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); |
526 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); | 526 | QPushButton * allclose = new QPushButton( "C",mQuickBar ); |
527 | allclose->setFixedWidth( fixwid ); | 527 | allclose->setFixedWidth( fixwid ); |
528 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); | 528 | connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); |
529 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); | 529 | QPushButton * s_done = new QPushButton( "D",mQuickBar ); |
530 | s_done->setPixmap( SmallIcon("greenhook16")); | 530 | s_done->setPixmap( SmallIcon("greenhook16")); |
531 | s_done->setFixedWidth( fixwid ); | 531 | s_done->setFixedWidth( fixwid ); |
532 | s_done->setFixedHeight( flat->sizeHint().height() ); | 532 | s_done->setFixedHeight( flat->sizeHint().height() ); |
533 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); | 533 | connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); |
534 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); | 534 | QPushButton * s_run = new QPushButton( "R",mQuickBar ); |
535 | s_run->setPixmap( SmallIcon("ko16old")); | 535 | s_run->setPixmap( SmallIcon("ko16old")); |
536 | s_run->setFixedWidth( fixwid ); | 536 | s_run->setFixedWidth( fixwid ); |
537 | s_run->setFixedHeight( flat->sizeHint().height() ); | 537 | s_run->setFixedHeight( flat->sizeHint().height() ); |
538 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); | 538 | connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); |
539 | 539 | ||
540 | mNewSubBut = new QPushButton( "sub",mQuickBar ); | 540 | mNewSubBut = new QPushButton( "sub",mQuickBar ); |
541 | mNewSubBut->setFixedWidth( fixwid*3/2 ); | 541 | mNewSubBut->setFixedWidth( fixwid*3/2 ); |
542 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); | 542 | connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); |
543 | mNewSubBut->setEnabled( false ); | 543 | mNewSubBut->setEnabled( false ); |
544 | quickLayout->addWidget( mNewSubBut ); | 544 | quickLayout->addWidget( mNewSubBut ); |
545 | quickLayout->addWidget( s_done ); | 545 | quickLayout->addWidget( s_done ); |
546 | quickLayout->addWidget( s_run ); | 546 | quickLayout->addWidget( s_run ); |
547 | 547 | ||
548 | quickLayout->addWidget( allopen ); | 548 | quickLayout->addWidget( allopen ); |
549 | quickLayout->addWidget( allclose ); | 549 | quickLayout->addWidget( allclose ); |
550 | quickLayout->addWidget( flat ); | 550 | quickLayout->addWidget( flat ); |
551 | 551 | ||
552 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); | 552 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); |
553 | 553 | ||
554 | mTodoListView = new KOTodoListView(calendar,this, name ); | 554 | mTodoListView = new KOTodoListView(calendar,this, name ); |
555 | topLayout->addWidget(mTodoListView); | 555 | topLayout->addWidget(mTodoListView); |
556 | //mTodoListView->header()->setMaximumHeight(30); | 556 | //mTodoListView->header()->setMaximumHeight(30); |
557 | mTodoListView->setRootIsDecorated(true); | 557 | mTodoListView->setRootIsDecorated(true); |
558 | mTodoListView->setAllColumnsShowFocus(true); | 558 | mTodoListView->setAllColumnsShowFocus(true); |
559 | 559 | ||
560 | mTodoListView->setShowSortIndicator(true); | 560 | mTodoListView->setShowSortIndicator(true); |
561 | 561 | ||
562 | mTodoListView->addColumn(i18n("Todo")); | 562 | mTodoListView->addColumn(i18n("Todo")); |
563 | mTodoListView->addColumn(i18n("Prio")); | 563 | mTodoListView->addColumn(i18n("Prio")); |
564 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 564 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
565 | mTodoListView->addColumn(i18n("Complete")); | 565 | mTodoListView->addColumn(i18n("Complete")); |
566 | mTodoListView->setColumnAlignment(2,AlignCenter); | 566 | mTodoListView->setColumnAlignment(2,AlignCenter); |
567 | 567 | ||
568 | mTodoListView->addColumn(i18n("Due Date")); | 568 | mTodoListView->addColumn(i18n("Due Date")); |
569 | mTodoListView->setColumnAlignment(3,AlignLeft); | 569 | mTodoListView->setColumnAlignment(3,AlignLeft); |
570 | mTodoListView->addColumn(i18n("Due Time")); | 570 | mTodoListView->addColumn(i18n("Due Time")); |
571 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 571 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
572 | 572 | ||
573 | mTodoListView->addColumn(i18n("Start Date")); | 573 | mTodoListView->addColumn(i18n("Start Date")); |
574 | mTodoListView->setColumnAlignment(5,AlignLeft); | 574 | mTodoListView->setColumnAlignment(5,AlignLeft); |
575 | mTodoListView->addColumn(i18n("Start Time")); | 575 | mTodoListView->addColumn(i18n("Start Time")); |
576 | mTodoListView->setColumnAlignment(6,AlignHCenter); | 576 | mTodoListView->setColumnAlignment(6,AlignHCenter); |
577 | 577 | ||
578 | mTodoListView->addColumn(i18n("Cancelled")); | 578 | mTodoListView->addColumn(i18n("Cancelled")); |
579 | mTodoListView->addColumn(i18n("Categories")); | 579 | mTodoListView->addColumn(i18n("Categories")); |
580 | mTodoListView->addColumn(i18n("Calendar")); | 580 | mTodoListView->addColumn(i18n("Calendar")); |
581 | #if 0 | 581 | #if 0 |
582 | mTodoListView->addColumn(i18n("Sort Id")); | 582 | mTodoListView->addColumn(i18n("Sort Id")); |
583 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 583 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
584 | #endif | 584 | #endif |
585 | 585 | ||
586 | mTodoListView->setMinimumHeight( 60 ); | 586 | mTodoListView->setMinimumHeight( 60 ); |
587 | mTodoListView->setItemsRenameable( true ); | 587 | mTodoListView->setItemsRenameable( true ); |
588 | mTodoListView->setRenameable( 0 ); | 588 | mTodoListView->setRenameable( 0 ); |
589 | mTodoListView->setColumnWidth( 0, 120 ); | 589 | mTodoListView->setColumnWidth( 0, 120 ); |
590 | int iii = 0; | 590 | int iii = 0; |
591 | for ( iii = 0; iii< 10 ; ++iii ) | 591 | for ( iii = 0; iii< 10 ; ++iii ) |
592 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); | 592 | mTodoListView->setColumnWidthMode( iii, QListView::Manual ); |
593 | 593 | ||
594 | 594 | ||
595 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); | 595 | mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); |
596 | 596 | ||
597 | mPriorityPopupMenu = new QPopupMenu(this); | 597 | mPriorityPopupMenu = new QPopupMenu(this); |
598 | for (int i = 1; i <= 5; i++) { | 598 | for (int i = 1; i <= 5; i++) { |
599 | QString label = QString ("%1").arg (i); | 599 | QString label = QString ("%1").arg (i); |
600 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 600 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
601 | } | 601 | } |
602 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 602 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
603 | 603 | ||
604 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 604 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
605 | for (int i = 0; i <= 100; i+=20) { | 605 | for (int i = 0; i <= 100; i+=20) { |
606 | QString label = QString ("%1 %").arg (i); | 606 | QString label = QString ("%1 %").arg (i); |
607 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 607 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
608 | } | 608 | } |
609 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 609 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
610 | 610 | ||
611 | 611 | ||
612 | mCategoryPopupMenu = new QPopupMenu (this); | 612 | mCategoryPopupMenu = new QPopupMenu (this); |
613 | mCategoryPopupMenu->setCheckable (true); | 613 | mCategoryPopupMenu->setCheckable (true); |
614 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 614 | connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
615 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); | 615 | connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); |
616 | 616 | ||
617 | mCalPopupMenu = new QPopupMenu (this); | 617 | mCalPopupMenu = new QPopupMenu (this); |
618 | mCalPopupMenu->setCheckable (true); | 618 | mCalPopupMenu->setCheckable (true); |
619 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); | 619 | connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); |
620 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); | 620 | connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); |
621 | 621 | ||
622 | 622 | ||
623 | 623 | ||
624 | 624 | ||
625 | mItemPopupMenu = new QPopupMenu(this); | 625 | mItemPopupMenu = new QPopupMenu(this); |
626 | mItemPopupMenu->insertItem(i18n("Show"), this, | 626 | mItemPopupMenu->insertItem(i18n("Show"), this, |
627 | SLOT (showTodo())); | 627 | SLOT (showTodo())); |
628 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 628 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
629 | SLOT (editTodo())); | 629 | SLOT (editTodo())); |
630 | mItemPopupMenu->insertItem( i18n("Delete..."), this, | 630 | mItemPopupMenu->insertItem( i18n("Delete..."), this, |
631 | SLOT (deleteTodo())); | 631 | SLOT (deleteTodo())); |
632 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 632 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
633 | SLOT (cloneTodo())); | 633 | SLOT (cloneTodo())); |
634 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 634 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
635 | SLOT (moveTodo())); | 635 | SLOT (moveTodo())); |
636 | #ifndef DESKTOP_VERSION | 636 | #ifndef DESKTOP_VERSION |
637 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 637 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
638 | SLOT (beamTodo())); | 638 | SLOT (beamTodo())); |
639 | #endif | 639 | #endif |
640 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 640 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
641 | SLOT (cancelTodo())); | 641 | SLOT (cancelTodo())); |
642 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); | 642 | mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); |
643 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); | 643 | mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); |
644 | mItemPopupMenu->insertSeparator(); | 644 | mItemPopupMenu->insertSeparator(); |
645 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, | 645 | mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, |
646 | SLOT (toggleRunningItem())); | 646 | SLOT (toggleRunningItem())); |
647 | mItemPopupMenu->insertSeparator(); | 647 | mItemPopupMenu->insertSeparator(); |
648 | /* | 648 | /* |
649 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 649 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
650 | SLOT (newTodo())); | 650 | SLOT (newTodo())); |
651 | */ | 651 | */ |
652 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 652 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
653 | SLOT (newSubTodo())); | 653 | SLOT (newSubTodo())); |
654 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 654 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
655 | SLOT (unparentTodo()),0,21); | 655 | SLOT (unparentTodo()),0,21); |
656 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 656 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
657 | SLOT (reparentTodo()),0,22); | 657 | SLOT (reparentTodo()),0,22); |
658 | mItemPopupMenu->insertSeparator(); | 658 | mItemPopupMenu->insertSeparator(); |
659 | #if 0 | 659 | #if 0 |
660 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), | 660 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), |
661 | this, SLOT( purgeCompleted() ) ); | 661 | this, SLOT( purgeCompleted() ) ); |
662 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 662 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
663 | this, SLOT( toggleCompleted() ),0, 33 ); | 663 | this, SLOT( toggleCompleted() ),0, 33 ); |
664 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 664 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
665 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 665 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
666 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 666 | mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
667 | this, SLOT( toggleRunning() ),0, 35 ); | 667 | this, SLOT( toggleRunning() ),0, 35 ); |
668 | 668 | ||
669 | #endif | 669 | #endif |
670 | mPopupMenu = new QPopupMenu(this); | 670 | mPopupMenu = new QPopupMenu(this); |
671 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 671 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
672 | SLOT (newTodo()),0,1); | 672 | SLOT (newTodo()),0,1); |
673 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), | 673 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), |
674 | this, SLOT(purgeCompleted()),0,2); | 674 | this, SLOT(purgeCompleted()),0,2); |
675 | mPopupMenu->insertItem(i18n("Show Completed"), | 675 | mPopupMenu->insertItem(i18n("Show Completed"), |
676 | this, SLOT( toggleCompleted() ),0,3 ); | 676 | this, SLOT( toggleCompleted() ),0,3 ); |
677 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), | 677 | mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), |
678 | this, SLOT( toggleRunning() ),0,5 ); | 678 | this, SLOT( toggleRunning() ),0,5 ); |
679 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), | 679 | mPopupMenu->insertItem(i18n(" set all open","Display all opened"), |
680 | this, SLOT( setAllOpen() ),0,6 ); | 680 | this, SLOT( setAllOpen() ),0,6 ); |
681 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), | 681 | mPopupMenu->insertItem(i18n(" set all close","Display all closed"), |
682 | this, SLOT( setAllClose() ),0,7 ); | 682 | this, SLOT( setAllClose() ),0,7 ); |
683 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), | 683 | mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), |
684 | this, SLOT( setAllFlat() ),0,8 ); | 684 | this, SLOT( setAllFlat() ),0,8 ); |
685 | mPopupMenu->insertSeparator(); | 685 | mPopupMenu->insertSeparator(); |
686 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 686 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
687 | this, SLOT( toggleQuickTodo() ),0,4 ); | 687 | this, SLOT( toggleQuickTodo() ),0,4 ); |
688 | mDocPrefs = new DocPrefs( name ); | 688 | mDocPrefs = new DocPrefs( name ); |
689 | 689 | ||
690 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); | 690 | mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); |
691 | mPopupMenu->setCheckable( true ); | 691 | mPopupMenu->setCheckable( true ); |
692 | mItemPopupMenu->setCheckable( true ); | 692 | mItemPopupMenu->setCheckable( true ); |
693 | 693 | ||
694 | 694 | ||
695 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 695 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
696 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 696 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
697 | 697 | ||
698 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 698 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
699 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 699 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
700 | 700 | ||
701 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 701 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
702 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 702 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
703 | 703 | ||
704 | 704 | ||
705 | // Double clicking conflicts with opening/closing the subtree | 705 | // Double clicking conflicts with opening/closing the subtree |
706 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 706 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
707 | SLOT( editItem( QListViewItem *) ) ); | 707 | SLOT( editItem( QListViewItem *) ) ); |
708 | /* | 708 | /* |
709 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 709 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
710 | const QPoint &,int ) ), | 710 | const QPoint &,int ) ), |
711 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 711 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
712 | */ | 712 | */ |
713 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 713 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
714 | const QPoint &,int ) ), | 714 | const QPoint &,int ) ), |
715 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 715 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
716 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 716 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
717 | SLOT( itemClicked( QListViewItem * ) ) ); | 717 | SLOT( itemClicked( QListViewItem * ) ) ); |
718 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 718 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
719 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 719 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
720 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 720 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
721 | SLOT( updateView() ) ); | 721 | SLOT( updateView() ) ); |
722 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | 722 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
723 | SLOT( todoModified(Todo *, int) ) ); | 723 | SLOT( todoModified(Todo *, int) ) ); |
724 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 724 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
725 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 725 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
726 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 726 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
727 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 727 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
728 | connect( mTodoListView, SIGNAL( paintNeeded() ), | 728 | connect( mTodoListView, SIGNAL( paintNeeded() ), |
729 | SLOT( paintNeeded()) ); | 729 | SLOT( paintNeeded()) ); |
730 | 730 | ||
731 | #if 0 | 731 | #if 0 |
732 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 732 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
733 | SLOT(selectionChanged(QListViewItem *))); | 733 | SLOT(selectionChanged(QListViewItem *))); |
734 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 734 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
735 | SLOT(selectionChanged(QListViewItem *))); | 735 | SLOT(selectionChanged(QListViewItem *))); |
736 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 736 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
737 | SLOT(selectionChanged(QListViewItem *))); | 737 | SLOT(selectionChanged(QListViewItem *))); |
738 | #endif | 738 | #endif |
739 | 739 | ||
740 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | 740 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); |
741 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | 741 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); |
742 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | 742 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); |
743 | 743 | ||
744 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 744 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
745 | SLOT( processSelectionChange() ) ); | 745 | SLOT( processSelectionChange() ) ); |
746 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 746 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
747 | SLOT( addQuickTodo() ) ); | 747 | SLOT( addQuickTodo() ) ); |
748 | 748 | ||
749 | } | 749 | } |
750 | 750 | ||
751 | KOTodoView::~KOTodoView() | 751 | KOTodoView::~KOTodoView() |
752 | { | 752 | { |
753 | 753 | ||
754 | #if QT_VERSION >= 0x030000 | 754 | #if QT_VERSION >= 0x030000 |
755 | 755 | ||
756 | #else | 756 | #else |
757 | delete mKOTodoViewWhatsThis; | 757 | delete mKOTodoViewWhatsThis; |
758 | #endif | 758 | #endif |
759 | 759 | ||
760 | delete mDocPrefs; | 760 | delete mDocPrefs; |
761 | } | 761 | } |
762 | QString KOTodoView::getWhatsThisText(QPoint p) | 762 | QString KOTodoView::getWhatsThisText(QPoint p) |
763 | { | 763 | { |
764 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); | 764 | KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); |
765 | if ( item ) | 765 | if ( item ) |
766 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), | 766 | return KIncidenceFormatter::instance()->getFormattedText( item->todo(), |
767 | KOPrefs::instance()->mWTshowDetails, | 767 | KOPrefs::instance()->mWTshowDetails, |
768 | KOPrefs::instance()->mWTshowCreated, | 768 | KOPrefs::instance()->mWTshowCreated, |
769 | KOPrefs::instance()->mWTshowChanged); | 769 | KOPrefs::instance()->mWTshowChanged); |
770 | return i18n("That is the todo view" ); | 770 | return i18n("That is the todo view" ); |
771 | 771 | ||
772 | } | 772 | } |
773 | 773 | ||
774 | void KOTodoView::jumpToDate () | 774 | void KOTodoView::jumpToDate () |
775 | { | 775 | { |
776 | // if (mActiveItem) { | 776 | // if (mActiveItem) { |
777 | // mActiveItem->todo()); | 777 | // mActiveItem->todo()); |
778 | // if ( mActiveItem->todo()->hasDueDate() ) | 778 | // if ( mActiveItem->todo()->hasDueDate() ) |
779 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 779 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
780 | } | 780 | } |
781 | void KOTodoView::paintNeeded() | 781 | void KOTodoView::paintNeeded() |
782 | { | 782 | { |
783 | if ( mPendingUpdateBeforeRepaint ) { | 783 | if ( mPendingUpdateBeforeRepaint ) { |
784 | updateView(); | 784 | updateView(); |
785 | mPendingUpdateBeforeRepaint = false; | 785 | mPendingUpdateBeforeRepaint = false; |
786 | } | 786 | } |
787 | } | 787 | } |
788 | void KOTodoView::paintEvent(QPaintEvent * pevent) | 788 | void KOTodoView::paintEvent(QPaintEvent * pevent) |
789 | { | 789 | { |
790 | if ( mPendingUpdateBeforeRepaint ) { | 790 | if ( mPendingUpdateBeforeRepaint ) { |
791 | updateView(); | 791 | updateView(); |
792 | mPendingUpdateBeforeRepaint = false; | 792 | mPendingUpdateBeforeRepaint = false; |
793 | } | 793 | } |
794 | KOrg::BaseView::paintEvent( pevent); | 794 | KOrg::BaseView::paintEvent( pevent); |
795 | } | 795 | } |
796 | 796 | ||
797 | void KOTodoView::updateView() | 797 | void KOTodoView::updateView() |
798 | { | 798 | { |
799 | pendingSubtodo = 0; | 799 | pendingSubtodo = 0; |
800 | if ( mBlockUpdate ) { | 800 | if ( mBlockUpdate ) { |
801 | return; | 801 | return; |
802 | } | 802 | } |
803 | if ( !isVisible() ) { | 803 | if ( !isVisible() ) { |
804 | mPendingUpdateBeforeRepaint = true; | 804 | mPendingUpdateBeforeRepaint = true; |
805 | return; | 805 | return; |
806 | } | 806 | } |
807 | //qDebug("KOTodoView::updateView() %x", this); | 807 | //qDebug("KOTodoView::updateView() %x", this); |
808 | if ( isFlatDisplay ) { | 808 | if ( isFlatDisplay ) { |
809 | displayAllFlat(); | 809 | displayAllFlat(); |
810 | return; | 810 | return; |
811 | } | 811 | } |
812 | storeCurrentItem(); | 812 | storeCurrentItem(); |
813 | //qDebug("update "); | 813 | //qDebug("update "); |
814 | // kdDebug() << "KOTodoView::updateView()" << endl; | 814 | // kdDebug() << "KOTodoView::updateView()" << endl; |
815 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 815 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
816 | 816 | ||
817 | 817 | ||
818 | mTodoListView->clear(); | 818 | mTodoListView->clear(); |
819 | if ( mName == "todolistsmall" ) { | 819 | if ( mName == "todolistsmall" ) { |
820 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 820 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
821 | int ps = fo.pointSize() -2; | 821 | int ps = fo.pointSize() -2; |
822 | if ( ps > 12 ) | 822 | if ( ps > 12 ) |
823 | ps -= 2; | 823 | ps -= 2; |
824 | fo.setPointSize( ps ); | 824 | fo.setPointSize( ps ); |
825 | } | 825 | } |
826 | } | 826 | } |
827 | 827 | ||
828 | mTodoListView->setFont( fo ); | 828 | mTodoListView->setFont( fo ); |
829 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 829 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
830 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 830 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
831 | QPtrList<Todo> todoList = calendar()->todos(); | 831 | QPtrList<Todo> todoList = calendar()->todos(); |
832 | 832 | ||
833 | /* | 833 | /* |
834 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 834 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
835 | Event *t; | 835 | Event *t; |
836 | for(t = todoList.first(); t; t = todoList.next()) { | 836 | for(t = todoList.first(); t; t = todoList.next()) { |
837 | kdDebug() << " " << t->getSummary() << endl; | 837 | kdDebug() << " " << t->getSummary() << endl; |
838 | 838 | ||
839 | if (t->getRelatedTo()) { | 839 | if (t->getRelatedTo()) { |
840 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 840 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
841 | } | 841 | } |
842 | 842 | ||
843 | QPtrList<Event> l = t->getRelations(); | 843 | QPtrList<Event> l = t->getRelations(); |
844 | Event *c; | 844 | Event *c; |
845 | for(c=l.first();c;c=l.next()) { | 845 | for(c=l.first();c;c=l.next()) { |
846 | kdDebug() << " - relation: " << c->getSummary() << endl; | 846 | kdDebug() << " - relation: " << c->getSummary() << endl; |
847 | } | 847 | } |
848 | } | 848 | } |
849 | */ | 849 | */ |
850 | 850 | ||
851 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 851 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
852 | // specific order of events. That means that we have to generate parent items | 852 | // specific order of events. That means that we have to generate parent items |
853 | // recursively for proper hierarchical display of Todos. | 853 | // recursively for proper hierarchical display of Todos. |
854 | mTodoMap.clear(); | 854 | mTodoMap.clear(); |
855 | Todo *todo; | 855 | Todo *todo; |
856 | todo = todoList.first();// todo; todo = todoList.next()) { | 856 | todo = todoList.first();// todo; todo = todoList.next()) { |
857 | while ( todo ) { | 857 | while ( todo ) { |
858 | bool next = true; | 858 | bool next = true; |
859 | // qDebug("todo %s ", todo->summary().latin1()); | 859 | // qDebug("todo %s ", todo->summary().latin1()); |
860 | Incidence *incidence = todo->relatedTo(); | 860 | Incidence *incidence = todo->relatedTo(); |
861 | while ( incidence ) { | 861 | while ( incidence ) { |
862 | if ( incidence->typeID() == todoID ) { | 862 | if ( incidence->typeID() == todoID ) { |
863 | //qDebug("related %s ",incidence->summary().latin1() ); | 863 | //qDebug("related %s ",incidence->summary().latin1() ); |
864 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { | 864 | if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { |
865 | //qDebug("related not found "); | 865 | //qDebug("related not found "); |
866 | todoList.remove( ); | 866 | todoList.remove( ); |
867 | todo = todoList.current(); | 867 | todo = todoList.current(); |
868 | next = false; | 868 | next = false; |
869 | incidence = 0; | 869 | incidence = 0; |
870 | 870 | ||
871 | } else { | 871 | } else { |
872 | //qDebug("related found "); | 872 | //qDebug("related found "); |
873 | incidence = incidence->relatedTo(); | 873 | incidence = incidence->relatedTo(); |
874 | } | 874 | } |
875 | } else | 875 | } else |
876 | incidence = 0; | 876 | incidence = 0; |
877 | } | 877 | } |
878 | if ( next ) | 878 | if ( next ) |
879 | todo = todoList.next(); | 879 | todo = todoList.next(); |
880 | } | 880 | } |
881 | 881 | ||
882 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 882 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
883 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) | 883 | if (!mTodoMap.contains(todo) && checkTodo( todo ) ) |
884 | { | 884 | { |
885 | insertTodoItem(todo); | 885 | insertTodoItem(todo); |
886 | } | 886 | } |
887 | } | 887 | } |
888 | // Restore opened/closed state | 888 | // Restore opened/closed state |
889 | mTodoListView->blockSignals( true ); | 889 | mTodoListView->blockSignals( true ); |
890 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 890 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
891 | mTodoListView->blockSignals( false ); | 891 | mTodoListView->blockSignals( false ); |
892 | resetCurrentItem(); | 892 | resetCurrentItem(); |
893 | } | 893 | } |
894 | 894 | ||
895 | void KOTodoView::storeCurrentItem() | 895 | void KOTodoView::storeCurrentItem() |
896 | { | 896 | { |
897 | mCurItem = 0; | 897 | mCurItem = 0; |
898 | mCurItemRootParent = 0; | 898 | mCurItemRootParent = 0; |
899 | mCurItemParent = 0; | 899 | mCurItemParent = 0; |
900 | mCurItemAbove = 0; | 900 | mCurItemAbove = 0; |
901 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 901 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
902 | if (mActiveItem) { | 902 | if (mActiveItem) { |
903 | mCurItem = mActiveItem->todo(); | 903 | mCurItem = mActiveItem->todo(); |
904 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); | 904 | KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); |
905 | if ( activeItemAbove ) | 905 | if ( activeItemAbove ) |
906 | mCurItemAbove = activeItemAbove->todo(); | 906 | mCurItemAbove = activeItemAbove->todo(); |
907 | mCurItemRootParent = mCurItem; | 907 | mCurItemRootParent = mCurItem; |
908 | mCurItemParent = mCurItemRootParent->relatedTo(); | 908 | mCurItemParent = mCurItemRootParent->relatedTo(); |
909 | while ( mCurItemRootParent->relatedTo() != 0 ) | 909 | while ( mCurItemRootParent->relatedTo() != 0 ) |
910 | mCurItemRootParent = mCurItemRootParent->relatedTo(); | 910 | mCurItemRootParent = mCurItemRootParent->relatedTo(); |
911 | } | 911 | } |
912 | mActiveItem = 0; | 912 | mActiveItem = 0; |
913 | } | 913 | } |
914 | 914 | ||
915 | void KOTodoView::resetCurrentItem() | 915 | void KOTodoView::resetCurrentItem() |
916 | { | 916 | { |
917 | //mTodoListView->setFocus(); | 917 | //mTodoListView->setFocus(); |
918 | KOTodoViewItem* foundItem = 0; | 918 | KOTodoViewItem* foundItem = 0; |
919 | KOTodoViewItem* foundItemRoot = 0; | 919 | KOTodoViewItem* foundItemRoot = 0; |
920 | KOTodoViewItem* foundItemParent = 0; | 920 | KOTodoViewItem* foundItemParent = 0; |
921 | KOTodoViewItem* foundItemAbove = 0; | 921 | KOTodoViewItem* foundItemAbove = 0; |
922 | if ( mTodoListView->firstChild () ) { | 922 | if ( mTodoListView->firstChild () ) { |
923 | if ( mCurItem ) { | 923 | if ( mCurItem ) { |
924 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); | 924 | KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); |
925 | while ( item ) { | 925 | while ( item ) { |
926 | if ( item->todo() == mCurItem ) { | 926 | if ( item->todo() == mCurItem ) { |
927 | foundItem = item; | 927 | foundItem = item; |
928 | break; | 928 | break; |
929 | } else if ( item->todo() == mCurItemAbove ) { | 929 | } else if ( item->todo() == mCurItemAbove ) { |
930 | foundItemAbove = item; | 930 | foundItemAbove = item; |
931 | 931 | ||
932 | } | 932 | } |
933 | if ( item->todo() == mCurItemRootParent ) { | 933 | if ( item->todo() == mCurItemRootParent ) { |
934 | foundItemRoot = item; | 934 | foundItemRoot = item; |
935 | } | 935 | } |
936 | if ( item->todo() == mCurItemParent ) { | 936 | if ( item->todo() == mCurItemParent ) { |
937 | foundItemParent = item; | 937 | foundItemParent = item; |
938 | } | 938 | } |
939 | item = (KOTodoViewItem*)item->itemBelow(); | 939 | item = (KOTodoViewItem*)item->itemBelow(); |
940 | } | 940 | } |
941 | if ( ! foundItem ) { | 941 | if ( ! foundItem ) { |
942 | if ( foundItemParent ) { | 942 | if ( foundItemParent ) { |
943 | foundItem = foundItemParent; | 943 | foundItem = foundItemParent; |
944 | } else { | 944 | } else { |
945 | if ( foundItemRoot ) | 945 | if ( foundItemRoot ) |
946 | foundItem = foundItemRoot; | 946 | foundItem = foundItemRoot; |
947 | else | 947 | else |
948 | foundItem = foundItemAbove; | 948 | foundItem = foundItemAbove; |
949 | } | 949 | } |
950 | } | 950 | } |
951 | } | 951 | } |
952 | if ( foundItem ) { | 952 | if ( foundItem ) { |
953 | mTodoListView->setSelected ( foundItem, true ); | 953 | mTodoListView->setSelected ( foundItem, true ); |
954 | mTodoListView->setCurrentItem( foundItem ); | 954 | mTodoListView->setCurrentItem( foundItem ); |
955 | mTodoListView->ensureItemVisible( foundItem ); | 955 | mTodoListView->ensureItemVisible( foundItem ); |
956 | } else { | 956 | } else { |
957 | if ( mTodoListView->firstChild () ) { | 957 | if ( mTodoListView->firstChild () ) { |
958 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); | 958 | mTodoListView->setSelected ( mTodoListView->firstChild (), true ); |
959 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); | 959 | mTodoListView->setCurrentItem( mTodoListView->firstChild () ); |
960 | } | 960 | } |
961 | } | 961 | } |
962 | } | 962 | } |
963 | processSelectionChange(); | 963 | processSelectionChange(); |
964 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 964 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
965 | } | 965 | } |
966 | void KOTodoView::resetFocusToList() | 966 | void KOTodoView::resetFocusToList() |
967 | { | 967 | { |
968 | topLevelWidget()->setActiveWindow(); | 968 | topLevelWidget()->setActiveWindow(); |
969 | mTodoListView->setFocus(); | 969 | mTodoListView->setFocus(); |
970 | } | 970 | } |
971 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 971 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
972 | bool KOTodoView::checkTodo( Todo * todo ) | 972 | bool KOTodoView::checkTodo( Todo * todo ) |
973 | { | 973 | { |
974 | 974 | ||
975 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 975 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
976 | return false; | 976 | return false; |
977 | if ( !todo->isCompleted() ) { | 977 | if ( !todo->isCompleted() ) { |
978 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 978 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
979 | return true; | 979 | return true; |
980 | } | 980 | } |
981 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 981 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
982 | if ( todo->hasStartDate() ) | 982 | if ( todo->hasStartDate() ) |
983 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 983 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
984 | return false; | 984 | return false; |
985 | if ( todo->hasDueDate() ) | 985 | if ( todo->hasDueDate() ) |
986 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 986 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
987 | return false; | 987 | return false; |
988 | } | 988 | } |
989 | return true; | 989 | return true; |
990 | } | 990 | } |
991 | 991 | ||
992 | void KOTodoView::restoreItemState( QListViewItem *item ) | 992 | void KOTodoView::restoreItemState( QListViewItem *item ) |
993 | { | 993 | { |
994 | pendingSubtodo = 0; | 994 | pendingSubtodo = 0; |
995 | while( item ) { | 995 | while( item ) { |
996 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 996 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
997 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 997 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
998 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 998 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
999 | item = item->nextSibling(); | 999 | item = item->nextSibling(); |
1000 | } | 1000 | } |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | 1003 | ||
1004 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 1004 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
1005 | KOTodoView::insertTodoItem(Todo *todo) | 1005 | KOTodoView::insertTodoItem(Todo *todo) |
1006 | { | 1006 | { |
1007 | 1007 | ||
1008 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 1008 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
1009 | // TODO: Check, if dynmaic cast is necessary | 1009 | // TODO: Check, if dynmaic cast is necessary |
1010 | 1010 | ||
1011 | pendingSubtodo = 0; | 1011 | pendingSubtodo = 0; |
1012 | Incidence *incidence = todo->relatedTo(); | 1012 | Incidence *incidence = todo->relatedTo(); |
1013 | while ( incidence && !incidence->calEnabled() ) | 1013 | while ( incidence && !incidence->calEnabled() ) |
1014 | incidence = incidence->relatedTo(); | 1014 | incidence = incidence->relatedTo(); |
1015 | if (incidence && incidence->typeID() == todoID ) { | 1015 | if (incidence && incidence->typeID() == todoID ) { |
1016 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 1016 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
1017 | 1017 | ||
1018 | // kdDebug() << " has Related" << endl; | 1018 | // kdDebug() << " has Related" << endl; |
1019 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1019 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1020 | itemIterator = mTodoMap.find(relatedTodo); | 1020 | itemIterator = mTodoMap.find(relatedTodo); |
1021 | if (itemIterator == mTodoMap.end()) { | 1021 | if (itemIterator == mTodoMap.end()) { |
1022 | // kdDebug() << " related not yet in list" << endl; | 1022 | // kdDebug() << " related not yet in list" << endl; |
1023 | itemIterator = insertTodoItem (relatedTodo); | 1023 | itemIterator = insertTodoItem (relatedTodo); |
1024 | } | 1024 | } |
1025 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 1025 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
1026 | // and one into the map. Sure finding is more easy but why? -zecke | 1026 | // and one into the map. Sure finding is more easy but why? -zecke |
1027 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 1027 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
1028 | return mTodoMap.insert(todo,todoItem); | 1028 | return mTodoMap.insert(todo,todoItem); |
1029 | } else { | 1029 | } else { |
1030 | // kdDebug() << " no Related" << endl; | 1030 | // kdDebug() << " no Related" << endl; |
1031 | // see above -zecke | 1031 | // see above -zecke |
1032 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1032 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1033 | return mTodoMap.insert(todo,todoItem); | 1033 | return mTodoMap.insert(todo,todoItem); |
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | 1036 | ||
1037 | 1037 | ||
1038 | void KOTodoView::updateConfig() | 1038 | void KOTodoView::updateConfig() |
1039 | { | 1039 | { |
1040 | updateView(); | 1040 | updateView(); |
1041 | mTodoListView->repaintContents(); | 1041 | mTodoListView->repaintContents(); |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 1044 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
1045 | { | 1045 | { |
1046 | QPtrList<Incidence> selected; | 1046 | QPtrList<Incidence> selected; |
1047 | 1047 | ||
1048 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1048 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1049 | // if (!item) item = mActiveItem; | 1049 | // if (!item) item = mActiveItem; |
1050 | if (item) selected.append(item->todo()); | 1050 | if (item) selected.append(item->todo()); |
1051 | 1051 | ||
1052 | return selected; | 1052 | return selected; |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | QPtrList<Todo> KOTodoView::selectedTodos() | 1055 | QPtrList<Todo> KOTodoView::selectedTodos() |
1056 | { | 1056 | { |
1057 | QPtrList<Todo> selected; | 1057 | QPtrList<Todo> selected; |
1058 | 1058 | ||
1059 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1059 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1060 | // if (!item) item = mActiveItem; | 1060 | // if (!item) item = mActiveItem; |
1061 | if (item) selected.append(item->todo()); | 1061 | if (item) selected.append(item->todo()); |
1062 | 1062 | ||
1063 | return selected; | 1063 | return selected; |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | void KOTodoView::changeEventDisplay(Event *, int) | 1066 | void KOTodoView::changeEventDisplay(Event *, int) |
1067 | { | 1067 | { |
1068 | updateView(); | 1068 | updateView(); |
1069 | } | 1069 | } |
1070 | 1070 | ||
1071 | void KOTodoView::showDates(const QDate &, const QDate &) | 1071 | void KOTodoView::showDates(const QDate &, const QDate &) |
1072 | { | 1072 | { |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | void KOTodoView::showEvents(QPtrList<Event>) | 1075 | void KOTodoView::showEvents(QPtrList<Event>) |
1076 | { | 1076 | { |
1077 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1077 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1080 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1081 | const QDate &td) | 1081 | const QDate &td) |
1082 | { | 1082 | { |
1083 | #ifndef KORG_NOPRINTER | 1083 | #ifndef KORG_NOPRINTER |
1084 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1084 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1085 | #endif | 1085 | #endif |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void KOTodoView::editItem(QListViewItem *item ) | 1088 | void KOTodoView::editItem(QListViewItem *item ) |
1089 | { | 1089 | { |
1090 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1090 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1093 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1094 | { | 1094 | { |
1095 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1095 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1098 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1099 | { | 1099 | { |
1100 | pendingSubtodo = 0; | 1100 | pendingSubtodo = 0; |
1101 | mActiveItem = (KOTodoViewItem *)item; | 1101 | mActiveItem = (KOTodoViewItem *)item; |
1102 | if (item) { | 1102 | if (item) { |
1103 | switch (column){ | 1103 | switch (column){ |
1104 | case 1: | 1104 | case 1: |
1105 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1105 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1106 | case 2: | 1106 | case 2: |
1107 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1107 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1108 | case 3: | 1108 | case 3: |
1109 | moveTodo(); | 1109 | moveTodo(); |
1110 | break; | 1110 | break; |
1111 | case 8: | 1111 | case 8: |
1112 | mCategoryPopupMenu->popup(QCursor::pos ()); break; | 1112 | mCategoryPopupMenu->popup(QCursor::pos ()); break; |
1113 | case 9: | 1113 | case 9: |
1114 | mCalPopupMenu->popup(QCursor::pos ()); break; | 1114 | mCalPopupMenu->popup(QCursor::pos ()); break; |
1115 | default: | 1115 | default: |
1116 | mItemPopupMenu->popup(QCursor::pos()); | 1116 | mItemPopupMenu->popup(QCursor::pos()); |
1117 | } | 1117 | } |
1118 | } else mPopupMenu->popup(QCursor::pos()); | 1118 | } else mPopupMenu->popup(QCursor::pos()); |
1119 | } | 1119 | } |
1120 | void KOTodoView::newTodo() | 1120 | void KOTodoView::newTodo() |
1121 | { | 1121 | { |
1122 | emit newTodoSignal(); | 1122 | emit newTodoSignal(); |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | void KOTodoView::newSubTodo() | 1125 | void KOTodoView::newSubTodo() |
1126 | { | 1126 | { |
1127 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1127 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1128 | if (mActiveItem) { | 1128 | if (mActiveItem) { |
1129 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { | 1129 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { |
1130 | addQuickTodoPar( mActiveItem->todo()); | 1130 | addQuickTodoPar( mActiveItem->todo()); |
1131 | } else | 1131 | } else |
1132 | emit newSubTodoSignal(mActiveItem->todo()); | 1132 | emit newSubTodoSignal(mActiveItem->todo()); |
1133 | } | 1133 | } |
1134 | } | 1134 | } |
1135 | void KOTodoView::unparentTodo() | 1135 | void KOTodoView::unparentTodo() |
1136 | { | 1136 | { |
1137 | if (mActiveItem) { | 1137 | if (mActiveItem) { |
1138 | emit unparentTodoSignal(mActiveItem->todo()); | 1138 | emit unparentTodoSignal(mActiveItem->todo()); |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | void KOTodoView::reparentTodo() | 1142 | void KOTodoView::reparentTodo() |
1143 | { | 1143 | { |
1144 | if (mActiveItem) { | 1144 | if (mActiveItem) { |
1145 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1145 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1146 | pendingSubtodo = mActiveItem; | 1146 | pendingSubtodo = mActiveItem; |
1147 | } | 1147 | } |
1148 | } | 1148 | } |
1149 | void KOTodoView::editTodo() | 1149 | void KOTodoView::editTodo() |
1150 | { | 1150 | { |
1151 | if (mActiveItem) { | 1151 | if (mActiveItem) { |
1152 | emit editTodoSignal(mActiveItem->todo()); | 1152 | emit editTodoSignal(mActiveItem->todo()); |
1153 | } | 1153 | } |
1154 | } | 1154 | } |
1155 | void KOTodoView::cloneTodo() | 1155 | void KOTodoView::cloneTodo() |
1156 | { | 1156 | { |
1157 | if (mActiveItem) { | 1157 | if (mActiveItem) { |
1158 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1158 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1159 | } | 1159 | } |
1160 | } | 1160 | } |
1161 | void KOTodoView::cancelTodo() | 1161 | void KOTodoView::cancelTodo() |
1162 | { | 1162 | { |
1163 | if (mActiveItem) { | 1163 | if (mActiveItem) { |
1164 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1164 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1165 | } | 1165 | } |
1166 | } | 1166 | } |
1167 | void KOTodoView::moveTodo() | 1167 | void KOTodoView::moveTodo() |
1168 | { | 1168 | { |
1169 | if (mActiveItem) { | 1169 | if (mActiveItem) { |
1170 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1170 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1171 | } | 1171 | } |
1172 | } | 1172 | } |
1173 | void KOTodoView::beamTodo() | 1173 | void KOTodoView::beamTodo() |
1174 | { | 1174 | { |
1175 | if (mActiveItem) { | 1175 | if (mActiveItem) { |
1176 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1176 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1177 | } | 1177 | } |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | 1180 | ||
1181 | void KOTodoView::showTodo() | 1181 | void KOTodoView::showTodo() |
1182 | { | 1182 | { |
1183 | if (mActiveItem) { | 1183 | if (mActiveItem) { |
1184 | emit showTodoSignal(mActiveItem->todo()); | 1184 | emit showTodoSignal(mActiveItem->todo()); |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | void KOTodoView::deleteTodo() | 1188 | void KOTodoView::deleteTodo() |
1189 | { | 1189 | { |
1190 | if (mActiveItem) { | 1190 | if (mActiveItem) { |
1191 | emit deleteTodoSignal(mActiveItem->todo()); | 1191 | emit deleteTodoSignal(mActiveItem->todo()); |
1192 | } | 1192 | } |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | void KOTodoView::setNewPriority(int index) | 1195 | void KOTodoView::setNewPriority(int index) |
1196 | { | 1196 | { |
1197 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1197 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1198 | mActiveItem->todo()->setPriority(mPriority[index]); | 1198 | mActiveItem->todo()->setPriority(mPriority[index]); |
1199 | mActiveItem->construct(); | 1199 | mActiveItem->construct(); |
1200 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1200 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1201 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1201 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1202 | } | 1202 | } |
1203 | processSelectionChange(); | 1203 | processSelectionChange(); |
1204 | } | 1204 | } |
1205 | 1205 | ||
1206 | void KOTodoView::setNewPercentage(int index) | 1206 | void KOTodoView::setNewPercentage(int index) |
1207 | { | 1207 | { |
1208 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1208 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1209 | 1209 | ||
1210 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1210 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1211 | mActiveItem->setOn( true ); | 1211 | mActiveItem->setOn( true ); |
1212 | processSelectionChange(); | 1212 | processSelectionChange(); |
1213 | return; | 1213 | return; |
1214 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1214 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1215 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1215 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1216 | if ( par && par->isOn() ) | 1216 | if ( par && par->isOn() ) |
1217 | par->setOn( false ); | 1217 | par->setOn( false ); |
1218 | } | 1218 | } |
1219 | if (mPercentage[index] == 100) { | 1219 | if (mPercentage[index] == 100) { |
1220 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1220 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1221 | } else { | 1221 | } else { |
1222 | mActiveItem->todo()->setCompleted(false); | 1222 | mActiveItem->todo()->setCompleted(false); |
1223 | } | 1223 | } |
1224 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1224 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1225 | mActiveItem->construct(); | 1225 | mActiveItem->construct(); |
1226 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1226 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1227 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1227 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1228 | } | 1228 | } |
1229 | processSelectionChange(); | 1229 | processSelectionChange(); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | void KOTodoView::fillCategories () | 1232 | void KOTodoView::fillCategories () |
1233 | { | 1233 | { |
1234 | mCategoryPopupMenu->clear(); | 1234 | mCategoryPopupMenu->clear(); |
1235 | if ( ! mActiveItem ) return; | 1235 | if ( ! mActiveItem ) return; |
1236 | QStringList checkedCategories = mActiveItem->todo()->categories (); | 1236 | QStringList checkedCategories = mActiveItem->todo()->categories (); |
1237 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1237 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1238 | it != KOPrefs::instance()->mCustomCategories.end (); | 1238 | it != KOPrefs::instance()->mCustomCategories.end (); |
1239 | ++it) { | 1239 | ++it) { |
1240 | int index = mCategoryPopupMenu->insertItem (*it); | 1240 | int index = mCategoryPopupMenu->insertItem (*it); |
1241 | mCategory[index] = *it; | 1241 | mCategory[index] = *it; |
1242 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); | 1242 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1243 | } | 1243 | } |
1244 | } | 1244 | } |
1245 | void KOTodoView::fillCal () | 1245 | void KOTodoView::fillCal () |
1246 | { | 1246 | { |
1247 | mCalPopupMenu->clear(); | 1247 | mCalPopupMenu->clear(); |
1248 | if (!mActiveItem) return; | 1248 | if (!mActiveItem) return; |
1249 | bool readO = mActiveItem->todo()->isReadOnly(); | 1249 | bool readO = mActiveItem->todo()->isReadOnly(); |
1250 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 1250 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
1251 | while ( kkf ) { | 1251 | while ( kkf ) { |
1252 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); | 1252 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); |
1253 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) | 1253 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) |
1254 | mCalPopupMenu->setItemEnabled( index, false ); | 1254 | mCalPopupMenu->setItemEnabled( index, false ); |
1255 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); | 1255 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); |
1256 | kkf = KOPrefs::instance()->mCalendars.next(); | 1256 | kkf = KOPrefs::instance()->mCalendars.next(); |
1257 | } | 1257 | } |
1258 | } | 1258 | } |
1259 | void KOTodoView::changedCal (int index ) | 1259 | void KOTodoView::changedCal (int index ) |
1260 | { | 1260 | { |
1261 | if (!mActiveItem) return; | 1261 | if (!mActiveItem) return; |
1262 | mActiveItem->todo()->setCalID( index ); | 1262 | mActiveItem->todo()->setCalID( index ); |
1263 | mActiveItem->construct(); | 1263 | mActiveItem->construct(); |
1264 | } | 1264 | } |
1265 | void KOTodoView::changedCategories(int index) | 1265 | void KOTodoView::changedCategories(int index) |
1266 | { | 1266 | { |
1267 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1267 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1268 | QStringList categories = mActiveItem->todo()->categories (); | 1268 | QStringList categories = mActiveItem->todo()->categories (); |
1269 | QString colcat = categories.first(); | 1269 | QString colcat = categories.first(); |
1270 | if (categories.find (mCategory[index]) != categories.end ()) | 1270 | if (categories.find (mCategory[index]) != categories.end ()) |
1271 | categories.remove (mCategory[index]); | 1271 | categories.remove (mCategory[index]); |
1272 | else | 1272 | else |
1273 | categories.insert (categories.end(), mCategory[index]); | 1273 | categories.insert (categories.end(), mCategory[index]); |
1274 | categories.sort (); | 1274 | categories.sort (); |
1275 | if ( !colcat.isEmpty() ) { | 1275 | if ( !colcat.isEmpty() ) { |
1276 | if ( categories.find ( colcat ) != categories.end () ) { | 1276 | if ( categories.find ( colcat ) != categories.end () ) { |
1277 | categories.remove( colcat ); | 1277 | categories.remove( colcat ); |
1278 | categories.prepend( colcat ); | 1278 | categories.prepend( colcat ); |
1279 | } | 1279 | } |
1280 | } | 1280 | } |
1281 | mActiveItem->todo()->setCategories (categories); | 1281 | mActiveItem->todo()->setCategories (categories); |
1282 | mActiveItem->construct(); | 1282 | mActiveItem->construct(); |
1283 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1283 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1284 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1284 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1285 | } | 1285 | } |
1286 | } | 1286 | } |
1287 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1287 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1288 | { | 1288 | { |
1289 | if ( pendingSubtodo != 0 ) { | 1289 | if ( pendingSubtodo != 0 ) { |
1290 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1290 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1291 | } | 1291 | } |
1292 | pendingSubtodo = 0; | 1292 | pendingSubtodo = 0; |
1293 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1293 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1294 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1294 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1295 | //qDebug("ROW %d ", row); | 1295 | //qDebug("ROW %d ", row); |
1296 | if (!item) { | 1296 | if (!item) { |
1297 | newTodo(); | 1297 | newTodo(); |
1298 | return; | 1298 | return; |
1299 | } else { | 1299 | } else { |
1300 | if ( row == 1 ) { | 1300 | if ( row == 1 ) { |
1301 | mActiveItem = (KOTodoViewItem *) item; | 1301 | mActiveItem = (KOTodoViewItem *) item; |
1302 | newSubTodo(); | 1302 | newSubTodo(); |
1303 | return; | 1303 | return; |
1304 | } | 1304 | } |
1305 | if ( row == 5 || row == 6 || row == 2) { | 1305 | if ( row == 5 || row == 6 || row == 2) { |
1306 | mActiveItem = (KOTodoViewItem *) item; | 1306 | mActiveItem = (KOTodoViewItem *) item; |
1307 | Todo * t = mActiveItem->todo(); | 1307 | Todo * t = mActiveItem->todo(); |
1308 | if ( t->isRunning() ) { | 1308 | if ( t->isRunning() ) { |
1309 | if ( t->runTime() < 15) { | 1309 | if ( t->runTime() < 15) { |
1310 | t->stopRunning(); | 1310 | t->stopRunning(); |
1311 | mActiveItem->construct(); | 1311 | mActiveItem->construct(); |
1312 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1312 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1313 | return; | 1313 | return; |
1314 | } | 1314 | } |
1315 | else | 1315 | else |
1316 | toggleRunningItem(); | 1316 | toggleRunningItem(); |
1317 | return; | 1317 | return; |
1318 | } else { | 1318 | } else { |
1319 | t->setRunning( true ); | 1319 | t->setRunning( true ); |
1320 | mActiveItem->construct(); | 1320 | mActiveItem->construct(); |
1321 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1321 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1322 | return; | 1322 | return; |
1323 | } | 1323 | } |
1324 | } | 1324 | } |
1325 | } | 1325 | } |
1326 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1326 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1327 | editItem( item ); | 1327 | editItem( item ); |
1328 | else | 1328 | else |
1329 | showItem( item , QPoint(), 0 ); | 1329 | showItem( item , QPoint(), 0 ); |
1330 | } | 1330 | } |
1331 | void KOTodoView::toggleRunningItem() | 1331 | void KOTodoView::toggleRunningItem() |
1332 | { | 1332 | { |
1333 | // qDebug("KOTodoView::toggleRunning() "); | 1333 | // qDebug("KOTodoView::toggleRunning() "); |
1334 | if ( ! mActiveItem ) | 1334 | if ( ! mActiveItem ) |
1335 | return; | 1335 | return; |
1336 | Todo * t = mActiveItem->todo(); | 1336 | Todo * t = mActiveItem->todo(); |
1337 | if ( t->isRunning() ) { | 1337 | if ( t->isRunning() ) { |
1338 | KOStopTodoPrefs tp ( t, this ); | 1338 | KOStopTodoPrefs tp ( t, this ); |
1339 | if (QApplication::desktop()->width() <= 800 ){ | 1339 | if (QApplication::desktop()->width() <= 800 ){ |
1340 | int wid = tp.width(); | 1340 | int wid = tp.width(); |
1341 | int hei = tp.height(); | 1341 | int hei = tp.height(); |
1342 | int xx = (QApplication::desktop()->width()-wid)/2; | 1342 | int xx = (QApplication::desktop()->width()-wid)/2; |
1343 | int yy = (QApplication::desktop()->height()-hei)/2; | 1343 | int yy = (QApplication::desktop()->height()-hei)/2; |
1344 | tp.setGeometry( xx,yy,wid,hei ); | 1344 | tp.setGeometry( xx,yy,wid,hei ); |
1345 | } | 1345 | } |
1346 | tp.exec(); | 1346 | tp.exec(); |
1347 | mActiveItem->construct(); | 1347 | mActiveItem->construct(); |
1348 | } else { | 1348 | } else { |
1349 | KOStartTodoPrefs tp ( t->summary(), this ); | 1349 | KOStartTodoPrefs tp ( t->summary(), this ); |
1350 | if (QApplication::desktop()->width() <= 800 ){ | 1350 | if (QApplication::desktop()->width() <= 800 ){ |
1351 | int wid = tp.width(); | 1351 | int wid = tp.width(); |
1352 | int hei = tp.height(); | 1352 | int hei = tp.height(); |
1353 | int xx = (QApplication::desktop()->width()-wid)/2; | 1353 | int xx = (QApplication::desktop()->width()-wid)/2; |
1354 | int yy = (QApplication::desktop()->height()-hei)/2; | 1354 | int yy = (QApplication::desktop()->height()-hei)/2; |
1355 | tp.setGeometry( xx,yy,wid,hei ); | 1355 | tp.setGeometry( xx,yy,wid,hei ); |
1356 | } | 1356 | } |
1357 | if ( !tp.exec() ) return; | 1357 | if ( !tp.exec() ) return; |
1358 | if ( tp.stopAll() ) { | 1358 | if ( tp.stopAll() ) { |
1359 | mCalendar->stopAllTodos(); | 1359 | mCalendar->stopAllTodos(); |
1360 | t->setRunning( true ); | 1360 | t->setRunning( true ); |
1361 | updateView(); | 1361 | updateView(); |
1362 | } else { | 1362 | } else { |
1363 | t->setRunning( true ); | 1363 | t->setRunning( true ); |
1364 | mActiveItem->construct(); | 1364 | mActiveItem->construct(); |
1365 | } | 1365 | } |
1366 | } | 1366 | } |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | void KOTodoView::itemClicked(QListViewItem *item) | 1369 | void KOTodoView::itemClicked(QListViewItem *item) |
1370 | { | 1370 | { |
1371 | //qDebug("KOTodoView::itemClicked %d", item); | 1371 | //qDebug("KOTodoView::itemClicked %d", item); |
1372 | if (!item) { | 1372 | if (!item) { |
1373 | if ( pendingSubtodo != 0 ) { | 1373 | if ( pendingSubtodo != 0 ) { |
1374 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1374 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1375 | } | 1375 | } |
1376 | pendingSubtodo = 0; | 1376 | pendingSubtodo = 0; |
1377 | return; | 1377 | return; |
1378 | } | 1378 | } |
1379 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1379 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1380 | if ( pendingSubtodo != 0 ) { | 1380 | if ( pendingSubtodo != 0 ) { |
1381 | bool allowReparent = true; | 1381 | bool allowReparent = true; |
1382 | QListViewItem *par = item; | 1382 | QListViewItem *par = item; |
1383 | while ( par ) { | 1383 | while ( par ) { |
1384 | if ( par == pendingSubtodo ) { | 1384 | if ( par == pendingSubtodo ) { |
1385 | allowReparent = false; | 1385 | allowReparent = false; |
1386 | break; | 1386 | break; |
1387 | } | 1387 | } |
1388 | par = par->parent(); | 1388 | par = par->parent(); |
1389 | } | 1389 | } |
1390 | if ( !allowReparent ) { | 1390 | if ( !allowReparent ) { |
1391 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1391 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1392 | pendingSubtodo = 0; | 1392 | pendingSubtodo = 0; |
1393 | } else { | 1393 | } else { |
1394 | Todo* newParent = todoItem->todo(); | 1394 | Todo* newParent = todoItem->todo(); |
1395 | Todo* newSub = pendingSubtodo->todo(); | 1395 | Todo* newSub = pendingSubtodo->todo(); |
1396 | pendingSubtodo = 0; | 1396 | pendingSubtodo = 0; |
1397 | emit reparentTodoSignal( newParent,newSub ); | 1397 | emit reparentTodoSignal( newParent,newSub ); |
1398 | return; | 1398 | return; |
1399 | } | 1399 | } |
1400 | } | 1400 | } |
1401 | 1401 | ||
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | void KOTodoView::setDocumentId( const QString &id ) | 1404 | void KOTodoView::setDocumentId( const QString &id ) |
1405 | { | 1405 | { |
1406 | 1406 | ||
1407 | mDocPrefs->setDoc( id ); | 1407 | mDocPrefs->setDoc( id ); |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1410 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1411 | { | 1411 | { |
1412 | if (!item) return; | 1412 | if (!item) return; |
1413 | 1413 | ||
1414 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1414 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1415 | 1415 | ||
1416 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1416 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1417 | 1417 | ||
1418 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1418 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1419 | } | 1419 | } |
1420 | 1420 | ||
1421 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1421 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1422 | { | 1422 | { |
1423 | mTodoListView->saveLayout(config,group); | 1423 | mTodoListView->saveLayout(config,group); |
1424 | } | 1424 | } |
1425 | 1425 | ||
1426 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1426 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1427 | { | 1427 | { |
1428 | mTodoListView->restoreLayout(config,group); | 1428 | mTodoListView->restoreLayout(config,group); |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | void KOTodoView::processSelectionChange() | 1431 | void KOTodoView::processSelectionChange() |
1432 | { | 1432 | { |
1433 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1433 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1434 | 1434 | ||
1435 | KOTodoViewItem *item = | 1435 | KOTodoViewItem *item = |
1436 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1436 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1437 | 1437 | ||
1438 | if ( !item ) { | 1438 | if ( !item ) { |
1439 | emit incidenceSelected( 0 ); | 1439 | emit incidenceSelected( 0 ); |
1440 | mNewSubBut->setEnabled( false ); | 1440 | mNewSubBut->setEnabled( false ); |
1441 | } else { | 1441 | } else { |
1442 | emit incidenceSelected( item->todo() ); | 1442 | emit incidenceSelected( item->todo() ); |
1443 | mNewSubBut->setEnabled( true ); | 1443 | mNewSubBut->setEnabled( true ); |
1444 | } | 1444 | } |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | void KOTodoView::modified(bool b) | 1447 | void KOTodoView::modified(bool b) |
1448 | { | 1448 | { |
1449 | emit isModified(b); | 1449 | emit isModified(b); |
1450 | } | 1450 | } |
1451 | void KOTodoView::setTodoModified( Todo* todo ) | 1451 | void KOTodoView::setTodoModified( Todo* todo ) |
1452 | { | 1452 | { |
1453 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1453 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1454 | } | 1454 | } |
1455 | void KOTodoView::clearSelection() | 1455 | void KOTodoView::clearSelection() |
1456 | { | 1456 | { |
1457 | mTodoListView->selectAll( false ); | 1457 | mTodoListView->selectAll( false ); |
1458 | } | 1458 | } |
1459 | void KOTodoView::setAllOpen() | 1459 | void KOTodoView::setAllOpen() |
1460 | { | 1460 | { |
1461 | if ( isFlatDisplay ) { | 1461 | if ( isFlatDisplay ) { |
1462 | isFlatDisplay = false; | 1462 | isFlatDisplay = false; |
1463 | mPopupMenu->setItemChecked( 8,false ); | 1463 | mPopupMenu->setItemChecked( 8,false ); |
1464 | updateView(); | 1464 | updateView(); |
1465 | } else { | 1465 | } else { |
1466 | storeCurrentItem(); | 1466 | storeCurrentItem(); |
1467 | } | 1467 | } |
1468 | setOpen(mTodoListView->firstChild(), true); | 1468 | setOpen(mTodoListView->firstChild(), true); |
1469 | resetCurrentItem(); | 1469 | resetCurrentItem(); |
1470 | } | 1470 | } |
1471 | void KOTodoView::setAllClose() | 1471 | void KOTodoView::setAllClose() |
1472 | { | 1472 | { |
1473 | if ( isFlatDisplay ) { | 1473 | if ( isFlatDisplay ) { |
1474 | isFlatDisplay = false; | 1474 | isFlatDisplay = false; |
1475 | mPopupMenu->setItemChecked( 8,false ); | 1475 | mPopupMenu->setItemChecked( 8,false ); |
1476 | updateView(); | 1476 | updateView(); |
1477 | } else { | 1477 | } else { |
1478 | storeCurrentItem(); | 1478 | storeCurrentItem(); |
1479 | } | 1479 | } |
1480 | setOpen(mTodoListView->firstChild(), false); | 1480 | setOpen(mTodoListView->firstChild(), false); |
1481 | resetCurrentItem(); | 1481 | resetCurrentItem(); |
1482 | } | 1482 | } |
1483 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1483 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1484 | { | 1484 | { |
1485 | 1485 | ||
1486 | while ( item ) { | 1486 | while ( item ) { |
1487 | setOpen( item->firstChild(), setOpenI ); | 1487 | setOpen( item->firstChild(), setOpenI ); |
1488 | item->setOpen( setOpenI ); | 1488 | item->setOpen( setOpenI ); |
1489 | item = item->nextSibling(); | 1489 | item = item->nextSibling(); |
1490 | } | 1490 | } |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | void KOTodoView::displayAllFlat() | 1493 | void KOTodoView::displayAllFlat() |
1494 | { | 1494 | { |
1495 | storeCurrentItem(); | 1495 | storeCurrentItem(); |
1496 | pendingSubtodo = 0; | 1496 | pendingSubtodo = 0; |
1497 | if ( mBlockUpdate ) { | 1497 | if ( mBlockUpdate ) { |
1498 | return; | 1498 | return; |
1499 | } | 1499 | } |
1500 | mPopupMenu->setItemChecked( 8,true ); | 1500 | mPopupMenu->setItemChecked( 8,true ); |
1501 | isFlatDisplay = true; | 1501 | isFlatDisplay = true; |
1502 | QPtrList<Todo> todoList = calendar()->todos(); | 1502 | QPtrList<Todo> todoList = calendar()->todos(); |
1503 | mTodoMap.clear(); | 1503 | mTodoMap.clear(); |
1504 | mTodoListView->clear(); | 1504 | mTodoListView->clear(); |
1505 | Todo *todo; | 1505 | Todo *todo; |
1506 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1506 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1507 | if ( checkTodo( todo ) ) { | 1507 | if ( checkTodo( todo ) ) { |
1508 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1508 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1509 | mTodoMap.insert(todo,todoItem); | 1509 | mTodoMap.insert(todo,todoItem); |
1510 | } | 1510 | } |
1511 | } | 1511 | } |
1512 | resetCurrentItem(); | 1512 | resetCurrentItem(); |
1513 | } | 1513 | } |
1514 | 1514 | ||
1515 | void KOTodoView::setAllFlat() | 1515 | void KOTodoView::setAllFlat() |
1516 | { | 1516 | { |
1517 | if ( isFlatDisplay ) { | 1517 | if ( isFlatDisplay ) { |
1518 | isFlatDisplay = false; | 1518 | isFlatDisplay = false; |
1519 | mPopupMenu->setItemChecked( 8,false ); | 1519 | mPopupMenu->setItemChecked( 8,false ); |
1520 | updateView(); | 1520 | updateView(); |
1521 | return; | 1521 | return; |
1522 | } | 1522 | } |
1523 | displayAllFlat(); | 1523 | displayAllFlat(); |
1524 | } | 1524 | } |
1525 | 1525 | ||
1526 | void KOTodoView::purgeCompleted() | 1526 | void KOTodoView::purgeCompleted() |
1527 | { | 1527 | { |
1528 | emit purgeCompletedSignal(); | 1528 | emit purgeCompletedSignal(); |
1529 | 1529 | ||
1530 | } | 1530 | } |
1531 | void KOTodoView::toggleQuickTodo() | 1531 | void KOTodoView::toggleQuickTodo() |
1532 | { | 1532 | { |
1533 | if ( mQuickBar->isVisible() ) { | 1533 | if ( mQuickBar->isVisible() ) { |
1534 | mQuickBar->hide(); | 1534 | mQuickBar->hide(); |
1535 | KOPrefs::instance()->mEnableQuickTodo = false; | 1535 | KOPrefs::instance()->mEnableQuickTodo = false; |
1536 | } | 1536 | } |
1537 | else { | 1537 | else { |
1538 | mQuickBar->show(); | 1538 | mQuickBar->show(); |
1539 | KOPrefs::instance()->mEnableQuickTodo = true; | 1539 | KOPrefs::instance()->mEnableQuickTodo = true; |
1540 | } | 1540 | } |
1541 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1541 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1542 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1542 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | void KOTodoView::toggleRunning() | 1545 | void KOTodoView::toggleRunning() |
1546 | { | 1546 | { |
1547 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1547 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1548 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1548 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1549 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1549 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1550 | updateView(); | 1550 | updateView(); |
1551 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 1551 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
1552 | topLevelWidget()->setCaption(i18n("Hide not Running")); | 1552 | topLevelWidget()->setCaption(i18n("Hide not Running")); |
1553 | else | 1553 | else |
1554 | topLevelWidget()->setCaption(i18n("Show not Running")); | 1554 | topLevelWidget()->setCaption(i18n("Show not Running")); |
1555 | } | 1555 | } |
1556 | 1556 | ||
1557 | void KOTodoView::toggleCompleted() | 1557 | void KOTodoView::toggleCompleted() |
1558 | { | 1558 | { |
1559 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1559 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1560 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1560 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1561 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1561 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1562 | updateView(); | 1562 | updateView(); |
1563 | if ( KOPrefs::instance()->mShowCompletedTodo ) | 1563 | if ( KOPrefs::instance()->mShowCompletedTodo ) |
1564 | topLevelWidget()->setCaption(i18n("Show Completed")); | 1564 | topLevelWidget()->setCaption(i18n("Show Completed")); |
1565 | else | 1565 | else |
1566 | topLevelWidget()->setCaption(i18n("Hide Completed")); | 1566 | topLevelWidget()->setCaption(i18n("Hide Completed")); |
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | void KOTodoView::addQuickTodo() | 1569 | void KOTodoView::addQuickTodo() |
1570 | { | 1570 | { |
1571 | addQuickTodoPar( 0 ); | 1571 | addQuickTodoPar( 0 ); |
1572 | } | 1572 | } |
1573 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) | 1573 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) |
1574 | { | 1574 | { |
1575 | Todo *todo = new Todo(); | 1575 | Todo *todo = new Todo(); |
1576 | todo->setSummary(mQuickAdd->text()); | 1576 | todo->setSummary(mQuickAdd->text()); |
1577 | todo->setOrganizer(KOPrefs::instance()->email()); | 1577 | todo->setOrganizer(KOPrefs::instance()->email()); |
1578 | if ( parentTodo ) { | 1578 | if ( parentTodo ) { |
1579 | todo->setRelatedTo(parentTodo); | 1579 | todo->setRelatedTo(parentTodo); |
1580 | 1580 | ||
1581 | todo->setCategories (parentTodo->categoriesStr ()); | 1581 | todo->setCategories (parentTodo->categoriesStr ()); |
1582 | todo->setSecrecy (parentTodo->secrecy ()); | 1582 | todo->setSecrecy (parentTodo->secrecy ()); |
1583 | if ( parentTodo->priority() < 3 ) | 1583 | if ( parentTodo->priority() < 3 ) |
1584 | todo->setPriority( parentTodo->priority() ); | 1584 | todo->setPriority( parentTodo->priority() ); |
1585 | todo->setCalID( parentTodo->calID() ); | 1585 | todo->setCalID( parentTodo->calID() ); |
1586 | } else { | 1586 | } else { |
1587 | CalFilter * cf = mCalendar->filter(); | 1587 | CalFilter * cf = mCalendar->filter(); |
1588 | if ( cf ) { | 1588 | if ( cf ) { |
1589 | if ( cf->isEnabled()&& cf->showCategories()) { | 1589 | if ( cf->isEnabled()&& cf->showCategories()) { |
1590 | todo->setCategories(cf->categoryList()); | 1590 | todo->setCategories(cf->categoryList()); |
1591 | } | 1591 | } |
1592 | if ( cf->isEnabled() ) | 1592 | if ( cf->isEnabled() ) |
1593 | todo->setSecrecy( cf->getSecrecy()); | 1593 | todo->setSecrecy( cf->getSecrecy()); |
1594 | } | 1594 | } |
1595 | } | 1595 | } |
1596 | mCalendar->addTodo(todo); | 1596 | mCalendar->addTodo(todo); |
1597 | mQuickAdd->setText(""); | 1597 | mQuickAdd->setText(""); |
1598 | todoModified (todo, KOGlobals::EVENTADDED ); | 1598 | todoModified (todo, KOGlobals::EVENTADDED ); |
1599 | updateView(); | 1599 | updateView(); |
1600 | 1600 | ||
1601 | } | 1601 | } |
1602 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1602 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1603 | { | 1603 | { |
1604 | // e->ignore(); | 1604 | // e->ignore(); |
1605 | //return; | 1605 | //return; |
1606 | //qDebug("KOTodoView::keyPressEvent "); | 1606 | //qDebug("KOTodoView::keyPressEvent "); |
1607 | if ( !isVisible() ) { | 1607 | if ( !isVisible() ) { |
1608 | e->ignore(); | 1608 | e->ignore(); |
1609 | return; | 1609 | return; |
1610 | } | 1610 | } |
1611 | switch ( e->key() ) { | 1611 | switch ( e->key() ) { |
1612 | case Qt::Key_Down: | 1612 | case Qt::Key_Down: |
1613 | case Qt::Key_Up: | 1613 | case Qt::Key_Up: |
1614 | QWidget::keyPressEvent ( e ); | 1614 | QWidget::keyPressEvent ( e ); |
1615 | break; | 1615 | break; |
1616 | 1616 | ||
1617 | case Qt::Key_Q: | 1617 | case Qt::Key_Q: |
1618 | 1618 | ||
1619 | 1619 | ||
1620 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { | 1620 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { |
1621 | e->ignore(); | 1621 | e->ignore(); |
1622 | break; | 1622 | break; |
1623 | } | 1623 | } |
1624 | toggleQuickTodo(); | 1624 | toggleQuickTodo(); |
1625 | break; | 1625 | break; |
1626 | case Qt::Key_U: | 1626 | case Qt::Key_U: |
1627 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1627 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1628 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1628 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1629 | unparentTodo(); | 1629 | unparentTodo(); |
1630 | e->accept(); | 1630 | e->accept(); |
1631 | } else | 1631 | } else |
1632 | e->ignore(); | 1632 | e->ignore(); |
1633 | break; | 1633 | break; |
1634 | case Qt::Key_S: | 1634 | case Qt::Key_S: |
1635 | if ( e->state() == Qt::ControlButton ) { | 1635 | if ( e->state() == Qt::ControlButton ) { |
1636 | e->ignore(); | 1636 | e->ignore(); |
1637 | break; | 1637 | break; |
1638 | } | 1638 | } |
1639 | if ( e->state() == Qt::ShiftButton ) { | 1639 | if ( e->state() == Qt::ShiftButton ) { |
1640 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1640 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1641 | reparentTodo(); | 1641 | reparentTodo(); |
1642 | e->accept(); | 1642 | e->accept(); |
1643 | } else | 1643 | } else |
1644 | e->ignore(); | 1644 | e->ignore(); |
1645 | break; | 1645 | break; |
1646 | case Qt::Key_P: | 1646 | case Qt::Key_P: |
1647 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1647 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1648 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1648 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1649 | if ( pendingSubtodo ) | 1649 | if ( pendingSubtodo ) |
1650 | itemClicked(mActiveItem); | 1650 | itemClicked(mActiveItem); |
1651 | e->accept(); | 1651 | e->accept(); |
1652 | } else | 1652 | } else |
1653 | e->ignore(); | 1653 | e->ignore(); |
1654 | break; | 1654 | break; |
1655 | case Qt::Key_Escape: | 1655 | case Qt::Key_Escape: |
1656 | if ( pendingSubtodo ) { | 1656 | if ( pendingSubtodo ) { |
1657 | itemClicked(0); | 1657 | itemClicked(0); |
1658 | e->accept(); | 1658 | e->accept(); |
1659 | } else | 1659 | } else |
1660 | e->ignore(); | 1660 | e->ignore(); |
1661 | break; | 1661 | break; |
1662 | default: | 1662 | default: |
1663 | e->ignore(); | 1663 | e->ignore(); |
1664 | } | 1664 | } |
1665 | 1665 | ||
1666 | if ( true ) { | 1666 | if ( true ) { |
1667 | if ( e->key() == Qt::Key_I ) { | 1667 | if ( e->key() == Qt::Key_I ) { |
1668 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1668 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1669 | if ( cn ) { | 1669 | if ( cn ) { |
1670 | mActiveItem = cn; | 1670 | mActiveItem = cn; |
1671 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1671 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1672 | if ( ci ){ | 1672 | if ( ci ){ |
1673 | showTodo(); | 1673 | showTodo(); |
1674 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1674 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1675 | if ( cn ) { | 1675 | if ( cn ) { |
1676 | mTodoListView->setCurrentItem ( cn ); | 1676 | mTodoListView->setCurrentItem ( cn ); |
1677 | mTodoListView->ensureItemVisible ( cn ); | 1677 | mTodoListView->ensureItemVisible ( cn ); |
1678 | } | 1678 | } |
1679 | 1679 | ||
1680 | } | 1680 | } |
1681 | } | 1681 | } |
1682 | e->accept(); | 1682 | e->accept(); |
1683 | 1683 | ||
1684 | } | 1684 | } |
1685 | 1685 | ||
1686 | } | 1686 | } |
1687 | 1687 | ||
1688 | } | 1688 | } |
1689 | void KOTodoView::updateTodo( Todo * t, int type ) | 1689 | void KOTodoView::updateTodo( Todo * t, int type ) |
1690 | { | 1690 | { |
1691 | if ( mBlockUpdate) | 1691 | if ( mBlockUpdate) |
1692 | return; | 1692 | return; |
1693 | 1693 | ||
1694 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1694 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1695 | itemIterator = mTodoMap.find(t); | 1695 | itemIterator = mTodoMap.find(t); |
1696 | if (itemIterator != mTodoMap.end()) { | 1696 | if (itemIterator != mTodoMap.end()) { |
1697 | (*itemIterator)->construct(); | 1697 | (*itemIterator)->construct(); |
1698 | } else { | 1698 | } else { |
1699 | if ( type == KOGlobals::EVENTADDED ) { | 1699 | if ( type == KOGlobals::EVENTADDED ) { |
1700 | insertTodoItem( t ); | 1700 | insertTodoItem( t ); |
1701 | } | 1701 | } |
1702 | } | 1702 | } |
1703 | 1703 | ||
1704 | } | 1704 | } |
1705 | 1705 | ||
1706 | void KOTodoView::todoModified(Todo * t , int p ) | 1706 | void KOTodoView::todoModified(Todo * t , int p ) |
1707 | { | 1707 | { |
1708 | mBlockUpdate = true; | 1708 | mBlockUpdate = true; |
1709 | emit todoModifiedSignal ( t, p ); | 1709 | emit todoModifiedSignal ( t, p ); |
1710 | mBlockUpdate = false; | 1710 | mBlockUpdate = false; |
1711 | } | 1711 | } |