summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-31 23:43:35 (UTC)
committer zautrix <zautrix>2005-01-31 23:43:35 (UTC)
commitfce3fd8accec495a2deda6fe3cd55375fac46432 (patch) (unidiff)
tree24231254fa729b1b546f0475759fcba24455e1f5
parent336678d691a8c3346c92a4e561ac7938ed532003 (diff)
downloadkdepimpi-fce3fd8accec495a2deda6fe3cd55375fac46432.zip
kdepimpi-fce3fd8accec495a2deda6fe3cd55375fac46432.tar.gz
kdepimpi-fce3fd8accec495a2deda6fe3cd55375fac46432.tar.bz2
mf
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt7
-rw-r--r--korganizer/kodaymatrix.cpp170
-rw-r--r--korganizer/kodaymatrix.h2
-rw-r--r--korganizer/komonthview.cpp6
-rw-r--r--korganizer/kotodoview.cpp17
-rw-r--r--korganizer/kotodoview.h4
-rw-r--r--korganizer/koviewmanager.cpp1
7 files changed, 116 insertions, 91 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 178f92d..2858d9c 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,126 +1,133 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3 3
4********** VERSION 2.0.1 ************ 4********** VERSION 2.0.1 ************
5 5
6Oooops ... I forgot to test on the Zaurus 5500 ... 6Oooops ... I forgot to test on the Zaurus 5500 ...
7 7
8Fixed many problems of new (english) strings (and german translations) 8Fixed many problems of new (english) strings (and german translations)
9introduced in the latest versions, where the text was not fitting on the 9introduced in the latest versions, where the text was not fitting on the
10240x320 display of the Zaurus 5500. 10240x320 display of the Zaurus 5500.
11 11
12KO/Pi:
12Added a popup menu ( press pen and hold to get popup ) to the agenda view 13Added a popup menu ( press pen and hold to get popup ) to the agenda view
13with many useful items (add event/todo, show next week, two weeks, month, journal). 14with many useful items (add event/todo, show next week, two weeks, month, journal).
14 15
15Added items to the todolist popup menu for: 16Added items to the todolist popup menu for:
16Display all opened, all closed or all todos flat. 17Display all opened, all closed or all todos flat.
17The "flat" view makes is possible to sort all todos after ,e.g., prio or date. 18The "flat" view makes is possible to sort all todos after ,e.g., prio or date.
18Made the reparenting of todos on the desktop possible via Drag&Drop. 19Made the reparenting of todos on the desktop possible via Drag&Drop.
19Fixed several bugs in setting the completed datetime for todos. 20Fixed several bugs in setting the completed datetime for todos.
20Added info about completed datetime of todos to the todo viewer. 21Added info about completed datetime of todos to the todo viewer.
21Now displaying a completed todo (with completed datetime set) in the agenda view 22Now displaying a completed todo (with completed datetime set) in the agenda view
22at the time of the completion. Such that now it is possible to see in the agenda view 23at the time of the completion. Such that now it is possible to see in the agenda view
23when what todo was completed. 24when what todo was completed.
24Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos. 25Fixed behaviour of automatic setting completion of todos with sub-todos/parent todos.
25Now the behaviour is: 26Now the behaviour is:
26Setting a parent to complete sets all (sub)childs to complete. 27Setting a parent to complete sets all (sub)childs to complete.
27Setting a parent to uncomplete does not change the childs. 28Setting a parent to uncomplete does not change the childs.
28Setting a child to uncomplete sets all parent to uncomplete. 29Setting a child to uncomplete sets all parent to uncomplete.
29Setting a child to complete does not change the parents. 30Setting a child to complete does not change the parents.
30 31
32Smart updating and double buffering of the daymatrix.
33Showing holidays in the day matrix.
34Many other small performance updates.
35
36Made day labels in agenda clickable. By clicking a label, the day is displayed in single day mode.
37
31Now the translation file usertranslation.txt is supposed to be in utf8 format. 38Now the translation file usertranslation.txt is supposed to be in utf8 format.
32If you want to translate a language from western europe, just change the germantranslation.txt file. Please read the updated Usertranslation HowTo in KO/Pi Help menu. 39If you want to translate a language from western europe, just change the germantranslation.txt file. Please read the updated Usertranslation HowTo in KO/Pi Help menu.
33 40
34 41
35********** VERSION 2.0.0 ************ 42********** VERSION 2.0.0 ************
36 43
37Stable release 2.0.0! 44Stable release 2.0.0!
38 45
39KO/Pi: 46KO/Pi:
40Fixed problem in edit dialog recreation at startup. 47Fixed problem in edit dialog recreation at startup.
41Made "toggle view*" menu items enabled context sensitive. 48Made "toggle view*" menu items enabled context sensitive.
42Changed agenda size menu to items 1-10. 49Changed agenda size menu to items 1-10.
43Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down. 50Made it possible to change agenda size quickly by pressing mouse on timelabels in agenda view and move mouse up/down.
44Usebility enhancements in the KO/Pi menus. 51Usebility enhancements in the KO/Pi menus.
45Birthday import now adds year to summary. 52Birthday import now adds year to summary.
46What's Next view shows age in years for birthday. 53What's Next view shows age in years for birthday.
47 54
48OM/Pi: 55OM/Pi:
49Added three info lines to display subject, from and to of selected mails. 56Added three info lines to display subject, from and to of selected mails.
50 57
51KA/Pi: 58KA/Pi:
52Fixed jump bar behaviour on Zaurus. 59Fixed jump bar behaviour on Zaurus.
53Now KA/Pi search field supports searching for a range of starting characters. 60Now KA/Pi search field supports searching for a range of starting characters.
54E.g. to search for all contact beginning with b to n, type 61E.g. to search for all contact beginning with b to n, type
55b-n 62b-n
56in the search field. 63in the search field.
57 64
58********** VERSION 1.9.20 ************ 65********** VERSION 1.9.20 ************
59 66
60KO/Pi: 67KO/Pi:
61Added for the "dislplay one day" agenda mode 68Added for the "dislplay one day" agenda mode
62info in the caption and in the day lables: 69info in the caption and in the day lables:
63Now it is displayed, if the selected day is from "day before yesterday" 70Now it is displayed, if the selected day is from "day before yesterday"
64to "day after tomorrow". 71to "day after tomorrow".
65Made it possible to delete a Todo, which has sub-todos. 72Made it possible to delete a Todo, which has sub-todos.
66Fixed two small problems in the todo view. 73Fixed two small problems in the todo view.
67Added missing German translation for filter edit and print dialog. 74Added missing German translation for filter edit and print dialog.
68Made search dialog closeable by cancel key. 75Made search dialog closeable by cancel key.
69 76
70Made it possible to select in the date picker the (ligt grey ) 77Made it possible to select in the date picker the (ligt grey )
71dates of the prev./next month with the mouse. 78dates of the prev./next month with the mouse.
72 79
73OM/Pi: 80OM/Pi:
74"Delete mail" icon in main window now deletes all selected mails. 81"Delete mail" icon in main window now deletes all selected mails.
75Fixed the problem, that the state flag of imap mails was ignored. 82Fixed the problem, that the state flag of imap mails was ignored.
76Now mails with "FLAG_SEEN" on the imap server get no icon in the list view 83Now mails with "FLAG_SEEN" on the imap server get no icon in the list view
77to indecate that they are already seen. 84to indecate that they are already seen.
78Fixed the problem that the body of some mails was not displayed in the 85Fixed the problem that the body of some mails was not displayed in the
79mail viewer when fetching them from the imap server directly to read them. 86mail viewer when fetching them from the imap server directly to read them.
80Made it (configurable) possible to show the "To:" field in the list view. 87Made it (configurable) possible to show the "To:" field in the list view.
81Added to the mail viewer the option "View Source" to make it possible to see the raw mail data. 88Added to the mail viewer the option "View Source" to make it possible to see the raw mail data.
82Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the 89Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the
83local storage folder (specified in account settings) of the account of the mail. 90local storage folder (specified in account settings) of the account of the mail.
84Removed some memory leaks in OM/Pi. 91Removed some memory leaks in OM/Pi.
85 92
86 93
87********** VERSION 1.9.19 ************ 94********** VERSION 1.9.19 ************
88 95
89Added a lot of missing translations to KA/Pi, 96Added a lot of missing translations to KA/Pi,
90Added some missing translations to KO/Pi and OM/Pi. 97Added some missing translations to KO/Pi and OM/Pi.
91 98
92Fixed some minor problems in KA/Pi + KO/Pi. 99Fixed some minor problems in KA/Pi + KO/Pi.
93 100
94Fixed a crash when closing PwM/Pi. 101Fixed a crash when closing PwM/Pi.
95Added German translation for PwM/Pi. 102Added German translation for PwM/Pi.
96 103
97Made view change and Month View update faster in KO/Pi. 104Made view change and Month View update faster in KO/Pi.
98 105
99 106
100********** VERSION 1.9.18 ************ 107********** VERSION 1.9.18 ************
101 108
102FYI: The VERSION 1.9.17 was a testing release only. 109FYI: The VERSION 1.9.17 was a testing release only.
103Please read the changelog of VERSION 1.9.17 as well. 110Please read the changelog of VERSION 1.9.17 as well.
104 111
105Cleaned up the syncing config dialog. 112Cleaned up the syncing config dialog.
106Added sync config options for date range for events. 113Added sync config options for date range for events.
107Added sync config options for filters on incoming data. 114Added sync config options for filters on incoming data.
108Added sync config options for filters on outgoing data. 115Added sync config options for filters on outgoing data.
109Please read the updated SyncHowTo about the new filter settings. 116Please read the updated SyncHowTo about the new filter settings.
110These filter settings make it now possible to sync with shared 117These filter settings make it now possible to sync with shared
111calendars without writing back private or confidential data 118calendars without writing back private or confidential data
112(via the outgoing filters). 119(via the outgoing filters).
113To sync only with particular parts of a shared calendar, 120To sync only with particular parts of a shared calendar,
114the incoming filter settings can be used. 121the incoming filter settings can be used.
115An example can be found in the SyncHowTo. 122An example can be found in the SyncHowTo.
116Same for shared addressbooks. 123Same for shared addressbooks.
117 124
118Added a setting for the global kdepim data storage. 125Added a setting for the global kdepim data storage.
119Usually the data is stored in (yourhomedir/kdepim). 126Usually the data is stored in (yourhomedir/kdepim).
120Now you can set in the Global config dialog TAB, subTAB "Data storage path" 127Now you can set in the Global config dialog TAB, subTAB "Data storage path"
121a directory where all the kdepim data is stored. 128a directory where all the kdepim data is stored.
122That makes it easy to save all kdepim data on a SD card on the Z, for example. 129That makes it easy to save all kdepim data on a SD card on the Z, for example.
123 130
124KO/Pi: 131KO/Pi:
125The timeedit input has a pulldown list for times. 132The timeedit input has a pulldown list for times.
126If opened, this pulldown list should now has the right time highlighted. 133If opened, this pulldown list should now has the right time highlighted.
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index ca896b5..549ef2a 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -119,269 +119,262 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const
119 updateView(); 119 updateView();
120} 120}
121 121
122QColor KODayMatrix::getShadedColor(QColor color) 122QColor KODayMatrix::getShadedColor(QColor color)
123{ 123{
124 QColor shaded; 124 QColor shaded;
125 int h=0; 125 int h=0;
126 int s=0; 126 int s=0;
127 int v=0; 127 int v=0;
128 color.hsv(&h,&s,&v); 128 color.hsv(&h,&s,&v);
129 s = s/4; 129 s = s/4;
130 v = 192+v/4; 130 v = 192+v/4;
131 shaded.setHsv(h,s,v); 131 shaded.setHsv(h,s,v);
132 132
133 return shaded; 133 return shaded;
134} 134}
135 135
136KODayMatrix::~KODayMatrix() 136KODayMatrix::~KODayMatrix()
137{ 137{
138 delete [] days; 138 delete [] days;
139 delete [] daylbls; 139 delete [] daylbls;
140 delete [] events; 140 delete [] events;
141 delete mToolTip; 141 delete mToolTip;
142} 142}
143 143
144/* 144/*
145void KODayMatrix::setStartDate(QDate start) 145void KODayMatrix::setStartDate(QDate start)
146{ 146{
147 updateView(start); 147 updateView(start);
148} 148}
149*/ 149*/
150 150
151void KODayMatrix::addSelectedDaysTo(DateList& selDays) 151void KODayMatrix::addSelectedDaysTo(DateList& selDays)
152{ 152{
153 153
154 if (mSelStart == NOSELECTION) { 154 if (mSelStart == NOSELECTION) {
155 return; 155 return;
156 } 156 }
157 157
158 //cope with selection being out of matrix limits at top (< 0) 158 //cope with selection being out of matrix limits at top (< 0)
159 int i0 = mSelStart; 159 int i0 = mSelStart;
160 if (i0 < 0) { 160 if (i0 < 0) {
161 for (int i = i0; i < 0; i++) { 161 for (int i = i0; i < 0; i++) {
162 selDays.append(days[0].addDays(i)); 162 selDays.append(days[0].addDays(i));
163 } 163 }
164 i0 = 0; 164 i0 = 0;
165 } 165 }
166 166
167 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 167 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
168 if (mSelEnd > NUMDAYS-1) { 168 if (mSelEnd > NUMDAYS-1) {
169 for (int i = i0; i <= NUMDAYS-1; i++) { 169 for (int i = i0; i <= NUMDAYS-1; i++) {
170 selDays.append(days[i]); 170 selDays.append(days[i]);
171 } 171 }
172 for (int i = NUMDAYS; i < mSelEnd; i++) { 172 for (int i = NUMDAYS; i < mSelEnd; i++) {
173 selDays.append(days[0].addDays(i)); 173 selDays.append(days[0].addDays(i));
174 } 174 }
175 175
176 // apply normal routine to selection being entirely within matrix limits 176 // apply normal routine to selection being entirely within matrix limits
177 } else { 177 } else {
178 for (int i = i0; i <= mSelEnd; i++) { 178 for (int i = i0; i <= mSelEnd; i++) {
179 selDays.append(days[i]); 179 selDays.append(days[i]);
180 } 180 }
181 } 181 }
182} 182}
183 183
184void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 184void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
185{ 185{
186 mSelStart = startdate.daysTo(start); 186 mSelStart = startdate.daysTo(start);
187 mSelEnd = startdate.daysTo(end); 187 mSelEnd = startdate.daysTo(end);
188} 188}
189 189
190 190
191void KODayMatrix::recalculateToday() 191void KODayMatrix::recalculateToday()
192{ 192{
193 today = -1; 193 today = -1;
194 for (int i=0; i<NUMDAYS; i++) { 194 for (int i=0; i<NUMDAYS; i++) {
195 events[i] = 0; 195 events[i] = 0;
196 days[i] = startdate.addDays(i); 196 days[i] = startdate.addDays(i);
197 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 197 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
198 198
199 // if today is in the currently displayed month, hilight today 199 // if today is in the currently displayed month, hilight today
200 if (days[i].year() == QDate::currentDate().year() && 200 if (days[i].year() == QDate::currentDate().year() &&
201 days[i].month() == QDate::currentDate().month() && 201 days[i].month() == QDate::currentDate().month() &&
202 days[i].day() == QDate::currentDate().day()) { 202 days[i].day() == QDate::currentDate().day()) {
203 today = i; 203 today = i;
204 } 204 }
205 } 205 }
206 // qDebug(QString("Today is visible at %1.").arg(today)); 206 // qDebug(QString("Today is visible at %1.").arg(today));
207} 207}
208 208
209void KODayMatrix::updateView() 209void KODayMatrix::updateView()
210{ 210{
211 updateView(startdate); 211 updateView(startdate);
212} 212}
213void KODayMatrix::repaintViewTimed() 213void KODayMatrix::repaintViewTimed()
214{ 214{
215 qDebug("KODayMatrix::repaintViewTimed ");
216 mRepaintTimer->stop(); 215 mRepaintTimer->stop();
217 repaint(false); 216 repaint(false);
218} 217}
219void KODayMatrix::updateViewTimed() 218void KODayMatrix::updateViewTimed()
220{ 219{
221 220
222 mUpdateTimer->stop(); 221 mUpdateTimer->stop();
223 qDebug("KODayMatrix::updateView(QDate actdate)");
224 for(int i = 0; i < NUMDAYS; i++) { 222 for(int i = 0; i < NUMDAYS; i++) {
225
226 // if events are set for the day then remember to draw it bold 223 // if events are set for the day then remember to draw it bold
227 QPtrList<Event> eventlist = mCalendar->events(days[i]); 224 QPtrList<Event> eventlist = mCalendar->events(days[i]);
228 Event *event; 225 Event *event;
229 int numEvents = eventlist.count(); 226 int numEvents = eventlist.count();
230 227 QString holiStr = "";
231 for(event=eventlist.first();event != 0;event=eventlist.next()) { 228 for(event=eventlist.first();event != 0;event=eventlist.next()) {
232 ushort recurType = event->recurrence()->doesRecur(); 229 ushort recurType = event->recurrence()->doesRecur();
233
234 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 230 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
235 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 231 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
236 numEvents--; 232 numEvents--;
237 } 233 }
234 if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) {
235 if ( !holiStr.isEmpty() )
236 holiStr += "\n";
237 holiStr += event->summary();
238 }
238 } 239 }
239 events[i] = numEvents; 240 events[i] = numEvents;
240
241 //if it is a holy day then draw it red. Sundays are consider holidays, too 241 //if it is a holy day then draw it red. Sundays are consider holidays, too
242#ifndef KORG_NOPLUGINS
243 QString holiStr = KOCore::self()->holiday(days[i]);
244#else
245 QString holiStr = QString::null;
246#endif
247 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 242 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
248 !holiStr.isEmpty()) { 243 !holiStr.isEmpty()) {
249 if (holiStr.isNull()) holiStr = "";
250 mHolidays[i] = holiStr; 244 mHolidays[i] = holiStr;
251
252 } else { 245 } else {
253 mHolidays[i] = QString::null; 246 mHolidays[i] = QString::null;
254 } 247 }
255 } 248 }
256 if ( ! mPendingUpdateBeforeRepaint ) 249 if ( ! mPendingUpdateBeforeRepaint )
257 repaint(false); 250 repaint(false);
258 } 251}
259void KODayMatrix::updateView(QDate actdate) 252void KODayMatrix::updateView(QDate actdate)
260{ 253{
261 254
262 if ( ! actdate.isValid() ) { 255 if ( ! actdate.isValid() ) {
263 //qDebug("date not valid "); 256 //qDebug("date not valid ");
264 return; 257 return;
265 } 258 }
266 mDayChanged = false; 259 mDayChanged = false;
267 //flag to indicate if the starting day of the matrix has changed by this call 260 //flag to indicate if the starting day of the matrix has changed by this call
268 //mDayChanged = false; 261 //mDayChanged = false;
269 // if a new startdate is to be set then apply Cornelius's calculation 262 // if a new startdate is to be set then apply Cornelius's calculation
270 // of the first day to be shown 263 // of the first day to be shown
271 if (actdate != startdate) { 264 if (actdate != startdate) {
272 // reset index of selection according to shift of starting date from startdate to actdate 265 // reset index of selection according to shift of starting date from startdate to actdate
273 if (mSelStart != NOSELECTION) { 266 if (mSelStart != NOSELECTION) {
274 int tmp = actdate.daysTo(startdate); 267 int tmp = actdate.daysTo(startdate);
275 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 268 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
276 // shift selection if new one would be visible at least partly ! 269 // shift selection if new one would be visible at least partly !
277 270
278 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 271 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
279 // nested if is required for next X display pushed from a different month - correction required 272 // nested if is required for next X display pushed from a different month - correction required
280 // otherwise, for month forward and backward, it must be avoided 273 // otherwise, for month forward and backward, it must be avoided
281 if( mSelStart > NUMDAYS || mSelStart < 0 ) 274 if( mSelStart > NUMDAYS || mSelStart < 0 )
282 mSelStart = mSelStart + tmp; 275 mSelStart = mSelStart + tmp;
283 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 276 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
284 mSelEnd = mSelEnd + tmp; 277 mSelEnd = mSelEnd + tmp;
285 } 278 }
286 } 279 }
287 startdate = actdate; 280 startdate = actdate;
288 mDayChanged = true; 281 mDayChanged = true;
289 recalculateToday(); 282 recalculateToday();
290 } 283 }
291 qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 284 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
292 if ( !isVisible() ) { 285 if ( !isVisible() ) {
293 mPendingUpdateBeforeRepaint = true; 286 mPendingUpdateBeforeRepaint = true;
294 } else { 287 } else {
295#ifdef DESKTOP_VERSION 288#ifdef DESKTOP_VERSION
296 //mRepaintTimer->start( 250 ); 289 //mRepaintTimer->start( 250 );
297 mUpdateTimer->start( 250 ); 290 mUpdateTimer->start( 250 );
298#else 291#else
299 mRepaintTimer->start( 350 ); 292 mRepaintTimer->start( 350 );
300 mUpdateTimer->start( 2000 ); 293 mUpdateTimer->start( 2000 );
301#endif 294#endif
302 } 295 }
303} 296}
304 297
305const QDate& KODayMatrix::getDate(int offset) 298const QDate& KODayMatrix::getDate(int offset)
306{ 299{
307 if (offset < 0 || offset > NUMDAYS-1) { 300 if (offset < 0 || offset > NUMDAYS-1) {
308 qDebug("Wrong offset2 "); 301 qDebug("Wrong offset2 ");
309 return days[0]; 302 return days[0];
310 } 303 }
311 return days[offset]; 304 return days[offset];
312} 305}
313 306
314QString KODayMatrix::getHolidayLabel(int offset) 307QString KODayMatrix::getHolidayLabel(int offset)
315{ 308{
316 if (offset < 0 || offset > NUMDAYS-1) { 309 if (offset < 0 || offset > NUMDAYS-1) {
317 qDebug("Wrong offset1 "); 310 qDebug("Wrong offset1 ");
318 return 0; 311 return 0;
319 } 312 }
320 return mHolidays[offset]; 313 return mHolidays[offset];
321} 314}
322 315
323int KODayMatrix::getDayIndexFrom(int x, int y) 316int KODayMatrix::getDayIndexFrom(int x, int y)
324{ 317{
325 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 318 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
326 6 - x/daysize.width() : x/daysize.width()); 319 6 - x/daysize.width() : x/daysize.width());
327} 320}
328 321
329// ---------------------------------------------------------------------------- 322// ----------------------------------------------------------------------------
330// M O U S E E V E N T H A N D L I N G 323// M O U S E E V E N T H A N D L I N G
331// ---------------------------------------------------------------------------- 324// ----------------------------------------------------------------------------
332 325
333void KODayMatrix::mousePressEvent (QMouseEvent* e) 326void KODayMatrix::mousePressEvent (QMouseEvent* e)
334{ 327{
335 mSelStart = getDayIndexFrom(e->x(), e->y()); 328 mSelStart = getDayIndexFrom(e->x(), e->y());
336 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 329 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
337 mSelInit = mSelStart; 330 mSelInit = mSelStart;
338} 331}
339 332
340void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 333void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
341{ 334{
342 335
343 int tmp = getDayIndexFrom(e->x(), e->y()); 336 int tmp = getDayIndexFrom(e->x(), e->y());
344 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 337 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
345 338
346 if (mSelInit > tmp) { 339 if (mSelInit > tmp) {
347 mSelEnd = mSelInit; 340 mSelEnd = mSelInit;
348 if (tmp != mSelStart) { 341 if (tmp != mSelStart) {
349 mSelStart = tmp; 342 mSelStart = tmp;
350 repaint(); 343 repaint();
351 } 344 }
352 } else { 345 } else {
353 mSelStart = mSelInit; 346 mSelStart = mSelInit;
354 347
355 //repaint only if selection has changed 348 //repaint only if selection has changed
356 if (tmp != mSelEnd) { 349 if (tmp != mSelEnd) {
357 mSelEnd = tmp; 350 mSelEnd = tmp;
358 repaint(); 351 repaint();
359 } 352 }
360 } 353 }
361 354
362 DateList daylist; 355 DateList daylist;
363 if ( mSelStart < 0 ) 356 if ( mSelStart < 0 )
364 mSelStart = 0; 357 mSelStart = 0;
365 for (int i = mSelStart; i <= mSelEnd; i++) { 358 for (int i = mSelStart; i <= mSelEnd; i++) {
366 daylist.append(days[i]); 359 daylist.append(days[i]);
367 } 360 }
368 emit selected((const DateList)daylist); 361 emit selected((const DateList)daylist);
369 362
370} 363}
371 364
372void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 365void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
373{ 366{
374 int tmp = getDayIndexFrom(e->x(), e->y()); 367 int tmp = getDayIndexFrom(e->x(), e->y());
375 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 368 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
376 369
377 if (mSelInit > tmp) { 370 if (mSelInit > tmp) {
378 mSelEnd = mSelInit; 371 mSelEnd = mSelInit;
379 if (tmp != mSelStart) { 372 if (tmp != mSelStart) {
380 mSelStart = tmp; 373 mSelStart = tmp;
381 repaint(); 374 repaint();
382 } 375 }
383 } else { 376 } else {
384 mSelStart = mSelInit; 377 mSelStart = mSelInit;
385 378
386 //repaint only if selection has changed 379 //repaint only if selection has changed
387 if (tmp != mSelEnd) { 380 if (tmp != mSelEnd) {
@@ -394,237 +387,242 @@ void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
394// ---------------------------------------------------------------------------- 387// ----------------------------------------------------------------------------
395// D R A G ' N D R O P H A N D L I N G 388// D R A G ' N D R O P H A N D L I N G
396// ---------------------------------------------------------------------------- 389// ----------------------------------------------------------------------------
397 390
398void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 391void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
399{ 392{
400#ifndef KORG_NODND 393#ifndef KORG_NODND
401 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 394 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
402 e->ignore(); 395 e->ignore();
403 return; 396 return;
404 } 397 }
405 398
406 // some visual feedback 399 // some visual feedback
407// oldPalette = palette(); 400// oldPalette = palette();
408// setPalette(my_HilitePalette); 401// setPalette(my_HilitePalette);
409// update(); 402// update();
410#endif 403#endif
411} 404}
412 405
413void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 406void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
414{ 407{
415#ifndef KORG_NODND 408#ifndef KORG_NODND
416 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 409 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
417 e->ignore(); 410 e->ignore();
418 return; 411 return;
419 } 412 }
420 413
421 e->accept(); 414 e->accept();
422#endif 415#endif
423} 416}
424 417
425void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 418void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
426{ 419{
427#ifndef KORG_NODND 420#ifndef KORG_NODND
428// setPalette(oldPalette); 421// setPalette(oldPalette);
429// update(); 422// update();
430#endif 423#endif
431} 424}
432 425
433void KODayMatrix::dropEvent(QDropEvent *e) 426void KODayMatrix::dropEvent(QDropEvent *e)
434{ 427{
435#ifndef KORG_NODND 428#ifndef KORG_NODND
436// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 429// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
437 430
438 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 431 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
439 e->ignore(); 432 e->ignore();
440 return; 433 return;
441 } 434 }
442 435
443 DndFactory factory( mCalendar ); 436 DndFactory factory( mCalendar );
444 Event *event = factory.createDrop(e); 437 Event *event = factory.createDrop(e);
445 438
446 if (event) { 439 if (event) {
447 e->acceptAction(); 440 e->acceptAction();
448 441
449 Event *existingEvent = mCalendar->event(event->uid()); 442 Event *existingEvent = mCalendar->event(event->uid());
450 443
451 if(existingEvent) { 444 if(existingEvent) {
452 // uniquify event 445 // uniquify event
453 event->recreate(); 446 event->recreate();
454/* 447/*
455 KMessageBox::sorry(this, 448 KMessageBox::sorry(this,
456 i18n("Event already exists in this calendar."), 449 i18n("Event already exists in this calendar."),
457 i18n("Drop Event")); 450 i18n("Drop Event"));
458 delete event; 451 delete event;
459 return; 452 return;
460*/ 453*/
461 } 454 }
462// kdDebug() << "Drop new Event" << endl; 455// kdDebug() << "Drop new Event" << endl;
463 // Adjust date 456 // Adjust date
464 QDateTime start = event->dtStart(); 457 QDateTime start = event->dtStart();
465 QDateTime end = event->dtEnd(); 458 QDateTime end = event->dtEnd();
466 int duration = start.daysTo(end); 459 int duration = start.daysTo(end);
467 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 460 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
468 461
469 start.setDate(days[idx]); 462 start.setDate(days[idx]);
470 end.setDate(days[idx].addDays(duration)); 463 end.setDate(days[idx].addDays(duration));
471 464
472 event->setDtStart(start); 465 event->setDtStart(start);
473 event->setDtEnd(end); 466 event->setDtEnd(end);
474 mCalendar->addEvent(event); 467 mCalendar->addEvent(event);
475 468
476 emit eventDropped(event); 469 emit eventDropped(event);
477 } else { 470 } else {
478// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 471// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
479 e->ignore(); 472 e->ignore();
480 } 473 }
481#endif 474#endif
482} 475}
483 476
484// ---------------------------------------------------------------------------- 477// ----------------------------------------------------------------------------
485// P A I N T E V E N T H A N D L I N G 478// P A I N T E V E N T H A N D L I N G
486// ---------------------------------------------------------------------------- 479// ----------------------------------------------------------------------------
487 480
488void KODayMatrix::paintEvent(QPaintEvent * pevent) 481void KODayMatrix::paintEvent(QPaintEvent * pevent)
489{ 482{
490//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; 483 if ( width() <= 0 || height() <= 0 )
491 if ( mPendingUpdateBeforeRepaint ) { 484 return;
492 updateViewTimed(); 485 if ( mPendingUpdateBeforeRepaint ) {
493 mPendingUpdateBeforeRepaint = false; 486 updateViewTimed();
487 mPendingUpdateBeforeRepaint = false;
488 }
489 if ( myPix.width() != width() || myPix.height()!=height() ) {
490 myPix.resize(size() );
494 } 491 }
495 QPainter p(this); 492 QPainter p(&myPix);
496 493
497 QRect sz = frameRect(); 494 QRect sz = frameRect();
498 int dheight = daysize.height(); 495 int dheight = daysize.height();
499 int dwidth = daysize.width(); 496 int dwidth = daysize.width();
500 int row,col; 497 int row,col;
501 int selw, selh; 498 int selw, selh;
502 bool isRTL = KOGlobals::self()->reverseLayout(); 499 bool isRTL = KOGlobals::self()->reverseLayout();
503 500
504 // draw background and topleft frame 501 // draw background and topleft frame
505 p.fillRect(pevent->rect(), mDefaultBackColor); 502 p.fillRect(pevent->rect(), mDefaultBackColor);
506 p.setPen(mDefaultTextColor); 503 p.setPen(mDefaultTextColor);
507 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 504 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
508 505
509 // draw selected days with highlighted background color 506 // draw selected days with highlighted background color
510 if (mSelStart != NOSELECTION) { 507 if (mSelStart != NOSELECTION) {
511 508
512 row = mSelStart/7; 509 row = mSelStart/7;
513 col = mSelStart -row*7; 510 col = mSelStart -row*7;
514 QColor selcol = KOPrefs::instance()->mHighlightColor; 511 QColor selcol = KOPrefs::instance()->mHighlightColor;
515 512
516 if (row == mSelEnd/7) { 513 if (row == mSelEnd/7) {
517 // Single row selection 514 // Single row selection
518 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, 515 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth,
519 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); 516 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol);
520 } else { 517 } else {
521 // draw first row to the right 518 // draw first row to the right
522 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, 519 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth,
523 dheight, selcol); 520 dheight, selcol);
524 // draw full block till last line 521 // draw full block till last line
525 selh = mSelEnd/7-row; 522 selh = mSelEnd/7-row;
526 if (selh > 1) { 523 if (selh > 1) {
527 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); 524 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol);
528 } 525 }
529 // draw last block from left to mSelEnd 526 // draw last block from left to mSelEnd
530 selw = mSelEnd-7*(mSelEnd/7)+1; 527 selw = mSelEnd-7*(mSelEnd/7)+1;
531 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, 528 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight,
532 selw*dwidth, dheight, selcol); 529 selw*dwidth, dheight, selcol);
533 } 530 }
534 } 531 }
535 532
536 // iterate over all days in the matrix and draw the day label in appropriate colors 533 // iterate over all days in the matrix and draw the day label in appropriate colors
537 QColor actcol = mDefaultTextColorShaded; 534 QColor actcol = mDefaultTextColorShaded;
538 p.setPen(actcol); 535 p.setPen(actcol);
539 QPen tmppen; 536 QPen tmppen;
540 for(int i = 0; i < NUMDAYS; i++) { 537 for(int i = 0; i < NUMDAYS; i++) {
541 row = i/7; 538 row = i/7;
542 col = isRTL ? 6-(i-row*7) : i-row*7; 539 col = isRTL ? 6-(i-row*7) : i-row*7;
543 540
544 // if it is the first day of a month switch color from normal to shaded and vice versa 541 // if it is the first day of a month switch color from normal to shaded and vice versa
545 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 542 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
546 if (actcol == mDefaultTextColorShaded) { 543 if (actcol == mDefaultTextColorShaded) {
547 actcol = mDefaultTextColor; 544 actcol = mDefaultTextColor;
548 } else { 545 } else {
549 actcol = mDefaultTextColorShaded; 546 actcol = mDefaultTextColorShaded;
547 }
548 p.setPen(actcol);
550 } 549 }
551 p.setPen(actcol);
552 }
553 550
554 //Reset pen color after selected days block 551 //Reset pen color after selected days block
555 if (i == mSelEnd+1) { 552 if (i == mSelEnd+1) {
556 p.setPen(actcol); 553 p.setPen(actcol);
557 } 554 }
555
556 // if today then draw rectangle around day
557 if (today == i) {
558 tmppen = p.pen();
559 QPen mTodayPen(p.pen());
560
561 mTodayPen.setWidth(mTodayMarginWidth);
562 //draw red rectangle for holidays
563 if (!mHolidays[i].isNull()) {
564 if (actcol == mDefaultTextColor) {
565 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
566 } else {
567 mTodayPen.setColor(mHolidayColorShaded);
568 }
569 }
570 //draw gray rectangle for today if in selection
571 if (i >= mSelStart && i <= mSelEnd) {
572 QColor grey("grey");
573 mTodayPen.setColor(grey);
574 }
575 p.setPen(mTodayPen);
576 p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
577 p.setPen(tmppen);
578 }
558 579
559 // if today then draw rectangle around day 580 // if any events are on that day then draw it using a bold font
560 if (today == i) { 581 if (events[i] > 0) {
561 tmppen = p.pen(); 582 QFont myFont = font();
562 QPen mTodayPen(p.pen()); 583 myFont.setBold(true);
584 p.setFont(myFont);
585 }
563 586
564 mTodayPen.setWidth(mTodayMarginWidth); 587 // if it is a holiday then use the default holiday color
565 //draw red rectangle for holidays
566 if (!mHolidays[i].isNull()) { 588 if (!mHolidays[i].isNull()) {
567 if (actcol == mDefaultTextColor) { 589 if (actcol == mDefaultTextColor) {
568 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 590 p.setPen(KOPrefs::instance()->mHolidayColor);
569 } else { 591 } else {
570 mTodayPen.setColor(mHolidayColorShaded); 592 p.setPen(mHolidayColorShaded);
571 } 593 }
572 } 594 }
573 //draw gray rectangle for today if in selection 595
596 // draw selected days with special color
597 // DO NOT specially highlight holidays in selection !
574 if (i >= mSelStart && i <= mSelEnd) { 598 if (i >= mSelStart && i <= mSelEnd) {
575 QColor grey("grey"); 599 p.setPen(mSelectedDaysColor);
576 mTodayPen.setColor(grey);
577 } 600 }
578 p.setPen(mTodayPen);
579 p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
580 p.setPen(tmppen);
581 }
582 601
583 // if any events are on that day then draw it using a bold font 602 p.drawText(col*dwidth, row*dheight, dwidth, dheight,
584 if (events[i] > 0) { 603 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
585 QFont myFont = font();
586 myFont.setBold(true);
587 p.setFont(myFont);
588 }
589 604
590 // if it is a holiday then use the default holiday color 605 // reset color to actual color
591 if (!mHolidays[i].isNull()) { 606 if (!mHolidays[i].isNull()) {
592 if (actcol == mDefaultTextColor) { 607 p.setPen(actcol);
593 p.setPen(KOPrefs::instance()->mHolidayColor); 608 }
594 } else { 609 // reset bold font to plain font
595 p.setPen(mHolidayColorShaded); 610 if (events[i] > 0) {
611 QFont myFont = font();
612 myFont.setBold(false);
613 p.setFont(myFont);
596 } 614 }
597 }
598
599 // draw selected days with special color
600 // DO NOT specially highlight holidays in selection !
601 if (i >= mSelStart && i <= mSelEnd) {
602 p.setPen(mSelectedDaysColor);
603 }
604
605 p.drawText(col*dwidth, row*dheight, dwidth, dheight,
606 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
607
608 // reset color to actual color
609 if (!mHolidays[i].isNull()) {
610 p.setPen(actcol);
611 }
612 // reset bold font to plain font
613 if (events[i] > 0) {
614 QFont myFont = font();
615 myFont.setBold(false);
616 p.setFont(myFont);
617 }
618 } 615 }
616 bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
619} 617}
620 618
621// ---------------------------------------------------------------------------- 619// ----------------------------------------------------------------------------
622// R E SI Z E E V E N T H A N D L I N G 620// R E SI Z E E V E N T H A N D L I N G
623// ---------------------------------------------------------------------------- 621// ----------------------------------------------------------------------------
624 622
625void KODayMatrix::resizeEvent(QResizeEvent *) 623void KODayMatrix::resizeEvent(QResizeEvent *)
626{ 624{
627 QRect sz = frameRect(); 625 QRect sz = frameRect();
628 daysize.setHeight(sz.height()*7 / NUMDAYS); 626 daysize.setHeight(sz.height()*7 / NUMDAYS);
629 daysize.setWidth(sz.width() / 7); 627 daysize.setWidth(sz.width() / 7);
630} 628}
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index ac2f59c..2dd112a 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -1,314 +1,316 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
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#ifndef _KODAYMAT_H 23#ifndef _KODAYMAT_H
24#define _KODAYMAT_H 24#define _KODAYMAT_H
25 25
26#include <libkcal/calendar.h> 26#include <libkcal/calendar.h>
27 27
28#include <qstring.h> 28#include <qstring.h>
29#include <qframe.h> 29#include <qframe.h>
30#include <qcolor.h> 30#include <qcolor.h>
31#include <qpen.h> 31#include <qpen.h>
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qtooltip.h> 33#include <qtooltip.h>
34#include <qpixmap.h>
34 35
35#include <qmap.h> 36#include <qmap.h>
36 37
37class QDragEnterEvent; 38class QDragEnterEvent;
38class QDragMoveEvent; 39class QDragMoveEvent;
39class QDragLeaveEvent; 40class QDragLeaveEvent;
40class QDropEvent; 41class QDropEvent;
41 42
42class KODayMatrix; 43class KODayMatrix;
43 44
44using namespace KCal; 45using namespace KCal;
45 46
46 47
47/** 48/**
48 * small helper class to dynamically show tooltips inside the day matrix. 49 * small helper class to dynamically show tooltips inside the day matrix.
49 * This class asks the day matrix object for a appropriate label which 50 * This class asks the day matrix object for a appropriate label which
50 * is in our special case the name of the holiday or null if this day is no holiday. 51 * is in our special case the name of the holiday or null if this day is no holiday.
51 */ 52 */
52class DynamicTip : public QToolTip 53class DynamicTip : public QToolTip
53{ 54{
54public: 55public:
55 56
56 /** 57 /**
57 * Constructor that expects a KODayMatrix object as parent. 58 * Constructor that expects a KODayMatrix object as parent.
58 * 59 *
59 * @param parent the parent KODayMatrix control. 60 * @param parent the parent KODayMatrix control.
60 */ 61 */
61 DynamicTip(QWidget* parent ); 62 DynamicTip(QWidget* parent );
62 63
63protected: 64protected:
64 65
65 /** 66 /**
66 * Qt's callback to ask the object to provide an approrpiate text for the 67 * Qt's callback to ask the object to provide an approrpiate text for the
67 * tooltip to be shown. 68 * tooltip to be shown.
68 * 69 *
69 * @param pos coordinates of the mouse. 70 * @param pos coordinates of the mouse.
70 */ 71 */
71 void maybeTip( const QPoint & pos); 72 void maybeTip( const QPoint & pos);
72 73
73private: 74private:
74 75
75 /** the parent control this tooltip is designed for. */ 76 /** the parent control this tooltip is designed for. */
76 KODayMatrix* matrix; 77 KODayMatrix* matrix;
77}; 78};
78 79
79/** 80/**
80 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. 81 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed.
81 * Cornelius thought this was a waste of memory and a lot of overhead. 82 * Cornelius thought this was a waste of memory and a lot of overhead.
82 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame 83 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame
83 * that draws the labels and allows for dragging selection while maintaining nearly full 84 * that draws the labels and allows for dragging selection while maintaining nearly full
84 * compatibility in behaviour with its predecessor. 85 * compatibility in behaviour with its predecessor.
85 * 86 *
86 * The following functionality has been changed: 87 * The following functionality has been changed:
87 * 88 *
88 * o when shifting events in the agenda view from one day to another the day matrix is updated now 89 * o when shifting events in the agenda view from one day to another the day matrix is updated now
89 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. 90 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date.
90 * o no support for Ctrl+click to create groups of dates 91 * o no support for Ctrl+click to create groups of dates
91 * (This has not really been supported in the predecessor. It was not very intuitive nor was it 92 * (This has not really been supported in the predecessor. It was not very intuitive nor was it
92 * user friendly.) 93 * user friendly.)
93 * This feature has been replaced with dragging a selection on the matrix. The matrix will 94 * This feature has been replaced with dragging a selection on the matrix. The matrix will
94 * automatically choose the appropriate selection (e.g. you are not any longer able to select 95 * automatically choose the appropriate selection (e.g. you are not any longer able to select
95 * two distinct groups of date selections as in the old class) 96 * two distinct groups of date selections as in the old class)
96 * o now that you can select more then a week it can happen that not all selected days are 97 * o now that you can select more then a week it can happen that not all selected days are
97 * displayed in the matrix. However this is preferred to the alternative which would mean to 98 * displayed in the matrix. However this is preferred to the alternative which would mean to
98 * adjust the selection and leave some days undisplayed while scrolling through the months 99 * adjust the selection and leave some days undisplayed while scrolling through the months
99 * 100 *
100 * @short day matrix widget of the KDateNavigator 101 * @short day matrix widget of the KDateNavigator
101 * 102 *
102 * @author Eitzenberger Thomas 103 * @author Eitzenberger Thomas
103 */ 104 */
104class KODayMatrix: public QFrame { 105class KODayMatrix: public QFrame {
105 106
106 Q_OBJECT 107 Q_OBJECT
107 108
108public: 109public:
109 110
110 /** constructor to create a day matrix widget. 111 /** constructor to create a day matrix widget.
111 * 112 *
112 * @param parent widget that is the parent of the day matrix. Normally this should 113 * @param parent widget that is the parent of the day matrix. Normally this should
113 * be a KDateNavigator 114 * be a KDateNavigator
114 * @param calendar instance of a calendar on which all calculations are based 115 * @param calendar instance of a calendar on which all calculations are based
115 * @param date start date of the matrix (is expected to be already fixed). It is 116 * @param date start date of the matrix (is expected to be already fixed). It is
116 * assumed that this date is the first week day to be shown in the matrix. 117 * assumed that this date is the first week day to be shown in the matrix.
117 * @param name name of the widget 118 * @param name name of the widget
118 */ 119 */
119 KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); 120 KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name );
120 121
121 /** destructor that deallocates all dynamically allocated private members. 122 /** destructor that deallocates all dynamically allocated private members.
122 */ 123 */
123 ~KODayMatrix(); 124 ~KODayMatrix();
124 125
125 /** updates the day matrix to start with the given date. Does all the necessary 126 /** updates the day matrix to start with the given date. Does all the necessary
126 * checks for holidays or events on a day and stores them for display later on. 127 * checks for holidays or events on a day and stores them for display later on.
127 * Does NOT update the view visually. Call repaint() for this. 128 * Does NOT update the view visually. Call repaint() for this.
128 * 129 *
129 * @param actdate recalculates the day matrix to show NUMDAYS starting from this 130 * @param actdate recalculates the day matrix to show NUMDAYS starting from this
130 * date. 131 * date.
131 */ 132 */
132 void updateView(QDate actdate); 133 void updateView(QDate actdate);
133 134
134 /** returns the QDate object associated with day indexed by the 135 /** returns the QDate object associated with day indexed by the
135 * supplied offset. 136 * supplied offset.
136 */ 137 */
137 const QDate& getDate(int offset); 138 const QDate& getDate(int offset);
138 139
139 /** returns the official name of this holy day or 0 if there is no label 140 /** returns the official name of this holy day or 0 if there is no label
140 * for this day. 141 * for this day.
141 */ 142 */
142 QString getHolidayLabel(int offset); 143 QString getHolidayLabel(int offset);
143 144
144 /** adds all actual selected days from mSelStart to mSelEnd to the supplied 145 /** adds all actual selected days from mSelStart to mSelEnd to the supplied
145 * DateList. 146 * DateList.
146 */ 147 */
147 void addSelectedDaysTo(DateList&); 148 void addSelectedDaysTo(DateList&);
148 149
149 /** sets the actual to be displayed selection in the day matrix starting from 150 /** sets the actual to be displayed selection in the day matrix starting from
150 * start and ending with end. Theview must be manually updated by calling 151 * start and ending with end. Theview must be manually updated by calling
151 * repaint. (?) 152 * repaint. (?)
152 */ 153 */
153 void setSelectedDaysFrom(const QDate& start, const QDate& end); 154 void setSelectedDaysFrom(const QDate& start, const QDate& end);
154 155
155 156
156 /** Is today visible in the view? Keep this in sync with 157 /** Is today visible in the view? Keep this in sync with
157 * the values today (below) can take. 158 * the values today (below) can take.
158 */ 159 */
159 bool isTodayVisible() const { return today>=0; } ; 160 bool isTodayVisible() const { return today>=0; } ;
160 161
161 /** If today is visible, then we can find out if today is 162 /** If today is visible, then we can find out if today is
162 * near the beginning or the end of the month. 163 * near the beginning or the end of the month.
163 * This is dependent on today remaining the index 164 * This is dependent on today remaining the index
164 * in the array of visible dates and going from 165 * in the array of visible dates and going from
165 * top left (0) to bottom right (41). 166 * top left (0) to bottom right (41).
166 */ 167 */
167 bool isBeginningOfMonth() const { return today<=8; } ; 168 bool isBeginningOfMonth() const { return today<=8; } ;
168 bool isEndOfMonth() const { return today>=27; } ; 169 bool isEndOfMonth() const { return today>=27; } ;
169 170
170public slots: 171public slots:
171 /** Recalculates all the flags of the days in the matrix like holidays or events 172 /** Recalculates all the flags of the days in the matrix like holidays or events
172 * on a day (Actually calls above method with the actual startdate). 173 * on a day (Actually calls above method with the actual startdate).
173 */ 174 */
174 void updateView(); 175 void updateView();
175 void updateViewTimed(); 176 void updateViewTimed();
176 void repaintViewTimed(); 177 void repaintViewTimed();
177 178
178 /** 179 /**
179 * Calculate which square in the matrix should be 180 * Calculate which square in the matrix should be
180 * hilighted to indicate it's today. 181 * hilighted to indicate it's today.
181 */ 182 */
182 void recalculateToday(); 183 void recalculateToday();
183 184
184/* 185/*
185 void setStartDate(QDate); 186 void setStartDate(QDate);
186*/ 187*/
187 188
188signals: 189signals:
189 190
190 /** emitted if the user selects a block of days with the mouse by dragging a rectangle 191 /** emitted if the user selects a block of days with the mouse by dragging a rectangle
191 * inside the matrix 192 * inside the matrix
192 * 193 *
193 * @param daylist list of days that have been selected by the user 194 * @param daylist list of days that have been selected by the user
194 */ 195 */
195 void selected( const KCal::DateList &daylist ); 196 void selected( const KCal::DateList &daylist );
196 197
197 /** emitted if the user has dropped an event inside the matrix 198 /** emitted if the user has dropped an event inside the matrix
198 * 199 *
199 * @param event the dropped calendar event 200 * @param event the dropped calendar event
200 */ 201 */
201 void eventDropped(Event *event); 202 void eventDropped(Event *event);
202 203
203protected: 204protected:
204 205
205 void paintEvent(QPaintEvent *ev); 206 void paintEvent(QPaintEvent *ev);
206 207
207 void mousePressEvent (QMouseEvent* e); 208 void mousePressEvent (QMouseEvent* e);
208 209
209 void mouseReleaseEvent (QMouseEvent* e); 210 void mouseReleaseEvent (QMouseEvent* e);
210 211
211 void mouseMoveEvent (QMouseEvent* e); 212 void mouseMoveEvent (QMouseEvent* e);
212 213
213 void dragEnterEvent(QDragEnterEvent *); 214 void dragEnterEvent(QDragEnterEvent *);
214 215
215 void dragMoveEvent(QDragMoveEvent *); 216 void dragMoveEvent(QDragMoveEvent *);
216 217
217 void dragLeaveEvent(QDragLeaveEvent *); 218 void dragLeaveEvent(QDragLeaveEvent *);
218 219
219 void dropEvent(QDropEvent *); 220 void dropEvent(QDropEvent *);
220 221
221 void resizeEvent(QResizeEvent *); 222 void resizeEvent(QResizeEvent *);
222 223
223private: 224private:
225 QPixmap myPix;
224 QTimer* mUpdateTimer; 226 QTimer* mUpdateTimer;
225 QTimer* mRepaintTimer; 227 QTimer* mRepaintTimer;
226 bool mDayChanged; 228 bool mDayChanged;
227 bool mPendingUpdateBeforeRepaint; 229 bool mPendingUpdateBeforeRepaint;
228 230
229 /** returns the index of the day located at the matrix's widget (x,y) position. 231 /** returns the index of the day located at the matrix's widget (x,y) position.
230 * 232 *
231 * @param x horizontal coordinate 233 * @param x horizontal coordinate
232 * @param y vertical coordinate 234 * @param y vertical coordinate
233 */ 235 */
234 int getDayIndexFrom(int x, int y); 236 int getDayIndexFrom(int x, int y);
235 237
236 /** calculates a "shaded" color from the supplied color object. 238 /** calculates a "shaded" color from the supplied color object.
237 * (Copied from Cornelius's kdpdatebutton.cpp) 239 * (Copied from Cornelius's kdpdatebutton.cpp)
238 * 240 *
239 * @param color source based on which a shaded color should be calculated. 241 * @param color source based on which a shaded color should be calculated.
240 */ 242 */
241 QColor getShadedColor(QColor color); 243 QColor getShadedColor(QColor color);
242 244
243 /** number of days to be displayed. For now there is no support for any other number then 42. 245 /** number of days to be displayed. For now there is no support for any other number then 42.
244 so change it at your own risk :o) */ 246 so change it at your own risk :o) */
245 static const int NUMDAYS; 247 static const int NUMDAYS;
246 248
247 /** calendar instance to be queried for holidays, events, ... */ 249 /** calendar instance to be queried for holidays, events, ... */
248 Calendar *mCalendar; 250 Calendar *mCalendar;
249 251
250 /** starting date of the matrix */ 252 /** starting date of the matrix */
251 QDate startdate; 253 QDate startdate;
252 254
253 /** array of day labels to optimeize drawing performance. */ 255 /** array of day labels to optimeize drawing performance. */
254 QString *daylbls; 256 QString *daylbls;
255 257
256 /** array of days displayed to reduce memory consumption by 258 /** array of days displayed to reduce memory consumption by
257 subsequently calling QDate::addDays(). */ 259 subsequently calling QDate::addDays(). */
258 QDate *days; 260 QDate *days;
259 261
260 /** array of storing the number of events on a given day. 262 /** array of storing the number of events on a given day.
261 * used for drawing a bold font if there is at least one event on that day. 263 * used for drawing a bold font if there is at least one event on that day.
262 */ 264 */
263 int *events; 265 int *events;
264 266
265 /** stores holiday names of the days shown in the matrix. */ 267 /** stores holiday names of the days shown in the matrix. */
266 QMap<int,QString> mHolidays; 268 QMap<int,QString> mHolidays;
267 269
268 /** indey of today or -1 if today is not visible in the matrix. */ 270 /** indey of today or -1 if today is not visible in the matrix. */
269 int today; 271 int today;
270 272
271 /** index of day where dragged selection was initiated. 273 /** index of day where dragged selection was initiated.
272 used to detect "negative" timely selections */ 274 used to detect "negative" timely selections */
273 int mSelInit; 275 int mSelInit;
274 276
275 /** if mSelStart has this value it indicates that there is no 277 /** if mSelStart has this value it indicates that there is no
276 actual selection in the matrix. */ 278 actual selection in the matrix. */
277 static const int NOSELECTION; 279 static const int NOSELECTION;
278 280
279 /** index of first selected day. */ 281 /** index of first selected day. */
280 int mSelStart; 282 int mSelStart;
281 283
282 /** index of last selected day. */ 284 /** index of last selected day. */
283 int mSelEnd; 285 int mSelEnd;
284 286
285 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ 287 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */
286 DynamicTip* mToolTip; 288 DynamicTip* mToolTip;
287 289
288 290
289 /** default background colour of the matrix. */ 291 /** default background colour of the matrix. */
290 QColor mDefaultBackColor; 292 QColor mDefaultBackColor;
291 293
292 /** default text color of the matrix. */ 294 /** default text color of the matrix. */
293 QColor mDefaultTextColor; 295 QColor mDefaultTextColor;
294 296
295 /** default text color for days not in the actual month. */ 297 /** default text color for days not in the actual month. */
296 QColor mDefaultTextColorShaded; 298 QColor mDefaultTextColorShaded;
297 299
298 /** default text color for holidays not in the actual month. */ 300 /** default text color for holidays not in the actual month. */
299 QColor mHolidayColorShaded; 301 QColor mHolidayColorShaded;
300 302
301 /** text color for selected days. */ 303 /** text color for selected days. */
302 QColor mSelectedDaysColor; 304 QColor mSelectedDaysColor;
303 305
304 /** default width of the frame drawn around today if it is visible in the matrix. */ 306 /** default width of the frame drawn around today if it is visible in the matrix. */
305 int mTodayMarginWidth; 307 int mTodayMarginWidth;
306 308
307 /** stores actual size of each day in the widget so that I dont need to ask this data 309 /** stores actual size of each day in the widget so that I dont need to ask this data
308 * on every repaint. 310 * on every repaint.
309 */ 311 */
310 QRect daysize; 312 QRect daysize;
311 313
312}; 314};
313 315
314#endif 316#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 4cff23a..6411156 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -883,297 +883,297 @@ void KOMonthView::updateConfig()
883 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 883 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
884 } 884 }
885 bool temp = mShowSatSunComp ; 885 bool temp = mShowSatSunComp ;
886 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 886 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
887 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 887 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
888 computeLayout(); 888 computeLayout();
889 updateDayLabels(); 889 updateDayLabels();
890 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 890 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
891 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 891 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
892 //resizeEvent( 0 ); 892 //resizeEvent( 0 );
893 for (uint i = 0; i < mCells.count(); ++i) { 893 for (uint i = 0; i < mCells.count(); ++i) {
894 mCells[i]->updateConfig(); 894 mCells[i]->updateConfig();
895 } 895 }
896#ifdef DESKTOP_VERSION 896#ifdef DESKTOP_VERSION
897 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 897 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
898#endif 898#endif
899 updateView(); 899 updateView();
900} 900}
901 901
902void KOMonthView::updateDayLabels() 902void KOMonthView::updateDayLabels()
903{ 903{
904 904
905 for (int i = 0; i < 7; i++) { 905 for (int i = 0; i < 7; i++) {
906 if (mWeekStartsMonday) { 906 if (mWeekStartsMonday) {
907 bool show = mShortDayLabels; 907 bool show = mShortDayLabels;
908 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 908 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
909 show = true; 909 show = true;
910 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 910 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
911 } else { 911 } else {
912 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 912 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
913 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 913 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
914 914
915 } 915 }
916 } 916 }
917} 917}
918 918
919void KOMonthView::showDates(const QDate &start, const QDate &) 919void KOMonthView::showDates(const QDate &start, const QDate &)
920{ 920{
921 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 921 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
922 922
923 923
924 mStartDate = start; 924 mStartDate = start;
925 925
926 int startWeekDay = mWeekStartsMonday ? 1 : 7; 926 int startWeekDay = mWeekStartsMonday ? 1 : 7;
927 927
928 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 928 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
929 mStartDate = mStartDate.addDays( -1 ); 929 mStartDate = mStartDate.addDays( -1 );
930 } 930 }
931 931
932 bool primary = false; 932 bool primary = false;
933 uint i; 933 uint i;
934 for( i = 0; i < mCells.size(); ++i ) { 934 for( i = 0; i < mCells.size(); ++i ) {
935 QDate date = mStartDate.addDays( i ); 935 QDate date = mStartDate.addDays( i );
936 mCells[i]->setDate( date ); 936 mCells[i]->setDate( date );
937 937
938#ifndef KORG_NOPLUGINS 938#ifndef KORG_NOPLUGINS
939 // add holiday, if present 939 // add holiday, if present
940 QString hstring(KOCore::self()->holiday(date)); 940 QString hstring(KOCore::self()->holiday(date));
941 mCells[i]->setHoliday( hstring ); 941 mCells[i]->setHoliday( hstring );
942#endif 942#endif
943 943
944 } 944 }
945 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 945 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
946 for( i = 0; i < 6; ++i ) { 946 for( i = 0; i < 6; ++i ) {
947 int wno; 947 int wno;
948 // remember, according to ISO 8601, the first week of the year is the 948 // remember, according to ISO 8601, the first week of the year is the
949 // first week that contains a thursday. Thus we must subtract off 4, 949 // first week that contains a thursday. Thus we must subtract off 4,
950 // not just 1. 950 // not just 1.
951 int dayOfYear = date.dayOfYear(); 951 int dayOfYear = date.dayOfYear();
952 if (dayOfYear % 7 != 0) 952 if (dayOfYear % 7 != 0)
953 wno = dayOfYear / 7 + 1; 953 wno = dayOfYear / 7 + 1;
954 else 954 else
955 wno =dayOfYear / 7; 955 wno =dayOfYear / 7;
956 mWeekLabels[i]->setWeekNum( wno ); 956 mWeekLabels[i]->setWeekNum( wno );
957 date = date.addDays( 7 ); 957 date = date.addDays( 7 );
958 } 958 }
959 updateView(); 959 updateView();
960} 960}
961 961
962void KOMonthView::showEvents(QPtrList<Event>) 962void KOMonthView::showEvents(QPtrList<Event>)
963{ 963{
964 qDebug("KOMonthView::selectEvents is not implemented yet. "); 964 qDebug("KOMonthView::selectEvents is not implemented yet. ");
965} 965}
966 966
967void KOMonthView::changeEventDisplay(Event *, int) 967void KOMonthView::changeEventDisplay(Event *, int)
968{ 968{
969 // this should be re-written to be much more efficient, but this 969 // this should be re-written to be much more efficient, but this
970 // quick-and-dirty-hack gets the job done for right now. 970 // quick-and-dirty-hack gets the job done for right now.
971 updateView(); 971 updateView();
972} 972}
973 973
974void KOMonthView::updateView() 974void KOMonthView::updateView()
975{ 975{
976 976
977 if ( !updatePossible ) 977 if ( !updatePossible )
978 return; 978 return;
979 QTime ti; 979 //QTime ti;
980 ti.start(); 980 //ti.start();
981#if 1 981#if 1
982 int i; 982 int i;
983 for( i = 0; i < mCells.count(); ++i ) { 983 for( i = 0; i < mCells.count(); ++i ) {
984 mCells[i]->startUpdateCell(); 984 mCells[i]->startUpdateCell();
985 } 985 }
986 986
987 QPtrList<Event> events = calendar()->events(); 987 QPtrList<Event> events = calendar()->events();
988 Event *event; 988 Event *event;
989 QDateTime dt; 989 QDateTime dt;
990 bool ok; 990 bool ok;
991 int timeSpan = mCells.size()-1; 991 int timeSpan = mCells.size()-1;
992 QDate endDate = mStartDate.addDays( timeSpan ); 992 QDate endDate = mStartDate.addDays( timeSpan );
993 for( event = events.first(); event; event = events.next() ) { // for event 993 for( event = events.first(); event; event = events.next() ) { // for event
994 if ( event->doesRecur() ) { 994 if ( event->doesRecur() ) {
995 bool last; 995 bool last;
996 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 996 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
997 QDateTime incidenceEnd; 997 QDateTime incidenceEnd;
998 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 998 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
999 bool invalid = false; 999 bool invalid = false;
1000 while( true ) { 1000 while( true ) {
1001 if ( incidenceStart.isValid() ) { 1001 if ( incidenceStart.isValid() ) {
1002 incidenceEnd = incidenceStart.addDays( eventlen ); 1002 incidenceEnd = incidenceStart.addDays( eventlen );
1003 int st = incidenceStart.date().daysTo( endDate ); 1003 int st = incidenceStart.date().daysTo( endDate );
1004 if ( st >= 0 ) { // start before timeend 1004 if ( st >= 0 ) { // start before timeend
1005 int end = mStartDate.daysTo( incidenceEnd.date() ); 1005 int end = mStartDate.daysTo( incidenceEnd.date() );
1006 if ( end >= 0 ) { // end after timestart --- got one! 1006 if ( end >= 0 ) { // end after timestart --- got one!
1007 //normalize 1007 //normalize
1008 st = timeSpan - st; 1008 st = timeSpan - st;
1009 if ( st < 0 ) st = 0; 1009 if ( st < 0 ) st = 0;
1010 if ( end > timeSpan ) end = timeSpan; 1010 if ( end > timeSpan ) end = timeSpan;
1011 int iii; 1011 int iii;
1012 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1012 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1013 for ( iii = st;iii<= end;++iii) 1013 for ( iii = st;iii<= end;++iii)
1014 mCells[iii]->insertEvent( event ); 1014 mCells[iii]->insertEvent( event );
1015 } 1015 }
1016 } 1016 }
1017 } else { 1017 } else {
1018 if ( invalid ) 1018 if ( invalid )
1019 break; 1019 break;
1020 invalid = true; 1020 invalid = true;
1021 //qDebug("invalid %s", event->summary().latin1()); 1021 //qDebug("invalid %s", event->summary().latin1());
1022 incidenceStart = QDateTime( mStartDate ); 1022 incidenceStart = QDateTime( mStartDate );
1023 } 1023 }
1024 if ( last ) 1024 if ( last )
1025 break; 1025 break;
1026 bool ok; 1026 bool ok;
1027 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1027 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1028 if ( ! ok ) 1028 if ( ! ok )
1029 break; 1029 break;
1030 if ( incidenceStart.date() > endDate ) 1030 if ( incidenceStart.date() > endDate )
1031 break; 1031 break;
1032 } 1032 }
1033 } else { // no recur 1033 } else { // no recur
1034 int st = event->dtStart().date().daysTo( endDate ); 1034 int st = event->dtStart().date().daysTo( endDate );
1035 if ( st >= 0 ) { // start before timeend 1035 if ( st >= 0 ) { // start before timeend
1036 int end = mStartDate.daysTo( event->dtEnd().date() ); 1036 int end = mStartDate.daysTo( event->dtEnd().date() );
1037 if ( end >= 0 ) { // end after timestart --- got one! 1037 if ( end >= 0 ) { // end after timestart --- got one!
1038 //normalize 1038 //normalize
1039 st = timeSpan - st; 1039 st = timeSpan - st;
1040 if ( st < 0 ) st = 0; 1040 if ( st < 0 ) st = 0;
1041 if ( end > timeSpan ) end = timeSpan; 1041 if ( end > timeSpan ) end = timeSpan;
1042 int iii; 1042 int iii;
1043 for ( iii = st;iii<= end;++iii) 1043 for ( iii = st;iii<= end;++iii)
1044 mCells[iii]->insertEvent( event ); 1044 mCells[iii]->insertEvent( event );
1045 } 1045 }
1046 } 1046 }
1047 } 1047 }
1048 } 1048 }
1049 // insert due todos 1049 // insert due todos
1050 QPtrList<Todo> todos = calendar()->todos( ); 1050 QPtrList<Todo> todos = calendar()->todos( );
1051 Todo *todo; 1051 Todo *todo;
1052 for(todo = todos.first(); todo; todo = todos.next()) { 1052 for(todo = todos.first(); todo; todo = todos.next()) {
1053 //insertTodo( todo ); 1053 //insertTodo( todo );
1054 if ( todo->hasDueDate() ) { 1054 if ( todo->hasDueDate() ) {
1055 int day = mStartDate.daysTo( todo->dtDue().date() ); 1055 int day = mStartDate.daysTo( todo->dtDue().date() );
1056 if ( day >= 0 && day < mCells.size() ) { 1056 if ( day >= 0 && day < mCells.size() ) {
1057 mCells[day]->insertTodo( todo ); 1057 mCells[day]->insertTodo( todo );
1058 } 1058 }
1059 } 1059 }
1060 } 1060 }
1061 1061
1062 for( i = 0; i < mCells.count(); ++i ) { 1062 for( i = 0; i < mCells.count(); ++i ) {
1063 mCells[i]->finishUpdateCell(); 1063 mCells[i]->finishUpdateCell();
1064 } 1064 }
1065 processSelectionChange(); 1065 processSelectionChange();
1066 mCells[0]->setFocus(); 1066 mCells[0]->setFocus();
1067 1067
1068 1068
1069#else 1069#else
1070 // old code 1070 // old code
1071 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1071 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1072 int i; 1072 int i;
1073 for( i = 0; i < mCells.count(); ++i ) { 1073 for( i = 0; i < mCells.count(); ++i ) {
1074 mCells[i]->updateCell(); 1074 mCells[i]->updateCell();
1075 } 1075 }
1076 1076
1077 //qDebug("KOMonthView::updateView() "); 1077 //qDebug("KOMonthView::updateView() ");
1078 processSelectionChange(); 1078 processSelectionChange();
1079 // qDebug("---------------------------------------------------------------------+ "); 1079 // qDebug("---------------------------------------------------------------------+ ");
1080 mCells[0]->setFocus(); 1080 mCells[0]->setFocus();
1081#endif 1081#endif
1082 1082
1083 qDebug("update time %d ", ti.elapsed()); 1083 //qDebug("update time %d ", ti.elapsed());
1084} 1084}
1085 1085
1086void KOMonthView::resizeEvent(QResizeEvent * e) 1086void KOMonthView::resizeEvent(QResizeEvent * e)
1087{ 1087{
1088 computeLayout(); 1088 computeLayout();
1089 mCells[0]->setFocus(); 1089 mCells[0]->setFocus();
1090} 1090}
1091void KOMonthView::computeLayout() 1091void KOMonthView::computeLayout()
1092{ 1092{
1093 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 1093 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
1094 // note this only changes the text if the requested size crosses the 1094 // note this only changes the text if the requested size crosses the
1095 // threshold between big enough to support the full name and not big 1095 // threshold between big enough to support the full name and not big
1096 // enough. 1096 // enough.
1097 1097
1098 int daysToShow = 7; 1098 int daysToShow = 7;
1099 bool combinedSatSun = false; 1099 bool combinedSatSun = false;
1100 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1100 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1101 daysToShow = 6; 1101 daysToShow = 6;
1102 combinedSatSun = true; 1102 combinedSatSun = true;
1103 } 1103 }
1104 int tWid = topLevelWidget()->size().width(); 1104 int tWid = topLevelWidget()->size().width();
1105 int tHei = topLevelWidget()->size().height(); 1105 int tHei = topLevelWidget()->size().height();
1106 1106
1107 int wid = size().width();//e 1107 int wid = size().width();//e
1108 int hei = size().height()-1; 1108 int hei = size().height()-1;
1109 1109
1110 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1110 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1111 return; 1111 return;
1112 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1112 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1113 QFontMetrics fm ( mWeekLabels[0]->font() ); 1113 QFontMetrics fm ( mWeekLabels[0]->font() );
1114 int weeklabelwid = fm.width( "888" ); 1114 int weeklabelwid = fm.width( "888" );
1115 wid -= weeklabelwid; 1115 wid -= weeklabelwid;
1116 1116
1117 int colWid = wid / daysToShow; 1117 int colWid = wid / daysToShow;
1118 int lastCol = wid - ( colWid*6 ); 1118 int lastCol = wid - ( colWid*6 );
1119 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1119 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1120 int cellHei = (hei - dayLabelHei) /6; 1120 int cellHei = (hei - dayLabelHei) /6;
1121 int colModulo = wid % daysToShow; 1121 int colModulo = wid % daysToShow;
1122 int rowModulo = (hei- dayLabelHei) % 6; 1122 int rowModulo = (hei- dayLabelHei) % 6;
1123 //qDebug("rowmod %d ", rowModulo); 1123 //qDebug("rowmod %d ", rowModulo);
1124 int i; 1124 int i;
1125 int x,y,w,h; 1125 int x,y,w,h;
1126 x= 0; 1126 x= 0;
1127 y= 0; 1127 y= 0;
1128 w = colWid; 1128 w = colWid;
1129 h = dayLabelHei ; 1129 h = dayLabelHei ;
1130 for ( i = 0; i < 7; i++) { 1130 for ( i = 0; i < 7; i++) {
1131 if ( i == daysToShow-colModulo ) 1131 if ( i == daysToShow-colModulo )
1132 ++w; 1132 ++w;
1133 if ( combinedSatSun ) { 1133 if ( combinedSatSun ) {
1134 if ( i >= daysToShow-1 ) { 1134 if ( i >= daysToShow-1 ) {
1135 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1135 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1136 x -= w/2 ; 1136 x -= w/2 ;
1137 } 1137 }
1138 else 1138 else
1139 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1139 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1140 } else 1140 } else
1141 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1141 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1142 x += w; 1142 x += w;
1143 } 1143 }
1144 x= 0; 1144 x= 0;
1145 y= dayLabelHei; 1145 y= dayLabelHei;
1146 w = colWid; 1146 w = colWid;
1147 h = cellHei ; 1147 h = cellHei ;
1148 for ( i = 0; i < mCells.count(); ++i) { 1148 for ( i = 0; i < mCells.count(); ++i) {
1149 1149
1150 w = colWid; 1150 w = colWid;
1151 if ( ((i) % 7) >= 7-colModulo ) { 1151 if ( ((i) % 7) >= 7-colModulo ) {
1152 ++w; 1152 ++w;
1153 } 1153 }
1154 if ( i == (6-rowModulo)*7) 1154 if ( i == (6-rowModulo)*7)
1155 ++h; 1155 ++h;
1156 if ( combinedSatSun ) { 1156 if ( combinedSatSun ) {
1157 if ( (i)%7 >= daysToShow-1 ) { 1157 if ( (i)%7 >= daysToShow-1 ) {
1158 if ( (i)%7 == daysToShow-1 ) { 1158 if ( (i)%7 == daysToShow-1 ) {
1159 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1159 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1160 x -= w ;y += h/2; 1160 x -= w ;y += h/2;
1161 } else { 1161 } else {
1162 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1162 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1163 y -= h/2; 1163 y -= h/2;
1164 } 1164 }
1165 } else 1165 } else
1166 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1166 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1167 1167
1168 } 1168 }
1169 else 1169 else
1170 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1170 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1171 x += w; 1171 x += w;
1172 if ( x + w/2 > wid ) { 1172 if ( x + w/2 > wid ) {
1173 x = 0; 1173 x = 0;
1174 y += h; 1174 y += h;
1175 } 1175 }
1176 } 1176 }
1177 y= dayLabelHei; 1177 y= dayLabelHei;
1178 h = cellHei ; 1178 h = cellHei ;
1179 for ( i = 0; i < 6; i++) { 1179 for ( i = 0; i < 6; i++) {
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 82437d8..99402c4 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -116,193 +116,197 @@ void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
116 116
117void KOTodoListView::contentsDropEvent(QDropEvent *e) 117void KOTodoListView::contentsDropEvent(QDropEvent *e)
118{ 118{
119#ifndef KORG_NODND 119#ifndef KORG_NODND
120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
121 121
122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
123 !QTextDrag::canDecode( e ) ) { 123 !QTextDrag::canDecode( e ) ) {
124 e->ignore(); 124 e->ignore();
125 return; 125 return;
126 } 126 }
127 127
128 DndFactory factory( mCalendar ); 128 DndFactory factory( mCalendar );
129 Todo *todo = factory.createDropTodo(e); 129 Todo *todo = factory.createDropTodo(e);
130 130
131 if (todo) { 131 if (todo) {
132 e->acceptAction(); 132 e->acceptAction();
133 133
134 KOTodoViewItem *destination = 134 KOTodoViewItem *destination =
135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
136 Todo *destinationEvent = 0; 136 Todo *destinationEvent = 0;
137 if (destination) destinationEvent = destination->todo(); 137 if (destination) destinationEvent = destination->todo();
138 138
139 Todo *existingTodo = mCalendar->todo(todo->uid()); 139 Todo *existingTodo = mCalendar->todo(todo->uid());
140 140
141 if(existingTodo) { 141 if(existingTodo) {
142 Incidence *to = destinationEvent; 142 Incidence *to = destinationEvent;
143 while(to) { 143 while(to) {
144 if (to->uid() == todo->uid()) { 144 if (to->uid() == todo->uid()) {
145 KMessageBox::sorry(this, 145 KMessageBox::sorry(this,
146 i18n("Cannot move To-Do to itself\nor a child of itself"), 146 i18n("Cannot move To-Do to itself\nor a child of itself"),
147 i18n("Drop To-Do")); 147 i18n("Drop To-Do"));
148 delete todo; 148 delete todo;
149 return; 149 return;
150 } 150 }
151 to = to->relatedTo(); 151 to = to->relatedTo();
152 } 152 }
153 internalDrop = true; 153 internalDrop = true;
154 if ( destinationEvent ) 154 if ( destinationEvent )
155 reparentTodoSignal( destinationEvent, existingTodo ); 155 reparentTodoSignal( destinationEvent, existingTodo );
156 else 156 else
157 unparentTodoSignal(existingTodo); 157 unparentTodoSignal(existingTodo);
158 delete todo; 158 delete todo;
159 } else { 159 } else {
160 mCalendar->addTodo(todo); 160 mCalendar->addTodo(todo);
161 emit todoDropped(todo, KOGlobals::EVENTADDED); 161 emit todoDropped(todo, KOGlobals::EVENTADDED);
162 if ( destinationEvent ) 162 if ( destinationEvent )
163 reparentTodoSignal( destinationEvent, todo ); 163 reparentTodoSignal( destinationEvent, todo );
164 } 164 }
165 } 165 }
166 else { 166 else {
167 QString text; 167 QString text;
168 if (QTextDrag::decode(e,text)) { 168 if (QTextDrag::decode(e,text)) {
169 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 169 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
170 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 170 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
171 qDebug("Dropped : " + text); 171 qDebug("Dropped : " + text);
172 QStringList emails = QStringList::split(",",text); 172 QStringList emails = QStringList::split(",",text);
173 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 173 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
174 int pos = (*it).find("<"); 174 int pos = (*it).find("<");
175 QString name = (*it).left(pos); 175 QString name = (*it).left(pos);
176 QString email = (*it).mid(pos); 176 QString email = (*it).mid(pos);
177 if (!email.isEmpty() && todoi) { 177 if (!email.isEmpty() && todoi) {
178 todoi->todo()->addAttendee(new Attendee(name,email)); 178 todoi->todo()->addAttendee(new Attendee(name,email));
179 } 179 }
180 } 180 }
181 } 181 }
182 else { 182 else {
183 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 183 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
184 e->ignore(); 184 e->ignore();
185 } 185 }
186 } 186 }
187#endif 187#endif
188} 188}
189 189
190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
191{ 191{
192#ifndef KORG_NODND 192#ifndef KORG_NODND
193 QPoint p(contentsToViewport(e->pos())); 193 QPoint p(contentsToViewport(e->pos()));
194 QListViewItem *i = itemAt(p); 194 QListViewItem *i = itemAt(p);
195 mMousePressed = false; 195 mMousePressed = false;
196 if (i) { 196 if (i) {
197 // if the user clicked into the root decoration of the item, don't 197 // if the user clicked into the root decoration of the item, don't
198 // try to start a drag! 198 // try to start a drag!
199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + 199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
201 itemMargin() || 201 itemMargin() ||
202 p.x() < header()->sectionPos(header()->mapToIndex(0))) { 202 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
203 if (e->button()==Qt::LeftButton) { 203 if (e->button()==Qt::LeftButton) {
204 mPressPos = e->pos(); 204 mPressPos = e->pos();
205 mMousePressed = true; 205 mMousePressed = true;
206 } 206 }
207 } 207 }
208 } 208 }
209#endif 209#endif
210 QListView::contentsMousePressEvent(e); 210 QListView::contentsMousePressEvent(e);
211} 211}
212 212void KOTodoListView::paintEvent(QPaintEvent* e)
213{
214 emit paintNeeded();
215 QListView::paintEvent( e);
216}
213void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 217void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
214{ 218{
215 219
216#ifndef KORG_NODND 220#ifndef KORG_NODND
217 QListView::contentsMouseMoveEvent(e); 221 QListView::contentsMouseMoveEvent(e);
218 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 222 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
219 QApplication::startDragDistance()) { 223 QApplication::startDragDistance()) {
220 mMousePressed = false; 224 mMousePressed = false;
221 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 225 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
222 if (item) { 226 if (item) {
223 DndFactory factory( mCalendar ); 227 DndFactory factory( mCalendar );
224 ICalDrag *vd = factory.createDrag( 228 ICalDrag *vd = factory.createDrag(
225 ((KOTodoViewItem *)item)->todo(),viewport()); 229 ((KOTodoViewItem *)item)->todo(),viewport());
226 internalDrop = false; 230 internalDrop = false;
227 // we cannot do any senseful here, because the DnD is still broken in Qt 231 // we cannot do any senseful here, because the DnD is still broken in Qt
228 if (vd->drag()) { 232 if (vd->drag()) {
229 if ( !internalDrop ) { 233 if ( !internalDrop ) {
230 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 234 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
231 qDebug("Dnd: External move: Delete drag source "); 235 qDebug("Dnd: External move: Delete drag source ");
232 } else 236 } else
233 qDebug("Dnd: Internal move "); 237 qDebug("Dnd: Internal move ");
234 238
235 } else { 239 } else {
236 if ( !internalDrop ) { 240 if ( !internalDrop ) {
237 qDebug("Dnd: External Copy"); 241 qDebug("Dnd: External Copy");
238 } else 242 } else
239 qDebug("DnD: Internal copy: Copy pending"); 243 qDebug("DnD: Internal copy: Copy pending");
240 } 244 }
241 } 245 }
242 } 246 }
243#endif 247#endif
244} 248}
245void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 249void KOTodoListView::keyPressEvent ( QKeyEvent * e )
246{ 250{
247 251
248 QListViewItem* cn; 252 QListViewItem* cn;
249 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 253 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
250 cn = currentItem(); 254 cn = currentItem();
251 if ( cn ) { 255 if ( cn ) {
252 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 256 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
253 if ( ci ){ 257 if ( ci ){
254 if ( e->state() == ShiftButton ) 258 if ( e->state() == ShiftButton )
255 ci->setOn( false ); 259 ci->setOn( false );
256 else 260 else
257 ci->setOn( true ); 261 ci->setOn( true );
258 cn = cn->itemBelow(); 262 cn = cn->itemBelow();
259 if ( cn ) { 263 if ( cn ) {
260 setCurrentItem ( cn ); 264 setCurrentItem ( cn );
261 ensureItemVisible ( cn ); 265 ensureItemVisible ( cn );
262 } 266 }
263 267
264 } 268 }
265 } 269 }
266 270
267 return; 271 return;
268 } 272 }
269 273
270 // qDebug("KOTodoListView::keyPressEvent "); 274 // qDebug("KOTodoListView::keyPressEvent ");
271 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 275 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
272 switch ( e->key() ) { 276 switch ( e->key() ) {
273 case Qt::Key_Down: 277 case Qt::Key_Down:
274 case Qt::Key_Up: 278 case Qt::Key_Up:
275 QListView::keyPressEvent ( e ); 279 QListView::keyPressEvent ( e );
276 break; 280 break;
277 case Qt::Key_Left: 281 case Qt::Key_Left:
278 case Qt::Key_Right: 282 case Qt::Key_Right:
279 QListView::keyPressEvent ( e ); 283 QListView::keyPressEvent ( e );
280 e->accept(); 284 e->accept();
281 return; 285 return;
282 break; 286 break;
283 default: 287 default:
284 e->ignore(); 288 e->ignore();
285 break; 289 break;
286 } 290 }
287 return; 291 return;
288 } 292 }
289 e->ignore(); 293 e->ignore();
290} 294}
291void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 295void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
292{ 296{
293 QListView::contentsMouseReleaseEvent(e); 297 QListView::contentsMouseReleaseEvent(e);
294 mMousePressed = false; 298 mMousePressed = false;
295} 299}
296 300
297void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 301void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
298{ 302{
299 if (!e) return; 303 if (!e) return;
300 304
301 QPoint vp = contentsToViewport(e->pos()); 305 QPoint vp = contentsToViewport(e->pos());
302 306
303 QListViewItem *item = itemAt(vp); 307 QListViewItem *item = itemAt(vp);
304 308
305 emit double_Clicked(item); 309 emit double_Clicked(item);
306 if (!item) return; 310 if (!item) return;
307 311
308 emit doubleClicked(item,vp,0); 312 emit doubleClicked(item,vp,0);
@@ -408,234 +412,243 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
408 412
409 413
410 mItemPopupMenu = new QPopupMenu(this); 414 mItemPopupMenu = new QPopupMenu(this);
411 mItemPopupMenu->insertItem(i18n("Show..."), this, 415 mItemPopupMenu->insertItem(i18n("Show..."), this,
412 SLOT (showTodo())); 416 SLOT (showTodo()));
413 mItemPopupMenu->insertItem(i18n("Edit..."), this, 417 mItemPopupMenu->insertItem(i18n("Edit..."), this,
414 SLOT (editTodo())); 418 SLOT (editTodo()));
415 mItemPopupMenu->insertItem( i18n("Delete"), this, 419 mItemPopupMenu->insertItem( i18n("Delete"), this,
416 SLOT (deleteTodo())); 420 SLOT (deleteTodo()));
417 mItemPopupMenu->insertItem( i18n("Clone..."), this, 421 mItemPopupMenu->insertItem( i18n("Clone..."), this,
418 SLOT (cloneTodo())); 422 SLOT (cloneTodo()));
419 mItemPopupMenu->insertItem( i18n("Move..."), this, 423 mItemPopupMenu->insertItem( i18n("Move..."), this,
420 SLOT (moveTodo())); 424 SLOT (moveTodo()));
421 mItemPopupMenu->insertItem( i18n("Beam..."), this, 425 mItemPopupMenu->insertItem( i18n("Beam..."), this,
422 SLOT (beamTodo())); 426 SLOT (beamTodo()));
423 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 427 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
424 SLOT (cancelTodo())); 428 SLOT (cancelTodo()));
425 mItemPopupMenu->insertSeparator(); 429 mItemPopupMenu->insertSeparator();
426 430
427 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 431 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
428 SLOT (newTodo())); 432 SLOT (newTodo()));
429 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 433 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
430 SLOT (newSubTodo())); 434 SLOT (newSubTodo()));
431 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 435 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
432 SLOT (unparentTodo()),0,21); 436 SLOT (unparentTodo()),0,21);
433 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 437 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
434 SLOT (reparentTodo()),0,22); 438 SLOT (reparentTodo()),0,22);
435 mItemPopupMenu->insertSeparator(); 439 mItemPopupMenu->insertSeparator();
436#if 0 440#if 0
437 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 441 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
438 this, SLOT( purgeCompleted() ) ); 442 this, SLOT( purgeCompleted() ) );
439 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 443 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
440 this, SLOT( toggleCompleted() ),0, 33 ); 444 this, SLOT( toggleCompleted() ),0, 33 );
441 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 445 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
442 this, SLOT( toggleQuickTodo() ),0, 34 ); 446 this, SLOT( toggleQuickTodo() ),0, 34 );
443 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 447 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
444 this, SLOT( toggleRunning() ),0, 35 ); 448 this, SLOT( toggleRunning() ),0, 35 );
445 449
446#endif 450#endif
447 mPopupMenu = new QPopupMenu(this); 451 mPopupMenu = new QPopupMenu(this);
448 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 452 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
449 SLOT (newTodo()),0,1); 453 SLOT (newTodo()),0,1);
450 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 454 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
451 this, SLOT(purgeCompleted()),0,2); 455 this, SLOT(purgeCompleted()),0,2);
452 mPopupMenu->insertItem(i18n("Show Completed"), 456 mPopupMenu->insertItem(i18n("Show Completed"),
453 this, SLOT( toggleCompleted() ),0,3 ); 457 this, SLOT( toggleCompleted() ),0,3 );
454 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 458 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
455 this, SLOT( toggleQuickTodo() ),0,4 ); 459 this, SLOT( toggleQuickTodo() ),0,4 );
456 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 460 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
457 this, SLOT( toggleRunning() ),0,5 ); 461 this, SLOT( toggleRunning() ),0,5 );
458 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 462 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
459 this, SLOT( setAllOpen() ),0,6 ); 463 this, SLOT( setAllOpen() ),0,6 );
460 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 464 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
461 this, SLOT( setAllClose() ),0,7 ); 465 this, SLOT( setAllClose() ),0,7 );
462 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 466 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
463 this, SLOT( setAllFlat() ),0,8 ); 467 this, SLOT( setAllFlat() ),0,8 );
464 mDocPrefs = new DocPrefs( name ); 468 mDocPrefs = new DocPrefs( name );
465 469
466 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 470 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
467 mPopupMenu->setCheckable( true ); 471 mPopupMenu->setCheckable( true );
468 mItemPopupMenu->setCheckable( true ); 472 mItemPopupMenu->setCheckable( true );
469 473
470 474
471 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 475 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
472 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 476 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
473 477
474 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 478 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
475 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 479 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
476 480
477 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 481 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
478 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 482 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
479 483
480 484
481 // Double clicking conflicts with opening/closing the subtree 485 // Double clicking conflicts with opening/closing the subtree
482 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 486 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
483 SLOT( editItem( QListViewItem *) ) ); 487 SLOT( editItem( QListViewItem *) ) );
484 /* 488 /*
485 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 489 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
486 const QPoint &,int ) ), 490 const QPoint &,int ) ),
487 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 491 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
488 */ 492 */
489 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 493 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
490 const QPoint &,int ) ), 494 const QPoint &,int ) ),
491 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 495 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
492 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 496 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
493 SLOT( itemClicked( QListViewItem * ) ) ); 497 SLOT( itemClicked( QListViewItem * ) ) );
494 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 498 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
495 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 499 SLOT( itemDoubleClicked( QListViewItem * ) ) );
496 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 500 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
497 SLOT( updateView() ) ); 501 SLOT( updateView() ) );
498 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 502 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
499 SLOT( todoModified(Todo *, int) ) ); 503 SLOT( todoModified(Todo *, int) ) );
500 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 504 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
501 SLOT( itemStateChanged( QListViewItem * ) ) ); 505 SLOT( itemStateChanged( QListViewItem * ) ) );
502 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 506 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
503 SLOT( itemStateChanged( QListViewItem * ) ) ); 507 SLOT( itemStateChanged( QListViewItem * ) ) );
508 connect( mTodoListView, SIGNAL( paintNeeded() ),
509 SLOT( paintNeeded()) );
504 510
505#if 0 511#if 0
506 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 512 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
507 SLOT(selectionChanged(QListViewItem *))); 513 SLOT(selectionChanged(QListViewItem *)));
508 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 514 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
509 SLOT(selectionChanged(QListViewItem *))); 515 SLOT(selectionChanged(QListViewItem *)));
510 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 516 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
511 SLOT(selectionChanged(QListViewItem *))); 517 SLOT(selectionChanged(QListViewItem *)));
512#endif 518#endif
513 519
514 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 520 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
515 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 521 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
516 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 522 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
517 523
518 connect( mTodoListView, SIGNAL(selectionChanged() ), 524 connect( mTodoListView, SIGNAL(selectionChanged() ),
519 SLOT( processSelectionChange() ) ); 525 SLOT( processSelectionChange() ) );
520 connect( mQuickAdd, SIGNAL( returnPressed () ), 526 connect( mQuickAdd, SIGNAL( returnPressed () ),
521 SLOT( addQuickTodo() ) ); 527 SLOT( addQuickTodo() ) );
522 528
523} 529}
524 530
525KOTodoView::~KOTodoView() 531KOTodoView::~KOTodoView()
526{ 532{
527 delete mDocPrefs; 533 delete mDocPrefs;
528} 534}
529 535
530void KOTodoView::jumpToDate () 536void KOTodoView::jumpToDate ()
531{ 537{
532 // if (mActiveItem) { 538 // if (mActiveItem) {
533// mActiveItem->todo()); 539// mActiveItem->todo());
534// if ( mActiveItem->todo()->hasDueDate() ) 540// if ( mActiveItem->todo()->hasDueDate() )
535// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 541// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
536} 542}
543void KOTodoView::paintNeeded()
544{
545 if ( mPendingUpdateBeforeRepaint ) {
546 updateView();
547 mPendingUpdateBeforeRepaint = false;
548 }
549}
537void KOTodoView::paintEvent(QPaintEvent * pevent) 550void KOTodoView::paintEvent(QPaintEvent * pevent)
538{ 551{
539 if ( mPendingUpdateBeforeRepaint ) { 552 if ( mPendingUpdateBeforeRepaint ) {
540 updateView(); 553 updateView();
541 mPendingUpdateBeforeRepaint = false; 554 mPendingUpdateBeforeRepaint = false;
542 } 555 }
543 KOrg::BaseView::paintEvent( pevent); 556 KOrg::BaseView::paintEvent( pevent);
544} 557}
545 bool mPendingUpdateBeforeRepaint; 558
546void KOTodoView::updateView() 559void KOTodoView::updateView()
547{ 560{
548 pendingSubtodo = 0; 561 pendingSubtodo = 0;
549 if ( mBlockUpdate ) { 562 if ( mBlockUpdate ) {
550 return; 563 return;
551 } 564 }
552 if ( !isVisible() ) { 565 if ( !isVisible() ) {
553 mPendingUpdateBeforeRepaint = true; 566 mPendingUpdateBeforeRepaint = true;
554 return; 567 return;
555 } 568 }
556 //qDebug("KOTodoView::updateView() %x", this); 569 //qDebug("KOTodoView::updateView() %x", this);
557 if ( isFlatDisplay ) { 570 if ( isFlatDisplay ) {
558 setAllFlat(); 571 setAllFlat();
559 return; 572 return;
560 } 573 }
561 //qDebug("update "); 574 //qDebug("update ");
562// kdDebug() << "KOTodoView::updateView()" << endl; 575// kdDebug() << "KOTodoView::updateView()" << endl;
563 QFont fo = KOPrefs::instance()->mTodoViewFont; 576 QFont fo = KOPrefs::instance()->mTodoViewFont;
564 mTodoListView->clear(); 577 mTodoListView->clear();
565 if ( mName == "todolistsmall" ) { 578 if ( mName == "todolistsmall" ) {
566 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 579 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
567 int ps = fo.pointSize() -2; 580 int ps = fo.pointSize() -2;
568 if ( ps > 12 ) 581 if ( ps > 12 )
569 ps -= 2; 582 ps -= 2;
570 fo.setPointSize( ps ); 583 fo.setPointSize( ps );
571 } 584 }
572 } 585 }
573 586
574 mTodoListView->setFont( fo ); 587 mTodoListView->setFont( fo );
575 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 588 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
576 //mTodoListView->header()->setMaximumHeight(fm.height()); 589 //mTodoListView->header()->setMaximumHeight(fm.height());
577 QPtrList<Todo> todoList = calendar()->todos(); 590 QPtrList<Todo> todoList = calendar()->todos();
578 591
579/* 592/*
580 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 593 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
581 Event *t; 594 Event *t;
582 for(t = todoList.first(); t; t = todoList.next()) { 595 for(t = todoList.first(); t; t = todoList.next()) {
583 kdDebug() << " " << t->getSummary() << endl; 596 kdDebug() << " " << t->getSummary() << endl;
584 597
585 if (t->getRelatedTo()) { 598 if (t->getRelatedTo()) {
586 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 599 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
587 } 600 }
588 601
589 QPtrList<Event> l = t->getRelations(); 602 QPtrList<Event> l = t->getRelations();
590 Event *c; 603 Event *c;
591 for(c=l.first();c;c=l.next()) { 604 for(c=l.first();c;c=l.next()) {
592 kdDebug() << " - relation: " << c->getSummary() << endl; 605 kdDebug() << " - relation: " << c->getSummary() << endl;
593 } 606 }
594 } 607 }
595*/ 608*/
596 609
597 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 610 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
598 // specific order of events. That means that we have to generate parent items 611 // specific order of events. That means that we have to generate parent items
599 // recursively for proper hierarchical display of Todos. 612 // recursively for proper hierarchical display of Todos.
600 mTodoMap.clear(); 613 mTodoMap.clear();
601 Todo *todo; 614 Todo *todo;
602 todo = todoList.first();// todo; todo = todoList.next()) { 615 todo = todoList.first();// todo; todo = todoList.next()) {
603 while ( todo ) { 616 while ( todo ) {
604 bool next = true; 617 bool next = true;
605 // qDebug("todo %s ", todo->summary().latin1()); 618 // qDebug("todo %s ", todo->summary().latin1());
606 Incidence *incidence = todo->relatedTo(); 619 Incidence *incidence = todo->relatedTo();
607 while ( incidence ) { 620 while ( incidence ) {
608 if ( incidence->type() == "Todo") { 621 if ( incidence->type() == "Todo") {
609 //qDebug("related %s ",incidence->summary().latin1() ); 622 //qDebug("related %s ",incidence->summary().latin1() );
610 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 623 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
611 //qDebug("related not found "); 624 //qDebug("related not found ");
612 todoList.remove( ); 625 todoList.remove( );
613 todo = todoList.current(); 626 todo = todoList.current();
614 next = false; 627 next = false;
615 incidence = 0; 628 incidence = 0;
616 629
617 } else { 630 } else {
618 //qDebug("related found "); 631 //qDebug("related found ");
619 incidence = incidence->relatedTo(); 632 incidence = incidence->relatedTo();
620 } 633 }
621 } else 634 } else
622 incidence = 0; 635 incidence = 0;
623 } 636 }
624 if ( next ) 637 if ( next )
625 todo = todoList.next(); 638 todo = todoList.next();
626 } 639 }
627// qDebug("again .... "); 640// qDebug("again .... ");
628// for(todo = todoList.first(); todo; todo = todoList.next()) { 641// for(todo = todoList.first(); todo; todo = todoList.next()) {
629 642
630// qDebug("yytodo %s ", todo->summary().latin1()); 643// qDebug("yytodo %s ", todo->summary().latin1());
631// } 644// }
632 //qDebug("for "); 645 //qDebug("for ");
633 for(todo = todoList.first(); todo; todo = todoList.next()) { 646 for(todo = todoList.first(); todo; todo = todoList.next()) {
634 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 647 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
635 { 648 {
636 insertTodoItem(todo); 649 insertTodoItem(todo);
637 } 650 }
638 } 651 }
639 //qDebug("for end "); 652 //qDebug("for end ");
640 // Restore opened/closed state 653 // Restore opened/closed state
641 mTodoListView->blockSignals( true ); 654 mTodoListView->blockSignals( true );
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 16bc133..2a9e737 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -1,249 +1,253 @@
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#ifndef KOTODOVIEW_H 23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H 24#define KOTODOVIEW_H
25 25
26#include <qfont.h> 26#include <qfont.h>
27#include <qfontmetrics.h> 27#include <qfontmetrics.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qlistbox.h> 31#include <qlistbox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qlistview.h> 35#include <qlistview.h>
36#include <klistview.h> 36#include <klistview.h>
37 37
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40 40
41#include <korganizer/baseview.h> 41#include <korganizer/baseview.h>
42 42
43#include "kotodoviewitem.h" 43#include "kotodoviewitem.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "koglobals.h" 45#include "koglobals.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47 47
48class QDragEnterEvent; 48class QDragEnterEvent;
49class QDragMoveEvent; 49class QDragMoveEvent;
50class QDragLeaveEvent; 50class QDragLeaveEvent;
51class QDropEvent; 51class QDropEvent;
52 52
53class DocPrefs; 53class DocPrefs;
54 54
55class KOTodoListView : public KListView 55class KOTodoListView : public KListView
56{ 56{
57 Q_OBJECT 57 Q_OBJECT
58 public: 58 public:
59 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 59 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
60 virtual ~KOTodoListView() {} 60 virtual ~KOTodoListView() {}
61 61
62 signals: 62 signals:
63 void paintNeeded();
63 void todoDropped(Todo *, int); 64 void todoDropped(Todo *, int);
64 void double_Clicked(QListViewItem *item); 65 void double_Clicked(QListViewItem *item);
65 void reparentTodoSignal( Todo *,Todo * ); 66 void reparentTodoSignal( Todo *,Todo * );
66 void unparentTodoSignal(Todo *); 67 void unparentTodoSignal(Todo *);
67 void deleteTodo( Todo * ); 68 void deleteTodo( Todo * );
68 protected: 69 protected:
69 void contentsDragEnterEvent(QDragEnterEvent *); 70 void contentsDragEnterEvent(QDragEnterEvent *);
70 void contentsDragMoveEvent(QDragMoveEvent *); 71 void contentsDragMoveEvent(QDragMoveEvent *);
71 void contentsDragLeaveEvent(QDragLeaveEvent *); 72 void contentsDragLeaveEvent(QDragLeaveEvent *);
72 void contentsDropEvent(QDropEvent *); 73 void contentsDropEvent(QDropEvent *);
73 74
74 void contentsMousePressEvent(QMouseEvent *); 75 void contentsMousePressEvent(QMouseEvent *);
75 void contentsMouseMoveEvent(QMouseEvent *); 76 void contentsMouseMoveEvent(QMouseEvent *);
76 void contentsMouseReleaseEvent(QMouseEvent *); 77 void contentsMouseReleaseEvent(QMouseEvent *);
77 void contentsMouseDoubleClickEvent(QMouseEvent *); 78 void contentsMouseDoubleClickEvent(QMouseEvent *);
78 79
79 private: 80 private:
81 void paintEvent(QPaintEvent * pevent);
80 bool internalDrop; 82 bool internalDrop;
81 QString mName; 83 QString mName;
82 Calendar *mCalendar; 84 Calendar *mCalendar;
83 QPoint mPressPos; 85 QPoint mPressPos;
84 bool mMousePressed; 86 bool mMousePressed;
85 QListViewItem *mOldCurrent; 87 QListViewItem *mOldCurrent;
86 void keyPressEvent ( QKeyEvent * ) ; 88 void keyPressEvent ( QKeyEvent * ) ;
87}; 89};
88 90
89 91
90/** 92/**
91 This is the line-edit on top of the todoview for fast addition of new todos 93 This is the line-edit on top of the todoview for fast addition of new todos
92*/ 94*/
93class KOQuickTodo : public QLineEdit 95class KOQuickTodo : public QLineEdit
94{ 96{
95 public: 97 public:
96 KOQuickTodo(QWidget *parent=0); 98 KOQuickTodo(QWidget *parent=0);
97 protected: 99 protected:
98 void focusInEvent(QFocusEvent *ev); 100 void focusInEvent(QFocusEvent *ev);
99 void focusOutEvent(QFocusEvent *ev); 101 void focusOutEvent(QFocusEvent *ev);
100}; 102};
101 103
102 104
103/** 105/**
104 This class provides a multi-column list view of todo events. 106 This class provides a multi-column list view of todo events.
105 107
106 @short multi-column list view of todo events. 108 @short multi-column list view of todo events.
107 @author Cornelius Schumacher <schumacher@kde.org> 109 @author Cornelius Schumacher <schumacher@kde.org>
108*/ 110*/
109class KOTodoView : public KOrg::BaseView 111class KOTodoView : public KOrg::BaseView
110{ 112{
111 Q_OBJECT 113 Q_OBJECT
112 public: 114 public:
113 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); 115 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 );
114 ~KOTodoView(); 116 ~KOTodoView();
115 117
116 QPtrList<Incidence> selectedIncidences(); 118 QPtrList<Incidence> selectedIncidences();
117 QPtrList<Todo> selectedTodos(); 119 QPtrList<Todo> selectedTodos();
118 120
119 DateList selectedDates() 121 DateList selectedDates()
120 {DateList q; 122 {DateList q;
121 return q;} 123 return q;}
122 124
123 /** Return number of shown dates. TodoView does not show dates, */ 125 /** Return number of shown dates. TodoView does not show dates, */
124 int currentDateCount() { return 0; } 126 int currentDateCount() { return 0; }
125 127
126 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); 128 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td);
127 129
128 void setDocumentId( const QString & ); 130 void setDocumentId( const QString & );
129 131
130 void saveLayout(KConfig *config, const QString &group) const; 132 void saveLayout(KConfig *config, const QString &group) const;
131 void restoreLayout(KConfig *config, const QString &group); 133 void restoreLayout(KConfig *config, const QString &group);
132 /** Create a popup menu to set categories */ 134 /** Create a popup menu to set categories */
133 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); 135 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem);
134 void setNavigator( DateNavigator* nav ) {mNavigator = nav;} 136 void setNavigator( DateNavigator* nav ) {mNavigator = nav;}
135 137
136 public slots: 138 public slots:
137 void updateView(); 139 void updateView();
138 void updateConfig(); 140 void updateConfig();
139 141
140 void changeEventDisplay(Event *, int); 142 void changeEventDisplay(Event *, int);
141 143
142 void showDates(const QDate &start, const QDate &end); 144 void showDates(const QDate &start, const QDate &end);
143 void showEvents(QPtrList<Event> eventList); 145 void showEvents(QPtrList<Event> eventList);
144 146
145 void clearSelection(); 147 void clearSelection();
146 void jumpToDate (); 148 void jumpToDate ();
147 149
148 void editItem(QListViewItem *item); 150 void editItem(QListViewItem *item);
149 void showItem(QListViewItem *item,const QPoint &,int); 151 void showItem(QListViewItem *item,const QPoint &,int);
150 void popupMenu(QListViewItem *item,const QPoint &,int); 152 void popupMenu(QListViewItem *item,const QPoint &,int);
151 void newTodo(); 153 void newTodo();
152 void newSubTodo(); 154 void newSubTodo();
153 void unparentTodo(); 155 void unparentTodo();
154 void reparentTodo(); 156 void reparentTodo();
155 void showTodo(); 157 void showTodo();
156 void editTodo(); 158 void editTodo();
157 void cloneTodo(); 159 void cloneTodo();
158 void cancelTodo(); 160 void cancelTodo();
159 void moveTodo(); 161 void moveTodo();
160 void beamTodo(); 162 void beamTodo();
161 void deleteTodo(); 163 void deleteTodo();
162 164
163 void setNewPriority(int); 165 void setNewPriority(int);
164 void setNewPercentage(int); 166 void setNewPercentage(int);
165 void changedCategories(int); 167 void changedCategories(int);
166 168
167 void setAllOpen(); 169 void setAllOpen();
168 void setAllClose(); 170 void setAllClose();
169 void setAllFlat(); 171 void setAllFlat();
170 172
171 void purgeCompleted(); 173 void purgeCompleted();
172 void toggleCompleted(); 174 void toggleCompleted();
173 void toggleRunning(); 175 void toggleRunning();
174 void toggleQuickTodo(); 176 void toggleQuickTodo();
175 void updateTodo( Todo *, int ); 177 void updateTodo( Todo *, int );
176 178
177 void itemClicked(QListViewItem *); 179 void itemClicked(QListViewItem *);
178 void itemStateChanged(QListViewItem *); 180 void itemStateChanged(QListViewItem *);
179 void modified(bool); 181 void modified(bool);
180 void itemDoubleClicked(QListViewItem *item); 182 void itemDoubleClicked(QListViewItem *item);
181 183
182 signals: 184 signals:
183 void newTodoSignal(); 185 void newTodoSignal();
184 void newSubTodoSignal(Todo *); 186 void newSubTodoSignal(Todo *);
185 void unparentTodoSignal(Todo *); 187 void unparentTodoSignal(Todo *);
186 void reparentTodoSignal( Todo *,Todo * ); 188 void reparentTodoSignal( Todo *,Todo * );
187 void showTodoSignal(Todo *); 189 void showTodoSignal(Todo *);
188 190
189 void editTodoSignal(Todo *); 191 void editTodoSignal(Todo *);
190 void deleteTodoSignal(Todo *); 192 void deleteTodoSignal(Todo *);
191 void todoModifiedSignal (Todo *, int); 193 void todoModifiedSignal (Todo *, int);
192 194
193 void isModified(bool); 195 void isModified(bool);
194 void cloneTodoSignal( Incidence * ); 196 void cloneTodoSignal( Incidence * );
195 void cancelTodoSignal( Incidence * ); 197 void cancelTodoSignal( Incidence * );
196 void moveTodoSignal( Incidence * ); 198 void moveTodoSignal( Incidence * );
197 void beamTodoSignal( Incidence * ); 199 void beamTodoSignal( Incidence * );
198 void purgeCompletedSignal(); 200 void purgeCompletedSignal();
199 201
200 protected slots: 202 protected slots:
203 void paintNeeded();
201 void processSelectionChange(); 204 void processSelectionChange();
202 void addQuickTodo(); 205 void addQuickTodo();
203 void setTodoModified( Todo* ); 206 void setTodoModified( Todo* );
204 void todoModified(Todo *, int ); 207 void todoModified(Todo *, int );
205 208
206 private: 209 private:
207 /* 210 /*
208 * the TodoEditor approach is rather unscaling in the long 211 * the TodoEditor approach is rather unscaling in the long
209 * run. 212 * run.
210 * Korganizer keeps it in memory and we need to update 213 * Korganizer keeps it in memory and we need to update
211 * 1. make KOTodoViewItem a QObject again? 214 * 1. make KOTodoViewItem a QObject again?
212 * 2. add a public method for setting one todo modified? 215 * 2. add a public method for setting one todo modified?
213 * 3. add a private method for setting a todo modified + friend here? 216 * 3. add a private method for setting a todo modified + friend here?
214 * -- zecke 2002-07-08 217 * -- zecke 2002-07-08
215 */ 218 */
219 friend class KOTodoListView;
216 void paintEvent(QPaintEvent * pevent); 220 void paintEvent(QPaintEvent * pevent);
217 bool mPendingUpdateBeforeRepaint; 221 bool mPendingUpdateBeforeRepaint;
218 friend class KOTodoViewItem; 222 friend class KOTodoViewItem;
219 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); 223 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
220 void restoreItemState( QListViewItem * ); 224 void restoreItemState( QListViewItem * );
221 225
222 bool checkTodo( Todo * ); 226 bool checkTodo( Todo * );
223 bool isFlatDisplay; 227 bool isFlatDisplay;
224 void setOpen( QListViewItem*, bool setOpen); 228 void setOpen( QListViewItem*, bool setOpen);
225 KOTodoListView *mTodoListView; 229 KOTodoListView *mTodoListView;
226 QPopupMenu *mItemPopupMenu; 230 QPopupMenu *mItemPopupMenu;
227 QPopupMenu *mPopupMenu; 231 QPopupMenu *mPopupMenu;
228 QPopupMenu *mPriorityPopupMenu; 232 QPopupMenu *mPriorityPopupMenu;
229 QPopupMenu *mPercentageCompletedPopupMenu; 233 QPopupMenu *mPercentageCompletedPopupMenu;
230 QPopupMenu *mCategoryPopupMenu; 234 QPopupMenu *mCategoryPopupMenu;
231 235
232 QMap<int, int> mPercentage; 236 QMap<int, int> mPercentage;
233 QMap<int, int> mPriority; 237 QMap<int, int> mPriority;
234 QMap<int, QString> mCategory; 238 QMap<int, QString> mCategory;
235 KOTodoViewItem *mActiveItem; 239 KOTodoViewItem *mActiveItem;
236 240
237 QMap<Todo *,KOTodoViewItem *> mTodoMap; 241 QMap<Todo *,KOTodoViewItem *> mTodoMap;
238 QString mName; 242 QString mName;
239 243
240 DocPrefs *mDocPrefs; 244 DocPrefs *mDocPrefs;
241 QString mCurrentDoc; 245 QString mCurrentDoc;
242 KOQuickTodo *mQuickAdd; 246 KOQuickTodo *mQuickAdd;
243 bool mBlockUpdate; 247 bool mBlockUpdate;
244 void keyPressEvent ( QKeyEvent * ) ; 248 void keyPressEvent ( QKeyEvent * ) ;
245 KOTodoViewItem * pendingSubtodo; 249 KOTodoViewItem * pendingSubtodo;
246 DateNavigator* mNavigator; 250 DateNavigator* mNavigator;
247}; 251};
248 252
249#endif 253#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 30f5fb1..188ad23 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -511,145 +511,146 @@ void KOViewManager::showMonthView()
511 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 511 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
512 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 512 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
513 513
514 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 514 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
515 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 515 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
516 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 516 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
517 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 517 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
518 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 518 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
519 mMainView, SLOT ( selectWeekNum( int ) ) ); 519 mMainView, SLOT ( selectWeekNum( int ) ) );
520 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 520 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
521 mMainView, SLOT ( showDay( QDate ) ) ); 521 mMainView, SLOT ( showDay( QDate ) ) );
522 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 522 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
523 connect( mMonthView, SIGNAL(nextMonth() ), 523 connect( mMonthView, SIGNAL(nextMonth() ),
524 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); 524 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) );
525 connect( mMonthView, SIGNAL(prevMonth() ), 525 connect( mMonthView, SIGNAL(prevMonth() ),
526 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 526 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) );
527 mMonthView->updateConfig(); 527 mMonthView->updateConfig();
528 } 528 }
529 529
530 globalFlagBlockAgenda = 1; 530 globalFlagBlockAgenda = 1;
531 //mFlagShowNextxDays = false; 531 //mFlagShowNextxDays = false;
532 // if(mMonthView == mCurrentView) return; 532 // if(mMonthView == mCurrentView) return;
533 mMainView->dateNavigator()->selectMonth(); 533 mMainView->dateNavigator()->selectMonth();
534 534
535 showView(mMonthView, true ); 535 showView(mMonthView, true );
536 536
537} 537}
538 538
539void KOViewManager::showTodoView() 539void KOViewManager::showTodoView()
540{ 540{
541 //mFlagShowNextxDays = false; 541 //mFlagShowNextxDays = false;
542 if ( !mTodoView ) { 542 if ( !mTodoView ) {
543 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 543 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
544 "KOViewManager::TodoView" ); 544 "KOViewManager::TodoView" );
545 545
546 addView( mTodoView ); 546 addView( mTodoView );
547 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 547 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
548 548
549 // SIGNALS/SLOTS FOR TODO VIEW 549 // SIGNALS/SLOTS FOR TODO VIEW
550 connect( mTodoView, SIGNAL( newTodoSignal() ), 550 connect( mTodoView, SIGNAL( newTodoSignal() ),
551 mMainView, SLOT( newTodo() ) ); 551 mMainView, SLOT( newTodo() ) );
552 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 552 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
553 mMainView, SLOT( newSubTodo( Todo *) ) ); 553 mMainView, SLOT( newSubTodo( Todo *) ) );
554 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 554 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
555 mMainView, SLOT( showTodo( Todo * ) ) ); 555 mMainView, SLOT( showTodo( Todo * ) ) );
556 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 556 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
557 mMainView, SLOT( editTodo( Todo * ) ) ); 557 mMainView, SLOT( editTodo( Todo * ) ) );
558 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 558 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
559 mMainView, SLOT( deleteTodo( Todo * ) ) ); 559 mMainView, SLOT( deleteTodo( Todo * ) ) );
560 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 560 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
561 mMainView, SLOT( purgeCompleted() ) ); 561 mMainView, SLOT( purgeCompleted() ) );
562 562
563 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
564 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 564 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
565 565
566 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 566 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
567 SLOT( updateConfig() ) ); 567 SLOT( updateConfig() ) );
568 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 568 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
569 SLOT( updateTodo( Todo *, int ) ) ); 569 SLOT( updateTodo( Todo *, int ) ) );
570 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 570 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
571 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 571 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
572 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 572 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
573 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 573 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
574 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 574 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
575 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 575 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
576 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 576 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
577 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 577 mMainView, SLOT ( todo_unsub( Todo * ) ) );
578 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 578 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
579 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 579 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
580 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 580 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
581 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 581 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
582 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 582 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
583 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 583 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
584 KConfig *config = KOGlobals::config(); 584 KConfig *config = KOGlobals::config();
585 mTodoView->restoreLayout(config,"Todo View"); 585 mTodoView->restoreLayout(config,"Todo View");
586 mTodoView->setNavigator( mMainView->dateNavigator() ); 586 mTodoView->setNavigator( mMainView->dateNavigator() );
587 } 587 }
588 588
589 globalFlagBlockAgenda = 1; 589 globalFlagBlockAgenda = 1;
590 showView( mTodoView, true ); 590 showView( mTodoView, true );
591 591
592} 592}
593 593
594void KOViewManager::showJournalView() 594void KOViewManager::showJournalView()
595{ 595{
596 //mFlagShowNextxDays = false; 596 //mFlagShowNextxDays = false;
597 if (!mJournalView) { 597 if (!mJournalView) {
598 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 598 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
599 "KOViewManager::JournalView"); 599 "KOViewManager::JournalView");
600 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 600 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
601 SLOT( updateConfig() ) ); 601 SLOT( updateConfig() ) );
602 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 602 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
603 addView(mJournalView); 603 addView(mJournalView);
604 } 604 }
605 605
606 showView(mJournalView); 606 showView(mJournalView);
607 mMainView->dateNavigator()->selectDates( 1 );
607} 608}
608 609
609void KOViewManager::showTimeSpanView() 610void KOViewManager::showTimeSpanView()
610{ 611{
611 //mFlagShowNextxDays = false; 612 //mFlagShowNextxDays = false;
612 if (!mTimeSpanView) { 613 if (!mTimeSpanView) {
613 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 614 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
614 "KOViewManager::TimeSpanView"); 615 "KOViewManager::TimeSpanView");
615 addView(mTimeSpanView); 616 addView(mTimeSpanView);
616 617
617 mTimeSpanView->readSettings(); 618 mTimeSpanView->readSettings();
618 } 619 }
619 620
620 showView(mTimeSpanView); 621 showView(mTimeSpanView);
621} 622}
622 623
623Incidence *KOViewManager::currentSelection() 624Incidence *KOViewManager::currentSelection()
624{ 625{
625 if (!mCurrentView) return 0; 626 if (!mCurrentView) return 0;
626 if ( mCurrentView == mListView ) { 627 if ( mCurrentView == mListView ) {
627 if ( mListView->currentItem() ) 628 if ( mListView->currentItem() )
628 return mListView->currentItem(); 629 return mListView->currentItem();
629 } 630 }
630 return mCurrentView->selectedIncidences().first(); 631 return mCurrentView->selectedIncidences().first();
631} 632}
632 633
633QDate KOViewManager::currentSelectionDate() 634QDate KOViewManager::currentSelectionDate()
634{ 635{
635 QDate qd; 636 QDate qd;
636 if (mCurrentView) { 637 if (mCurrentView) {
637 DateList qvl = mCurrentView->selectedDates(); 638 DateList qvl = mCurrentView->selectedDates();
638 if (!qvl.isEmpty()) qd = qvl.first(); 639 if (!qvl.isEmpty()) qd = qvl.first();
639 } 640 }
640 return qd; 641 return qd;
641} 642}
642 643
643void KOViewManager::addView(KOrg::BaseView *view) 644void KOViewManager::addView(KOrg::BaseView *view)
644{ 645{
645#if QT_VERSION >= 0x030000 646#if QT_VERSION >= 0x030000
646 mMainView->viewStack()->addWidget( view ); 647 mMainView->viewStack()->addWidget( view );
647#else 648#else
648 mMainView->viewStack()->addWidget( view, 1 ); 649 mMainView->viewStack()->addWidget( view, 1 );
649#endif 650#endif
650} 651}
651 652
652void KOViewManager::setDocumentId( const QString &id ) 653void KOViewManager::setDocumentId( const QString &id )
653{ 654{
654 if (mTodoView) mTodoView->setDocumentId( id ); 655 if (mTodoView) mTodoView->setDocumentId( id );
655} 656}