summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt6
-rw-r--r--korganizer/koagendaview.cpp1
2 files changed, 6 insertions, 1 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index da5f365..6bc6be9 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,232 +1,238 @@
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********** VERSION 2.0.23 ************
4
5Fixed again a lot of small and strange bugs, e.g. the missing toolbar of KA/Pi after a new installation.
6Fixed the (agenda) layout of KO/Pi on 5500er.
7Some usebility enhancements (e.g. reselection the current item of the todo view after some changes).
8
3********** VERSION 2.0.22 ************ 9********** VERSION 2.0.22 ************
4 10
5KO/Pi: 11KO/Pi:
6Fix for creating events/todos via the abgenda context menu. 12Fix for creating events/todos via the abgenda context menu.
7Added option to split toolbar to 3 toolbars. 13Added option to split toolbar to 3 toolbars.
8(Toolbar moving s disabled for this option due to a bug in Qt somewhere). 14(Toolbar moving s disabled for this option due to a bug in Qt somewhere).
9Added option to show one small filter-view-toolbar. 15Added option to show one small filter-view-toolbar.
10Added a print option to the desktop version: 16Added a print option to the desktop version:
11Now you can print out the view of the "Event Viewer". 17Now you can print out the view of the "Event Viewer".
12That means you can print all data of one particular event/todo. 18That means you can print all data of one particular event/todo.
13Added scaling options to printout of Event Viewer and What'sNext View. 19Added scaling options to printout of Event Viewer and What'sNext View.
14Fixed some problems in the month view in "week start sunday" mode. 20Fixed some problems in the month view in "week start sunday" mode.
15KA/Pi: 21KA/Pi:
16Added two more config options. 22Added two more config options.
17Fixed resizing problem of address request dialog when orientation was switched. 23Fixed resizing problem of address request dialog when orientation was switched.
18Cleaned up the menu structure. 24Cleaned up the menu structure.
19Fixed some more problems. 25Fixed some more problems.
20 26
21Fixed the annoying problem that scrolling continued after the key was released in KO/Pi Monthview and the KA/Pi views. 27Fixed the annoying problem that scrolling continued after the key was released in KO/Pi Monthview and the KA/Pi views.
22 28
23And, this is a really cool option (Ben did suggest it): 29And, this is a really cool option (Ben did suggest it):
24Now KO/Pi and KA/Pi can be run from a USB stick: 30Now KO/Pi and KA/Pi can be run from a USB stick:
25All data is read from and written to the stick. 31All data is read from and written to the stick.
26You can enable this in the global configure option TAB with: 32You can enable this in the global configure option TAB with:
27Save using LOCAL storage. 33Save using LOCAL storage.
28Just put KDE-Pim/Pi on a memory stick and you can access all your PIM data on every computer with Windows XP. It will work with the ME and Linux versions as well. I will put a memory stick version for teh next stable release online. 34Just put KDE-Pim/Pi on a memory stick and you can access all your PIM data on every computer with Windows XP. It will work with the ME and Linux versions as well. I will put a memory stick version for teh next stable release online.
29 35
30********** VERSION 2.0.21 ************ 36********** VERSION 2.0.21 ************
31 37
32Fixed another SMTP problem in OM/Pi. 38Fixed another SMTP problem in OM/Pi.
33Some small changed in the new datenavigator in KO/Pi. 39Some small changed in the new datenavigator in KO/Pi.
34Changed default setting for new filter in KA/Pi to "exclude categories". 40Changed default setting for new filter in KA/Pi to "exclude categories".
35Changed the default font size for 640x480 display . 41Changed the default font size for 640x480 display .
36Changed popup menu behaviour in agenda and list view. 42Changed popup menu behaviour in agenda and list view.
37Fixed some layout problems of the date label size in the month view. 43Fixed some layout problems of the date label size in the month view.
38Made month view update faster. 44Made month view update faster.
39Made first datenavigator repainting faster. 45Made first datenavigator repainting faster.
40Changed the title of the event/todo edit dialogs. 46Changed the title of the event/todo edit dialogs.
41Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course). 47Timelabels in agenga changed from 22:00 to 22 oo. ( the oo higher, of course).
42Many small usebility fixes in KO/Pi. 48Many small usebility fixes in KO/Pi.
43Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi. 49Pressing the "Calendar" button on the Z switches now to the next view in KO/Pi.
44The set of possible "next views" are the views you have toolbar buttons for. 50The set of possible "next views" are the views you have toolbar buttons for.
45 51
46Made alarm sound working on Linux. 52Made alarm sound working on Linux.
47 53
48KO/Pi alarm applet changed: 54KO/Pi alarm applet changed:
49Made buttons in alarm dialog much bigger. 55Made buttons in alarm dialog much bigger.
50Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger. 56Made setting of timer more user friendly by showing the actual timer fire time and making the buttons in the timer settings much bigger.
51The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings. 57The goal was it to make it possible to use a finger tip ( and not the stylus ) on the touchscreen to adjust the settings.
52 58
53And because this version is realeased at Easter, I added an Easter-egg: 59And because this version is realeased at Easter, I added an Easter-egg:
54With a new undocumented command you can get a message box about the next alarm. 60With a new undocumented command you can get a message box about the next alarm.
55Good luck to find it! 61Good luck to find it!
56 62
57 63
58 64
59********** VERSION 2.0.20 ************ 65********** VERSION 2.0.20 ************
60 66
61Two small fixes in OM/Pi. 67Two small fixes in OM/Pi.
62 68
63Better resizing of the new datenavigator in KO/Pi. 69Better resizing of the new datenavigator in KO/Pi.
64 70
65********** VERSION 2.0.19 ************ 71********** VERSION 2.0.19 ************
66KO/Pi: 72KO/Pi:
67Enhancements and bugfixes in the new datenavigator. 73Enhancements and bugfixes in the new datenavigator.
68Bugfix in this changelog: 74Bugfix in this changelog:
69The datenavigator was changed in version 2.0.18, not the datepicker. 75The datenavigator was changed in version 2.0.18, not the datepicker.
70 76
71********** VERSION 2.0.18 ************ 77********** VERSION 2.0.18 ************
72KO/Pi: 78KO/Pi:
73Fixed some minor problems. 79Fixed some minor problems.
74Cleaned up the KO/Pi config dialog. 80Cleaned up the KO/Pi config dialog.
75Fixed problem moving events in aganda view. 81Fixed problem moving events in aganda view.
76Made datepicker scaleable, i.e. if the datenavigator shows now a 82Made datepicker scaleable, i.e. if the datenavigator shows now a
77datenavigator matrix depending on its size. 83datenavigator matrix depending on its size.
78Birthdays are now displayed green in the datenavigator. 84Birthdays are now displayed green in the datenavigator.
79What'sThis Help in datenavigator shows all events of the day. 85What'sThis Help in datenavigator shows all events of the day.
80 86
81OM/Pi: 87OM/Pi:
82Updated the backend mail library to the latest version. 88Updated the backend mail library to the latest version.
83Please backup your mail before using this version. 89Please backup your mail before using this version.
84 90
85********** VERSION 2.0.17 ************ 91********** VERSION 2.0.17 ************
86 92
87KO/Pi: 93KO/Pi:
88Tooltips in month view were not sorted. Fixed. 94Tooltips in month view were not sorted. Fixed.
89Daylabel in agenda view ( for display of one day ) was too short. Fixed. 95Daylabel in agenda view ( for display of one day ) was too short. Fixed.
90Conflict display dialog for syncing was not on top of other windows. Fixed. 96Conflict display dialog for syncing was not on top of other windows. Fixed.
91Fixed some minor problems. 97Fixed some minor problems.
92 98
93Fixed an endless loop when importing vcs file with RESOURCES entry. 99Fixed an endless loop when importing vcs file with RESOURCES entry.
94 100
95********** VERSION 2.0.16 ************ 101********** VERSION 2.0.16 ************
96OM/Pi: 102OM/Pi:
97Fixed the SMTP account setting the option. 103Fixed the SMTP account setting the option.
98Fixed something in mail sending. 104Fixed something in mail sending.
99 105
100KO/Pi: 106KO/Pi:
101Added possibility to export selected events/todos as vcal file. 107Added possibility to export selected events/todos as vcal file.
102 108
103********** VERSION 2.0.15 ************ 109********** VERSION 2.0.15 ************
104 110
105PwM/Pi: 111PwM/Pi:
106Added keyboard shorcuts for 112Added keyboard shorcuts for
107- toggling summary view (space bar) 113- toggling summary view (space bar)
108- delete item (delete + backspace key) 114- delete item (delete + backspace key)
109- add new item ( i + n key) 115- add new item ( i + n key)
110Fixed length of info in the title. 116Fixed length of info in the title.
111 117
112KO/Pi-KA/Pi: 118KO/Pi-KA/Pi:
113Changed "ME" menu bar entry to an icon. 119Changed "ME" menu bar entry to an icon.
114 120
115KO/Pi: 121KO/Pi:
116Fixed two minor bugs in displaying todos. 122Fixed two minor bugs in displaying todos.
117If in month view a cell is selected, the key shortcut "d" shows now that date. 123If in month view a cell is selected, the key shortcut "d" shows now that date.
118Added complete info for a todo in month view as an icon left of the text. 124Added complete info for a todo in month view as an icon left of the text.
119Fixed problems of displaying data when "<" or ">" are used in summary/location/description. 125Fixed problems of displaying data when "<" or ">" are used in summary/location/description.
120Fixed problem of search dialog size when switching displays. 126Fixed problem of search dialog size when switching displays.
121Cancel key now closes date picker. 127Cancel key now closes date picker.
122Rearranged KO/Pi file menu structure. 128Rearranged KO/Pi file menu structure.
123 129
124OM/Pi: 130OM/Pi:
125Added to the SMTP account setting the option 131Added to the SMTP account setting the option
126"No secure connection". 132"No secure connection".
127You have to configure your SMTP accounts again, sorry. 133You have to configure your SMTP accounts again, sorry.
128 134
129KA/Pi: 135KA/Pi:
130Added support for importing quoted-printable. 136Added support for importing quoted-printable.
131Support was added by Peter P.. Thanks, Peter! 137Support was added by Peter P.. Thanks, Peter!
132 138
133 139
134********** VERSION 2.0.14 ************ 140********** VERSION 2.0.14 ************
135 141
136Made Passwordmanager PwM/Pi more userfriendly: 142Made Passwordmanager PwM/Pi more userfriendly:
137Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. 143Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more.
138Fixed bug in KO/Pi todo printing. 144Fixed bug in KO/Pi todo printing.
139Made Qtopia calendar import possible on desktop . 145Made Qtopia calendar import possible on desktop .
140 146
141********** VERSION 2.0.13 ************ 147********** VERSION 2.0.13 ************
142 148
143Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. 149Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter.
144 150
145In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". 151In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down".
146 152
147OM/Pi: 153OM/Pi:
148Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. 154Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails.
149Added missing German translation. 155Added missing German translation.
150Added warning if path is specified in local folder settings of account config. 156Added warning if path is specified in local folder settings of account config.
151 157
152********** VERSION 2.0.12 ************ 158********** VERSION 2.0.12 ************
153 159
154KO/Pi: 160KO/Pi:
155Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. 161Fixed a bug in todo start/due date handling for non recurring todos with a start and due date.
156Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. 162Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes.
157Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. 163Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer.
158 164
159Fixed problem in pi-sync mode when wrong password was sent. 165Fixed problem in pi-sync mode when wrong password was sent.
160 166
161OM/Pi: 167OM/Pi:
162Fixed a crash when displaying mails with "Show mail as html" was checked in the config. 168Fixed a crash when displaying mails with "Show mail as html" was checked in the config.
163Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. 169Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled.
164 170
165********** VERSION 2.0.11 ************ 171********** VERSION 2.0.11 ************
166 172
167Fixed some problems in pi-sync mode 173Fixed some problems in pi-sync mode
168(e.g. details of events were not synced properly) 174(e.g. details of events were not synced properly)
169 175
170********** VERSION 2.0.10 ************ 176********** VERSION 2.0.10 ************
171 177
172KO/Pi: 178KO/Pi:
173In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. 179In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view.
174This is fixed. 180This is fixed.
175Changed the search dialog a bit to make it more user friendly. 181Changed the search dialog a bit to make it more user friendly.
176(E.g.: Removed message box about "no items found" and set key focus to search line edit after search). 182(E.g.: Removed message box about "no items found" and set key focus to search line edit after search).
177 183
178Added config option to hide the week number in KO/Pi toolbar. 184Added config option to hide the week number in KO/Pi toolbar.
179 185
180********** VERSION 2.0.9 ************ 186********** VERSION 2.0.9 ************
181 187
182Made month view icons for multiday events a bit nicer. 188Made month view icons for multiday events a bit nicer.
183Some minor fixes in KO/Pi 189Some minor fixes in KO/Pi
184(e.g. go to today did not work for new week view properly). 190(e.g. go to today did not work for new week view properly).
185 191
186 192
187********** VERSION 2.0.8 ************ 193********** VERSION 2.0.8 ************
188 194
189Fixed a problem in dependency info in the ipk files for the Zaurus. 195Fixed a problem in dependency info in the ipk files for the Zaurus.
190 196
191Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar. 197Added icon for the stealth new week view and made navigation more user friendly in monthview by adding a prev/next week button to the navigator bar.
192 198
193Added a "go today" button to the datepicker. 199Added a "go today" button to the datepicker.
194 200
195Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) 201Added "created" and "last modified" to event/todo viewer (and What'sThis viewer)
196and made it configureable to show these values. 202and made it configureable to show these values.
197 203
198Fixed a problem for events (from external iCal files) that do have a duration but no end date. 204Fixed a problem for events (from external iCal files) that do have a duration but no end date.
199 205
200 206
201********** VERSION 2.0.7 ************ 207********** VERSION 2.0.7 ************
202 208
203Added global application font settings 209Added global application font settings
204(for all KDE-Pim/Pi apps) to the general settings. 210(for all KDE-Pim/Pi apps) to the general settings.
205 211
206Fixed a problem in OM/Pi when trying to login to some IMAP servers 212Fixed a problem in OM/Pi when trying to login to some IMAP servers
207(like the IMAP server of Apple: mail.mac.com ) 213(like the IMAP server of Apple: mail.mac.com )
208 214
209Added recurring todos to KO/Pi. 215Added recurring todos to KO/Pi.
210 216
211 217
212********** VERSION 2.0.6 ************ 218********** VERSION 2.0.6 ************
213 219
214Stable release 2.0.6! 220Stable release 2.0.6!
215 221
216Some bugfixes in the pi-sync mode. 222Some bugfixes in the pi-sync mode.
217Added German translation for pi-sync mode. 223Added German translation for pi-sync mode.
218 224
219KO/Pi: 225KO/Pi:
220Made the todolist using alternate background. 226Made the todolist using alternate background.
221 227
222Other minor fixes in KO/Pi. 228Other minor fixes in KO/Pi.
223 229
224 230
225You can find the complete changelog 231You can find the complete changelog
226from version 1.7.7 to 2.0.5 232from version 1.7.7 to 2.0.5
227in the source package or on 233in the source package or on
228 234
229http://www.pi-sync.net/html/changelog.html 235http://www.pi-sync.net/html/changelog.html
230 236
231 237
232 238
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 880d399..d450a97 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1624 +1,1623 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = font(); 123 QFont nFont = font();
124 p->setFont( font()); 124 p->setFont( font());
125 125
126 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 127 suffix = "00";
128 } else 128 } else
129 if (cell > 11) suffix = "pm"; 129 if (cell > 11) suffix = "pm";
130 130
131 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
138 break; 138 break;
139 -- pointS; 139 -- pointS;
140 } 140 }
141 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
143 } 143 }
144 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 145 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 150 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline 153 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 154 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2 ,y,cw+2,y); 156 p->drawLine(startW-tw2 ,y,cw+2,y);
157 hour.setNum(cell); 157 hour.setNum(cell);
158 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
163 } 163 }
164 164
165 // center and draw the time label 165 // center and draw the time label
166 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 167 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 168 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 170 p->setFont( sFont );
171 offset = startW - tw2; 171 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
173 173
174 // increment indices 174 // increment indices
175 y += mCellHeight; 175 y += mCellHeight;
176 cell++; 176 cell++;
177 } 177 }
178 178
179 179
180 180
181 181
182} 182}
183 183
184/** 184/**
185 Calculates the minimum width. 185 Calculates the minimum width.
186*/ 186*/
187int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
188{ 188{
189 return mMiniWidth; 189 return mMiniWidth;
190} 190}
191 191
192/** updates widget's internal state */ 192/** updates widget's internal state */
193void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
194{ 194{
195 mRedrawNeeded = true; 195 mRedrawNeeded = true;
196 // set the font 196 // set the font
197 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
200 QString test = "20"; 200 QString test = "20";
201 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
202 test = "12"; 202 test = "12";
203 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
204 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
205 test = "pm"; 205 test = "pm";
206 else { 206 else {
207 test = "00"; 207 test = "00";
208 } 208 }
209 QFont sFont = font(); 209 QFont sFont = font();
210 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
211 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 qDebug("testwid %d %d", mMiniWidth ,fmS.width( test ));
214 // update geometry restrictions based on new settings 213 // update geometry restrictions based on new settings
215 setFixedWidth( mMiniWidth ); 214 setFixedWidth( mMiniWidth );
216 215
217 // update HourSize 216 // update HourSize
218 mCellHeight = KOPrefs::instance()->mHourSize*4; 217 mCellHeight = KOPrefs::instance()->mHourSize*4;
219 resizeContents(50,mRows * mCellHeight); 218 resizeContents(50,mRows * mCellHeight);
220} 219}
221 220
222/** update time label positions */ 221/** update time label positions */
223void TimeLabels::positionChanged() 222void TimeLabels::positionChanged()
224{ 223{
225 int adjustment = mAgenda->contentsY(); 224 int adjustment = mAgenda->contentsY();
226 setContentsPos(0, adjustment); 225 setContentsPos(0, adjustment);
227} 226}
228 227
229/** */ 228/** */
230void TimeLabels::setAgenda(KOAgenda* agenda) 229void TimeLabels::setAgenda(KOAgenda* agenda)
231{ 230{
232 mAgenda = agenda; 231 mAgenda = agenda;
233} 232}
234 233
235void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
236{ 235{
237 mMouseDownY = e->pos().y(); 236 mMouseDownY = e->pos().y();
238 mOrgCap = topLevelWidget()->caption(); 237 mOrgCap = topLevelWidget()->caption();
239} 238}
240 239
241void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
242{ 241{
243 int diff = mMouseDownY - e->pos().y(); 242 int diff = mMouseDownY - e->pos().y();
244 if ( diff < 10 && diff > -10 ) 243 if ( diff < 10 && diff > -10 )
245 return; 244 return;
246 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
247 if ( tSize < 4 ) 246 if ( tSize < 4 )
248 tSize = 4; 247 tSize = 4;
249 if ( tSize > 22 ) 248 if ( tSize > 22 )
250 tSize = 22; 249 tSize = 22;
251 tSize = (tSize-2)/2; 250 tSize = (tSize-2)/2;
252 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
253 252
254} 253}
255void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
256{ 255{
257 topLevelWidget()->setCaption( mOrgCap ); 256 topLevelWidget()->setCaption( mOrgCap );
258 int diff = mMouseDownY - e->pos().y(); 257 int diff = mMouseDownY - e->pos().y();
259 if ( diff < 10 && diff > -10 ) 258 if ( diff < 10 && diff > -10 )
260 return; 259 return;
261 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 260 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
262 if ( tSize < 4 ) 261 if ( tSize < 4 )
263 tSize = 4; 262 tSize = 4;
264 if ( tSize > 22 ) 263 if ( tSize > 22 )
265 tSize = 22; 264 tSize = 22;
266 tSize = (tSize/2)*2; 265 tSize = (tSize/2)*2;
267 if ( tSize == KOPrefs::instance()->mHourSize ) 266 if ( tSize == KOPrefs::instance()->mHourSize )
268 return; 267 return;
269 KOPrefs::instance()->mHourSize = tSize; 268 KOPrefs::instance()->mHourSize = tSize;
270 emit scaleChanged(); 269 emit scaleChanged();
271} 270}
272 271
273/** This is called in response to repaint() */ 272/** This is called in response to repaint() */
274void TimeLabels::paintEvent(QPaintEvent*) 273void TimeLabels::paintEvent(QPaintEvent*)
275{ 274{
276 275
277 // kdDebug() << "paintevent..." << endl; 276 // kdDebug() << "paintevent..." << endl;
278 // this is another hack! 277 // this is another hack!
279 // QPainter painter(this); 278 // QPainter painter(this);
280 //QString c 279 //QString c
281 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
282} 281}
283 282
284//////////////////////////////////////////////////////////////////////////// 283////////////////////////////////////////////////////////////////////////////
285 284
286EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
287 : QFrame(parent,name) 286 : QFrame(parent,name)
288{ 287{
289 mColumns = 1; 288 mColumns = 1;
290 mTopBox = 0; 289 mTopBox = 0;
291 mLocation = loc; 290 mLocation = loc;
292 mTopLayout = 0; 291 mTopLayout = 0;
293 mPaintWidget = 0; 292 mPaintWidget = 0;
294 mXOffset = 0; 293 mXOffset = 0;
295 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
296 else mPixmap = SmallIcon("1downarrow"); 295 else mPixmap = SmallIcon("1downarrow");
297 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
298 mEnabled.fill( false ); 297 mEnabled.fill( false );
299 setMinimumHeight(mPixmap.height()); 298 setMinimumHeight(mPixmap.height());
300} 299}
301 300
302EventIndicator::~EventIndicator() 301EventIndicator::~EventIndicator()
303{ 302{
304} 303}
305 304
306void EventIndicator::drawContents(QPainter *p) 305void EventIndicator::drawContents(QPainter *p)
307{ 306{
308 307
309 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
310 KDGanttSplitterHandle* han = 0; 309 KDGanttSplitterHandle* han = 0;
311 if ( mPaintWidget ) 310 if ( mPaintWidget )
312 han = mPaintWidget->firstHandle(); 311 han = mPaintWidget->firstHandle();
313 if ( ! han ) { 312 if ( ! han ) {
314 int i; 313 int i;
315 for(i=0;i<mColumns;++i) { 314 for(i=0;i<mColumns;++i) {
316 if (mEnabled[i]) { 315 if (mEnabled[i]) {
317 int cellWidth = contentsRect().right()/mColumns; 316 int cellWidth = contentsRect().right()/mColumns;
318 int xOffset = KOGlobals::self()->reverseLayout() ? 317 int xOffset = KOGlobals::self()->reverseLayout() ?
319 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
320 i*cellWidth + (cellWidth -mPixmap.width()) /2; 319 i*cellWidth + (cellWidth -mPixmap.width()) /2;
321 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
322 } 321 }
323 } 322 }
324 } else { 323 } else {
325 han->repaint(); 324 han->repaint();
326 //mPaintWidget->setBackgroundColor( red ); 325 //mPaintWidget->setBackgroundColor( red );
327 326
328 QPainter pa( han ); 327 QPainter pa( han );
329 int i; 328 int i;
330 bool setColor = false; 329 bool setColor = false;
331 for(i=0;i<mColumns;++i) { 330 for(i=0;i<mColumns;++i) {
332 if (mEnabled[i]) { 331 if (mEnabled[i]) {
333 setColor = true; 332 setColor = true;
334 333
335 int cellWidth = contentsRect().right()/mColumns; 334 int cellWidth = contentsRect().right()/mColumns;
336 int xOffset = KOGlobals::self()->reverseLayout() ? 335 int xOffset = KOGlobals::self()->reverseLayout() ?
337 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
338 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 337 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
339 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
340 //qDebug("222draw pix %d ",xOffset ); 339 //qDebug("222draw pix %d ",xOffset );
341 340
342 } 341 }
343 342
344 } 343 }
345 pa.end(); 344 pa.end();
346 345
347 } 346 }
348} 347}
349 348
350void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
351{ 350{
352 mXOffset = x; 351 mXOffset = x;
353} 352}
354void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
355{ 354{
356 mPaintWidget = w; 355 mPaintWidget = w;
357 setMaximumHeight(0); 356 setMaximumHeight(0);
358 setMinimumHeight(0); 357 setMinimumHeight(0);
359} 358}
360void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
361{ 360{
362 mColumns = columns; 361 mColumns = columns;
363 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
364 363
365 update(); 364 update();
366} 365}
367 366
368void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
369{ 368{
370 mEnabled[column] = enable; 369 mEnabled[column] = enable;
371} 370}
372 371
373 372
374//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
376//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
377 376
378KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
379 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
380{ 379{
381 mBlockUpdating = true; 380 mBlockUpdating = true;
382 mStartHour = 8; 381 mStartHour = 8;
383 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
384 383
385 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
386 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
387 mDayLabels = 0; 386 mDayLabels = 0;
388 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
389 QPixmap expandPix; 388 QPixmap expandPix;
390 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
391 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
392 } else { 391 } else {
393 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
394 } 393 }
395 394
396 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
397 396
398 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
399 // Create agenda splitter 398 // Create agenda splitter
400 399
401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
403 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
404 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
405 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
406 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
407 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
408 407
409 // Create all-day agenda widget 408 // Create all-day agenda widget
410 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
411 410
412 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
413 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
414 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
415 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
416 if ( heibut > widebut ) 415 if ( heibut > widebut )
417 widebut = heibut ; 416 widebut = heibut ;
418 417
419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
420 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
421 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
423 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
425 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
426 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
427 426
428 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
429 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
430 429
431 // Create agenda frame 430 // Create agenda frame
432 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
433 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
434 433
435 // create event indicator bars 434 // create event indicator bars
436 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
437#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
438 // FIX 437 // FIX
439 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
440#endif 439#endif
441 mDayLabelsFrame = new QHBox(agendaFrame); 440 mDayLabelsFrame = new QHBox(agendaFrame);
442 //topLayout->addWidget(mDayLabelsFrame); 441 //topLayout->addWidget(mDayLabelsFrame);
443 mDayLabels = new QFrame (mDayLabelsFrame); 442 mDayLabels = new QFrame (mDayLabelsFrame);
444 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 443 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
445 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
446 agendaLayout->addWidget(mEventIndicatorTop,1,1); 445 agendaLayout->addWidget(mEventIndicatorTop,1,1);
447 446
448 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
449 agendaFrame); 448 agendaFrame);
450 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 449 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
451 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 450 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
452 agendaLayout->addWidget(dummyAgendaRight,1,2); 451 agendaLayout->addWidget(dummyAgendaRight,1,2);
453 452
454 // Create time labels 453 // Create time labels
455 mTimeLabels = new TimeLabels(24,agendaFrame); 454 mTimeLabels = new TimeLabels(24,agendaFrame);
456 agendaLayout->addWidget(mTimeLabels,2,0); 455 agendaLayout->addWidget(mTimeLabels,2,0);
457 connect(mTimeLabels,SIGNAL( scaleChanged()), 456 connect(mTimeLabels,SIGNAL( scaleChanged()),
458 this,SLOT(updateConfig())); 457 this,SLOT(updateConfig()));
459 458
460 // Create agenda 459 // Create agenda
461 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
462 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
463 agendaLayout->setColStretch(1,1); 462 agendaLayout->setColStretch(1,1);
464 mAgenda->setFocusPolicy(NoFocus); 463 mAgenda->setFocusPolicy(NoFocus);
465 // Create event context menu for agenda 464 // Create event context menu for agenda
466 mAllAgendaPopup = eventPopup(); 465 mAllAgendaPopup = eventPopup();
467 466
468 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
469 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
470 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
471 470
472 471
473 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
474 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
475 474
476 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
477 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
478 mAgenda->setPopup( mAllAgendaPopup ); 477 mAgenda->setPopup( mAllAgendaPopup );
479 mAllDayAgenda->setPopup( mAllAgendaPopup ); 478 mAllDayAgenda->setPopup( mAllAgendaPopup );
480 // make connections between dependent widgets 479 // make connections between dependent widgets
481 mTimeLabels->setAgenda(mAgenda); 480 mTimeLabels->setAgenda(mAgenda);
482 481
483 // Update widgets to reflect user preferences 482 // Update widgets to reflect user preferences
484 // updateConfig(); 483 // updateConfig();
485 484
486 // createDayLabels(); 485 // createDayLabels();
487 486
488 // these blank widgets make the All Day Event box line up with the agenda 487 // these blank widgets make the All Day Event box line up with the agenda
489 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
491 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
492 491
493 // Scrolling 492 // Scrolling
494 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
495 mTimeLabels, SLOT(positionChanged())); 494 mTimeLabels, SLOT(positionChanged()));
496 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
497 SLOT(setContentsPos(int))); 496 SLOT(setContentsPos(int)));
498 497
499 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
500 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
501 500
502 // Create/Show/Edit/Delete Event 501 // Create/Show/Edit/Delete Event
503 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 502 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
504 SLOT(newEvent(int,int))); 503 SLOT(newEvent(int,int)));
505 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
506 SLOT(newTodo(int,int))); 505 SLOT(newTodo(int,int)));
507 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
508 SLOT(newEvent(int,int,int,int))); 507 SLOT(newEvent(int,int,int,int)));
509 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
510 SLOT(newEventAllDay(int,int))); 509 SLOT(newEventAllDay(int,int)));
511 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
512 SLOT(newTodoAllDay(int,int))); 511 SLOT(newTodoAllDay(int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
514 SLOT(newEventAllDay(int,int))); 513 SLOT(newEventAllDay(int,int)));
515 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
516 SLOT(newTimeSpanSelected(int,int,int,int))); 515 SLOT(newTimeSpanSelected(int,int,int,int)));
517 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
518 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
519 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
521 520
522 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
523 SIGNAL(editIncidenceSignal(Incidence *))); 522 SIGNAL(editIncidenceSignal(Incidence *)));
524 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
525 SIGNAL(editIncidenceSignal(Incidence *))); 524 SIGNAL(editIncidenceSignal(Incidence *)));
526 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
527 SIGNAL(showIncidenceSignal(Incidence *))); 526 SIGNAL(showIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
529 SIGNAL(showIncidenceSignal(Incidence *))); 528 SIGNAL(showIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
531 SIGNAL(deleteIncidenceSignal(Incidence *))); 530 SIGNAL(deleteIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
533 SIGNAL(deleteIncidenceSignal(Incidence *))); 532 SIGNAL(deleteIncidenceSignal(Incidence *)));
534 533
535 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
536 SLOT(updateEventDates(KOAgendaItem *, int ))); 535 SLOT(updateEventDates(KOAgendaItem *, int )));
537 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
538 SLOT(updateEventDates(KOAgendaItem *, int))); 537 SLOT(updateEventDates(KOAgendaItem *, int)));
539 538
540 // event indicator update 539 // event indicator update
541 connect(mAgenda,SIGNAL(lowerYChanged(int)), 540 connect(mAgenda,SIGNAL(lowerYChanged(int)),
542 SLOT(updateEventIndicatorTop(int))); 541 SLOT(updateEventIndicatorTop(int)));
543 connect(mAgenda,SIGNAL(upperYChanged(int)), 542 connect(mAgenda,SIGNAL(upperYChanged(int)),
544 SLOT(updateEventIndicatorBottom(int))); 543 SLOT(updateEventIndicatorBottom(int)));
545 // drag signals 544 // drag signals
546 /* 545 /*
547 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 546 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
548 SLOT(startDrag(Event *))); 547 SLOT(startDrag(Event *)));
549 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
550 SLOT(startDrag(Event *))); 549 SLOT(startDrag(Event *)));
551 */ 550 */
552 // synchronize selections 551 // synchronize selections
553 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
554 mAllDayAgenda, SLOT( deselectItem() ) ); 553 mAllDayAgenda, SLOT( deselectItem() ) );
555 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
556 mAgenda, SLOT( deselectItem() ) ); 555 mAgenda, SLOT( deselectItem() ) );
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 SIGNAL( incidenceSelected( Incidence * ) ) ); 557 SIGNAL( incidenceSelected( Incidence * ) ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 SIGNAL( incidenceSelected( Incidence * ) ) ); 559 SIGNAL( incidenceSelected( Incidence * ) ) );
561 connect( mAgenda, SIGNAL( resizedSignal() ), 560 connect( mAgenda, SIGNAL( resizedSignal() ),
562 SLOT( updateConfig( ) ) ); 561 SLOT( updateConfig( ) ) );
563 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
564 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
565 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
566 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 565 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
567 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
569 568
570 569
571} 570}
572 571
573void KOAgendaView::toggleAllDay() 572void KOAgendaView::toggleAllDay()
574{ 573{
575 if ( mSplitterAgenda->firstHandle() ) 574 if ( mSplitterAgenda->firstHandle() )
576 mSplitterAgenda->firstHandle()->toggle(); 575 mSplitterAgenda->firstHandle()->toggle();
577} 576}
578void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 577void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
579{ 578{
580 calendar()->addIncidence( inc ); 579 calendar()->addIncidence( inc );
581 580
582 if ( incOld ) { 581 if ( incOld ) {
583 if ( incOld->type() == "Todo" ) 582 if ( incOld->type() == "Todo" )
584 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 583 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
585 else 584 else
586 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 585 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
587 } 586 }
588 587
589} 588}
590 589
591KOAgendaView::~KOAgendaView() 590KOAgendaView::~KOAgendaView()
592{ 591{
593 delete mAllAgendaPopup; 592 delete mAllAgendaPopup;
594 //delete mAllDayAgendaPopup; 593 //delete mAllDayAgendaPopup;
595 delete KOAgendaItem::paintPix(); 594 delete KOAgendaItem::paintPix();
596 delete KOAgendaItem::paintPixSel(); 595 delete KOAgendaItem::paintPixSel();
597} 596}
598void KOAgendaView::resizeEvent( QResizeEvent* e ) 597void KOAgendaView::resizeEvent( QResizeEvent* e )
599{ 598{
600 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 599 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
601 bool uc = false; 600 bool uc = false;
602 int ow = e->oldSize().width(); 601 int ow = e->oldSize().width();
603 int oh = e->oldSize().height(); 602 int oh = e->oldSize().height();
604 int w = e->size().width(); 603 int w = e->size().width();
605 int h = e->size().height(); 604 int h = e->size().height();
606 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 605 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
607 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 606 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
608 uc = true; 607 uc = true;
609 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 608 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
610 } 609 }
611 mUpcomingWidth = e->size().width() ; 610 mUpcomingWidth = e->size().width() ;
612 if ( mBlockUpdating || uc ) { 611 if ( mBlockUpdating || uc ) {
613 mBlockUpdating = false; 612 mBlockUpdating = false;
614 //mAgenda->setMinimumSize(800 , 600 ); 613 //mAgenda->setMinimumSize(800 , 600 );
615 //qDebug("mAgenda->resize+++++++++++++++ "); 614 //qDebug("mAgenda->resize+++++++++++++++ ");
616 updateConfig(); 615 updateConfig();
617 //qDebug("KOAgendaView::Updating now possible "); 616 //qDebug("KOAgendaView::Updating now possible ");
618 } else 617 } else
619 createDayLabels(); 618 createDayLabels();
620 //qDebug("resizeEvent end "); 619 //qDebug("resizeEvent end ");
621 620
622} 621}
623void KOAgendaView::slotDaylabelClicked( int num ) 622void KOAgendaView::slotDaylabelClicked( int num )
624{ 623{
625 624
626 QDate firstDate = mSelectedDates.first(); 625 QDate firstDate = mSelectedDates.first();
627 if ( num == -1 ) 626 if ( num == -1 )
628 emit showDateView( 6, firstDate ); 627 emit showDateView( 6, firstDate );
629 else if (num >= 0 ) { 628 else if (num >= 0 ) {
630 if ( mSelectedDates.count() == 1) 629 if ( mSelectedDates.count() == 1)
631 emit showDateView( 9, firstDate.addDays( num ) ); 630 emit showDateView( 9, firstDate.addDays( num ) );
632 else 631 else
633 emit showDateView( 3, firstDate.addDays( num ) ); 632 emit showDateView( 3, firstDate.addDays( num ) );
634 } 633 }
635 else 634 else
636 showDateView( 10, firstDate.addDays(1) ); 635 showDateView( 10, firstDate.addDays(1) );
637} 636}
638 637
639KOAgendaButton* KOAgendaView::getNewDaylabel() 638KOAgendaButton* KOAgendaView::getNewDaylabel()
640{ 639{
641 640
642 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 641 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
643 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 642 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
644 mDayLabelsList.append( dayLabel ); 643 mDayLabelsList.append( dayLabel );
645 mLayoutDayLabels->addWidget(dayLabel); 644 mLayoutDayLabels->addWidget(dayLabel);
646 return dayLabel ; 645 return dayLabel ;
647} 646}
648 647
649void KOAgendaView::createDayLabels() 648void KOAgendaView::createDayLabels()
650{ 649{
651 650
652 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 651 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
653 // qDebug(" KOAgendaView::createDayLabels() blocked "); 652 // qDebug(" KOAgendaView::createDayLabels() blocked ");
654 return; 653 return;
655 654
656 } 655 }
657 int newHight; 656 int newHight;
658 if ( !mSelectedDates.count()) 657 if ( !mSelectedDates.count())
659 return; 658 return;
660 659
661 // ### Before deleting and recreating we could check if mSelectedDates changed... 660 // ### Before deleting and recreating we could check if mSelectedDates changed...
662 // It would remove some flickering and gain speed (since this is called by 661 // It would remove some flickering and gain speed (since this is called by
663 // each updateView() call) 662 // each updateView() call)
664 663
665 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 664 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
666 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 665 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
667 if ( maxWid < 20 ) 666 if ( maxWid < 20 )
668 maxWid = 20; 667 maxWid = 20;
669 668
670 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 669 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
671 QFontMetrics fm ( dlf ); 670 QFontMetrics fm ( dlf );
672 int selCount = mSelectedDates.count(); 671 int selCount = mSelectedDates.count();
673 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 672 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
674 QString dayTest = "Mon 20"; 673 QString dayTest = "Mon 20";
675 //QString dayTest = "Mon 20"; 674 //QString dayTest = "Mon 20";
676 int wid = fm.width( dayTest ); 675 int wid = fm.width( dayTest );
677 //maxWid -= ( selCount * 3 ); //working for QLabels 676 //maxWid -= ( selCount * 3 ); //working for QLabels
678 if ( QApplication::desktop()->width() <= 320 ) 677 if ( QApplication::desktop()->width() <= 320 )
679 maxWid -= ( selCount * 3 ); //working for QPushButton 678 maxWid -= ( selCount * 3 ); //working for QPushButton
680 else 679 else
681 maxWid -= ( selCount * 3 ); //working for QPushButton 680 maxWid -= ( selCount * 3 ); //working for QPushButton
682 if ( maxWid < 0 ) 681 if ( maxWid < 0 )
683 maxWid = 20; 682 maxWid = 20;
684 int needWid = wid * selCount; 683 int needWid = wid * selCount;
685 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 684 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
686 //if ( needWid > maxWid ) 685 //if ( needWid > maxWid )
687 // qDebug("DAYLABELS TOOOOOOO BIG "); 686 // qDebug("DAYLABELS TOOOOOOO BIG ");
688 while ( needWid > maxWid ) { 687 while ( needWid > maxWid ) {
689 dayTest = dayTest.left( dayTest.length() - 1 ); 688 dayTest = dayTest.left( dayTest.length() - 1 );
690 wid = fm.width( dayTest ); 689 wid = fm.width( dayTest );
691 needWid = wid * selCount; 690 needWid = wid * selCount;
692 } 691 }
693 int maxLen = dayTest.length(); 692 int maxLen = dayTest.length();
694 int fontPoint = dlf.pointSize(); 693 int fontPoint = dlf.pointSize();
695 if ( maxLen < 2 ) { 694 if ( maxLen < 2 ) {
696 int fontPoint = dlf.pointSize(); 695 int fontPoint = dlf.pointSize();
697 while ( fontPoint > 4 ) { 696 while ( fontPoint > 4 ) {
698 --fontPoint; 697 --fontPoint;
699 dlf.setPointSize( fontPoint ); 698 dlf.setPointSize( fontPoint );
700 QFontMetrics f( dlf ); 699 QFontMetrics f( dlf );
701 wid = f.width( "30" ); 700 wid = f.width( "30" );
702 needWid = wid * selCount; 701 needWid = wid * selCount;
703 if ( needWid < maxWid ) 702 if ( needWid < maxWid )
704 break; 703 break;
705 } 704 }
706 maxLen = 2; 705 maxLen = 2;
707 } 706 }
708 //qDebug("Max len %d ", dayTest.length() ); 707 //qDebug("Max len %d ", dayTest.length() );
709 708
710 QFontMetrics tempF( dlf ); 709 QFontMetrics tempF( dlf );
711 newHight = tempF.height(); 710 newHight = tempF.height();
712 mDayLabels->setFont( dlf ); 711 mDayLabels->setFont( dlf );
713 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 712 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
714 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 713 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
715 //mLayoutDayLabels->addSpacing( 2 ); 714 //mLayoutDayLabels->addSpacing( 2 );
716 // QFont lFont = dlf; 715 // QFont lFont = dlf;
717 bool appendLabels = false; 716 bool appendLabels = false;
718 KOAgendaButton *dayLabel; 717 KOAgendaButton *dayLabel;
719 dayLabel = mDayLabelsList.first(); 718 dayLabel = mDayLabelsList.first();
720 if ( !dayLabel ) { 719 if ( !dayLabel ) {
721 appendLabels = true; 720 appendLabels = true;
722 dayLabel = getNewDaylabel(); 721 dayLabel = getNewDaylabel();
723 } 722 }
724 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 723 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
725 dayLabel->setFont( dlf ); 724 dayLabel->setFont( dlf );
726 dayLabel->setNum( -1 ); 725 dayLabel->setNum( -1 );
727 //dayLabel->setAlignment(QLabel::AlignHCenter); 726 //dayLabel->setAlignment(QLabel::AlignHCenter);
728#if 0 727#if 0
729 if ( QApplication::desktop()->width() <= 320 ) 728 if ( QApplication::desktop()->width() <= 320 )
730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); 729 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
731 else 730 else
732#endif 731#endif
733 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 732 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
734 dayLabel->show(); 733 dayLabel->show();
735 DateList::ConstIterator dit; 734 DateList::ConstIterator dit;
736 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 735 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
737 int counter = -1; 736 int counter = -1;
738 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 737 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
739 ++counter; 738 ++counter;
740 QDate date = *dit; 739 QDate date = *dit;
741 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 740 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
742 if ( ! appendLabels ) { 741 if ( ! appendLabels ) {
743 dayLabel = mDayLabelsList.next(); 742 dayLabel = mDayLabelsList.next();
744 if ( !dayLabel ) 743 if ( !dayLabel )
745 appendLabels = true; 744 appendLabels = true;
746 } 745 }
747 if ( appendLabels ) { 746 if ( appendLabels ) {
748 dayLabel = getNewDaylabel(); 747 dayLabel = getNewDaylabel();
749 } 748 }
750 dayLabel->setMinimumWidth( 1 ); 749 dayLabel->setMinimumWidth( 1 );
751 dayLabel->setMaximumWidth( 10240 ); 750 dayLabel->setMaximumWidth( 10240 );
752 dayLabel->setFont( dlf ); 751 dayLabel->setFont( dlf );
753 dayLabel->show(); 752 dayLabel->show();
754 dayLabel->setAutoRepeat( false ); 753 dayLabel->setAutoRepeat( false );
755 dayLabel->setNum( counter ); 754 dayLabel->setNum( counter );
756 QString str; 755 QString str;
757 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 756 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
758 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 757 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
759 switch ( maxLen ) { 758 switch ( maxLen ) {
760 case 2: 759 case 2:
761 str = QString::number( date.day() ); 760 str = QString::number( date.day() );
762 break; 761 break;
763 762
764 case 3: 763 case 3:
765 str = dayName.left( 1 ) +QString::number( date.day()); 764 str = dayName.left( 1 ) +QString::number( date.day());
766 765
767 break; 766 break;
768 case 4: 767 case 4:
769 str = dayName.left( 1 ) + " " +QString::number( date.day()); 768 str = dayName.left( 1 ) + " " +QString::number( date.day());
770 769
771 break; 770 break;
772 case 5: 771 case 5:
773 str = dayName.left( 2 ) + " " +QString::number( date.day()); 772 str = dayName.left( 2 ) + " " +QString::number( date.day());
774 773
775 break; 774 break;
776 case 6: 775 case 6:
777 str = dayName.left( 3 ) + " " +QString::number( date.day()); 776 str = dayName.left( 3 ) + " " +QString::number( date.day());
778 break; 777 break;
779 778
780 default: 779 default:
781 break; 780 break;
782 } 781 }
783 if ( oneday ) { 782 if ( oneday ) {
784 QString addString; 783 QString addString;
785 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 784 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
786 addString = i18n("Today"); 785 addString = i18n("Today");
787 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
788 addString = i18n("Tomorrow"); 787 addString = i18n("Tomorrow");
789 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
790 addString = i18n("Yesterday"); 789 addString = i18n("Yesterday");
791 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
792 addString = i18n("Day before yesterday"); 791 addString = i18n("Day before yesterday");
793 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 792 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
794 addString = i18n("Day after tomorrow"); 793 addString = i18n("Day after tomorrow");
795 if ( !addString.isEmpty() ) { 794 if ( !addString.isEmpty() ) {
796 str = addString+", " + str; 795 str = addString+", " + str;
797 } else { 796 } else {
798 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 797 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
799 } 798 }
800 } 799 }
801 dayLabel->setText(str); 800 dayLabel->setText(str);
802 //dayLabel->setAlignment(QLabel::AlignHCenter); 801 //dayLabel->setAlignment(QLabel::AlignHCenter);
803 if (date == QDate::currentDate()) { 802 if (date == QDate::currentDate()) {
804 QFont bFont = dlf; 803 QFont bFont = dlf;
805 bFont.setBold( true ); 804 bFont.setBold( true );
806 dayLabel->setFont(bFont); 805 dayLabel->setFont(bFont);
807 } 806 }
808 //dayLayout->addWidget(dayLabel); 807 //dayLayout->addWidget(dayLabel);
809 808
810#ifndef KORG_NOPLUGINS 809#ifndef KORG_NOPLUGINS
811 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 810 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
812 CalendarDecoration *it; 811 CalendarDecoration *it;
813 for(it = cds.first(); it; it = cds.next()) { 812 for(it = cds.first(); it; it = cds.next()) {
814 QString text = it->shortText( date ); 813 QString text = it->shortText( date );
815 if ( !text.isEmpty() ) { 814 if ( !text.isEmpty() ) {
816 QLabel *label = new QLabel(text,mDayLabels); 815 QLabel *label = new QLabel(text,mDayLabels);
817 label->setAlignment(AlignCenter); 816 label->setAlignment(AlignCenter);
818 dayLayout->addWidget(label); 817 dayLayout->addWidget(label);
819 } 818 }
820 } 819 }
821 820
822 for(it = cds.first(); it; it = cds.next()) { 821 for(it = cds.first(); it; it = cds.next()) {
823 QWidget *wid = it->smallWidget(mDayLabels,date); 822 QWidget *wid = it->smallWidget(mDayLabels,date);
824 if ( wid ) { 823 if ( wid ) {
825 // wid->setHeight(20); 824 // wid->setHeight(20);
826 dayLayout->addWidget(wid); 825 dayLayout->addWidget(wid);
827 } 826 }
828 } 827 }
829#endif 828#endif
830 } 829 }
831 if ( ! appendLabels ) { 830 if ( ! appendLabels ) {
832 dayLabel = mDayLabelsList.next(); 831 dayLabel = mDayLabelsList.next();
833 if ( !dayLabel ) 832 if ( !dayLabel )
834 appendLabels = true; 833 appendLabels = true;
835 } 834 }
836 if ( appendLabels ) { 835 if ( appendLabels ) {
837 dayLabel = getNewDaylabel(); 836 dayLabel = getNewDaylabel();
838 } 837 }
839 //dayLabel->hide();//test only 838 //dayLabel->hide();//test only
840 839
841 dayLabel->setText(">"); 840 dayLabel->setText(">");
842 dayLabel->setFont( dlf ); 841 dayLabel->setFont( dlf );
843 dayLabel->setAutoRepeat( true ); 842 dayLabel->setAutoRepeat( true );
844 dayLabel->show(); 843 dayLabel->show();
845 dayLabel->setNum( -2 ); 844 dayLabel->setNum( -2 );
846 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 845 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
847 846
848 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 847 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
849 if ( !appendLabels ) { 848 if ( !appendLabels ) {
850 dayLabel = mDayLabelsList.next(); 849 dayLabel = mDayLabelsList.next();
851 while ( dayLabel ) { 850 while ( dayLabel ) {
852 //qDebug("!dayLabel %d",dayLabel ); 851 //qDebug("!dayLabel %d",dayLabel );
853 dayLabel->hide(); 852 dayLabel->hide();
854 dayLabel = mDayLabelsList.next(); 853 dayLabel = mDayLabelsList.next();
855 } 854 }
856 } 855 }
857 856
858 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 857 mDayLabelsFrame->setFixedHeight( newHight + 4 );
859} 858}
860 859
861int KOAgendaView::maxDatesHint() 860int KOAgendaView::maxDatesHint()
862{ 861{
863 // Not sure about the max number of events, so return 0 for now. 862 // Not sure about the max number of events, so return 0 for now.
864 return 0; 863 return 0;
865} 864}
866 865
867int KOAgendaView::currentDateCount() 866int KOAgendaView::currentDateCount()
868{ 867{
869 return mSelectedDates.count(); 868 return mSelectedDates.count();
870} 869}
871 870
872QPtrList<Incidence> KOAgendaView::selectedIncidences() 871QPtrList<Incidence> KOAgendaView::selectedIncidences()
873{ 872{
874 QPtrList<Incidence> selected; 873 QPtrList<Incidence> selected;
875 Incidence *incidence; 874 Incidence *incidence;
876 875
877 incidence = mAgenda->selectedIncidence(); 876 incidence = mAgenda->selectedIncidence();
878 if (incidence) selected.append(incidence); 877 if (incidence) selected.append(incidence);
879 878
880 incidence = mAllDayAgenda->selectedIncidence(); 879 incidence = mAllDayAgenda->selectedIncidence();
881 if (incidence) selected.append(incidence); 880 if (incidence) selected.append(incidence);
882 881
883 return selected; 882 return selected;
884} 883}
885 884
886DateList KOAgendaView::selectedDates() 885DateList KOAgendaView::selectedDates()
887{ 886{
888 DateList selected; 887 DateList selected;
889 QDate qd; 888 QDate qd;
890 889
891 qd = mAgenda->selectedIncidenceDate(); 890 qd = mAgenda->selectedIncidenceDate();
892 if (qd.isValid()) selected.append(qd); 891 if (qd.isValid()) selected.append(qd);
893 892
894 qd = mAllDayAgenda->selectedIncidenceDate(); 893 qd = mAllDayAgenda->selectedIncidenceDate();
895 if (qd.isValid()) selected.append(qd); 894 if (qd.isValid()) selected.append(qd);
896 895
897 return selected; 896 return selected;
898} 897}
899 898
900 899
901void KOAgendaView::updateView() 900void KOAgendaView::updateView()
902{ 901{
903 if ( mBlockUpdating ) 902 if ( mBlockUpdating )
904 return; 903 return;
905 // kdDebug() << "KOAgendaView::updateView()" << endl; 904 // kdDebug() << "KOAgendaView::updateView()" << endl;
906 fillAgenda(); 905 fillAgenda();
907 906
908} 907}
909 908
910 909
911/* 910/*
912 Update configuration settings for the agenda view. This method is not 911 Update configuration settings for the agenda view. This method is not
913 complete. 912 complete.
914*/ 913*/
915void KOAgendaView::updateConfig() 914void KOAgendaView::updateConfig()
916{ 915{
917 if ( mBlockUpdating ) 916 if ( mBlockUpdating )
918 return; 917 return;
919 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 918 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
920 int old = KOPrefs::instance()->mHourSize; 919 int old = KOPrefs::instance()->mHourSize;
921 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 920 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
922 qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 921 qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
923 } 922 }
924 923
925 924
926 // update config for children 925 // update config for children
927 mTimeLabels->updateConfig(); 926 mTimeLabels->updateConfig();
928 mAgenda->storePosition(); 927 mAgenda->storePosition();
929 mAgenda->updateConfig(); 928 mAgenda->updateConfig();
930 mAllDayAgenda->updateConfig(); 929 mAllDayAgenda->updateConfig();
931 // widget synchronization 930 // widget synchronization
932 //TODO: find a better way, maybe signal/slot 931 //TODO: find a better way, maybe signal/slot
933 mTimeLabels->positionChanged(); 932 mTimeLabels->positionChanged();
934 933
935 // for some reason, this needs to be called explicitly 934 // for some reason, this needs to be called explicitly
936 mTimeLabels->repaint(); 935 mTimeLabels->repaint();
937 936
938 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 937 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
939 938
940 // ToolTips displaying summary of events 939 // ToolTips displaying summary of events
941 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 940 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
942 ->mEnableToolTips); 941 ->mEnableToolTips);
943 942
944 //setHolidayMasks(); 943 //setHolidayMasks();
945 944
946 //createDayLabels(); called by via updateView(); 945 //createDayLabels(); called by via updateView();
947 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 946 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
948 updateView(); 947 updateView();
949 mAgenda->restorePosition(); 948 mAgenda->restorePosition();
950} 949}
951 950
952 951
953void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 952void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
954{ 953{
955 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 954 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
956 //qDebug("KOAgendaView::updateEventDates "); 955 //qDebug("KOAgendaView::updateEventDates ");
957 QDateTime startDt,endDt; 956 QDateTime startDt,endDt;
958 QDate startDate; 957 QDate startDate;
959 int lenInSecs; 958 int lenInSecs;
960 // if ( type == KOAgenda::RESIZETOP ) 959 // if ( type == KOAgenda::RESIZETOP )
961 // qDebug("RESIZETOP "); 960 // qDebug("RESIZETOP ");
962 // if ( type == KOAgenda::RESIZEBOTTOM ) 961 // if ( type == KOAgenda::RESIZEBOTTOM )
963 // qDebug("RESIZEBOTTOM "); 962 // qDebug("RESIZEBOTTOM ");
964 // if ( type == KOAgenda::MOVE ) 963 // if ( type == KOAgenda::MOVE )
965 // qDebug("MOVE "); 964 // qDebug("MOVE ");
966 if ( item->incidence()->type() == "Event" ) { 965 if ( item->incidence()->type() == "Event" ) {
967 startDt =item->incidence()->dtStart(); 966 startDt =item->incidence()->dtStart();
968 endDt = item->incidence()->dtEnd(); 967 endDt = item->incidence()->dtEnd();
969 lenInSecs = startDt.secsTo( endDt ); 968 lenInSecs = startDt.secsTo( endDt );
970 } 969 }
971 970
972 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 971 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
973 972
974 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 973 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
975 startDate = mSelectedDates[item->mLastMoveXPos]; 974 startDate = mSelectedDates[item->mLastMoveXPos];
976 } else { 975 } else {
977 if (item->cellX() < 0) { 976 if (item->cellX() < 0) {
978 startDate = (mSelectedDates.first()).addDays(item->cellX()); 977 startDate = (mSelectedDates.first()).addDays(item->cellX());
979 } else { 978 } else {
980 startDate = mSelectedDates[item->cellX()]; 979 startDate = mSelectedDates[item->cellX()];
981 } 980 }
982 } 981 }
983 startDt.setDate(startDate); 982 startDt.setDate(startDate);
984 983
985 if (item->incidence()->doesFloat()) { 984 if (item->incidence()->doesFloat()) {
986 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 985 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
987 } else { 986 } else {
988 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 987 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
989 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 988 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
990 if ( item->incidence()->type() == "Event" ) { 989 if ( item->incidence()->type() == "Event" ) {
991 if ( type == KOAgenda::MOVE ) { 990 if ( type == KOAgenda::MOVE ) {
992 endDt = startDt.addSecs(lenInSecs); 991 endDt = startDt.addSecs(lenInSecs);
993 992
994 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 993 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
995 if (item->lastMultiItem()) { 994 if (item->lastMultiItem()) {
996 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 995 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
997 endDt.setDate(startDate. 996 endDt.setDate(startDate.
998 addDays(item->lastMultiItem()->cellX() - item->cellX())); 997 addDays(item->lastMultiItem()->cellX() - item->cellX()));
999 } else { 998 } else {
1000 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 999 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1001 endDt.setDate(startDate); 1000 endDt.setDate(startDate);
1002 } 1001 }
1003 } 1002 }
1004 } else { 1003 } else {
1005 // todo 1004 // todo
1006 if (item->lastMultiItem()) { 1005 if (item->lastMultiItem()) {
1007 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1006 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1008 endDt.setDate(startDate. 1007 endDt.setDate(startDate.
1009 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1008 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1010 } else { 1009 } else {
1011 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1010 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1012 if ( item->cellYBottom() > 0 ) 1011 if ( item->cellYBottom() > 0 )
1013 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1012 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1014 else 1013 else
1015 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1014 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1016 endDt.setDate(startDate); 1015 endDt.setDate(startDate);
1017 } 1016 }
1018 } 1017 }
1019 } 1018 }
1020 if ( item->incidence()->type() == "Event" ) { 1019 if ( item->incidence()->type() == "Event" ) {
1021 item->incidence()->setDtStart(startDt); 1020 item->incidence()->setDtStart(startDt);
1022 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1021 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1023 } else if ( item->incidence()->type() == "Todo" ) { 1022 } else if ( item->incidence()->type() == "Todo" ) {
1024 Todo* to = static_cast<Todo*>(item->incidence()); 1023 Todo* to = static_cast<Todo*>(item->incidence());
1025 1024
1026 to->setDtDue(endDt); 1025 to->setDtDue(endDt);
1027 if ( to->hasStartDate() ) { 1026 if ( to->hasStartDate() ) {
1028 if (to->dtStart() >= to->dtDue() ) 1027 if (to->dtStart() >= to->dtDue() )
1029 to->setDtStart(to->dtDue().addDays( -2 )); 1028 to->setDtStart(to->dtDue().addDays( -2 ));
1030 } 1029 }
1031 1030
1032 } 1031 }
1033 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1032 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1034 item->incidence()->setRevision(item->incidence()->revision()+1); 1033 item->incidence()->setRevision(item->incidence()->revision()+1);
1035 item->setItemDate(startDt.date()); 1034 item->setItemDate(startDt.date());
1036 //item->updateItem(); 1035 //item->updateItem();
1037 if ( item->incidence()->type() == "Todo" ) { 1036 if ( item->incidence()->type() == "Todo" ) {
1038 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1037 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1039 1038
1040 } 1039 }
1041 else 1040 else
1042 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1041 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1043 item->updateItem(); 1042 item->updateItem();
1044} 1043}
1045 1044
1046void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1045void KOAgendaView::showDates( const QDate &start, const QDate &end )
1047{ 1046{
1048 // kdDebug() << "KOAgendaView::selectDates" << endl; 1047 // kdDebug() << "KOAgendaView::selectDates" << endl;
1049 1048
1050 mSelectedDates.clear(); 1049 mSelectedDates.clear();
1051 // qDebug("KOAgendaView::showDates "); 1050 // qDebug("KOAgendaView::showDates ");
1052 QDate d = start; 1051 QDate d = start;
1053 while (d <= end) { 1052 while (d <= end) {
1054 mSelectedDates.append(d); 1053 mSelectedDates.append(d);
1055 d = d.addDays( 1 ); 1054 d = d.addDays( 1 );
1056 } 1055 }
1057 1056
1058 // and update the view 1057 // and update the view
1059 fillAgenda(); 1058 fillAgenda();
1060} 1059}
1061 1060
1062 1061
1063void KOAgendaView::showEvents(QPtrList<Event>) 1062void KOAgendaView::showEvents(QPtrList<Event>)
1064{ 1063{
1065 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1064 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1066} 1065}
1067 1066
1068void KOAgendaView::changeEventDisplay(Event *, int) 1067void KOAgendaView::changeEventDisplay(Event *, int)
1069{ 1068{
1070 // qDebug("KOAgendaView::changeEventDisplay "); 1069 // qDebug("KOAgendaView::changeEventDisplay ");
1071 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1070 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1072 // this should be re-written to be MUCH smarter. Right now we 1071 // this should be re-written to be MUCH smarter. Right now we
1073 // are just playing dumb. 1072 // are just playing dumb.
1074 fillAgenda(); 1073 fillAgenda();
1075} 1074}
1076 1075
1077void KOAgendaView::fillAgenda(const QDate &) 1076void KOAgendaView::fillAgenda(const QDate &)
1078{ 1077{
1079 // qDebug("KOAgendaView::fillAgenda "); 1078 // qDebug("KOAgendaView::fillAgenda ");
1080 fillAgenda(); 1079 fillAgenda();
1081} 1080}
1082 1081
1083void KOAgendaView::fillAgenda() 1082void KOAgendaView::fillAgenda()
1084{ 1083{
1085 if ( globalFlagBlockStartup ) 1084 if ( globalFlagBlockStartup )
1086 return; 1085 return;
1087 if ( globalFlagBlockAgenda == 1 ) 1086 if ( globalFlagBlockAgenda == 1 )
1088 return; 1087 return;
1089 static bool onlyOne = false; 1088 static bool onlyOne = false;
1090 if ( onlyOne ) 1089 if ( onlyOne )
1091 return; 1090 return;
1092 onlyOne = true; 1091 onlyOne = true;
1093 //if ( globalFlagBlockAgenda == 2 ) 1092 //if ( globalFlagBlockAgenda == 2 )
1094 //globalFlagBlockAgenda = 0; 1093 //globalFlagBlockAgenda = 0;
1095 // globalFlagBlockPainting = false; 1094 // globalFlagBlockPainting = false;
1096 if ( globalFlagBlockAgenda == 0 ) 1095 if ( globalFlagBlockAgenda == 0 )
1097 globalFlagBlockAgenda = 1; 1096 globalFlagBlockAgenda = 1;
1098 // clearView(); 1097 // clearView();
1099 //qDebug("fillAgenda()++++ "); 1098 //qDebug("fillAgenda()++++ ");
1100 globalFlagBlockAgendaItemPaint = 1; 1099 globalFlagBlockAgendaItemPaint = 1;
1101 1100
1102 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1101 mAllDayAgenda->changeColumns(mSelectedDates.count());
1103 mAgenda->changeColumns(mSelectedDates.count()); 1102 mAgenda->changeColumns(mSelectedDates.count());
1104 qApp->processEvents(); 1103 qApp->processEvents();
1105 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1104 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1106 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1105 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1107 setHolidayMasks(); 1106 setHolidayMasks();
1108 1107
1109 //mAgenda->hideUnused(); 1108 //mAgenda->hideUnused();
1110 //mAllDayAgenda->hideUnused(); 1109 //mAllDayAgenda->hideUnused();
1111 1110
1112 // mAgenda->blockNextRepaint( false ); 1111 // mAgenda->blockNextRepaint( false );
1113 // mAgenda->viewport()->repaint(); 1112 // mAgenda->viewport()->repaint();
1114 // mAgenda->blockNextRepaint( true ); 1113 // mAgenda->blockNextRepaint( true );
1115 mMinY.resize(mSelectedDates.count()); 1114 mMinY.resize(mSelectedDates.count());
1116 mMaxY.resize(mSelectedDates.count()); 1115 mMaxY.resize(mSelectedDates.count());
1117 1116
1118 QPtrList<Event> dayEvents; 1117 QPtrList<Event> dayEvents;
1119 1118
1120 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1119 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1121 // Therefore, gtodoset all of them. 1120 // Therefore, gtodoset all of them.
1122 QPtrList<Todo> todos = calendar()->todos(); 1121 QPtrList<Todo> todos = calendar()->todos();
1123 1122
1124 mAgenda->setDateList(mSelectedDates); 1123 mAgenda->setDateList(mSelectedDates);
1125 1124
1126 QDate today = QDate::currentDate(); 1125 QDate today = QDate::currentDate();
1127 1126
1128 DateList::ConstIterator dit; 1127 DateList::ConstIterator dit;
1129 int curCol = 0; 1128 int curCol = 0;
1130 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1129 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1131 QDate currentDate = *dit; 1130 QDate currentDate = *dit;
1132 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1131 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1133 // << endl; 1132 // << endl;
1134 1133
1135 dayEvents = calendar()->events(currentDate,true); 1134 dayEvents = calendar()->events(currentDate,true);
1136 1135
1137 // Default values, which can never be reached 1136 // Default values, which can never be reached
1138 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1137 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1139 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1138 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1140 1139
1141 unsigned int numEvent; 1140 unsigned int numEvent;
1142 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1141 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1143 Event *event = dayEvents.at(numEvent); 1142 Event *event = dayEvents.at(numEvent);
1144 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1143 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1145 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1144 if ( event->uid().left(15) == QString("last-syncEvent-") )
1146 continue; 1145 continue;
1147 // kdDebug() << " Event: " << event->summary() << endl; 1146 // kdDebug() << " Event: " << event->summary() << endl;
1148 1147
1149 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1148 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1150 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1149 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1151 1150
1152 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1151 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1153 1152
1154 if (event->doesFloat()) { 1153 if (event->doesFloat()) {
1155 if (event->recurrence()->doesRecur()) { 1154 if (event->recurrence()->doesRecur()) {
1156 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1155 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1157 } else { 1156 } else {
1158 if (beginX <= 0 && curCol == 0) { 1157 if (beginX <= 0 && curCol == 0) {
1159 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1158 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1160 } else if (beginX == curCol) { 1159 } else if (beginX == curCol) {
1161 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1160 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1162 } 1161 }
1163 } 1162 }
1164 } else if (event->isMultiDay()) { 1163 } else if (event->isMultiDay()) {
1165 if ( event->doesRecur () ) { 1164 if ( event->doesRecur () ) {
1166 QDate dateit = currentDate; 1165 QDate dateit = currentDate;
1167 int count = 0; 1166 int count = 0;
1168 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1167 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1169 while (! event->recursOn( dateit ) && count <= max ) { 1168 while (! event->recursOn( dateit ) && count <= max ) {
1170 ++count; 1169 ++count;
1171 dateit = dateit.addDays( -1 ); 1170 dateit = dateit.addDays( -1 );
1172 } 1171 }
1173 bool ok; 1172 bool ok;
1174 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1173 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1175 if ( ok ) 1174 if ( ok )
1176 { 1175 {
1177 int secs = event->dtStart().secsTo( event->dtEnd() ); 1176 int secs = event->dtStart().secsTo( event->dtEnd() );
1178 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1177 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1179 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1178 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1180 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1179 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1181 1180
1182 } 1181 }
1183 } 1182 }
1184 int startY = mAgenda->timeToY(event->dtStart().time()); 1183 int startY = mAgenda->timeToY(event->dtStart().time());
1185 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1184 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1186 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1185 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1187 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1186 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1188 //qDebug("insert!!! "); 1187 //qDebug("insert!!! ");
1189 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1188 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1190 } 1189 }
1191 if (beginX == curCol) { 1190 if (beginX == curCol) {
1192 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1191 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1193 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1192 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1194 } else if (endX == curCol) { 1193 } else if (endX == curCol) {
1195 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1194 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1196 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1195 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1197 } else { 1196 } else {
1198 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1197 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1199 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1198 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1200 } 1199 }
1201 } else { 1200 } else {
1202 int startY = mAgenda->timeToY(event->dtStart().time()); 1201 int startY = mAgenda->timeToY(event->dtStart().time());
1203 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1202 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1204 if (endY < startY) endY = startY; 1203 if (endY < startY) endY = startY;
1205 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1204 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1206 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1205 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1207 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1206 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1208 } 1207 }
1209 } 1208 }
1210 // ---------- [display Todos -------------- 1209 // ---------- [display Todos --------------
1211 unsigned int numTodo; 1210 unsigned int numTodo;
1212 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1211 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1213 Todo *todo = todos.at(numTodo); 1212 Todo *todo = todos.at(numTodo);
1214 1213
1215 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1214 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1216 1215
1217 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1216 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1218 // Already completed items can be displayed on their original due date 1217 // Already completed items can be displayed on their original due date
1219 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1218 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1220 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1219 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1221 bool fillIn = false; 1220 bool fillIn = false;
1222 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1221 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1223 fillIn = true; 1222 fillIn = true;
1224 if ( ! fillIn && !todo->hasCompletedDate() ) 1223 if ( ! fillIn && !todo->hasCompletedDate() )
1225 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1224 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1226 if ( fillIn ) { 1225 if ( fillIn ) {
1227 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1226 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1228 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1227 if ( KOPrefs::instance()->mShowTodoInAgenda )
1229 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1228 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1230 } 1229 }
1231 else { 1230 else {
1232 QDateTime dt; 1231 QDateTime dt;
1233 if ( todo->hasCompletedDate() ) 1232 if ( todo->hasCompletedDate() )
1234 dt = todo->completed(); 1233 dt = todo->completed();
1235 else 1234 else
1236 dt = todo->dtDue();; 1235 dt = todo->dtDue();;
1237 1236
1238 1237
1239 int endY = mAgenda->timeToY(dt.time()) - 1; 1238 int endY = mAgenda->timeToY(dt.time()) - 1;
1240 int hi = (18/KOPrefs::instance()->mHourSize); 1239 int hi = (18/KOPrefs::instance()->mHourSize);
1241 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1240 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1242 int startY = endY -hi; 1241 int startY = endY -hi;
1243 1242
1244 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1243 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1245 1244
1246 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1245 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1247 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1246 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1248 } 1247 }
1249 } 1248 }
1250 } 1249 }
1251 // ---------- display Todos] -------------- 1250 // ---------- display Todos] --------------
1252 1251
1253 ++curCol; 1252 ++curCol;
1254 } 1253 }
1255 mAgenda->hideUnused(); 1254 mAgenda->hideUnused();
1256 mAllDayAgenda->hideUnused(); 1255 mAllDayAgenda->hideUnused();
1257 mAgenda->checkScrollBoundaries(); 1256 mAgenda->checkScrollBoundaries();
1258 1257
1259 deleteSelectedDateTime(); 1258 deleteSelectedDateTime();
1260 1259
1261 createDayLabels(); 1260 createDayLabels();
1262 emit incidenceSelected( 0 ); 1261 emit incidenceSelected( 0 );
1263 1262
1264 if ( globalFlagBlockAgenda == 2 ) { 1263 if ( globalFlagBlockAgenda == 2 ) {
1265 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1264 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1266 setStartHour( KOPrefs::instance()->mDayBegins ); 1265 setStartHour( KOPrefs::instance()->mDayBegins );
1267 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1266 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1268 setStartHour( QTime::currentTime ().hour() ); 1267 setStartHour( QTime::currentTime ().hour() );
1269 // qApp->processEvents(); 1268 // qApp->processEvents();
1270 } 1269 }
1271 qApp->processEvents(); 1270 qApp->processEvents();
1272 //qDebug("qApp->processEvents(); END "); 1271 //qDebug("qApp->processEvents(); END ");
1273 globalFlagBlockAgenda = 0; 1272 globalFlagBlockAgenda = 0;
1274 1273
1275 // mAgenda->hideUnused(); 1274 // mAgenda->hideUnused();
1276 //mAllDayAgenda->hideUnused(); 1275 //mAllDayAgenda->hideUnused();
1277 mAllDayAgenda->drawContentsToPainter(); 1276 mAllDayAgenda->drawContentsToPainter();
1278 mAgenda->drawContentsToPainter(); 1277 mAgenda->drawContentsToPainter();
1279 repaintAgenda(); 1278 repaintAgenda();
1280 onlyOne = false; 1279 onlyOne = false;
1281 // mAgenda->finishUpdate(); 1280 // mAgenda->finishUpdate();
1282 //mAllDayAgenda->finishUpdate(); 1281 //mAllDayAgenda->finishUpdate();
1283 1282
1284 // repaintAgenda(); 1283 // repaintAgenda();
1285 //qApp->processEvents(); 1284 //qApp->processEvents();
1286 // globalFlagBlockAgenda = 0; 1285 // globalFlagBlockAgenda = 0;
1287} 1286}
1288void KOAgendaView::repaintAgenda() 1287void KOAgendaView::repaintAgenda()
1289{ 1288{
1290 // mAllDayAgenda->drawContentsToPainter(); 1289 // mAllDayAgenda->drawContentsToPainter();
1291// mAllDayAgenda->viewport()->repaint( false ); 1290// mAllDayAgenda->viewport()->repaint( false );
1292// mAgenda->drawContentsToPainter(); 1291// mAgenda->drawContentsToPainter();
1293// mAgenda->viewport()->repaint( false ); 1292// mAgenda->viewport()->repaint( false );
1294// qApp->processEvents(); 1293// qApp->processEvents();
1295 1294
1296 //qDebug("KOAgendaView::repaintAgenda() "); 1295 //qDebug("KOAgendaView::repaintAgenda() ");
1297 //qApp->processEvents(); 1296 //qApp->processEvents();
1298 mAgenda->viewport()->repaint( false ); 1297 mAgenda->viewport()->repaint( false );
1299 mAllDayAgenda->viewport()->repaint( false ); 1298 mAllDayAgenda->viewport()->repaint( false );
1300 mAgenda->finishUpdate(); 1299 mAgenda->finishUpdate();
1301 mAllDayAgenda->finishUpdate(); 1300 mAllDayAgenda->finishUpdate();
1302} 1301}
1303 1302
1304 1303
1305void KOAgendaView::clearView() 1304void KOAgendaView::clearView()
1306{ 1305{
1307 // kdDebug() << "ClearView" << endl; 1306 // kdDebug() << "ClearView" << endl;
1308 mAllDayAgenda->clear(); 1307 mAllDayAgenda->clear();
1309 mAgenda->clear(); 1308 mAgenda->clear();
1310} 1309}
1311 1310
1312void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1311void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1313 const QDate &td) 1312 const QDate &td)
1314{ 1313{
1315#ifndef KORG_NOPRINTER 1314#ifndef KORG_NOPRINTER
1316 if (fd == td) 1315 if (fd == td)
1317 calPrinter->preview(CalPrinter::Day, fd, td); 1316 calPrinter->preview(CalPrinter::Day, fd, td);
1318 else 1317 else
1319 calPrinter->preview(CalPrinter::Week, fd, td); 1318 calPrinter->preview(CalPrinter::Week, fd, td);
1320#endif 1319#endif
1321} 1320}
1322 1321
1323// void KOAgendaView::updateMovedTodo() 1322// void KOAgendaView::updateMovedTodo()
1324// { 1323// {
1325// // updateConfig(); 1324// // updateConfig();
1326// // emit updateTodoViews(); 1325// // emit updateTodoViews();
1327// } 1326// }
1328 1327
1329void KOAgendaView::slotShowDateView( int mode , int d ) 1328void KOAgendaView::slotShowDateView( int mode , int d )
1330{ 1329{
1331 if ( d >= mSelectedDates.count() ) { 1330 if ( d >= mSelectedDates.count() ) {
1332 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); 1331 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() );
1333 1332
1334 } else { 1333 } else {
1335 QDate day = mSelectedDates[d]; 1334 QDate day = mSelectedDates[d];
1336 emit showDateView(mode , day ); 1335 emit showDateView(mode , day );
1337 } 1336 }
1338 1337
1339} 1338}
1340void KOAgendaView::newEvent(int gx, int gy) 1339void KOAgendaView::newEvent(int gx, int gy)
1341{ 1340{
1342 if (!mSelectedDates.count()) return; 1341 if (!mSelectedDates.count()) return;
1343 1342
1344 QDate day = mSelectedDates[gx]; 1343 QDate day = mSelectedDates[gx];
1345 1344
1346 QTime time = mAgenda->gyToTime(gy); 1345 QTime time = mAgenda->gyToTime(gy);
1347 QDateTime dt(day,time); 1346 QDateTime dt(day,time);
1348 // if ( dt < QDateTime::currentDateTime () ) 1347 // if ( dt < QDateTime::currentDateTime () )
1349 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1348 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1350 emit newEventSignal(dt); 1349 emit newEventSignal(dt);
1351} 1350}
1352 1351
1353void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1352void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1354{ 1353{
1355 if (!mSelectedDates.count()) return; 1354 if (!mSelectedDates.count()) return;
1356 1355
1357 QDate dayStart = mSelectedDates[gxStart]; 1356 QDate dayStart = mSelectedDates[gxStart];
1358 QDate dayEnd = mSelectedDates[gxEnd]; 1357 QDate dayEnd = mSelectedDates[gxEnd];
1359 1358
1360 QTime timeStart = mAgenda->gyToTime(gyStart); 1359 QTime timeStart = mAgenda->gyToTime(gyStart);
1361 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1360 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1362 1361
1363 QDateTime dtStart(dayStart,timeStart); 1362 QDateTime dtStart(dayStart,timeStart);
1364 QDateTime dtEnd(dayEnd,timeEnd); 1363 QDateTime dtEnd(dayEnd,timeEnd);
1365 1364
1366 emit newEventSignal(dtStart,dtEnd); 1365 emit newEventSignal(dtStart,dtEnd);
1367} 1366}
1368 1367
1369void KOAgendaView::newEventAllDay(int gx, int ) 1368void KOAgendaView::newEventAllDay(int gx, int )
1370{ 1369{
1371 if (!mSelectedDates.count()) return; 1370 if (!mSelectedDates.count()) return;
1372 1371
1373 QDate day = mSelectedDates[gx]; 1372 QDate day = mSelectedDates[gx];
1374 1373
1375 emit newEventSignal(day); 1374 emit newEventSignal(day);
1376} 1375}
1377void KOAgendaView::newTodoAllDay(int gx, int ) 1376void KOAgendaView::newTodoAllDay(int gx, int )
1378{ 1377{
1379 if (!mSelectedDates.count()) return; 1378 if (!mSelectedDates.count()) return;
1380 1379
1381 QDateTime day (mSelectedDates[gx] ); 1380 QDateTime day (mSelectedDates[gx] );
1382 emit newTodoSignal(day, true); 1381 emit newTodoSignal(day, true);
1383} 1382}
1384void KOAgendaView::newTodo(int gx, int gy ) 1383void KOAgendaView::newTodo(int gx, int gy )
1385{ 1384{
1386 if (!mSelectedDates.count()) return; 1385 if (!mSelectedDates.count()) return;
1387 QDate dayStart = mSelectedDates[gx]; 1386 QDate dayStart = mSelectedDates[gx];
1388 QTime timeStart = mAgenda->gyToTime(gy); 1387 QTime timeStart = mAgenda->gyToTime(gy);
1389 QDateTime dt (dayStart,timeStart); 1388 QDateTime dt (dayStart,timeStart);
1390 emit newTodoSignal( dt, false ); 1389 emit newTodoSignal( dt, false );
1391} 1390}
1392 1391
1393void KOAgendaView::updateEventIndicatorTop(int newY) 1392void KOAgendaView::updateEventIndicatorTop(int newY)
1394{ 1393{
1395 uint i; 1394 uint i;
1396 for(i=0;i<mMinY.size();++i) { 1395 for(i=0;i<mMinY.size();++i) {
1397 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1396 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1398 else mEventIndicatorTop->enableColumn(i,false); 1397 else mEventIndicatorTop->enableColumn(i,false);
1399 } 1398 }
1400 1399
1401 mEventIndicatorTop->update(); 1400 mEventIndicatorTop->update();
1402} 1401}
1403 1402
1404void KOAgendaView::updateEventIndicatorBottom(int newY) 1403void KOAgendaView::updateEventIndicatorBottom(int newY)
1405{ 1404{
1406 uint i; 1405 uint i;
1407 for(i=0;i<mMaxY.size();++i) { 1406 for(i=0;i<mMaxY.size();++i) {
1408 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1407 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1409 else mEventIndicatorBottom->enableColumn(i,false); 1408 else mEventIndicatorBottom->enableColumn(i,false);
1410 } 1409 }
1411 1410
1412 mEventIndicatorBottom->update(); 1411 mEventIndicatorBottom->update();
1413} 1412}
1414 1413
1415void KOAgendaView::startDrag(Event *event) 1414void KOAgendaView::startDrag(Event *event)
1416{ 1415{
1417#ifndef KORG_NODND 1416#ifndef KORG_NODND
1418 DndFactory factory( calendar() ); 1417 DndFactory factory( calendar() );
1419 ICalDrag *vd = factory.createDrag(event,this); 1418 ICalDrag *vd = factory.createDrag(event,this);
1420 if (vd->drag()) { 1419 if (vd->drag()) {
1421 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1420 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1422 } 1421 }
1423#endif 1422#endif
1424} 1423}
1425 1424
1426void KOAgendaView::readSettings() 1425void KOAgendaView::readSettings()
1427{ 1426{
1428 readSettings(KOGlobals::config()); 1427 readSettings(KOGlobals::config());
1429} 1428}
1430 1429
1431void KOAgendaView::readSettings(KConfig *config) 1430void KOAgendaView::readSettings(KConfig *config)
1432{ 1431{
1433 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1432 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1434 1433
1435 config->setGroup("Views"); 1434 config->setGroup("Views");
1436 1435
1437 //#ifndef KORG_NOSPLITTER 1436 //#ifndef KORG_NOSPLITTER
1438 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1437 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1439 if (sizes.count() == 2) { 1438 if (sizes.count() == 2) {
1440 if ( sizes[0] < 20 ) { 1439 if ( sizes[0] < 20 ) {
1441 sizes[1] = sizes[1] +20 - sizes[0]; 1440 sizes[1] = sizes[1] +20 - sizes[0];
1442 sizes[0] = 20; 1441 sizes[0] = 20;
1443 } 1442 }
1444 mSplitterAgenda->setSizes(sizes); 1443 mSplitterAgenda->setSizes(sizes);
1445 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1444 // qDebug("read %d %d ",sizes[0],sizes[1] );
1446 } 1445 }
1447 //#endif 1446 //#endif
1448 1447
1449 // updateConfig(); 1448 // updateConfig();
1450} 1449}
1451 1450
1452void KOAgendaView::writeSettings(KConfig *config) 1451void KOAgendaView::writeSettings(KConfig *config)
1453{ 1452{
1454 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1453 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1455 1454
1456 config->setGroup("Views"); 1455 config->setGroup("Views");
1457 1456
1458 //#ifndef KORG_NOSPLITTER 1457 //#ifndef KORG_NOSPLITTER
1459 QValueList<int> list = mSplitterAgenda->sizes(); 1458 QValueList<int> list = mSplitterAgenda->sizes();
1460 config->writeEntry("Separator AgendaView",list); 1459 config->writeEntry("Separator AgendaView",list);
1461 //qDebug("write %d %d ", list[0],list[1] ); 1460 //qDebug("write %d %d ", list[0],list[1] );
1462 //#endif 1461 //#endif
1463} 1462}
1464 1463
1465void KOAgendaView::setHolidayMasks() 1464void KOAgendaView::setHolidayMasks()
1466{ 1465{
1467 mHolidayMask.resize(mSelectedDates.count()); 1466 mHolidayMask.resize(mSelectedDates.count());
1468 1467
1469 uint i; 1468 uint i;
1470 for(i=0;i<mSelectedDates.count();++i) { 1469 for(i=0;i<mSelectedDates.count();++i) {
1471 QDate date = mSelectedDates[i]; 1470 QDate date = mSelectedDates[i];
1472 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1471 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1473 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1472 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1474 bool showHoliday = false; 1473 bool showHoliday = false;
1475 if ( KOPrefs::instance()->mExcludeHolidays ) { 1474 if ( KOPrefs::instance()->mExcludeHolidays ) {
1476 QPtrList<Event> events = calendar()->events( date, true ); 1475 QPtrList<Event> events = calendar()->events( date, true );
1477 Event *event; 1476 Event *event;
1478 for( event = events.first(); event; event = events.next() ) { 1477 for( event = events.first(); event; event = events.next() ) {
1479 if ( event->isHoliday()) { 1478 if ( event->isHoliday()) {
1480 showHoliday = true; 1479 showHoliday = true;
1481 break; 1480 break;
1482 } 1481 }
1483 } 1482 }
1484 1483
1485 } 1484 }
1486 1485
1487#ifndef KORG_NOPLUGINS 1486#ifndef KORG_NOPLUGINS
1488 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1487 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1489 !KOCore::self()->holiday(date).isEmpty(); 1488 !KOCore::self()->holiday(date).isEmpty();
1490#endif 1489#endif
1491 bool showDay = showSaturday || showSunday || showHoliday; 1490 bool showDay = showSaturday || showSunday || showHoliday;
1492 1491
1493 if (showDay) { 1492 if (showDay) {
1494 mHolidayMask.at(i) = true; 1493 mHolidayMask.at(i) = true;
1495 } else { 1494 } else {
1496 mHolidayMask.at(i) = false; 1495 mHolidayMask.at(i) = false;
1497 } 1496 }
1498 } 1497 }
1499 1498
1500 mAgenda->setHolidayMask(&mHolidayMask); 1499 mAgenda->setHolidayMask(&mHolidayMask);
1501 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1500 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1502} 1501}
1503 1502
1504void KOAgendaView::setContentsPos(int y) 1503void KOAgendaView::setContentsPos(int y)
1505{ 1504{
1506 mAgenda->setContentsPos(0,y); 1505 mAgenda->setContentsPos(0,y);
1507} 1506}
1508 1507
1509void KOAgendaView::clearSelection() 1508void KOAgendaView::clearSelection()
1510{ 1509{
1511 mAgenda->deselectItem(); 1510 mAgenda->deselectItem();
1512 mAllDayAgenda->deselectItem(); 1511 mAllDayAgenda->deselectItem();
1513} 1512}
1514 1513
1515void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1514void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1516 int gxEnd, int gyEnd) 1515 int gxEnd, int gyEnd)
1517{ 1516{
1518 mTimeSpanInAllDay = true; 1517 mTimeSpanInAllDay = true;
1519 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1518 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1520} 1519}
1521 1520
1522 1521
1523 1522
1524 1523
1525void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1524void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1526 int gxEnd, int gyEnd) 1525 int gxEnd, int gyEnd)
1527{ 1526{
1528 if (!mSelectedDates.count()) return; 1527 if (!mSelectedDates.count()) return;
1529 1528
1530 QDate dayStart = mSelectedDates[gxStart]; 1529 QDate dayStart = mSelectedDates[gxStart];
1531 QDate dayEnd = mSelectedDates[gxEnd]; 1530 QDate dayEnd = mSelectedDates[gxEnd];
1532 1531
1533 QTime timeStart = mAgenda->gyToTime(gyStart); 1532 QTime timeStart = mAgenda->gyToTime(gyStart);
1534 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1533 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1535 1534
1536 QDateTime dtStart(dayStart,timeStart); 1535 QDateTime dtStart(dayStart,timeStart);
1537 QDateTime dtEnd(dayEnd,timeEnd); 1536 QDateTime dtEnd(dayEnd,timeEnd);
1538 1537
1539 mTimeSpanBegin = dtStart; 1538 mTimeSpanBegin = dtStart;
1540 mTimeSpanEnd = dtEnd; 1539 mTimeSpanEnd = dtEnd;
1541 1540
1542} 1541}
1543 1542
1544void KOAgendaView::deleteSelectedDateTime() 1543void KOAgendaView::deleteSelectedDateTime()
1545{ 1544{
1546 mTimeSpanBegin.setDate(QDate()); 1545 mTimeSpanBegin.setDate(QDate());
1547 mTimeSpanEnd.setDate(QDate()); 1546 mTimeSpanEnd.setDate(QDate());
1548 mTimeSpanInAllDay = false; 1547 mTimeSpanInAllDay = false;
1549} 1548}
1550 1549
1551void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1550void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1552{ 1551{
1553 e->ignore(); 1552 e->ignore();
1554} 1553}
1555 1554
1556void KOAgendaView::scrollOneHourUp() 1555void KOAgendaView::scrollOneHourUp()
1557{ 1556{
1558 1557
1559 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1558 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1560} 1559}
1561void KOAgendaView::scrollOneHourDown() 1560void KOAgendaView::scrollOneHourDown()
1562{ 1561{
1563 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1562 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1564} 1563}
1565 1564
1566void KOAgendaView::setStartHour( int h ) 1565void KOAgendaView::setStartHour( int h )
1567{ 1566{
1568 mAgenda->setStartHour( h ); 1567 mAgenda->setStartHour( h );
1569 1568
1570} 1569}
1571void KOAgendaView::setInitStartHour() 1570void KOAgendaView::setInitStartHour()
1572{ 1571{
1573 1572
1574 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1573 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1575 setStartHour( QTime::currentTime ().hour() ); 1574 setStartHour( QTime::currentTime ().hour() );
1576 else 1575 else
1577 setStartHour( KOPrefs::instance()->mDayBegins ); 1576 setStartHour( KOPrefs::instance()->mDayBegins );
1578 1577
1579} 1578}
1580 1579
1581 1580
1582void KOAgendaView::updateTodo( Todo * t, int ) 1581void KOAgendaView::updateTodo( Todo * t, int )
1583{ 1582{
1584 if ( !isVisible() ) 1583 if ( !isVisible() )
1585 return; 1584 return;
1586 bool remove = false; 1585 bool remove = false;
1587 bool removeAD = false; 1586 bool removeAD = false;
1588 QDate da; 1587 QDate da;
1589 if ( t->hasCompletedDate() ) 1588 if ( t->hasCompletedDate() )
1590 da = t->completed().date(); 1589 da = t->completed().date();
1591 else 1590 else
1592 da = t->dtDue().date(); 1591 da = t->dtDue().date();
1593 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1592 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1594 remove = true; 1593 remove = true;
1595 removeAD = true; 1594 removeAD = true;
1596 } 1595 }
1597 else { 1596 else {
1598 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1597 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1599 if ( overdue && 1598 if ( overdue &&
1600 QDate::currentDate() >= mSelectedDates.first() && 1599 QDate::currentDate() >= mSelectedDates.first() &&
1601 QDate::currentDate() <= mSelectedDates.last()) { 1600 QDate::currentDate() <= mSelectedDates.last()) {
1602 removeAD = false; 1601 removeAD = false;
1603 remove = true; 1602 remove = true;
1604 } 1603 }
1605 else { 1604 else {
1606 1605
1607 if ( da < mSelectedDates.first() || 1606 if ( da < mSelectedDates.first() ||
1608 da > mSelectedDates.last() ) { 1607 da > mSelectedDates.last() ) {
1609 remove = true; 1608 remove = true;
1610 removeAD = true; 1609 removeAD = true;
1611 } else { 1610 } else {
1612 remove = t->doesFloat() && !t->hasCompletedDate(); 1611 remove = t->doesFloat() && !t->hasCompletedDate();
1613 removeAD = !remove; 1612 removeAD = !remove;
1614 } 1613 }
1615 } 1614 }
1616 } 1615 }
1617 int days = mSelectedDates.first().daysTo( da ); 1616 int days = mSelectedDates.first().daysTo( da );
1618 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1617 //qDebug("daysto %d %d %d", days, remove,removeAD );
1619 mAgenda->updateTodo( t , days, remove); 1618 mAgenda->updateTodo( t , days, remove);
1620 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1619 if ( KOPrefs::instance()->mShowTodoInAgenda )
1621 mAllDayAgenda->updateTodo( t , days, removeAD); 1620 mAllDayAgenda->updateTodo( t , days, removeAD);
1622 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1621 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1623 1622
1624} 1623}