summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-25 21:08:48 (UTC)
committer zautrix <zautrix>2005-03-25 21:08:48 (UTC)
commit6427570041c902840fe0f557415a07bb7aa8c031 (patch) (unidiff)
treee397342aca97119927ec6c312be5ac5f953d5eec
parent4d93404e3453229e58c2ff9305beae131c9f1af9 (diff)
downloadkdepimpi-6427570041c902840fe0f557415a07bb7aa8c031.zip
kdepimpi-6427570041c902840fe0f557415a07bb7aa8c031.tar.gz
kdepimpi-6427570041c902840fe0f557415a07bb7aa8c031.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt8
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--korganizer/datenavigatorcontainer.cpp2
-rw-r--r--korganizer/datenavigatorcontainer.h1
-rw-r--r--korganizer/kdatenavigator.cpp3
-rw-r--r--korganizer/kdatenavigator.h1
-rw-r--r--korganizer/koviewmanager.cpp10
-rw-r--r--korganizer/koviewmanager.h3
8 files changed, 29 insertions, 3 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 1c2bff8..6f8b041 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,183 +1,189 @@
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.21 ************ 3********** VERSION 2.0.21 ************
4 4
5Fixed another SMTP problem in OM/Pi. 5Fixed another SMTP problem in OM/Pi.
6Some small changed in the new datenavigator in KO/Pi. 6Some small changed in the new datenavigator in KO/Pi.
7Changed default setting for new filter in KA/Pi to "exclude categories". 7Changed default setting for new filter in KA/Pi to "exclude categories".
8Changed the default font size for 640x480 display 8Changed the default font size for 640x480 display .
9Changed popup menu behaviour in agenda and list view.
10Fixed some layout problems of the date label size in the month view.
11Made month view update faster.
12Made first datenavigator repainting faster.
13Changed the title of the event/todo edit dialogs.
14
9 15
10********** VERSION 2.0.20 ************ 16********** VERSION 2.0.20 ************
11 17
12Two small fixes in OM/Pi. 18Two small fixes in OM/Pi.
13 19
14Better resizing of the new datenavigator in KO/Pi. 20Better resizing of the new datenavigator in KO/Pi.
15 21
16********** VERSION 2.0.19 ************ 22********** VERSION 2.0.19 ************
17KO/Pi: 23KO/Pi:
18Enhancements and bugfixes in the new datenavigator. 24Enhancements and bugfixes in the new datenavigator.
19Bugfix in this changelog: 25Bugfix in this changelog:
20The datenavigator was changed in version 2.0.18, not the datepicker. 26The datenavigator was changed in version 2.0.18, not the datepicker.
21 27
22********** VERSION 2.0.18 ************ 28********** VERSION 2.0.18 ************
23KO/Pi: 29KO/Pi:
24Fixed some minor problems. 30Fixed some minor problems.
25Cleaned up the KO/Pi config dialog. 31Cleaned up the KO/Pi config dialog.
26Fixed problem moving events in aganda view. 32Fixed problem moving events in aganda view.
27Made datepicker scaleable, i.e. if the datenavigator shows now a 33Made datepicker scaleable, i.e. if the datenavigator shows now a
28datenavigator matrix depending on its size. 34datenavigator matrix depending on its size.
29Birthdays are now displayed green in the datenavigator. 35Birthdays are now displayed green in the datenavigator.
30What'sThis Help in datenavigator shows all events of the day. 36What'sThis Help in datenavigator shows all events of the day.
31 37
32OM/Pi: 38OM/Pi:
33Updated the backend mail library to the latest version. 39Updated the backend mail library to the latest version.
34Please backup your mail before using this version. 40Please backup your mail before using this version.
35 41
36********** VERSION 2.0.17 ************ 42********** VERSION 2.0.17 ************
37 43
38KO/Pi: 44KO/Pi:
39Tooltips in month view were not sorted. Fixed. 45Tooltips in month view were not sorted. Fixed.
40Daylabel in agenda view ( for display of one day ) was too short. Fixed. 46Daylabel in agenda view ( for display of one day ) was too short. Fixed.
41Conflict display dialog for syncing was not on top of other windows. Fixed. 47Conflict display dialog for syncing was not on top of other windows. Fixed.
42Fixed some minor problems. 48Fixed some minor problems.
43 49
44Fixed an endless loop when importing vcs file with RESOURCES entry. 50Fixed an endless loop when importing vcs file with RESOURCES entry.
45 51
46********** VERSION 2.0.16 ************ 52********** VERSION 2.0.16 ************
47OM/Pi: 53OM/Pi:
48Fixed the SMTP account setting the option. 54Fixed the SMTP account setting the option.
49Fixed something in mail sending. 55Fixed something in mail sending.
50 56
51KO/Pi: 57KO/Pi:
52Added possibility to export selected events/todos as vcal file. 58Added possibility to export selected events/todos as vcal file.
53 59
54********** VERSION 2.0.15 ************ 60********** VERSION 2.0.15 ************
55 61
56PwM/Pi: 62PwM/Pi:
57Added keyboard shorcuts for 63Added keyboard shorcuts for
58- toggling summary view (space bar) 64- toggling summary view (space bar)
59- delete item (delete + backspace key) 65- delete item (delete + backspace key)
60- add new item ( i + n key) 66- add new item ( i + n key)
61Fixed length of info in the title. 67Fixed length of info in the title.
62 68
63KO/Pi-KA/Pi: 69KO/Pi-KA/Pi:
64Changed "ME" menu bar entry to an icon. 70Changed "ME" menu bar entry to an icon.
65 71
66KO/Pi: 72KO/Pi:
67Fixed two minor bugs in displaying todos. 73Fixed two minor bugs in displaying todos.
68If in month view a cell is selected, the key shortcut "d" shows now that date. 74If in month view a cell is selected, the key shortcut "d" shows now that date.
69Added complete info for a todo in month view as an icon left of the text. 75Added complete info for a todo in month view as an icon left of the text.
70Fixed problems of displaying data when "<" or ">" are used in summary/location/description. 76Fixed problems of displaying data when "<" or ">" are used in summary/location/description.
71Fixed problem of search dialog size when switching displays. 77Fixed problem of search dialog size when switching displays.
72Cancel key now closes date picker. 78Cancel key now closes date picker.
73Rearranged KO/Pi file menu structure. 79Rearranged KO/Pi file menu structure.
74 80
75OM/Pi: 81OM/Pi:
76Added to the SMTP account setting the option 82Added to the SMTP account setting the option
77"No secure connection". 83"No secure connection".
78You have to configure your SMTP accounts again, sorry. 84You have to configure your SMTP accounts again, sorry.
79 85
80KA/Pi: 86KA/Pi:
81Added support for importing quoted-printable. 87Added support for importing quoted-printable.
82Support was added by Peter P.. Thanks, Peter! 88Support was added by Peter P.. Thanks, Peter!
83 89
84 90
85********** VERSION 2.0.14 ************ 91********** VERSION 2.0.14 ************
86 92
87Made Passwordmanager PwM/Pi more userfriendly: 93Made Passwordmanager PwM/Pi more userfriendly:
88Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. 94Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more.
89Fixed bug in KO/Pi todo printing. 95Fixed bug in KO/Pi todo printing.
90Made Qtopia calendar import possible on desktop . 96Made Qtopia calendar import possible on desktop .
91 97
92********** VERSION 2.0.13 ************ 98********** VERSION 2.0.13 ************
93 99
94Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter. 100Fixed a problem in the addressee select dialog and made it more user friendly by adding a minimize splitter.
95 101
96In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down". 102In the search dialog you can switch now the focus from search line edit to the list view by pressing key "arrow down".
97 103
98OM/Pi: 104OM/Pi:
99Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails. 105Fixed a refresh problem of outgoing/sent/sendfailed folders after sending mails.
100Added missing German translation. 106Added missing German translation.
101Added warning if path is specified in local folder settings of account config. 107Added warning if path is specified in local folder settings of account config.
102 108
103********** VERSION 2.0.12 ************ 109********** VERSION 2.0.12 ************
104 110
105KO/Pi: 111KO/Pi:
106Fixed a bug in todo start/due date handling for non recurring todos with a start and due date. 112Fixed a bug in todo start/due date handling for non recurring todos with a start and due date.
107Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes. 113Fixed some layout problems in the KO/Pi agenda view when there were many conflicting itmes.
108Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer. 114Fixed several problems of the keyboard focus in the desktop versions when opening the search dialog/event viewer.
109 115
110Fixed problem in pi-sync mode when wrong password was sent. 116Fixed problem in pi-sync mode when wrong password was sent.
111 117
112OM/Pi: 118OM/Pi:
113Fixed a crash when displaying mails with "Show mail as html" was checked in the config. 119Fixed a crash when displaying mails with "Show mail as html" was checked in the config.
114Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled. 120Added a check before displaying the mail if the mail is in html format, if "Show mail as html" is enabled.
115 121
116********** VERSION 2.0.11 ************ 122********** VERSION 2.0.11 ************
117 123
118Fixed some problems in pi-sync mode 124Fixed some problems in pi-sync mode
119(e.g. details of events were not synced properly) 125(e.g. details of events were not synced properly)
120 126
121********** VERSION 2.0.10 ************ 127********** VERSION 2.0.10 ************
122 128
123KO/Pi: 129KO/Pi:
124In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view. 130In the desktop versions the context menu in the search dialog was broken after introducing the What'sThis info for the list view.
125This is fixed. 131This is fixed.
126Changed the search dialog a bit to make it more user friendly. 132Changed the search dialog a bit to make it more user friendly.
127(E.g.: Removed message box about "no items found" and set key focus to search line edit after search). 133(E.g.: Removed message box about "no items found" and set key focus to search line edit after search).
128 134
129Added config option to hide the week number in KO/Pi toolbar. 135Added config option to hide the week number in KO/Pi toolbar.
130 136
131********** VERSION 2.0.9 ************ 137********** VERSION 2.0.9 ************
132 138
133Made month view icons for multiday events a bit nicer. 139Made month view icons for multiday events a bit nicer.
134Some minor fixes in KO/Pi 140Some minor fixes in KO/Pi
135(e.g. go to today did not work for new week view properly). 141(e.g. go to today did not work for new week view properly).
136 142
137 143
138********** VERSION 2.0.8 ************ 144********** VERSION 2.0.8 ************
139 145
140Fixed a problem in dependency info in the ipk files for the Zaurus. 146Fixed a problem in dependency info in the ipk files for the Zaurus.
141 147
142Added 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. 148Added 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.
143 149
144Added a "go today" button to the datepicker. 150Added a "go today" button to the datepicker.
145 151
146Added "created" and "last modified" to event/todo viewer (and What'sThis viewer) 152Added "created" and "last modified" to event/todo viewer (and What'sThis viewer)
147and made it configureable to show these values. 153and made it configureable to show these values.
148 154
149Fixed a problem for events (from external iCal files) that do have a duration but no end date. 155Fixed a problem for events (from external iCal files) that do have a duration but no end date.
150 156
151 157
152********** VERSION 2.0.7 ************ 158********** VERSION 2.0.7 ************
153 159
154Added global application font settings 160Added global application font settings
155(for all KDE-Pim/Pi apps) to the general settings. 161(for all KDE-Pim/Pi apps) to the general settings.
156 162
157Fixed a problem in OM/Pi when trying to login to some IMAP servers 163Fixed a problem in OM/Pi when trying to login to some IMAP servers
158(like the IMAP server of Apple: mail.mac.com ) 164(like the IMAP server of Apple: mail.mac.com )
159 165
160Added recurring todos to KO/Pi. 166Added recurring todos to KO/Pi.
161 167
162 168
163********** VERSION 2.0.6 ************ 169********** VERSION 2.0.6 ************
164 170
165Stable release 2.0.6! 171Stable release 2.0.6!
166 172
167Some bugfixes in the pi-sync mode. 173Some bugfixes in the pi-sync mode.
168Added German translation for pi-sync mode. 174Added German translation for pi-sync mode.
169 175
170KO/Pi: 176KO/Pi:
171Made the todolist using alternate background. 177Made the todolist using alternate background.
172 178
173Other minor fixes in KO/Pi. 179Other minor fixes in KO/Pi.
174 180
175 181
176You can find the complete changelog 182You can find the complete changelog
177from version 1.7.7 to 2.0.5 183from version 1.7.7 to 2.0.5
178in the source package or on 184in the source package or on
179 185
180http://www.pi-sync.net/html/changelog.html 186http://www.pi-sync.net/html/changelog.html
181 187
182 188
183 189
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 6ed6a1c..92fd59c 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4056 +1,4060 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141 141
142class KOBeamPrefs : public QDialog 142class KOBeamPrefs : public QDialog
143{ 143{
144 public: 144 public:
145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
146 QDialog( parent, name, true ) 146 QDialog( parent, name, true )
147 { 147 {
148 setCaption( i18n("Beam Options") ); 148 setCaption( i18n("Beam Options") );
149 QVBoxLayout* lay = new QVBoxLayout( this ); 149 QVBoxLayout* lay = new QVBoxLayout( this );
150 lay->setSpacing( 3 ); 150 lay->setSpacing( 3 );
151 lay->setMargin( 3 ); 151 lay->setMargin( 3 );
152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
153 lay->addWidget( format ); 153 lay->addWidget( format );
154 format->setExclusive ( true ) ; 154 format->setExclusive ( true ) ;
155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
156 lay->addWidget( time ); time->setExclusive ( true ) ; 156 lay->addWidget( time ); time->setExclusive ( true ) ;
157 vcal = new QRadioButton(" vCalendar ", format ); 157 vcal = new QRadioButton(" vCalendar ", format );
158 ical = new QRadioButton(" iCalendar ", format ); 158 ical = new QRadioButton(" iCalendar ", format );
159 vcal->setChecked( true ); 159 vcal->setChecked( true );
160 tz = new QRadioButton(i18n(" With timezone "), time ); 160 tz = new QRadioButton(i18n(" With timezone "), time );
161 local = new QRadioButton(i18n(" Local time "), time ); 161 local = new QRadioButton(i18n(" Local time "), time );
162 tz->setChecked( true ); 162 tz->setChecked( true );
163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
164 lay->addWidget( ok ); 164 lay->addWidget( ok );
165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
166 lay->addWidget( cancel ); 166 lay->addWidget( cancel );
167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
169 resize( 200, 200 ); 169 resize( 200, 200 );
170 } 170 }
171 171
172 bool beamVcal() { return vcal->isChecked(); } 172 bool beamVcal() { return vcal->isChecked(); }
173 bool beamLocal() { return local->isChecked(); } 173 bool beamLocal() { return local->isChecked(); }
174private: 174private:
175 QRadioButton* vcal, *ical, *local, *tz; 175 QRadioButton* vcal, *ical, *local, *tz;
176}; 176};
177class KOCatPrefs : public QDialog 177class KOCatPrefs : public QDialog
178{ 178{
179 public: 179 public:
180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
181 QDialog( parent, name, true ) 181 QDialog( parent, name, true )
182 { 182 {
183 setCaption( i18n("Manage new Categories") ); 183 setCaption( i18n("Manage new Categories") );
184 QVBoxLayout* lay = new QVBoxLayout( this ); 184 QVBoxLayout* lay = new QVBoxLayout( this );
185 lay->setSpacing( 3 ); 185 lay->setSpacing( 3 );
186 lay->setMargin( 3 ); 186 lay->setMargin( 3 );
187 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 187 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
188 lay->addWidget( lab ); 188 lay->addWidget( lab );
189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
190 lay->addWidget( format ); 190 lay->addWidget( format );
191 format->setExclusive ( true ) ; 191 format->setExclusive ( true ) ;
192 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 192 addCatBut = new QRadioButton(i18n("Add to category list"), format );
193 new QRadioButton(i18n("Remove from Events/Todos"), format ); 193 new QRadioButton(i18n("Remove from Events/Todos"), format );
194 addCatBut->setChecked( true ); 194 addCatBut->setChecked( true );
195 QPushButton * ok = new QPushButton( i18n("OK"), this ); 195 QPushButton * ok = new QPushButton( i18n("OK"), this );
196 lay->addWidget( ok ); 196 lay->addWidget( ok );
197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
198 lay->addWidget( cancel ); 198 lay->addWidget( cancel );
199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
201 resize( 200, 200 ); 201 resize( 200, 200 );
202 } 202 }
203 203
204 bool addCat() { return addCatBut->isChecked(); } 204 bool addCat() { return addCatBut->isChecked(); }
205private: 205private:
206 QRadioButton* addCatBut; 206 QRadioButton* addCatBut;
207}; 207};
208 208
209 209
210 210
211CalendarView::CalendarView( CalendarResources *calendar, 211CalendarView::CalendarView( CalendarResources *calendar,
212 QWidget *parent, const char *name ) 212 QWidget *parent, const char *name )
213 : CalendarViewBase( parent, name ), 213 : CalendarViewBase( parent, name ),
214 mCalendar( calendar ), 214 mCalendar( calendar ),
215 mResourceManager( calendar->resourceManager() ) 215 mResourceManager( calendar->resourceManager() )
216{ 216{
217 217
218 mEventEditor = 0; 218 mEventEditor = 0;
219 mTodoEditor = 0; 219 mTodoEditor = 0;
220 220
221 init(); 221 init();
222} 222}
223 223
224CalendarView::CalendarView( Calendar *calendar, 224CalendarView::CalendarView( Calendar *calendar,
225 QWidget *parent, const char *name ) 225 QWidget *parent, const char *name )
226 : CalendarViewBase( parent, name ), 226 : CalendarViewBase( parent, name ),
227 mCalendar( calendar ), 227 mCalendar( calendar ),
228 mResourceManager( 0 ) 228 mResourceManager( 0 )
229{ 229{
230 230
231 mEventEditor = 0; 231 mEventEditor = 0;
232 mTodoEditor = 0; 232 mTodoEditor = 0;
233 init(); 233 init();
234} 234}
235 235
236void CalendarView::init() 236void CalendarView::init()
237{ 237{
238 238
239 setFocusPolicy ( WheelFocus ); 239 setFocusPolicy ( WheelFocus );
240 mViewerCallerIsSearchDialog = false; 240 mViewerCallerIsSearchDialog = false;
241 mBlockShowDates = false; 241 mBlockShowDates = false;
242 beamDialog = new KOBeamPrefs(); 242 beamDialog = new KOBeamPrefs();
243 mDatePickerMode = 0; 243 mDatePickerMode = 0;
244 mCurrentSyncDevice = ""; 244 mCurrentSyncDevice = "";
245 writeLocale(); 245 writeLocale();
246 mViewManager = new KOViewManager( this ); 246 mViewManager = new KOViewManager( this );
247 mDialogManager = new KODialogManager( this ); 247 mDialogManager = new KODialogManager( this );
248 mEventViewerDialog = 0; 248 mEventViewerDialog = 0;
249 mModified = false; 249 mModified = false;
250 mReadOnly = false; 250 mReadOnly = false;
251 mSelectedIncidence = 0; 251 mSelectedIncidence = 0;
252 mCalPrinter = 0; 252 mCalPrinter = 0;
253 mFilters.setAutoDelete(true); 253 mFilters.setAutoDelete(true);
254 254
255 mCalendar->registerObserver( this ); 255 mCalendar->registerObserver( this );
256 // TODO: Make sure that view is updated, when calendar is changed. 256 // TODO: Make sure that view is updated, when calendar is changed.
257 257
258 mStorage = new FileStorage( mCalendar ); 258 mStorage = new FileStorage( mCalendar );
259 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 259 mNavigator = new DateNavigator( this, "datevav", mViewManager );
260 260
261 QBoxLayout *topLayout = (QBoxLayout*)layout(); 261 QBoxLayout *topLayout = (QBoxLayout*)layout();
262#ifndef KORG_NOSPLITTER 262#ifndef KORG_NOSPLITTER
263 // create the main layout frames. 263 // create the main layout frames.
264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
265 topLayout->addWidget(mPanner); 265 topLayout->addWidget(mPanner);
266 266
267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
268 "CalendarView::LeftFrame"); 268 "CalendarView::LeftFrame");
269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
270 270
271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
272 "CalendarView::DateNavigator" ); 272 "CalendarView::DateNavigator" );
273 273
274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
276 mTodoList->setNavigator( mNavigator ); 276 mTodoList->setNavigator( mNavigator );
277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
278 278
279#ifdef KORG_NORESOURCEVIEW 279#ifdef KORG_NORESOURCEVIEW
280 mResourceView = 0; 280 mResourceView = 0;
281#else 281#else
282 if ( mResourceManager ) { 282 if ( mResourceManager ) {
283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
284 mResourceView->updateView(); 284 mResourceView->updateView();
285 connect( mResourceView, SIGNAL( resourcesChanged() ), 285 connect( mResourceView, SIGNAL( resourcesChanged() ),
286 SLOT( updateView() ) ); 286 SLOT( updateView() ) );
287 } else { 287 } else {
288 mResourceView = 0; 288 mResourceView = 0;
289 } 289 }
290#endif 290#endif
291 QWidget *rightBox = new QWidget( mPanner ); 291 QWidget *rightBox = new QWidget( mPanner );
292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
293 293
294 mRightFrame = new QWidgetStack( rightBox ); 294 mRightFrame = new QWidgetStack( rightBox );
295 rightLayout->addWidget( mRightFrame, 1 ); 295 rightLayout->addWidget( mRightFrame, 1 );
296 296
297 mLeftFrame = mLeftSplitter; 297 mLeftFrame = mLeftSplitter;
298#else 298#else
299 //QWidget *mainBox = new QWidget( this ); 299 //QWidget *mainBox = new QWidget( this );
300 //QWidget *leftFrame = new QWidget( mainBox ); 300 //QWidget *leftFrame = new QWidget( mainBox );
301 //QBoxLayout * mainBoxLayout; 301 //QBoxLayout * mainBoxLayout;
302 if ( KOPrefs::instance()->mVerticalScreen ) { 302 if ( KOPrefs::instance()->mVerticalScreen ) {
303 //mainBoxLayout = new QVBoxLayout(mainBox); 303 //mainBoxLayout = new QVBoxLayout(mainBox);
304 //leftFrameLayout = new QHBoxLayout(leftFrame ); 304 //leftFrameLayout = new QHBoxLayout(leftFrame );
305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
309 } else { 309 } else {
310 //mainBoxLayout = new QHBoxLayout(mainBox); 310 //mainBoxLayout = new QHBoxLayout(mainBox);
311 //leftFrameLayout = new QVBoxLayout(leftFrame ); 311 //leftFrameLayout = new QVBoxLayout(leftFrame );
312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
316 } 316 }
317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
318 //QBoxLayout * leftFrameLayout; 318 //QBoxLayout * leftFrameLayout;
319 topLayout->addWidget( mMainFrame ); 319 topLayout->addWidget( mMainFrame );
320 //mainBoxLayout->addWidget (mLeftFrame); 320 //mainBoxLayout->addWidget (mLeftFrame);
321 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 321 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
322 "CalendarView::DateNavigator" ); 322 "CalendarView::DateNavigator" );
323#if 0 323#if 0
324 // FIXME 324 // FIXME
325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
326 "CalendarView::DateNavigator", QDate::currentDate()); 326 "CalendarView::DateNavigator", QDate::currentDate());
327#endif 327#endif
328 // mDateNavigator->blockSignals( true ); 328 // mDateNavigator->blockSignals( true );
329 //leftFrameLayout->addWidget( mDateNavigator ); 329 //leftFrameLayout->addWidget( mDateNavigator );
330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
332 mTodoList->setNavigator( mNavigator ); 332 mTodoList->setNavigator( mNavigator );
333#if 0 333#if 0
334 if ( QApplication::desktop()->width() < 480 ) { 334 if ( QApplication::desktop()->width() < 480 ) {
335 leftFrameLayout->addWidget(mFilterView); 335 leftFrameLayout->addWidget(mFilterView);
336 leftFrameLayout->addWidget(mTodoList, 2 ); 336 leftFrameLayout->addWidget(mTodoList, 2 );
337 337
338 } else { 338 } else {
339 leftFrameLayout->addWidget(mTodoList,2 ); 339 leftFrameLayout->addWidget(mTodoList,2 );
340 leftFrameLayout->addWidget(mFilterView ); 340 leftFrameLayout->addWidget(mFilterView );
341 } 341 }
342#endif 342#endif
343 mFilterView->hide(); 343 mFilterView->hide();
344 QWidget *rightBox = new QWidget( mMainFrame ); 344 QWidget *rightBox = new QWidget( mMainFrame );
345 //mainBoxLayout->addWidget ( rightBox, 10 ); 345 //mainBoxLayout->addWidget ( rightBox, 10 );
346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
347 mRightFrame = new QWidgetStack( rightBox ); 347 mRightFrame = new QWidgetStack( rightBox );
348 rightLayout->addWidget( mRightFrame, 10 ); 348 rightLayout->addWidget( mRightFrame, 10 );
349 349
350 //mLeftFrame = (QWidget *)leftFrame; 350 //mLeftFrame = (QWidget *)leftFrame;
351 if ( KOPrefs::instance()->mVerticalScreen ) { 351 if ( KOPrefs::instance()->mVerticalScreen ) {
352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
356 } else { 356 } else {
357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
360 } 360 }
361 if ( !KOPrefs::instance()->mShowDateNavigator) 361 if ( !KOPrefs::instance()->mShowDateNavigator)
362 mDateNavigator->hide(); 362 mDateNavigator->hide();
363 //qDebug("Calendarview Size %d %d ", width(), height()); 363 //qDebug("Calendarview Size %d %d ", width(), height());
364#endif 364#endif
365 365
366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
367 SLOT( showDates( const KCal::DateList & ) ) ); 367 SLOT( showDates( const KCal::DateList & ) ) );
368 368
369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
371 371
372 372
373
374 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
375 mViewManager, SLOT( showMonth( const QDate & ) ) );
376
373 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 377 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
374 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 378 mNavigator, SLOT( selectWeek( const QDate & ) ) );
375 379
376 connect( mDateNavigator, SIGNAL( goPrevYear() ), 380 connect( mDateNavigator, SIGNAL( goPrevYear() ),
377 mNavigator, SLOT( selectPreviousYear() ) ); 381 mNavigator, SLOT( selectPreviousYear() ) );
378 connect( mDateNavigator, SIGNAL( goNextYear() ), 382 connect( mDateNavigator, SIGNAL( goNextYear() ),
379 mNavigator, SLOT( selectNextYear() ) ); 383 mNavigator, SLOT( selectNextYear() ) );
380 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 384 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
381 mNavigator, SLOT( selectPreviousMonth() ) ); 385 mNavigator, SLOT( selectPreviousMonth() ) );
382 connect( mDateNavigator, SIGNAL( goNextMonth() ), 386 connect( mDateNavigator, SIGNAL( goNextMonth() ),
383 mNavigator, SLOT( selectNextMonth() ) ); 387 mNavigator, SLOT( selectNextMonth() ) );
384 388
385 connect( mDateNavigator, SIGNAL( goPrevious() ), 389 connect( mDateNavigator, SIGNAL( goPrevious() ),
386 mNavigator, SLOT( selectPrevious() ) ); 390 mNavigator, SLOT( selectPrevious() ) );
387 connect( mDateNavigator, SIGNAL( goNext() ), 391 connect( mDateNavigator, SIGNAL( goNext() ),
388 mNavigator, SLOT( selectNext() ) ); 392 mNavigator, SLOT( selectNext() ) );
389 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 393 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
390 mNavigator, SLOT( slotMonthSelect( int ) ) ); 394 mNavigator, SLOT( slotMonthSelect( int ) ) );
391 395
392 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 396 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
393 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 397 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
394#if 0 398#if 0
395 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 399 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
396 SLOT( incidenceAdded( Incidence *) ) ); 400 SLOT( incidenceAdded( Incidence *) ) );
397#endif 401#endif
398 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 402 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
399 403
400 connect( this, SIGNAL( configChanged() ), 404 connect( this, SIGNAL( configChanged() ),
401 mDateNavigator, SLOT( updateConfig() ) ); 405 mDateNavigator, SLOT( updateConfig() ) );
402 406
403 connect( mTodoList, SIGNAL( newTodoSignal() ), 407 connect( mTodoList, SIGNAL( newTodoSignal() ),
404 SLOT( newTodo() ) ); 408 SLOT( newTodo() ) );
405 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 409 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
406 SLOT( newSubTodo( Todo * ) ) ); 410 SLOT( newSubTodo( Todo * ) ) );
407 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 411 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
408 SLOT( editTodo( Todo * ) ) ); 412 SLOT( editTodo( Todo * ) ) );
409 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
410 SLOT( showTodo( Todo *) ) ); 414 SLOT( showTodo( Todo *) ) );
411 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 415 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
412 SLOT( deleteTodo( Todo *) ) ); 416 SLOT( deleteTodo( Todo *) ) );
413 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 417 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
414 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 418 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
415 SLOT( purgeCompleted() ) ); 419 SLOT( purgeCompleted() ) );
416 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 420 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
417 SIGNAL( todoModified( Todo *, int ) ) ); 421 SIGNAL( todoModified( Todo *, int ) ) );
418 422
419 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 423 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
420 this, SLOT ( cloneIncidence( Incidence * ) ) ); 424 this, SLOT ( cloneIncidence( Incidence * ) ) );
421 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 425 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
422 this, SLOT (cancelIncidence( Incidence * ) ) ); 426 this, SLOT (cancelIncidence( Incidence * ) ) );
423 427
424 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 428 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
425 this, SLOT ( moveIncidence( Incidence * ) ) ); 429 this, SLOT ( moveIncidence( Incidence * ) ) );
426 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 430 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
427 this, SLOT ( beamIncidence( Incidence * ) ) ); 431 this, SLOT ( beamIncidence( Incidence * ) ) );
428 432
429 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 433 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
430 this, SLOT ( todo_unsub( Todo * ) ) ); 434 this, SLOT ( todo_unsub( Todo * ) ) );
431 435
432 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 436 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
433 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 437 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
434 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 438 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
435 SLOT( updateTodo( Todo *, int ) ) ); 439 SLOT( updateTodo( Todo *, int ) ) );
436 connect( this, SIGNAL( todoModified( Todo *, int )), this, 440 connect( this, SIGNAL( todoModified( Todo *, int )), this,
437 SLOT( changeTodoDisplay( Todo *, int ) ) ); 441 SLOT( changeTodoDisplay( Todo *, int ) ) );
438 442
439 443
440 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 444 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
441 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 445 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
442 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 446 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
443 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 447 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
444 448
445 449
446 450
447 451
448 452
449 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 453 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
450 SLOT(checkClipboard())); 454 SLOT(checkClipboard()));
451 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 455 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
452 SLOT( processTodoListSelection( Incidence * ) ) ); 456 SLOT( processTodoListSelection( Incidence * ) ) );
453 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 457 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
454 458
455 // kdDebug() << "CalendarView::CalendarView() done" << endl; 459 // kdDebug() << "CalendarView::CalendarView() done" << endl;
456 460
457 mDateFrame = new QVBox(0,0,WType_Popup); 461 mDateFrame = new QVBox(0,0,WType_Popup);
458 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 462 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
459 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 463 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
460 mDateFrame->setLineWidth(3); 464 mDateFrame->setLineWidth(3);
461 mDateFrame->hide(); 465 mDateFrame->hide();
462 mDateFrame->setCaption( i18n( "Pick a date to display")); 466 mDateFrame->setCaption( i18n( "Pick a date to display"));
463 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 467 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
464 468
465 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 469 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
466 470
467 mEventEditor = mDialogManager->getEventEditor(); 471 mEventEditor = mDialogManager->getEventEditor();
468 mTodoEditor = mDialogManager->getTodoEditor(); 472 mTodoEditor = mDialogManager->getTodoEditor();
469 473
470 mFlagEditDescription = false; 474 mFlagEditDescription = false;
471 475
472 mSuspendTimer = new QTimer( this ); 476 mSuspendTimer = new QTimer( this );
473 mAlarmTimer = new QTimer( this ); 477 mAlarmTimer = new QTimer( this );
474 mRecheckAlarmTimer = new QTimer( this ); 478 mRecheckAlarmTimer = new QTimer( this );
475 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 479 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
476 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 480 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
477 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 481 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
478 mAlarmDialog = new AlarmDialog( this ); 482 mAlarmDialog = new AlarmDialog( this );
479 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 483 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
480 mAlarmDialog->setServerNotification( false ); 484 mAlarmDialog->setServerNotification( false );
481 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 485 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
482 486
483 487
484#ifndef DESKTOP_VERSION 488#ifndef DESKTOP_VERSION
485//US listen for arriving address resultsets 489//US listen for arriving address resultsets
486 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 490 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
487 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 491 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
488#endif 492#endif
489 mDateNavigator->setCalendar( mCalendar ); 493 mDateNavigator->setCalendar( mCalendar );
490} 494}
491 495
492 496
493CalendarView::~CalendarView() 497CalendarView::~CalendarView()
494{ 498{
495 // kdDebug() << "~CalendarView()" << endl; 499 // kdDebug() << "~CalendarView()" << endl;
496 //qDebug("CalendarView::~CalendarView() "); 500 //qDebug("CalendarView::~CalendarView() ");
497 delete mDialogManager; 501 delete mDialogManager;
498 delete mViewManager; 502 delete mViewManager;
499 delete mStorage; 503 delete mStorage;
500 delete mDateFrame ; 504 delete mDateFrame ;
501 delete beamDialog; 505 delete beamDialog;
502 delete mEventViewerDialog; 506 delete mEventViewerDialog;
503 //kdDebug() << "~CalendarView() done" << endl; 507 //kdDebug() << "~CalendarView() done" << endl;
504} 508}
505 509
506void CalendarView::showDay( QDate d ) 510void CalendarView::showDay( QDate d )
507{ 511{
508 dateNavigator()->blockSignals( true ); 512 dateNavigator()->blockSignals( true );
509 dateNavigator()->selectDate( d ); 513 dateNavigator()->selectDate( d );
510 dateNavigator()->blockSignals( false ); 514 dateNavigator()->blockSignals( false );
511 mViewManager->showDayView(); 515 mViewManager->showDayView();
512 //dateNavigator()->selectDate( d ); 516 //dateNavigator()->selectDate( d );
513} 517}
514void CalendarView::timerAlarm() 518void CalendarView::timerAlarm()
515{ 519{
516 //qDebug("CalendarView::timerAlarm() "); 520 //qDebug("CalendarView::timerAlarm() ");
517 computeAlarm(mAlarmNotification ); 521 computeAlarm(mAlarmNotification );
518} 522}
519 523
520void CalendarView::suspendAlarm() 524void CalendarView::suspendAlarm()
521{ 525{
522 //qDebug(" CalendarView::suspendAlarm() "); 526 //qDebug(" CalendarView::suspendAlarm() ");
523 computeAlarm(mSuspendAlarmNotification ); 527 computeAlarm(mSuspendAlarmNotification );
524 528
525} 529}
526 530
527void CalendarView::startAlarm( QString mess , QString filename) 531void CalendarView::startAlarm( QString mess , QString filename)
528{ 532{
529 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 533 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
530 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 534 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
531 535
532} 536}
533 537
534void CalendarView::checkNextTimerAlarm() 538void CalendarView::checkNextTimerAlarm()
535{ 539{
536 mCalendar->checkAlarmForIncidence( 0, true ); 540 mCalendar->checkAlarmForIncidence( 0, true );
537} 541}
538 542
539void CalendarView::computeAlarm( QString msg ) 543void CalendarView::computeAlarm( QString msg )
540{ 544{
541 545
542 QString mess = msg; 546 QString mess = msg;
543 QString mAlarmMessage = mess.mid( 9 ); 547 QString mAlarmMessage = mess.mid( 9 );
544 QString filename = MainWindow::resourcePath(); 548 QString filename = MainWindow::resourcePath();
545 filename += "koalarm.wav"; 549 filename += "koalarm.wav";
546 QString tempfilename; 550 QString tempfilename;
547 if ( mess.left( 13 ) == "suspend_alarm") { 551 if ( mess.left( 13 ) == "suspend_alarm") {
548 bool error = false; 552 bool error = false;
549 int len = mess.mid( 13 ).find("+++"); 553 int len = mess.mid( 13 ).find("+++");
550 if ( len < 2 ) 554 if ( len < 2 )
551 error = true; 555 error = true;
552 else { 556 else {
553 tempfilename = mess.mid( 13, len ); 557 tempfilename = mess.mid( 13, len );
554 if ( !QFile::exists( tempfilename ) ) 558 if ( !QFile::exists( tempfilename ) )
555 error = true; 559 error = true;
556 } 560 }
557 if ( ! error ) { 561 if ( ! error ) {
558 filename = tempfilename; 562 filename = tempfilename;
559 } 563 }
560 mAlarmMessage = mess.mid( 13+len+3 ); 564 mAlarmMessage = mess.mid( 13+len+3 );
561 //qDebug("suspend file %s ",tempfilename.latin1() ); 565 //qDebug("suspend file %s ",tempfilename.latin1() );
562 startAlarm( mAlarmMessage, filename); 566 startAlarm( mAlarmMessage, filename);
563 return; 567 return;
564 } 568 }
565 if ( mess.left( 11 ) == "timer_alarm") { 569 if ( mess.left( 11 ) == "timer_alarm") {
566 //mTimerTime = 0; 570 //mTimerTime = 0;
567 startAlarm( mess.mid( 11 ), filename ); 571 startAlarm( mess.mid( 11 ), filename );
568 return; 572 return;
569 } 573 }
570 if ( mess.left( 10 ) == "proc_alarm") { 574 if ( mess.left( 10 ) == "proc_alarm") {
571 bool error = false; 575 bool error = false;
572 int len = mess.mid( 10 ).find("+++"); 576 int len = mess.mid( 10 ).find("+++");
573 if ( len < 2 ) 577 if ( len < 2 )
574 error = true; 578 error = true;
575 else { 579 else {
576 tempfilename = mess.mid( 10, len ); 580 tempfilename = mess.mid( 10, len );
577 if ( !QFile::exists( tempfilename ) ) 581 if ( !QFile::exists( tempfilename ) )
578 error = true; 582 error = true;
579 } 583 }
580 if ( error ) { 584 if ( error ) {
581 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 585 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
582 mAlarmMessage += mess.mid( 10+len+3+9 ); 586 mAlarmMessage += mess.mid( 10+len+3+9 );
583 } else { 587 } else {
584 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 588 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
585 //qDebug("-----system command %s ",tempfilename.latin1() ); 589 //qDebug("-----system command %s ",tempfilename.latin1() );
586#ifndef _WIN32_ 590#ifndef _WIN32_
587 if ( vfork () == 0 ) { 591 if ( vfork () == 0 ) {
588 execl ( tempfilename.latin1(), 0 ); 592 execl ( tempfilename.latin1(), 0 );
589 return; 593 return;
590 } 594 }
591#else 595#else
592 QProcess* p = new QProcess(); 596 QProcess* p = new QProcess();
593 p->addArgument( tempfilename.latin1() ); 597 p->addArgument( tempfilename.latin1() );
594 p->start(); 598 p->start();
595 return; 599 return;
596#endif 600#endif
597 601
598 return; 602 return;
599 } 603 }
600 604
601 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 605 //qDebug("+++++++system command %s ",tempfilename.latin1() );
602 } 606 }
603 if ( mess.left( 11 ) == "audio_alarm") { 607 if ( mess.left( 11 ) == "audio_alarm") {
604 bool error = false; 608 bool error = false;
605 int len = mess.mid( 11 ).find("+++"); 609 int len = mess.mid( 11 ).find("+++");
606 if ( len < 2 ) 610 if ( len < 2 )
607 error = true; 611 error = true;
608 else { 612 else {
609 tempfilename = mess.mid( 11, len ); 613 tempfilename = mess.mid( 11, len );
610 if ( !QFile::exists( tempfilename ) ) 614 if ( !QFile::exists( tempfilename ) )
611 error = true; 615 error = true;
612 } 616 }
613 if ( ! error ) { 617 if ( ! error ) {
614 filename = tempfilename; 618 filename = tempfilename;
615 } 619 }
616 mAlarmMessage = mess.mid( 11+len+3+9 ); 620 mAlarmMessage = mess.mid( 11+len+3+9 );
617 //qDebug("audio file command %s ",tempfilename.latin1() ); 621 //qDebug("audio file command %s ",tempfilename.latin1() );
618 } 622 }
619 if ( mess.left( 9 ) == "cal_alarm") { 623 if ( mess.left( 9 ) == "cal_alarm") {
620 mAlarmMessage = mess.mid( 9 ) ; 624 mAlarmMessage = mess.mid( 9 ) ;
621 } 625 }
622 626
623 startAlarm( mAlarmMessage, filename ); 627 startAlarm( mAlarmMessage, filename );
624 628
625 629
626} 630}
627 631
628void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 632void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
629{ 633{
630 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 634 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
631 635
632 mSuspendAlarmNotification = noti; 636 mSuspendAlarmNotification = noti;
633 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 637 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
634 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 638 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
635 mSuspendTimer->start( ms , true ); 639 mSuspendTimer->start( ms , true );
636 640
637} 641}
638 642
639void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 643void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
640{ 644{
641 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 645 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
642 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 646 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
643#ifndef DESKTOP_VERSION 647#ifndef DESKTOP_VERSION
644 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 648 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
645#endif 649#endif
646 return; 650 return;
647 } 651 }
648 int maxSec; 652 int maxSec;
649 //maxSec = 5; //testing only 653 //maxSec = 5; //testing only
650 maxSec = 86400+3600; // one day+1hour 654 maxSec = 86400+3600; // one day+1hour
651 mAlarmNotification = noti; 655 mAlarmNotification = noti;
652 int sec = QDateTime::currentDateTime().secsTo( qdt ); 656 int sec = QDateTime::currentDateTime().secsTo( qdt );
653 if ( sec > maxSec ) { 657 if ( sec > maxSec ) {
654 mRecheckAlarmTimer->start( maxSec * 1000 ); 658 mRecheckAlarmTimer->start( maxSec * 1000 );
655 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 659 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
656 return; 660 return;
657 } else { 661 } else {
658 mRecheckAlarmTimer->stop(); 662 mRecheckAlarmTimer->stop();
659 } 663 }
660 //qDebug("Alarm timer started with secs: %d ", sec); 664 //qDebug("Alarm timer started with secs: %d ", sec);
661 mAlarmTimer->start( sec *1000 , true ); 665 mAlarmTimer->start( sec *1000 , true );
662 666
663} 667}
664// called by mRecheckAlarmTimer to get next alarm 668// called by mRecheckAlarmTimer to get next alarm
665// we need this, because a QTimer has only a max range of 25 days 669// we need this, because a QTimer has only a max range of 25 days
666void CalendarView::recheckTimerAlarm() 670void CalendarView::recheckTimerAlarm()
667{ 671{
668 mAlarmTimer->stop(); 672 mAlarmTimer->stop();
669 mRecheckAlarmTimer->stop(); 673 mRecheckAlarmTimer->stop();
670 mCalendar->checkAlarmForIncidence( 0, true ); 674 mCalendar->checkAlarmForIncidence( 0, true );
671} 675}
672void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 676void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
673{ 677{
674 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 678 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
675 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 679 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
676#ifndef DESKTOP_VERSION 680#ifndef DESKTOP_VERSION
677 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 681 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
678#endif 682#endif
679 return; 683 return;
680 } 684 }
681 mAlarmTimer->stop(); 685 mAlarmTimer->stop();
682} 686}
683void CalendarView::selectWeekNum ( int num ) 687void CalendarView::selectWeekNum ( int num )
684{ 688{
685 dateNavigator()->blockSignals( true ); 689 dateNavigator()->blockSignals( true );
686 dateNavigator()->selectWeek( num ); 690 dateNavigator()->selectWeek( num );
687 dateNavigator()->blockSignals( false ); 691 dateNavigator()->blockSignals( false );
688 mViewManager->showWeekView(); 692 mViewManager->showWeekView();
689} 693}
690KOViewManager *CalendarView::viewManager() 694KOViewManager *CalendarView::viewManager()
691{ 695{
692 return mViewManager; 696 return mViewManager;
693} 697}
694 698
695KODialogManager *CalendarView::dialogManager() 699KODialogManager *CalendarView::dialogManager()
696{ 700{
697 return mDialogManager; 701 return mDialogManager;
698} 702}
699 703
700QDate CalendarView::startDate() 704QDate CalendarView::startDate()
701{ 705{
702 DateList dates = mNavigator->selectedDates(); 706 DateList dates = mNavigator->selectedDates();
703 707
704 return dates.first(); 708 return dates.first();
705} 709}
706 710
707QDate CalendarView::endDate() 711QDate CalendarView::endDate()
708{ 712{
709 DateList dates = mNavigator->selectedDates(); 713 DateList dates = mNavigator->selectedDates();
710 714
711 return dates.last(); 715 return dates.last();
712} 716}
713 717
714 718
715void CalendarView::createPrinter() 719void CalendarView::createPrinter()
716{ 720{
717#ifndef KORG_NOPRINTER 721#ifndef KORG_NOPRINTER
718 if (!mCalPrinter) { 722 if (!mCalPrinter) {
719 mCalPrinter = new CalPrinter(this, mCalendar); 723 mCalPrinter = new CalPrinter(this, mCalendar);
720 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 724 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
721 } 725 }
722#endif 726#endif
723} 727}
724 728
725 729
726//KOPrefs::instance()->mWriteBackFile 730//KOPrefs::instance()->mWriteBackFile
727//KOPrefs::instance()->mWriteBackExistingOnly 731//KOPrefs::instance()->mWriteBackExistingOnly
728 732
729// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 733// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
730// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 734// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
731// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 735// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
732// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 736// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
733// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 737// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
734// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 738// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
735 739
736int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 740int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
737{ 741{
738 742
739 // 0 equal 743 // 0 equal
740 // 1 take local 744 // 1 take local
741 // 2 take remote 745 // 2 take remote
742 // 3 cancel 746 // 3 cancel
743 QDateTime lastSync = mLastCalendarSync; 747 QDateTime lastSync = mLastCalendarSync;
744 QDateTime localMod = local->lastModified(); 748 QDateTime localMod = local->lastModified();
745 QDateTime remoteMod = remote->lastModified(); 749 QDateTime remoteMod = remote->lastModified();
746 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 750 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
747 bool remCh, locCh; 751 bool remCh, locCh;
748 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 752 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
749 //if ( remCh ) 753 //if ( remCh )
750 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 754 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
751 locCh = ( localMod > mLastCalendarSync ); 755 locCh = ( localMod > mLastCalendarSync );
752 if ( !remCh && ! locCh ) { 756 if ( !remCh && ! locCh ) {
753 //qDebug("both not changed "); 757 //qDebug("both not changed ");
754 lastSync = localMod.addDays(1); 758 lastSync = localMod.addDays(1);
755 if ( mode <= SYNC_PREF_ASK ) 759 if ( mode <= SYNC_PREF_ASK )
756 return 0; 760 return 0;
757 } else { 761 } else {
758 if ( locCh ) { 762 if ( locCh ) {
759 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 763 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
760 lastSync = localMod.addDays( -1 ); 764 lastSync = localMod.addDays( -1 );
761 if ( !remCh ) 765 if ( !remCh )
762 remoteMod = ( lastSync.addDays( -1 ) ); 766 remoteMod = ( lastSync.addDays( -1 ) );
763 } else { 767 } else {
764 //qDebug(" not loc changed "); 768 //qDebug(" not loc changed ");
765 lastSync = localMod.addDays( 1 ); 769 lastSync = localMod.addDays( 1 );
766 if ( remCh ) 770 if ( remCh )
767 remoteMod =( lastSync.addDays( 1 ) ); 771 remoteMod =( lastSync.addDays( 1 ) );
768 772
769 } 773 }
770 } 774 }
771 full = true; 775 full = true;
772 if ( mode < SYNC_PREF_ASK ) 776 if ( mode < SYNC_PREF_ASK )
773 mode = SYNC_PREF_ASK; 777 mode = SYNC_PREF_ASK;
774 } else { 778 } else {
775 if ( localMod == remoteMod ) 779 if ( localMod == remoteMod )
776 // if ( local->revision() == remote->revision() ) 780 // if ( local->revision() == remote->revision() )
777 return 0; 781 return 0;
778 782
779 } 783 }
780 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 784 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
781 785
782 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 786 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
783 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 787 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
784 //full = true; //debug only 788 //full = true; //debug only
785 if ( full ) { 789 if ( full ) {
786 bool equ = false; 790 bool equ = false;
787 if ( local->type() == "Event" ) { 791 if ( local->type() == "Event" ) {
788 equ = (*((Event*) local) == *((Event*) remote)); 792 equ = (*((Event*) local) == *((Event*) remote));
789 } 793 }
790 else if ( local->type() =="Todo" ) 794 else if ( local->type() =="Todo" )
791 equ = (*((Todo*) local) == (*(Todo*) remote)); 795 equ = (*((Todo*) local) == (*(Todo*) remote));
792 else if ( local->type() =="Journal" ) 796 else if ( local->type() =="Journal" )
793 equ = (*((Journal*) local) == *((Journal*) remote)); 797 equ = (*((Journal*) local) == *((Journal*) remote));
794 if ( equ ) { 798 if ( equ ) {
795 //qDebug("equal "); 799 //qDebug("equal ");
796 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 800 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
797 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 801 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
798 } 802 }
799 if ( mode < SYNC_PREF_FORCE_LOCAL ) 803 if ( mode < SYNC_PREF_FORCE_LOCAL )
800 return 0; 804 return 0;
801 805
802 }//else //debug only 806 }//else //debug only
803 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 807 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
804 } 808 }
805 int result; 809 int result;
806 bool localIsNew; 810 bool localIsNew;
807 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 811 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
808 812
809 if ( full && mode < SYNC_PREF_NEWEST ) 813 if ( full && mode < SYNC_PREF_NEWEST )
810 mode = SYNC_PREF_ASK; 814 mode = SYNC_PREF_ASK;
811 815
812 switch( mode ) { 816 switch( mode ) {
813 case SYNC_PREF_LOCAL: 817 case SYNC_PREF_LOCAL:
814 if ( lastSync > remoteMod ) 818 if ( lastSync > remoteMod )
815 return 1; 819 return 1;
816 if ( lastSync > localMod ) 820 if ( lastSync > localMod )
817 return 2; 821 return 2;
818 return 1; 822 return 1;
819 break; 823 break;
820 case SYNC_PREF_REMOTE: 824 case SYNC_PREF_REMOTE:
821 if ( lastSync > remoteMod ) 825 if ( lastSync > remoteMod )
822 return 1; 826 return 1;
823 if ( lastSync > localMod ) 827 if ( lastSync > localMod )
824 return 2; 828 return 2;
825 return 2; 829 return 2;
826 break; 830 break;
827 case SYNC_PREF_NEWEST: 831 case SYNC_PREF_NEWEST:
828 if ( localMod > remoteMod ) 832 if ( localMod > remoteMod )
829 return 1; 833 return 1;
830 else 834 else
831 return 2; 835 return 2;
832 break; 836 break;
833 case SYNC_PREF_ASK: 837 case SYNC_PREF_ASK:
834 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 838 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
835 if ( lastSync > remoteMod ) 839 if ( lastSync > remoteMod )
836 return 1; 840 return 1;
837 if ( lastSync > localMod ) 841 if ( lastSync > localMod )
838 return 2; 842 return 2;
839 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 843 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
840 localIsNew = localMod >= remoteMod; 844 localIsNew = localMod >= remoteMod;
841 if ( localIsNew ) 845 if ( localIsNew )
842 getEventViewerDialog()->setColorMode( 1 ); 846 getEventViewerDialog()->setColorMode( 1 );
843 else 847 else
844 getEventViewerDialog()->setColorMode( 2 ); 848 getEventViewerDialog()->setColorMode( 2 );
845 getEventViewerDialog()->setIncidence(local); 849 getEventViewerDialog()->setIncidence(local);
846 if ( localIsNew ) 850 if ( localIsNew )
847 getEventViewerDialog()->setColorMode( 2 ); 851 getEventViewerDialog()->setColorMode( 2 );
848 else 852 else
849 getEventViewerDialog()->setColorMode( 1 ); 853 getEventViewerDialog()->setColorMode( 1 );
850 getEventViewerDialog()->addIncidence(remote); 854 getEventViewerDialog()->addIncidence(remote);
851 getEventViewerDialog()->setColorMode( 0 ); 855 getEventViewerDialog()->setColorMode( 0 );
852 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 856 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
853 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 857 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
854 getEventViewerDialog()->showMe(); 858 getEventViewerDialog()->showMe();
855 result = getEventViewerDialog()->executeS( localIsNew ); 859 result = getEventViewerDialog()->executeS( localIsNew );
856 return result; 860 return result;
857 861
858 break; 862 break;
859 case SYNC_PREF_FORCE_LOCAL: 863 case SYNC_PREF_FORCE_LOCAL:
860 return 1; 864 return 1;
861 break; 865 break;
862 case SYNC_PREF_FORCE_REMOTE: 866 case SYNC_PREF_FORCE_REMOTE:
863 return 2; 867 return 2;
864 break; 868 break;
865 869
866 default: 870 default:
867 // SYNC_PREF_TAKE_BOTH not implemented 871 // SYNC_PREF_TAKE_BOTH not implemented
868 break; 872 break;
869 } 873 }
870 return 0; 874 return 0;
871} 875}
872Event* CalendarView::getLastSyncEvent() 876Event* CalendarView::getLastSyncEvent()
873{ 877{
874 Event* lse; 878 Event* lse;
875 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 879 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
876 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 880 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
877 if (!lse) { 881 if (!lse) {
878 lse = new Event(); 882 lse = new Event();
879 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 883 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
880 QString sum = ""; 884 QString sum = "";
881 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 885 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
882 sum = "E: "; 886 sum = "E: ";
883 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 887 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
884 lse->setDtStart( mLastCalendarSync ); 888 lse->setDtStart( mLastCalendarSync );
885 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 889 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
886 lse->setCategories( i18n("SyncEvent") ); 890 lse->setCategories( i18n("SyncEvent") );
887 lse->setReadOnly( true ); 891 lse->setReadOnly( true );
888 mCalendar->addEvent( lse ); 892 mCalendar->addEvent( lse );
889 } 893 }
890 894
891 return lse; 895 return lse;
892 896
893} 897}
894 898
895// we check, if the to delete event has a id for a profile 899// we check, if the to delete event has a id for a profile
896// if yes, we set this id in the profile to delete 900// if yes, we set this id in the profile to delete
897void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 901void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
898{ 902{
899 if ( lastSync.count() == 0 ) { 903 if ( lastSync.count() == 0 ) {
900 //qDebug(" lastSync.count() == 0"); 904 //qDebug(" lastSync.count() == 0");
901 return; 905 return;
902 } 906 }
903 if ( toDelete->type() == "Journal" ) 907 if ( toDelete->type() == "Journal" )
904 return; 908 return;
905 909
906 Event* eve = lastSync.first(); 910 Event* eve = lastSync.first();
907 911
908 while ( eve ) { 912 while ( eve ) {
909 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 913 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
910 if ( !id.isEmpty() ) { 914 if ( !id.isEmpty() ) {
911 QString des = eve->description(); 915 QString des = eve->description();
912 QString pref = "e"; 916 QString pref = "e";
913 if ( toDelete->type() == "Todo" ) 917 if ( toDelete->type() == "Todo" )
914 pref = "t"; 918 pref = "t";
915 des += pref+ id + ","; 919 des += pref+ id + ",";
916 eve->setReadOnly( false ); 920 eve->setReadOnly( false );
917 eve->setDescription( des ); 921 eve->setDescription( des );
918 //qDebug("setdes %s ", des.latin1()); 922 //qDebug("setdes %s ", des.latin1());
919 eve->setReadOnly( true ); 923 eve->setReadOnly( true );
920 } 924 }
921 eve = lastSync.next(); 925 eve = lastSync.next();
922 } 926 }
923 927
924} 928}
925void CalendarView::checkExternalId( Incidence * inc ) 929void CalendarView::checkExternalId( Incidence * inc )
926{ 930{
927 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 931 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
928 checkExternSyncEvent( lastSync, inc ); 932 checkExternSyncEvent( lastSync, inc );
929 933
930} 934}
931bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 935bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
932{ 936{
933 bool syncOK = true; 937 bool syncOK = true;
934 int addedEvent = 0; 938 int addedEvent = 0;
935 int addedEventR = 0; 939 int addedEventR = 0;
936 int deletedEventR = 0; 940 int deletedEventR = 0;
937 int deletedEventL = 0; 941 int deletedEventL = 0;
938 int changedLocal = 0; 942 int changedLocal = 0;
939 int changedRemote = 0; 943 int changedRemote = 0;
940 int filteredIN = 0; 944 int filteredIN = 0;
941 int filteredOUT = 0; 945 int filteredOUT = 0;
942 //QPtrList<Event> el = local->rawEvents(); 946 //QPtrList<Event> el = local->rawEvents();
943 Event* eventR; 947 Event* eventR;
944 QString uid; 948 QString uid;
945 int take; 949 int take;
946 Event* eventL; 950 Event* eventL;
947 Event* eventRSync; 951 Event* eventRSync;
948 Event* eventLSync; 952 Event* eventLSync;
949 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 953 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
950 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 954 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
951 bool fullDateRange = false; 955 bool fullDateRange = false;
952 local->resetTempSyncStat(); 956 local->resetTempSyncStat();
953 mLastCalendarSync = QDateTime::currentDateTime(); 957 mLastCalendarSync = QDateTime::currentDateTime();
954 if ( mSyncManager->syncWithDesktop() ) { 958 if ( mSyncManager->syncWithDesktop() ) {
955 remote->resetPilotStat(1); 959 remote->resetPilotStat(1);
956 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 960 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
957 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 961 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
958 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 962 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
959 } else { 963 } else {
960 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 964 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
961 } 965 }
962 } 966 }
963 QDateTime modifiedCalendar = mLastCalendarSync; 967 QDateTime modifiedCalendar = mLastCalendarSync;
964 eventLSync = getLastSyncEvent(); 968 eventLSync = getLastSyncEvent();
965 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 969 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
966 if ( eventR ) { 970 if ( eventR ) {
967 eventRSync = (Event*) eventR->clone(); 971 eventRSync = (Event*) eventR->clone();
968 remote->deleteEvent(eventR ); 972 remote->deleteEvent(eventR );
969 973
970 } else { 974 } else {
971 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 975 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
972 eventRSync = (Event*)eventLSync->clone(); 976 eventRSync = (Event*)eventLSync->clone();
973 } else { 977 } else {
974 fullDateRange = true; 978 fullDateRange = true;
975 eventRSync = new Event(); 979 eventRSync = new Event();
976 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 980 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
977 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 981 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
978 eventRSync->setDtStart( mLastCalendarSync ); 982 eventRSync->setDtStart( mLastCalendarSync );
979 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 983 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
980 eventRSync->setCategories( i18n("SyncEvent") ); 984 eventRSync->setCategories( i18n("SyncEvent") );
981 } 985 }
982 } 986 }
983 if ( eventLSync->dtStart() == mLastCalendarSync ) 987 if ( eventLSync->dtStart() == mLastCalendarSync )
984 fullDateRange = true; 988 fullDateRange = true;
985 989
986 if ( ! fullDateRange ) { 990 if ( ! fullDateRange ) {
987 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 991 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
988 992
989 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 993 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
990 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 994 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
991 fullDateRange = true; 995 fullDateRange = true;
992 } 996 }
993 } 997 }
994 if ( mSyncManager->syncWithDesktop() ) { 998 if ( mSyncManager->syncWithDesktop() ) {
995 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 999 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
996 } 1000 }
997 if ( fullDateRange ) 1001 if ( fullDateRange )
998 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1002 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
999 else 1003 else
1000 mLastCalendarSync = eventLSync->dtStart(); 1004 mLastCalendarSync = eventLSync->dtStart();
1001 // for resyncing if own file has changed 1005 // for resyncing if own file has changed
1002 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1006 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1003 mLastCalendarSync = loadedFileVersion; 1007 mLastCalendarSync = loadedFileVersion;
1004 //qDebug("setting mLastCalendarSync "); 1008 //qDebug("setting mLastCalendarSync ");
1005 } 1009 }
1006 //qDebug("*************************** "); 1010 //qDebug("*************************** ");
1007 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1011 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1008 QPtrList<Incidence> er = remote->rawIncidences(); 1012 QPtrList<Incidence> er = remote->rawIncidences();
1009 Incidence* inR = er.first(); 1013 Incidence* inR = er.first();
1010 Incidence* inL; 1014 Incidence* inL;
1011 QProgressBar bar( er.count(),0 ); 1015 QProgressBar bar( er.count(),0 );
1012 bar.setCaption (i18n("Syncing - close to abort!") ); 1016 bar.setCaption (i18n("Syncing - close to abort!") );
1013 1017
1014 // ************** setting up filter ************* 1018 // ************** setting up filter *************
1015 CalFilter *filterIN = 0; 1019 CalFilter *filterIN = 0;
1016 CalFilter *filterOUT = 0; 1020 CalFilter *filterOUT = 0;
1017 CalFilter *filter = mFilters.first(); 1021 CalFilter *filter = mFilters.first();
1018 while(filter) { 1022 while(filter) {
1019 if ( filter->name() == mSyncManager->mFilterInCal ) 1023 if ( filter->name() == mSyncManager->mFilterInCal )
1020 filterIN = filter; 1024 filterIN = filter;
1021 if ( filter->name() == mSyncManager->mFilterOutCal ) 1025 if ( filter->name() == mSyncManager->mFilterOutCal )
1022 filterOUT = filter; 1026 filterOUT = filter;
1023 filter = mFilters.next(); 1027 filter = mFilters.next();
1024 } 1028 }
1025 int w = 300; 1029 int w = 300;
1026 if ( QApplication::desktop()->width() < 320 ) 1030 if ( QApplication::desktop()->width() < 320 )
1027 w = 220; 1031 w = 220;
1028 int h = bar.sizeHint().height() ; 1032 int h = bar.sizeHint().height() ;
1029 int dw = QApplication::desktop()->width(); 1033 int dw = QApplication::desktop()->width();
1030 int dh = QApplication::desktop()->height(); 1034 int dh = QApplication::desktop()->height();
1031 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1035 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1032 bar.show(); 1036 bar.show();
1033 int modulo = (er.count()/10)+1; 1037 int modulo = (er.count()/10)+1;
1034 int incCounter = 0; 1038 int incCounter = 0;
1035 while ( inR ) { 1039 while ( inR ) {
1036 if ( ! bar.isVisible() ) 1040 if ( ! bar.isVisible() )
1037 return false; 1041 return false;
1038 if ( incCounter % modulo == 0 ) 1042 if ( incCounter % modulo == 0 )
1039 bar.setProgress( incCounter ); 1043 bar.setProgress( incCounter );
1040 ++incCounter; 1044 ++incCounter;
1041 uid = inR->uid(); 1045 uid = inR->uid();
1042 bool skipIncidence = false; 1046 bool skipIncidence = false;
1043 if ( uid.left(15) == QString("last-syncEvent-") ) 1047 if ( uid.left(15) == QString("last-syncEvent-") )
1044 skipIncidence = true; 1048 skipIncidence = true;
1045 QString idS; 1049 QString idS;
1046 qApp->processEvents(); 1050 qApp->processEvents();
1047 if ( !skipIncidence ) { 1051 if ( !skipIncidence ) {
1048 inL = local->incidence( uid ); 1052 inL = local->incidence( uid );
1049 if ( inL ) { // maybe conflict - same uid in both calendars 1053 if ( inL ) { // maybe conflict - same uid in both calendars
1050 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1054 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1051 //qDebug("take %d %s ", take, inL->summary().latin1()); 1055 //qDebug("take %d %s ", take, inL->summary().latin1());
1052 if ( take == 3 ) 1056 if ( take == 3 )
1053 return false; 1057 return false;
1054 if ( take == 1 ) {// take local ********************** 1058 if ( take == 1 ) {// take local **********************
1055 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1059 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1056 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1060 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1057 else 1061 else
1058 idS = inR->IDStr(); 1062 idS = inR->IDStr();
1059 remote->deleteIncidence( inR ); 1063 remote->deleteIncidence( inR );
1060 inR = inL->clone(); 1064 inR = inL->clone();
1061 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1065 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1062 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1066 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1063 inR->setIDStr( idS ); 1067 inR->setIDStr( idS );
1064 remote->addIncidence( inR ); 1068 remote->addIncidence( inR );
1065 if ( mSyncManager->syncWithDesktop() ) 1069 if ( mSyncManager->syncWithDesktop() )
1066 inR->setPilotId( 2 ); 1070 inR->setPilotId( 2 );
1067 ++changedRemote; 1071 ++changedRemote;
1068 } else {// take remote ********************** 1072 } else {// take remote **********************
1069 idS = inL->IDStr(); 1073 idS = inL->IDStr();
1070 int pid = inL->pilotId(); 1074 int pid = inL->pilotId();
1071 local->deleteIncidence( inL ); 1075 local->deleteIncidence( inL );
1072 inL = inR->clone(); 1076 inL = inR->clone();
1073 if ( mSyncManager->syncWithDesktop() ) 1077 if ( mSyncManager->syncWithDesktop() )
1074 inL->setPilotId( pid ); 1078 inL->setPilotId( pid );
1075 inL->setIDStr( idS ); 1079 inL->setIDStr( idS );
1076 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1080 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1077 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1081 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1078 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1082 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1079 } 1083 }
1080 local->addIncidence( inL ); 1084 local->addIncidence( inL );
1081 ++changedLocal; 1085 ++changedLocal;
1082 } 1086 }
1083 } 1087 }
1084 } else { // no conflict ********** add or delete remote 1088 } else { // no conflict ********** add or delete remote
1085 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1089 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1086 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1087 QString des = eventLSync->description(); 1091 QString des = eventLSync->description();
1088 QString pref = "e"; 1092 QString pref = "e";
1089 if ( inR->type() == "Todo" ) 1093 if ( inR->type() == "Todo" )
1090 pref = "t"; 1094 pref = "t";
1091 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1095 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1092 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1096 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1093 //remote->deleteIncidence( inR ); 1097 //remote->deleteIncidence( inR );
1094 ++deletedEventR; 1098 ++deletedEventR;
1095 } else { 1099 } else {
1096 inR->setLastModified( modifiedCalendar ); 1100 inR->setLastModified( modifiedCalendar );
1097 inL = inR->clone(); 1101 inL = inR->clone();
1098 inL->setIDStr( ":" ); 1102 inL->setIDStr( ":" );
1099 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1103 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1100 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1104 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1101 local->addIncidence( inL ); 1105 local->addIncidence( inL );
1102 ++addedEvent; 1106 ++addedEvent;
1103 1107
1104 } 1108 }
1105 } else { 1109 } else {
1106 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1110 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1107 inR->setLastModified( modifiedCalendar ); 1111 inR->setLastModified( modifiedCalendar );
1108 inL = inR->clone(); 1112 inL = inR->clone();
1109 inL->setIDStr( ":" ); 1113 inL->setIDStr( ":" );
1110 local->addIncidence( inL ); 1114 local->addIncidence( inL );
1111 ++addedEvent; 1115 ++addedEvent;
1112 1116
1113 } else { 1117 } else {
1114 checkExternSyncEvent(eventRSyncSharp, inR); 1118 checkExternSyncEvent(eventRSyncSharp, inR);
1115 remote->deleteIncidence( inR ); 1119 remote->deleteIncidence( inR );
1116 ++deletedEventR; 1120 ++deletedEventR;
1117 } 1121 }
1118 } 1122 }
1119 } else { 1123 } else {
1120 ++filteredIN; 1124 ++filteredIN;
1121 } 1125 }
1122 } 1126 }
1123 } 1127 }
1124 inR = er.next(); 1128 inR = er.next();
1125 } 1129 }
1126 QPtrList<Incidence> el = local->rawIncidences(); 1130 QPtrList<Incidence> el = local->rawIncidences();
1127 inL = el.first(); 1131 inL = el.first();
1128 modulo = (el.count()/10)+1; 1132 modulo = (el.count()/10)+1;
1129 bar.setCaption (i18n("Add / remove events") ); 1133 bar.setCaption (i18n("Add / remove events") );
1130 bar.setTotalSteps ( el.count() ) ; 1134 bar.setTotalSteps ( el.count() ) ;
1131 bar.show(); 1135 bar.show();
1132 incCounter = 0; 1136 incCounter = 0;
1133 1137
1134 while ( inL ) { 1138 while ( inL ) {
1135 1139
1136 qApp->processEvents(); 1140 qApp->processEvents();
1137 if ( ! bar.isVisible() ) 1141 if ( ! bar.isVisible() )
1138 return false; 1142 return false;
1139 if ( incCounter % modulo == 0 ) 1143 if ( incCounter % modulo == 0 )
1140 bar.setProgress( incCounter ); 1144 bar.setProgress( incCounter );
1141 ++incCounter; 1145 ++incCounter;
1142 uid = inL->uid(); 1146 uid = inL->uid();
1143 bool skipIncidence = false; 1147 bool skipIncidence = false;
1144 if ( uid.left(15) == QString("last-syncEvent-") ) 1148 if ( uid.left(15) == QString("last-syncEvent-") )
1145 skipIncidence = true; 1149 skipIncidence = true;
1146 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1150 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1147 skipIncidence = true; 1151 skipIncidence = true;
1148 if ( !skipIncidence ) { 1152 if ( !skipIncidence ) {
1149 inR = remote->incidence( uid ); 1153 inR = remote->incidence( uid );
1150 if ( ! inR ) { 1154 if ( ! inR ) {
1151 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1155 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1152 // no conflict ********** add or delete local 1156 // no conflict ********** add or delete local
1153 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1157 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1154 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1158 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1155 checkExternSyncEvent(eventLSyncSharp, inL); 1159 checkExternSyncEvent(eventLSyncSharp, inL);
1156 local->deleteIncidence( inL ); 1160 local->deleteIncidence( inL );
1157 ++deletedEventL; 1161 ++deletedEventL;
1158 } else { 1162 } else {
1159 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1163 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1160 inL->removeID(mCurrentSyncDevice ); 1164 inL->removeID(mCurrentSyncDevice );
1161 ++addedEventR; 1165 ++addedEventR;
1162 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1166 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1163 inL->setLastModified( modifiedCalendar ); 1167 inL->setLastModified( modifiedCalendar );
1164 inR = inL->clone(); 1168 inR = inL->clone();
1165 inR->setIDStr( ":" ); 1169 inR->setIDStr( ":" );
1166 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1170 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1167 remote->addIncidence( inR ); 1171 remote->addIncidence( inR );
1168 } 1172 }
1169 } 1173 }
1170 } else { 1174 } else {
1171 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1175 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1172 checkExternSyncEvent(eventLSyncSharp, inL); 1176 checkExternSyncEvent(eventLSyncSharp, inL);
1173 local->deleteIncidence( inL ); 1177 local->deleteIncidence( inL );
1174 ++deletedEventL; 1178 ++deletedEventL;
1175 } else { 1179 } else {
1176 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1180 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1177 ++addedEventR; 1181 ++addedEventR;
1178 inL->setLastModified( modifiedCalendar ); 1182 inL->setLastModified( modifiedCalendar );
1179 inR = inL->clone(); 1183 inR = inL->clone();
1180 inR->setIDStr( ":" ); 1184 inR->setIDStr( ":" );
1181 remote->addIncidence( inR ); 1185 remote->addIncidence( inR );
1182 } 1186 }
1183 } 1187 }
1184 } 1188 }
1185 } else { 1189 } else {
1186 ++filteredOUT; 1190 ++filteredOUT;
1187 } 1191 }
1188 } 1192 }
1189 } 1193 }
1190 inL = el.next(); 1194 inL = el.next();
1191 } 1195 }
1192 int delFut = 0; 1196 int delFut = 0;
1193 int remRem = 0; 1197 int remRem = 0;
1194 if ( mSyncManager->mWriteBackInFuture ) { 1198 if ( mSyncManager->mWriteBackInFuture ) {
1195 er = remote->rawIncidences(); 1199 er = remote->rawIncidences();
1196 remRem = er.count(); 1200 remRem = er.count();
1197 inR = er.first(); 1201 inR = er.first();
1198 QDateTime dt; 1202 QDateTime dt;
1199 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1203 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1200 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1204 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1201 while ( inR ) { 1205 while ( inR ) {
1202 if ( inR->type() == "Todo" ) { 1206 if ( inR->type() == "Todo" ) {
1203 Todo * t = (Todo*)inR; 1207 Todo * t = (Todo*)inR;
1204 if ( t->hasDueDate() ) 1208 if ( t->hasDueDate() )
1205 dt = t->dtDue(); 1209 dt = t->dtDue();
1206 else 1210 else
1207 dt = cur.addSecs( 62 ); 1211 dt = cur.addSecs( 62 );
1208 } 1212 }
1209 else if (inR->type() == "Event" ) { 1213 else if (inR->type() == "Event" ) {
1210 bool ok; 1214 bool ok;
1211 dt = inR->getNextOccurence( cur, &ok ); 1215 dt = inR->getNextOccurence( cur, &ok );
1212 if ( !ok ) 1216 if ( !ok )
1213 dt = cur.addSecs( -62 ); 1217 dt = cur.addSecs( -62 );
1214 } 1218 }
1215 else 1219 else
1216 dt = inR->dtStart(); 1220 dt = inR->dtStart();
1217 if ( dt < cur || dt > end ) { 1221 if ( dt < cur || dt > end ) {
1218 remote->deleteIncidence( inR ); 1222 remote->deleteIncidence( inR );
1219 ++delFut; 1223 ++delFut;
1220 } 1224 }
1221 inR = er.next(); 1225 inR = er.next();
1222 } 1226 }
1223 } 1227 }
1224 bar.hide(); 1228 bar.hide();
1225 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1229 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1226 eventLSync->setReadOnly( false ); 1230 eventLSync->setReadOnly( false );
1227 eventLSync->setDtStart( mLastCalendarSync ); 1231 eventLSync->setDtStart( mLastCalendarSync );
1228 eventRSync->setDtStart( mLastCalendarSync ); 1232 eventRSync->setDtStart( mLastCalendarSync );
1229 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1233 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1230 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1234 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1231 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1235 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1232 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1236 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1233 eventLSync->setReadOnly( true ); 1237 eventLSync->setReadOnly( true );
1234 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1238 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1235 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1239 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1236 remote->addEvent( eventRSync ); 1240 remote->addEvent( eventRSync );
1237 else 1241 else
1238 delete eventRSync; 1242 delete eventRSync;
1239 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1243 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1240 QString mes; 1244 QString mes;
1241 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1245 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1242 QString delmess; 1246 QString delmess;
1243 if ( delFut ) { 1247 if ( delFut ) {
1244 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1248 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1245 mes += delmess; 1249 mes += delmess;
1246 } 1250 }
1247 mes = i18n("Local calendar changed!\n") +mes; 1251 mes = i18n("Local calendar changed!\n") +mes;
1248 mCalendar->checkAlarmForIncidence( 0, true ); 1252 mCalendar->checkAlarmForIncidence( 0, true );
1249 qDebug( mes ); 1253 qDebug( mes );
1250 if ( mSyncManager->mShowSyncSummary ) { 1254 if ( mSyncManager->mShowSyncSummary ) {
1251 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1255 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1252 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1256 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1253 qDebug("KO: WB cancelled "); 1257 qDebug("KO: WB cancelled ");
1254 mSyncManager->mWriteBackFile = false; 1258 mSyncManager->mWriteBackFile = false;
1255 return syncOK; 1259 return syncOK;
1256 } 1260 }
1257 } 1261 }
1258 return syncOK; 1262 return syncOK;
1259} 1263}
1260 1264
1261void CalendarView::setSyncDevice( QString s ) 1265void CalendarView::setSyncDevice( QString s )
1262{ 1266{
1263 mCurrentSyncDevice= s; 1267 mCurrentSyncDevice= s;
1264} 1268}
1265void CalendarView::setSyncName( QString s ) 1269void CalendarView::setSyncName( QString s )
1266{ 1270{
1267 mCurrentSyncName= s; 1271 mCurrentSyncName= s;
1268} 1272}
1269bool CalendarView::syncCalendar(QString filename, int mode) 1273bool CalendarView::syncCalendar(QString filename, int mode)
1270{ 1274{
1271 //qDebug("syncCalendar %s ", filename.latin1()); 1275 //qDebug("syncCalendar %s ", filename.latin1());
1272 mGlobalSyncMode = SYNC_MODE_NORMAL; 1276 mGlobalSyncMode = SYNC_MODE_NORMAL;
1273 CalendarLocal* calendar = new CalendarLocal(); 1277 CalendarLocal* calendar = new CalendarLocal();
1274 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1278 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1275 FileStorage* storage = new FileStorage( calendar ); 1279 FileStorage* storage = new FileStorage( calendar );
1276 bool syncOK = false; 1280 bool syncOK = false;
1277 storage->setFileName( filename ); 1281 storage->setFileName( filename );
1278 // qDebug("loading ... "); 1282 // qDebug("loading ... ");
1279 if ( storage->load() ) { 1283 if ( storage->load() ) {
1280 getEventViewerDialog()->setSyncMode( true ); 1284 getEventViewerDialog()->setSyncMode( true );
1281 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1285 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1282 getEventViewerDialog()->setSyncMode( false ); 1286 getEventViewerDialog()->setSyncMode( false );
1283 if ( syncOK ) { 1287 if ( syncOK ) {
1284 if ( mSyncManager->mWriteBackFile ) 1288 if ( mSyncManager->mWriteBackFile )
1285 { 1289 {
1286 storage->setSaveFormat( new ICalFormat() ); 1290 storage->setSaveFormat( new ICalFormat() );
1287 storage->save(); 1291 storage->save();
1288 } 1292 }
1289 } 1293 }
1290 setModified( true ); 1294 setModified( true );
1291 } 1295 }
1292 delete storage; 1296 delete storage;
1293 delete calendar; 1297 delete calendar;
1294 if ( syncOK ) 1298 if ( syncOK )
1295 updateView(); 1299 updateView();
1296 return syncOK; 1300 return syncOK;
1297} 1301}
1298 1302
1299void CalendarView::syncExternal( int mode ) 1303void CalendarView::syncExternal( int mode )
1300{ 1304{
1301 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1305 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1302 1306
1303 qApp->processEvents(); 1307 qApp->processEvents();
1304 CalendarLocal* calendar = new CalendarLocal(); 1308 CalendarLocal* calendar = new CalendarLocal();
1305 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1309 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1306 bool syncOK = false; 1310 bool syncOK = false;
1307 bool loadSuccess = false; 1311 bool loadSuccess = false;
1308 PhoneFormat* phoneFormat = 0; 1312 PhoneFormat* phoneFormat = 0;
1309 emit tempDisableBR(true); 1313 emit tempDisableBR(true);
1310#ifndef DESKTOP_VERSION 1314#ifndef DESKTOP_VERSION
1311 SharpFormat* sharpFormat = 0; 1315 SharpFormat* sharpFormat = 0;
1312 if ( mode == 0 ) { // sharp 1316 if ( mode == 0 ) { // sharp
1313 sharpFormat = new SharpFormat () ; 1317 sharpFormat = new SharpFormat () ;
1314 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1318 loadSuccess = sharpFormat->load( calendar, mCalendar );
1315 1319
1316 } else 1320 } else
1317#endif 1321#endif
1318 if ( mode == 1 ) { // phone 1322 if ( mode == 1 ) { // phone
1319 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1323 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1320 mSyncManager->mPhoneDevice, 1324 mSyncManager->mPhoneDevice,
1321 mSyncManager->mPhoneConnection, 1325 mSyncManager->mPhoneConnection,
1322 mSyncManager->mPhoneModel); 1326 mSyncManager->mPhoneModel);
1323 loadSuccess = phoneFormat->load( calendar,mCalendar); 1327 loadSuccess = phoneFormat->load( calendar,mCalendar);
1324 1328
1325 } else { 1329 } else {
1326 emit tempDisableBR(false); 1330 emit tempDisableBR(false);
1327 return; 1331 return;
1328 } 1332 }
1329 if ( loadSuccess ) { 1333 if ( loadSuccess ) {
1330 getEventViewerDialog()->setSyncMode( true ); 1334 getEventViewerDialog()->setSyncMode( true );
1331 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1335 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1332 getEventViewerDialog()->setSyncMode( false ); 1336 getEventViewerDialog()->setSyncMode( false );
1333 qApp->processEvents(); 1337 qApp->processEvents();
1334 if ( syncOK ) { 1338 if ( syncOK ) {
1335 if ( mSyncManager->mWriteBackFile ) 1339 if ( mSyncManager->mWriteBackFile )
1336 { 1340 {
1337 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1341 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1338 Incidence* inc = iL.first(); 1342 Incidence* inc = iL.first();
1339 if ( phoneFormat ) { 1343 if ( phoneFormat ) {
1340 while ( inc ) { 1344 while ( inc ) {
1341 inc->removeID(mCurrentSyncDevice); 1345 inc->removeID(mCurrentSyncDevice);
1342 inc = iL.next(); 1346 inc = iL.next();
1343 } 1347 }
1344 } 1348 }
1345#ifndef DESKTOP_VERSION 1349#ifndef DESKTOP_VERSION
1346 if ( sharpFormat ) 1350 if ( sharpFormat )
1347 sharpFormat->save(calendar); 1351 sharpFormat->save(calendar);
1348#endif 1352#endif
1349 if ( phoneFormat ) 1353 if ( phoneFormat )
1350 phoneFormat->save(calendar); 1354 phoneFormat->save(calendar);
1351 iL = calendar->rawIncidences(); 1355 iL = calendar->rawIncidences();
1352 inc = iL.first(); 1356 inc = iL.first();
1353 Incidence* loc; 1357 Incidence* loc;
1354 while ( inc ) { 1358 while ( inc ) {
1355 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1359 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1356 loc = mCalendar->incidence(inc->uid() ); 1360 loc = mCalendar->incidence(inc->uid() );
1357 if ( loc ) { 1361 if ( loc ) {
1358 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1362 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1359 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1363 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1360 } 1364 }
1361 } 1365 }
1362 inc = iL.next(); 1366 inc = iL.next();
1363 } 1367 }
1364 Incidence* lse = getLastSyncEvent(); 1368 Incidence* lse = getLastSyncEvent();
1365 if ( lse ) { 1369 if ( lse ) {
1366 lse->setReadOnly( false ); 1370 lse->setReadOnly( false );
1367 lse->setDescription( "" ); 1371 lse->setDescription( "" );
1368 lse->setReadOnly( true ); 1372 lse->setReadOnly( true );
1369 } 1373 }
1370 } 1374 }
1371 } else { 1375 } else {
1372 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1376 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1373 } 1377 }
1374 setModified( true ); 1378 setModified( true );
1375 } else { 1379 } else {
1376 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1380 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1377 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1381 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1378 question, i18n("Ok")) ; 1382 question, i18n("Ok")) ;
1379 1383
1380 } 1384 }
1381 delete calendar; 1385 delete calendar;
1382 updateView(); 1386 updateView();
1383 emit tempDisableBR(false); 1387 emit tempDisableBR(false);
1384 return ;//syncOK; 1388 return ;//syncOK;
1385 1389
1386} 1390}
1387 1391
1388bool CalendarView::importBday() 1392bool CalendarView::importBday()
1389{ 1393{
1390#ifndef KORG_NOKABC 1394#ifndef KORG_NOKABC
1391 1395
1392#ifdef DESKTOP_VERSION 1396#ifdef DESKTOP_VERSION
1393 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1397 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1394 KABC::AddressBook::Iterator it; 1398 KABC::AddressBook::Iterator it;
1395 int count = 0; 1399 int count = 0;
1396 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1400 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1397 ++count; 1401 ++count;
1398 } 1402 }
1399 QProgressBar bar(count,0 ); 1403 QProgressBar bar(count,0 );
1400 int w = 300; 1404 int w = 300;
1401 if ( QApplication::desktop()->width() < 320 ) 1405 if ( QApplication::desktop()->width() < 320 )
1402 w = 220; 1406 w = 220;
1403 int h = bar.sizeHint().height() ; 1407 int h = bar.sizeHint().height() ;
1404 int dw = QApplication::desktop()->width(); 1408 int dw = QApplication::desktop()->width();
1405 int dh = QApplication::desktop()->height(); 1409 int dh = QApplication::desktop()->height();
1406 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1410 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1407 bar.show(); 1411 bar.show();
1408 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1412 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1409 qApp->processEvents(); 1413 qApp->processEvents();
1410 count = 0; 1414 count = 0;
1411 int addCount = 0; 1415 int addCount = 0;
1412 KCal::Attendee* a = 0; 1416 KCal::Attendee* a = 0;
1413 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1417 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1414 if ( ! bar.isVisible() ) 1418 if ( ! bar.isVisible() )
1415 return false; 1419 return false;
1416 bar.setProgress( count++ ); 1420 bar.setProgress( count++ );
1417 qApp->processEvents(); 1421 qApp->processEvents();
1418 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1422 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1419 if ( (*it).birthday().date().isValid() ){ 1423 if ( (*it).birthday().date().isValid() ){
1420 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1424 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1421 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1425 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1422 ++addCount; 1426 ++addCount;
1423 } 1427 }
1424 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1428 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1425 if ( anni.isValid() ){ 1429 if ( anni.isValid() ){
1426 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1430 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1427 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1431 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1428 ++addCount; 1432 ++addCount;
1429 } 1433 }
1430 } 1434 }
1431 updateView(); 1435 updateView();
1432 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1436 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1433#else //DESKTOP_VERSION 1437#else //DESKTOP_VERSION
1434 1438
1435 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1439 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1436 // the result should now arrive through method insertBirthdays 1440 // the result should now arrive through method insertBirthdays
1437 1441
1438#endif //DESKTOP_VERSION 1442#endif //DESKTOP_VERSION
1439 1443
1440#endif //KORG_NOKABC 1444#endif //KORG_NOKABC
1441 1445
1442 1446
1443 return true; 1447 return true;
1444} 1448}
1445 1449
1446// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1450// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1447void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1451void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1448 const QStringList& anniversaryList, const QStringList& realNameList, 1452 const QStringList& anniversaryList, const QStringList& realNameList,
1449 const QStringList& emailList, const QStringList& assembledNameList, 1453 const QStringList& emailList, const QStringList& assembledNameList,
1450 const QStringList& uidList) 1454 const QStringList& uidList)
1451{ 1455{
1452 //qDebug("KO::CalendarView::insertBirthdays"); 1456 //qDebug("KO::CalendarView::insertBirthdays");
1453 if (uid == this->name()) 1457 if (uid == this->name())
1454 { 1458 {
1455 int count = birthdayList.count(); 1459 int count = birthdayList.count();
1456 int addCount = 0; 1460 int addCount = 0;
1457 KCal::Attendee* a = 0; 1461 KCal::Attendee* a = 0;
1458 1462
1459 //qDebug("CalView 1 %i", count); 1463 //qDebug("CalView 1 %i", count);
1460 1464
1461 QProgressBar bar(count,0 ); 1465 QProgressBar bar(count,0 );
1462 int w = 300; 1466 int w = 300;
1463 if ( QApplication::desktop()->width() < 320 ) 1467 if ( QApplication::desktop()->width() < 320 )
1464 w = 220; 1468 w = 220;
1465 int h = bar.sizeHint().height() ; 1469 int h = bar.sizeHint().height() ;
1466 int dw = QApplication::desktop()->width(); 1470 int dw = QApplication::desktop()->width();
1467 int dh = QApplication::desktop()->height(); 1471 int dh = QApplication::desktop()->height();
1468 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1472 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1469 bar.show(); 1473 bar.show();
1470 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1474 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1471 qApp->processEvents(); 1475 qApp->processEvents();
1472 1476
1473 QDate birthday; 1477 QDate birthday;
1474 QDate anniversary; 1478 QDate anniversary;
1475 QString realName; 1479 QString realName;
1476 QString email; 1480 QString email;
1477 QString assembledName; 1481 QString assembledName;
1478 QString uid; 1482 QString uid;
1479 bool ok = true; 1483 bool ok = true;
1480 for ( int i = 0; i < count; i++) 1484 for ( int i = 0; i < count; i++)
1481 { 1485 {
1482 if ( ! bar.isVisible() ) 1486 if ( ! bar.isVisible() )
1483 return; 1487 return;
1484 bar.setProgress( i ); 1488 bar.setProgress( i );
1485 qApp->processEvents(); 1489 qApp->processEvents();
1486 1490
1487 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1491 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1488 if (!ok) { 1492 if (!ok) {
1489 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1493 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1490 } 1494 }
1491 1495
1492 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1496 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1493 if (!ok) { 1497 if (!ok) {
1494 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1498 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1495 } 1499 }
1496 realName = realNameList[i]; 1500 realName = realNameList[i];
1497 email = emailList[i]; 1501 email = emailList[i];
1498 assembledName = assembledNameList[i]; 1502 assembledName = assembledNameList[i];
1499 uid = uidList[i]; 1503 uid = uidList[i];
1500 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1504 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1501 1505
1502 if ( birthday.isValid() ){ 1506 if ( birthday.isValid() ){
1503 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1507 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1504 KCal::Attendee::ReqParticipant,uid) ; 1508 KCal::Attendee::ReqParticipant,uid) ;
1505 if ( addAnniversary( birthday, assembledName, a, true ) ) 1509 if ( addAnniversary( birthday, assembledName, a, true ) )
1506 ++addCount; 1510 ++addCount;
1507 } 1511 }
1508 1512
1509 if ( anniversary.isValid() ){ 1513 if ( anniversary.isValid() ){
1510 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1514 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1511 KCal::Attendee::ReqParticipant,uid) ; 1515 KCal::Attendee::ReqParticipant,uid) ;
1512 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1516 if ( addAnniversary( anniversary, assembledName, a, false ) )
1513 ++addCount; 1517 ++addCount;
1514 } 1518 }
1515 } 1519 }
1516 1520
1517 updateView(); 1521 updateView();
1518 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1522 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1519 1523
1520 } 1524 }
1521 1525
1522} 1526}
1523 1527
1524 1528
1525 1529
1526bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1530bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1527{ 1531{
1528 //qDebug("addAnni "); 1532 //qDebug("addAnni ");
1529 Event * ev = new Event(); 1533 Event * ev = new Event();
1530 ev->setOrganizer(KOPrefs::instance()->email()); 1534 ev->setOrganizer(KOPrefs::instance()->email());
1531 if ( a ) { 1535 if ( a ) {
1532 ev->addAttendee( a ); 1536 ev->addAttendee( a );
1533 } 1537 }
1534 QString kind; 1538 QString kind;
1535 if ( birthday ) { 1539 if ( birthday ) {
1536 kind = i18n( "Birthday" ); 1540 kind = i18n( "Birthday" );
1537 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1541 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1538 } 1542 }
1539 else { 1543 else {
1540 kind = i18n( "Anniversary" ); 1544 kind = i18n( "Anniversary" );
1541 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1545 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1542 } 1546 }
1543 ev->setCategories( kind ); 1547 ev->setCategories( kind );
1544 ev->setDtStart( QDateTime(date) ); 1548 ev->setDtStart( QDateTime(date) );
1545 ev->setDtEnd( QDateTime(date) ); 1549 ev->setDtEnd( QDateTime(date) );
1546 ev->setFloats( true ); 1550 ev->setFloats( true );
1547 Recurrence * rec = ev->recurrence(); 1551 Recurrence * rec = ev->recurrence();
1548 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1552 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1549 rec->addYearlyNum( date.month() ); 1553 rec->addYearlyNum( date.month() );
1550 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1554 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1551 delete ev; 1555 delete ev;
1552 return false; 1556 return false;
1553 } 1557 }
1554 return true; 1558 return true;
1555 1559
1556} 1560}
1557bool CalendarView::importQtopia( const QString &categories, 1561bool CalendarView::importQtopia( const QString &categories,
1558 const QString &datebook, 1562 const QString &datebook,
1559 const QString &todolist ) 1563 const QString &todolist )
1560{ 1564{
1561 1565
1562 QtopiaFormat qtopiaFormat; 1566 QtopiaFormat qtopiaFormat;
1563 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1567 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1564 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1568 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1565 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1569 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1566 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1570 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1567 1571
1568 updateView(); 1572 updateView();
1569 return true; 1573 return true;
1570 1574
1571#if 0 1575#if 0
1572 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1576 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1573 mCurrentSyncDevice = "qtopia-XML"; 1577 mCurrentSyncDevice = "qtopia-XML";
1574 if ( mSyncManager->mAskForPreferences ) 1578 if ( mSyncManager->mAskForPreferences )
1575 edit_sync_options(); 1579 edit_sync_options();
1576 qApp->processEvents(); 1580 qApp->processEvents();
1577 CalendarLocal* calendar = new CalendarLocal(); 1581 CalendarLocal* calendar = new CalendarLocal();
1578 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1582 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1579 bool syncOK = false; 1583 bool syncOK = false;
1580 QtopiaFormat qtopiaFormat; 1584 QtopiaFormat qtopiaFormat;
1581 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1585 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1582 bool loadOk = true; 1586 bool loadOk = true;
1583 if ( !categories.isEmpty() ) 1587 if ( !categories.isEmpty() )
1584 loadOk = qtopiaFormat.load( calendar, categories ); 1588 loadOk = qtopiaFormat.load( calendar, categories );
1585 if ( loadOk && !datebook.isEmpty() ) 1589 if ( loadOk && !datebook.isEmpty() )
1586 loadOk = qtopiaFormat.load( calendar, datebook ); 1590 loadOk = qtopiaFormat.load( calendar, datebook );
1587 if ( loadOk && !todolist.isEmpty() ) 1591 if ( loadOk && !todolist.isEmpty() )
1588 loadOk = qtopiaFormat.load( calendar, todolist ); 1592 loadOk = qtopiaFormat.load( calendar, todolist );
1589 1593
1590 if ( loadOk ) { 1594 if ( loadOk ) {
1591 getEventViewerDialog()->setSyncMode( true ); 1595 getEventViewerDialog()->setSyncMode( true );
1592 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1596 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1593 getEventViewerDialog()->setSyncMode( false ); 1597 getEventViewerDialog()->setSyncMode( false );
1594 qApp->processEvents(); 1598 qApp->processEvents();
1595 if ( syncOK ) { 1599 if ( syncOK ) {
1596 if ( mSyncManager->mWriteBackFile ) 1600 if ( mSyncManager->mWriteBackFile )
1597 { 1601 {
1598 // write back XML file 1602 // write back XML file
1599 1603
1600 } 1604 }
1601 setModified( true ); 1605 setModified( true );
1602 } 1606 }
1603 } else { 1607 } else {
1604 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1608 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1605 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1609 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1606 question, i18n("Ok")) ; 1610 question, i18n("Ok")) ;
1607 } 1611 }
1608 delete calendar; 1612 delete calendar;
1609 updateView(); 1613 updateView();
1610 return syncOK; 1614 return syncOK;
1611 1615
1612 1616
1613#endif 1617#endif
1614 1618
1615} 1619}
1616 1620
1617void CalendarView::setSyncEventsReadOnly() 1621void CalendarView::setSyncEventsReadOnly()
1618{ 1622{
1619 Event * ev; 1623 Event * ev;
1620 QPtrList<Event> eL = mCalendar->rawEvents(); 1624 QPtrList<Event> eL = mCalendar->rawEvents();
1621 ev = eL.first(); 1625 ev = eL.first();
1622 while ( ev ) { 1626 while ( ev ) {
1623 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1627 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1624 ev->setReadOnly( true ); 1628 ev->setReadOnly( true );
1625 ev = eL.next(); 1629 ev = eL.next();
1626 } 1630 }
1627} 1631}
1628bool CalendarView::openCalendar(QString filename, bool merge) 1632bool CalendarView::openCalendar(QString filename, bool merge)
1629{ 1633{
1630 1634
1631 if (filename.isEmpty()) { 1635 if (filename.isEmpty()) {
1632 return false; 1636 return false;
1633 } 1637 }
1634 1638
1635 if (!QFile::exists(filename)) { 1639 if (!QFile::exists(filename)) {
1636 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1640 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1637 return false; 1641 return false;
1638 } 1642 }
1639 1643
1640 globalFlagBlockAgenda = 1; 1644 globalFlagBlockAgenda = 1;
1641 if (!merge) mCalendar->close(); 1645 if (!merge) mCalendar->close();
1642 1646
1643 mStorage->setFileName( filename ); 1647 mStorage->setFileName( filename );
1644 1648
1645 if ( mStorage->load() ) { 1649 if ( mStorage->load() ) {
1646 if ( merge ) ;//setModified( true ); 1650 if ( merge ) ;//setModified( true );
1647 else { 1651 else {
1648 //setModified( true ); 1652 //setModified( true );
1649 mViewManager->setDocumentId( filename ); 1653 mViewManager->setDocumentId( filename );
1650 mDialogManager->setDocumentId( filename ); 1654 mDialogManager->setDocumentId( filename );
1651 mTodoList->setDocumentId( filename ); 1655 mTodoList->setDocumentId( filename );
1652 } 1656 }
1653 globalFlagBlockAgenda = 2; 1657 globalFlagBlockAgenda = 2;
1654 // if ( getLastSyncEvent() ) 1658 // if ( getLastSyncEvent() )
1655 // getLastSyncEvent()->setReadOnly( true ); 1659 // getLastSyncEvent()->setReadOnly( true );
1656 mCalendar->reInitAlarmSettings(); 1660 mCalendar->reInitAlarmSettings();
1657 setSyncEventsReadOnly(); 1661 setSyncEventsReadOnly();
1658 updateUnmanagedViews(); 1662 updateUnmanagedViews();
1659 updateView(); 1663 updateView();
1660 if ( filename != MainWindow::defaultFileName() ) { 1664 if ( filename != MainWindow::defaultFileName() ) {
1661 saveCalendar( MainWindow::defaultFileName() ); 1665 saveCalendar( MainWindow::defaultFileName() );
1662 } else { 1666 } else {
1663 QFileInfo finf ( MainWindow::defaultFileName()); 1667 QFileInfo finf ( MainWindow::defaultFileName());
1664 if ( finf.exists() ) { 1668 if ( finf.exists() ) {
1665 setLoadedFileVersion( finf.lastModified () ); 1669 setLoadedFileVersion( finf.lastModified () );
1666 } 1670 }
1667 } 1671 }
1668 return true; 1672 return true;
1669 } else { 1673 } else {
1670 // while failing to load, the calendar object could 1674 // while failing to load, the calendar object could
1671 // have become partially populated. Clear it out. 1675 // have become partially populated. Clear it out.
1672 if ( !merge ) { 1676 if ( !merge ) {
1673 mCalendar->close(); 1677 mCalendar->close();
1674 mViewManager->setDocumentId( filename ); 1678 mViewManager->setDocumentId( filename );
1675 mDialogManager->setDocumentId( filename ); 1679 mDialogManager->setDocumentId( filename );
1676 mTodoList->setDocumentId( filename ); 1680 mTodoList->setDocumentId( filename );
1677 } 1681 }
1678 1682
1679 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1683 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1680 1684
1681 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1685 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1682 globalFlagBlockAgenda = 2; 1686 globalFlagBlockAgenda = 2;
1683 mCalendar->reInitAlarmSettings(); 1687 mCalendar->reInitAlarmSettings();
1684 setSyncEventsReadOnly(); 1688 setSyncEventsReadOnly();
1685 updateUnmanagedViews(); 1689 updateUnmanagedViews();
1686 updateView(); 1690 updateView();
1687 } 1691 }
1688 return false; 1692 return false;
1689} 1693}
1690void CalendarView::showOpenError() 1694void CalendarView::showOpenError()
1691{ 1695{
1692 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1696 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1693} 1697}
1694void CalendarView::setLoadedFileVersion(QDateTime dt) 1698void CalendarView::setLoadedFileVersion(QDateTime dt)
1695{ 1699{
1696 loadedFileVersion = dt; 1700 loadedFileVersion = dt;
1697} 1701}
1698bool CalendarView::checkFileChanged(QString fn) 1702bool CalendarView::checkFileChanged(QString fn)
1699{ 1703{
1700 QFileInfo finf ( fn ); 1704 QFileInfo finf ( fn );
1701 if ( !finf.exists() ) 1705 if ( !finf.exists() )
1702 return true; 1706 return true;
1703 QDateTime dt = finf.lastModified (); 1707 QDateTime dt = finf.lastModified ();
1704 if ( dt <= loadedFileVersion ) 1708 if ( dt <= loadedFileVersion )
1705 return false; 1709 return false;
1706 return true; 1710 return true;
1707 1711
1708} 1712}
1709void CalendarView::watchSavedFile() 1713void CalendarView::watchSavedFile()
1710{ 1714{
1711 QFileInfo finf ( MainWindow::defaultFileName()); 1715 QFileInfo finf ( MainWindow::defaultFileName());
1712 if ( !finf.exists() ) 1716 if ( !finf.exists() )
1713 return; 1717 return;
1714 QDateTime dt = finf.lastModified (); 1718 QDateTime dt = finf.lastModified ();
1715 if ( dt < loadedFileVersion ) { 1719 if ( dt < loadedFileVersion ) {
1716 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1720 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1717 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1721 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1718 return; 1722 return;
1719 } 1723 }
1720 loadedFileVersion = dt; 1724 loadedFileVersion = dt;
1721} 1725}
1722 1726
1723bool CalendarView::checkFileVersion(QString fn) 1727bool CalendarView::checkFileVersion(QString fn)
1724{ 1728{
1725 QFileInfo finf ( fn ); 1729 QFileInfo finf ( fn );
1726 if ( !finf.exists() ) 1730 if ( !finf.exists() )
1727 return true; 1731 return true;
1728 QDateTime dt = finf.lastModified (); 1732 QDateTime dt = finf.lastModified ();
1729 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1733 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1730 //qDebug("file on disk version %s",dt.toString().latin1()); 1734 //qDebug("file on disk version %s",dt.toString().latin1());
1731 if ( dt <= loadedFileVersion ) 1735 if ( dt <= loadedFileVersion )
1732 return true; 1736 return true;
1733 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1737 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1734 i18n("KO/Pi Warning"),i18n("Overwrite"), 1738 i18n("KO/Pi Warning"),i18n("Overwrite"),
1735 i18n("Sync+save")); 1739 i18n("Sync+save"));
1736 1740
1737 if ( km == KMessageBox::Cancel ) 1741 if ( km == KMessageBox::Cancel )
1738 return false; 1742 return false;
1739 if ( km == KMessageBox::Yes ) 1743 if ( km == KMessageBox::Yes )
1740 return true; 1744 return true;
1741 1745
1742 setSyncDevice("deleteaftersync" ); 1746 setSyncDevice("deleteaftersync" );
1743 mSyncManager->mAskForPreferences = true; 1747 mSyncManager->mAskForPreferences = true;
1744 mSyncManager->mSyncAlgoPrefs = 3; 1748 mSyncManager->mSyncAlgoPrefs = 3;
1745 mSyncManager->mWriteBackFile = false; 1749 mSyncManager->mWriteBackFile = false;
1746 mSyncManager->mWriteBackExistingOnly = false; 1750 mSyncManager->mWriteBackExistingOnly = false;
1747 mSyncManager->mShowSyncSummary = false; 1751 mSyncManager->mShowSyncSummary = false;
1748 syncCalendar( fn, 3 ); 1752 syncCalendar( fn, 3 );
1749 Event * e = getLastSyncEvent(); 1753 Event * e = getLastSyncEvent();
1750 mCalendar->deleteEvent ( e ); 1754 mCalendar->deleteEvent ( e );
1751 updateView(); 1755 updateView();
1752 return true; 1756 return true;
1753} 1757}
1754 1758
1755bool CalendarView::saveCalendar( QString filename ) 1759bool CalendarView::saveCalendar( QString filename )
1756{ 1760{
1757 1761
1758 // Store back all unsaved data into calendar object 1762 // Store back all unsaved data into calendar object
1759 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1763 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1760 if ( mViewManager->currentView() ) 1764 if ( mViewManager->currentView() )
1761 mViewManager->currentView()->flushView(); 1765 mViewManager->currentView()->flushView();
1762 1766
1763 1767
1764 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1768 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1765 mStorage->setSaveFormat( new ICalFormat() ); 1769 mStorage->setSaveFormat( new ICalFormat() );
1766 mStorage->setFileName( filename ); 1770 mStorage->setFileName( filename );
1767 bool success; 1771 bool success;
1768 success = mStorage->save(); 1772 success = mStorage->save();
1769 if ( !success ) { 1773 if ( !success ) {
1770 return false; 1774 return false;
1771 } 1775 }
1772 if ( filename == MainWindow::defaultFileName() ) { 1776 if ( filename == MainWindow::defaultFileName() ) {
1773 setLoadedFileVersion( lfv ); 1777 setLoadedFileVersion( lfv );
1774 watchSavedFile(); 1778 watchSavedFile();
1775 } 1779 }
1776 return true; 1780 return true;
1777} 1781}
1778 1782
1779void CalendarView::closeCalendar() 1783void CalendarView::closeCalendar()
1780{ 1784{
1781 1785
1782 // child windows no longer valid 1786 // child windows no longer valid
1783 emit closingDown(); 1787 emit closingDown();
1784 1788
1785 mCalendar->close(); 1789 mCalendar->close();
1786 setModified(false); 1790 setModified(false);
1787 updateView(); 1791 updateView();
1788} 1792}
1789 1793
1790void CalendarView::archiveCalendar() 1794void CalendarView::archiveCalendar()
1791{ 1795{
1792 mDialogManager->showArchiveDialog(); 1796 mDialogManager->showArchiveDialog();
1793} 1797}
1794 1798
1795 1799
1796void CalendarView::readSettings() 1800void CalendarView::readSettings()
1797{ 1801{
1798 1802
1799 1803
1800 // mViewManager->showAgendaView(); 1804 // mViewManager->showAgendaView();
1801 QString str; 1805 QString str;
1802 //qDebug("CalendarView::readSettings() "); 1806 //qDebug("CalendarView::readSettings() ");
1803 // read settings from the KConfig, supplying reasonable 1807 // read settings from the KConfig, supplying reasonable
1804 // defaults where none are to be found 1808 // defaults where none are to be found
1805 KConfig *config = KOGlobals::config(); 1809 KConfig *config = KOGlobals::config();
1806#ifndef KORG_NOSPLITTER 1810#ifndef KORG_NOSPLITTER
1807 config->setGroup("KOrganizer Geometry"); 1811 config->setGroup("KOrganizer Geometry");
1808 1812
1809 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1813 QValueList<int> sizes = config->readIntListEntry("Separator1");
1810 if (sizes.count() != 2) { 1814 if (sizes.count() != 2) {
1811 sizes << mDateNavigator->minimumSizeHint().width(); 1815 sizes << mDateNavigator->minimumSizeHint().width();
1812 sizes << 300; 1816 sizes << 300;
1813 } 1817 }
1814 mPanner->setSizes(sizes); 1818 mPanner->setSizes(sizes);
1815 1819
1816 sizes = config->readIntListEntry("Separator2"); 1820 sizes = config->readIntListEntry("Separator2");
1817 if ( ( mResourceView && sizes.count() == 4 ) || 1821 if ( ( mResourceView && sizes.count() == 4 ) ||
1818 ( !mResourceView && sizes.count() == 3 ) ) { 1822 ( !mResourceView && sizes.count() == 3 ) ) {
1819 mLeftSplitter->setSizes(sizes); 1823 mLeftSplitter->setSizes(sizes);
1820 } 1824 }
1821#endif 1825#endif
1822 globalFlagBlockAgenda = 1; 1826 globalFlagBlockAgenda = 1;
1823 mViewManager->showAgendaView(); 1827 mViewManager->showAgendaView();
1824 //mViewManager->readSettings( config ); 1828 //mViewManager->readSettings( config );
1825 mTodoList->restoreLayout(config,QString("Todo Layout")); 1829 mTodoList->restoreLayout(config,QString("Todo Layout"));
1826 readFilterSettings(config); 1830 readFilterSettings(config);
1827 1831
1828#ifdef DESKTOP_VERSION 1832#ifdef DESKTOP_VERSION
1829 config->setGroup("WidgetLayout"); 1833 config->setGroup("WidgetLayout");
1830 QStringList list; 1834 QStringList list;
1831 list = config->readListEntry("MainLayout"); 1835 list = config->readListEntry("MainLayout");
1832 int x,y,w,h; 1836 int x,y,w,h;
1833 if ( ! list.isEmpty() ) { 1837 if ( ! list.isEmpty() ) {
1834 x = list[0].toInt(); 1838 x = list[0].toInt();
1835 y = list[1].toInt(); 1839 y = list[1].toInt();
1836 w = list[2].toInt(); 1840 w = list[2].toInt();
1837 h = list[3].toInt(); 1841 h = list[3].toInt();
1838 topLevelWidget()->setGeometry(x,y,w,h); 1842 topLevelWidget()->setGeometry(x,y,w,h);
1839 1843
1840 } else { 1844 } else {
1841 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1845 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1842 } 1846 }
1843 list = config->readListEntry("EditEventLayout"); 1847 list = config->readListEntry("EditEventLayout");
1844 if ( ! list.isEmpty() ) { 1848 if ( ! list.isEmpty() ) {
1845 x = list[0].toInt(); 1849 x = list[0].toInt();
1846 y = list[1].toInt(); 1850 y = list[1].toInt();
1847 w = list[2].toInt(); 1851 w = list[2].toInt();
1848 h = list[3].toInt(); 1852 h = list[3].toInt();
1849 mEventEditor->setGeometry(x,y,w,h); 1853 mEventEditor->setGeometry(x,y,w,h);
1850 1854
1851 } 1855 }
1852 list = config->readListEntry("EditTodoLayout"); 1856 list = config->readListEntry("EditTodoLayout");
1853 if ( ! list.isEmpty() ) { 1857 if ( ! list.isEmpty() ) {
1854 x = list[0].toInt(); 1858 x = list[0].toInt();
1855 y = list[1].toInt(); 1859 y = list[1].toInt();
1856 w = list[2].toInt(); 1860 w = list[2].toInt();
1857 h = list[3].toInt(); 1861 h = list[3].toInt();
1858 mTodoEditor->setGeometry(x,y,w,h); 1862 mTodoEditor->setGeometry(x,y,w,h);
1859 1863
1860 } 1864 }
1861 list = config->readListEntry("ViewerLayout"); 1865 list = config->readListEntry("ViewerLayout");
1862 if ( ! list.isEmpty() ) { 1866 if ( ! list.isEmpty() ) {
1863 x = list[0].toInt(); 1867 x = list[0].toInt();
1864 y = list[1].toInt(); 1868 y = list[1].toInt();
1865 w = list[2].toInt(); 1869 w = list[2].toInt();
1866 h = list[3].toInt(); 1870 h = list[3].toInt();
1867 getEventViewerDialog()->setGeometry(x,y,w,h); 1871 getEventViewerDialog()->setGeometry(x,y,w,h);
1868 } 1872 }
1869#endif 1873#endif
1870 config->setGroup( "Views" ); 1874 config->setGroup( "Views" );
1871 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1875 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1872 1876
1873 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1877 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1874 1878
1875 int resetval = 0; 1879 int resetval = 0;
1876 int maxVal = 0; 1880 int maxVal = 0;
1877 if (sizes.count() != 3) { 1881 if (sizes.count() != 3) {
1878 if ( KOPrefs::instance()->mVerticalScreen ) { 1882 if ( KOPrefs::instance()->mVerticalScreen ) {
1879 resetval = mDateNavigator->sizeHint().width()+2; 1883 resetval = mDateNavigator->sizeHint().width()+2;
1880 } else { 1884 } else {
1881 resetval = mDateNavigator->sizeHint().height()+2; 1885 resetval = mDateNavigator->sizeHint().height()+2;
1882 } 1886 }
1883 } 1887 }
1884 if ( resetval ) { 1888 if ( resetval ) {
1885 sizes.clear(); 1889 sizes.clear();
1886 if ( KOPrefs::instance()->mVerticalScreen ) { 1890 if ( KOPrefs::instance()->mVerticalScreen ) {
1887 maxVal = QApplication::desktop()->width() -10; 1891 maxVal = QApplication::desktop()->width() -10;
1888 } else { 1892 } else {
1889 maxVal = QApplication::desktop()->height()-10; 1893 maxVal = QApplication::desktop()->height()-10;
1890 } 1894 }
1891 sizes << resetval; 1895 sizes << resetval;
1892 if ( maxVal < resetval + resetval) 1896 if ( maxVal < resetval + resetval)
1893 resetval = maxVal - resetval; 1897 resetval = maxVal - resetval;
1894 sizes << resetval; 1898 sizes << resetval;
1895 sizes << 100; 1899 sizes << 100;
1896 } 1900 }
1897 mLeftFrame->setSizes(sizes); 1901 mLeftFrame->setSizes(sizes);
1898 sizes = config->readIntListEntry("Main Splitter Frame"); 1902 sizes = config->readIntListEntry("Main Splitter Frame");
1899 resetval = 0; 1903 resetval = 0;
1900 maxVal = 0; 1904 maxVal = 0;
1901 if (sizes.count() != 2) { 1905 if (sizes.count() != 2) {
1902 if ( !KOPrefs::instance()->mVerticalScreen ) { 1906 if ( !KOPrefs::instance()->mVerticalScreen ) {
1903 resetval = mDateNavigator->sizeHint().width()+2; 1907 resetval = mDateNavigator->sizeHint().width()+2;
1904 } else { 1908 } else {
1905 resetval = mDateNavigator->sizeHint().height()+2; 1909 resetval = mDateNavigator->sizeHint().height()+2;
1906 } 1910 }
1907 } 1911 }
1908 if ( resetval ) { 1912 if ( resetval ) {
1909 sizes.clear(); 1913 sizes.clear();
1910 if ( !KOPrefs::instance()->mVerticalScreen ) { 1914 if ( !KOPrefs::instance()->mVerticalScreen ) {
1911 maxVal = QApplication::desktop()->width() -10; 1915 maxVal = QApplication::desktop()->width() -10;
1912 } else { 1916 } else {
1913 maxVal = QApplication::desktop()->height()-10; 1917 maxVal = QApplication::desktop()->height()-10;
1914 } 1918 }
1915 sizes << resetval; 1919 sizes << resetval;
1916 if ( maxVal < resetval + resetval) 1920 if ( maxVal < resetval + resetval)
1917 resetval = maxVal - resetval; 1921 resetval = maxVal - resetval;
1918 sizes << resetval; 1922 sizes << resetval;
1919 } 1923 }
1920 mMainFrame->setSizes(sizes); 1924 mMainFrame->setSizes(sizes);
1921 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1925 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1922 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1926 else if ( dateCount == 7 ) mNavigator->selectWeek();
1923 else mNavigator->selectDates( dateCount ); 1927 else mNavigator->selectDates( dateCount );
1924 // mViewManager->readSettings( config ); 1928 // mViewManager->readSettings( config );
1925 updateConfig(); 1929 updateConfig();
1926 globalFlagBlockAgenda = 2; 1930 globalFlagBlockAgenda = 2;
1927 mViewManager->readSettings( config ); 1931 mViewManager->readSettings( config );
1928 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 1932 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
1929} 1933}
1930 1934
1931 1935
1932void CalendarView::writeSettings() 1936void CalendarView::writeSettings()
1933{ 1937{
1934 // kdDebug() << "CalendarView::writeSettings" << endl; 1938 // kdDebug() << "CalendarView::writeSettings" << endl;
1935 1939
1936 KConfig *config = KOGlobals::config(); 1940 KConfig *config = KOGlobals::config();
1937 1941
1938 mViewManager->writeSettings( config ); 1942 mViewManager->writeSettings( config );
1939 mTodoList->saveLayout(config,QString("Todo Layout")); 1943 mTodoList->saveLayout(config,QString("Todo Layout"));
1940 mDialogManager->writeSettings( config ); 1944 mDialogManager->writeSettings( config );
1941 //KOPrefs::instance()->usrWriteConfig(); 1945 //KOPrefs::instance()->usrWriteConfig();
1942 KOPrefs::instance()->writeConfig(); 1946 KOPrefs::instance()->writeConfig();
1943 1947
1944 writeFilterSettings(config); 1948 writeFilterSettings(config);
1945 1949
1946 config->setGroup( "Views" ); 1950 config->setGroup( "Views" );
1947 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1951 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1948 1952
1949 QValueList<int> listINT = mLeftFrame->sizes(); 1953 QValueList<int> listINT = mLeftFrame->sizes();
1950 config->writeEntry("Left Splitter Frame",listINT); 1954 config->writeEntry("Left Splitter Frame",listINT);
1951 QValueList<int> listINT2 = mMainFrame->sizes(); 1955 QValueList<int> listINT2 = mMainFrame->sizes();
1952 config->writeEntry("Main Splitter Frame",listINT2); 1956 config->writeEntry("Main Splitter Frame",listINT2);
1953#ifdef DESKTOP_VERSION 1957#ifdef DESKTOP_VERSION
1954 config->setGroup("WidgetLayout"); 1958 config->setGroup("WidgetLayout");
1955 QStringList list ;//= config->readListEntry("MainLayout"); 1959 QStringList list ;//= config->readListEntry("MainLayout");
1956 int x,y,w,h; 1960 int x,y,w,h;
1957 QWidget* wid; 1961 QWidget* wid;
1958 wid = topLevelWidget(); 1962 wid = topLevelWidget();
1959 x = wid->geometry().x(); 1963 x = wid->geometry().x();
1960 y = wid->geometry().y(); 1964 y = wid->geometry().y();
1961 w = wid->width(); 1965 w = wid->width();
1962 h = wid->height(); 1966 h = wid->height();
1963 list.clear(); 1967 list.clear();
1964 list << QString::number( x ); 1968 list << QString::number( x );
1965 list << QString::number( y ); 1969 list << QString::number( y );
1966 list << QString::number( w ); 1970 list << QString::number( w );
1967 list << QString::number( h ); 1971 list << QString::number( h );
1968 config->writeEntry("MainLayout",list ); 1972 config->writeEntry("MainLayout",list );
1969 1973
1970 wid = mEventEditor; 1974 wid = mEventEditor;
1971 x = wid->geometry().x(); 1975 x = wid->geometry().x();
1972 y = wid->geometry().y(); 1976 y = wid->geometry().y();
1973 w = wid->width(); 1977 w = wid->width();
1974 h = wid->height(); 1978 h = wid->height();
1975 list.clear(); 1979 list.clear();
1976 list << QString::number( x ); 1980 list << QString::number( x );
1977 list << QString::number( y ); 1981 list << QString::number( y );
1978 list << QString::number( w ); 1982 list << QString::number( w );
1979 list << QString::number( h ); 1983 list << QString::number( h );
1980 config->writeEntry("EditEventLayout",list ); 1984 config->writeEntry("EditEventLayout",list );
1981 1985
1982 wid = mTodoEditor; 1986 wid = mTodoEditor;
1983 x = wid->geometry().x(); 1987 x = wid->geometry().x();
1984 y = wid->geometry().y(); 1988 y = wid->geometry().y();
1985 w = wid->width(); 1989 w = wid->width();
1986 h = wid->height(); 1990 h = wid->height();
1987 list.clear(); 1991 list.clear();
1988 list << QString::number( x ); 1992 list << QString::number( x );
1989 list << QString::number( y ); 1993 list << QString::number( y );
1990 list << QString::number( w ); 1994 list << QString::number( w );
1991 list << QString::number( h ); 1995 list << QString::number( h );
1992 config->writeEntry("EditTodoLayout",list ); 1996 config->writeEntry("EditTodoLayout",list );
1993 wid = getEventViewerDialog(); 1997 wid = getEventViewerDialog();
1994 x = wid->geometry().x(); 1998 x = wid->geometry().x();
1995 y = wid->geometry().y(); 1999 y = wid->geometry().y();
1996 w = wid->width(); 2000 w = wid->width();
1997 h = wid->height(); 2001 h = wid->height();
1998 list.clear(); 2002 list.clear();
1999 list << QString::number( x ); 2003 list << QString::number( x );
2000 list << QString::number( y ); 2004 list << QString::number( y );
2001 list << QString::number( w ); 2005 list << QString::number( w );
2002 list << QString::number( h ); 2006 list << QString::number( h );
2003 config->writeEntry("ViewerLayout",list ); 2007 config->writeEntry("ViewerLayout",list );
2004 wid = mDialogManager->getSearchDialog(); 2008 wid = mDialogManager->getSearchDialog();
2005 if ( wid ) { 2009 if ( wid ) {
2006 x = wid->geometry().x(); 2010 x = wid->geometry().x();
2007 y = wid->geometry().y(); 2011 y = wid->geometry().y();
2008 w = wid->width(); 2012 w = wid->width();
2009 h = wid->height(); 2013 h = wid->height();
2010 list.clear(); 2014 list.clear();
2011 list << QString::number( x ); 2015 list << QString::number( x );
2012 list << QString::number( y ); 2016 list << QString::number( y );
2013 list << QString::number( w ); 2017 list << QString::number( w );
2014 list << QString::number( h ); 2018 list << QString::number( h );
2015 config->writeEntry("SearchLayout",list ); 2019 config->writeEntry("SearchLayout",list );
2016 } 2020 }
2017#endif 2021#endif
2018 2022
2019 2023
2020 config->sync(); 2024 config->sync();
2021} 2025}
2022 2026
2023void CalendarView::readFilterSettings(KConfig *config) 2027void CalendarView::readFilterSettings(KConfig *config)
2024{ 2028{
2025 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2029 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2026 2030
2027 mFilters.clear(); 2031 mFilters.clear();
2028 2032
2029 config->setGroup("General"); 2033 config->setGroup("General");
2030 QStringList filterList = config->readListEntry("CalendarFilters"); 2034 QStringList filterList = config->readListEntry("CalendarFilters");
2031 2035
2032 QStringList::ConstIterator it = filterList.begin(); 2036 QStringList::ConstIterator it = filterList.begin();
2033 QStringList::ConstIterator end = filterList.end(); 2037 QStringList::ConstIterator end = filterList.end();
2034 while(it != end) { 2038 while(it != end) {
2035 // kdDebug() << " filter: " << (*it) << endl; 2039 // kdDebug() << " filter: " << (*it) << endl;
2036 2040
2037 CalFilter *filter; 2041 CalFilter *filter;
2038 filter = new CalFilter(*it); 2042 filter = new CalFilter(*it);
2039 config->setGroup("Filter_" + (*it)); 2043 config->setGroup("Filter_" + (*it));
2040 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2044 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2041 filter->setCriteria(config->readNumEntry("Criteria",0)); 2045 filter->setCriteria(config->readNumEntry("Criteria",0));
2042 filter->setCategoryList(config->readListEntry("CategoryList")); 2046 filter->setCategoryList(config->readListEntry("CategoryList"));
2043 mFilters.append(filter); 2047 mFilters.append(filter);
2044 2048
2045 ++it; 2049 ++it;
2046 } 2050 }
2047 2051
2048 if (mFilters.count() == 0) { 2052 if (mFilters.count() == 0) {
2049 CalFilter *filter = new CalFilter(i18n("Default")); 2053 CalFilter *filter = new CalFilter(i18n("Default"));
2050 mFilters.append(filter); 2054 mFilters.append(filter);
2051 } 2055 }
2052 mFilterView->updateFilters(); 2056 mFilterView->updateFilters();
2053 config->setGroup("FilterView"); 2057 config->setGroup("FilterView");
2054 2058
2055 mFilterView->blockSignals(true); 2059 mFilterView->blockSignals(true);
2056 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2060 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2057 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2061 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2058 mFilterView->blockSignals(false); 2062 mFilterView->blockSignals(false);
2059 // We do it manually to avoid it being done twice by the above calls 2063 // We do it manually to avoid it being done twice by the above calls
2060 updateFilter(); 2064 updateFilter();
2061} 2065}
2062 2066
2063void CalendarView::writeFilterSettings(KConfig *config) 2067void CalendarView::writeFilterSettings(KConfig *config)
2064{ 2068{
2065 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2069 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2066 2070
2067 QStringList filterList; 2071 QStringList filterList;
2068 2072
2069 CalFilter *filter = mFilters.first(); 2073 CalFilter *filter = mFilters.first();
2070 while(filter) { 2074 while(filter) {
2071 // kdDebug() << " fn: " << filter->name() << endl; 2075 // kdDebug() << " fn: " << filter->name() << endl;
2072 filterList << filter->name(); 2076 filterList << filter->name();
2073 config->setGroup("Filter_" + filter->name()); 2077 config->setGroup("Filter_" + filter->name());
2074 config->writeEntry("Criteria",filter->criteria()); 2078 config->writeEntry("Criteria",filter->criteria());
2075 config->writeEntry("CategoryList",filter->categoryList()); 2079 config->writeEntry("CategoryList",filter->categoryList());
2076 filter = mFilters.next(); 2080 filter = mFilters.next();
2077 } 2081 }
2078 config->setGroup("General"); 2082 config->setGroup("General");
2079 config->writeEntry("CalendarFilters",filterList); 2083 config->writeEntry("CalendarFilters",filterList);
2080 2084
2081 config->setGroup("FilterView"); 2085 config->setGroup("FilterView");
2082 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2086 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2083 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2087 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2084} 2088}
2085 2089
2086 2090
2087void CalendarView::goToday() 2091void CalendarView::goToday()
2088{ 2092{
2089 if ( mViewManager->currentView()->isMonthView() ) 2093 if ( mViewManager->currentView()->isMonthView() )
2090 mNavigator->selectTodayMonth(); 2094 mNavigator->selectTodayMonth();
2091 else 2095 else
2092 mNavigator->selectToday(); 2096 mNavigator->selectToday();
2093} 2097}
2094 2098
2095void CalendarView::goNext() 2099void CalendarView::goNext()
2096{ 2100{
2097 mNavigator->selectNext(); 2101 mNavigator->selectNext();
2098} 2102}
2099 2103
2100void CalendarView::goPrevious() 2104void CalendarView::goPrevious()
2101{ 2105{
2102 mNavigator->selectPrevious(); 2106 mNavigator->selectPrevious();
2103} 2107}
2104void CalendarView::goNextMonth() 2108void CalendarView::goNextMonth()
2105{ 2109{
2106 mNavigator->selectNextMonth(); 2110 mNavigator->selectNextMonth();
2107} 2111}
2108 2112
2109void CalendarView::goPreviousMonth() 2113void CalendarView::goPreviousMonth()
2110{ 2114{
2111 mNavigator->selectPreviousMonth(); 2115 mNavigator->selectPreviousMonth();
2112} 2116}
2113void CalendarView::writeLocale() 2117void CalendarView::writeLocale()
2114{ 2118{
2115 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2119 //KPimGlobalPrefs::instance()->setGlobalConfig();
2116#if 0 2120#if 0
2117 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2121 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2118 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2122 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2119 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2123 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2120 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2124 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2121 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2125 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2122 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2126 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2123 dummy = KOPrefs::instance()->mUserDateFormatShort; 2127 dummy = KOPrefs::instance()->mUserDateFormatShort;
2124 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2128 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2125 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2129 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2126 KOPrefs::instance()->mDaylightsavingStart, 2130 KOPrefs::instance()->mDaylightsavingStart,
2127 KOPrefs::instance()->mDaylightsavingEnd ); 2131 KOPrefs::instance()->mDaylightsavingEnd );
2128 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2132 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2129#endif 2133#endif
2130} 2134}
2131void CalendarView::updateConfig() 2135void CalendarView::updateConfig()
2132{ 2136{
2133 writeLocale(); 2137 writeLocale();
2134 if ( KOPrefs::instance()->mUseAppColors ) 2138 if ( KOPrefs::instance()->mUseAppColors )
2135 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2139 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2136 emit configChanged(); 2140 emit configChanged();
2137 mTodoList->updateConfig(); 2141 mTodoList->updateConfig();
2138 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2142 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2139 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2143 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2140 // To make the "fill window" configurations work 2144 // To make the "fill window" configurations work
2141 //mViewManager->raiseCurrentView(); 2145 //mViewManager->raiseCurrentView();
2142} 2146}
2143 2147
2144 2148
2145void CalendarView::eventChanged(Event *event) 2149void CalendarView::eventChanged(Event *event)
2146{ 2150{
2147 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2151 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2148 //updateUnmanagedViews(); 2152 //updateUnmanagedViews();
2149} 2153}
2150 2154
2151void CalendarView::eventAdded(Event *event) 2155void CalendarView::eventAdded(Event *event)
2152{ 2156{
2153 changeEventDisplay(event,KOGlobals::EVENTADDED); 2157 changeEventDisplay(event,KOGlobals::EVENTADDED);
2154} 2158}
2155 2159
2156void CalendarView::eventToBeDeleted(Event *) 2160void CalendarView::eventToBeDeleted(Event *)
2157{ 2161{
2158 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2162 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2159} 2163}
2160 2164
2161void CalendarView::eventDeleted() 2165void CalendarView::eventDeleted()
2162{ 2166{
2163 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2167 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2164} 2168}
2165void CalendarView::changeTodoDisplay(Todo *which, int action) 2169void CalendarView::changeTodoDisplay(Todo *which, int action)
2166{ 2170{
2167 changeIncidenceDisplay((Incidence *)which, action); 2171 changeIncidenceDisplay((Incidence *)which, action);
2168 mDateNavigator->updateView(); //LR 2172 mDateNavigator->updateView(); //LR
2169 //mDialogManager->updateSearchDialog(); 2173 //mDialogManager->updateSearchDialog();
2170 2174
2171 if (which) { 2175 if (which) {
2172 mViewManager->updateWNview(); 2176 mViewManager->updateWNview();
2173 //mTodoList->updateView(); 2177 //mTodoList->updateView();
2174 } 2178 }
2175 2179
2176} 2180}
2177 2181
2178void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2182void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2179{ 2183{
2180 updateUnmanagedViews(); 2184 updateUnmanagedViews();
2181 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2185 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2182 if ( action == KOGlobals::EVENTDELETED ) { //delete 2186 if ( action == KOGlobals::EVENTDELETED ) { //delete
2183 mCalendar->checkAlarmForIncidence( 0, true ); 2187 mCalendar->checkAlarmForIncidence( 0, true );
2184 if ( mEventViewerDialog ) 2188 if ( mEventViewerDialog )
2185 mEventViewerDialog->hide(); 2189 mEventViewerDialog->hide();
2186 } 2190 }
2187 else 2191 else
2188 mCalendar->checkAlarmForIncidence( which , false ); 2192 mCalendar->checkAlarmForIncidence( which , false );
2189} 2193}
2190 2194
2191// most of the changeEventDisplays() right now just call the view's 2195// most of the changeEventDisplays() right now just call the view's
2192// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2196// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2193void CalendarView::changeEventDisplay(Event *which, int action) 2197void CalendarView::changeEventDisplay(Event *which, int action)
2194{ 2198{
2195 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2199 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2196 changeIncidenceDisplay((Incidence *)which, action); 2200 changeIncidenceDisplay((Incidence *)which, action);
2197 mDateNavigator->updateView(); 2201 mDateNavigator->updateView();
2198 //mDialogManager->updateSearchDialog(); 2202 //mDialogManager->updateSearchDialog();
2199 2203
2200 if (which) { 2204 if (which) {
2201 // If there is an event view visible update the display 2205 // If there is an event view visible update the display
2202 mViewManager->currentView()->changeEventDisplay(which,action); 2206 mViewManager->currentView()->changeEventDisplay(which,action);
2203 // TODO: check, if update needed 2207 // TODO: check, if update needed
2204 // if (which->getTodoStatus()) { 2208 // if (which->getTodoStatus()) {
2205 mTodoList->updateView(); 2209 mTodoList->updateView();
2206 // } 2210 // }
2207 } else { 2211 } else {
2208 mViewManager->currentView()->updateView(); 2212 mViewManager->currentView()->updateView();
2209 } 2213 }
2210} 2214}
2211 2215
2212 2216
2213void CalendarView::updateTodoViews() 2217void CalendarView::updateTodoViews()
2214{ 2218{
2215 mTodoList->updateView(); 2219 mTodoList->updateView();
2216 mViewManager->currentView()->updateView(); 2220 mViewManager->currentView()->updateView();
2217 2221
2218} 2222}
2219 2223
2220 2224
2221void CalendarView::updateView(const QDate &start, const QDate &end) 2225void CalendarView::updateView(const QDate &start, const QDate &end)
2222{ 2226{
2223 mTodoList->updateView(); 2227 mTodoList->updateView();
2224 mViewManager->updateView(start, end); 2228 mViewManager->updateView(start, end);
2225 //mDateNavigator->updateView(); 2229 //mDateNavigator->updateView();
2226} 2230}
2227 2231
2228void CalendarView::updateView() 2232void CalendarView::updateView()
2229{ 2233{
2230 DateList tmpList = mNavigator->selectedDates(); 2234 DateList tmpList = mNavigator->selectedDates();
2231 2235
2232 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2236 if ( KOPrefs::instance()->mHideNonStartedTodos )
2233 mTodoList->updateView(); 2237 mTodoList->updateView();
2234 // We assume that the navigator only selects consecutive days. 2238 // We assume that the navigator only selects consecutive days.
2235 updateView( tmpList.first(), tmpList.last() ); 2239 updateView( tmpList.first(), tmpList.last() );
2236} 2240}
2237 2241
2238void CalendarView::updateUnmanagedViews() 2242void CalendarView::updateUnmanagedViews()
2239{ 2243{
2240 mDateNavigator->updateDayMatrix(); 2244 mDateNavigator->updateDayMatrix();
2241} 2245}
2242 2246
2243int CalendarView::msgItemDelete(const QString name) 2247int CalendarView::msgItemDelete(const QString name)
2244{ 2248{
2245 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2249 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2246 i18n("This item will be\npermanently deleted."), 2250 i18n("This item will be\npermanently deleted."),
2247 i18n("KO/Pi Confirmation"),i18n("Delete")); 2251 i18n("KO/Pi Confirmation"),i18n("Delete"));
2248} 2252}
2249 2253
2250 2254
2251void CalendarView::edit_cut() 2255void CalendarView::edit_cut()
2252{ 2256{
2253 Event *anEvent=0; 2257 Event *anEvent=0;
2254 2258
2255 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2259 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2256 2260
2257 if (mViewManager->currentView()->isEventView()) { 2261 if (mViewManager->currentView()->isEventView()) {
2258 if ( incidence && incidence->type() == "Event" ) { 2262 if ( incidence && incidence->type() == "Event" ) {
2259 anEvent = static_cast<Event *>(incidence); 2263 anEvent = static_cast<Event *>(incidence);
2260 } 2264 }
2261 } 2265 }
2262 2266
2263 if (!anEvent) { 2267 if (!anEvent) {
2264 KNotifyClient::beep(); 2268 KNotifyClient::beep();
2265 return; 2269 return;
2266 } 2270 }
2267 DndFactory factory( mCalendar ); 2271 DndFactory factory( mCalendar );
2268 factory.cutIncidence(anEvent); 2272 factory.cutIncidence(anEvent);
2269 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2273 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2270} 2274}
2271 2275
2272void CalendarView::edit_copy() 2276void CalendarView::edit_copy()
2273{ 2277{
2274 Event *anEvent=0; 2278 Event *anEvent=0;
2275 2279
2276 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2280 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2277 2281
2278 if (mViewManager->currentView()->isEventView()) { 2282 if (mViewManager->currentView()->isEventView()) {
2279 if ( incidence && incidence->type() == "Event" ) { 2283 if ( incidence && incidence->type() == "Event" ) {
2280 anEvent = static_cast<Event *>(incidence); 2284 anEvent = static_cast<Event *>(incidence);
2281 } 2285 }
2282 } 2286 }
2283 2287
2284 if (!anEvent) { 2288 if (!anEvent) {
2285 KNotifyClient::beep(); 2289 KNotifyClient::beep();
2286 return; 2290 return;
2287 } 2291 }
2288 DndFactory factory( mCalendar ); 2292 DndFactory factory( mCalendar );
2289 factory.copyIncidence(anEvent); 2293 factory.copyIncidence(anEvent);
2290} 2294}
2291 2295
2292void CalendarView::edit_paste() 2296void CalendarView::edit_paste()
2293{ 2297{
2294 QDate date = mNavigator->selectedDates().first(); 2298 QDate date = mNavigator->selectedDates().first();
2295 2299
2296 DndFactory factory( mCalendar ); 2300 DndFactory factory( mCalendar );
2297 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2301 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2298 2302
2299 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2303 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2300} 2304}
2301 2305
2302void CalendarView::edit_options() 2306void CalendarView::edit_options()
2303{ 2307{
2304 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2308 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2305 emit save(); 2309 emit save();
2306 emit saveStopTimer(); 2310 emit saveStopTimer();
2307 mDialogManager->showOptionsDialog(); 2311 mDialogManager->showOptionsDialog();
2308 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2312 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2309 emit saveStopTimer(); 2313 emit saveStopTimer();
2310 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2314 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2311 i18n("Timezone settings"),i18n("Reload"))) { 2315 i18n("Timezone settings"),i18n("Reload"))) {
2312 qDebug("KO: TZ reload cancelled "); 2316 qDebug("KO: TZ reload cancelled ");
2313 return; 2317 return;
2314 } 2318 }
2315 qDebug("KO: Timezone change "); 2319 qDebug("KO: Timezone change ");
2316 openCalendar( MainWindow::defaultFileName() ); 2320 openCalendar( MainWindow::defaultFileName() );
2317 setModified(true); 2321 setModified(true);
2318 } 2322 }
2319 else 2323 else
2320 qDebug("KO: No tz change "); 2324 qDebug("KO: No tz change ");
2321 2325
2322} 2326}
2323 2327
2324 2328
2325void CalendarView::slotSelectPickerDate( QDate d) 2329void CalendarView::slotSelectPickerDate( QDate d)
2326{ 2330{
2327 mDateFrame->hide(); 2331 mDateFrame->hide();
2328 if ( mDatePickerMode == 1 ) { 2332 if ( mDatePickerMode == 1 ) {
2329 mNavigator->slotDaySelect( d ); 2333 mNavigator->slotDaySelect( d );
2330 } else if ( mDatePickerMode == 2 ) { 2334 } else if ( mDatePickerMode == 2 ) {
2331 if ( mMoveIncidence->type() == "Todo" ) { 2335 if ( mMoveIncidence->type() == "Todo" ) {
2332 Todo * to = (Todo *) mMoveIncidence; 2336 Todo * to = (Todo *) mMoveIncidence;
2333 QTime tim; 2337 QTime tim;
2334 int len = 0; 2338 int len = 0;
2335 if ( to->hasStartDate() && to->hasDueDate() ) 2339 if ( to->hasStartDate() && to->hasDueDate() )
2336 len = to->dtStart().secsTo( to->dtDue()); 2340 len = to->dtStart().secsTo( to->dtDue());
2337 if ( to->hasDueDate() ) 2341 if ( to->hasDueDate() )
2338 tim = to->dtDue().time(); 2342 tim = to->dtDue().time();
2339 else { 2343 else {
2340 tim = QTime ( 0,0,0 ); 2344 tim = QTime ( 0,0,0 );
2341 to->setFloats( true ); 2345 to->setFloats( true );
2342 to->setHasDueDate( true ); 2346 to->setHasDueDate( true );
2343 } 2347 }
2344 QDateTime dt ( d,tim ); 2348 QDateTime dt ( d,tim );
2345 to->setDtDue( dt ); 2349 to->setDtDue( dt );
2346 2350
2347 if ( to->hasStartDate() ) { 2351 if ( to->hasStartDate() ) {
2348 if ( len>0 ) 2352 if ( len>0 )
2349 to->setDtStart(to->dtDue().addSecs( -len )); 2353 to->setDtStart(to->dtDue().addSecs( -len ));
2350 else 2354 else
2351 if (to->dtStart() > to->dtDue() ) 2355 if (to->dtStart() > to->dtDue() )
2352 to->setDtStart(to->dtDue().addDays( -3 )); 2356 to->setDtStart(to->dtDue().addDays( -3 ));
2353 } 2357 }
2354 2358
2355 todoChanged( to ); 2359 todoChanged( to );
2356 } else { 2360 } else {
2357 if ( mMoveIncidence->doesRecur() ) { 2361 if ( mMoveIncidence->doesRecur() ) {
2358#if 0 2362#if 0
2359 // PENDING implement this 2363 // PENDING implement this
2360 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2364 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2361 mCalendar()->addIncidence( newInc ); 2365 mCalendar()->addIncidence( newInc );
2362 if ( mMoveIncidence->type() == "Todo" ) 2366 if ( mMoveIncidence->type() == "Todo" )
2363 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2367 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2364 else 2368 else
2365 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2369 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2366 mMoveIncidence = newInc; 2370 mMoveIncidence = newInc;
2367 2371
2368#endif 2372#endif
2369 } 2373 }
2370 QTime tim = mMoveIncidence->dtStart().time(); 2374 QTime tim = mMoveIncidence->dtStart().time();
2371 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2375 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2372 QDateTime dt ( d,tim ); 2376 QDateTime dt ( d,tim );
2373 mMoveIncidence->setDtStart( dt ); 2377 mMoveIncidence->setDtStart( dt );
2374 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2378 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2375 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2379 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2376 } 2380 }
2377 2381
2378 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2382 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2379 } 2383 }
2380} 2384}
2381 2385
2382void CalendarView::removeCategories() 2386void CalendarView::removeCategories()
2383{ 2387{
2384 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2388 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2385 QStringList catList = KOPrefs::instance()->mCustomCategories; 2389 QStringList catList = KOPrefs::instance()->mCustomCategories;
2386 QStringList catIncList; 2390 QStringList catIncList;
2387 QStringList newCatList; 2391 QStringList newCatList;
2388 Incidence* inc = incList.first(); 2392 Incidence* inc = incList.first();
2389 int i; 2393 int i;
2390 int count = 0; 2394 int count = 0;
2391 while ( inc ) { 2395 while ( inc ) {
2392 newCatList.clear(); 2396 newCatList.clear();
2393 catIncList = inc->categories() ; 2397 catIncList = inc->categories() ;
2394 for( i = 0; i< catIncList.count(); ++i ) { 2398 for( i = 0; i< catIncList.count(); ++i ) {
2395 if ( catList.contains (catIncList[i])) 2399 if ( catList.contains (catIncList[i]))
2396 newCatList.append( catIncList[i] ); 2400 newCatList.append( catIncList[i] );
2397 } 2401 }
2398 newCatList.sort(); 2402 newCatList.sort();
2399 inc->setCategories( newCatList.join(",") ); 2403 inc->setCategories( newCatList.join(",") );
2400 inc = incList.next(); 2404 inc = incList.next();
2401 } 2405 }
2402} 2406}
2403 2407
2404int CalendarView::addCategories() 2408int CalendarView::addCategories()
2405{ 2409{
2406 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2410 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2407 QStringList catList = KOPrefs::instance()->mCustomCategories; 2411 QStringList catList = KOPrefs::instance()->mCustomCategories;
2408 QStringList catIncList; 2412 QStringList catIncList;
2409 Incidence* inc = incList.first(); 2413 Incidence* inc = incList.first();
2410 int i; 2414 int i;
2411 int count = 0; 2415 int count = 0;
2412 while ( inc ) { 2416 while ( inc ) {
2413 catIncList = inc->categories() ; 2417 catIncList = inc->categories() ;
2414 for( i = 0; i< catIncList.count(); ++i ) { 2418 for( i = 0; i< catIncList.count(); ++i ) {
2415 if ( !catList.contains (catIncList[i])) { 2419 if ( !catList.contains (catIncList[i])) {
2416 catList.append( catIncList[i] ); 2420 catList.append( catIncList[i] );
2417 //qDebug("add cat %s ", catIncList[i].latin1()); 2421 //qDebug("add cat %s ", catIncList[i].latin1());
2418 ++count; 2422 ++count;
2419 } 2423 }
2420 } 2424 }
2421 inc = incList.next(); 2425 inc = incList.next();
2422 } 2426 }
2423 catList.sort(); 2427 catList.sort();
2424 KOPrefs::instance()->mCustomCategories = catList; 2428 KOPrefs::instance()->mCustomCategories = catList;
2425 return count; 2429 return count;
2426} 2430}
2427 2431
2428void CalendarView::manageCategories() 2432void CalendarView::manageCategories()
2429{ 2433{
2430 KOCatPrefs* cp = new KOCatPrefs(); 2434 KOCatPrefs* cp = new KOCatPrefs();
2431 cp->show(); 2435 cp->show();
2432 int w =cp->sizeHint().width() ; 2436 int w =cp->sizeHint().width() ;
2433 int h = cp->sizeHint().height() ; 2437 int h = cp->sizeHint().height() ;
2434 int dw = QApplication::desktop()->width(); 2438 int dw = QApplication::desktop()->width();
2435 int dh = QApplication::desktop()->height(); 2439 int dh = QApplication::desktop()->height();
2436 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2440 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2437 if ( !cp->exec() ) { 2441 if ( !cp->exec() ) {
2438 delete cp; 2442 delete cp;
2439 return; 2443 return;
2440 } 2444 }
2441 int count = 0; 2445 int count = 0;
2442 if ( cp->addCat() ) { 2446 if ( cp->addCat() ) {
2443 count = addCategories(); 2447 count = addCategories();
2444 if ( count ) { 2448 if ( count ) {
2445 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2449 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2446 writeSettings(); 2450 writeSettings();
2447 } else 2451 } else
2448 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2452 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2449 } else { 2453 } else {
2450 removeCategories(); 2454 removeCategories();
2451 updateView(); 2455 updateView();
2452 } 2456 }
2453 delete cp; 2457 delete cp;
2454} 2458}
2455 2459
2456void CalendarView::beamIncidence(Incidence * Inc) 2460void CalendarView::beamIncidence(Incidence * Inc)
2457{ 2461{
2458 QPtrList<Incidence> delSel ; 2462 QPtrList<Incidence> delSel ;
2459 delSel.append(Inc); 2463 delSel.append(Inc);
2460 beamIncidenceList( delSel ); 2464 beamIncidenceList( delSel );
2461} 2465}
2462void CalendarView::beamCalendar() 2466void CalendarView::beamCalendar()
2463{ 2467{
2464 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2468 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2465 //qDebug("beamCalendar() "); 2469 //qDebug("beamCalendar() ");
2466 beamIncidenceList( delSel ); 2470 beamIncidenceList( delSel );
2467} 2471}
2468void CalendarView::beamFilteredCalendar() 2472void CalendarView::beamFilteredCalendar()
2469{ 2473{
2470 QPtrList<Incidence> delSel = mCalendar->incidences(); 2474 QPtrList<Incidence> delSel = mCalendar->incidences();
2471 //qDebug("beamFilteredCalendar() "); 2475 //qDebug("beamFilteredCalendar() ");
2472 beamIncidenceList( delSel ); 2476 beamIncidenceList( delSel );
2473} 2477}
2474void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2478void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2475{ 2479{
2476 if ( beamDialog->exec () == QDialog::Rejected ) 2480 if ( beamDialog->exec () == QDialog::Rejected )
2477 return; 2481 return;
2478#ifdef DESKTOP_VERSION 2482#ifdef DESKTOP_VERSION
2479 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2483 QString fn = locateLocal( "tmp", "kopibeamfile" );
2480#else 2484#else
2481 QString fn = "/tmp/kopibeamfile"; 2485 QString fn = "/tmp/kopibeamfile";
2482#endif 2486#endif
2483 QString mes; 2487 QString mes;
2484 bool createbup = true; 2488 bool createbup = true;
2485 if ( createbup ) { 2489 if ( createbup ) {
2486 QString description = "\n"; 2490 QString description = "\n";
2487 CalendarLocal* cal = new CalendarLocal(); 2491 CalendarLocal* cal = new CalendarLocal();
2488 if ( beamDialog->beamLocal() ) 2492 if ( beamDialog->beamLocal() )
2489 cal->setLocalTime(); 2493 cal->setLocalTime();
2490 else 2494 else
2491 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2495 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2492 Incidence *incidence = delSel.first(); 2496 Incidence *incidence = delSel.first();
2493 bool addText = false; 2497 bool addText = false;
2494 if ( delSel.count() < 10 ) 2498 if ( delSel.count() < 10 )
2495 addText = true; 2499 addText = true;
2496 else { 2500 else {
2497 description.sprintf(i18n(" %d items?"),delSel.count() ); 2501 description.sprintf(i18n(" %d items?"),delSel.count() );
2498 } 2502 }
2499 while ( incidence ) { 2503 while ( incidence ) {
2500 Incidence *in = incidence->clone(); 2504 Incidence *in = incidence->clone();
2501 if ( ! in->summary().isEmpty() ) { 2505 if ( ! in->summary().isEmpty() ) {
2502 in->setDescription(""); 2506 in->setDescription("");
2503 } else { 2507 } else {
2504 in->setSummary( in->description().left(20)); 2508 in->setSummary( in->description().left(20));
2505 in->setDescription(""); 2509 in->setDescription("");
2506 } 2510 }
2507 if ( addText ) 2511 if ( addText )
2508 description += in->summary() + "\n"; 2512 description += in->summary() + "\n";
2509 cal->addIncidence( in ); 2513 cal->addIncidence( in );
2510 incidence = delSel.next(); 2514 incidence = delSel.next();
2511 } 2515 }
2512 if ( beamDialog->beamVcal() ) { 2516 if ( beamDialog->beamVcal() ) {
2513 fn += ".vcs"; 2517 fn += ".vcs";
2514 FileStorage storage( cal, fn, new VCalFormat ); 2518 FileStorage storage( cal, fn, new VCalFormat );
2515 storage.save(); 2519 storage.save();
2516 } else { 2520 } else {
2517 fn += ".ics"; 2521 fn += ".ics";
2518 FileStorage storage( cal, fn, new ICalFormat( ) ); 2522 FileStorage storage( cal, fn, new ICalFormat( ) );
2519 storage.save(); 2523 storage.save();
2520 } 2524 }
2521 delete cal; 2525 delete cal;
2522 mes = i18n("KO/Pi: Ready for beaming"); 2526 mes = i18n("KO/Pi: Ready for beaming");
2523 topLevelWidget()->setCaption(mes); 2527 topLevelWidget()->setCaption(mes);
2524 KApplication::convert2latin1( fn ); 2528 KApplication::convert2latin1( fn );
2525#ifndef DESKTOP_VERSION 2529#ifndef DESKTOP_VERSION
2526 Ir *ir = new Ir( this ); 2530 Ir *ir = new Ir( this );
2527 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2531 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2528 ir->send( fn, description, "text/x-vCalendar" ); 2532 ir->send( fn, description, "text/x-vCalendar" );
2529#endif 2533#endif
2530 } 2534 }
2531} 2535}
2532void CalendarView::beamDone( Ir *ir ) 2536void CalendarView::beamDone( Ir *ir )
2533{ 2537{
2534#ifndef DESKTOP_VERSION 2538#ifndef DESKTOP_VERSION
2535 delete ir; 2539 delete ir;
2536#endif 2540#endif
2537 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2541 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2538 topLevelWidget()->raise(); 2542 topLevelWidget()->raise();
2539} 2543}
2540 2544
2541void CalendarView::moveIncidence(Incidence * inc ) 2545void CalendarView::moveIncidence(Incidence * inc )
2542{ 2546{
2543 if ( !inc ) return; 2547 if ( !inc ) return;
2544 showDatePickerPopup(); 2548 showDatePickerPopup();
2545 mDatePickerMode = 2; 2549 mDatePickerMode = 2;
2546 mMoveIncidence = inc ; 2550 mMoveIncidence = inc ;
2547 QDate da; 2551 QDate da;
2548 if ( mMoveIncidence->type() == "Todo" ) { 2552 if ( mMoveIncidence->type() == "Todo" ) {
2549 Todo * to = (Todo *) mMoveIncidence; 2553 Todo * to = (Todo *) mMoveIncidence;
2550 if ( to->hasDueDate() ) 2554 if ( to->hasDueDate() )
2551 da = to->dtDue().date(); 2555 da = to->dtDue().date();
2552 else 2556 else
2553 da = QDate::currentDate(); 2557 da = QDate::currentDate();
2554 } else { 2558 } else {
2555 da = mMoveIncidence->dtStart().date(); 2559 da = mMoveIncidence->dtStart().date();
2556 } 2560 }
2557 //PENDING set date for recurring incidence to date of recurrence 2561 //PENDING set date for recurring incidence to date of recurrence
2558 //mMoveIncidenceOldDate; 2562 //mMoveIncidenceOldDate;
2559 mDatePicker->setDate( da ); 2563 mDatePicker->setDate( da );
2560} 2564}
2561void CalendarView::showDatePickerPopup() 2565void CalendarView::showDatePickerPopup()
2562{ 2566{
2563 if ( mDateFrame->isVisible() ) 2567 if ( mDateFrame->isVisible() )
2564 mDateFrame->hide(); 2568 mDateFrame->hide();
2565 else { 2569 else {
2566 int offX = 0, offY = 0; 2570 int offX = 0, offY = 0;
2567#ifdef DESKTOP_VERSION 2571#ifdef DESKTOP_VERSION
2568 int w =mDatePicker->sizeHint().width() ; 2572 int w =mDatePicker->sizeHint().width() ;
2569 int h = mDatePicker->sizeHint().height() ; 2573 int h = mDatePicker->sizeHint().height() ;
2570 int dw = topLevelWidget()->width(); 2574 int dw = topLevelWidget()->width();
2571 int dh = topLevelWidget()->height(); 2575 int dh = topLevelWidget()->height();
2572 offX = topLevelWidget()->x(); 2576 offX = topLevelWidget()->x();
2573 offY = topLevelWidget()->y(); 2577 offY = topLevelWidget()->y();
2574#else 2578#else
2575 int w =mDatePicker->sizeHint().width() ; 2579 int w =mDatePicker->sizeHint().width() ;
2576 int h = mDatePicker->sizeHint().height() ; 2580 int h = mDatePicker->sizeHint().height() ;
2577 int dw = QApplication::desktop()->width(); 2581 int dw = QApplication::desktop()->width();
2578 int dh = QApplication::desktop()->height(); 2582 int dh = QApplication::desktop()->height();
2579#endif 2583#endif
2580 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2584 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2581 mDateFrame->show(); 2585 mDateFrame->show();
2582 } 2586 }
2583} 2587}
2584void CalendarView::showDatePicker( ) 2588void CalendarView::showDatePicker( )
2585{ 2589{
2586 showDatePickerPopup(); 2590 showDatePickerPopup();
2587 mDatePickerMode = 1; 2591 mDatePickerMode = 1;
2588 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2592 mDatePicker->setDate( mNavigator->selectedDates().first() );
2589} 2593}
2590 2594
2591void CalendarView::showEventEditor() 2595void CalendarView::showEventEditor()
2592{ 2596{
2593#ifdef DESKTOP_VERSION 2597#ifdef DESKTOP_VERSION
2594 int x,y,w,h; 2598 int x,y,w,h;
2595 x = mEventEditor->geometry().x(); 2599 x = mEventEditor->geometry().x();
2596 y = mEventEditor->geometry().y(); 2600 y = mEventEditor->geometry().y();
2597 w = mEventEditor->width(); 2601 w = mEventEditor->width();
2598 h = mEventEditor->height(); 2602 h = mEventEditor->height();
2599 mEventEditor->show(); 2603 mEventEditor->show();
2600 mEventEditor->setGeometry(x,y,w,h); 2604 mEventEditor->setGeometry(x,y,w,h);
2601#else 2605#else
2602 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2606 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2603 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2607 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2604 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2608 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2605 qApp->processEvents(); 2609 qApp->processEvents();
2606 delete mEventEditor; 2610 delete mEventEditor;
2607 mEventEditor = mDialogManager->getEventEditor(); 2611 mEventEditor = mDialogManager->getEventEditor();
2608 topLevelWidget()->setCaption( i18n("") ); 2612 topLevelWidget()->setCaption( i18n("") );
2609 } 2613 }
2610 mEventEditor->showMaximized(); 2614 mEventEditor->showMaximized();
2611#endif 2615#endif
2612} 2616}
2613void CalendarView::showTodoEditor() 2617void CalendarView::showTodoEditor()
2614{ 2618{
2615#ifdef DESKTOP_VERSION 2619#ifdef DESKTOP_VERSION
2616 int x,y,w,h; 2620 int x,y,w,h;
2617 x = mTodoEditor->geometry().x(); 2621 x = mTodoEditor->geometry().x();
2618 y = mTodoEditor->geometry().y(); 2622 y = mTodoEditor->geometry().y();
2619 w = mTodoEditor->width(); 2623 w = mTodoEditor->width();
2620 h = mTodoEditor->height(); 2624 h = mTodoEditor->height();
2621 mTodoEditor->show(); 2625 mTodoEditor->show();
2622 mTodoEditor->setGeometry(x,y,w,h); 2626 mTodoEditor->setGeometry(x,y,w,h);
2623#else 2627#else
2624 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2628 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2625 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2629 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2626 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2630 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2627 qApp->processEvents(); 2631 qApp->processEvents();
2628 delete mTodoEditor; 2632 delete mTodoEditor;
2629 mTodoEditor = mDialogManager->getTodoEditor(); 2633 mTodoEditor = mDialogManager->getTodoEditor();
2630 topLevelWidget()->setCaption( i18n("") ); 2634 topLevelWidget()->setCaption( i18n("") );
2631 } 2635 }
2632 mTodoEditor->showMaximized(); 2636 mTodoEditor->showMaximized();
2633#endif 2637#endif
2634} 2638}
2635 2639
2636void CalendarView::cloneIncidence() 2640void CalendarView::cloneIncidence()
2637{ 2641{
2638 Incidence *incidence = currentSelection(); 2642 Incidence *incidence = currentSelection();
2639 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2643 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2640 if ( incidence ) { 2644 if ( incidence ) {
2641 cloneIncidence(incidence); 2645 cloneIncidence(incidence);
2642 } 2646 }
2643} 2647}
2644void CalendarView::moveIncidence() 2648void CalendarView::moveIncidence()
2645{ 2649{
2646 Incidence *incidence = currentSelection(); 2650 Incidence *incidence = currentSelection();
2647 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2651 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2648 if ( incidence ) { 2652 if ( incidence ) {
2649 moveIncidence(incidence); 2653 moveIncidence(incidence);
2650 } 2654 }
2651} 2655}
2652void CalendarView::beamIncidence() 2656void CalendarView::beamIncidence()
2653{ 2657{
2654 Incidence *incidence = currentSelection(); 2658 Incidence *incidence = currentSelection();
2655 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2659 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2656 if ( incidence ) { 2660 if ( incidence ) {
2657 beamIncidence(incidence); 2661 beamIncidence(incidence);
2658 } 2662 }
2659} 2663}
2660void CalendarView::toggleCancelIncidence() 2664void CalendarView::toggleCancelIncidence()
2661{ 2665{
2662 Incidence *incidence = currentSelection(); 2666 Incidence *incidence = currentSelection();
2663 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2667 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2664 if ( incidence ) { 2668 if ( incidence ) {
2665 cancelIncidence(incidence); 2669 cancelIncidence(incidence);
2666 } 2670 }
2667} 2671}
2668 2672
2669 2673
2670void CalendarView::cancelIncidence(Incidence * inc ) 2674void CalendarView::cancelIncidence(Incidence * inc )
2671{ 2675{
2672 inc->setCancelled( ! inc->cancelled() ); 2676 inc->setCancelled( ! inc->cancelled() );
2673 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2677 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2674 updateView(); 2678 updateView();
2675} 2679}
2676void CalendarView::cloneIncidence(Incidence * orgInc ) 2680void CalendarView::cloneIncidence(Incidence * orgInc )
2677{ 2681{
2678 Incidence * newInc = orgInc->clone(); 2682 Incidence * newInc = orgInc->clone();
2679 newInc->recreate(); 2683 newInc->recreate();
2680 2684
2681 if ( newInc->type() == "Todo" ) { 2685 if ( newInc->type() == "Todo" ) {
2682 Todo* t = (Todo*) newInc; 2686 Todo* t = (Todo*) newInc;
2683 showTodoEditor(); 2687 showTodoEditor();
2684 mTodoEditor->editTodo( t ); 2688 mTodoEditor->editTodo( t );
2685 if ( mTodoEditor->exec() ) { 2689 if ( mTodoEditor->exec() ) {
2686 mCalendar->addTodo( t ); 2690 mCalendar->addTodo( t );
2687 updateView(); 2691 updateView();
2688 } else { 2692 } else {
2689 delete t; 2693 delete t;
2690 } 2694 }
2691 } 2695 }
2692 else { 2696 else {
2693 Event* e = (Event*) newInc; 2697 Event* e = (Event*) newInc;
2694 showEventEditor(); 2698 showEventEditor();
2695 mEventEditor->editEvent( e ); 2699 mEventEditor->editEvent( e );
2696 if ( mEventEditor->exec() ) { 2700 if ( mEventEditor->exec() ) {
2697 mCalendar->addEvent( e ); 2701 mCalendar->addEvent( e );
2698 updateView(); 2702 updateView();
2699 } else { 2703 } else {
2700 delete e; 2704 delete e;
2701 } 2705 }
2702 } 2706 }
2703 setActiveWindow(); 2707 setActiveWindow();
2704} 2708}
2705 2709
2706void CalendarView::newEvent() 2710void CalendarView::newEvent()
2707{ 2711{
2708 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2712 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2709 KOAgendaView *aView = mViewManager->agendaView(); 2713 KOAgendaView *aView = mViewManager->agendaView();
2710 if (aView) { 2714 if (aView) {
2711 if (aView->selectionStart().isValid()) { 2715 if (aView->selectionStart().isValid()) {
2712 if (aView->selectedIsAllDay()) { 2716 if (aView->selectedIsAllDay()) {
2713 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2717 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2714 } else { 2718 } else {
2715 newEvent(aView->selectionStart(),aView->selectionEnd()); 2719 newEvent(aView->selectionStart(),aView->selectionEnd());
2716 } 2720 }
2717 return; 2721 return;
2718 } 2722 }
2719 } 2723 }
2720 2724
2721 QDate date = mNavigator->selectedDates().first(); 2725 QDate date = mNavigator->selectedDates().first();
2722 QDateTime current = QDateTime::currentDateTime(); 2726 QDateTime current = QDateTime::currentDateTime();
2723 if ( date <= current.date() ) { 2727 if ( date <= current.date() ) {
2724 int hour = current.time().hour() +1; 2728 int hour = current.time().hour() +1;
2725 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2729 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2726 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2730 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2727 } else 2731 } else
2728 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2732 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2729 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2733 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2730 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2734 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2731} 2735}
2732 2736
2733void CalendarView::newEvent(QDateTime fh) 2737void CalendarView::newEvent(QDateTime fh)
2734{ 2738{
2735 newEvent(fh, 2739 newEvent(fh,
2736 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2740 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2737} 2741}
2738 2742
2739void CalendarView::newEvent(QDate dt) 2743void CalendarView::newEvent(QDate dt)
2740{ 2744{
2741 newEvent(QDateTime(dt, QTime(0,0,0)), 2745 newEvent(QDateTime(dt, QTime(0,0,0)),
2742 QDateTime(dt, QTime(0,0,0)), true); 2746 QDateTime(dt, QTime(0,0,0)), true);
2743} 2747}
2744void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2748void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2745{ 2749{
2746 newEvent(fromHint, toHint, false); 2750 newEvent(fromHint, toHint, false);
2747} 2751}
2748void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2752void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2749{ 2753{
2750 2754
2751 showEventEditor(); 2755 showEventEditor();
2752 mEventEditor->newEvent(fromHint,toHint,allDay); 2756 mEventEditor->newEvent(fromHint,toHint,allDay);
2753 if ( mFilterView->filtersEnabled() ) { 2757 if ( mFilterView->filtersEnabled() ) {
2754 CalFilter *filter = mFilterView->selectedFilter(); 2758 CalFilter *filter = mFilterView->selectedFilter();
2755 if (filter && filter->showCategories()) { 2759 if (filter && filter->showCategories()) {
2756 mEventEditor->setCategories(filter->categoryList().join(",") ); 2760 mEventEditor->setCategories(filter->categoryList().join(",") );
2757 } 2761 }
2758 if ( filter ) 2762 if ( filter )
2759 mEventEditor->setSecrecy( filter->getSecrecy() ); 2763 mEventEditor->setSecrecy( filter->getSecrecy() );
2760 } 2764 }
2761 mEventEditor->exec(); 2765 mEventEditor->exec();
2762 setActiveWindow(); 2766 setActiveWindow();
2763} 2767}
2764void CalendarView::todoAdded(Todo * t) 2768void CalendarView::todoAdded(Todo * t)
2765{ 2769{
2766 2770
2767 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2771 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2768 updateTodoViews(); 2772 updateTodoViews();
2769} 2773}
2770void CalendarView::todoChanged(Todo * t) 2774void CalendarView::todoChanged(Todo * t)
2771{ 2775{
2772 emit todoModified( t, 4 ); 2776 emit todoModified( t, 4 );
2773 // updateTodoViews(); 2777 // updateTodoViews();
2774} 2778}
2775void CalendarView::todoToBeDeleted(Todo *) 2779void CalendarView::todoToBeDeleted(Todo *)
2776{ 2780{
2777 //qDebug("todoToBeDeleted(Todo *) "); 2781 //qDebug("todoToBeDeleted(Todo *) ");
2778 updateTodoViews(); 2782 updateTodoViews();
2779} 2783}
2780void CalendarView::todoDeleted() 2784void CalendarView::todoDeleted()
2781{ 2785{
2782 //qDebug(" todoDeleted()"); 2786 //qDebug(" todoDeleted()");
2783 updateTodoViews(); 2787 updateTodoViews();
2784} 2788}
2785 2789
2786 2790
2787void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2791void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2788{ 2792{
2789 showTodoEditor(); 2793 showTodoEditor();
2790 mTodoEditor->newTodo(dt,0,allday); 2794 mTodoEditor->newTodo(dt,0,allday);
2791 if ( mFilterView->filtersEnabled() ) { 2795 if ( mFilterView->filtersEnabled() ) {
2792 CalFilter *filter = mFilterView->selectedFilter(); 2796 CalFilter *filter = mFilterView->selectedFilter();
2793 if (filter && filter->showCategories()) { 2797 if (filter && filter->showCategories()) {
2794 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2798 mTodoEditor->setCategories(filter->categoryList().join(",") );
2795 } 2799 }
2796 if ( filter ) 2800 if ( filter )
2797 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2801 mTodoEditor->setSecrecy( filter->getSecrecy() );
2798 } 2802 }
2799 mTodoEditor->exec(); 2803 mTodoEditor->exec();
2800 setActiveWindow(); 2804 setActiveWindow();
2801} 2805}
2802 2806
2803void CalendarView::newTodo() 2807void CalendarView::newTodo()
2804{ 2808{
2805 newTodoDateTime( QDateTime(),true ); 2809 newTodoDateTime( QDateTime(),true );
2806} 2810}
2807 2811
2808void CalendarView::newSubTodo() 2812void CalendarView::newSubTodo()
2809{ 2813{
2810 Todo *todo = selectedTodo(); 2814 Todo *todo = selectedTodo();
2811 if ( todo ) newSubTodo( todo ); 2815 if ( todo ) newSubTodo( todo );
2812} 2816}
2813 2817
2814void CalendarView::newSubTodo(Todo *parentEvent) 2818void CalendarView::newSubTodo(Todo *parentEvent)
2815{ 2819{
2816 2820
2817 showTodoEditor(); 2821 showTodoEditor();
2818 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2822 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2819 mTodoEditor->exec(); 2823 mTodoEditor->exec();
2820 setActiveWindow(); 2824 setActiveWindow();
2821} 2825}
2822 2826
2823void CalendarView::newFloatingEvent() 2827void CalendarView::newFloatingEvent()
2824{ 2828{
2825 DateList tmpList = mNavigator->selectedDates(); 2829 DateList tmpList = mNavigator->selectedDates();
2826 QDate date = tmpList.first(); 2830 QDate date = tmpList.first();
2827 2831
2828 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2832 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2829 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2833 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2830} 2834}
2831 2835
2832 2836
2833void CalendarView::editEvent( Event *event ) 2837void CalendarView::editEvent( Event *event )
2834{ 2838{
2835 2839
2836 if ( !event ) return; 2840 if ( !event ) return;
2837 if ( event->isReadOnly() ) { 2841 if ( event->isReadOnly() ) {
2838 showEvent( event ); 2842 showEvent( event );
2839 return; 2843 return;
2840 } 2844 }
2841 showEventEditor(); 2845 showEventEditor();
2842 mEventEditor->editEvent( event , mFlagEditDescription); 2846 mEventEditor->editEvent( event , mFlagEditDescription);
2843 mEventEditor->exec(); 2847 mEventEditor->exec();
2844 setActiveWindow(); 2848 setActiveWindow();
2845 2849
2846} 2850}
2847void CalendarView::editJournal( Journal *jour ) 2851void CalendarView::editJournal( Journal *jour )
2848{ 2852{
2849 if ( !jour ) return; 2853 if ( !jour ) return;
2850 mDialogManager->hideSearchDialog(); 2854 mDialogManager->hideSearchDialog();
2851 mViewManager->showJournalView(); 2855 mViewManager->showJournalView();
2852 mNavigator->slotDaySelect( jour->dtStart().date() ); 2856 mNavigator->slotDaySelect( jour->dtStart().date() );
2853} 2857}
2854void CalendarView::editTodo( Todo *todo ) 2858void CalendarView::editTodo( Todo *todo )
2855{ 2859{
2856 if ( !todo ) return; 2860 if ( !todo ) return;
2857 2861
2858 if ( todo->isReadOnly() ) { 2862 if ( todo->isReadOnly() ) {
2859 showTodo( todo ); 2863 showTodo( todo );
2860 return; 2864 return;
2861 } 2865 }
2862 showTodoEditor(); 2866 showTodoEditor();
2863 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2867 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2864 mTodoEditor->exec(); 2868 mTodoEditor->exec();
2865 setActiveWindow(); 2869 setActiveWindow();
2866 2870
2867} 2871}
2868 2872
2869KOEventViewerDialog* CalendarView::getEventViewerDialog() 2873KOEventViewerDialog* CalendarView::getEventViewerDialog()
2870{ 2874{
2871 if ( !mEventViewerDialog ) { 2875 if ( !mEventViewerDialog ) {
2872 mEventViewerDialog = new KOEventViewerDialog(0); 2876 mEventViewerDialog = new KOEventViewerDialog(0);
2873 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2877 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2874 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2878 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2875 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2879 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2876 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2880 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2877 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2881 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2878 viewManager(), SLOT( showAgendaView( bool ) ) ); 2882 viewManager(), SLOT( showAgendaView( bool ) ) );
2879 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 2883 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2880 this, SLOT( slotViewerClosed() ) ); 2884 this, SLOT( slotViewerClosed() ) );
2881 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2885 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2882 this, SLOT( todoChanged(Todo *) ) ); 2886 this, SLOT( todoChanged(Todo *) ) );
2883 mEventViewerDialog->resize( 640, 480 ); 2887 mEventViewerDialog->resize( 640, 480 );
2884 2888
2885 } 2889 }
2886 return mEventViewerDialog; 2890 return mEventViewerDialog;
2887} 2891}
2888void CalendarView::showEvent(Event *event) 2892void CalendarView::showEvent(Event *event)
2889{ 2893{
2890 getEventViewerDialog()->setEvent(event); 2894 getEventViewerDialog()->setEvent(event);
2891 getEventViewerDialog()->showMe(); 2895 getEventViewerDialog()->showMe();
2892} 2896}
2893 2897
2894void CalendarView::showTodo(Todo *event) 2898void CalendarView::showTodo(Todo *event)
2895{ 2899{
2896 getEventViewerDialog()->setTodo(event); 2900 getEventViewerDialog()->setTodo(event);
2897 getEventViewerDialog()->showMe(); 2901 getEventViewerDialog()->showMe();
2898} 2902}
2899void CalendarView::showJournal( Journal *jour ) 2903void CalendarView::showJournal( Journal *jour )
2900{ 2904{
2901 getEventViewerDialog()->setJournal(jour); 2905 getEventViewerDialog()->setJournal(jour);
2902 getEventViewerDialog()->showMe(); 2906 getEventViewerDialog()->showMe();
2903 2907
2904} 2908}
2905// void CalendarView::todoModified (Todo *event, int changed) 2909// void CalendarView::todoModified (Todo *event, int changed)
2906// { 2910// {
2907// // if (mDialogList.find (event) != mDialogList.end ()) { 2911// // if (mDialogList.find (event) != mDialogList.end ()) {
2908// // kdDebug() << "Todo modified and open" << endl; 2912// // kdDebug() << "Todo modified and open" << endl;
2909// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2913// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2910// // temp->modified (changed); 2914// // temp->modified (changed);
2911 2915
2912// // } 2916// // }
2913 2917
2914// mViewManager->updateView(); 2918// mViewManager->updateView();
2915// } 2919// }
2916 2920
2917void CalendarView::appointment_show() 2921void CalendarView::appointment_show()
2918{ 2922{
2919 Event *anEvent = 0; 2923 Event *anEvent = 0;
2920 2924
2921 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2925 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2922 2926
2923 if (mViewManager->currentView()->isEventView()) { 2927 if (mViewManager->currentView()->isEventView()) {
2924 if ( incidence && incidence->type() == "Event" ) { 2928 if ( incidence && incidence->type() == "Event" ) {
2925 anEvent = static_cast<Event *>(incidence); 2929 anEvent = static_cast<Event *>(incidence);
2926 } 2930 }
2927 } 2931 }
2928 2932
2929 if (!anEvent) { 2933 if (!anEvent) {
2930 KNotifyClient::beep(); 2934 KNotifyClient::beep();
2931 return; 2935 return;
2932 } 2936 }
2933 2937
2934 showEvent(anEvent); 2938 showEvent(anEvent);
2935} 2939}
2936 2940
2937void CalendarView::appointment_edit() 2941void CalendarView::appointment_edit()
2938{ 2942{
2939 Event *anEvent = 0; 2943 Event *anEvent = 0;
2940 2944
2941 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2945 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2942 2946
2943 if (mViewManager->currentView()->isEventView()) { 2947 if (mViewManager->currentView()->isEventView()) {
2944 if ( incidence && incidence->type() == "Event" ) { 2948 if ( incidence && incidence->type() == "Event" ) {
2945 anEvent = static_cast<Event *>(incidence); 2949 anEvent = static_cast<Event *>(incidence);
2946 } 2950 }
2947 } 2951 }
2948 2952
2949 if (!anEvent) { 2953 if (!anEvent) {
2950 KNotifyClient::beep(); 2954 KNotifyClient::beep();
2951 return; 2955 return;
2952 } 2956 }
2953 2957
2954 editEvent(anEvent); 2958 editEvent(anEvent);
2955} 2959}
2956 2960
2957void CalendarView::appointment_delete() 2961void CalendarView::appointment_delete()
2958{ 2962{
2959 Event *anEvent = 0; 2963 Event *anEvent = 0;
2960 2964
2961 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2965 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2962 2966
2963 if (mViewManager->currentView()->isEventView()) { 2967 if (mViewManager->currentView()->isEventView()) {
2964 if ( incidence && incidence->type() == "Event" ) { 2968 if ( incidence && incidence->type() == "Event" ) {
2965 anEvent = static_cast<Event *>(incidence); 2969 anEvent = static_cast<Event *>(incidence);
2966 } 2970 }
2967 } 2971 }
2968 2972
2969 if (!anEvent) { 2973 if (!anEvent) {
2970 KNotifyClient::beep(); 2974 KNotifyClient::beep();
2971 return; 2975 return;
2972 } 2976 }
2973 2977
2974 deleteEvent(anEvent); 2978 deleteEvent(anEvent);
2975} 2979}
2976 2980
2977void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2981void CalendarView::todo_resub( Todo * parent, Todo * sub )
2978{ 2982{
2979 if (!sub) return; 2983 if (!sub) return;
2980 if (!parent) return; 2984 if (!parent) return;
2981 if ( sub->relatedTo() ) 2985 if ( sub->relatedTo() )
2982 sub->relatedTo()->removeRelation(sub); 2986 sub->relatedTo()->removeRelation(sub);
2983 sub->setRelatedTo(parent); 2987 sub->setRelatedTo(parent);
2984 sub->setRelatedToUid(parent->uid()); 2988 sub->setRelatedToUid(parent->uid());
2985 parent->addRelation(sub); 2989 parent->addRelation(sub);
2986 sub->updated(); 2990 sub->updated();
2987 parent->updated(); 2991 parent->updated();
2988 setModified(true); 2992 setModified(true);
2989 updateView(); 2993 updateView();
2990} 2994}
2991void CalendarView::todo_unsub(Todo *anTodo ) 2995void CalendarView::todo_unsub(Todo *anTodo )
2992{ 2996{
2993 // Todo *anTodo = selectedTodo(); 2997 // Todo *anTodo = selectedTodo();
2994 if (!anTodo) return; 2998 if (!anTodo) return;
2995 if (!anTodo->relatedTo()) return; 2999 if (!anTodo->relatedTo()) return;
2996 anTodo->relatedTo()->removeRelation(anTodo); 3000 anTodo->relatedTo()->removeRelation(anTodo);
2997 anTodo->setRelatedTo(0); 3001 anTodo->setRelatedTo(0);
2998 anTodo->updated(); 3002 anTodo->updated();
2999 anTodo->setRelatedToUid(""); 3003 anTodo->setRelatedToUid("");
3000 setModified(true); 3004 setModified(true);
3001 updateView(); 3005 updateView();
3002} 3006}
3003 3007
3004void CalendarView::deleteTodo(Todo *todo) 3008void CalendarView::deleteTodo(Todo *todo)
3005{ 3009{
3006 if (!todo) { 3010 if (!todo) {
3007 KNotifyClient::beep(); 3011 KNotifyClient::beep();
3008 return; 3012 return;
3009 } 3013 }
3010 if (KOPrefs::instance()->mConfirm) { 3014 if (KOPrefs::instance()->mConfirm) {
3011 QString text = todo->summary().left(20); 3015 QString text = todo->summary().left(20);
3012 if (!todo->relations().isEmpty()) { 3016 if (!todo->relations().isEmpty()) {
3013 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3017 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3014 3018
3015 } 3019 }
3016 switch (msgItemDelete(text)) { 3020 switch (msgItemDelete(text)) {
3017 case KMessageBox::Continue: // OK 3021 case KMessageBox::Continue: // OK
3018 bool deleteT = false; 3022 bool deleteT = false;
3019 if (!todo->relations().isEmpty()) { 3023 if (!todo->relations().isEmpty()) {
3020 deleteT = removeCompletedSubTodos( todo ); 3024 deleteT = removeCompletedSubTodos( todo );
3021 } 3025 }
3022 // deleteT == true: todo already deleted in removeCompletedSubTodos 3026 // deleteT == true: todo already deleted in removeCompletedSubTodos
3023 if ( !deleteT ) { 3027 if ( !deleteT ) {
3024 checkExternalId( todo ); 3028 checkExternalId( todo );
3025 calendar()->deleteTodo(todo); 3029 calendar()->deleteTodo(todo);
3026 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3030 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3027 updateView(); 3031 updateView();
3028 } 3032 }
3029 break; 3033 break;
3030 } // switch 3034 } // switch
3031 } else { 3035 } else {
3032 checkExternalId( todo ); 3036 checkExternalId( todo );
3033 mCalendar->deleteTodo(todo); 3037 mCalendar->deleteTodo(todo);
3034 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3038 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3035 updateView(); 3039 updateView();
3036 } 3040 }
3037 3041
3038 emit updateSearchDialog(); 3042 emit updateSearchDialog();
3039} 3043}
3040void CalendarView::deleteJournal(Journal *jour) 3044void CalendarView::deleteJournal(Journal *jour)
3041{ 3045{
3042 if (!jour) { 3046 if (!jour) {
3043 KNotifyClient::beep(); 3047 KNotifyClient::beep();
3044 return; 3048 return;
3045 } 3049 }
3046 if (KOPrefs::instance()->mConfirm) { 3050 if (KOPrefs::instance()->mConfirm) {
3047 switch (msgItemDelete( jour->description().left(20))) { 3051 switch (msgItemDelete( jour->description().left(20))) {
3048 case KMessageBox::Continue: // OK 3052 case KMessageBox::Continue: // OK
3049 calendar()->deleteJournal(jour); 3053 calendar()->deleteJournal(jour);
3050 updateView(); 3054 updateView();
3051 break; 3055 break;
3052 } // switch 3056 } // switch
3053 } else { 3057 } else {
3054 calendar()->deleteJournal(jour);; 3058 calendar()->deleteJournal(jour);;
3055 updateView(); 3059 updateView();
3056 } 3060 }
3057 emit updateSearchDialog(); 3061 emit updateSearchDialog();
3058} 3062}
3059 3063
3060void CalendarView::deleteEvent(Event *anEvent) 3064void CalendarView::deleteEvent(Event *anEvent)
3061{ 3065{
3062 if (!anEvent) { 3066 if (!anEvent) {
3063 KNotifyClient::beep(); 3067 KNotifyClient::beep();
3064 return; 3068 return;
3065 } 3069 }
3066 3070
3067 if (anEvent->recurrence()->doesRecur()) { 3071 if (anEvent->recurrence()->doesRecur()) {
3068 QDate itemDate = mViewManager->currentSelectionDate(); 3072 QDate itemDate = mViewManager->currentSelectionDate();
3069 int km; 3073 int km;
3070 if (!itemDate.isValid()) { 3074 if (!itemDate.isValid()) {
3071 //kdDebug() << "Date Not Valid" << endl; 3075 //kdDebug() << "Date Not Valid" << endl;
3072 if (KOPrefs::instance()->mConfirm) { 3076 if (KOPrefs::instance()->mConfirm) {
3073 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3077 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3074 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3078 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3075 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3079 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3076 if ( km == KMessageBox::Continue ) 3080 if ( km == KMessageBox::Continue )
3077 km = KMessageBox::No; // No = all below 3081 km = KMessageBox::No; // No = all below
3078 } else 3082 } else
3079 km = KMessageBox::No; 3083 km = KMessageBox::No;
3080 } else { 3084 } else {
3081 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3085 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3082 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3086 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3083 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3087 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3084 i18n("KO/Pi Confirmation"),i18n("Current"), 3088 i18n("KO/Pi Confirmation"),i18n("Current"),
3085 i18n("All")); 3089 i18n("All"));
3086 } 3090 }
3087 switch(km) { 3091 switch(km) {
3088 3092
3089 case KMessageBox::No: // Continue // all 3093 case KMessageBox::No: // Continue // all
3090 //qDebug("KMessageBox::No "); 3094 //qDebug("KMessageBox::No ");
3091 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3095 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3092 schedule(Scheduler::Cancel,anEvent); 3096 schedule(Scheduler::Cancel,anEvent);
3093 3097
3094 checkExternalId( anEvent); 3098 checkExternalId( anEvent);
3095 mCalendar->deleteEvent(anEvent); 3099 mCalendar->deleteEvent(anEvent);
3096 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3100 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3097 break; 3101 break;
3098 3102
3099 // Disabled because it does not work 3103 // Disabled because it does not work
3100 //#if 0 3104 //#if 0
3101 case KMessageBox::Yes: // just this one 3105 case KMessageBox::Yes: // just this one
3102 //QDate qd = mNavigator->selectedDates().first(); 3106 //QDate qd = mNavigator->selectedDates().first();
3103 //if (!qd.isValid()) { 3107 //if (!qd.isValid()) {
3104 // kdDebug() << "no date selected, or invalid date" << endl; 3108 // kdDebug() << "no date selected, or invalid date" << endl;
3105 // KNotifyClient::beep(); 3109 // KNotifyClient::beep();
3106 // return; 3110 // return;
3107 //} 3111 //}
3108 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3112 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3109 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3113 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3110 anEvent->addExDate(itemDate); 3114 anEvent->addExDate(itemDate);
3111 int duration = anEvent->recurrence()->duration(); 3115 int duration = anEvent->recurrence()->duration();
3112 if ( duration > 0 ) { 3116 if ( duration > 0 ) {
3113 anEvent->recurrence()->setDuration( duration - 1 ); 3117 anEvent->recurrence()->setDuration( duration - 1 );
3114 } 3118 }
3115 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3119 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3116 } 3120 }
3117 break; 3121 break;
3118 //#endif 3122 //#endif
3119 } // switch 3123 } // switch
3120 } else { 3124 } else {
3121 if (KOPrefs::instance()->mConfirm) { 3125 if (KOPrefs::instance()->mConfirm) {
3122 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3126 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3123 i18n("\nAre you sure you want\nto delete this event?"), 3127 i18n("\nAre you sure you want\nto delete this event?"),
3124 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3128 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3125 case KMessageBox::Continue: // OK 3129 case KMessageBox::Continue: // OK
3126 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3130 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3127 schedule(Scheduler::Cancel,anEvent); 3131 schedule(Scheduler::Cancel,anEvent);
3128 checkExternalId( anEvent); 3132 checkExternalId( anEvent);
3129 mCalendar->deleteEvent(anEvent); 3133 mCalendar->deleteEvent(anEvent);
3130 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3134 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3131 break; 3135 break;
3132 } // switch 3136 } // switch
3133 } else { 3137 } else {
3134 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3138 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3135 schedule(Scheduler::Cancel,anEvent); 3139 schedule(Scheduler::Cancel,anEvent);
3136 checkExternalId( anEvent); 3140 checkExternalId( anEvent);
3137 mCalendar->deleteEvent(anEvent); 3141 mCalendar->deleteEvent(anEvent);
3138 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3142 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3139 } 3143 }
3140 } // if-else 3144 } // if-else
3141 emit updateSearchDialog(); 3145 emit updateSearchDialog();
3142} 3146}
3143 3147
3144bool CalendarView::deleteEvent(const QString &uid) 3148bool CalendarView::deleteEvent(const QString &uid)
3145{ 3149{
3146 Event *ev = mCalendar->event(uid); 3150 Event *ev = mCalendar->event(uid);
3147 if (ev) { 3151 if (ev) {
3148 deleteEvent(ev); 3152 deleteEvent(ev);
3149 return true; 3153 return true;
3150 } else { 3154 } else {
3151 return false; 3155 return false;
3152 } 3156 }
3153} 3157}
3154 3158
3155/*****************************************************************************/ 3159/*****************************************************************************/
3156 3160
3157void CalendarView::action_mail() 3161void CalendarView::action_mail()
3158{ 3162{
3159#ifndef KORG_NOMAIL 3163#ifndef KORG_NOMAIL
3160 KOMailClient mailClient; 3164 KOMailClient mailClient;
3161 3165
3162 Incidence *incidence = currentSelection(); 3166 Incidence *incidence = currentSelection();
3163 3167
3164 if (!incidence) { 3168 if (!incidence) {
3165 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3169 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3166 return; 3170 return;
3167 } 3171 }
3168 if(incidence->attendeeCount() == 0 ) { 3172 if(incidence->attendeeCount() == 0 ) {
3169 KMessageBox::sorry(this, 3173 KMessageBox::sorry(this,
3170 i18n("Can't generate mail:\nNo attendees defined.\n")); 3174 i18n("Can't generate mail:\nNo attendees defined.\n"));
3171 return; 3175 return;
3172 } 3176 }
3173 3177
3174 CalendarLocal cal_tmp; 3178 CalendarLocal cal_tmp;
3175 Event *event = 0; 3179 Event *event = 0;
3176 Event *ev = 0; 3180 Event *ev = 0;
3177 if ( incidence && incidence->type() == "Event" ) { 3181 if ( incidence && incidence->type() == "Event" ) {
3178 event = static_cast<Event *>(incidence); 3182 event = static_cast<Event *>(incidence);
3179 ev = new Event(*event); 3183 ev = new Event(*event);
3180 cal_tmp.addEvent(ev); 3184 cal_tmp.addEvent(ev);
3181 } 3185 }
3182 ICalFormat mForm(); 3186 ICalFormat mForm();
3183 QString attachment = mForm.toString( &cal_tmp ); 3187 QString attachment = mForm.toString( &cal_tmp );
3184 if (ev) delete(ev); 3188 if (ev) delete(ev);
3185 3189
3186 mailClient.mailAttendees(currentSelection(), attachment); 3190 mailClient.mailAttendees(currentSelection(), attachment);
3187 3191
3188#endif 3192#endif
3189 3193
3190#if 0 3194#if 0
3191 Event *anEvent = 0; 3195 Event *anEvent = 0;
3192 if (mViewManager->currentView()->isEventView()) { 3196 if (mViewManager->currentView()->isEventView()) {
3193 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3197 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3194 } 3198 }
3195 3199
3196 if (!anEvent) { 3200 if (!anEvent) {
3197 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3201 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3198 return; 3202 return;
3199 } 3203 }
3200 if(anEvent->attendeeCount() == 0 ) { 3204 if(anEvent->attendeeCount() == 0 ) {
3201 KMessageBox::sorry(this, 3205 KMessageBox::sorry(this,
3202 i18n("Can't generate mail:\nNo attendees defined.\n")); 3206 i18n("Can't generate mail:\nNo attendees defined.\n"));
3203 return; 3207 return;
3204 } 3208 }
3205 3209
3206 mailobject.emailEvent(anEvent); 3210 mailobject.emailEvent(anEvent);
3207#endif 3211#endif
3208} 3212}
3209 3213
3210 3214
3211void CalendarView::schedule_publish(Incidence *incidence) 3215void CalendarView::schedule_publish(Incidence *incidence)
3212{ 3216{
3213 Event *event = 0; 3217 Event *event = 0;
3214 Todo *todo = 0; 3218 Todo *todo = 0;
3215 3219
3216 if (incidence == 0) { 3220 if (incidence == 0) {
3217 incidence = mViewManager->currentView()->selectedIncidences().first(); 3221 incidence = mViewManager->currentView()->selectedIncidences().first();
3218 if (incidence == 0) { 3222 if (incidence == 0) {
3219 incidence = mTodoList->selectedIncidences().first(); 3223 incidence = mTodoList->selectedIncidences().first();
3220 } 3224 }
3221 } 3225 }
3222 if ( incidence && incidence->type() == "Event" ) { 3226 if ( incidence && incidence->type() == "Event" ) {
3223 event = static_cast<Event *>(incidence); 3227 event = static_cast<Event *>(incidence);
3224 } else { 3228 } else {
3225 if ( incidence && incidence->type() == "Todo" ) { 3229 if ( incidence && incidence->type() == "Todo" ) {
3226 todo = static_cast<Todo *>(incidence); 3230 todo = static_cast<Todo *>(incidence);
3227 } 3231 }
3228 } 3232 }
3229 3233
3230 if (!event && !todo) { 3234 if (!event && !todo) {
3231 KMessageBox::sorry(this,i18n("No event selected.")); 3235 KMessageBox::sorry(this,i18n("No event selected."));
3232 return; 3236 return;
3233 } 3237 }
3234 3238
3235 PublishDialog *publishdlg = new PublishDialog(); 3239 PublishDialog *publishdlg = new PublishDialog();
3236 if (incidence->attendeeCount()>0) { 3240 if (incidence->attendeeCount()>0) {
3237 QPtrList<Attendee> attendees = incidence->attendees(); 3241 QPtrList<Attendee> attendees = incidence->attendees();
3238 attendees.first(); 3242 attendees.first();
3239 while ( attendees.current()!=0 ) { 3243 while ( attendees.current()!=0 ) {
3240 publishdlg->addAttendee(attendees.current()); 3244 publishdlg->addAttendee(attendees.current());
3241 attendees.next(); 3245 attendees.next();
3242 } 3246 }
3243 } 3247 }
3244 bool send = true; 3248 bool send = true;
3245 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3249 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3246 if ( publishdlg->exec() != QDialog::Accepted ) 3250 if ( publishdlg->exec() != QDialog::Accepted )
3247 send = false; 3251 send = false;
3248 } 3252 }
3249 if ( send ) { 3253 if ( send ) {
3250 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3254 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3251 if ( event ) { 3255 if ( event ) {
3252 Event *ev = new Event(*event); 3256 Event *ev = new Event(*event);
3253 ev->registerObserver(0); 3257 ev->registerObserver(0);
3254 ev->clearAttendees(); 3258 ev->clearAttendees();
3255 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3259 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3256 delete(ev); 3260 delete(ev);
3257 } 3261 }
3258 } else { 3262 } else {
3259 if ( todo ) { 3263 if ( todo ) {
3260 Todo *ev = new Todo(*todo); 3264 Todo *ev = new Todo(*todo);
3261 ev->registerObserver(0); 3265 ev->registerObserver(0);
3262 ev->clearAttendees(); 3266 ev->clearAttendees();
3263 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3267 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3264 delete(ev); 3268 delete(ev);
3265 } 3269 }
3266 } 3270 }
3267 } 3271 }
3268 } 3272 }
3269 delete publishdlg; 3273 delete publishdlg;
3270} 3274}
3271 3275
3272void CalendarView::schedule_request(Incidence *incidence) 3276void CalendarView::schedule_request(Incidence *incidence)
3273{ 3277{
3274 schedule(Scheduler::Request,incidence); 3278 schedule(Scheduler::Request,incidence);
3275} 3279}
3276 3280
3277void CalendarView::schedule_refresh(Incidence *incidence) 3281void CalendarView::schedule_refresh(Incidence *incidence)
3278{ 3282{
3279 schedule(Scheduler::Refresh,incidence); 3283 schedule(Scheduler::Refresh,incidence);
3280} 3284}
3281 3285
3282void CalendarView::schedule_cancel(Incidence *incidence) 3286void CalendarView::schedule_cancel(Incidence *incidence)
3283{ 3287{
3284 schedule(Scheduler::Cancel,incidence); 3288 schedule(Scheduler::Cancel,incidence);
3285} 3289}
3286 3290
3287void CalendarView::schedule_add(Incidence *incidence) 3291void CalendarView::schedule_add(Incidence *incidence)
3288{ 3292{
3289 schedule(Scheduler::Add,incidence); 3293 schedule(Scheduler::Add,incidence);
3290} 3294}
3291 3295
3292void CalendarView::schedule_reply(Incidence *incidence) 3296void CalendarView::schedule_reply(Incidence *incidence)
3293{ 3297{
3294 schedule(Scheduler::Reply,incidence); 3298 schedule(Scheduler::Reply,incidence);
3295} 3299}
3296 3300
3297void CalendarView::schedule_counter(Incidence *incidence) 3301void CalendarView::schedule_counter(Incidence *incidence)
3298{ 3302{
3299 schedule(Scheduler::Counter,incidence); 3303 schedule(Scheduler::Counter,incidence);
3300} 3304}
3301 3305
3302void CalendarView::schedule_declinecounter(Incidence *incidence) 3306void CalendarView::schedule_declinecounter(Incidence *incidence)
3303{ 3307{
3304 schedule(Scheduler::Declinecounter,incidence); 3308 schedule(Scheduler::Declinecounter,incidence);
3305} 3309}
3306 3310
3307void CalendarView::schedule_publish_freebusy(int daysToPublish) 3311void CalendarView::schedule_publish_freebusy(int daysToPublish)
3308{ 3312{
3309 QDateTime start = QDateTime::currentDateTime(); 3313 QDateTime start = QDateTime::currentDateTime();
3310 QDateTime end = start.addDays(daysToPublish); 3314 QDateTime end = start.addDays(daysToPublish);
3311 3315
3312 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3316 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3313 freebusy->setOrganizer(KOPrefs::instance()->email()); 3317 freebusy->setOrganizer(KOPrefs::instance()->email());
3314 3318
3315 3319
3316 PublishDialog *publishdlg = new PublishDialog(); 3320 PublishDialog *publishdlg = new PublishDialog();
3317 if ( publishdlg->exec() == QDialog::Accepted ) { 3321 if ( publishdlg->exec() == QDialog::Accepted ) {
3318 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3322 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3319 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3323 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3320 delete(freebusy); 3324 delete(freebusy);
3321 } 3325 }
3322 } 3326 }
3323 delete publishdlg; 3327 delete publishdlg;
3324} 3328}
3325 3329
3326void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3330void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3327{ 3331{
3328 Event *event = 0; 3332 Event *event = 0;
3329 Todo *todo = 0; 3333 Todo *todo = 0;
3330 3334
3331 if (incidence == 0) { 3335 if (incidence == 0) {
3332 incidence = mViewManager->currentView()->selectedIncidences().first(); 3336 incidence = mViewManager->currentView()->selectedIncidences().first();
3333 if (incidence == 0) { 3337 if (incidence == 0) {
3334 incidence = mTodoList->selectedIncidences().first(); 3338 incidence = mTodoList->selectedIncidences().first();
3335 } 3339 }
3336 } 3340 }
3337 if ( incidence && incidence->type() == "Event" ) { 3341 if ( incidence && incidence->type() == "Event" ) {
3338 event = static_cast<Event *>(incidence); 3342 event = static_cast<Event *>(incidence);
3339 } 3343 }
3340 if ( incidence && incidence->type() == "Todo" ) { 3344 if ( incidence && incidence->type() == "Todo" ) {
3341 todo = static_cast<Todo *>(incidence); 3345 todo = static_cast<Todo *>(incidence);
3342 } 3346 }
3343 3347
3344 if (!event && !todo) { 3348 if (!event && !todo) {
3345 KMessageBox::sorry(this,i18n("No event selected.")); 3349 KMessageBox::sorry(this,i18n("No event selected."));
3346 return; 3350 return;
3347 } 3351 }
3348 3352
3349 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3353 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3350 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3354 KMessageBox::sorry(this,i18n("The event has no attendees."));
3351 return; 3355 return;
3352 } 3356 }
3353 3357
3354 Event *ev = 0; 3358 Event *ev = 0;
3355 if (event) ev = new Event(*event); 3359 if (event) ev = new Event(*event);
3356 Todo *to = 0; 3360 Todo *to = 0;
3357 if (todo) to = new Todo(*todo); 3361 if (todo) to = new Todo(*todo);
3358 3362
3359 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3363 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3360 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3364 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3361 if (!me) { 3365 if (!me) {
3362 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3366 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3363 return; 3367 return;
3364 } 3368 }
3365 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3369 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3366 StatusDialog *statdlg = new StatusDialog(this); 3370 StatusDialog *statdlg = new StatusDialog(this);
3367 if (!statdlg->exec()==QDialog::Accepted) return; 3371 if (!statdlg->exec()==QDialog::Accepted) return;
3368 me->setStatus( statdlg->status() ); 3372 me->setStatus( statdlg->status() );
3369 delete(statdlg); 3373 delete(statdlg);
3370 } 3374 }
3371 Attendee *menew = new Attendee(*me); 3375 Attendee *menew = new Attendee(*me);
3372 if (ev) { 3376 if (ev) {
3373 ev->clearAttendees(); 3377 ev->clearAttendees();
3374 ev->addAttendee(menew,false); 3378 ev->addAttendee(menew,false);
3375 } else { 3379 } else {
3376 if (to) { 3380 if (to) {
3377 todo->clearAttendees(); 3381 todo->clearAttendees();
3378 todo->addAttendee(menew,false); 3382 todo->addAttendee(menew,false);
3379 } 3383 }
3380 } 3384 }
3381 } 3385 }
3382 3386
3383 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3387 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3384 if (ev) { 3388 if (ev) {
3385 if ( !dlg->addMessage(ev,method) ) delete(ev); 3389 if ( !dlg->addMessage(ev,method) ) delete(ev);
3386 } else { 3390 } else {
3387 if (to) { 3391 if (to) {
3388 if ( !dlg->addMessage(to,method) ) delete(to); 3392 if ( !dlg->addMessage(to,method) ) delete(to);
3389 } 3393 }
3390 } 3394 }
3391} 3395}
3392 3396
3393void CalendarView::openAddressbook() 3397void CalendarView::openAddressbook()
3394{ 3398{
3395 KRun::runCommand("kaddressbook"); 3399 KRun::runCommand("kaddressbook");
3396} 3400}
3397 3401
3398void CalendarView::setModified(bool modified) 3402void CalendarView::setModified(bool modified)
3399{ 3403{
3400 if ( modified ) 3404 if ( modified )
3401 emit signalmodified(); 3405 emit signalmodified();
3402 if (mModified != modified) { 3406 if (mModified != modified) {
3403 mModified = modified; 3407 mModified = modified;
3404 emit modifiedChanged(mModified); 3408 emit modifiedChanged(mModified);
3405 } 3409 }
3406} 3410}
3407 3411
3408bool CalendarView::isReadOnly() 3412bool CalendarView::isReadOnly()
3409{ 3413{
3410 return mReadOnly; 3414 return mReadOnly;
3411} 3415}
3412 3416
3413void CalendarView::setReadOnly(bool readOnly) 3417void CalendarView::setReadOnly(bool readOnly)
3414{ 3418{
3415 if (mReadOnly != readOnly) { 3419 if (mReadOnly != readOnly) {
3416 mReadOnly = readOnly; 3420 mReadOnly = readOnly;
3417 emit readOnlyChanged(mReadOnly); 3421 emit readOnlyChanged(mReadOnly);
3418 } 3422 }
3419} 3423}
3420 3424
3421bool CalendarView::isModified() 3425bool CalendarView::isModified()
3422{ 3426{
3423 return mModified; 3427 return mModified;
3424} 3428}
3425 3429
3426void CalendarView::printSetup() 3430void CalendarView::printSetup()
3427{ 3431{
3428#ifndef KORG_NOPRINTER 3432#ifndef KORG_NOPRINTER
3429 createPrinter(); 3433 createPrinter();
3430 3434
3431 mCalPrinter->setupPrinter(); 3435 mCalPrinter->setupPrinter();
3432#endif 3436#endif
3433} 3437}
3434 3438
3435void CalendarView::print() 3439void CalendarView::print()
3436{ 3440{
3437#ifndef KORG_NOPRINTER 3441#ifndef KORG_NOPRINTER
3438 createPrinter(); 3442 createPrinter();
3439 3443
3440 DateList tmpDateList = mNavigator->selectedDates(); 3444 DateList tmpDateList = mNavigator->selectedDates();
3441 mCalPrinter->print(CalPrinter::Month, 3445 mCalPrinter->print(CalPrinter::Month,
3442 tmpDateList.first(), tmpDateList.last()); 3446 tmpDateList.first(), tmpDateList.last());
3443#endif 3447#endif
3444} 3448}
3445 3449
3446void CalendarView::printPreview() 3450void CalendarView::printPreview()
3447{ 3451{
3448#ifndef KORG_NOPRINTER 3452#ifndef KORG_NOPRINTER
3449 kdDebug() << "CalendarView::printPreview()" << endl; 3453 kdDebug() << "CalendarView::printPreview()" << endl;
3450 3454
3451 createPrinter(); 3455 createPrinter();
3452 3456
3453 DateList tmpDateList = mNavigator->selectedDates(); 3457 DateList tmpDateList = mNavigator->selectedDates();
3454 3458
3455 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3459 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3456 tmpDateList.last()); 3460 tmpDateList.last());
3457#endif 3461#endif
3458} 3462}
3459 3463
3460void CalendarView::exportICalendar() 3464void CalendarView::exportICalendar()
3461{ 3465{
3462 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3466 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3463 3467
3464 // Force correct extension 3468 // Force correct extension
3465 if (filename.right(4) != ".ics") filename += ".ics"; 3469 if (filename.right(4) != ".ics") filename += ".ics";
3466 3470
3467 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3471 FileStorage storage( mCalendar, filename, new ICalFormat() );
3468 storage.save(); 3472 storage.save();
3469} 3473}
3470 3474
3471bool CalendarView::exportVCalendar( QString filename ) 3475bool CalendarView::exportVCalendar( QString filename )
3472{ 3476{
3473 if (mCalendar->journals().count() > 0) { 3477 if (mCalendar->journals().count() > 0) {
3474 int result = KMessageBox::warningContinueCancel(this, 3478 int result = KMessageBox::warningContinueCancel(this,
3475 i18n("The journal entries can not be\nexported to a vCalendar file."), 3479 i18n("The journal entries can not be\nexported to a vCalendar file."),
3476 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3480 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3477 true); 3481 true);
3478 if (result != KMessageBox::Continue) return false; 3482 if (result != KMessageBox::Continue) return false;
3479 } 3483 }
3480 3484
3481 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3485 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3482 3486
3483 // Force correct extension 3487 // Force correct extension
3484 if (filename.right(4) != ".vcs") filename += ".vcs"; 3488 if (filename.right(4) != ".vcs") filename += ".vcs";
3485 3489
3486 FileStorage storage( mCalendar, filename, new VCalFormat ); 3490 FileStorage storage( mCalendar, filename, new VCalFormat );
3487 return storage.save(); 3491 return storage.save();
3488 3492
3489} 3493}
3490 3494
3491void CalendarView::eventUpdated(Incidence *) 3495void CalendarView::eventUpdated(Incidence *)
3492{ 3496{
3493 setModified(); 3497 setModified();
3494 // Don't call updateView here. The code, which has caused the update of the 3498 // Don't call updateView here. The code, which has caused the update of the
3495 // event is responsible for updating the view. 3499 // event is responsible for updating the view.
3496 // updateView(); 3500 // updateView();
3497} 3501}
3498 3502
3499void CalendarView::adaptNavigationUnits() 3503void CalendarView::adaptNavigationUnits()
3500{ 3504{
3501 if (mViewManager->currentView()->isEventView()) { 3505 if (mViewManager->currentView()->isEventView()) {
3502 int days = mViewManager->currentView()->currentDateCount(); 3506 int days = mViewManager->currentView()->currentDateCount();
3503 if (days == 1) { 3507 if (days == 1) {
3504 emit changeNavStringPrev(i18n("&Previous Day")); 3508 emit changeNavStringPrev(i18n("&Previous Day"));
3505 emit changeNavStringNext(i18n("&Next Day")); 3509 emit changeNavStringNext(i18n("&Next Day"));
3506 } else { 3510 } else {
3507 emit changeNavStringPrev(i18n("&Previous Week")); 3511 emit changeNavStringPrev(i18n("&Previous Week"));
3508 emit changeNavStringNext(i18n("&Next Week")); 3512 emit changeNavStringNext(i18n("&Next Week"));
3509 } 3513 }
3510 } 3514 }
3511} 3515}
3512 3516
3513void CalendarView::processMainViewSelection( Incidence *incidence ) 3517void CalendarView::processMainViewSelection( Incidence *incidence )
3514{ 3518{
3515 if ( incidence ) mTodoList->clearSelection(); 3519 if ( incidence ) mTodoList->clearSelection();
3516 processIncidenceSelection( incidence ); 3520 processIncidenceSelection( incidence );
3517} 3521}
3518 3522
3519void CalendarView::processTodoListSelection( Incidence *incidence ) 3523void CalendarView::processTodoListSelection( Incidence *incidence )
3520{ 3524{
3521 if ( incidence && mViewManager->currentView() ) { 3525 if ( incidence && mViewManager->currentView() ) {
3522 mViewManager->currentView()->clearSelection(); 3526 mViewManager->currentView()->clearSelection();
3523 } 3527 }
3524 processIncidenceSelection( incidence ); 3528 processIncidenceSelection( incidence );
3525} 3529}
3526 3530
3527void CalendarView::processIncidenceSelection( Incidence *incidence ) 3531void CalendarView::processIncidenceSelection( Incidence *incidence )
3528{ 3532{
3529 if ( incidence == mSelectedIncidence ) return; 3533 if ( incidence == mSelectedIncidence ) return;
3530 3534
3531 mSelectedIncidence = incidence; 3535 mSelectedIncidence = incidence;
3532 3536
3533 emit incidenceSelected( mSelectedIncidence ); 3537 emit incidenceSelected( mSelectedIncidence );
3534 3538
3535 if ( incidence && incidence->type() == "Event" ) { 3539 if ( incidence && incidence->type() == "Event" ) {
3536 Event *event = static_cast<Event *>( incidence ); 3540 Event *event = static_cast<Event *>( incidence );
3537 if ( event->organizer() == KOPrefs::instance()->email() ) { 3541 if ( event->organizer() == KOPrefs::instance()->email() ) {
3538 emit organizerEventsSelected( true ); 3542 emit organizerEventsSelected( true );
3539 } else { 3543 } else {
3540 emit organizerEventsSelected(false); 3544 emit organizerEventsSelected(false);
3541 } 3545 }
3542 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3546 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3543 KOPrefs::instance()->email() ) ) { 3547 KOPrefs::instance()->email() ) ) {
3544 emit groupEventsSelected( true ); 3548 emit groupEventsSelected( true );
3545 } else { 3549 } else {
3546 emit groupEventsSelected(false); 3550 emit groupEventsSelected(false);
3547 } 3551 }
3548 return; 3552 return;
3549 } else { 3553 } else {
3550 if ( incidence && incidence->type() == "Todo" ) { 3554 if ( incidence && incidence->type() == "Todo" ) {
3551 emit todoSelected( true ); 3555 emit todoSelected( true );
3552 Todo *event = static_cast<Todo *>( incidence ); 3556 Todo *event = static_cast<Todo *>( incidence );
3553 if ( event->organizer() == KOPrefs::instance()->email() ) { 3557 if ( event->organizer() == KOPrefs::instance()->email() ) {
3554 emit organizerEventsSelected( true ); 3558 emit organizerEventsSelected( true );
3555 } else { 3559 } else {
3556 emit organizerEventsSelected(false); 3560 emit organizerEventsSelected(false);
3557 } 3561 }
3558 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3562 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3559 KOPrefs::instance()->email() ) ) { 3563 KOPrefs::instance()->email() ) ) {
3560 emit groupEventsSelected( true ); 3564 emit groupEventsSelected( true );
3561 } else { 3565 } else {
3562 emit groupEventsSelected(false); 3566 emit groupEventsSelected(false);
3563 } 3567 }
3564 return; 3568 return;
3565 } else { 3569 } else {
3566 emit todoSelected( false ); 3570 emit todoSelected( false );
3567 emit organizerEventsSelected(false); 3571 emit organizerEventsSelected(false);
3568 emit groupEventsSelected(false); 3572 emit groupEventsSelected(false);
3569 } 3573 }
3570 return; 3574 return;
3571 } 3575 }
3572 3576
3573 /* if ( incidence && incidence->type() == "Todo" ) { 3577 /* if ( incidence && incidence->type() == "Todo" ) {
3574 emit todoSelected( true ); 3578 emit todoSelected( true );
3575 } else { 3579 } else {
3576 emit todoSelected( false ); 3580 emit todoSelected( false );
3577 }*/ 3581 }*/
3578} 3582}
3579 3583
3580 3584
3581void CalendarView::checkClipboard() 3585void CalendarView::checkClipboard()
3582{ 3586{
3583#ifndef KORG_NODND 3587#ifndef KORG_NODND
3584 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3588 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3585 emit pasteEnabled(true); 3589 emit pasteEnabled(true);
3586 } else { 3590 } else {
3587 emit pasteEnabled(false); 3591 emit pasteEnabled(false);
3588 } 3592 }
3589#endif 3593#endif
3590} 3594}
3591 3595
3592void CalendarView::showDates(const DateList &selectedDates) 3596void CalendarView::showDates(const DateList &selectedDates)
3593{ 3597{
3594 // kdDebug() << "CalendarView::selectDates()" << endl; 3598 // kdDebug() << "CalendarView::selectDates()" << endl;
3595 3599
3596 3600
3597 if ( !mBlockShowDates ) { 3601 if ( !mBlockShowDates ) {
3598 if ( mViewManager->currentView() ) { 3602 if ( mViewManager->currentView() ) {
3599 updateView( selectedDates.first(), selectedDates.last() ); 3603 updateView( selectedDates.first(), selectedDates.last() );
3600 } else { 3604 } else {
3601 mViewManager->showAgendaView(); 3605 mViewManager->showAgendaView();
3602 } 3606 }
3603 } 3607 }
3604 3608
3605 QString selDates; 3609 QString selDates;
3606 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3610 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3607 if (selectedDates.first() < selectedDates.last() ) 3611 if (selectedDates.first() < selectedDates.last() )
3608 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3612 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3609 else { 3613 else {
3610 QString addString; 3614 QString addString;
3611 if ( selectedDates.first() == QDateTime::currentDateTime().date() ) 3615 if ( selectedDates.first() == QDateTime::currentDateTime().date() )
3612 addString = i18n("Today"); 3616 addString = i18n("Today");
3613 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 3617 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
3614 addString = i18n("Tomorrow"); 3618 addString = i18n("Tomorrow");
3615 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 3619 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
3616 addString = i18n("Yesterday"); 3620 addString = i18n("Yesterday");
3617 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 3621 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
3618 addString = i18n("Day before yesterday"); 3622 addString = i18n("Day before yesterday");
3619 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 3623 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
3620 addString = i18n("Day after tomorrow"); 3624 addString = i18n("Day after tomorrow");
3621 if ( !addString.isEmpty() ) { 3625 if ( !addString.isEmpty() ) {
3622 topLevelWidget()->setCaption( addString+", " + selDates ); 3626 topLevelWidget()->setCaption( addString+", " + selDates );
3623 return; 3627 return;
3624 } 3628 }
3625 } 3629 }
3626 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3630 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3627 3631
3628} 3632}
3629 3633
3630QPtrList<CalFilter> CalendarView::filters() 3634QPtrList<CalFilter> CalendarView::filters()
3631{ 3635{
3632 return mFilters; 3636 return mFilters;
3633 3637
3634} 3638}
3635void CalendarView::editFilters() 3639void CalendarView::editFilters()
3636{ 3640{
3637 // kdDebug() << "CalendarView::editFilters()" << endl; 3641 // kdDebug() << "CalendarView::editFilters()" << endl;
3638 3642
3639 CalFilter *filter = mFilters.first(); 3643 CalFilter *filter = mFilters.first();
3640 while(filter) { 3644 while(filter) {
3641 kdDebug() << " Filter: " << filter->name() << endl; 3645 kdDebug() << " Filter: " << filter->name() << endl;
3642 filter = mFilters.next(); 3646 filter = mFilters.next();
3643 } 3647 }
3644 3648
3645 mDialogManager->showFilterEditDialog(&mFilters); 3649 mDialogManager->showFilterEditDialog(&mFilters);
3646} 3650}
3647void CalendarView::toggleFilter() 3651void CalendarView::toggleFilter()
3648{ 3652{
3649 showFilter(! mFilterView->isVisible()); 3653 showFilter(! mFilterView->isVisible());
3650} 3654}
3651 3655
3652KOFilterView *CalendarView::filterView() 3656KOFilterView *CalendarView::filterView()
3653{ 3657{
3654 return mFilterView; 3658 return mFilterView;
3655} 3659}
3656void CalendarView::selectFilter( int fil ) 3660void CalendarView::selectFilter( int fil )
3657{ 3661{
3658 mFilterView->setSelectedFilter( fil ); 3662 mFilterView->setSelectedFilter( fil );
3659} 3663}
3660void CalendarView::showFilter(bool visible) 3664void CalendarView::showFilter(bool visible)
3661{ 3665{
3662 if (visible) mFilterView->show(); 3666 if (visible) mFilterView->show();
3663 else mFilterView->hide(); 3667 else mFilterView->hide();
3664} 3668}
3665void CalendarView::toggleFilerEnabled( ) 3669void CalendarView::toggleFilerEnabled( )
3666{ 3670{
3667 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3671 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3668 if ( !mFilterView->filtersEnabled() ) 3672 if ( !mFilterView->filtersEnabled() )
3669 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3673 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3670 3674
3671} 3675}
3672void CalendarView::updateFilter() 3676void CalendarView::updateFilter()
3673{ 3677{
3674 CalFilter *filter = mFilterView->selectedFilter(); 3678 CalFilter *filter = mFilterView->selectedFilter();
3675 if (filter) { 3679 if (filter) {
3676 QString mess; 3680 QString mess;
3677 if (mFilterView->filtersEnabled()) { 3681 if (mFilterView->filtersEnabled()) {
3678 mess = i18n("Filter selected: ")+filter->name(); 3682 mess = i18n("Filter selected: ")+filter->name();
3679 filter->setEnabled(true); 3683 filter->setEnabled(true);
3680 } 3684 }
3681 else filter->setEnabled(false); 3685 else filter->setEnabled(false);
3682 mCalendar->setFilter(filter); 3686 mCalendar->setFilter(filter);
3683 updateView(); 3687 updateView();
3684 if ( !mess.isEmpty() ) 3688 if ( !mess.isEmpty() )
3685 topLevelWidget()->setCaption( mess ); 3689 topLevelWidget()->setCaption( mess );
3686 3690
3687 } 3691 }
3688} 3692}
3689 3693
3690void CalendarView::filterEdited() 3694void CalendarView::filterEdited()
3691{ 3695{
3692 mFilterView->updateFilters(); 3696 mFilterView->updateFilters();
3693 updateFilter(); 3697 updateFilter();
3694 writeSettings(); 3698 writeSettings();
3695} 3699}
3696 3700
3697 3701
3698void CalendarView::takeOverEvent() 3702void CalendarView::takeOverEvent()
3699{ 3703{
3700 Incidence *incidence = currentSelection(); 3704 Incidence *incidence = currentSelection();
3701 3705
3702 if (!incidence) return; 3706 if (!incidence) return;
3703 3707
3704 incidence->setOrganizer(KOPrefs::instance()->email()); 3708 incidence->setOrganizer(KOPrefs::instance()->email());
3705 incidence->recreate(); 3709 incidence->recreate();
3706 incidence->setReadOnly(false); 3710 incidence->setReadOnly(false);
3707 3711
3708 updateView(); 3712 updateView();
3709} 3713}
3710 3714
3711void CalendarView::takeOverCalendar() 3715void CalendarView::takeOverCalendar()
3712{ 3716{
3713 // TODO: Create Calendar::allIncidences() function and use it here 3717 // TODO: Create Calendar::allIncidences() function and use it here
3714 3718
3715 QPtrList<Event> events = mCalendar->events(); 3719 QPtrList<Event> events = mCalendar->events();
3716 for(uint i=0; i<events.count(); ++i) { 3720 for(uint i=0; i<events.count(); ++i) {
3717 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3721 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3718 events.at(i)->recreate(); 3722 events.at(i)->recreate();
3719 events.at(i)->setReadOnly(false); 3723 events.at(i)->setReadOnly(false);
3720 } 3724 }
3721 3725
3722 QPtrList<Todo> todos = mCalendar->todos(); 3726 QPtrList<Todo> todos = mCalendar->todos();
3723 for(uint i=0; i<todos.count(); ++i) { 3727 for(uint i=0; i<todos.count(); ++i) {
3724 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3728 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3725 todos.at(i)->recreate(); 3729 todos.at(i)->recreate();
3726 todos.at(i)->setReadOnly(false); 3730 todos.at(i)->setReadOnly(false);
3727 } 3731 }
3728 3732
3729 QPtrList<Journal> journals = mCalendar->journals(); 3733 QPtrList<Journal> journals = mCalendar->journals();
3730 for(uint i=0; i<journals.count(); ++i) { 3734 for(uint i=0; i<journals.count(); ++i) {
3731 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3735 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3732 journals.at(i)->recreate(); 3736 journals.at(i)->recreate();
3733 journals.at(i)->setReadOnly(false); 3737 journals.at(i)->setReadOnly(false);
3734 } 3738 }
3735 3739
3736 updateView(); 3740 updateView();
3737} 3741}
3738 3742
3739void CalendarView::showIntro() 3743void CalendarView::showIntro()
3740{ 3744{
3741 kdDebug() << "To be implemented." << endl; 3745 kdDebug() << "To be implemented." << endl;
3742} 3746}
3743 3747
3744QWidgetStack *CalendarView::viewStack() 3748QWidgetStack *CalendarView::viewStack()
3745{ 3749{
3746 return mRightFrame; 3750 return mRightFrame;
3747} 3751}
3748 3752
3749QWidget *CalendarView::leftFrame() 3753QWidget *CalendarView::leftFrame()
3750{ 3754{
3751 return ( QWidget *)mLeftFrame; 3755 return ( QWidget *)mLeftFrame;
3752} 3756}
3753 3757
3754DateNavigator *CalendarView::dateNavigator() 3758DateNavigator *CalendarView::dateNavigator()
3755{ 3759{
3756 return mNavigator; 3760 return mNavigator;
3757} 3761}
3758 3762
3759KDateNavigator* CalendarView::dateNavigatorWidget() 3763KDateNavigator* CalendarView::dateNavigatorWidget()
3760{ 3764{
3761 return mDateNavigator->navigatorView(); 3765 return mDateNavigator->navigatorView();
3762} 3766}
3763void CalendarView::toggleDateNavigatorWidget() 3767void CalendarView::toggleDateNavigatorWidget()
3764{ 3768{
3765 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3769 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3766 3770
3767 if (!KOPrefs::instance()->mShowDateNavigator ) 3771 if (!KOPrefs::instance()->mShowDateNavigator )
3768 mDateNavigator->hide(); 3772 mDateNavigator->hide();
3769 else 3773 else
3770 mDateNavigator->show(); 3774 mDateNavigator->show();
3771} 3775}
3772void CalendarView::addView(KOrg::BaseView *view) 3776void CalendarView::addView(KOrg::BaseView *view)
3773{ 3777{
3774 mViewManager->addView(view); 3778 mViewManager->addView(view);
3775} 3779}
3776 3780
3777void CalendarView::showView(KOrg::BaseView *view) 3781void CalendarView::showView(KOrg::BaseView *view)
3778{ 3782{
3779 mViewManager->showView(view, mLeftFrame->isVisible()); 3783 mViewManager->showView(view, mLeftFrame->isVisible());
3780} 3784}
3781 3785
3782Incidence *CalendarView::currentSelection() 3786Incidence *CalendarView::currentSelection()
3783{ 3787{
3784 return mViewManager->currentSelection(); 3788 return mViewManager->currentSelection();
3785} 3789}
3786void CalendarView::toggleAllDaySize() 3790void CalendarView::toggleAllDaySize()
3787{ 3791{
3788 /* 3792 /*
3789 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3793 if ( KOPrefs::instance()->mAllDaySize > 47 )
3790 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3794 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3791 else 3795 else
3792 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3796 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3793 */ 3797 */
3794 viewManager()->agendaView()->toggleAllDay(); 3798 viewManager()->agendaView()->toggleAllDay();
3795} 3799}
3796void CalendarView::toggleExpand() 3800void CalendarView::toggleExpand()
3797{ 3801{
3798 // if ( mLeftFrame->isHidden() ) { 3802 // if ( mLeftFrame->isHidden() ) {
3799 // mLeftFrame->show(); 3803 // mLeftFrame->show();
3800 // emit calendarViewExpanded( false ); 3804 // emit calendarViewExpanded( false );
3801 // } else { 3805 // } else {
3802 // mLeftFrame->hide(); 3806 // mLeftFrame->hide();
3803 // emit calendarViewExpanded( true ); 3807 // emit calendarViewExpanded( true );
3804 // } 3808 // }
3805 //qDebug(" CalendarView::toggleExpand()"); 3809 //qDebug(" CalendarView::toggleExpand()");
3806 globalFlagBlockAgenda = 1; 3810 globalFlagBlockAgenda = 1;
3807 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3811 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3808 globalFlagBlockAgenda = 5; 3812 globalFlagBlockAgenda = 5;
3809 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3813 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3810 //mViewManager->showView( 0, true ); 3814 //mViewManager->showView( 0, true );
3811} 3815}
3812 3816
3813void CalendarView::calendarModified( bool modified, Calendar * ) 3817void CalendarView::calendarModified( bool modified, Calendar * )
3814{ 3818{
3815 setModified( modified ); 3819 setModified( modified );
3816} 3820}
3817 3821
3818Todo *CalendarView::selectedTodo() 3822Todo *CalendarView::selectedTodo()
3819{ 3823{
3820 Incidence *incidence = currentSelection(); 3824 Incidence *incidence = currentSelection();
3821 if ( incidence && incidence->type() == "Todo" ) { 3825 if ( incidence && incidence->type() == "Todo" ) {
3822 return static_cast<Todo *>( incidence ); 3826 return static_cast<Todo *>( incidence );
3823 } 3827 }
3824 3828
3825 incidence = mTodoList->selectedIncidences().first(); 3829 incidence = mTodoList->selectedIncidences().first();
3826 if ( incidence && incidence->type() == "Todo" ) { 3830 if ( incidence && incidence->type() == "Todo" ) {
3827 return static_cast<Todo *>( incidence ); 3831 return static_cast<Todo *>( incidence );
3828 } 3832 }
3829 3833
3830 return 0; 3834 return 0;
3831} 3835}
3832 3836
3833void CalendarView::dialogClosing(Incidence *in) 3837void CalendarView::dialogClosing(Incidence *in)
3834{ 3838{
3835 // mDialogList.remove(in); 3839 // mDialogList.remove(in);
3836} 3840}
3837 3841
3838void CalendarView::showIncidence() 3842void CalendarView::showIncidence()
3839{ 3843{
3840 mViewerCallerIsSearchDialog = false; 3844 mViewerCallerIsSearchDialog = false;
3841 Incidence *incidence = currentSelection(); 3845 Incidence *incidence = currentSelection();
3842 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3846 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3843 if ( incidence ) { 3847 if ( incidence ) {
3844 ShowIncidenceVisitor v; 3848 ShowIncidenceVisitor v;
3845 v.act( incidence, this ); 3849 v.act( incidence, this );
3846 } 3850 }
3847} 3851}
3848void CalendarView::editIncidenceDescription() 3852void CalendarView::editIncidenceDescription()
3849{ 3853{
3850 mFlagEditDescription = true; 3854 mFlagEditDescription = true;
3851 editIncidence(); 3855 editIncidence();
3852 mFlagEditDescription = false; 3856 mFlagEditDescription = false;
3853} 3857}
3854void CalendarView::editIncidence() 3858void CalendarView::editIncidence()
3855{ 3859{
3856 // qDebug("editIncidence() "); 3860 // qDebug("editIncidence() ");
3857 Incidence *incidence = currentSelection(); 3861 Incidence *incidence = currentSelection();
3858 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3862 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3859 if ( incidence ) { 3863 if ( incidence ) {
3860 EditIncidenceVisitor v; 3864 EditIncidenceVisitor v;
3861 v.act( incidence, this ); 3865 v.act( incidence, this );
3862 } 3866 }
3863} 3867}
3864 3868
3865void CalendarView::deleteIncidence() 3869void CalendarView::deleteIncidence()
3866{ 3870{
3867 Incidence *incidence = currentSelection(); 3871 Incidence *incidence = currentSelection();
3868 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3872 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3869 if ( incidence ) { 3873 if ( incidence ) {
3870 deleteIncidence(incidence); 3874 deleteIncidence(incidence);
3871 } 3875 }
3872} 3876}
3873 3877
3874void CalendarView::showIncidence(Incidence *incidence) 3878void CalendarView::showIncidence(Incidence *incidence)
3875{ 3879{
3876 mViewerCallerIsSearchDialog = false; 3880 mViewerCallerIsSearchDialog = false;
3877 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 3881 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3878 if ( sender() && mDialogManager->getSearchDialog() ) { 3882 if ( sender() && mDialogManager->getSearchDialog() ) {
3879 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 3883 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3880 mViewerCallerIsSearchDialog = true; 3884 mViewerCallerIsSearchDialog = true;
3881 } 3885 }
3882 } 3886 }
3883 if ( incidence ) { 3887 if ( incidence ) {
3884 ShowIncidenceVisitor v; 3888 ShowIncidenceVisitor v;
3885 v.act( incidence, this ); 3889 v.act( incidence, this );
3886 } 3890 }
3887} 3891}
3888 3892
3889void CalendarView::editIncidence(Incidence *incidence) 3893void CalendarView::editIncidence(Incidence *incidence)
3890{ 3894{
3891 if ( incidence ) { 3895 if ( incidence ) {
3892 3896
3893 EditIncidenceVisitor v; 3897 EditIncidenceVisitor v;
3894 v.act( incidence, this ); 3898 v.act( incidence, this );
3895 3899
3896 } 3900 }
3897} 3901}
3898 3902
3899void CalendarView::deleteIncidence(Incidence *incidence) 3903void CalendarView::deleteIncidence(Incidence *incidence)
3900{ 3904{
3901 //qDebug(" CalendarView::deleteIncidence "); 3905 //qDebug(" CalendarView::deleteIncidence ");
3902 if ( incidence ) { 3906 if ( incidence ) {
3903 DeleteIncidenceVisitor v; 3907 DeleteIncidenceVisitor v;
3904 v.act( incidence, this ); 3908 v.act( incidence, this );
3905 } 3909 }
3906} 3910}
3907 3911
3908 3912
3909void CalendarView::lookForOutgoingMessages() 3913void CalendarView::lookForOutgoingMessages()
3910{ 3914{
3911 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3915 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3912 ogd->loadMessages(); 3916 ogd->loadMessages();
3913} 3917}
3914 3918
3915void CalendarView::lookForIncomingMessages() 3919void CalendarView::lookForIncomingMessages()
3916{ 3920{
3917 IncomingDialog *icd = mDialogManager->incomingDialog(); 3921 IncomingDialog *icd = mDialogManager->incomingDialog();
3918 icd->retrieve(); 3922 icd->retrieve();
3919} 3923}
3920 3924
3921bool CalendarView::removeCompletedSubTodos( Todo* t ) 3925bool CalendarView::removeCompletedSubTodos( Todo* t )
3922{ 3926{
3923 bool deleteTodo = true; 3927 bool deleteTodo = true;
3924 QPtrList<Incidence> subTodos; 3928 QPtrList<Incidence> subTodos;
3925 Incidence *aTodo; 3929 Incidence *aTodo;
3926 subTodos = t->relations(); 3930 subTodos = t->relations();
3927 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3931 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3928 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3932 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3929 deleteTodo = false; 3933 deleteTodo = false;
3930 } 3934 }
3931 if ( deleteTodo ) { 3935 if ( deleteTodo ) {
3932 if ( t->isCompleted() && !t->doesRecur()) { 3936 if ( t->isCompleted() && !t->doesRecur()) {
3933 checkExternalId( t ); 3937 checkExternalId( t );
3934 mCalendar->deleteTodo( t ); 3938 mCalendar->deleteTodo( t );
3935 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3939 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3936 } 3940 }
3937 else 3941 else
3938 deleteTodo = false; 3942 deleteTodo = false;
3939 } 3943 }
3940 return deleteTodo; 3944 return deleteTodo;
3941 3945
3942} 3946}
3943void CalendarView::purgeCompleted() 3947void CalendarView::purgeCompleted()
3944{ 3948{
3945 int result = KMessageBox::warningContinueCancel(this, 3949 int result = KMessageBox::warningContinueCancel(this,
3946 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3950 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3947 3951
3948 if (result == KMessageBox::Continue) { 3952 if (result == KMessageBox::Continue) {
3949 3953
3950 QPtrList<Todo> todoCal; 3954 QPtrList<Todo> todoCal;
3951 QPtrList<Todo> rootTodos; 3955 QPtrList<Todo> rootTodos;
3952 //QPtrList<Incidence> rel; 3956 //QPtrList<Incidence> rel;
3953 Todo *aTodo;//, *rTodo; 3957 Todo *aTodo;//, *rTodo;
3954 Incidence *rIncidence; 3958 Incidence *rIncidence;
3955 bool childDelete = false; 3959 bool childDelete = false;
3956 bool deletedOne = true; 3960 bool deletedOne = true;
3957 todoCal = calendar()->todos(); 3961 todoCal = calendar()->todos();
3958 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3962 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3959 if ( !aTodo->relatedTo() ) 3963 if ( !aTodo->relatedTo() )
3960 rootTodos.append( aTodo ); 3964 rootTodos.append( aTodo );
3961 } 3965 }
3962 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3966 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3963 removeCompletedSubTodos( aTodo ); 3967 removeCompletedSubTodos( aTodo );
3964 } 3968 }
3965 3969
3966 updateView(); 3970 updateView();
3967 } 3971 }
3968} 3972}
3969 3973
3970void CalendarView::slotCalendarChanged() 3974void CalendarView::slotCalendarChanged()
3971{ 3975{
3972 ; 3976 ;
3973} 3977}
3974 3978
3975void CalendarView::keyPressEvent ( QKeyEvent *e) 3979void CalendarView::keyPressEvent ( QKeyEvent *e)
3976{ 3980{
3977 //qDebug(" alendarView::keyPressEvent "); 3981 //qDebug(" alendarView::keyPressEvent ");
3978 e->ignore(); 3982 e->ignore();
3979} 3983}
3980 3984
3981 3985
3982bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3986bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3983{ 3987{
3984 // mSyncManager = manager; 3988 // mSyncManager = manager;
3985 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3989 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3986 qDebug("KO: SyncKDE request detected!"); 3990 qDebug("KO: SyncKDE request detected!");
3987 } 3991 }
3988 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3992 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3989 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3993 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3990 return syncCalendar( filename, mode ); 3994 return syncCalendar( filename, mode );
3991} 3995}
3992bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3996bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3993{ 3997{
3994 //mSyncManager = manager; 3998 //mSyncManager = manager;
3995 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3999 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3996 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4000 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3997 if ( resource == "sharp" ) 4001 if ( resource == "sharp" )
3998 syncExternal( 0 ); 4002 syncExternal( 0 );
3999 if ( resource == "phone" ) 4003 if ( resource == "phone" )
4000 syncExternal( 1 ); 4004 syncExternal( 1 );
4001 // pending setmodified 4005 // pending setmodified
4002 return true; 4006 return true;
4003} 4007}
4004void CalendarView::setSyncManager(KSyncManager* manager) 4008void CalendarView::setSyncManager(KSyncManager* manager)
4005{ 4009{
4006 mSyncManager = manager; 4010 mSyncManager = manager;
4007} 4011}
4008 4012
4009void CalendarView::removeSyncInfo( QString syncProfile) 4013void CalendarView::removeSyncInfo( QString syncProfile)
4010{ 4014{
4011 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4015 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4012 mCalendar->removeSyncInfo( syncProfile ); 4016 mCalendar->removeSyncInfo( syncProfile );
4013 4017
4014} 4018}
4015 4019
4016void CalendarView::undo_delete() 4020void CalendarView::undo_delete()
4017{ 4021{
4018 //qDebug("undo_delete() "); 4022 //qDebug("undo_delete() ");
4019 Incidence* undo = mCalendar->undoIncidence(); 4023 Incidence* undo = mCalendar->undoIncidence();
4020 if ( !undo ) { 4024 if ( !undo ) {
4021 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4025 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4022 i18n("KO/Pi")); 4026 i18n("KO/Pi"));
4023 return; 4027 return;
4024 } 4028 }
4025 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4029 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4026 i18n("\nAre you sure you want\nto restore this?"), 4030 i18n("\nAre you sure you want\nto restore this?"),
4027 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4031 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4028 mCalendar->undoDeleteIncidence(); 4032 mCalendar->undoDeleteIncidence();
4029 updateView(); 4033 updateView();
4030 } 4034 }
4031} 4035}
4032 4036
4033void CalendarView::slotViewerClosed() 4037void CalendarView::slotViewerClosed()
4034{ 4038{
4035 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4039 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4036} 4040}
4037 4041
4038void CalendarView::resetFocus() 4042void CalendarView::resetFocus()
4039{ 4043{
4040 if ( mViewerCallerIsSearchDialog ) { 4044 if ( mViewerCallerIsSearchDialog ) {
4041 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4045 if ( mDialogManager->getSearchDialog()->isVisible() ){
4042 mDialogManager->getSearchDialog()->raise(); 4046 mDialogManager->getSearchDialog()->raise();
4043 mDialogManager->getSearchDialog()->setActiveWindow(); 4047 mDialogManager->getSearchDialog()->setActiveWindow();
4044 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4048 mDialogManager->getSearchDialog()->listview()->resetFocus();
4045 } else 4049 } else
4046 mViewerCallerIsSearchDialog = false; 4050 mViewerCallerIsSearchDialog = false;
4047 } 4051 }
4048 if ( !mViewerCallerIsSearchDialog ) { 4052 if ( !mViewerCallerIsSearchDialog ) {
4049 //mViewManager->currentView()->setFocus(); 4053 //mViewManager->currentView()->setFocus();
4050 //qDebug("sssssssssssssssset focus "); 4054 //qDebug("sssssssssssssssset focus ");
4051 topLevelWidget()->raise(); 4055 topLevelWidget()->raise();
4052 setActiveWindow(); 4056 setActiveWindow();
4053 //setFocus(); 4057 //setFocus();
4054 } 4058 }
4055 mViewerCallerIsSearchDialog = false; 4059 mViewerCallerIsSearchDialog = false;
4056} 4060}
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 11dc592..edeebdf 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -1,429 +1,431 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <kdebug.h> 26#include <kdebug.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29//#include "koglobals.h" 29//#include "koglobals.h"
30#include "navigatorbar.h" 30#include "navigatorbar.h"
31#include "kdatenavigator.h" 31#include "kdatenavigator.h"
32 32
33#include <kcalendarsystem.h> 33#include <kcalendarsystem.h>
34 34
35#include "datenavigatorcontainer.h" 35#include "datenavigatorcontainer.h"
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, 38DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
39 const char *name ) 39 const char *name )
40 : QWidget( parent, name ), mCalendar( 0 ), 40 : QWidget( parent, name ), mCalendar( 0 ),
41 mHorizontalCount( 1 ), mVerticalCount( 1 ) 41 mHorizontalCount( 1 ), mVerticalCount( 1 )
42{ 42{
43 mResizeEnabled = false; 43 mResizeEnabled = false;
44 mExtraViews.setAutoDelete( true ); 44 mExtraViews.setAutoDelete( true );
45 45
46 mNavigatorView = new KDateNavigator( this, name ); 46 mNavigatorView = new KDateNavigator( this, name );
47 mNavigatorView->hide(); 47 mNavigatorView->hide();
48 connectNavigatorView( mNavigatorView ); 48 connectNavigatorView( mNavigatorView );
49 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 49 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
50 mLastDisplayedDN = 0; 50 mLastDisplayedDN = 0;
51 mUpdateTimer; 51 mUpdateTimer;
52 mUpdateTimer = new QTimer( this ); 52 mUpdateTimer = new QTimer( this );
53 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); 53 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() ));
54 mFirstSelectedDate = QDate::currentDate(); 54 mFirstSelectedDate = QDate::currentDate();
55 mSelectedDateCount = 1; 55 mSelectedDateCount = 1;
56} 56}
57 57
58DateNavigatorContainer::~DateNavigatorContainer() 58DateNavigatorContainer::~DateNavigatorContainer()
59{ 59{
60} 60}
61 61
62void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 62void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
63{ 63{
64 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), 64 connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
65 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 65 SIGNAL( datesSelected( const KCal::DateList & ) ) );
66#if 0 66#if 0
67 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), 67 connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
68 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); 68 SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
69 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), 69 connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
70 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); 70 SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
71#endif 71#endif
72 connect( v, SIGNAL( weekClicked( const QDate & ) ), 72 connect( v, SIGNAL( weekClicked( const QDate & ) ),
73 SIGNAL( weekClicked( const QDate & ) ) ); 73 SIGNAL( weekClicked( const QDate & ) ) );
74 connect( v, SIGNAL( showMonth( const QDate & ) ),
75 SIGNAL( showMonth( const QDate & ) ) );
74 76
75 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 77 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
76 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 78 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
77 79
78 connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) ); 80 connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) );
79 connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) ); 81 connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) );
80 connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) ); 82 connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) );
81 connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) ); 83 connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) );
82 84
83 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 85 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
84} 86}
85void DateNavigatorContainer::slotgoNextYear() 87void DateNavigatorContainer::slotgoNextYear()
86{ 88{
87 jumpMonth( 12 ); 89 jumpMonth( 12 );
88 emit goNextYear(); 90 emit goNextYear();
89 91
90} 92}
91void DateNavigatorContainer::slotgoPrevYear() 93void DateNavigatorContainer::slotgoPrevYear()
92{ 94{
93 jumpMonth( -12 ); 95 jumpMonth( -12 );
94 emit goPrevYear(); 96 emit goPrevYear();
95 97
96} 98}
97void DateNavigatorContainer::slotgoPrevMonth() 99void DateNavigatorContainer::slotgoPrevMonth()
98{ 100{
99 jumpMonth( -1 ); 101 jumpMonth( -1 );
100 emit goPrevMonth(); 102 emit goPrevMonth();
101 103
102} 104}
103void DateNavigatorContainer::slotgoNextMonth() 105void DateNavigatorContainer::slotgoNextMonth()
104{ 106{
105 jumpMonth( 1 ); 107 jumpMonth( 1 );
106 emit goNextMonth(); 108 emit goNextMonth();
107} 109}
108void DateNavigatorContainer::jumpMonth( int month ) 110void DateNavigatorContainer::jumpMonth( int month )
109{ 111{
110 112
111 QDate baseDate = mNavigatorView->baseDate(); 113 QDate baseDate = mNavigatorView->baseDate();
112 computeMonthSelected( baseDate.month() + month, false ); 114 computeMonthSelected( baseDate.month() + month, false );
113} 115}
114void DateNavigatorContainer::slotMonthSelected( int month ) 116void DateNavigatorContainer::slotMonthSelected( int month )
115{ 117{
116 computeMonthSelected( month, true ); 118 computeMonthSelected( month, true );
117} 119}
118void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) 120void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit )
119{ 121{
120 //qDebug("slotMonthSelected %d ", month); 122 //qDebug("slotMonthSelected %d ", month);
121 QDate baseDate = mNavigatorView->baseDate(); 123 QDate baseDate = mNavigatorView->baseDate();
122 if ( baseDate.month() == month ) 124 if ( baseDate.month() == month )
123 return; 125 return;
124 //qDebug("month %d %d ",baseDate.month(),month); 126 //qDebug("month %d %d ",baseDate.month(),month);
125 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); 127 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 );
126 date = date.addDays( -(baseDate.month()-month ) *30 ); 128 date = date.addDays( -(baseDate.month()-month ) *30 );
127 QDate newBase = QDate ( date.year(), date.month() , baseDate.day() ); 129 QDate newBase = QDate ( date.year(), date.month() , baseDate.day() );
128 130
129 //qDebug("NEW BASE %s", newBase.toString().latin1()); 131 //qDebug("NEW BASE %s", newBase.toString().latin1());
130 mNavigatorView->setBaseDate( newBase ); 132 mNavigatorView->setBaseDate( newBase );
131 QDate last = lastAvailableDate(); 133 QDate last = lastAvailableDate();
132 QDate first = firstAvailableDate(); 134 QDate first = firstAvailableDate();
133 135
134 QDate selFirst = mFirstSelectedDate; 136 QDate selFirst = mFirstSelectedDate;
135 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 137 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
136 if ( selFirst >= first && selLast <= last ) { 138 if ( selFirst >= first && selLast <= last ) {
137 setBaseDates(); 139 setBaseDates();
138 if ( forceEmit ) 140 if ( forceEmit )
139 updateDayMatrixDates(); 141 updateDayMatrixDates();
140 } 142 }
141 else { 143 else {
142 setBaseDates(); 144 setBaseDates();
143 if ( forceEmit ) 145 if ( forceEmit )
144 updateDayMatrixDates(); 146 updateDayMatrixDates();
145 if ( forceEmit ) 147 if ( forceEmit )
146 emit monthSelected( month ); 148 emit monthSelected( month );
147 } 149 }
148} 150}
149void DateNavigatorContainer::setCalendar( Calendar *cal ) 151void DateNavigatorContainer::setCalendar( Calendar *cal )
150{ 152{
151 mCalendar = cal; 153 mCalendar = cal;
152 mNavigatorView->setCalendar( cal ); 154 mNavigatorView->setCalendar( cal );
153 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 155 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
154 KDateNavigator *n = mExtraViews.at( i ); 156 KDateNavigator *n = mExtraViews.at( i );
155 n->setCalendar( cal ); 157 n->setCalendar( cal );
156 } 158 }
157} 159}
158void DateNavigatorContainer::checkUpdateDayMatrixDates() 160void DateNavigatorContainer::checkUpdateDayMatrixDates()
159{ 161{
160 //qDebug("KODNC: wid %d hei %d ", width(), height()); 162 //qDebug("KODNC: wid %d hei %d ", width(), height());
161 mUpdateTimer->stop(); 163 mUpdateTimer->stop();
162 //return; 164 //return;
163 if ( width() < 3 || height() < 3 ) 165 if ( width() < 3 || height() < 3 )
164 return; 166 return;
165 static int lastWid = 0; 167 static int lastWid = 0;
166 static int lastHei = 0; 168 static int lastHei = 0;
167 if ( lastWid == width() && height() == lastHei ) { 169 if ( lastWid == width() && height() == lastHei ) {
168 qDebug("KODNC: No layout computing needed. "); 170 qDebug("KODNC: No layout computing needed. ");
169 } else { 171 } else {
170 lastWid = width(); 172 lastWid = width();
171 lastHei = height(); 173 lastHei = height();
172 174
173 QSize minSize = mNavigatorView->yourSizeHint(); 175 QSize minSize = mNavigatorView->yourSizeHint();
174 176
175 int verticalCount = size().height() / minSize.height(); 177 int verticalCount = size().height() / minSize.height();
176 int horizontalCount = size().width() / minSize.width(); 178 int horizontalCount = size().width() / minSize.width();
177 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 179 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
178 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 180 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
179 bool fontchange = false; 181 bool fontchange = false;
180 if ( horizontalCount == 1) 182 if ( horizontalCount == 1)
181 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); 183 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
182 QFont fo; 184 QFont fo;
183 if ( horizontalCount != mHorizontalCount || 185 if ( horizontalCount != mHorizontalCount ||
184 verticalCount != mVerticalCount ) { 186 verticalCount != mVerticalCount ) {
185 uint count = horizontalCount * verticalCount; 187 uint count = horizontalCount * verticalCount;
186 if ( count == 0 ) { 188 if ( count == 0 ) {
187 bool ok; 189 bool ok;
188 fo = mNavigatorView->yourFontHint( size() , &ok ); 190 fo = mNavigatorView->yourFontHint( size() , &ok );
189 //mNavigatorView->resize( size() ); 191 //mNavigatorView->resize( size() );
190 //if ( ! ok ) 192 //if ( ! ok )
191 // return; 193 // return;
192 int butt = 2; 194 int butt = 2;
193 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); 195 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
194 if ( horizontalCount <= 1 ) 196 if ( horizontalCount <= 1 )
195 minSize = mNavigatorView->sizeHintTwoButtons( 4 ); 197 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
196 else 198 else
197 minSize = mNavigatorView->sizeHintTwoButtons(); 199 minSize = mNavigatorView->sizeHintTwoButtons();
198 verticalCount = size().height() / minSize.height(); 200 verticalCount = size().height() / minSize.height();
199 horizontalCount = size().width() / minSize.width(); 201 horizontalCount = size().width() / minSize.width();
200 if ( horizontalCount == 0 ) 202 if ( horizontalCount == 0 )
201 horizontalCount = 1; 203 horizontalCount = 1;
202 if ( verticalCount == 0 ) 204 if ( verticalCount == 0 )
203 verticalCount = 1; 205 verticalCount = 1;
204 fontchange = true; 206 fontchange = true;
205 count = horizontalCount * verticalCount; 207 count = horizontalCount * verticalCount;
206 } else { 208 } else {
207 if ( mNavigatorView->fontChanged() ) { 209 if ( mNavigatorView->fontChanged() ) {
208 fontchange = true; 210 fontchange = true;
209 fo = KOPrefs::instance()->mDateNavigatorFont; 211 fo = KOPrefs::instance()->mDateNavigatorFont;
210 mNavigatorView->changeFont( fo ); 212 mNavigatorView->changeFont( fo );
211 mNavigatorView->unsetFontChanged(); 213 mNavigatorView->unsetFontChanged();
212 } 214 }
213 } 215 }
214 216
215 mLastDisplayedDN = horizontalCount*verticalCount-1; 217 mLastDisplayedDN = horizontalCount*verticalCount-1;
216 while ( count > ( mExtraViews.count() + 1 ) ) { 218 while ( count > ( mExtraViews.count() + 1 ) ) {
217 KDateNavigator *n = new KDateNavigator( this ); 219 KDateNavigator *n = new KDateNavigator( this );
218 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 220 n->setMonthSignalOffset ( mExtraViews.count()+1 );
219 mExtraViews.append( n ); 221 mExtraViews.append( n );
220 n->setCalendar( mCalendar ); 222 n->setCalendar( mCalendar );
221 connectNavigatorView( n ); 223 connectNavigatorView( n );
222 // n->show(); 224 // n->show();
223 } 225 }
224 226
225 227
226 setBaseDates(); 228 setBaseDates();
227 if ( fontchange ) { 229 if ( fontchange ) {
228 //mNavigatorView->changeFont( fo ); 230 //mNavigatorView->changeFont( fo );
229 uint i; 231 uint i;
230 for( i = 0; i < mExtraViews.count(); ++i ) { 232 for( i = 0; i < mExtraViews.count(); ++i ) {
231 KDateNavigator *view = mExtraViews.at( i ); 233 KDateNavigator *view = mExtraViews.at( i );
232 view->changeFont( fo ); 234 view->changeFont( fo );
233 } 235 }
234 } 236 }
235 mHorizontalCount = horizontalCount; 237 mHorizontalCount = horizontalCount;
236 mVerticalCount = verticalCount; 238 mVerticalCount = verticalCount;
237 239
238 } 240 }
239 241
240 int theight = height() / mVerticalCount; 242 int theight = height() / mVerticalCount;
241 int twidth = width() / mHorizontalCount; 243 int twidth = width() / mHorizontalCount;
242 244
243 NavigatorBar *bar = mNavigatorView->navigatorBar(); 245 NavigatorBar *bar = mNavigatorView->navigatorBar();
244 if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); 246 if ( mHorizontalCount > 1 ) bar->showButtons( true, false );
245 else bar->showButtons( true, true ); 247 else bar->showButtons( true, true );
246 248
247 mNavigatorView->setGeometry(0, 249 mNavigatorView->setGeometry(0,
248 0, twidth, theight ); 250 0, twidth, theight );
249 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 251 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
250 int x = ( i + 1 ) % mHorizontalCount; 252 int x = ( i + 1 ) % mHorizontalCount;
251 int y = ( i + 1 ) / mHorizontalCount; 253 int y = ( i + 1 ) / mHorizontalCount;
252 254
253 KDateNavigator *view = mExtraViews.at( i ); 255 KDateNavigator *view = mExtraViews.at( i );
254 bar = view->navigatorBar(); 256 bar = view->navigatorBar();
255 if ( y > 0 ) bar->showButtons( false, false ); 257 if ( y > 0 ) bar->showButtons( false, false );
256 else { 258 else {
257 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); 259 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true );
258 else bar->showButtons( false, false ); 260 else bar->showButtons( false, false );
259 } 261 }
260 view->setGeometry( x * twidth, 262 view->setGeometry( x * twidth,
261 y * theight, twidth, theight ); 263 y * theight, twidth, theight );
262 } 264 }
263 int iii = 0; 265 int iii = 0;
264 int ccc = mHorizontalCount * mVerticalCount; 266 int ccc = mHorizontalCount * mVerticalCount;
265 mNavigatorView->show(); 267 mNavigatorView->show();
266 while ( iii < ( mExtraViews.count() ) ) { 268 while ( iii < ( mExtraViews.count() ) ) {
267 if ( iii < ccc-1 ) 269 if ( iii < ccc-1 )
268 mExtraViews.at( iii )->show(); 270 mExtraViews.at( iii )->show();
269 else 271 else
270 mExtraViews.at( iii )->hide(); 272 mExtraViews.at( iii )->hide();
271 ++iii; 273 ++iii;
272 } 274 }
273 } 275 }
274 276
275 QDate last = lastAvailableDate(); 277 QDate last = lastAvailableDate();
276 QDate first = firstAvailableDate(); 278 QDate first = firstAvailableDate();
277 279
278 QDate selFirst = mFirstSelectedDate; 280 QDate selFirst = mFirstSelectedDate;
279 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 281 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
280 if ( selFirst >= first && selLast <= last ) { 282 if ( selFirst >= first && selLast <= last ) {
281 updateDayMatrixDates(); 283 updateDayMatrixDates();
282 } 284 }
283 else { 285 else {
284 updateDayMatrixDates(); 286 updateDayMatrixDates();
285 emit monthSelected( mFirstSelectedDate.month() ); 287 emit monthSelected( mFirstSelectedDate.month() );
286 } 288 }
287} 289}
288void DateNavigatorContainer::updateDayMatrixDates() 290void DateNavigatorContainer::updateDayMatrixDates()
289{ 291{
290 QDate fDate = mFirstSelectedDate; 292 QDate fDate = mFirstSelectedDate;
291 QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); 293 QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
292 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 294 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
293 mNavigatorView->dayMatrix()->repaint( false ); 295 mNavigatorView->dayMatrix()->repaint( false );
294 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 296 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
295 KDateNavigator *n = mExtraViews.at( i ); 297 KDateNavigator *n = mExtraViews.at( i );
296 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 298 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
297 n->dayMatrix()->repaint( false ); 299 n->dayMatrix()->repaint( false );
298 } 300 }
299 } 301 }
300} 302}
301 303
302void DateNavigatorContainer::updateDayMatrix() 304void DateNavigatorContainer::updateDayMatrix()
303{ 305{
304 mNavigatorView->updateDayMatrix(); 306 mNavigatorView->updateDayMatrix();
305 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 307 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
306 KDateNavigator *n = mExtraViews.at( i ); 308 KDateNavigator *n = mExtraViews.at( i );
307 n->updateDayMatrix(); 309 n->updateDayMatrix();
308 } 310 }
309} 311}
310 312
311void DateNavigatorContainer::updateToday() 313void DateNavigatorContainer::updateToday()
312{ 314{
313 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 315 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
314#if 0 316#if 0
315 mNavigatorView->updateToday(); 317 mNavigatorView->updateToday();
316 KDateNavigator *n; 318 KDateNavigator *n;
317 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 319 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
318 n->updateToday(); 320 n->updateToday();
319 } 321 }
320#endif 322#endif
321} 323}
322 324
323void DateNavigatorContainer::updateView() 325void DateNavigatorContainer::updateView()
324{ 326{
325 mNavigatorView->updateView(); 327 mNavigatorView->updateView();
326 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 328 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
327 KDateNavigator *n = mExtraViews.at( i ); 329 KDateNavigator *n = mExtraViews.at( i );
328 n->updateView(); 330 n->updateView();
329 } 331 }
330} 332}
331 333
332void DateNavigatorContainer::updateConfig() 334void DateNavigatorContainer::updateConfig()
333{ 335{
334 mNavigatorView->updateConfig(); 336 mNavigatorView->updateConfig();
335 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 337 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
336 KDateNavigator *n = mExtraViews.at( i ); 338 KDateNavigator *n = mExtraViews.at( i );
337 n->updateConfig(); 339 n->updateConfig();
338 } 340 }
339} 341}
340QDate DateNavigatorContainer::lastAvailableDate() const 342QDate DateNavigatorContainer::lastAvailableDate() const
341{ 343{
342 QDate date = mNavigatorView->baseDate(); 344 QDate date = mNavigatorView->baseDate();
343 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); 345 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() );
344 int iii = mLastDisplayedDN; 346 int iii = mLastDisplayedDN;
345 if ( mLastDisplayedDN ) 347 if ( mLastDisplayedDN )
346 last = last.addDays( 1); 348 last = last.addDays( 1);
347 while ( iii ) { 349 while ( iii ) {
348 last = last.addDays( last.daysInMonth ()); 350 last = last.addDays( last.daysInMonth ());
349 //qDebug("DATE %s ", last.toString().latin1() ); 351 //qDebug("DATE %s ", last.toString().latin1() );
350 --iii; 352 --iii;
351 } 353 }
352 if ( mLastDisplayedDN ) 354 if ( mLastDisplayedDN )
353 last = last.addDays( -1); 355 last = last.addDays( -1);
354 return last; 356 return last;
355} 357}
356QDate DateNavigatorContainer::firstAvailableDate() const 358QDate DateNavigatorContainer::firstAvailableDate() const
357{ 359{
358 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 ); 360 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 );
359} 361}
360void DateNavigatorContainer::selectDates( const DateList &dateList ) 362void DateNavigatorContainer::selectDates( const DateList &dateList )
361{ 363{
362 mFirstSelectedDate = dateList.first() ; 364 mFirstSelectedDate = dateList.first() ;
363 mSelectedDateCount = dateList.count() ; 365 mSelectedDateCount = dateList.count() ;
364 if ( !mLastDisplayedDN ) { 366 if ( !mLastDisplayedDN ) {
365 mNavigatorView->selectDates( dateList ); 367 mNavigatorView->selectDates( dateList );
366 return; 368 return;
367 } 369 }
368 QDate fDate = dateList.first(); 370 QDate fDate = dateList.first();
369 QDate lDate = dateList.last(); 371 QDate lDate = dateList.last();
370 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); 372 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() );
371 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 373 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
372 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { 374 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) {
373 updateDayMatrixDates(); 375 updateDayMatrixDates();
374 return; 376 return;
375 } 377 }
376 mNavigatorView->selectDates( dateList ); 378 mNavigatorView->selectDates( dateList );
377 setBaseDates(); 379 setBaseDates();
378 if ( mLastDisplayedDN ) { 380 if ( mLastDisplayedDN ) {
379 KDateNavigator *view = mExtraViews.at( 0 ); 381 KDateNavigator *view = mExtraViews.at( 0 );
380 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 382 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
381 view->dayMatrix()->repaint( false ); 383 view->dayMatrix()->repaint( false );
382 if ( mLastDisplayedDN > 1 ) { 384 if ( mLastDisplayedDN > 1 ) {
383 KDateNavigator *view = mExtraViews.at( 1 ); 385 KDateNavigator *view = mExtraViews.at( 1 );
384 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 386 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
385 view->dayMatrix()->repaint( false ); 387 view->dayMatrix()->repaint( false );
386 } 388 }
387 } 389 }
388} 390}
389 391
390void DateNavigatorContainer::setBaseDates() 392void DateNavigatorContainer::setBaseDates()
391{ 393{
392 QDate baseDate = mNavigatorView->baseDate(); 394 QDate baseDate = mNavigatorView->baseDate();
393 bool doRepaint = true; 395 bool doRepaint = true;
394 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 396 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
395 KDateNavigator *n = mExtraViews.at( i ); 397 KDateNavigator *n = mExtraViews.at( i );
396 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 398 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
397 n->setBaseDate( baseDate, doRepaint ); 399 n->setBaseDate( baseDate, doRepaint );
398 } 400 }
399} 401}
400void DateNavigatorContainer::setResizeEnabled() 402void DateNavigatorContainer::setResizeEnabled()
401{ 403{
402 mResizeEnabled = true; 404 mResizeEnabled = true;
403 //qDebug("DateNavigatorContainer::setResizeEnabled "); 405 //qDebug("DateNavigatorContainer::setResizeEnabled ");
404 checkUpdateDayMatrixDates(); 406 checkUpdateDayMatrixDates();
405} 407}
406void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 408void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
407{ 409{
408 410
409 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height()); 411 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height());
410 //qDebug("COUNT %d ", mExtraViews.count()); 412 //qDebug("COUNT %d ", mExtraViews.count());
411 if ( ! mResizeEnabled ) { 413 if ( ! mResizeEnabled ) {
412 //qDebug("NOT ResizeEnabled"); 414 //qDebug("NOT ResizeEnabled");
413 return; 415 return;
414 } 416 }
415 else 417 else
416 mUpdateTimer->start( 250 ); 418 mUpdateTimer->start( 250 );
417 419
418 //updateDayMatrixDates(); 420 //updateDayMatrixDates();
419} 421}
420 422
421QSize DateNavigatorContainer::minimumSizeHint() const 423QSize DateNavigatorContainer::minimumSizeHint() const
422{ 424{
423 return mNavigatorView->minimumSizeHint(); 425 return mNavigatorView->minimumSizeHint();
424} 426}
425 427
426QSize DateNavigatorContainer::sizeHint() const 428QSize DateNavigatorContainer::sizeHint() const
427{ 429{
428 return mNavigatorView->yourSizeHint(); 430 return mNavigatorView->yourSizeHint();
429} 431}
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h
index ac9745d..87cc59f 100644
--- a/korganizer/datenavigatorcontainer.h
+++ b/korganizer/datenavigatorcontainer.h
@@ -1,108 +1,109 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com> 5 Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25#ifndef DATENAVIGATORCONTAINER_H 25#ifndef DATENAVIGATORCONTAINER_H
26#define DATENAVIGATORCONTAINER_H 26#define DATENAVIGATORCONTAINER_H
27 27
28class KDateNavigator; 28class KDateNavigator;
29 29
30#include <qwidget.h> 30#include <qwidget.h>
31#include <qtimer.h> 31#include <qtimer.h>
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33using namespace KCal; 33using namespace KCal;
34 34
35class DateNavigatorContainer: public QWidget 35class DateNavigatorContainer: public QWidget
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 ); 39 DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 );
40 ~DateNavigatorContainer(); 40 ~DateNavigatorContainer();
41 41
42 /** 42 /**
43 Associate date navigator with a calendar. It is used by KODayMatrix. 43 Associate date navigator with a calendar. It is used by KODayMatrix.
44 */ 44 */
45 void setCalendar( Calendar * ); 45 void setCalendar( Calendar * );
46 46
47 QSize minimumSizeHint() const; 47 QSize minimumSizeHint() const;
48 QSize sizeHint() const; 48 QSize sizeHint() const;
49 KDateNavigator * navigatorView() { return mNavigatorView;} 49 KDateNavigator * navigatorView() { return mNavigatorView;}
50 QDate lastAvailableDate() const ; 50 QDate lastAvailableDate() const ;
51 QDate firstAvailableDate() const ; 51 QDate firstAvailableDate() const ;
52 52
53 public slots: 53 public slots:
54 void selectDates( const KCal::DateList & ); 54 void selectDates( const KCal::DateList & );
55 void updateView(); 55 void updateView();
56 void updateConfig(); 56 void updateConfig();
57 void updateDayMatrix(); 57 void updateDayMatrix();
58 void updateDayMatrixDates(); 58 void updateDayMatrixDates();
59 void checkUpdateDayMatrixDates(); 59 void checkUpdateDayMatrixDates();
60 void updateToday(); 60 void updateToday();
61 void slotMonthSelected( int month ); 61 void slotMonthSelected( int month );
62 void slotgoNextMonth(); 62 void slotgoNextMonth();
63 void slotgoPrevMonth(); 63 void slotgoPrevMonth();
64 void slotgoNextYear(); 64 void slotgoNextYear();
65 void slotgoPrevYear(); 65 void slotgoPrevYear();
66 void setResizeEnabled(); 66 void setResizeEnabled();
67 67
68 signals: 68 signals:
69 void datesSelected( const KCal::DateList & ); 69 void datesSelected( const KCal::DateList & );
70 void incidenceDropped( Incidence *, const QDate & ); 70 void incidenceDropped( Incidence *, const QDate & );
71 void incidenceDroppedMove( Incidence *, const QDate & ); 71 void incidenceDroppedMove( Incidence *, const QDate & );
72 void weekClicked( const QDate &); 72 void weekClicked( const QDate &);
73 73
74 void goPrevious(); 74 void goPrevious();
75 void goNext(); 75 void goNext();
76 76
77 void goNextMonth(); 77 void goNextMonth();
78 void goPrevMonth(); 78 void goPrevMonth();
79 void goNextYear(); 79 void goNextYear();
80 void goPrevYear(); 80 void goPrevYear();
81 void showMonth( const QDate & );
81 82
82 void monthSelected( int month ); 83 void monthSelected( int month );
83 84
84 protected: 85 protected:
85 void computeMonthSelected( int month , bool forceEmit ); 86 void computeMonthSelected( int month , bool forceEmit );
86 void jumpMonth( int month ); 87 void jumpMonth( int month );
87 void resizeEvent( QResizeEvent * ); 88 void resizeEvent( QResizeEvent * );
88 89
89 void setBaseDates(); 90 void setBaseDates();
90 void connectNavigatorView( KDateNavigator *v ); 91 void connectNavigatorView( KDateNavigator *v );
91 92
92 private: 93 private:
93 bool mResizeEnabled; 94 bool mResizeEnabled;
94 QTimer* mUpdateTimer; 95 QTimer* mUpdateTimer;
95 int mLastDisplayedDN; 96 int mLastDisplayedDN;
96 QDate mFirstSelectedDate; 97 QDate mFirstSelectedDate;
97 int mSelectedDateCount; 98 int mSelectedDateCount;
98 KDateNavigator *mNavigatorView; 99 KDateNavigator *mNavigatorView;
99 100
100 KCal::Calendar *mCalendar; 101 KCal::Calendar *mCalendar;
101 102
102 QPtrList<KDateNavigator> mExtraViews; 103 QPtrList<KDateNavigator> mExtraViews;
103 104
104 int mHorizontalCount; 105 int mHorizontalCount;
105 int mVerticalCount; 106 int mVerticalCount;
106}; 107};
107 108
108#endif 109#endif
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 5eccfd6..38bddc2 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -1,467 +1,470 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 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 <qstring.h> 24#include <qstring.h>
25#include <qkeycode.h> 25#include <qkeycode.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kglobal.h> 34#include <kglobal.h>
35 35
36#include "koglobals.h" 36#include "koglobals.h"
37#include "koprefs.h" 37#include "koprefs.h"
38#ifndef KORG_NOPLUGINS 38#ifndef KORG_NOPLUGINS
39#include "kocore.h" 39#include "kocore.h"
40#endif 40#endif
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#include "navigatorbar.h" 44#include "navigatorbar.h"
45 45
46#include "kdatenavigator.h" 46#include "kdatenavigator.h"
47 47
48KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) 48KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
49 : QFrame(parent, name), 49 : QFrame(parent, name),
50 updateTimer(0L) 50 updateTimer(0L)
51{ 51{
52 setFrameStyle(QFrame::NoFrame); 52 setFrameStyle(QFrame::NoFrame);
53 QDate startDate = QDate::currentDate(); 53 QDate startDate = QDate::currentDate();
54 QGridLayout *topLayout = new QGridLayout(this,8,8); 54 QGridLayout *topLayout = new QGridLayout(this,8,8);
55 55
56 if (! startDate.isValid()) { 56 if (! startDate.isValid()) {
57 qDebug("KDateNavigator::invalid startdate "); 57 qDebug("KDateNavigator::invalid startdate ");
58 startDate = QDate::currentDate(); 58 startDate = QDate::currentDate();
59 } 59 }
60 mMonthSignalOffset = 0; 60 mMonthSignalOffset = 0;
61 mSelectedDates.append(startDate); 61 mSelectedDates.append(startDate);
62 m_MthYr = startDate; 62 m_MthYr = startDate;
63 m_bShowWeekNums = true; 63 m_bShowWeekNums = true;
64 64
65 setFont( KOPrefs::instance()->mDateNavigatorFont ); 65 setFont( KOPrefs::instance()->mDateNavigatorFont );
66 mNavigatorBar = new NavigatorBar( startDate, this ); 66 mNavigatorBar = new NavigatorBar( startDate, this );
67 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); 67 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
68 //mNavigatorBar->resize( 1,1); 68 //mNavigatorBar->resize( 1,1);
69 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 69 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
70 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 70 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
71 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 71 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
72 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 72 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
73 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 73 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
74 74
75 // get the day of the week on the first day 75 // get the day of the week on the first day
76 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 76 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
77 m_fstDayOfWk = dayone.dayOfWeek(); 77 m_fstDayOfWk = dayone.dayOfWeek();
78 78
79 int i; 79 int i;
80 80
81 // Set up the heading fields. 81 // Set up the heading fields.
82 for( i = 0; i < 7; i++ ) { 82 for( i = 0; i < 7; i++ ) {
83 headings[i] = new QLabel("",this); 83 headings[i] = new QLabel("",this);
84 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 84 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
85 headings[i]->setAlignment(AlignCenter); 85 headings[i]->setAlignment(AlignCenter);
86 headings[i]->installEventFilter(this); 86 headings[i]->installEventFilter(this);
87 87
88 topLayout->addWidget(headings[i],1,i+1); 88 topLayout->addWidget(headings[i],1,i+1);
89 } 89 }
90 90
91 // Create the weeknumber labels 91 // Create the weeknumber labels
92 for( i = 0; i < 6; i++ ) { 92 for( i = 0; i < 6; i++ ) {
93 weeknos[i] = new QLabel(this); 93 weeknos[i] = new QLabel(this);
94 weeknos[i]->setAlignment(AlignCenter); 94 weeknos[i]->setAlignment(AlignCenter);
95 //weeknos[i]->setFont(QFont("Arial", 10)); 95 //weeknos[i]->setFont(QFont("Arial", 10));
96 if(!m_bShowWeekNums) { 96 if(!m_bShowWeekNums) {
97 weeknos[i]->hide(); 97 weeknos[i]->hide();
98 } 98 }
99 weeknos[i]->installEventFilter(this); 99 weeknos[i]->installEventFilter(this);
100 100
101 topLayout->addWidget(weeknos[i],i+2,0); 101 topLayout->addWidget(weeknos[i],i+2,0);
102 } 102 }
103 103
104 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 104 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
105 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 105 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
106 daymatrix->setLineWidth(1); 106 daymatrix->setLineWidth(1);
107 107
108 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 108 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
109 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 109 SIGNAL( datesSelected( const KCal::DateList & ) ) );
110 110
111 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 111 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
112 SIGNAL( eventDropped( Event * ) ) ); 112 SIGNAL( eventDropped( Event * ) ) );
113 113
114 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 114 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
115 115
116 // read settings from configuration file. 116 // read settings from configuration file.
117 updateConfig(); 117 updateConfig();
118 enableRollover(FollowMonth); 118 enableRollover(FollowMonth);
119 mySizeHint = sizeHintTwoButtons(); 119 mySizeHint = sizeHintTwoButtons();
120 myFullSizeHint = sizeHintTwoButtons( 4 ); 120 myFullSizeHint = sizeHintTwoButtons( 4 );
121 mFontChanged = false; 121 mFontChanged = false;
122 //resize ( 3,3 ); 122 //resize ( 3,3 );
123 123
124} 124}
125void KDateNavigator::changeFont ( QFont fo ) 125void KDateNavigator::changeFont ( QFont fo )
126{ 126{
127 setFont( fo ); 127 setFont( fo );
128 mNavigatorBar->resetFont( fo ); 128 mNavigatorBar->resetFont( fo );
129} 129}
130QFont KDateNavigator::yourFontHint( QSize si , bool *b) 130QFont KDateNavigator::yourFontHint( QSize si , bool *b)
131{ 131{
132 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 132 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
133 *b = false; 133 *b = false;
134 int fontPoint = fo.pointSize(); 134 int fontPoint = fo.pointSize();
135 while ( fontPoint > 5 ) { 135 while ( fontPoint > 5 ) {
136 --fontPoint; 136 --fontPoint;
137 fo.setPointSize( fontPoint ); 137 fo.setPointSize( fontPoint );
138 setFont( fo ); 138 setFont( fo );
139 mFontChanged = true; 139 mFontChanged = true;
140 mNavigatorBar->resetFont( fo ); 140 mNavigatorBar->resetFont( fo );
141 QSize sh = sizeHintTwoButtons( 2 ); 141 QSize sh = sizeHintTwoButtons( 2 );
142 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 142 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
143 if ( si.width() > sh.width() && si.height() > sh.height()) { 143 if ( si.width() > sh.width() && si.height() > sh.height()) {
144 if ( si.width() / sh.width() == 1 ) { 144 if ( si.width() / sh.width() == 1 ) {
145 if ( si.width() < sizeHintTwoButtons( 4 ).width()) 145 if ( si.width() < sizeHintTwoButtons( 4 ).width())
146 continue; 146 continue;
147 } 147 }
148 *b = true; 148 *b = true;
149 //qDebug("fooooooooooooooooooooooouuuuund "); 149 //qDebug("fooooooooooooooooooooooouuuuund ");
150 break; 150 break;
151 } 151 }
152 } 152 }
153 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); 153 //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
154 return fo; 154 return fo;
155} 155}
156QSize KDateNavigator::sizeHint() const 156QSize KDateNavigator::sizeHint() const
157{ 157{
158 QFontMetrics fm ( font() ); 158 QFontMetrics fm ( font() );
159 QSize day = daymatrix->sizeHint(); 159 QSize day = daymatrix->sizeHint();
160 QSize nav = mNavigatorBar->sizeHint(); 160 QSize nav = mNavigatorBar->sizeHint();
161 int wid = fm.width( "30") + day.width()+3; 161 int wid = fm.width( "30") + day.width()+3;
162 int hei = fm.height() +day.height()+nav.height()+2; 162 int hei = fm.height() +day.height()+nav.height()+2;
163 if ( wid < nav.width() ) 163 if ( wid < nav.width() )
164 wid = nav.width() ; 164 wid = nav.width() ;
165 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 165 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
166 return QSize ( wid, hei ); 166 return QSize ( wid, hei );
167} 167}
168QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const 168QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const
169{ 169{
170 QFontMetrics fm ( font() ); 170 QFontMetrics fm ( font() );
171 QSize day = daymatrix->sizeHint(); 171 QSize day = daymatrix->sizeHint();
172 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); 172 QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum );
173 int wid = fm.width( "30") + day.width()+3; 173 int wid = fm.width( "30") + day.width()+3;
174 int hei = fm.height() +day.height()+nav.height()+2; 174 int hei = fm.height() +day.height()+nav.height()+2;
175 if ( wid < nav.width() ) 175 if ( wid < nav.width() )
176 wid = nav.width() ; 176 wid = nav.width() ;
177 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); 177 //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
178 return QSize ( wid, hei ); 178 return QSize ( wid, hei );
179} 179}
180void KDateNavigator::slotMonthSelected( int m ) 180void KDateNavigator::slotMonthSelected( int m )
181{ 181{
182 if ( m_MthYr.month() <= mMonthSignalOffset) 182 if ( m_MthYr.month() <= mMonthSignalOffset)
183 m += 12; 183 m += 12;
184 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); 184 //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset);
185 emit monthSelected( m - mMonthSignalOffset ); 185 emit monthSelected( m - mMonthSignalOffset );
186 186
187} 187}
188void KDateNavigator::setCalendar( Calendar *cal ) 188void KDateNavigator::setCalendar( Calendar *cal )
189{ 189{
190 daymatrix->setCalendar( cal ); 190 daymatrix->setCalendar( cal );
191} 191}
192 192
193void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true 193void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
194{ 194{
195 m_MthYr = date; 195 m_MthYr = date;
196 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); 196 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1());
197 197
198 updateDates(); 198 updateDates();
199 updateView(); 199 updateView();
200 200
201 KCal::DateList dates; 201 KCal::DateList dates;
202 dates.append( date ); 202 dates.append( date );
203 mNavigatorBar->selectDates( dates ); 203 mNavigatorBar->selectDates( dates );
204 204
205 daymatrix->clearSelection(); 205 daymatrix->clearSelection();
206 if ( doRepaint ) 206 if ( doRepaint )
207 daymatrix->repaint( false ); 207 daymatrix->repaint( false );
208} 208}
209 209
210void KDateNavigator::enableRollover(RolloverType r) 210void KDateNavigator::enableRollover(RolloverType r)
211{ 211{
212 switch(r) 212 switch(r)
213 { 213 {
214 case None : 214 case None :
215 if (updateTimer) 215 if (updateTimer)
216 { 216 {
217 updateTimer->stop(); 217 updateTimer->stop();
218 delete updateTimer; 218 delete updateTimer;
219 updateTimer=0L; 219 updateTimer=0L;
220 } 220 }
221 break; 221 break;
222 case FollowDay : 222 case FollowDay :
223 case FollowMonth : 223 case FollowMonth :
224 if (!updateTimer) 224 if (!updateTimer)
225 { 225 {
226 updateTimer = new QTimer(this); 226 updateTimer = new QTimer(this);
227 QObject::connect(updateTimer,SIGNAL(timeout()), 227 QObject::connect(updateTimer,SIGNAL(timeout()),
228 this,SLOT(possiblyPastMidnight())); 228 this,SLOT(possiblyPastMidnight()));
229 } 229 }
230 updateTimer->start(0,true); 230 updateTimer->start(0,true);
231 lastDayChecked = QDate::currentDate(); 231 lastDayChecked = QDate::currentDate();
232 } 232 }
233 updateRollover=r; 233 updateRollover=r;
234} 234}
235 235
236 236
237KDateNavigator::~KDateNavigator() 237KDateNavigator::~KDateNavigator()
238{ 238{
239} 239}
240 240
241 241
242void KDateNavigator::passedMidnight() 242void KDateNavigator::passedMidnight()
243{ 243{
244 QDate today = QDate::currentDate(); 244 QDate today = QDate::currentDate();
245 bool emitMonth = false; 245 bool emitMonth = false;
246 246
247 if (today.month() != lastDayChecked.month()) 247 if (today.month() != lastDayChecked.month())
248 { 248 {
249 if (updateRollover==FollowMonth && 249 if (updateRollover==FollowMonth &&
250 daymatrix->isEndOfMonth()) { 250 daymatrix->isEndOfMonth()) {
251 goNextMonth(); 251 goNextMonth();
252 emitMonth=true; 252 emitMonth=true;
253 } 253 }
254 } 254 }
255 daymatrix->recalculateToday(); 255 daymatrix->recalculateToday();
256 daymatrix->repaint( false ); 256 daymatrix->repaint( false );
257 emit dayPassed(today); 257 emit dayPassed(today);
258 if (emitMonth) { emit monthPassed(today); } 258 if (emitMonth) { emit monthPassed(today); }
259} 259}
260 260
261/* slot */ void KDateNavigator::possiblyPastMidnight() 261/* slot */ void KDateNavigator::possiblyPastMidnight()
262{ 262{
263 if (lastDayChecked!=QDate::currentDate()) 263 if (lastDayChecked!=QDate::currentDate())
264 { 264 {
265 passedMidnight(); 265 passedMidnight();
266 lastDayChecked=QDate::currentDate(); 266 lastDayChecked=QDate::currentDate();
267 } 267 }
268 // Set the timer to go off 1 second after midnight 268 // Set the timer to go off 1 second after midnight
269 // or after 8 minutes, whichever comes first. 269 // or after 8 minutes, whichever comes first.
270 if (updateTimer) 270 if (updateTimer)
271 { 271 {
272 QTime now = QTime::currentTime(); 272 QTime now = QTime::currentTime();
273 QTime midnight = QTime(23,59,59); 273 QTime midnight = QTime(23,59,59);
274 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); 274 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
275 275
276 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) 276 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
277 //.arg(now.toString()).arg(midnight.toString())); 277 //.arg(now.toString()).arg(midnight.toString()));
278 278
279 updateTimer->stop(); 279 updateTimer->stop();
280 updateTimer->start(msecsWait,true); 280 updateTimer->start(msecsWait,true);
281 } 281 }
282} 282}
283 283
284void KDateNavigator::updateDates() 284void KDateNavigator::updateDates()
285{ 285{
286 // Find the first day of the week of the current month. 286 // Find the first day of the week of the current month.
287 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); 287 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
288 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); 288 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
289 int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); 289 int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
290 //int di = d1 - d2 + 1; 290 //int di = d1 - d2 + 1;
291 dayone = dayone.addDays( -d2 + 1 ); 291 dayone = dayone.addDays( -d2 + 1 );
292 292
293 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); 293 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
294 294
295 // If month begins on Monday and Monday is first day of week, 295 // If month begins on Monday and Monday is first day of week,
296 // month should begin on second line. Sunday doesn't have this problem. 296 // month should begin on second line. Sunday doesn't have this problem.
297 int nextLine = ( ( m_fstDayOfWkCalsys == 1) && 297 int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
298 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; 298 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
299 299
300 // update the matrix dates 300 // update the matrix dates
301 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; 301 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
302 302
303 303
304 daymatrix->updateView(dayone.addDays(index)); 304 daymatrix->updateView(dayone.addDays(index));
305//each updateDates is followed by an updateView -> repaint is issued there ! 305//each updateDates is followed by an updateView -> repaint is issued there !
306// daymatrix->repaint(); 306// daymatrix->repaint();
307} 307}
308 308
309void KDateNavigator::updateDayMatrix() 309void KDateNavigator::updateDayMatrix()
310{ 310{
311 daymatrix->updateView(); 311 daymatrix->updateView();
312 //daymatrix->repaint(); 312 //daymatrix->repaint();
313} 313}
314 314
315 315
316void KDateNavigator::updateView() 316void KDateNavigator::updateView()
317{ 317{
318 318
319 setUpdatesEnabled( false ); 319 setUpdatesEnabled( false );
320 320
321 int i; 321 int i;
322 322
323// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 323// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
324 daymatrix->updateView(); 324 daymatrix->updateView();
325 325
326 // set the week numbers. 326 // set the week numbers.
327 for(i = 0; i < 6; i++) { 327 for(i = 0; i < 6; i++) {
328 QString weeknum; 328 QString weeknum;
329 // remember, according to ISO 8601, the first week of the year is the 329 // remember, according to ISO 8601, the first week of the year is the
330 // first week that contains a thursday. Thus we must subtract off 4, 330 // first week that contains a thursday. Thus we must subtract off 4,
331 // not just 1. 331 // not just 1.
332 332
333 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); 333 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
334 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); 334 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4)));
335 335
336 int add = 0; 336 int add = 0;
337 if ( ! KGlobal::locale()->weekStartsMonday() ) 337 if ( ! KGlobal::locale()->weekStartsMonday() )
338 ++add; 338 ++add;
339 if (dayOfYear % 7 != 0) 339 if (dayOfYear % 7 != 0)
340 weeknum.setNum(dayOfYear / 7 + 1+add); 340 weeknum.setNum(dayOfYear / 7 + 1+add);
341 else 341 else
342 weeknum.setNum(dayOfYear / 7 +add); 342 weeknum.setNum(dayOfYear / 7 +add);
343 weeknos[i]->setText(weeknum); 343 weeknos[i]->setText(weeknum);
344 } 344 }
345 345
346 setUpdatesEnabled( true ); 346 setUpdatesEnabled( true );
347// kdDebug() << "updateView() -> repaint()" << endl; 347// kdDebug() << "updateView() -> repaint()" << endl;
348 repaint(); 348 repaint();
349 // daymatrix->repaint(); 349 // daymatrix->repaint();
350} 350}
351 351
352void KDateNavigator::updateConfig() 352void KDateNavigator::updateConfig()
353{ 353{
354 int day; 354 int day;
355 for(int i=0; i<7; i++) { 355 for(int i=0; i<7; i++) {
356 // take the first letter of the day name to be the abbreviation 356 // take the first letter of the day name to be the abbreviation
357 if (KGlobal::locale()->weekStartsMonday()) { 357 if (KGlobal::locale()->weekStartsMonday()) {
358 day = i+1; 358 day = i+1;
359 } else { 359 } else {
360 if (i==0) day = 7; 360 if (i==0) day = 7;
361 else day = i; 361 else day = i;
362 } 362 }
363 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, 363 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
364 true ); 364 true );
365 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); 365 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
366 headings[i]->setText( dayName ); 366 headings[i]->setText( dayName );
367 } 367 }
368 updateDates(); 368 updateDates();
369 updateView(); 369 updateView();
370} 370}
371 371
372void KDateNavigator::setShowWeekNums(bool enabled) 372void KDateNavigator::setShowWeekNums(bool enabled)
373{ 373{
374 qDebug("KDateNavigator::setShowWeekNums***************************** "); 374 qDebug("KDateNavigator::setShowWeekNums***************************** ");
375 m_bShowWeekNums = enabled; 375 m_bShowWeekNums = enabled;
376 for(int i=0; i<6; i++) { 376 for(int i=0; i<6; i++) {
377 if(enabled) 377 if(enabled)
378 weeknos[i]->show(); 378 weeknos[i]->show();
379 else 379 else
380 weeknos[i]->hide(); 380 weeknos[i]->hide();
381 } 381 }
382 resize(size()); 382 resize(size());
383} 383}
384 384
385void KDateNavigator::selectDates(const DateList& dateList) 385void KDateNavigator::selectDates(const DateList& dateList)
386{ 386{
387 387
388 if (dateList.count() > 0) { 388 if (dateList.count() > 0) {
389 mNavigatorBar->selectDates( dateList ); 389 mNavigatorBar->selectDates( dateList );
390 mSelectedDates = dateList; 390 mSelectedDates = dateList;
391 391
392 // set our record of the month and year that this datetbl is 392 // set our record of the month and year that this datetbl is
393 // displaying. 393 // displaying.
394 m_MthYr = mSelectedDates.first(); 394 m_MthYr = mSelectedDates.first();
395 395
396 396
397 // set our record of the first day of the week of the current 397 // set our record of the first day of the week of the current
398 // month. This needs to be done before calling dayToIndex, since it 398 // month. This needs to be done before calling dayToIndex, since it
399 // relies on this information being up to date. 399 // relies on this information being up to date.
400 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 400 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
401 m_fstDayOfWk = dayone.dayOfWeek(); 401 m_fstDayOfWk = dayone.dayOfWeek();
402 402
403 updateDates(); 403 updateDates();
404 404
405 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 405 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
406 406
407 updateView(); 407 updateView();
408 } 408 }
409} 409}
410 410
411int KDateNavigator::dayNum(int row, int col) 411int KDateNavigator::dayNum(int row, int col)
412{ 412{
413 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; 413 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk;
414} 414}
415 415
416int KDateNavigator::dayToIndex(int dayNum) 416int KDateNavigator::dayToIndex(int dayNum)
417{ 417{
418 int row, col; 418 int row, col;
419 419
420 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; 420 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7;
421 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) 421 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1))
422 row++; 422 row++;
423 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; 423 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7;
424 return row * 7 + col; 424 return row * 7 + col;
425} 425}
426 426
427void KDateNavigator::wheelEvent (QWheelEvent *e) 427void KDateNavigator::wheelEvent (QWheelEvent *e)
428{ 428{
429 if(e->delta()>0) emit goPrevious(); 429 if(e->delta()>0) emit goPrevious();
430 else emit goNext(); 430 else emit goNext();
431 431
432 e->accept(); 432 e->accept();
433} 433}
434 434
435bool KDateNavigator::eventFilter (QObject *o,QEvent *e) 435bool KDateNavigator::eventFilter (QObject *o,QEvent *e)
436{ 436{
437 if (e->type() == QEvent::MouseButtonPress) { 437 if (e->type() == QEvent::MouseButtonPress) {
438 int i; 438 int i;
439 for(i=0;i<6;++i) { 439 for(i=0;i<6;++i) {
440 if (o == weeknos[i]) { 440 if (o == weeknos[i]) {
441 QDate weekstart = daymatrix->getDate(i*7); 441 QDate weekstart = daymatrix->getDate(i*7);
442 emit weekClicked(weekstart); 442 emit weekClicked(weekstart);
443 break; 443 break;
444 } 444 }
445 } 445 }
446 for(i=0;i<7;++i) { 446 for(i=0;i<7;++i) {
447 if (o == headings[i]) { 447 if (o == headings[i]) {
448 KCal::DateList selDays; 448 KCal::DateList selDays;
449 QDate date = daymatrix->getDate(14); 449 QDate date = daymatrix->getDate(14);
450 emit showMonth(date );
451#if 0
450 int dio = date.daysInMonth(); 452 int dio = date.daysInMonth();
451 int j; 453 int j;
452 int ye = date.year(); 454 int ye = date.year();
453 int mo = date.month(); 455 int mo = date.month();
454 for ( j = 1; j <= dio; ++j ) { 456 for ( j = 1; j <= dio; ++j ) {
455 selDays.append( QDate( ye, mo, j ) ); 457 selDays.append( QDate( ye, mo, j ) );
456 } 458 }
457 emit datesSelected( selDays ); 459 emit datesSelected( selDays );
460#endif
458 break; 461 break;
459 } 462 }
460 } 463 }
461 return true; 464 return true;
462 } else { 465 } else {
463 return false; 466 return false;
464 } 467 }
465} 468}
466 469
467//#include "kdatenavigator.moc" 470//#include "kdatenavigator.moc"
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h
index 93bbceb..780ebb8 100644
--- a/korganizer/kdatenavigator.h
+++ b/korganizer/kdatenavigator.h
@@ -1,166 +1,167 @@
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#ifndef KDATENAVIGATOR_H 23#ifndef KDATENAVIGATOR_H
24#define KDATENAVIGATOR_H 24#define KDATENAVIGATOR_H
25 25
26#include <qframe.h> 26#include <qframe.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qlabel.h> 28#include <qlabel.h>
29 29
30#include <libkcal/calendar.h> 30#include <libkcal/calendar.h>
31 31
32#include "kodaymatrix.h" 32#include "kodaymatrix.h"
33 33
34class QPushButton; 34class QPushButton;
35class QTimer; 35class QTimer;
36 36
37class KCalendarSystem; 37class KCalendarSystem;
38 38
39class NavigatorBar; 39class NavigatorBar;
40 40
41class KDateNavigator: public QFrame 41class KDateNavigator: public QFrame
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44 public: 44 public:
45 KDateNavigator( QWidget *parent = 0,const char *name = 0 ); 45 KDateNavigator( QWidget *parent = 0,const char *name = 0 );
46 ~KDateNavigator(); 46 ~KDateNavigator();
47 47
48 /** The DateNavigator automatically checks for 48 /** The DateNavigator automatically checks for
49 * the passage of midnight. If rollover type is 49 * the passage of midnight. If rollover type is
50 * set to None, no signals are emitted and no 50 * set to None, no signals are emitted and no
51 * processing is done. With rollover set to 51 * processing is done. With rollover set to
52 * FollowDay, the day highlighter changes at 52 * FollowDay, the day highlighter changes at
53 * midnight and dayPassed() is emitted. 53 * midnight and dayPassed() is emitted.
54 * With FollowMonth, it has the same effect 54 * With FollowMonth, it has the same effect
55 * as FollowDay but also adjusts the month that is 55 * as FollowDay but also adjusts the month that is
56 * visible and emits monthPassed() when the month changes. 56 * visible and emits monthPassed() when the month changes.
57 */ 57 */
58 enum RolloverType { None, FollowDay, FollowMonth } ; 58 enum RolloverType { None, FollowDay, FollowMonth } ;
59 void enableRollover( RolloverType ); 59 void enableRollover( RolloverType );
60 60
61 void setShowWeekNums( bool enabled ); 61 void setShowWeekNums( bool enabled );
62 void setCalendar( Calendar * ); 62 void setCalendar( Calendar * );
63 void setBaseDate( const QDate & , bool doRepaint = true ); 63 void setBaseDate( const QDate & , bool doRepaint = true );
64 64
65 QDate baseDate() const { return m_MthYr;} 65 QDate baseDate() const { return m_MthYr;}
66 66
67 KCal::DateList selectedDates() const { return mSelectedDates; } 67 KCal::DateList selectedDates() const { return mSelectedDates; }
68 NavigatorBar *navigatorBar() const { return mNavigatorBar; } 68 NavigatorBar *navigatorBar() const { return mNavigatorBar; }
69 void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off%12;} 69 void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off%12;}
70 QSize yourSizeHint()const { return mySizeHint; }; 70 QSize yourSizeHint()const { return mySizeHint; };
71 QSize yourFullSizeHint() const { return myFullSizeHint;}; 71 QSize yourFullSizeHint() const { return myFullSizeHint;};
72 QFont yourFontHint( QSize , bool * b); 72 QFont yourFontHint( QSize , bool * b);
73 bool fontChanged() {return mFontChanged; } 73 bool fontChanged() {return mFontChanged; }
74 void unsetFontChanged() { mFontChanged = false; } 74 void unsetFontChanged() { mFontChanged = false; }
75 KODayMatrix *dayMatrix() { return daymatrix ;} 75 KODayMatrix *dayMatrix() { return daymatrix ;}
76 QSize sizeHint() const; 76 QSize sizeHint() const;
77 QSize sizeHintTwoButtons( int butnum = 2 ) const; 77 QSize sizeHintTwoButtons( int butnum = 2 ) const;
78 void changeFont ( QFont fo ); 78 void changeFont ( QFont fo );
79 public slots: 79 public slots:
80 void selectDates( const KCal::DateList & ); 80 void selectDates( const KCal::DateList & );
81 void updateView(); 81 void updateView();
82 void updateConfig(); 82 void updateConfig();
83 void updateDayMatrix(); 83 void updateDayMatrix();
84 84
85 signals: 85 signals:
86 void datesSelected( const KCal::DateList & ); 86 void datesSelected( const KCal::DateList & );
87 void eventDropped( Event * ); 87 void eventDropped( Event * );
88 void weekClicked( const QDate &); 88 void weekClicked( const QDate &);
89 void showMonth( const QDate & );
89 90
90 void goPrevious(); 91 void goPrevious();
91 void goNext(); 92 void goNext();
92 93
93 void goNextMonth(); 94 void goNextMonth();
94 void goPrevMonth(); 95 void goPrevMonth();
95 void goNextYear(); 96 void goNextYear();
96 void goPrevYear(); 97 void goPrevYear();
97 void monthSelected( int ); 98 void monthSelected( int );
98 99
99 // Signals emitted at midnight carrying the new date. 100 // Signals emitted at midnight carrying the new date.
100 void dayPassed( QDate ); 101 void dayPassed( QDate );
101 void monthPassed( QDate ); 102 void monthPassed( QDate );
102 103
103 protected slots: 104 protected slots:
104 105
105 /** 106 /**
106 * Called regularly to see if we need to update the view 107 * Called regularly to see if we need to update the view
107 * wrt. the today box and the month box. Only important 108 * wrt. the today box and the month box. Only important
108 * if you leave KOrganizer idle for long periods of time. 109 * if you leave KOrganizer idle for long periods of time.
109 * 110 *
110 * Until we have a reliable way of setting QTimers to go 111 * Until we have a reliable way of setting QTimers to go
111 * off at a particular wall-clock time, we need this, 112 * off at a particular wall-clock time, we need this,
112 * which calls passedMidnight() at the right moments. 113 * which calls passedMidnight() at the right moments.
113 */ 114 */
114 void possiblyPastMidnight(); 115 void possiblyPastMidnight();
115 116
116 /** handles updating the view when midnight has come by due to idle time. 117 /** handles updating the view when midnight has come by due to idle time.
117 * 118 *
118 */ 119 */
119 void passedMidnight(); 120 void passedMidnight();
120 void slotMonthSelected( int m ); 121 void slotMonthSelected( int m );
121 protected: 122 protected:
122 void updateDates(); 123 void updateDates();
123 124
124 void wheelEvent (QWheelEvent *); 125 void wheelEvent (QWheelEvent *);
125 126
126 bool eventFilter (QObject *,QEvent *); 127 bool eventFilter (QObject *,QEvent *);
127 128
128 private: 129 private:
129 QSize mySizeHint; 130 QSize mySizeHint;
130 QSize myFullSizeHint; 131 QSize myFullSizeHint;
131 bool mFontChanged; 132 bool mFontChanged;
132 int mMonthSignalOffset; 133 int mMonthSignalOffset;
133 NavigatorBar *mNavigatorBar; 134 NavigatorBar *mNavigatorBar;
134 135
135 QFrame *headingSep; 136 QFrame *headingSep;
136 QFrame *weeknumSep; 137 QFrame *weeknumSep;
137 QLabel *headings[7]; 138 QLabel *headings[7];
138 QLabel *weeknos[7]; 139 QLabel *weeknos[7];
139 KODayMatrix *daymatrix; 140 KODayMatrix *daymatrix;
140 141
141 KCal::DateList mSelectedDates; 142 KCal::DateList mSelectedDates;
142 QDate m_MthYr; 143 QDate m_MthYr;
143 int m_fstDayOfWk; 144 int m_fstDayOfWk;
144 bool m_bShowWeekNums; 145 bool m_bShowWeekNums;
145 146
146 int dayNum(int row, int col); 147 int dayNum(int row, int col);
147 int dayToIndex(int dayNum); 148 int dayToIndex(int dayNum);
148 149
149 Calendar *mCalendar; 150 Calendar *mCalendar;
150 KCalendarSystem *mCalendarSystem; 151 KCalendarSystem *mCalendarSystem;
151 152
152 const QString *curHeaders; 153 const QString *curHeaders;
153 154
154 /** used to update the day view periodically, in particular every 155 /** used to update the day view periodically, in particular every
155 * midnight to move the "today" rectangle. 156 * midnight to move the "today" rectangle.
156 */ 157 */
157 QTimer *updateTimer; 158 QTimer *updateTimer;
158 QDate lastDayChecked; 159 QDate lastDayChecked;
159 RolloverType updateRollover; 160 RolloverType updateRollover;
160 161
161 // Disabling copy constructor and assignment operator 162 // Disabling copy constructor and assignment operator
162 KDateNavigator(const KDateNavigator & ); 163 KDateNavigator(const KDateNavigator & );
163 KDateNavigator &operator=(const KDateNavigator &); 164 KDateNavigator &operator=(const KDateNavigator &);
164}; 165};
165 166
166#endif 167#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index c6e76c4..5a2dce3 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,720 +1,728 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 91 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 92 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 93 showMonthView();
94 else 94 else
95 showMonthViewWeek(); 95 showMonthViewWeek();
96 } 96 }
97 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
101 else { 101 else {
102 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
105 showAgendaView(); 105 showAgendaView();
106 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 109#endif
110 } 110 }
111} 111}
112 112
113void KOViewManager::showDateView( int view, QDate date) 113void KOViewManager::showDateView( int view, QDate date)
114{ 114{
115 static int lastMode = 0; 115 static int lastMode = 0;
116 static int lastCount = 0; 116 static int lastCount = 0;
117 static bool lastNDMode = false; 117 static bool lastNDMode = false;
118 static QDate lastDate; 118 static QDate lastDate;
119 //qDebug("date %d %s", view, date.toString().latin1()); 119 //qDebug("date %d %s", view, date.toString().latin1());
120 120
121 if (view != 9) 121 if (view != 9)
122 lastMode = 0; 122 lastMode = 0;
123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
124 bool savemFlagShowNextxDays = mFlagShowNextxDays; 124 bool savemFlagShowNextxDays = mFlagShowNextxDays;
125 mFlagShowNextxDays = false; 125 mFlagShowNextxDays = false;
126 if ( view == 3 ) { 126 if ( view == 3 ) {
127 //mCurrentAgendaView = 1 ; 127 //mCurrentAgendaView = 1 ;
128 lastDate = mMainView->dateNavigator()->selectedDates().first(); 128 lastDate = mMainView->dateNavigator()->selectedDates().first();
129 lastCount = mMainView->dateNavigator()->selectedDates().count(); 129 lastCount = mMainView->dateNavigator()->selectedDates().count();
130 lastNDMode = savemFlagShowNextxDays; 130 lastNDMode = savemFlagShowNextxDays;
131 mMainView->showDay( date ); 131 mMainView->dateNavigator()->selectDate( date );
132 lastMode = 1; 132 lastMode = 1;
133 mCurrentAgendaView = 1 ;
133 } else if (view == 4 ) { 134 } else if (view == 4 ) {
134 mCurrentAgendaView = 7 ; 135 mCurrentAgendaView = 7 ;
135 mMainView->dateNavigator()->selectDates( date, 7 ); 136 mMainView->dateNavigator()->selectDates( date, 7 );
136 } else if (view == 5 ) { 137 } else if (view == 5 ) {
137 mCurrentAgendaView = 14 ; 138 mCurrentAgendaView = 14 ;
138 mMainView->dateNavigator()->selectDates( date, 14); 139 mMainView->dateNavigator()->selectDates( date, 14);
139 } else if (view == 6 ) { 140 } else if (view == 6 ) {
140 //mMainView->dateNavigator()->selectDates( date, 7 ); 141 //mMainView->dateNavigator()->selectDates( date, 7 );
141 showMonthView(); 142 showMonthView();
142 } else if (view == 7 ) { 143 } else if (view == 7 ) {
143 mMainView->dateNavigator()->selectDate( date ); 144 mMainView->dateNavigator()->selectDate( date );
144 showJournalView(); 145 showJournalView();
145 } else if (view == 8 ) { 146 } else if (view == 8 ) {
146 globalFlagBlockAgenda = 1; 147 globalFlagBlockAgenda = 1;
147 if ( mCurrentAgendaView != 3 ) 148 if ( mCurrentAgendaView != 3 )
148 mCurrentAgendaView = -1; 149 mCurrentAgendaView = -1;
149 showAgendaView(KOPrefs::instance()->mFullViewMonth); 150 showAgendaView(KOPrefs::instance()->mFullViewMonth);
150 globalFlagBlockAgenda = 2; 151 globalFlagBlockAgenda = 2;
151 mMainView->dateNavigator()->selectDates( date , 152 mMainView->dateNavigator()->selectDates( date ,
152 KOPrefs::instance()->mNextXDays ); 153 KOPrefs::instance()->mNextXDays );
153 mFlagShowNextxDays = true; 154 mFlagShowNextxDays = true;
154 mCurrentAgendaView = 3 ; 155 mCurrentAgendaView = 3 ;
155 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
156 if ( lastMode ) { 157 if ( lastMode ) {
157 mCurrentAgendaView = lastCount ; 158 mCurrentAgendaView = lastCount ;
158 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 159 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
159 mFlagShowNextxDays = lastNDMode; 160 mFlagShowNextxDays = lastNDMode;
160 if ( mFlagShowNextxDays ) { 161 if ( mFlagShowNextxDays ) {
161 mCurrentAgendaView = 3 ; 162 mCurrentAgendaView = 3 ;
162 } 163 }
163 } else 164 } else
164 showWeekView(); 165 showWeekView();
165 } else if (view == 10) { 166 } else if (view == 10) {
166 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
167 } 168 }
168} 169}
169 170
170 171
171 172
172void KOViewManager::writeSettings(KConfig *config) 173void KOViewManager::writeSettings(KConfig *config)
173{ 174{
174 config->setGroup("General"); 175 config->setGroup("General");
175 176
176 QString view; 177 QString view;
177 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 178 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
178 else if (mCurrentView == mMonthView) view = "Month"; 179 else if (mCurrentView == mMonthView) view = "Month";
179 else if (mCurrentView == mListView) view = "List"; 180 else if (mCurrentView == mListView) view = "List";
180 else if (mCurrentView == mJournalView) view = "Journal"; 181 else if (mCurrentView == mJournalView) view = "Journal";
181 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
182 else if (mCurrentView == mTodoView) view = "Todo"; 183 else if (mCurrentView == mTodoView) view = "Todo";
183 else view = "Agenda"; 184 else view = "Agenda";
184 185
185 config->writeEntry("Current View",view); 186 config->writeEntry("Current View",view);
186 187
187 if (mAgendaView) { 188 if (mAgendaView) {
188 mAgendaView->writeSettings(config); 189 mAgendaView->writeSettings(config);
189 } 190 }
190 if (mTimeSpanView) { 191 if (mTimeSpanView) {
191 mTimeSpanView->writeSettings(config); 192 mTimeSpanView->writeSettings(config);
192 } 193 }
193 if (mListView) { 194 if (mListView) {
194 mListView->writeSettings(config); 195 mListView->writeSettings(config);
195 } 196 }
196 if (mTodoView) { 197 if (mTodoView) {
197 mTodoView->saveLayout(config,"Todo View"); 198 mTodoView->saveLayout(config,"Todo View");
198 } 199 }
199} 200}
200 201
201void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 202void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
202{ 203{
203 204
204 //mFlagShowNextxDays = false; 205 //mFlagShowNextxDays = false;
205 //if(view == mCurrentView) return; 206 //if(view == mCurrentView) return;
206 if ( view == 0 ) { 207 if ( view == 0 ) {
207 view = mCurrentView; 208 view = mCurrentView;
208 if ( view == 0 ) 209 if ( view == 0 )
209 return; 210 return;
210 } 211 }
211 bool callupdate = !(view == mCurrentView); 212 bool callupdate = !(view == mCurrentView);
212 bool full = fullScreen; 213 bool full = fullScreen;
213 if(view == mCurrentView && view != mWhatsNextView ) { 214 if(view == mCurrentView && view != mWhatsNextView ) {
214 if ( mCurrentAgendaView < 0 ) 215 if ( mCurrentAgendaView < 0 )
215 return; 216 return;
216 if ( view != mMonthView ) 217 if ( view != mMonthView )
217 full = mMainView->leftFrame()->isVisible(); 218 full = mMainView->leftFrame()->isVisible();
218 } else { 219 } else {
219 if ( view == mMonthView && mMonthView) 220 if ( view == mMonthView && mMonthView)
220 ;//mMonthView->skipResize = true ; 221 ;//mMonthView->skipResize = true ;
221 mCurrentView = view; 222 mCurrentView = view;
222 // bool full = fullScreen; 223 // bool full = fullScreen;
223 bool isFull = !mMainView->leftFrame()->isVisible(); 224 bool isFull = !mMainView->leftFrame()->isVisible();
224 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 225 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
225 full = true; 226 full = true;
226 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 227 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
227 full = false; 228 full = false;
228 } 229 }
229 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 230 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
230 //raiseCurrentView( full ); 231 //raiseCurrentView( full );
231 mMainView->processIncidenceSelection( 0 ); 232 mMainView->processIncidenceSelection( 0 );
232 //mMainView->updateView(); 233 //mMainView->updateView();
233 raiseCurrentView( full, callupdate ); 234 raiseCurrentView( full, callupdate );
234 mMainView->adaptNavigationUnits(); 235 mMainView->adaptNavigationUnits();
235} 236}
236 237
237void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 238void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
238{ 239{
239 mCurrentAgendaView = 0; 240 mCurrentAgendaView = 0;
240 if ( fullScreen ) { 241 if ( fullScreen ) {
241 mMainView->leftFrame()->hide(); 242 mMainView->leftFrame()->hide();
242 } else { 243 } else {
243 mMainView->leftFrame()->show(); 244 mMainView->leftFrame()->show();
244 } 245 }
245 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 246 //if ( mCurrentView == mMonthView ) qApp->processEvents();
246 emit signalFullScreen( !fullScreen ); 247 emit signalFullScreen( !fullScreen );
247 if ( callUpdateView ) 248 if ( callUpdateView )
248 mMainView->updateView(); 249 mMainView->updateView();
249 250
250 if ( globalFlagBlockAgenda == 5 ) { 251 if ( globalFlagBlockAgenda == 5 ) {
251 globalFlagBlockAgenda = 4; 252 globalFlagBlockAgenda = 4;
252 globalFlagBlockAgendaItemPaint = 1; 253 globalFlagBlockAgendaItemPaint = 1;
253 } 254 }
254 mMainView->viewStack()->raiseWidget(mCurrentView); 255 mMainView->viewStack()->raiseWidget(mCurrentView);
255 if ( globalFlagBlockAgenda == 4 ) { 256 if ( globalFlagBlockAgenda == 4 ) {
256 if ( mCurrentView == mAgendaView ) { 257 if ( mCurrentView == mAgendaView ) {
257 //globalFlagBlockAgenda =1 ; 258 //globalFlagBlockAgenda =1 ;
258 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 259 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
259 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 260 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
260 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 261 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
261 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 262 mAgendaView->setStartHour( QTime::currentTime ().hour() );
262 qApp->processEvents(); 263 qApp->processEvents();
263 //qDebug("qApp->processEvents() "); 264 //qDebug("qApp->processEvents() ");
264 globalFlagBlockAgenda = 0; 265 globalFlagBlockAgenda = 0;
265 mAgendaView->repaintAgenda(); 266 mAgendaView->repaintAgenda();
266 267
267 } 268 }
268 globalFlagBlockAgenda = 0; 269 globalFlagBlockAgenda = 0;
269 } 270 }
270 emit signalAgendaView( mCurrentView == mAgendaView ); 271 emit signalAgendaView( mCurrentView == mAgendaView );
271 //qDebug("raiseCurrentView ende "); 272 //qDebug("raiseCurrentView ende ");
272 273
273} 274}
274 275
275void KOViewManager::updateView() 276void KOViewManager::updateView()
276{ 277{
277 // qDebug("KOViewManager::updateView() "); 278 // qDebug("KOViewManager::updateView() ");
278 // if we are updating mTodoView, we get endless recursion 279 // if we are updating mTodoView, we get endless recursion
279 if ( mTodoView == mCurrentView ) 280 if ( mTodoView == mCurrentView )
280 return; 281 return;
281 if ( mCurrentView ) mCurrentView->updateView(); 282 if ( mCurrentView ) mCurrentView->updateView();
282 283
283} 284}
284 285
285void KOViewManager::updateView(const QDate &start, const QDate &end) 286void KOViewManager::updateView(const QDate &start, const QDate &end)
286{ 287{
287 // kdDebug() << "KOViewManager::updateView()" << endl; 288 // kdDebug() << "KOViewManager::updateView()" << endl;
288 289
289 if (mCurrentView) mCurrentView->showDates(start, end); 290 if (mCurrentView) mCurrentView->showDates(start, end);
290 291
291 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 292 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
292} 293}
293 294
294 295
295void KOViewManager::updateWNview() 296void KOViewManager::updateWNview()
296{ 297{
297 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 298 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
298 mWhatsNextView->updateView(); 299 mWhatsNextView->updateView();
299 300
300} 301}
301void KOViewManager::showWhatsNextView() 302void KOViewManager::showWhatsNextView()
302{ 303{
303 if (!mWhatsNextView) { 304 if (!mWhatsNextView) {
304 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 305 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
305 "KOViewManager::WhatsNextView"); 306 "KOViewManager::WhatsNextView");
306 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 307 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
307 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 308 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
308 addView(mWhatsNextView); 309 addView(mWhatsNextView);
309 connect(this, SIGNAL( printWNV() ), 310 connect(this, SIGNAL( printWNV() ),
310 mWhatsNextView, SLOT( printMe() ) ); 311 mWhatsNextView, SLOT( printMe() ) );
311 } 312 }
312 globalFlagBlockAgenda = 1; 313 globalFlagBlockAgenda = 1;
313 showView(mWhatsNextView, true ); 314 showView(mWhatsNextView, true );
314 //mWhatsNextView->updateView(); 315 //mWhatsNextView->updateView();
315 316
316} 317}
317 318
318void KOViewManager::showListView() 319void KOViewManager::showListView()
319{ 320{
320 if (!mListView) { 321 if (!mListView) {
321 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 322 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
322 addView(mListView); 323 addView(mListView);
323 324
324 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 325 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
325 mMainView, SLOT(showIncidence(Incidence *))); 326 mMainView, SLOT(showIncidence(Incidence *)));
326 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 327 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
327 mMainView, SLOT(editIncidence(Incidence *))); 328 mMainView, SLOT(editIncidence(Incidence *)));
328 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 329 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
329 mMainView, SLOT(deleteIncidence(Incidence *))); 330 mMainView, SLOT(deleteIncidence(Incidence *)));
330 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 331 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
331 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 332 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
332 connect( mListView, SIGNAL( signalNewEvent() ), 333 connect( mListView, SIGNAL( signalNewEvent() ),
333 mMainView, SLOT( newEvent() ) ); 334 mMainView, SLOT( newEvent() ) );
334 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 335 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
335 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 336 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
336 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 337 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
337 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 338 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
338 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 339 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
339 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 340 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
340 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 341 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
341 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 342 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
342 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 343 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
343 } 344 }
344 // bool temp = mFlagShowNextxDays; 345 // bool temp = mFlagShowNextxDays;
345 //globalFlagBlockPainting = true; 346 //globalFlagBlockPainting = true;
346 globalFlagBlockAgenda = 1; 347 globalFlagBlockAgenda = 1;
347 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 348 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
348 mMainView->setBlockShowDates( true ); 349 mMainView->setBlockShowDates( true );
349 mMainView->dateNavigator()->selectMonth(); 350 mMainView->dateNavigator()->selectMonth();
350 mMainView->setBlockShowDates( false ); 351 mMainView->setBlockShowDates( false );
351 } 352 }
352 showView(mListView, KOPrefs::instance()->mFullViewTodo); 353 showView(mListView, KOPrefs::instance()->mFullViewTodo);
353 //mFlagShowNextxDays = temp; 354 //mFlagShowNextxDays = temp;
354} 355}
355 356
356void KOViewManager::showAgendaView( bool fullScreen ) 357void KOViewManager::showAgendaView( bool fullScreen )
357{ 358{
358 359
359 mMainView->dialogManager()->hideSearchDialog(); 360 mMainView->dialogManager()->hideSearchDialog();
360 // qDebug("KOViewManager::showAgendaView "); 361 // qDebug("KOViewManager::showAgendaView ");
361 bool full; 362 bool full;
362 full = fullScreen; 363 full = fullScreen;
363 if (!mAgendaView) { 364 if (!mAgendaView) {
364 full = false; 365 full = false;
365 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 366 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
366 addView(mAgendaView); 367 addView(mAgendaView);
367#ifndef DESKTOP_VERSION 368#ifndef DESKTOP_VERSION
368 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 369 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
369#endif 370#endif
370 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 371 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
371 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 372 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
372 373
373 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 374 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
374 375
375 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 376 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
376 377
377 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 378 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
378 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 379 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
379 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 380 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
380 mMainView, SLOT(newEvent(QDateTime))); 381 mMainView, SLOT(newEvent(QDateTime)));
381 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 382 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
382 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 383 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
383 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 384 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
384 mMainView, SLOT(newEvent(QDate))); 385 mMainView, SLOT(newEvent(QDate)));
385 386
386 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 387 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
387 mMainView, SLOT(editIncidence(Incidence *))); 388 mMainView, SLOT(editIncidence(Incidence *)));
388 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 389 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
389 mMainView, SLOT(showIncidence(Incidence *))); 390 mMainView, SLOT(showIncidence(Incidence *)));
390 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 391 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
391 mMainView, SLOT(deleteIncidence(Incidence *))); 392 mMainView, SLOT(deleteIncidence(Incidence *)));
392 393
393 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 394 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
394 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 395 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
395 396
396 connect(mAgendaView, SIGNAL( toggleExpand() ), 397 connect(mAgendaView, SIGNAL( toggleExpand() ),
397 mMainView, SLOT( toggleExpand() ) ); 398 mMainView, SLOT( toggleExpand() ) );
398 399
399 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 400 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
400 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 401 mAgendaView, SLOT( setExpandedButton( bool ) ) );
401 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 402 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
402 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 403 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
403 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 404 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
404 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 405 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
405 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 406 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
406 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 407 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
407 SLOT( updateTodo( Todo *, int ) ) ); 408 SLOT( updateTodo( Todo *, int ) ) );
408 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 409 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
409 mMainView, SIGNAL( todoModified( Todo *, int ))); 410 mMainView, SIGNAL( todoModified( Todo *, int )));
410 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 411 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
411 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 412 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
412 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 413 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
413 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 414 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
414 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 415 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
415 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 416 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
416 mAgendaView->readSettings(); 417 mAgendaView->readSettings();
417 mAgendaView->updateConfig(); 418 mAgendaView->updateConfig();
418 } 419 }
419 420
420 showView( mAgendaView, full); 421 showView( mAgendaView, full);
421 422
422} 423}
423 424
424void KOViewManager::showDayView() 425void KOViewManager::showDayView()
425{ 426{
426 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 427 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
427 mFlagShowNextxDays = false; 428 mFlagShowNextxDays = false;
428 globalFlagBlockLabel = 1; 429 globalFlagBlockLabel = 1;
429 globalFlagBlockAgenda = 1; 430 globalFlagBlockAgenda = 1;
430 if ( mCurrentAgendaView != 1 ) 431 if ( mCurrentAgendaView != 1 )
431 mCurrentAgendaView = -1; 432 mCurrentAgendaView = -1;
432 showAgendaView(); 433 showAgendaView();
433 qApp->processEvents(); 434 qApp->processEvents();
434 globalFlagBlockAgenda = 2; 435 globalFlagBlockAgenda = 2;
435 globalFlagBlockLabel = 0; 436 globalFlagBlockLabel = 0;
436 mMainView->dateNavigator()->selectDates( 1 ); 437 mMainView->dateNavigator()->selectDates( 1 );
437 mCurrentAgendaView = 1 ; 438 mCurrentAgendaView = 1 ;
438 439
439} 440}
440 441
441void KOViewManager::showWorkWeekView() 442void KOViewManager::showWorkWeekView()
442{ 443{
443 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 444 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
444 mFlagShowNextxDays = false; 445 mFlagShowNextxDays = false;
445 globalFlagBlockAgenda = 1; 446 globalFlagBlockAgenda = 1;
446 globalFlagBlockLabel = 1; 447 globalFlagBlockLabel = 1;
447 if ( mCurrentAgendaView != 5 ) 448 if ( mCurrentAgendaView != 5 )
448 mCurrentAgendaView = -1; 449 mCurrentAgendaView = -1;
449 showAgendaView(); 450 showAgendaView();
450 qApp->processEvents(); 451 qApp->processEvents();
451 globalFlagBlockAgenda = 2; 452 globalFlagBlockAgenda = 2;
452 globalFlagBlockLabel = 0; 453 globalFlagBlockLabel = 0;
453 mMainView->dateNavigator()->selectWorkWeek(); 454 mMainView->dateNavigator()->selectWorkWeek();
454 mCurrentAgendaView = 5 ; 455 mCurrentAgendaView = 5 ;
455 456
456} 457}
457 458
458void KOViewManager::showWeekView() 459void KOViewManager::showWeekView()
459{ 460{
460 /* 461 /*
461 globalFlagBlockAgenda = 2; 462 globalFlagBlockAgenda = 2;
462 qDebug("4globalFlagBlockAgenda = 2; "); 463 qDebug("4globalFlagBlockAgenda = 2; ");
463 //globalFlagBlockPainting = true; 464 //globalFlagBlockPainting = true;
464 mMainView->dateNavigator()->selectWeek(); 465 mMainView->dateNavigator()->selectWeek();
465 showAgendaView(); 466 showAgendaView();
466 */ 467 */
467 468
468 469
469 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 470 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
470 mFlagShowNextxDays = false; 471 mFlagShowNextxDays = false;
471 globalFlagBlockAgenda = 1; 472 globalFlagBlockAgenda = 1;
472 globalFlagBlockLabel = 1; 473 globalFlagBlockLabel = 1;
473 if ( mCurrentAgendaView != 7 ) 474 if ( mCurrentAgendaView != 7 )
474 mCurrentAgendaView = -1; 475 mCurrentAgendaView = -1;
475 showAgendaView(); 476 showAgendaView();
476 qApp->processEvents(); 477 qApp->processEvents();
477 globalFlagBlockAgenda = 2; 478 globalFlagBlockAgenda = 2;
478 globalFlagBlockLabel = 0; 479 globalFlagBlockLabel = 0;
479 mMainView->dateNavigator()->selectWeek(); 480 mMainView->dateNavigator()->selectWeek();
480 mCurrentAgendaView = 7 ; 481 mCurrentAgendaView = 7 ;
481} 482}
482 483
483void KOViewManager::showNextXView() 484void KOViewManager::showNextXView()
484{ 485{
485 486
486 globalFlagBlockAgenda = 1; 487 globalFlagBlockAgenda = 1;
487 if ( mCurrentAgendaView != 3 ) 488 if ( mCurrentAgendaView != 3 )
488 mCurrentAgendaView = -1; 489 mCurrentAgendaView = -1;
489 showAgendaView(KOPrefs::instance()->mFullViewMonth); 490 showAgendaView(KOPrefs::instance()->mFullViewMonth);
490 globalFlagBlockAgenda = 2; 491 globalFlagBlockAgenda = 2;
491 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 492 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
492 KOPrefs::instance()->mNextXDays ); 493 KOPrefs::instance()->mNextXDays );
493 mFlagShowNextxDays = true; 494 mFlagShowNextxDays = true;
494 mCurrentAgendaView = 3 ; 495 mCurrentAgendaView = 3 ;
495} 496}
496bool KOViewManager::showsNextDays() 497bool KOViewManager::showsNextDays()
497{ 498{
498 return mFlagShowNextxDays; 499 return mFlagShowNextxDays;
499} 500}
500void KOViewManager::createMonthView() 501void KOViewManager::createMonthView()
501{ 502{
502if (!mMonthView) { 503if (!mMonthView) {
503 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 504 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
504 505
505 addView(mMonthView); 506 addView(mMonthView);
506 // mMonthView->show(); 507 // mMonthView->show();
507 // SIGNALS/SLOTS FOR MONTH VIEW 508 // SIGNALS/SLOTS FOR MONTH VIEW
508 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 509 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
509 mMainView, SLOT(newEvent(QDateTime))); 510 mMainView, SLOT(newEvent(QDateTime)));
510 511
511 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 512 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
512 mMainView, SLOT(showIncidence(Incidence *))); 513 mMainView, SLOT(showIncidence(Incidence *)));
513 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 514 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
514 mMainView, SLOT(editIncidence(Incidence *))); 515 mMainView, SLOT(editIncidence(Incidence *)));
515 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 516 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
516 mMainView, SLOT(deleteIncidence(Incidence *))); 517 mMainView, SLOT(deleteIncidence(Incidence *)));
517 518
518 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 519 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
519 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 520 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
520 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 521 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
521 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 522 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
522 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 523 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
523 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 524 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
524 525
525 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 526 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
526 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 527 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
527 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 528 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
528 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 529 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
529 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 530 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
530 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 531 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
531 connect( mMonthView, SIGNAL( selectMonth() ), 532 connect( mMonthView, SIGNAL( selectMonth() ),
532 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 533 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
533 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 534 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
534 mMainView, SLOT ( showDay( QDate ) ) ); 535 mMainView, SLOT ( showDay( QDate ) ) );
535 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 536 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
536 connect( mMonthView, SIGNAL(nextMonth() ), 537 connect( mMonthView, SIGNAL(nextMonth() ),
537 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 538 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
538 connect( mMonthView, SIGNAL(prevMonth() ), 539 connect( mMonthView, SIGNAL(prevMonth() ),
539 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 540 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
540 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 541 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
541 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 542 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
542 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 543 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
543 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 544 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
544 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 545 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
545 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 546 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
546 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 547 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
547 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 548 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
548 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 549 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
549 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 550 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
550 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 551 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
551 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 552 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
552 553
553 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 554 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
554 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 555 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
555 556
556 557
557 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 558 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
558 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 559 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
559 560
560 } 561 }
561} 562}
562void KOViewManager::showMonthViewWeek() 563void KOViewManager::showMonthViewWeek()
563{ 564{
564 createMonthView(); 565 createMonthView();
565 globalFlagBlockAgenda = 1; 566 globalFlagBlockAgenda = 1;
566 bool full = true; 567 bool full = true;
567 if ( mCurrentView == mMonthView) 568 if ( mCurrentView == mMonthView)
568 full = mMainView->leftFrame()->isVisible(); 569 full = mMainView->leftFrame()->isVisible();
569 if ( !KOPrefs::instance()->mMonthViewWeek ) { 570 if ( !KOPrefs::instance()->mMonthViewWeek ) {
570 mMonthView->switchView(); 571 mMonthView->switchView();
571 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 572 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
572 full = false; 573 full = false;
573 else 574 else
574 full = true; 575 full = true;
575 } 576 }
576 mMainView->dateNavigator()->selectWeek(); 577 mMainView->dateNavigator()->selectWeek();
577 showView(mMonthView, full ); 578 showView(mMonthView, full );
578} 579}
579 580
581void KOViewManager::showMonth( const QDate & date )
582{
583 mMainView->dateNavigator()->blockSignals( true );
584 mMainView->dateNavigator()->selectDate( date );
585 mMainView->dateNavigator()->blockSignals( false );
586 showMonthView();
587}
580void KOViewManager::showMonthView() 588void KOViewManager::showMonthView()
581 { 589 {
582 590
583 createMonthView(); 591 createMonthView();
584 globalFlagBlockAgenda = 1; 592 globalFlagBlockAgenda = 1;
585 //mFlagShowNextxDays = false; 593 //mFlagShowNextxDays = false;
586 bool full = true; 594 bool full = true;
587 if ( mCurrentView == mMonthView) 595 if ( mCurrentView == mMonthView)
588 full = mMainView->leftFrame()->isVisible(); 596 full = mMainView->leftFrame()->isVisible();
589 // if(mMonthView == mCurrentView) return; 597 // if(mMonthView == mCurrentView) return;
590 if ( KOPrefs::instance()->mMonthViewWeek ) { 598 if ( KOPrefs::instance()->mMonthViewWeek ) {
591 mMonthView->switchView(); 599 mMonthView->switchView();
592 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 600 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
593 full = false; 601 full = false;
594 else 602 else
595 full = true; 603 full = true;
596 } 604 }
597 mMainView->dateNavigator()->selectMonth(); 605 mMainView->dateNavigator()->selectMonth();
598 606
599 showView(mMonthView, full ); 607 showView(mMonthView, full );
600 608
601} 609}
602 610
603void KOViewManager::showTodoView() 611void KOViewManager::showTodoView()
604{ 612{
605 //mFlagShowNextxDays = false; 613 //mFlagShowNextxDays = false;
606 if ( !mTodoView ) { 614 if ( !mTodoView ) {
607 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 615 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
608 "KOViewManager::TodoView" ); 616 "KOViewManager::TodoView" );
609 617
610 addView( mTodoView ); 618 addView( mTodoView );
611 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 619 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
612 620
613 // SIGNALS/SLOTS FOR TODO VIEW 621 // SIGNALS/SLOTS FOR TODO VIEW
614 connect( mTodoView, SIGNAL( newTodoSignal() ), 622 connect( mTodoView, SIGNAL( newTodoSignal() ),
615 mMainView, SLOT( newTodo() ) ); 623 mMainView, SLOT( newTodo() ) );
616 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 624 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
617 mMainView, SLOT( newSubTodo( Todo *) ) ); 625 mMainView, SLOT( newSubTodo( Todo *) ) );
618 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 626 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
619 mMainView, SLOT( showTodo( Todo * ) ) ); 627 mMainView, SLOT( showTodo( Todo * ) ) );
620 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 628 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
621 mMainView, SLOT( editTodo( Todo * ) ) ); 629 mMainView, SLOT( editTodo( Todo * ) ) );
622 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 630 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
623 mMainView, SLOT( deleteTodo( Todo * ) ) ); 631 mMainView, SLOT( deleteTodo( Todo * ) ) );
624 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 632 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
625 mMainView, SLOT( purgeCompleted() ) ); 633 mMainView, SLOT( purgeCompleted() ) );
626 634
627 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 635 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
628 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 636 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
629 637
630 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 638 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
631 SLOT( updateConfig() ) ); 639 SLOT( updateConfig() ) );
632 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 640 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
633 SLOT( updateTodo( Todo *, int ) ) ); 641 SLOT( updateTodo( Todo *, int ) ) );
634 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 642 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
635 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 643 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
636 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 644 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
637 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 645 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
638 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 646 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
639 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 647 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
640 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 648 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
641 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 649 mMainView, SLOT ( todo_unsub( Todo * ) ) );
642 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 650 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
643 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 651 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
644 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 652 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
645 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 653 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
646 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 654 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
647 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 655 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
648 KConfig *config = KOGlobals::config(); 656 KConfig *config = KOGlobals::config();
649 mTodoView->restoreLayout(config,"Todo View"); 657 mTodoView->restoreLayout(config,"Todo View");
650 mTodoView->setNavigator( mMainView->dateNavigator() ); 658 mTodoView->setNavigator( mMainView->dateNavigator() );
651 } 659 }
652 660
653 globalFlagBlockAgenda = 1; 661 globalFlagBlockAgenda = 1;
654 showView( mTodoView, true ); 662 showView( mTodoView, true );
655 663
656} 664}
657 665
658void KOViewManager::showJournalView() 666void KOViewManager::showJournalView()
659{ 667{
660 //mFlagShowNextxDays = false; 668 //mFlagShowNextxDays = false;
661 if (!mJournalView) { 669 if (!mJournalView) {
662 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 670 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
663 "KOViewManager::JournalView"); 671 "KOViewManager::JournalView");
664 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 672 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
665 SLOT( updateConfig() ) ); 673 SLOT( updateConfig() ) );
666 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 674 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
667 addView(mJournalView); 675 addView(mJournalView);
668 } 676 }
669 677
670 showView(mJournalView); 678 showView(mJournalView);
671 mMainView->dateNavigator()->selectDates( 1 ); 679 mMainView->dateNavigator()->selectDates( 1 );
672} 680}
673 681
674void KOViewManager::showTimeSpanView() 682void KOViewManager::showTimeSpanView()
675{ 683{
676 //mFlagShowNextxDays = false; 684 //mFlagShowNextxDays = false;
677 if (!mTimeSpanView) { 685 if (!mTimeSpanView) {
678 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 686 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
679 "KOViewManager::TimeSpanView"); 687 "KOViewManager::TimeSpanView");
680 addView(mTimeSpanView); 688 addView(mTimeSpanView);
681 689
682 mTimeSpanView->readSettings(); 690 mTimeSpanView->readSettings();
683 } 691 }
684 692
685 showView(mTimeSpanView); 693 showView(mTimeSpanView);
686} 694}
687 695
688Incidence *KOViewManager::currentSelection() 696Incidence *KOViewManager::currentSelection()
689{ 697{
690 if (!mCurrentView) return 0; 698 if (!mCurrentView) return 0;
691 if ( mCurrentView == mListView ) { 699 if ( mCurrentView == mListView ) {
692 if ( mListView->currentItem() ) 700 if ( mListView->currentItem() )
693 return mListView->currentItem(); 701 return mListView->currentItem();
694 } 702 }
695 return mCurrentView->selectedIncidences().first(); 703 return mCurrentView->selectedIncidences().first();
696} 704}
697 705
698QDate KOViewManager::currentSelectionDate() 706QDate KOViewManager::currentSelectionDate()
699{ 707{
700 QDate qd; 708 QDate qd;
701 if (mCurrentView) { 709 if (mCurrentView) {
702 DateList qvl = mCurrentView->selectedDates(); 710 DateList qvl = mCurrentView->selectedDates();
703 if (!qvl.isEmpty()) qd = qvl.first(); 711 if (!qvl.isEmpty()) qd = qvl.first();
704 } 712 }
705 return qd; 713 return qd;
706} 714}
707 715
708void KOViewManager::addView(KOrg::BaseView *view) 716void KOViewManager::addView(KOrg::BaseView *view)
709{ 717{
710#if QT_VERSION >= 0x030000 718#if QT_VERSION >= 0x030000
711 mMainView->viewStack()->addWidget( view ); 719 mMainView->viewStack()->addWidget( view );
712#else 720#else
713 mMainView->viewStack()->addWidget( view, 1 ); 721 mMainView->viewStack()->addWidget( view, 1 );
714#endif 722#endif
715} 723}
716 724
717void KOViewManager::setDocumentId( const QString &id ) 725void KOViewManager::setDocumentId( const QString &id )
718{ 726{
719 if (mTodoView) mTodoView->setDocumentId( id ); 727 if (mTodoView) mTodoView->setDocumentId( id );
720} 728}
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h
index 8f0bf82..6290227 100644
--- a/korganizer/koviewmanager.h
+++ b/korganizer/koviewmanager.h
@@ -1,120 +1,121 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 3 Copyright (c) 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef KOVIEWMANAGER_H 24#ifndef KOVIEWMANAGER_H
25#define KOVIEWMANAGER_H 25#define KOVIEWMANAGER_H
26 26
27#include <qobject.h> 27#include <qobject.h>
28 28
29#include <korganizer/baseview.h> 29#include <korganizer/baseview.h>
30 30
31class CalendarView; 31class CalendarView;
32 32
33class KOListView; 33class KOListView;
34class KOAgendaView; 34class KOAgendaView;
35class KOMonthView; 35class KOMonthView;
36class KOTimeSpanView; 36class KOTimeSpanView;
37class KOTodoView; 37class KOTodoView;
38class KOWhatsNextView; 38class KOWhatsNextView;
39class KOJournalView; 39class KOJournalView;
40 40
41using namespace KCal; 41using namespace KCal;
42 42
43/** 43/**
44 This class manages the views of the calendar. It owns the objects and handles 44 This class manages the views of the calendar. It owns the objects and handles
45 creation and selection. 45 creation and selection.
46*/ 46*/
47class KOViewManager : public QObject 47class KOViewManager : public QObject
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOViewManager( CalendarView * ); 51 KOViewManager( CalendarView * );
52 virtual ~KOViewManager(); 52 virtual ~KOViewManager();
53 53
54 /** changes the view to be the currently selected view */ 54 /** changes the view to be the currently selected view */
55 void showView(KOrg::BaseView *, bool fullScreen = false ); 55 void showView(KOrg::BaseView *, bool fullScreen = false );
56 void updateWNview(); 56 void updateWNview();
57 void readSettings(KConfig *config); 57 void readSettings(KConfig *config);
58 void writeSettings(KConfig *config); 58 void writeSettings(KConfig *config);
59 bool showsNextDays(); 59 bool showsNextDays();
60 /** Read which view was shown last from config file */ 60 /** Read which view was shown last from config file */
61 void readCurrentView(KConfig *); 61 void readCurrentView(KConfig *);
62 /** Write which view is currently shown to config file */ 62 /** Write which view is currently shown to config file */
63 void writeCurrentView(KConfig *); 63 void writeCurrentView(KConfig *);
64 64
65 KOrg::BaseView *currentView(); 65 KOrg::BaseView *currentView();
66 66
67 void setDocumentId( const QString & ); 67 void setDocumentId( const QString & );
68 68
69 void updateView( const QDate &start, const QDate &end ); 69 void updateView( const QDate &start, const QDate &end );
70 70
71 void raiseCurrentView( bool fullScreen = false , bool updateView = false); 71 void raiseCurrentView( bool fullScreen = false , bool updateView = false);
72 72
73 void addView(KOrg::BaseView *); 73 void addView(KOrg::BaseView *);
74 74
75 Incidence *currentSelection(); 75 Incidence *currentSelection();
76 QDate currentSelectionDate(); 76 QDate currentSelectionDate();
77 77
78 KOAgendaView *agendaView() const { return mAgendaView; } 78 KOAgendaView *agendaView() const { return mAgendaView; }
79 79
80 signals: 80 signals:
81 void printWNV(); 81 void printWNV();
82 void signalFullScreen( bool ); 82 void signalFullScreen( bool );
83 void signalAgendaView( bool ); 83 void signalAgendaView( bool );
84 public slots: 84 public slots:
85 void showMonth( const QDate & );
85 void showDateView( int, QDate ); 86 void showDateView( int, QDate );
86 void updateView(); 87 void updateView();
87 void showWhatsNextView(); 88 void showWhatsNextView();
88 void showListView(); 89 void showListView();
89 void showAgendaView( bool fullScreen = false ); 90 void showAgendaView( bool fullScreen = false );
90 void showDayView(); 91 void showDayView();
91 void showWorkWeekView(); 92 void showWorkWeekView();
92 void showWeekView(); 93 void showWeekView();
93 void showNextXView(); 94 void showNextXView();
94 void showMonthView(); 95 void showMonthView();
95 void showMonthViewWeek(); 96 void showMonthViewWeek();
96 void showTodoView(); 97 void showTodoView();
97 void showJournalView(); 98 void showJournalView();
98 void showTimeSpanView(); 99 void showTimeSpanView();
99 100
100 private: 101 private:
101 void createMonthView(); 102 void createMonthView();
102 CalendarView *mMainView; 103 CalendarView *mMainView;
103 104
104 int mCurrentAgendaView; 105 int mCurrentAgendaView;
105 KOAgendaView *mAgendaView; 106 KOAgendaView *mAgendaView;
106 KOListView *mListView; 107 KOListView *mListView;
107 KOMonthView *mMonthView; 108 KOMonthView *mMonthView;
108 KOTodoView *mTodoView; 109 KOTodoView *mTodoView;
109 KOWhatsNextView *mWhatsNextView; 110 KOWhatsNextView *mWhatsNextView;
110 KOJournalView *mJournalView; 111 KOJournalView *mJournalView;
111 KOTimeSpanView *mTimeSpanView; 112 KOTimeSpanView *mTimeSpanView;
112 113
113 KOrg::BaseView *mCurrentView; // currently active event view 114 KOrg::BaseView *mCurrentView; // currently active event view
114 115
115 int mAgendaViewMode; 116 int mAgendaViewMode;
116 bool mFlagShowNextxDays; 117 bool mFlagShowNextxDays;
117 118
118}; 119};
119 120
120#endif 121#endif