author | zautrix <zautrix> | 2004-10-27 12:27:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-27 12:27:39 (UTC) |
commit | 2f3396d84d2f3c92e1e0e420d677892c1f9c0778 (patch) (unidiff) | |
tree | 1ebab5dc6d00cb09720789897ce2c86df05cc9ab /korganizer | |
parent | f73d249579d52d7aeaacde2dcb23abeb42f9ee95 (diff) | |
download | kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.zip kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.gz kdepimpi-2f3396d84d2f3c92e1e0e420d677892c1f9c0778.tar.bz2 |
completed KDE AB sync. but will it work ...?
-rw-r--r-- | korganizer/calendarview.cpp | 15 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 |
2 files changed, 6 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 326db88..6e61351 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3780 +1,3777 @@ | |||
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 "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | 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 ); | 186 | 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 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | beamDialog = new KOBeamPrefs(); | 236 | beamDialog = new KOBeamPrefs(); |
237 | mDatePickerMode = 0; | 237 | mDatePickerMode = 0; |
238 | mCurrentSyncDevice = ""; | 238 | mCurrentSyncDevice = ""; |
239 | writeLocale(); | 239 | writeLocale(); |
240 | mViewManager = new KOViewManager( this ); | 240 | mViewManager = new KOViewManager( this ); |
241 | mDialogManager = new KODialogManager( this ); | 241 | mDialogManager = new KODialogManager( this ); |
242 | mEventViewerDialog = 0; | 242 | mEventViewerDialog = 0; |
243 | mModified = false; | 243 | mModified = false; |
244 | mReadOnly = false; | 244 | mReadOnly = false; |
245 | mSelectedIncidence = 0; | 245 | mSelectedIncidence = 0; |
246 | mCalPrinter = 0; | 246 | mCalPrinter = 0; |
247 | mFilters.setAutoDelete(true); | 247 | mFilters.setAutoDelete(true); |
248 | 248 | ||
249 | mCalendar->registerObserver( this ); | 249 | mCalendar->registerObserver( this ); |
250 | // TODO: Make sure that view is updated, when calendar is changed. | 250 | // TODO: Make sure that view is updated, when calendar is changed. |
251 | 251 | ||
252 | mStorage = new FileStorage( mCalendar ); | 252 | mStorage = new FileStorage( mCalendar ); |
253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
254 | 254 | ||
255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
256 | #ifndef KORG_NOSPLITTER | 256 | #ifndef KORG_NOSPLITTER |
257 | // create the main layout frames. | 257 | // create the main layout frames. |
258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
259 | topLayout->addWidget(mPanner); | 259 | topLayout->addWidget(mPanner); |
260 | 260 | ||
261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
262 | "CalendarView::LeftFrame"); | 262 | "CalendarView::LeftFrame"); |
263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
264 | 264 | ||
265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
266 | "CalendarView::DateNavigator", QDate::currentDate() ); | 266 | "CalendarView::DateNavigator", QDate::currentDate() ); |
267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 269 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
270 | 270 | ||
271 | #ifdef KORG_NORESOURCEVIEW | 271 | #ifdef KORG_NORESOURCEVIEW |
272 | mResourceView = 0; | 272 | mResourceView = 0; |
273 | #else | 273 | #else |
274 | if ( mResourceManager ) { | 274 | if ( mResourceManager ) { |
275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 275 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
276 | mResourceView->updateView(); | 276 | mResourceView->updateView(); |
277 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 277 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
278 | SLOT( updateView() ) ); | 278 | SLOT( updateView() ) ); |
279 | } else { | 279 | } else { |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | } | 281 | } |
282 | #endif | 282 | #endif |
283 | QWidget *rightBox = new QWidget( mPanner ); | 283 | QWidget *rightBox = new QWidget( mPanner ); |
284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 284 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
285 | 285 | ||
286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 286 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
287 | rightLayout->addWidget( mNavigatorBar ); | 287 | rightLayout->addWidget( mNavigatorBar ); |
288 | 288 | ||
289 | mRightFrame = new QWidgetStack( rightBox ); | 289 | mRightFrame = new QWidgetStack( rightBox ); |
290 | rightLayout->addWidget( mRightFrame, 1 ); | 290 | rightLayout->addWidget( mRightFrame, 1 ); |
291 | 291 | ||
292 | mLeftFrame = mLeftSplitter; | 292 | mLeftFrame = mLeftSplitter; |
293 | #else | 293 | #else |
294 | QWidget *mainBox = new QWidget( this ); | 294 | QWidget *mainBox = new QWidget( this ); |
295 | QWidget *leftFrame = new QWidget( mainBox ); | 295 | QWidget *leftFrame = new QWidget( mainBox ); |
296 | 296 | ||
297 | QBoxLayout * mainBoxLayout; | 297 | QBoxLayout * mainBoxLayout; |
298 | QBoxLayout * leftFrameLayout; | 298 | QBoxLayout * leftFrameLayout; |
299 | if ( KOPrefs::instance()->mVerticalScreen ) { | 299 | if ( KOPrefs::instance()->mVerticalScreen ) { |
300 | mainBoxLayout = new QVBoxLayout(mainBox); | 300 | mainBoxLayout = new QVBoxLayout(mainBox); |
301 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 301 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
302 | } else { | 302 | } else { |
303 | mainBoxLayout = new QHBoxLayout(mainBox); | 303 | mainBoxLayout = new QHBoxLayout(mainBox); |
304 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 304 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
305 | } | 305 | } |
306 | topLayout->addWidget( mainBox ); | 306 | topLayout->addWidget( mainBox ); |
307 | mainBoxLayout->addWidget (leftFrame); | 307 | mainBoxLayout->addWidget (leftFrame); |
308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 308 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
309 | "CalendarView::DateNavigator", QDate::currentDate()); | 309 | "CalendarView::DateNavigator", QDate::currentDate()); |
310 | // mDateNavigator->blockSignals( true ); | 310 | // mDateNavigator->blockSignals( true ); |
311 | leftFrameLayout->addWidget( mDateNavigator ); | 311 | leftFrameLayout->addWidget( mDateNavigator ); |
312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 312 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 313 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
314 | 314 | ||
315 | if ( QApplication::desktop()->width() < 480 ) { | 315 | if ( QApplication::desktop()->width() < 480 ) { |
316 | leftFrameLayout->addWidget(mFilterView); | 316 | leftFrameLayout->addWidget(mFilterView); |
317 | leftFrameLayout->addWidget(mTodoList, 2 ); | 317 | leftFrameLayout->addWidget(mTodoList, 2 ); |
318 | 318 | ||
319 | } else { | 319 | } else { |
320 | leftFrameLayout->addWidget(mTodoList,2 ); | 320 | leftFrameLayout->addWidget(mTodoList,2 ); |
321 | leftFrameLayout->addWidget(mFilterView ); | 321 | leftFrameLayout->addWidget(mFilterView ); |
322 | } | 322 | } |
323 | mFilterView->hide(); | 323 | mFilterView->hide(); |
324 | QWidget *rightBox = new QWidget( mainBox ); | 324 | QWidget *rightBox = new QWidget( mainBox ); |
325 | mainBoxLayout->addWidget ( rightBox, 10 ); | 325 | mainBoxLayout->addWidget ( rightBox, 10 ); |
326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 327 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
328 | mRightFrame = new QWidgetStack( rightBox ); | 328 | mRightFrame = new QWidgetStack( rightBox ); |
329 | rightLayout->addWidget( mNavigatorBar ); | 329 | rightLayout->addWidget( mNavigatorBar ); |
330 | rightLayout->addWidget( mRightFrame, 10 ); | 330 | rightLayout->addWidget( mRightFrame, 10 ); |
331 | 331 | ||
332 | mLeftFrame = leftFrame; | 332 | mLeftFrame = leftFrame; |
333 | if ( KOPrefs::instance()->mVerticalScreen ) { | 333 | if ( KOPrefs::instance()->mVerticalScreen ) { |
334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 334 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 335 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
336 | } else { | 336 | } else { |
337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 337 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 338 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
339 | } | 339 | } |
340 | 340 | ||
341 | //qDebug("Calendarview Size %d %d ", width(), height()); | 341 | //qDebug("Calendarview Size %d %d ", width(), height()); |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 344 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
345 | SLOT( showDates( const KCal::DateList & ) ) ); | 345 | SLOT( showDates( const KCal::DateList & ) ) ); |
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
348 | 348 | ||
349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 349 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
350 | mNavigator, SLOT( selectPreviousYear() ) ); | 350 | mNavigator, SLOT( selectPreviousYear() ) ); |
351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
352 | mNavigator, SLOT( selectNextYear() ) ); | 352 | mNavigator, SLOT( selectNextYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 353 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
354 | mNavigator, SLOT( selectPreviousMonth() ) ); | 354 | mNavigator, SLOT( selectPreviousMonth() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
356 | mNavigator, SLOT( selectNextMonth() ) ); | 356 | mNavigator, SLOT( selectNextMonth() ) ); |
357 | 357 | ||
358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 358 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 359 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
360 | 360 | ||
361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 361 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 362 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
363 | 363 | ||
364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 364 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
365 | mNavigator, SLOT( selectPreviousYear() ) ); | 365 | mNavigator, SLOT( selectPreviousYear() ) ); |
366 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 366 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
367 | mNavigator, SLOT( selectNextYear() ) ); | 367 | mNavigator, SLOT( selectNextYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
369 | mNavigator, SLOT( selectPreviousMonth() ) ); | 369 | mNavigator, SLOT( selectPreviousMonth() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
371 | mNavigator, SLOT( selectNextMonth() ) ); | 371 | mNavigator, SLOT( selectNextMonth() ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 373 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
374 | mNavigator, SLOT( selectPrevious() ) ); | 374 | mNavigator, SLOT( selectPrevious() ) ); |
375 | connect( mDateNavigator, SIGNAL( goNext() ), | 375 | connect( mDateNavigator, SIGNAL( goNext() ), |
376 | mNavigator, SLOT( selectNext() ) ); | 376 | mNavigator, SLOT( selectNext() ) ); |
377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | 381 | ||
382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
384 | 384 | ||
385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
386 | SLOT( eventAdded( Event *) ) ); | 386 | SLOT( eventAdded( Event *) ) ); |
387 | 387 | ||
388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
389 | 389 | ||
390 | connect( this, SIGNAL( configChanged() ), | 390 | connect( this, SIGNAL( configChanged() ), |
391 | mDateNavigator, SLOT( updateConfig() ) ); | 391 | mDateNavigator, SLOT( updateConfig() ) ); |
392 | 392 | ||
393 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 393 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
394 | SLOT( newTodo() ) ); | 394 | SLOT( newTodo() ) ); |
395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
396 | SLOT( newSubTodo( Todo * ) ) ); | 396 | SLOT( newSubTodo( Todo * ) ) ); |
397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
425 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
428 | 428 | ||
429 | 429 | ||
430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | void CalendarView::timerAlarm() | 494 | void CalendarView::timerAlarm() |
495 | { | 495 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 496 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 497 | computeAlarm(mAlarmNotification ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void CalendarView::suspendAlarm() | 500 | void CalendarView::suspendAlarm() |
501 | { | 501 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 502 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 503 | computeAlarm(mSuspendAlarmNotification ); |
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 507 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 508 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | void CalendarView::checkNextTimerAlarm() | 514 | void CalendarView::checkNextTimerAlarm() |
515 | { | 515 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 516 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 519 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 520 | { |
521 | 521 | ||
522 | QString mess = msg; | 522 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 523 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 524 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 525 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 526 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 527 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 528 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 529 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 530 | if ( len < 2 ) |
531 | error = true; | 531 | error = true; |
532 | else { | 532 | else { |
533 | tempfilename = mess.mid( 13, len ); | 533 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 534 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 535 | error = true; |
536 | } | 536 | } |
537 | if ( ! error ) { | 537 | if ( ! error ) { |
538 | filename = tempfilename; | 538 | filename = tempfilename; |
539 | } | 539 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 540 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 541 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 542 | startAlarm( mAlarmMessage, filename); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 545 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 546 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 547 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 550 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 551 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 552 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 553 | if ( len < 2 ) |
554 | error = true; | 554 | error = true; |
555 | else { | 555 | else { |
556 | tempfilename = mess.mid( 10, len ); | 556 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 557 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 558 | error = true; |
559 | } | 559 | } |
560 | if ( error ) { | 560 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 562 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 563 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 565 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 566 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 567 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 574 | p->start(); |
575 | return; | 575 | return; |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | 580 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 584 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 586 | if ( len < 2 ) |
587 | error = true; | 587 | error = true; |
588 | else { | 588 | else { |
589 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 591 | error = true; |
592 | } | 592 | } |
593 | if ( ! error ) { | 593 | if ( ! error ) { |
594 | filename = tempfilename; | 594 | filename = tempfilename; |
595 | } | 595 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 598 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 601 | } |
602 | 602 | ||
603 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 609 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 611 | ||
612 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 620 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | int maxSec; | 628 | int maxSec; |
629 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 636 | return; |
637 | } else { | 637 | } else { |
638 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
639 | } | 639 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
642 | 642 | ||
643 | } | 643 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
647 | { | 647 | { |
648 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 651 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | // 0 equal | 717 | // 0 equal |
718 | // 1 take local | 718 | // 1 take local |
719 | // 2 take remote | 719 | // 2 take remote |
720 | // 3 cancel | 720 | // 3 cancel |
721 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
722 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
723 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
725 | bool remCh, locCh; | 725 | bool remCh, locCh; |
726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
727 | //if ( remCh ) | 727 | //if ( remCh ) |
728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
729 | locCh = ( localMod > mLastCalendarSync ); | 729 | locCh = ( localMod > mLastCalendarSync ); |
730 | if ( !remCh && ! locCh ) { | 730 | if ( !remCh && ! locCh ) { |
731 | //qDebug("both not changed "); | 731 | //qDebug("both not changed "); |
732 | lastSync = localMod.addDays(1); | 732 | lastSync = localMod.addDays(1); |
733 | if ( mode <= SYNC_PREF_ASK ) | 733 | if ( mode <= SYNC_PREF_ASK ) |
734 | return 0; | 734 | return 0; |
735 | } else { | 735 | } else { |
736 | if ( locCh ) { | 736 | if ( locCh ) { |
737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
738 | lastSync = localMod.addDays( -1 ); | 738 | lastSync = localMod.addDays( -1 ); |
739 | if ( !remCh ) | 739 | if ( !remCh ) |
740 | remoteMod = ( lastSync.addDays( -1 ) ); | 740 | remoteMod = ( lastSync.addDays( -1 ) ); |
741 | } else { | 741 | } else { |
742 | //qDebug(" not loc changed "); | 742 | //qDebug(" not loc changed "); |
743 | lastSync = localMod.addDays( 1 ); | 743 | lastSync = localMod.addDays( 1 ); |
744 | if ( remCh ) | 744 | if ( remCh ) |
745 | remoteMod =( lastSync.addDays( 1 ) ); | 745 | remoteMod =( lastSync.addDays( 1 ) ); |
746 | 746 | ||
747 | } | 747 | } |
748 | } | 748 | } |
749 | full = true; | 749 | full = true; |
750 | if ( mode < SYNC_PREF_ASK ) | 750 | if ( mode < SYNC_PREF_ASK ) |
751 | mode = SYNC_PREF_ASK; | 751 | mode = SYNC_PREF_ASK; |
752 | } else { | 752 | } else { |
753 | if ( localMod == remoteMod ) | 753 | if ( localMod == remoteMod ) |
754 | // if ( local->revision() == remote->revision() ) | 754 | // if ( local->revision() == remote->revision() ) |
755 | return 0; | 755 | return 0; |
756 | 756 | ||
757 | } | 757 | } |
758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
759 | 759 | ||
760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
762 | //full = true; //debug only | 762 | //full = true; //debug only |
763 | if ( full ) { | 763 | if ( full ) { |
764 | bool equ = false; | 764 | bool equ = false; |
765 | if ( local->type() == "Event" ) { | 765 | if ( local->type() == "Event" ) { |
766 | equ = (*((Event*) local) == *((Event*) remote)); | 766 | equ = (*((Event*) local) == *((Event*) remote)); |
767 | } | 767 | } |
768 | else if ( local->type() =="Todo" ) | 768 | else if ( local->type() =="Todo" ) |
769 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 769 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
770 | else if ( local->type() =="Journal" ) | 770 | else if ( local->type() =="Journal" ) |
771 | equ = (*((Journal*) local) == *((Journal*) remote)); | 771 | equ = (*((Journal*) local) == *((Journal*) remote)); |
772 | if ( equ ) { | 772 | if ( equ ) { |
773 | //qDebug("equal "); | 773 | //qDebug("equal "); |
774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
776 | } | 776 | } |
777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
778 | return 0; | 778 | return 0; |
779 | 779 | ||
780 | }//else //debug only | 780 | }//else //debug only |
781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
782 | } | 782 | } |
783 | int result; | 783 | int result; |
784 | bool localIsNew; | 784 | bool localIsNew; |
785 | //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() ); | 785 | //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() ); |
786 | 786 | ||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
789 | 789 | ||
790 | switch( mode ) { | 790 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remoteMod ) | 792 | if ( lastSync > remoteMod ) |
793 | return 1; | 793 | return 1; |
794 | if ( lastSync > localMod ) | 794 | if ( lastSync > localMod ) |
795 | return 2; | 795 | return 2; |
796 | return 1; | 796 | return 1; |
797 | break; | 797 | break; |
798 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remoteMod ) | 799 | if ( lastSync > remoteMod ) |
800 | return 1; | 800 | return 1; |
801 | if ( lastSync > localMod ) | 801 | if ( lastSync > localMod ) |
802 | return 2; | 802 | return 2; |
803 | return 2; | 803 | return 2; |
804 | break; | 804 | break; |
805 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
806 | if ( localMod > remoteMod ) | 806 | if ( localMod > remoteMod ) |
807 | return 1; | 807 | return 1; |
808 | else | 808 | else |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
813 | if ( lastSync > remoteMod ) | 813 | if ( lastSync > remoteMod ) |
814 | return 1; | 814 | return 1; |
815 | if ( lastSync > localMod ) | 815 | if ( lastSync > localMod ) |
816 | return 2; | 816 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | localIsNew = localMod >= remoteMod; | 818 | localIsNew = localMod >= remoteMod; |
819 | if ( localIsNew ) | 819 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 821 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 824 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 826 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 834 | return result; |
835 | 835 | ||
836 | break; | 836 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 838 | return 1; |
839 | break; | 839 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 858 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 860 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
867 | } | 867 | } |
868 | 868 | ||
869 | return lse; | 869 | return lse; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | // we check, if the to delete event has a id for a profile | 873 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 874 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 876 | { |
877 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 929 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncKDE ) { | 930 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 931 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("ERROR: KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync;; | 939 | QDateTime modifiedCalendar = mLastCalendarSync;; |
940 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 942 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
945 | 945 | ||
946 | } else { | 946 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 949 | } else { |
950 | fullDateRange = true; | 950 | fullDateRange = true; |
951 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncKDE ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() == mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | int w = 300; | 990 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 991 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 992 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 993 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 994 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 995 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 997 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 998 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 999 | int incCounter = 0; |
1000 | while ( inR ) { | 1000 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1001 | if ( ! bar.isVisible() ) |
1002 | return false; | 1002 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1003 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1004 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1005 | ++incCounter; |
1006 | uid = inR->uid(); | 1006 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1007 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1008 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1009 | skipIncidence = true; |
1010 | QString idS; | 1010 | QString idS; |
1011 | qApp->processEvents(); | 1011 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1012 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1013 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1014 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1018 | return false; | 1018 | return false; |
1019 | if ( take == 1 ) {// take local | 1019 | if ( take == 1 ) {// take local |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1022 | else |
1023 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1025 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1028 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1029 | remote->addIncidence( inR ); |
1030 | if ( mSyncKDE ) | 1030 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1031 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1032 | ++changedRemote; |
1033 | } else { | 1033 | } else { |
1034 | idS = inL->IDStr(); | 1034 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1035 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1038 | if ( mSyncKDE ) | 1038 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1039 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1040 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1044 | } |
1045 | local->addIncidence( inL ); | 1045 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1046 | ++changedLocal; |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } else { // no conflict | 1049 | } else { // no conflict |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1051 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1052 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1053 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1054 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1057 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1058 | ++deletedEventR; |
1059 | } else { | 1059 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1061 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1062 | inL->setIDStr( ":" ); |
1063 | local->addIncidence( inL ); | 1063 | local->addIncidence( inL ); |
1064 | ++addedEvent; | 1064 | ++addedEvent; |
1065 | } | 1065 | } |
1066 | } else { | 1066 | } else { |
1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1067 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1068 | inR->setLastModified( modifiedCalendar ); | 1068 | inR->setLastModified( modifiedCalendar ); |
1069 | inL = inR->clone(); | 1069 | inL = inR->clone(); |
1070 | inL->setIDStr( ":" ); | 1070 | inL->setIDStr( ":" ); |
1071 | local->addIncidence( inL ); | 1071 | local->addIncidence( inL ); |
1072 | ++addedEvent; | 1072 | ++addedEvent; |
1073 | } else { | 1073 | } else { |
1074 | checkExternSyncEvent(eventRSyncSharp, inR); | 1074 | checkExternSyncEvent(eventRSyncSharp, inR); |
1075 | remote->deleteIncidence( inR ); | 1075 | remote->deleteIncidence( inR ); |
1076 | ++deletedEventR; | 1076 | ++deletedEventR; |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | inR = er.next(); | 1081 | inR = er.next(); |
1082 | } | 1082 | } |
1083 | QPtrList<Incidence> el = local->rawIncidences(); | 1083 | QPtrList<Incidence> el = local->rawIncidences(); |
1084 | inL = el.first(); | 1084 | inL = el.first(); |
1085 | modulo = (el.count()/10)+1; | 1085 | modulo = (el.count()/10)+1; |
1086 | bar.setCaption (i18n("Add / remove events") ); | 1086 | bar.setCaption (i18n("Add / remove events") ); |
1087 | bar.setTotalSteps ( el.count() ) ; | 1087 | bar.setTotalSteps ( el.count() ) ; |
1088 | bar.show(); | 1088 | bar.show(); |
1089 | incCounter = 0; | 1089 | incCounter = 0; |
1090 | 1090 | ||
1091 | while ( inL ) { | 1091 | while ( inL ) { |
1092 | 1092 | ||
1093 | qApp->processEvents(); | 1093 | qApp->processEvents(); |
1094 | if ( ! bar.isVisible() ) | 1094 | if ( ! bar.isVisible() ) |
1095 | return false; | 1095 | return false; |
1096 | if ( incCounter % modulo == 0 ) | 1096 | if ( incCounter % modulo == 0 ) |
1097 | bar.setProgress( incCounter ); | 1097 | bar.setProgress( incCounter ); |
1098 | ++incCounter; | 1098 | ++incCounter; |
1099 | uid = inL->uid(); | 1099 | uid = inL->uid(); |
1100 | bool skipIncidence = false; | 1100 | bool skipIncidence = false; |
1101 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1101 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1102 | skipIncidence = true; | 1102 | skipIncidence = true; |
1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1104 | skipIncidence = true; | 1104 | skipIncidence = true; |
1105 | if ( !skipIncidence ) { | 1105 | if ( !skipIncidence ) { |
1106 | inR = remote->incidence( uid ); | 1106 | inR = remote->incidence( uid ); |
1107 | if ( ! inR ) { | 1107 | if ( ! inR ) { |
1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1110 | checkExternSyncEvent(eventLSyncSharp, inL); | 1110 | checkExternSyncEvent(eventLSyncSharp, inL); |
1111 | local->deleteIncidence( inL ); | 1111 | local->deleteIncidence( inL ); |
1112 | ++deletedEventL; | 1112 | ++deletedEventL; |
1113 | } else { | 1113 | } else { |
1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1115 | inL->removeID(mCurrentSyncDevice ); | 1115 | inL->removeID(mCurrentSyncDevice ); |
1116 | ++addedEventR; | 1116 | ++addedEventR; |
1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1118 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1119 | inR = inL->clone(); | 1119 | inR = inL->clone(); |
1120 | inR->setIDStr( ":" ); | 1120 | inR->setIDStr( ":" ); |
1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1122 | remote->addIncidence( inR ); | 1122 | remote->addIncidence( inR ); |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | } else { | 1125 | } else { |
1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1127 | checkExternSyncEvent(eventLSyncSharp, inL); | 1127 | checkExternSyncEvent(eventLSyncSharp, inL); |
1128 | local->deleteIncidence( inL ); | 1128 | local->deleteIncidence( inL ); |
1129 | ++deletedEventL; | 1129 | ++deletedEventL; |
1130 | } else { | 1130 | } else { |
1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1132 | ++addedEventR; | 1132 | ++addedEventR; |
1133 | inL->setLastModified( modifiedCalendar ); | 1133 | inL->setLastModified( modifiedCalendar ); |
1134 | inR = inL->clone(); | 1134 | inR = inL->clone(); |
1135 | inR->setIDStr( ":" ); | 1135 | inR->setIDStr( ":" ); |
1136 | remote->addIncidence( inR ); | 1136 | remote->addIncidence( inR ); |
1137 | } | 1137 | } |
1138 | } | 1138 | } |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | inL = el.next(); | 1142 | inL = el.next(); |
1143 | } | 1143 | } |
1144 | int delFut = 0; | 1144 | int delFut = 0; |
1145 | int remRem = 0; | 1145 | int remRem = 0; |
1146 | if ( mSyncManager->mWriteBackInFuture ) { | 1146 | if ( mSyncManager->mWriteBackInFuture ) { |
1147 | er = remote->rawIncidences(); | 1147 | er = remote->rawIncidences(); |
1148 | remRem = er.count(); | 1148 | remRem = er.count(); |
1149 | inR = er.first(); | 1149 | inR = er.first(); |
1150 | QDateTime dt; | 1150 | QDateTime dt; |
1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1151 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1152 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1153 | while ( inR ) { | 1153 | while ( inR ) { |
1154 | if ( inR->type() == "Todo" ) { | 1154 | if ( inR->type() == "Todo" ) { |
1155 | Todo * t = (Todo*)inR; | 1155 | Todo * t = (Todo*)inR; |
1156 | if ( t->hasDueDate() ) | 1156 | if ( t->hasDueDate() ) |
1157 | dt = t->dtDue(); | 1157 | dt = t->dtDue(); |
1158 | else | 1158 | else |
1159 | dt = cur.addSecs( 62 ); | 1159 | dt = cur.addSecs( 62 ); |
1160 | } | 1160 | } |
1161 | else if (inR->type() == "Event" ) { | 1161 | else if (inR->type() == "Event" ) { |
1162 | bool ok; | 1162 | bool ok; |
1163 | dt = inR->getNextOccurence( cur, &ok ); | 1163 | dt = inR->getNextOccurence( cur, &ok ); |
1164 | if ( !ok ) | 1164 | if ( !ok ) |
1165 | dt = cur.addSecs( -62 ); | 1165 | dt = cur.addSecs( -62 ); |
1166 | } | 1166 | } |
1167 | else | 1167 | else |
1168 | dt = inR->dtStart(); | 1168 | dt = inR->dtStart(); |
1169 | if ( dt < cur || dt > end ) { | 1169 | if ( dt < cur || dt > end ) { |
1170 | remote->deleteIncidence( inR ); | 1170 | remote->deleteIncidence( inR ); |
1171 | ++delFut; | 1171 | ++delFut; |
1172 | } | 1172 | } |
1173 | inR = er.next(); | 1173 | inR = er.next(); |
1174 | } | 1174 | } |
1175 | } | 1175 | } |
1176 | bar.hide(); | 1176 | bar.hide(); |
1177 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1177 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1178 | eventLSync->setReadOnly( false ); | 1178 | eventLSync->setReadOnly( false ); |
1179 | eventLSync->setDtStart( mLastCalendarSync ); | 1179 | eventLSync->setDtStart( mLastCalendarSync ); |
1180 | eventRSync->setDtStart( mLastCalendarSync ); | 1180 | eventRSync->setDtStart( mLastCalendarSync ); |
1181 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1181 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1182 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1182 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1183 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1183 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1184 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1184 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1185 | eventLSync->setReadOnly( true ); | 1185 | eventLSync->setReadOnly( true ); |
1186 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... | 1186 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1187 | remote->addEvent( eventRSync ); | 1187 | remote->addEvent( eventRSync ); |
1188 | else | 1188 | else |
1189 | delete eventRSync; | 1189 | delete eventRSync; |
1190 | QString mes; | 1190 | QString mes; |
1191 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1191 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1192 | QString delmess; | 1192 | QString delmess; |
1193 | if ( delFut ) { | 1193 | if ( delFut ) { |
1194 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1194 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1195 | mes += delmess; | 1195 | mes += delmess; |
1196 | } | 1196 | } |
1197 | if ( mSyncManager->mShowSyncSummary ) { | 1197 | if ( mSyncManager->mShowSyncSummary ) { |
1198 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1198 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1199 | } | 1199 | } |
1200 | qDebug( mes ); | 1200 | qDebug( mes ); |
1201 | mCalendar->checkAlarmForIncidence( 0, true ); | 1201 | mCalendar->checkAlarmForIncidence( 0, true ); |
1202 | return syncOK; | 1202 | return syncOK; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | void CalendarView::setSyncDevice( QString s ) | 1205 | void CalendarView::setSyncDevice( QString s ) |
1206 | { | 1206 | { |
1207 | mCurrentSyncDevice= s; | 1207 | mCurrentSyncDevice= s; |
1208 | } | 1208 | } |
1209 | void CalendarView::setSyncName( QString s ) | 1209 | void CalendarView::setSyncName( QString s ) |
1210 | { | 1210 | { |
1211 | mCurrentSyncName= s; | 1211 | mCurrentSyncName= s; |
1212 | } | 1212 | } |
1213 | bool CalendarView::syncCalendar(QString filename, int mode) | 1213 | bool CalendarView::syncCalendar(QString filename, int mode) |
1214 | { | 1214 | { |
1215 | //qDebug("syncCalendar %s ", filename.latin1()); | 1215 | //qDebug("syncCalendar %s ", filename.latin1()); |
1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1216 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1217 | CalendarLocal* calendar = new CalendarLocal(); | 1217 | CalendarLocal* calendar = new CalendarLocal(); |
1218 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1218 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1219 | FileStorage* storage = new FileStorage( calendar ); | 1219 | FileStorage* storage = new FileStorage( calendar ); |
1220 | bool syncOK = false; | 1220 | bool syncOK = false; |
1221 | storage->setFileName( filename ); | 1221 | storage->setFileName( filename ); |
1222 | // qDebug("loading ... "); | 1222 | // qDebug("loading ... "); |
1223 | if ( storage->load() ) { | 1223 | if ( storage->load() ) { |
1224 | getEventViewerDialog()->setSyncMode( true ); | 1224 | getEventViewerDialog()->setSyncMode( true ); |
1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1225 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1226 | getEventViewerDialog()->setSyncMode( false ); | 1226 | getEventViewerDialog()->setSyncMode( false ); |
1227 | if ( syncOK ) { | 1227 | if ( syncOK ) { |
1228 | if ( mSyncManager->mWriteBackFile ) | 1228 | if ( mSyncManager->mWriteBackFile ) |
1229 | { | 1229 | { |
1230 | storage->setSaveFormat( new ICalFormat() ); | 1230 | storage->setSaveFormat( new ICalFormat() ); |
1231 | storage->save(); | 1231 | storage->save(); |
1232 | } | 1232 | } |
1233 | } | 1233 | } |
1234 | setModified( true ); | 1234 | setModified( true ); |
1235 | } | 1235 | } |
1236 | delete storage; | 1236 | delete storage; |
1237 | delete calendar; | 1237 | delete calendar; |
1238 | if ( syncOK ) | 1238 | if ( syncOK ) |
1239 | updateView(); | 1239 | updateView(); |
1240 | return syncOK; | 1240 | return syncOK; |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | void CalendarView::syncExternal( int mode ) | 1243 | void CalendarView::syncExternal( int mode ) |
1244 | { | 1244 | { |
1245 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1245 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1246 | 1246 | ||
1247 | qApp->processEvents(); | 1247 | qApp->processEvents(); |
1248 | CalendarLocal* calendar = new CalendarLocal(); | 1248 | CalendarLocal* calendar = new CalendarLocal(); |
1249 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1249 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1250 | bool syncOK = false; | 1250 | bool syncOK = false; |
1251 | bool loadSuccess = false; | 1251 | bool loadSuccess = false; |
1252 | PhoneFormat* phoneFormat = 0; | 1252 | PhoneFormat* phoneFormat = 0; |
1253 | emit tempDisableBR(true); | 1253 | emit tempDisableBR(true); |
1254 | #ifndef DESKTOP_VERSION | 1254 | #ifndef DESKTOP_VERSION |
1255 | SharpFormat* sharpFormat = 0; | 1255 | SharpFormat* sharpFormat = 0; |
1256 | if ( mode == 0 ) { // sharp | 1256 | if ( mode == 0 ) { // sharp |
1257 | sharpFormat = new SharpFormat () ; | 1257 | sharpFormat = new SharpFormat () ; |
1258 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1258 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1259 | 1259 | ||
1260 | } else | 1260 | } else |
1261 | #endif | 1261 | #endif |
1262 | if ( mode == 1 ) { // phone | 1262 | if ( mode == 1 ) { // phone |
1263 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1263 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1264 | mSyncManager->mPhoneDevice, | 1264 | mSyncManager->mPhoneDevice, |
1265 | mSyncManager->mPhoneConnection, | 1265 | mSyncManager->mPhoneConnection, |
1266 | mSyncManager->mPhoneModel); | 1266 | mSyncManager->mPhoneModel); |
1267 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1267 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1268 | 1268 | ||
1269 | } else { | 1269 | } else { |
1270 | emit tempDisableBR(false); | 1270 | emit tempDisableBR(false); |
1271 | return; | 1271 | return; |
1272 | } | 1272 | } |
1273 | if ( loadSuccess ) { | 1273 | if ( loadSuccess ) { |
1274 | getEventViewerDialog()->setSyncMode( true ); | 1274 | getEventViewerDialog()->setSyncMode( true ); |
1275 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1275 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1276 | getEventViewerDialog()->setSyncMode( false ); | 1276 | getEventViewerDialog()->setSyncMode( false ); |
1277 | qApp->processEvents(); | 1277 | qApp->processEvents(); |
1278 | if ( syncOK ) { | 1278 | if ( syncOK ) { |
1279 | if ( mSyncManager->mWriteBackFile ) | 1279 | if ( mSyncManager->mWriteBackFile ) |
1280 | { | 1280 | { |
1281 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1281 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1282 | Incidence* inc = iL.first(); | 1282 | Incidence* inc = iL.first(); |
1283 | if ( phoneFormat ) { | 1283 | if ( phoneFormat ) { |
1284 | while ( inc ) { | 1284 | while ( inc ) { |
1285 | inc->removeID(mCurrentSyncDevice); | 1285 | inc->removeID(mCurrentSyncDevice); |
1286 | inc = iL.next(); | 1286 | inc = iL.next(); |
1287 | } | 1287 | } |
1288 | } | 1288 | } |
1289 | #ifndef DESKTOP_VERSION | 1289 | #ifndef DESKTOP_VERSION |
1290 | if ( sharpFormat ) | 1290 | if ( sharpFormat ) |
1291 | sharpFormat->save(calendar); | 1291 | sharpFormat->save(calendar); |
1292 | #endif | 1292 | #endif |
1293 | if ( phoneFormat ) | 1293 | if ( phoneFormat ) |
1294 | phoneFormat->save(calendar); | 1294 | phoneFormat->save(calendar); |
1295 | iL = calendar->rawIncidences(); | 1295 | iL = calendar->rawIncidences(); |
1296 | inc = iL.first(); | 1296 | inc = iL.first(); |
1297 | Incidence* loc; | 1297 | Incidence* loc; |
1298 | while ( inc ) { | 1298 | while ( inc ) { |
1299 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1299 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1300 | loc = mCalendar->incidence(inc->uid() ); | 1300 | loc = mCalendar->incidence(inc->uid() ); |
1301 | if ( loc ) { | 1301 | if ( loc ) { |
1302 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1302 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1303 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1303 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1304 | } | 1304 | } |
1305 | } | 1305 | } |
1306 | inc = iL.next(); | 1306 | inc = iL.next(); |
1307 | } | 1307 | } |
1308 | Incidence* lse = getLastSyncEvent(); | 1308 | Incidence* lse = getLastSyncEvent(); |
1309 | if ( lse ) { | 1309 | if ( lse ) { |
1310 | lse->setReadOnly( false ); | 1310 | lse->setReadOnly( false ); |
1311 | lse->setDescription( "" ); | 1311 | lse->setDescription( "" ); |
1312 | lse->setReadOnly( true ); | 1312 | lse->setReadOnly( true ); |
1313 | } | 1313 | } |
1314 | } | 1314 | } |
1315 | } | 1315 | } |
1316 | setModified( true ); | 1316 | setModified( true ); |
1317 | } else { | 1317 | } else { |
1318 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1318 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1319 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1319 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1320 | question, i18n("Ok")) ; | 1320 | question, i18n("Ok")) ; |
1321 | 1321 | ||
1322 | } | 1322 | } |
1323 | delete calendar; | 1323 | delete calendar; |
1324 | updateView(); | 1324 | updateView(); |
1325 | emit tempDisableBR(false); | 1325 | emit tempDisableBR(false); |
1326 | return ;//syncOK; | 1326 | return ;//syncOK; |
1327 | 1327 | ||
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | bool CalendarView::importBday() | 1330 | bool CalendarView::importBday() |
1331 | { | 1331 | { |
1332 | #ifndef KORG_NOKABC | 1332 | #ifndef KORG_NOKABC |
1333 | 1333 | ||
1334 | #ifdef DESKTOP_VERSION | 1334 | #ifdef DESKTOP_VERSION |
1335 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1335 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1336 | KABC::AddressBook::Iterator it; | 1336 | KABC::AddressBook::Iterator it; |
1337 | int count = 0; | 1337 | int count = 0; |
1338 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1338 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1339 | ++count; | 1339 | ++count; |
1340 | } | 1340 | } |
1341 | QProgressBar bar(count,0 ); | 1341 | QProgressBar bar(count,0 ); |
1342 | int w = 300; | 1342 | int w = 300; |
1343 | if ( QApplication::desktop()->width() < 320 ) | 1343 | if ( QApplication::desktop()->width() < 320 ) |
1344 | w = 220; | 1344 | w = 220; |
1345 | int h = bar.sizeHint().height() ; | 1345 | int h = bar.sizeHint().height() ; |
1346 | int dw = QApplication::desktop()->width(); | 1346 | int dw = QApplication::desktop()->width(); |
1347 | int dh = QApplication::desktop()->height(); | 1347 | int dh = QApplication::desktop()->height(); |
1348 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1348 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1349 | bar.show(); | 1349 | bar.show(); |
1350 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1350 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1351 | qApp->processEvents(); | 1351 | qApp->processEvents(); |
1352 | count = 0; | 1352 | count = 0; |
1353 | int addCount = 0; | 1353 | int addCount = 0; |
1354 | KCal::Attendee* a = 0; | 1354 | KCal::Attendee* a = 0; |
1355 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1355 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1356 | if ( ! bar.isVisible() ) | 1356 | if ( ! bar.isVisible() ) |
1357 | return false; | 1357 | return false; |
1358 | bar.setProgress( count++ ); | 1358 | bar.setProgress( count++ ); |
1359 | qApp->processEvents(); | 1359 | qApp->processEvents(); |
1360 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1360 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1361 | if ( (*it).birthday().date().isValid() ){ | 1361 | if ( (*it).birthday().date().isValid() ){ |
1362 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1362 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1363 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1363 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1364 | ++addCount; | 1364 | ++addCount; |
1365 | } | 1365 | } |
1366 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1366 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1367 | if ( anni.isValid() ){ | 1367 | if ( anni.isValid() ){ |
1368 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1368 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1369 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1369 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1370 | ++addCount; | 1370 | ++addCount; |
1371 | } | 1371 | } |
1372 | } | 1372 | } |
1373 | updateView(); | 1373 | updateView(); |
1374 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1374 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1375 | #else //DESKTOP_VERSION | 1375 | #else //DESKTOP_VERSION |
1376 | 1376 | ||
1377 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1377 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1378 | // the result should now arrive through method insertBirthdays | 1378 | // the result should now arrive through method insertBirthdays |
1379 | 1379 | ||
1380 | #endif //DESKTOP_VERSION | 1380 | #endif //DESKTOP_VERSION |
1381 | 1381 | ||
1382 | #endif //KORG_NOKABC | 1382 | #endif //KORG_NOKABC |
1383 | 1383 | ||
1384 | 1384 | ||
1385 | return true; | 1385 | return true; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1388 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1389 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1389 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1390 | const QStringList& anniversaryList, const QStringList& realNameList, | 1390 | const QStringList& anniversaryList, const QStringList& realNameList, |
1391 | const QStringList& emailList, const QStringList& assembledNameList, | 1391 | const QStringList& emailList, const QStringList& assembledNameList, |
1392 | const QStringList& uidList) | 1392 | const QStringList& uidList) |
1393 | { | 1393 | { |
1394 | qDebug("CalendarView::insertBirthdays"); | 1394 | qDebug("CalendarView::insertBirthdays"); |
1395 | if (uid == this->name()) | 1395 | if (uid == this->name()) |
1396 | { | 1396 | { |
1397 | int count = birthdayList.count(); | 1397 | int count = birthdayList.count(); |
1398 | int addCount = 0; | 1398 | int addCount = 0; |
1399 | KCal::Attendee* a = 0; | 1399 | KCal::Attendee* a = 0; |
1400 | 1400 | ||
1401 | qDebug("CalView 1 %i", count); | 1401 | qDebug("CalView 1 %i", count); |
1402 | 1402 | ||
1403 | QProgressBar bar(count,0 ); | 1403 | QProgressBar bar(count,0 ); |
1404 | int w = 300; | 1404 | int w = 300; |
1405 | if ( QApplication::desktop()->width() < 320 ) | 1405 | if ( QApplication::desktop()->width() < 320 ) |
1406 | w = 220; | 1406 | w = 220; |
1407 | int h = bar.sizeHint().height() ; | 1407 | int h = bar.sizeHint().height() ; |
1408 | int dw = QApplication::desktop()->width(); | 1408 | int dw = QApplication::desktop()->width(); |
1409 | int dh = QApplication::desktop()->height(); | 1409 | int dh = QApplication::desktop()->height(); |
1410 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1410 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1411 | bar.show(); | 1411 | bar.show(); |
1412 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1412 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1413 | qApp->processEvents(); | 1413 | qApp->processEvents(); |
1414 | 1414 | ||
1415 | QDate birthday; | 1415 | QDate birthday; |
1416 | QDate anniversary; | 1416 | QDate anniversary; |
1417 | QString realName; | 1417 | QString realName; |
1418 | QString email; | 1418 | QString email; |
1419 | QString assembledName; | 1419 | QString assembledName; |
1420 | QString uid; | 1420 | QString uid; |
1421 | bool ok = true; | 1421 | bool ok = true; |
1422 | for ( int i = 0; i < count; i++) | 1422 | for ( int i = 0; i < count; i++) |
1423 | { | 1423 | { |
1424 | if ( ! bar.isVisible() ) | 1424 | if ( ! bar.isVisible() ) |
1425 | return; | 1425 | return; |
1426 | bar.setProgress( i ); | 1426 | bar.setProgress( i ); |
1427 | qApp->processEvents(); | 1427 | qApp->processEvents(); |
1428 | 1428 | ||
1429 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1429 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1430 | if (!ok) { | 1430 | if (!ok) { |
1431 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1431 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1434 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1435 | if (!ok) { | 1435 | if (!ok) { |
1436 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1436 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1437 | } | 1437 | } |
1438 | realName = realNameList[i]; | 1438 | realName = realNameList[i]; |
1439 | email = emailList[i]; | 1439 | email = emailList[i]; |
1440 | assembledName = assembledNameList[i]; | 1440 | assembledName = assembledNameList[i]; |
1441 | uid = uidList[i]; | 1441 | uid = uidList[i]; |
1442 | //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() ); | 1442 | //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() ); |
1443 | 1443 | ||
1444 | if ( birthday.isValid() ){ | 1444 | if ( birthday.isValid() ){ |
1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1446 | KCal::Attendee::ReqParticipant,uid) ; | 1446 | KCal::Attendee::ReqParticipant,uid) ; |
1447 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1447 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1448 | ++addCount; | 1448 | ++addCount; |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | if ( anniversary.isValid() ){ | 1451 | if ( anniversary.isValid() ){ |
1452 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1452 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1453 | KCal::Attendee::ReqParticipant,uid) ; | 1453 | KCal::Attendee::ReqParticipant,uid) ; |
1454 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1454 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1455 | ++addCount; | 1455 | ++addCount; |
1456 | } | 1456 | } |
1457 | } | 1457 | } |
1458 | 1458 | ||
1459 | updateView(); | 1459 | updateView(); |
1460 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1460 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1461 | 1461 | ||
1462 | } | 1462 | } |
1463 | 1463 | ||
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | 1466 | ||
1467 | 1467 | ||
1468 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1468 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1469 | { | 1469 | { |
1470 | //qDebug("addAnni "); | 1470 | //qDebug("addAnni "); |
1471 | Event * ev = new Event(); | 1471 | Event * ev = new Event(); |
1472 | if ( a ) { | 1472 | if ( a ) { |
1473 | ev->addAttendee( a ); | 1473 | ev->addAttendee( a ); |
1474 | } | 1474 | } |
1475 | QString kind; | 1475 | QString kind; |
1476 | if ( birthday ) | 1476 | if ( birthday ) |
1477 | kind = i18n( "Birthday" ); | 1477 | kind = i18n( "Birthday" ); |
1478 | else | 1478 | else |
1479 | kind = i18n( "Anniversary" ); | 1479 | kind = i18n( "Anniversary" ); |
1480 | ev->setSummary( name + " - " + kind ); | 1480 | ev->setSummary( name + " - " + kind ); |
1481 | ev->setOrganizer(a->email()); | 1481 | ev->setOrganizer(a->email()); |
1482 | ev->setCategories( kind ); | 1482 | ev->setCategories( kind ); |
1483 | ev->setDtStart( QDateTime(date) ); | 1483 | ev->setDtStart( QDateTime(date) ); |
1484 | ev->setDtEnd( QDateTime(date) ); | 1484 | ev->setDtEnd( QDateTime(date) ); |
1485 | ev->setFloats( true ); | 1485 | ev->setFloats( true ); |
1486 | Recurrence * rec = ev->recurrence(); | 1486 | Recurrence * rec = ev->recurrence(); |
1487 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1487 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1488 | rec->addYearlyNum( date.month() ); | 1488 | rec->addYearlyNum( date.month() ); |
1489 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1489 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1490 | delete ev; | 1490 | delete ev; |
1491 | return false; | 1491 | return false; |
1492 | } | 1492 | } |
1493 | return true; | 1493 | return true; |
1494 | 1494 | ||
1495 | } | 1495 | } |
1496 | bool CalendarView::importQtopia( const QString &categories, | 1496 | bool CalendarView::importQtopia( const QString &categories, |
1497 | const QString &datebook, | 1497 | const QString &datebook, |
1498 | const QString &todolist ) | 1498 | const QString &todolist ) |
1499 | { | 1499 | { |
1500 | 1500 | ||
1501 | QtopiaFormat qtopiaFormat; | 1501 | QtopiaFormat qtopiaFormat; |
1502 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1502 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1503 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1503 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1504 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1504 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1505 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1505 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1506 | 1506 | ||
1507 | updateView(); | 1507 | updateView(); |
1508 | return true; | 1508 | return true; |
1509 | 1509 | ||
1510 | #if 0 | 1510 | #if 0 |
1511 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1511 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1512 | mCurrentSyncDevice = "qtopia-XML"; | 1512 | mCurrentSyncDevice = "qtopia-XML"; |
1513 | if ( mSyncManager->mAskForPreferences ) | 1513 | if ( mSyncManager->mAskForPreferences ) |
1514 | edit_sync_options(); | 1514 | edit_sync_options(); |
1515 | qApp->processEvents(); | 1515 | qApp->processEvents(); |
1516 | CalendarLocal* calendar = new CalendarLocal(); | 1516 | CalendarLocal* calendar = new CalendarLocal(); |
1517 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1517 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1518 | bool syncOK = false; | 1518 | bool syncOK = false; |
1519 | QtopiaFormat qtopiaFormat; | 1519 | QtopiaFormat qtopiaFormat; |
1520 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1520 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1521 | bool loadOk = true; | 1521 | bool loadOk = true; |
1522 | if ( !categories.isEmpty() ) | 1522 | if ( !categories.isEmpty() ) |
1523 | loadOk = qtopiaFormat.load( calendar, categories ); | 1523 | loadOk = qtopiaFormat.load( calendar, categories ); |
1524 | if ( loadOk && !datebook.isEmpty() ) | 1524 | if ( loadOk && !datebook.isEmpty() ) |
1525 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1525 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1526 | if ( loadOk && !todolist.isEmpty() ) | 1526 | if ( loadOk && !todolist.isEmpty() ) |
1527 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1527 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1528 | 1528 | ||
1529 | if ( loadOk ) { | 1529 | if ( loadOk ) { |
1530 | getEventViewerDialog()->setSyncMode( true ); | 1530 | getEventViewerDialog()->setSyncMode( true ); |
1531 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1531 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1532 | getEventViewerDialog()->setSyncMode( false ); | 1532 | getEventViewerDialog()->setSyncMode( false ); |
1533 | qApp->processEvents(); | 1533 | qApp->processEvents(); |
1534 | if ( syncOK ) { | 1534 | if ( syncOK ) { |
1535 | if ( mSyncManager->mWriteBackFile ) | 1535 | if ( mSyncManager->mWriteBackFile ) |
1536 | { | 1536 | { |
1537 | // write back XML file | 1537 | // write back XML file |
1538 | 1538 | ||
1539 | } | 1539 | } |
1540 | setModified( true ); | 1540 | setModified( true ); |
1541 | } | 1541 | } |
1542 | } else { | 1542 | } else { |
1543 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1543 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1544 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1544 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1545 | question, i18n("Ok")) ; | 1545 | question, i18n("Ok")) ; |
1546 | } | 1546 | } |
1547 | delete calendar; | 1547 | delete calendar; |
1548 | updateView(); | 1548 | updateView(); |
1549 | return syncOK; | 1549 | return syncOK; |
1550 | 1550 | ||
1551 | 1551 | ||
1552 | #endif | 1552 | #endif |
1553 | 1553 | ||
1554 | } | 1554 | } |
1555 | 1555 | ||
1556 | void CalendarView::setSyncEventsReadOnly() | 1556 | void CalendarView::setSyncEventsReadOnly() |
1557 | { | 1557 | { |
1558 | Event * ev; | 1558 | Event * ev; |
1559 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1559 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1560 | ev = eL.first(); | 1560 | ev = eL.first(); |
1561 | while ( ev ) { | 1561 | while ( ev ) { |
1562 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1562 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1563 | ev->setReadOnly( true ); | 1563 | ev->setReadOnly( true ); |
1564 | ev = eL.next(); | 1564 | ev = eL.next(); |
1565 | } | 1565 | } |
1566 | } | 1566 | } |
1567 | bool CalendarView::openCalendar(QString filename, bool merge) | 1567 | bool CalendarView::openCalendar(QString filename, bool merge) |
1568 | { | 1568 | { |
1569 | 1569 | ||
1570 | if (filename.isEmpty()) { | 1570 | if (filename.isEmpty()) { |
1571 | return false; | 1571 | return false; |
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | if (!QFile::exists(filename)) { | 1574 | if (!QFile::exists(filename)) { |
1575 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1575 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1576 | return false; | 1576 | return false; |
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | globalFlagBlockAgenda = 1; | 1579 | globalFlagBlockAgenda = 1; |
1580 | if (!merge) mCalendar->close(); | 1580 | if (!merge) mCalendar->close(); |
1581 | 1581 | ||
1582 | mStorage->setFileName( filename ); | 1582 | mStorage->setFileName( filename ); |
1583 | 1583 | ||
1584 | if ( mStorage->load() ) { | 1584 | if ( mStorage->load() ) { |
1585 | if ( merge ) ;//setModified( true ); | 1585 | if ( merge ) ;//setModified( true ); |
1586 | else { | 1586 | else { |
1587 | //setModified( true ); | 1587 | //setModified( true ); |
1588 | mViewManager->setDocumentId( filename ); | 1588 | mViewManager->setDocumentId( filename ); |
1589 | mDialogManager->setDocumentId( filename ); | 1589 | mDialogManager->setDocumentId( filename ); |
1590 | mTodoList->setDocumentId( filename ); | 1590 | mTodoList->setDocumentId( filename ); |
1591 | } | 1591 | } |
1592 | globalFlagBlockAgenda = 2; | 1592 | globalFlagBlockAgenda = 2; |
1593 | // if ( getLastSyncEvent() ) | 1593 | // if ( getLastSyncEvent() ) |
1594 | // getLastSyncEvent()->setReadOnly( true ); | 1594 | // getLastSyncEvent()->setReadOnly( true ); |
1595 | mCalendar->reInitAlarmSettings(); | 1595 | mCalendar->reInitAlarmSettings(); |
1596 | setSyncEventsReadOnly(); | 1596 | setSyncEventsReadOnly(); |
1597 | updateUnmanagedViews(); | 1597 | updateUnmanagedViews(); |
1598 | updateView(); | 1598 | updateView(); |
1599 | if ( filename != MainWindow::defaultFileName() ) { | 1599 | if ( filename != MainWindow::defaultFileName() ) { |
1600 | saveCalendar( MainWindow::defaultFileName() ); | 1600 | saveCalendar( MainWindow::defaultFileName() ); |
1601 | } else { | 1601 | } else { |
1602 | QFileInfo finf ( MainWindow::defaultFileName()); | 1602 | QFileInfo finf ( MainWindow::defaultFileName()); |
1603 | if ( finf.exists() ) { | 1603 | if ( finf.exists() ) { |
1604 | setLoadedFileVersion( finf.lastModified () ); | 1604 | setLoadedFileVersion( finf.lastModified () ); |
1605 | } | 1605 | } |
1606 | } | 1606 | } |
1607 | return true; | 1607 | return true; |
1608 | } else { | 1608 | } else { |
1609 | // while failing to load, the calendar object could | 1609 | // while failing to load, the calendar object could |
1610 | // have become partially populated. Clear it out. | 1610 | // have become partially populated. Clear it out. |
1611 | if ( !merge ) { | 1611 | if ( !merge ) { |
1612 | mCalendar->close(); | 1612 | mCalendar->close(); |
1613 | mViewManager->setDocumentId( filename ); | 1613 | mViewManager->setDocumentId( filename ); |
1614 | mDialogManager->setDocumentId( filename ); | 1614 | mDialogManager->setDocumentId( filename ); |
1615 | mTodoList->setDocumentId( filename ); | 1615 | mTodoList->setDocumentId( filename ); |
1616 | } | 1616 | } |
1617 | 1617 | ||
1618 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1618 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1619 | 1619 | ||
1620 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1620 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1621 | globalFlagBlockAgenda = 2; | 1621 | globalFlagBlockAgenda = 2; |
1622 | mCalendar->reInitAlarmSettings(); | 1622 | mCalendar->reInitAlarmSettings(); |
1623 | setSyncEventsReadOnly(); | 1623 | setSyncEventsReadOnly(); |
1624 | updateUnmanagedViews(); | 1624 | updateUnmanagedViews(); |
1625 | updateView(); | 1625 | updateView(); |
1626 | } | 1626 | } |
1627 | return false; | 1627 | return false; |
1628 | } | 1628 | } |
1629 | void CalendarView::showOpenError() | 1629 | void CalendarView::showOpenError() |
1630 | { | 1630 | { |
1631 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1631 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1632 | } | 1632 | } |
1633 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1633 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1634 | { | 1634 | { |
1635 | loadedFileVersion = dt; | 1635 | loadedFileVersion = dt; |
1636 | } | 1636 | } |
1637 | bool CalendarView::checkFileChanged(QString fn) | 1637 | bool CalendarView::checkFileChanged(QString fn) |
1638 | { | 1638 | { |
1639 | QFileInfo finf ( fn ); | 1639 | QFileInfo finf ( fn ); |
1640 | if ( !finf.exists() ) | 1640 | if ( !finf.exists() ) |
1641 | return true; | 1641 | return true; |
1642 | QDateTime dt = finf.lastModified (); | 1642 | QDateTime dt = finf.lastModified (); |
1643 | if ( dt <= loadedFileVersion ) | 1643 | if ( dt <= loadedFileVersion ) |
1644 | return false; | 1644 | return false; |
1645 | return true; | 1645 | return true; |
1646 | 1646 | ||
1647 | } | 1647 | } |
1648 | void CalendarView::watchSavedFile() | 1648 | void CalendarView::watchSavedFile() |
1649 | { | 1649 | { |
1650 | QFileInfo finf ( MainWindow::defaultFileName()); | 1650 | QFileInfo finf ( MainWindow::defaultFileName()); |
1651 | if ( !finf.exists() ) | 1651 | if ( !finf.exists() ) |
1652 | return; | 1652 | return; |
1653 | QDateTime dt = finf.lastModified (); | 1653 | QDateTime dt = finf.lastModified (); |
1654 | if ( dt < loadedFileVersion ) { | 1654 | if ( dt < loadedFileVersion ) { |
1655 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1655 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1656 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1656 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1657 | return; | 1657 | return; |
1658 | } | 1658 | } |
1659 | loadedFileVersion = dt; | 1659 | loadedFileVersion = dt; |
1660 | } | 1660 | } |
1661 | 1661 | ||
1662 | bool CalendarView::checkFileVersion(QString fn) | 1662 | bool CalendarView::checkFileVersion(QString fn) |
1663 | { | 1663 | { |
1664 | QFileInfo finf ( fn ); | 1664 | QFileInfo finf ( fn ); |
1665 | if ( !finf.exists() ) | 1665 | if ( !finf.exists() ) |
1666 | return true; | 1666 | return true; |
1667 | QDateTime dt = finf.lastModified (); | 1667 | QDateTime dt = finf.lastModified (); |
1668 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1668 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1669 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1669 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1670 | if ( dt <= loadedFileVersion ) | 1670 | if ( dt <= loadedFileVersion ) |
1671 | return true; | 1671 | return true; |
1672 | 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)) , | 1672 | 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)) , |
1673 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1673 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1674 | i18n("Sync+save")); | 1674 | i18n("Sync+save")); |
1675 | 1675 | ||
1676 | if ( km == KMessageBox::Cancel ) | 1676 | if ( km == KMessageBox::Cancel ) |
1677 | return false; | 1677 | return false; |
1678 | if ( km == KMessageBox::Yes ) | 1678 | if ( km == KMessageBox::Yes ) |
1679 | return true; | 1679 | return true; |
1680 | 1680 | ||
1681 | setSyncDevice("deleteaftersync" ); | 1681 | setSyncDevice("deleteaftersync" ); |
1682 | mSyncManager->mAskForPreferences = true; | 1682 | mSyncManager->mAskForPreferences = true; |
1683 | mSyncManager->mSyncAlgoPrefs = 3; | 1683 | mSyncManager->mSyncAlgoPrefs = 3; |
1684 | mSyncManager->mWriteBackFile = false; | 1684 | mSyncManager->mWriteBackFile = false; |
1685 | mSyncManager->mWriteBackExistingOnly = false; | 1685 | mSyncManager->mWriteBackExistingOnly = false; |
1686 | mSyncManager->mShowSyncSummary = false; | 1686 | mSyncManager->mShowSyncSummary = false; |
1687 | syncCalendar( fn, 3 ); | 1687 | syncCalendar( fn, 3 ); |
1688 | Event * e = getLastSyncEvent(); | 1688 | Event * e = getLastSyncEvent(); |
1689 | mCalendar->deleteEvent ( e ); | 1689 | mCalendar->deleteEvent ( e ); |
1690 | updateView(); | 1690 | updateView(); |
1691 | return true; | 1691 | return true; |
1692 | } | 1692 | } |
1693 | 1693 | ||
1694 | bool CalendarView::saveCalendar( QString filename ) | 1694 | bool CalendarView::saveCalendar( QString filename ) |
1695 | { | 1695 | { |
1696 | 1696 | ||
1697 | // Store back all unsaved data into calendar object | 1697 | // Store back all unsaved data into calendar object |
1698 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1698 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1699 | if ( mViewManager->currentView() ) | 1699 | if ( mViewManager->currentView() ) |
1700 | mViewManager->currentView()->flushView(); | 1700 | mViewManager->currentView()->flushView(); |
1701 | 1701 | ||
1702 | 1702 | ||
1703 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1703 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1704 | mStorage->setSaveFormat( new ICalFormat() ); | 1704 | mStorage->setSaveFormat( new ICalFormat() ); |
1705 | mStorage->setFileName( filename ); | 1705 | mStorage->setFileName( filename ); |
1706 | bool success; | 1706 | bool success; |
1707 | success = mStorage->save(); | 1707 | success = mStorage->save(); |
1708 | if ( !success ) { | 1708 | if ( !success ) { |
1709 | return false; | 1709 | return false; |
1710 | } | 1710 | } |
1711 | if ( filename == MainWindow::defaultFileName() ) { | 1711 | if ( filename == MainWindow::defaultFileName() ) { |
1712 | setLoadedFileVersion( lfv ); | 1712 | setLoadedFileVersion( lfv ); |
1713 | watchSavedFile(); | 1713 | watchSavedFile(); |
1714 | } | 1714 | } |
1715 | return true; | 1715 | return true; |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | void CalendarView::closeCalendar() | 1718 | void CalendarView::closeCalendar() |
1719 | { | 1719 | { |
1720 | 1720 | ||
1721 | // child windows no longer valid | 1721 | // child windows no longer valid |
1722 | emit closingDown(); | 1722 | emit closingDown(); |
1723 | 1723 | ||
1724 | mCalendar->close(); | 1724 | mCalendar->close(); |
1725 | setModified(false); | 1725 | setModified(false); |
1726 | updateView(); | 1726 | updateView(); |
1727 | } | 1727 | } |
1728 | 1728 | ||
1729 | void CalendarView::archiveCalendar() | 1729 | void CalendarView::archiveCalendar() |
1730 | { | 1730 | { |
1731 | mDialogManager->showArchiveDialog(); | 1731 | mDialogManager->showArchiveDialog(); |
1732 | } | 1732 | } |
1733 | 1733 | ||
1734 | 1734 | ||
1735 | void CalendarView::readSettings() | 1735 | void CalendarView::readSettings() |
1736 | { | 1736 | { |
1737 | 1737 | ||
1738 | 1738 | ||
1739 | // mViewManager->showAgendaView(); | 1739 | // mViewManager->showAgendaView(); |
1740 | QString str; | 1740 | QString str; |
1741 | //qDebug("CalendarView::readSettings() "); | 1741 | //qDebug("CalendarView::readSettings() "); |
1742 | // read settings from the KConfig, supplying reasonable | 1742 | // read settings from the KConfig, supplying reasonable |
1743 | // defaults where none are to be found | 1743 | // defaults where none are to be found |
1744 | KConfig *config = KOGlobals::config(); | 1744 | KConfig *config = KOGlobals::config(); |
1745 | #ifndef KORG_NOSPLITTER | 1745 | #ifndef KORG_NOSPLITTER |
1746 | config->setGroup("KOrganizer Geometry"); | 1746 | config->setGroup("KOrganizer Geometry"); |
1747 | 1747 | ||
1748 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1748 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1749 | if (sizes.count() != 2) { | 1749 | if (sizes.count() != 2) { |
1750 | sizes << mDateNavigator->minimumSizeHint().width(); | 1750 | sizes << mDateNavigator->minimumSizeHint().width(); |
1751 | sizes << 300; | 1751 | sizes << 300; |
1752 | } | 1752 | } |
1753 | mPanner->setSizes(sizes); | 1753 | mPanner->setSizes(sizes); |
1754 | 1754 | ||
1755 | sizes = config->readIntListEntry("Separator2"); | 1755 | sizes = config->readIntListEntry("Separator2"); |
1756 | if ( ( mResourceView && sizes.count() == 4 ) || | 1756 | if ( ( mResourceView && sizes.count() == 4 ) || |
1757 | ( !mResourceView && sizes.count() == 3 ) ) { | 1757 | ( !mResourceView && sizes.count() == 3 ) ) { |
1758 | mLeftSplitter->setSizes(sizes); | 1758 | mLeftSplitter->setSizes(sizes); |
1759 | } | 1759 | } |
1760 | #endif | 1760 | #endif |
1761 | globalFlagBlockAgenda = 1; | 1761 | globalFlagBlockAgenda = 1; |
1762 | mViewManager->showAgendaView(); | 1762 | mViewManager->showAgendaView(); |
1763 | //mViewManager->readSettings( config ); | 1763 | //mViewManager->readSettings( config ); |
1764 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1764 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1765 | readFilterSettings(config); | 1765 | readFilterSettings(config); |
1766 | config->setGroup( "Views" ); | 1766 | config->setGroup( "Views" ); |
1767 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1767 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1768 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1768 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1769 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1769 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1770 | else mNavigator->selectDates( dateCount ); | 1770 | else mNavigator->selectDates( dateCount ); |
1771 | // mViewManager->readSettings( config ); | 1771 | // mViewManager->readSettings( config ); |
1772 | updateConfig(); | 1772 | updateConfig(); |
1773 | globalFlagBlockAgenda = 2; | 1773 | globalFlagBlockAgenda = 2; |
1774 | mViewManager->readSettings( config ); | 1774 | mViewManager->readSettings( config ); |
1775 | #ifdef DESKTOP_VERSION | 1775 | #ifdef DESKTOP_VERSION |
1776 | config->setGroup("WidgetLayout"); | 1776 | config->setGroup("WidgetLayout"); |
1777 | QStringList list; | 1777 | QStringList list; |
1778 | list = config->readListEntry("MainLayout"); | 1778 | list = config->readListEntry("MainLayout"); |
1779 | int x,y,w,h; | 1779 | int x,y,w,h; |
1780 | if ( ! list.isEmpty() ) { | 1780 | if ( ! list.isEmpty() ) { |
1781 | x = list[0].toInt(); | 1781 | x = list[0].toInt(); |
1782 | y = list[1].toInt(); | 1782 | y = list[1].toInt(); |
1783 | w = list[2].toInt(); | 1783 | w = list[2].toInt(); |
1784 | h = list[3].toInt(); | 1784 | h = list[3].toInt(); |
1785 | topLevelWidget()->setGeometry(x,y,w,h); | 1785 | topLevelWidget()->setGeometry(x,y,w,h); |
1786 | 1786 | ||
1787 | } else { | 1787 | } else { |
1788 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1788 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1789 | } | 1789 | } |
1790 | list = config->readListEntry("EditEventLayout"); | 1790 | list = config->readListEntry("EditEventLayout"); |
1791 | if ( ! list.isEmpty() ) { | 1791 | if ( ! list.isEmpty() ) { |
1792 | x = list[0].toInt(); | 1792 | x = list[0].toInt(); |
1793 | y = list[1].toInt(); | 1793 | y = list[1].toInt(); |
1794 | w = list[2].toInt(); | 1794 | w = list[2].toInt(); |
1795 | h = list[3].toInt(); | 1795 | h = list[3].toInt(); |
1796 | mEventEditor->setGeometry(x,y,w,h); | 1796 | mEventEditor->setGeometry(x,y,w,h); |
1797 | 1797 | ||
1798 | } | 1798 | } |
1799 | list = config->readListEntry("EditTodoLayout"); | 1799 | list = config->readListEntry("EditTodoLayout"); |
1800 | if ( ! list.isEmpty() ) { | 1800 | if ( ! list.isEmpty() ) { |
1801 | x = list[0].toInt(); | 1801 | x = list[0].toInt(); |
1802 | y = list[1].toInt(); | 1802 | y = list[1].toInt(); |
1803 | w = list[2].toInt(); | 1803 | w = list[2].toInt(); |
1804 | h = list[3].toInt(); | 1804 | h = list[3].toInt(); |
1805 | mTodoEditor->setGeometry(x,y,w,h); | 1805 | mTodoEditor->setGeometry(x,y,w,h); |
1806 | 1806 | ||
1807 | } | 1807 | } |
1808 | list = config->readListEntry("ViewerLayout"); | 1808 | list = config->readListEntry("ViewerLayout"); |
1809 | if ( ! list.isEmpty() ) { | 1809 | if ( ! list.isEmpty() ) { |
1810 | x = list[0].toInt(); | 1810 | x = list[0].toInt(); |
1811 | y = list[1].toInt(); | 1811 | y = list[1].toInt(); |
1812 | w = list[2].toInt(); | 1812 | w = list[2].toInt(); |
1813 | h = list[3].toInt(); | 1813 | h = list[3].toInt(); |
1814 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1814 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1815 | } | 1815 | } |
1816 | #endif | 1816 | #endif |
1817 | 1817 | ||
1818 | } | 1818 | } |
1819 | 1819 | ||
1820 | 1820 | ||
1821 | void CalendarView::writeSettings() | 1821 | void CalendarView::writeSettings() |
1822 | { | 1822 | { |
1823 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1823 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1824 | 1824 | ||
1825 | KConfig *config = KOGlobals::config(); | 1825 | KConfig *config = KOGlobals::config(); |
1826 | 1826 | ||
1827 | #ifndef KORG_NOSPLITTER | 1827 | #ifndef KORG_NOSPLITTER |
1828 | config->setGroup("KOrganizer Geometry"); | 1828 | config->setGroup("KOrganizer Geometry"); |
1829 | 1829 | ||
1830 | QValueList<int> list = mPanner->sizes(); | 1830 | QValueList<int> list = mPanner->sizes(); |
1831 | config->writeEntry("Separator1",list); | 1831 | config->writeEntry("Separator1",list); |
1832 | 1832 | ||
1833 | list = mLeftSplitter->sizes(); | 1833 | list = mLeftSplitter->sizes(); |
1834 | config->writeEntry("Separator2",list); | 1834 | config->writeEntry("Separator2",list); |
1835 | #endif | 1835 | #endif |
1836 | 1836 | ||
1837 | mViewManager->writeSettings( config ); | 1837 | mViewManager->writeSettings( config ); |
1838 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1838 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1839 | mDialogManager->writeSettings( config ); | 1839 | mDialogManager->writeSettings( config ); |
1840 | //KOPrefs::instance()->usrWriteConfig(); | 1840 | //KOPrefs::instance()->usrWriteConfig(); |
1841 | KOPrefs::instance()->writeConfig(); | 1841 | KOPrefs::instance()->writeConfig(); |
1842 | 1842 | ||
1843 | writeFilterSettings(config); | 1843 | writeFilterSettings(config); |
1844 | 1844 | ||
1845 | config->setGroup( "Views" ); | 1845 | config->setGroup( "Views" ); |
1846 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1846 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1847 | 1847 | ||
1848 | #ifdef DESKTOP_VERSION | 1848 | #ifdef DESKTOP_VERSION |
1849 | config->setGroup("WidgetLayout"); | 1849 | config->setGroup("WidgetLayout"); |
1850 | QStringList list ;//= config->readListEntry("MainLayout"); | 1850 | QStringList list ;//= config->readListEntry("MainLayout"); |
1851 | int x,y,w,h; | 1851 | int x,y,w,h; |
1852 | QWidget* wid; | 1852 | QWidget* wid; |
1853 | wid = topLevelWidget(); | 1853 | wid = topLevelWidget(); |
1854 | x = wid->geometry().x(); | 1854 | x = wid->geometry().x(); |
1855 | y = wid->geometry().y(); | 1855 | y = wid->geometry().y(); |
1856 | w = wid->width(); | 1856 | w = wid->width(); |
1857 | h = wid->height(); | 1857 | h = wid->height(); |
1858 | list.clear(); | 1858 | list.clear(); |
1859 | list << QString::number( x ); | 1859 | list << QString::number( x ); |
1860 | list << QString::number( y ); | 1860 | list << QString::number( y ); |
1861 | list << QString::number( w ); | 1861 | list << QString::number( w ); |
1862 | list << QString::number( h ); | 1862 | list << QString::number( h ); |
1863 | config->writeEntry("MainLayout",list ); | 1863 | config->writeEntry("MainLayout",list ); |
1864 | 1864 | ||
1865 | wid = mEventEditor; | 1865 | wid = mEventEditor; |
1866 | x = wid->geometry().x(); | 1866 | x = wid->geometry().x(); |
1867 | y = wid->geometry().y(); | 1867 | y = wid->geometry().y(); |
1868 | w = wid->width(); | 1868 | w = wid->width(); |
1869 | h = wid->height(); | 1869 | h = wid->height(); |
1870 | list.clear(); | 1870 | list.clear(); |
1871 | list << QString::number( x ); | 1871 | list << QString::number( x ); |
1872 | list << QString::number( y ); | 1872 | list << QString::number( y ); |
1873 | list << QString::number( w ); | 1873 | list << QString::number( w ); |
1874 | list << QString::number( h ); | 1874 | list << QString::number( h ); |
1875 | config->writeEntry("EditEventLayout",list ); | 1875 | config->writeEntry("EditEventLayout",list ); |
1876 | 1876 | ||
1877 | wid = mTodoEditor; | 1877 | wid = mTodoEditor; |
1878 | x = wid->geometry().x(); | 1878 | x = wid->geometry().x(); |
1879 | y = wid->geometry().y(); | 1879 | y = wid->geometry().y(); |
1880 | w = wid->width(); | 1880 | w = wid->width(); |
1881 | h = wid->height(); | 1881 | h = wid->height(); |
1882 | list.clear(); | 1882 | list.clear(); |
1883 | list << QString::number( x ); | 1883 | list << QString::number( x ); |
1884 | list << QString::number( y ); | 1884 | list << QString::number( y ); |
1885 | list << QString::number( w ); | 1885 | list << QString::number( w ); |
1886 | list << QString::number( h ); | 1886 | list << QString::number( h ); |
1887 | config->writeEntry("EditTodoLayout",list ); | 1887 | config->writeEntry("EditTodoLayout",list ); |
1888 | wid = getEventViewerDialog(); | 1888 | wid = getEventViewerDialog(); |
1889 | x = wid->geometry().x(); | 1889 | x = wid->geometry().x(); |
1890 | y = wid->geometry().y(); | 1890 | y = wid->geometry().y(); |
1891 | w = wid->width(); | 1891 | w = wid->width(); |
1892 | h = wid->height(); | 1892 | h = wid->height(); |
1893 | list.clear(); | 1893 | list.clear(); |
1894 | list << QString::number( x ); | 1894 | list << QString::number( x ); |
1895 | list << QString::number( y ); | 1895 | list << QString::number( y ); |
1896 | list << QString::number( w ); | 1896 | list << QString::number( w ); |
1897 | list << QString::number( h ); | 1897 | list << QString::number( h ); |
1898 | config->writeEntry("ViewerLayout",list ); | 1898 | config->writeEntry("ViewerLayout",list ); |
1899 | wid = mDialogManager->getSearchDialog(); | 1899 | wid = mDialogManager->getSearchDialog(); |
1900 | if ( wid ) { | 1900 | if ( wid ) { |
1901 | x = wid->geometry().x(); | 1901 | x = wid->geometry().x(); |
1902 | y = wid->geometry().y(); | 1902 | y = wid->geometry().y(); |
1903 | w = wid->width(); | 1903 | w = wid->width(); |
1904 | h = wid->height(); | 1904 | h = wid->height(); |
1905 | list.clear(); | 1905 | list.clear(); |
1906 | list << QString::number( x ); | 1906 | list << QString::number( x ); |
1907 | list << QString::number( y ); | 1907 | list << QString::number( y ); |
1908 | list << QString::number( w ); | 1908 | list << QString::number( w ); |
1909 | list << QString::number( h ); | 1909 | list << QString::number( h ); |
1910 | config->writeEntry("SearchLayout",list ); | 1910 | config->writeEntry("SearchLayout",list ); |
1911 | } | 1911 | } |
1912 | #endif | 1912 | #endif |
1913 | 1913 | ||
1914 | 1914 | ||
1915 | config->sync(); | 1915 | config->sync(); |
1916 | } | 1916 | } |
1917 | 1917 | ||
1918 | void CalendarView::readFilterSettings(KConfig *config) | 1918 | void CalendarView::readFilterSettings(KConfig *config) |
1919 | { | 1919 | { |
1920 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1920 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1921 | 1921 | ||
1922 | mFilters.clear(); | 1922 | mFilters.clear(); |
1923 | 1923 | ||
1924 | config->setGroup("General"); | 1924 | config->setGroup("General"); |
1925 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1925 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1926 | 1926 | ||
1927 | QStringList::ConstIterator it = filterList.begin(); | 1927 | QStringList::ConstIterator it = filterList.begin(); |
1928 | QStringList::ConstIterator end = filterList.end(); | 1928 | QStringList::ConstIterator end = filterList.end(); |
1929 | while(it != end) { | 1929 | while(it != end) { |
1930 | // kdDebug() << " filter: " << (*it) << endl; | 1930 | // kdDebug() << " filter: " << (*it) << endl; |
1931 | 1931 | ||
1932 | CalFilter *filter; | 1932 | CalFilter *filter; |
1933 | filter = new CalFilter(*it); | 1933 | filter = new CalFilter(*it); |
1934 | config->setGroup("Filter_" + (*it)); | 1934 | config->setGroup("Filter_" + (*it)); |
1935 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1935 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1936 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1936 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1937 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1937 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1938 | mFilters.append(filter); | 1938 | mFilters.append(filter); |
1939 | 1939 | ||
1940 | ++it; | 1940 | ++it; |
1941 | } | 1941 | } |
1942 | 1942 | ||
1943 | if (mFilters.count() == 0) { | 1943 | if (mFilters.count() == 0) { |
1944 | CalFilter *filter = new CalFilter(i18n("Default")); | 1944 | CalFilter *filter = new CalFilter(i18n("Default")); |
1945 | mFilters.append(filter); | 1945 | mFilters.append(filter); |
1946 | } | 1946 | } |
1947 | mFilterView->updateFilters(); | 1947 | mFilterView->updateFilters(); |
1948 | config->setGroup("FilterView"); | 1948 | config->setGroup("FilterView"); |
1949 | 1949 | ||
1950 | mFilterView->blockSignals(true); | 1950 | mFilterView->blockSignals(true); |
1951 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1951 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1952 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1952 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1953 | mFilterView->blockSignals(false); | 1953 | mFilterView->blockSignals(false); |
1954 | // We do it manually to avoid it being done twice by the above calls | 1954 | // We do it manually to avoid it being done twice by the above calls |
1955 | updateFilter(); | 1955 | updateFilter(); |
1956 | } | 1956 | } |
1957 | 1957 | ||
1958 | void CalendarView::writeFilterSettings(KConfig *config) | 1958 | void CalendarView::writeFilterSettings(KConfig *config) |
1959 | { | 1959 | { |
1960 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1960 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1961 | 1961 | ||
1962 | QStringList filterList; | 1962 | QStringList filterList; |
1963 | 1963 | ||
1964 | CalFilter *filter = mFilters.first(); | 1964 | CalFilter *filter = mFilters.first(); |
1965 | while(filter) { | 1965 | while(filter) { |
1966 | // kdDebug() << " fn: " << filter->name() << endl; | 1966 | // kdDebug() << " fn: " << filter->name() << endl; |
1967 | filterList << filter->name(); | 1967 | filterList << filter->name(); |
1968 | config->setGroup("Filter_" + filter->name()); | 1968 | config->setGroup("Filter_" + filter->name()); |
1969 | config->writeEntry("Criteria",filter->criteria()); | 1969 | config->writeEntry("Criteria",filter->criteria()); |
1970 | config->writeEntry("CategoryList",filter->categoryList()); | 1970 | config->writeEntry("CategoryList",filter->categoryList()); |
1971 | filter = mFilters.next(); | 1971 | filter = mFilters.next(); |
1972 | } | 1972 | } |
1973 | config->setGroup("General"); | 1973 | config->setGroup("General"); |
1974 | config->writeEntry("CalendarFilters",filterList); | 1974 | config->writeEntry("CalendarFilters",filterList); |
1975 | 1975 | ||
1976 | config->setGroup("FilterView"); | 1976 | config->setGroup("FilterView"); |
1977 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1977 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1978 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1978 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1979 | } | 1979 | } |
1980 | 1980 | ||
1981 | 1981 | ||
1982 | void CalendarView::goToday() | 1982 | void CalendarView::goToday() |
1983 | { | 1983 | { |
1984 | mNavigator->selectToday(); | 1984 | mNavigator->selectToday(); |
1985 | } | 1985 | } |
1986 | 1986 | ||
1987 | void CalendarView::goNext() | 1987 | void CalendarView::goNext() |
1988 | { | 1988 | { |
1989 | mNavigator->selectNext(); | 1989 | mNavigator->selectNext(); |
1990 | } | 1990 | } |
1991 | 1991 | ||
1992 | void CalendarView::goPrevious() | 1992 | void CalendarView::goPrevious() |
1993 | { | 1993 | { |
1994 | mNavigator->selectPrevious(); | 1994 | mNavigator->selectPrevious(); |
1995 | } | 1995 | } |
1996 | void CalendarView::goNextMonth() | 1996 | void CalendarView::goNextMonth() |
1997 | { | 1997 | { |
1998 | mNavigator->selectNextMonth(); | 1998 | mNavigator->selectNextMonth(); |
1999 | } | 1999 | } |
2000 | 2000 | ||
2001 | void CalendarView::goPreviousMonth() | 2001 | void CalendarView::goPreviousMonth() |
2002 | { | 2002 | { |
2003 | mNavigator->selectPreviousMonth(); | 2003 | mNavigator->selectPreviousMonth(); |
2004 | } | 2004 | } |
2005 | void CalendarView::writeLocale() | 2005 | void CalendarView::writeLocale() |
2006 | { | 2006 | { |
2007 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2007 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2008 | #if 0 | 2008 | #if 0 |
2009 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2009 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2010 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2010 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2011 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2011 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2012 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2012 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2013 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2013 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2014 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2014 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2015 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2015 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2016 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2016 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2017 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2017 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2018 | KOPrefs::instance()->mDaylightsavingStart, | 2018 | KOPrefs::instance()->mDaylightsavingStart, |
2019 | KOPrefs::instance()->mDaylightsavingEnd ); | 2019 | KOPrefs::instance()->mDaylightsavingEnd ); |
2020 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2020 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2021 | #endif | 2021 | #endif |
2022 | } | 2022 | } |
2023 | void CalendarView::updateConfig() | 2023 | void CalendarView::updateConfig() |
2024 | { | 2024 | { |
2025 | writeLocale(); | 2025 | writeLocale(); |
2026 | if ( KOPrefs::instance()->mUseAppColors ) | 2026 | if ( KOPrefs::instance()->mUseAppColors ) |
2027 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2027 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2028 | emit configChanged(); | 2028 | emit configChanged(); |
2029 | mTodoList->updateConfig(); | 2029 | mTodoList->updateConfig(); |
2030 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2030 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2031 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2031 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2032 | // To make the "fill window" configurations work | 2032 | // To make the "fill window" configurations work |
2033 | //mViewManager->raiseCurrentView(); | 2033 | //mViewManager->raiseCurrentView(); |
2034 | } | 2034 | } |
2035 | 2035 | ||
2036 | 2036 | ||
2037 | void CalendarView::eventChanged(Event *event) | 2037 | void CalendarView::eventChanged(Event *event) |
2038 | { | 2038 | { |
2039 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2039 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2040 | //updateUnmanagedViews(); | 2040 | //updateUnmanagedViews(); |
2041 | } | 2041 | } |
2042 | 2042 | ||
2043 | void CalendarView::eventAdded(Event *event) | 2043 | void CalendarView::eventAdded(Event *event) |
2044 | { | 2044 | { |
2045 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2045 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | void CalendarView::eventToBeDeleted(Event *) | 2048 | void CalendarView::eventToBeDeleted(Event *) |
2049 | { | 2049 | { |
2050 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2050 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2051 | } | 2051 | } |
2052 | 2052 | ||
2053 | void CalendarView::eventDeleted() | 2053 | void CalendarView::eventDeleted() |
2054 | { | 2054 | { |
2055 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2055 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2056 | } | 2056 | } |
2057 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2057 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2058 | { | 2058 | { |
2059 | changeIncidenceDisplay((Incidence *)which, action); | 2059 | changeIncidenceDisplay((Incidence *)which, action); |
2060 | mDateNavigator->updateView(); //LR | 2060 | mDateNavigator->updateView(); //LR |
2061 | //mDialogManager->updateSearchDialog(); | 2061 | //mDialogManager->updateSearchDialog(); |
2062 | 2062 | ||
2063 | if (which) { | 2063 | if (which) { |
2064 | mViewManager->updateWNview(); | 2064 | mViewManager->updateWNview(); |
2065 | //mTodoList->updateView(); | 2065 | //mTodoList->updateView(); |
2066 | } | 2066 | } |
2067 | 2067 | ||
2068 | } | 2068 | } |
2069 | 2069 | ||
2070 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2070 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2071 | { | 2071 | { |
2072 | updateUnmanagedViews(); | 2072 | updateUnmanagedViews(); |
2073 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2073 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2074 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2074 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2075 | mCalendar->checkAlarmForIncidence( 0, true ); | 2075 | mCalendar->checkAlarmForIncidence( 0, true ); |
2076 | if ( mEventViewerDialog ) | 2076 | if ( mEventViewerDialog ) |
2077 | mEventViewerDialog->hide(); | 2077 | mEventViewerDialog->hide(); |
2078 | } | 2078 | } |
2079 | else | 2079 | else |
2080 | mCalendar->checkAlarmForIncidence( which , false ); | 2080 | mCalendar->checkAlarmForIncidence( which , false ); |
2081 | } | 2081 | } |
2082 | 2082 | ||
2083 | // most of the changeEventDisplays() right now just call the view's | 2083 | // most of the changeEventDisplays() right now just call the view's |
2084 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2084 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2085 | void CalendarView::changeEventDisplay(Event *which, int action) | 2085 | void CalendarView::changeEventDisplay(Event *which, int action) |
2086 | { | 2086 | { |
2087 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2087 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2088 | changeIncidenceDisplay((Incidence *)which, action); | 2088 | changeIncidenceDisplay((Incidence *)which, action); |
2089 | mDateNavigator->updateView(); | 2089 | mDateNavigator->updateView(); |
2090 | //mDialogManager->updateSearchDialog(); | 2090 | //mDialogManager->updateSearchDialog(); |
2091 | 2091 | ||
2092 | if (which) { | 2092 | if (which) { |
2093 | // If there is an event view visible update the display | 2093 | // If there is an event view visible update the display |
2094 | mViewManager->currentView()->changeEventDisplay(which,action); | 2094 | mViewManager->currentView()->changeEventDisplay(which,action); |
2095 | // TODO: check, if update needed | 2095 | // TODO: check, if update needed |
2096 | // if (which->getTodoStatus()) { | 2096 | // if (which->getTodoStatus()) { |
2097 | mTodoList->updateView(); | 2097 | mTodoList->updateView(); |
2098 | // } | 2098 | // } |
2099 | } else { | 2099 | } else { |
2100 | mViewManager->currentView()->updateView(); | 2100 | mViewManager->currentView()->updateView(); |
2101 | } | 2101 | } |
2102 | } | 2102 | } |
2103 | 2103 | ||
2104 | 2104 | ||
2105 | void CalendarView::updateTodoViews() | 2105 | void CalendarView::updateTodoViews() |
2106 | { | 2106 | { |
2107 | 2107 | ||
2108 | mTodoList->updateView(); | 2108 | mTodoList->updateView(); |
2109 | mViewManager->currentView()->updateView(); | 2109 | mViewManager->currentView()->updateView(); |
2110 | 2110 | ||
2111 | } | 2111 | } |
2112 | 2112 | ||
2113 | 2113 | ||
2114 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2114 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2115 | { | 2115 | { |
2116 | mTodoList->updateView(); | 2116 | mTodoList->updateView(); |
2117 | mViewManager->updateView(start, end); | 2117 | mViewManager->updateView(start, end); |
2118 | //mDateNavigator->updateView(); | 2118 | //mDateNavigator->updateView(); |
2119 | } | 2119 | } |
2120 | 2120 | ||
2121 | void CalendarView::updateView() | 2121 | void CalendarView::updateView() |
2122 | { | 2122 | { |
2123 | DateList tmpList = mNavigator->selectedDates(); | 2123 | DateList tmpList = mNavigator->selectedDates(); |
2124 | 2124 | ||
2125 | // We assume that the navigator only selects consecutive days. | 2125 | // We assume that the navigator only selects consecutive days. |
2126 | updateView( tmpList.first(), tmpList.last() ); | 2126 | updateView( tmpList.first(), tmpList.last() ); |
2127 | } | 2127 | } |
2128 | 2128 | ||
2129 | void CalendarView::updateUnmanagedViews() | 2129 | void CalendarView::updateUnmanagedViews() |
2130 | { | 2130 | { |
2131 | mDateNavigator->updateDayMatrix(); | 2131 | mDateNavigator->updateDayMatrix(); |
2132 | } | 2132 | } |
2133 | 2133 | ||
2134 | int CalendarView::msgItemDelete() | 2134 | int CalendarView::msgItemDelete() |
2135 | { | 2135 | { |
2136 | return KMessageBox::warningContinueCancel(this, | 2136 | return KMessageBox::warningContinueCancel(this, |
2137 | i18n("This item will be\npermanently deleted."), | 2137 | i18n("This item will be\npermanently deleted."), |
2138 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2138 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2139 | } | 2139 | } |
2140 | 2140 | ||
2141 | 2141 | ||
2142 | void CalendarView::edit_cut() | 2142 | void CalendarView::edit_cut() |
2143 | { | 2143 | { |
2144 | Event *anEvent=0; | 2144 | Event *anEvent=0; |
2145 | 2145 | ||
2146 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2146 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2147 | 2147 | ||
2148 | if (mViewManager->currentView()->isEventView()) { | 2148 | if (mViewManager->currentView()->isEventView()) { |
2149 | if ( incidence && incidence->type() == "Event" ) { | 2149 | if ( incidence && incidence->type() == "Event" ) { |
2150 | anEvent = static_cast<Event *>(incidence); | 2150 | anEvent = static_cast<Event *>(incidence); |
2151 | } | 2151 | } |
2152 | } | 2152 | } |
2153 | 2153 | ||
2154 | if (!anEvent) { | 2154 | if (!anEvent) { |
2155 | KNotifyClient::beep(); | 2155 | KNotifyClient::beep(); |
2156 | return; | 2156 | return; |
2157 | } | 2157 | } |
2158 | DndFactory factory( mCalendar ); | 2158 | DndFactory factory( mCalendar ); |
2159 | factory.cutEvent(anEvent); | 2159 | factory.cutEvent(anEvent); |
2160 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2160 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | void CalendarView::edit_copy() | 2163 | void CalendarView::edit_copy() |
2164 | { | 2164 | { |
2165 | Event *anEvent=0; | 2165 | Event *anEvent=0; |
2166 | 2166 | ||
2167 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2167 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2168 | 2168 | ||
2169 | if (mViewManager->currentView()->isEventView()) { | 2169 | if (mViewManager->currentView()->isEventView()) { |
2170 | if ( incidence && incidence->type() == "Event" ) { | 2170 | if ( incidence && incidence->type() == "Event" ) { |
2171 | anEvent = static_cast<Event *>(incidence); | 2171 | anEvent = static_cast<Event *>(incidence); |
2172 | } | 2172 | } |
2173 | } | 2173 | } |
2174 | 2174 | ||
2175 | if (!anEvent) { | 2175 | if (!anEvent) { |
2176 | KNotifyClient::beep(); | 2176 | KNotifyClient::beep(); |
2177 | return; | 2177 | return; |
2178 | } | 2178 | } |
2179 | DndFactory factory( mCalendar ); | 2179 | DndFactory factory( mCalendar ); |
2180 | factory.copyEvent(anEvent); | 2180 | factory.copyEvent(anEvent); |
2181 | } | 2181 | } |
2182 | 2182 | ||
2183 | void CalendarView::edit_paste() | 2183 | void CalendarView::edit_paste() |
2184 | { | 2184 | { |
2185 | QDate date = mNavigator->selectedDates().first(); | 2185 | QDate date = mNavigator->selectedDates().first(); |
2186 | 2186 | ||
2187 | DndFactory factory( mCalendar ); | 2187 | DndFactory factory( mCalendar ); |
2188 | Event *pastedEvent = factory.pasteEvent( date ); | 2188 | Event *pastedEvent = factory.pasteEvent( date ); |
2189 | 2189 | ||
2190 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2190 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | void CalendarView::edit_options() | 2193 | void CalendarView::edit_options() |
2194 | { | 2194 | { |
2195 | mDialogManager->showOptionsDialog(); | 2195 | mDialogManager->showOptionsDialog(); |
2196 | //writeSettings(); | 2196 | //writeSettings(); |
2197 | } | 2197 | } |
2198 | 2198 | ||
2199 | void CalendarView::slotSelectPickerDate( QDate d) | 2199 | void CalendarView::slotSelectPickerDate( QDate d) |
2200 | { | 2200 | { |
2201 | mDateFrame->hide(); | 2201 | mDateFrame->hide(); |
2202 | if ( mDatePickerMode == 1 ) { | 2202 | if ( mDatePickerMode == 1 ) { |
2203 | mNavigator->slotDaySelect( d ); | 2203 | mNavigator->slotDaySelect( d ); |
2204 | } else if ( mDatePickerMode == 2 ) { | 2204 | } else if ( mDatePickerMode == 2 ) { |
2205 | if ( mMoveIncidence->type() == "Todo" ) { | 2205 | if ( mMoveIncidence->type() == "Todo" ) { |
2206 | Todo * to = (Todo *) mMoveIncidence; | 2206 | Todo * to = (Todo *) mMoveIncidence; |
2207 | QTime tim; | 2207 | QTime tim; |
2208 | if ( to->hasDueDate() ) | 2208 | if ( to->hasDueDate() ) |
2209 | tim = to->dtDue().time(); | 2209 | tim = to->dtDue().time(); |
2210 | else { | 2210 | else { |
2211 | tim = QTime ( 0,0,0 ); | 2211 | tim = QTime ( 0,0,0 ); |
2212 | to->setFloats( true ); | 2212 | to->setFloats( true ); |
2213 | to->setHasDueDate( true ); | 2213 | to->setHasDueDate( true ); |
2214 | } | 2214 | } |
2215 | QDateTime dt ( d,tim ); | 2215 | QDateTime dt ( d,tim ); |
2216 | to->setDtDue( dt ); | 2216 | to->setDtDue( dt ); |
2217 | todoChanged( to ); | 2217 | todoChanged( to ); |
2218 | } else { | 2218 | } else { |
2219 | QTime tim = mMoveIncidence->dtStart().time(); | 2219 | QTime tim = mMoveIncidence->dtStart().time(); |
2220 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2220 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2221 | QDateTime dt ( d,tim ); | 2221 | QDateTime dt ( d,tim ); |
2222 | mMoveIncidence->setDtStart( dt ); | 2222 | mMoveIncidence->setDtStart( dt ); |
2223 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2223 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2224 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2224 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2225 | } | 2225 | } |
2226 | 2226 | ||
2227 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2227 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2228 | } | 2228 | } |
2229 | } | 2229 | } |
2230 | 2230 | ||
2231 | void CalendarView::removeCategories() | 2231 | void CalendarView::removeCategories() |
2232 | { | 2232 | { |
2233 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2233 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2234 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2234 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2235 | QStringList catIncList; | 2235 | QStringList catIncList; |
2236 | QStringList newCatList; | 2236 | QStringList newCatList; |
2237 | Incidence* inc = incList.first(); | 2237 | Incidence* inc = incList.first(); |
2238 | int i; | 2238 | int i; |
2239 | int count = 0; | 2239 | int count = 0; |
2240 | while ( inc ) { | 2240 | while ( inc ) { |
2241 | newCatList.clear(); | 2241 | newCatList.clear(); |
2242 | catIncList = inc->categories() ; | 2242 | catIncList = inc->categories() ; |
2243 | for( i = 0; i< catIncList.count(); ++i ) { | 2243 | for( i = 0; i< catIncList.count(); ++i ) { |
2244 | if ( catList.contains (catIncList[i])) | 2244 | if ( catList.contains (catIncList[i])) |
2245 | newCatList.append( catIncList[i] ); | 2245 | newCatList.append( catIncList[i] ); |
2246 | } | 2246 | } |
2247 | newCatList.sort(); | 2247 | newCatList.sort(); |
2248 | inc->setCategories( newCatList.join(",") ); | 2248 | inc->setCategories( newCatList.join(",") ); |
2249 | inc = incList.next(); | 2249 | inc = incList.next(); |
2250 | } | 2250 | } |
2251 | } | 2251 | } |
2252 | 2252 | ||
2253 | int CalendarView::addCategories() | 2253 | int CalendarView::addCategories() |
2254 | { | 2254 | { |
2255 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2255 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2256 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2256 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2257 | QStringList catIncList; | 2257 | QStringList catIncList; |
2258 | Incidence* inc = incList.first(); | 2258 | Incidence* inc = incList.first(); |
2259 | int i; | 2259 | int i; |
2260 | int count = 0; | 2260 | int count = 0; |
2261 | while ( inc ) { | 2261 | while ( inc ) { |
2262 | catIncList = inc->categories() ; | 2262 | catIncList = inc->categories() ; |
2263 | for( i = 0; i< catIncList.count(); ++i ) { | 2263 | for( i = 0; i< catIncList.count(); ++i ) { |
2264 | if ( !catList.contains (catIncList[i])) { | 2264 | if ( !catList.contains (catIncList[i])) { |
2265 | catList.append( catIncList[i] ); | 2265 | catList.append( catIncList[i] ); |
2266 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2266 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2267 | ++count; | 2267 | ++count; |
2268 | } | 2268 | } |
2269 | } | 2269 | } |
2270 | inc = incList.next(); | 2270 | inc = incList.next(); |
2271 | } | 2271 | } |
2272 | catList.sort(); | 2272 | catList.sort(); |
2273 | KOPrefs::instance()->mCustomCategories = catList; | 2273 | KOPrefs::instance()->mCustomCategories = catList; |
2274 | return count; | 2274 | return count; |
2275 | } | 2275 | } |
2276 | 2276 | ||
2277 | void CalendarView::manageCategories() | 2277 | void CalendarView::manageCategories() |
2278 | { | 2278 | { |
2279 | KOCatPrefs* cp = new KOCatPrefs(); | 2279 | KOCatPrefs* cp = new KOCatPrefs(); |
2280 | cp->show(); | 2280 | cp->show(); |
2281 | int w =cp->sizeHint().width() ; | 2281 | int w =cp->sizeHint().width() ; |
2282 | int h = cp->sizeHint().height() ; | 2282 | int h = cp->sizeHint().height() ; |
2283 | int dw = QApplication::desktop()->width(); | 2283 | int dw = QApplication::desktop()->width(); |
2284 | int dh = QApplication::desktop()->height(); | 2284 | int dh = QApplication::desktop()->height(); |
2285 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2285 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2286 | if ( !cp->exec() ) { | 2286 | if ( !cp->exec() ) { |
2287 | delete cp; | 2287 | delete cp; |
2288 | return; | 2288 | return; |
2289 | } | 2289 | } |
2290 | int count = 0; | 2290 | int count = 0; |
2291 | if ( cp->addCat() ) { | 2291 | if ( cp->addCat() ) { |
2292 | count = addCategories(); | 2292 | count = addCategories(); |
2293 | if ( count ) { | 2293 | if ( count ) { |
2294 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2294 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2295 | writeSettings(); | 2295 | writeSettings(); |
2296 | } | 2296 | } |
2297 | } else { | 2297 | } else { |
2298 | removeCategories(); | 2298 | removeCategories(); |
2299 | updateView(); | 2299 | updateView(); |
2300 | } | 2300 | } |
2301 | delete cp; | 2301 | delete cp; |
2302 | } | 2302 | } |
2303 | 2303 | ||
2304 | void CalendarView::beamIncidence(Incidence * Inc) | 2304 | void CalendarView::beamIncidence(Incidence * Inc) |
2305 | { | 2305 | { |
2306 | QPtrList<Incidence> delSel ; | 2306 | QPtrList<Incidence> delSel ; |
2307 | delSel.append(Inc); | 2307 | delSel.append(Inc); |
2308 | beamIncidenceList( delSel ); | 2308 | beamIncidenceList( delSel ); |
2309 | } | 2309 | } |
2310 | void CalendarView::beamCalendar() | 2310 | void CalendarView::beamCalendar() |
2311 | { | 2311 | { |
2312 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2312 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2313 | //qDebug("beamCalendar() "); | 2313 | //qDebug("beamCalendar() "); |
2314 | beamIncidenceList( delSel ); | 2314 | beamIncidenceList( delSel ); |
2315 | } | 2315 | } |
2316 | void CalendarView::beamFilteredCalendar() | 2316 | void CalendarView::beamFilteredCalendar() |
2317 | { | 2317 | { |
2318 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2318 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2319 | //qDebug("beamFilteredCalendar() "); | 2319 | //qDebug("beamFilteredCalendar() "); |
2320 | beamIncidenceList( delSel ); | 2320 | beamIncidenceList( delSel ); |
2321 | } | 2321 | } |
2322 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2322 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2323 | { | 2323 | { |
2324 | if ( beamDialog->exec () == QDialog::Rejected ) | 2324 | if ( beamDialog->exec () == QDialog::Rejected ) |
2325 | return; | 2325 | return; |
2326 | #ifdef DESKTOP_VERSION | 2326 | #ifdef DESKTOP_VERSION |
2327 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2327 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2328 | #else | 2328 | #else |
2329 | QString fn = "/tmp/kopibeamfile"; | 2329 | QString fn = "/tmp/kopibeamfile"; |
2330 | #endif | 2330 | #endif |
2331 | QString mes; | 2331 | QString mes; |
2332 | bool createbup = true; | 2332 | bool createbup = true; |
2333 | if ( createbup ) { | 2333 | if ( createbup ) { |
2334 | QString description = "\n"; | 2334 | QString description = "\n"; |
2335 | CalendarLocal* cal = new CalendarLocal(); | 2335 | CalendarLocal* cal = new CalendarLocal(); |
2336 | if ( beamDialog->beamLocal() ) | 2336 | if ( beamDialog->beamLocal() ) |
2337 | cal->setLocalTime(); | 2337 | cal->setLocalTime(); |
2338 | else | 2338 | else |
2339 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2339 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2340 | Incidence *incidence = delSel.first(); | 2340 | Incidence *incidence = delSel.first(); |
2341 | bool addText = false; | 2341 | bool addText = false; |
2342 | if ( delSel.count() < 10 ) | 2342 | if ( delSel.count() < 10 ) |
2343 | addText = true; | 2343 | addText = true; |
2344 | else { | 2344 | else { |
2345 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2345 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2346 | } | 2346 | } |
2347 | while ( incidence ) { | 2347 | while ( incidence ) { |
2348 | Incidence *in = incidence->clone(); | 2348 | Incidence *in = incidence->clone(); |
2349 | if ( ! in->summary().isEmpty() ) { | 2349 | if ( ! in->summary().isEmpty() ) { |
2350 | in->setDescription(""); | 2350 | in->setDescription(""); |
2351 | } else { | 2351 | } else { |
2352 | in->setSummary( in->description().left(20)); | 2352 | in->setSummary( in->description().left(20)); |
2353 | in->setDescription(""); | 2353 | in->setDescription(""); |
2354 | } | 2354 | } |
2355 | if ( addText ) | 2355 | if ( addText ) |
2356 | description += in->summary() + "\n"; | 2356 | description += in->summary() + "\n"; |
2357 | cal->addIncidence( in ); | 2357 | cal->addIncidence( in ); |
2358 | incidence = delSel.next(); | 2358 | incidence = delSel.next(); |
2359 | } | 2359 | } |
2360 | if ( beamDialog->beamVcal() ) { | 2360 | if ( beamDialog->beamVcal() ) { |
2361 | fn += ".vcs"; | 2361 | fn += ".vcs"; |
2362 | FileStorage storage( cal, fn, new VCalFormat ); | 2362 | FileStorage storage( cal, fn, new VCalFormat ); |
2363 | storage.save(); | 2363 | storage.save(); |
2364 | } else { | 2364 | } else { |
2365 | fn += ".ics"; | 2365 | fn += ".ics"; |
2366 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2366 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2367 | storage.save(); | 2367 | storage.save(); |
2368 | } | 2368 | } |
2369 | delete cal; | 2369 | delete cal; |
2370 | mes = i18n("KO/Pi: Ready for beaming"); | 2370 | mes = i18n("KO/Pi: Ready for beaming"); |
2371 | topLevelWidget()->setCaption(mes); | 2371 | topLevelWidget()->setCaption(mes); |
2372 | KApplication::convert2latin1( fn ); | 2372 | KApplication::convert2latin1( fn ); |
2373 | #ifndef DESKTOP_VERSION | 2373 | #ifndef DESKTOP_VERSION |
2374 | Ir *ir = new Ir( this ); | 2374 | Ir *ir = new Ir( this ); |
2375 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2375 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2376 | ir->send( fn, description, "text/x-vCalendar" ); | 2376 | ir->send( fn, description, "text/x-vCalendar" ); |
2377 | #endif | 2377 | #endif |
2378 | } | 2378 | } |
2379 | } | 2379 | } |
2380 | void CalendarView::beamDone( Ir *ir ) | 2380 | void CalendarView::beamDone( Ir *ir ) |
2381 | { | 2381 | { |
2382 | #ifndef DESKTOP_VERSION | 2382 | #ifndef DESKTOP_VERSION |
2383 | delete ir; | 2383 | delete ir; |
2384 | #endif | 2384 | #endif |
2385 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2385 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2386 | topLevelWidget()->raise(); | 2386 | topLevelWidget()->raise(); |
2387 | } | 2387 | } |
2388 | 2388 | ||
2389 | void CalendarView::moveIncidence(Incidence * inc ) | 2389 | void CalendarView::moveIncidence(Incidence * inc ) |
2390 | { | 2390 | { |
2391 | if ( !inc ) return; | 2391 | if ( !inc ) return; |
2392 | // qDebug("showDatePickerForIncidence( ) "); | 2392 | // qDebug("showDatePickerForIncidence( ) "); |
2393 | if ( mDateFrame->isVisible() ) | 2393 | if ( mDateFrame->isVisible() ) |
2394 | mDateFrame->hide(); | 2394 | mDateFrame->hide(); |
2395 | else { | 2395 | else { |
2396 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2396 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2397 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2397 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2398 | int dw = QApplication::desktop()->width(); | 2398 | int dw = QApplication::desktop()->width(); |
2399 | int dh = QApplication::desktop()->height(); | 2399 | int dh = QApplication::desktop()->height(); |
2400 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2400 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2401 | mDateFrame->show(); | 2401 | mDateFrame->show(); |
2402 | } | 2402 | } |
2403 | mDatePickerMode = 2; | 2403 | mDatePickerMode = 2; |
2404 | mMoveIncidence = inc ; | 2404 | mMoveIncidence = inc ; |
2405 | QDate da; | 2405 | QDate da; |
2406 | if ( mMoveIncidence->type() == "Todo" ) { | 2406 | if ( mMoveIncidence->type() == "Todo" ) { |
2407 | Todo * to = (Todo *) mMoveIncidence; | 2407 | Todo * to = (Todo *) mMoveIncidence; |
2408 | if ( to->hasDueDate() ) | 2408 | if ( to->hasDueDate() ) |
2409 | da = to->dtDue().date(); | 2409 | da = to->dtDue().date(); |
2410 | else | 2410 | else |
2411 | da = QDate::currentDate(); | 2411 | da = QDate::currentDate(); |
2412 | } else { | 2412 | } else { |
2413 | da = mMoveIncidence->dtStart().date(); | 2413 | da = mMoveIncidence->dtStart().date(); |
2414 | } | 2414 | } |
2415 | mDatePicker->setDate( da ); | 2415 | mDatePicker->setDate( da ); |
2416 | } | 2416 | } |
2417 | void CalendarView::showDatePicker( ) | 2417 | void CalendarView::showDatePicker( ) |
2418 | { | 2418 | { |
2419 | //qDebug("CalendarView::showDatePicker( ) "); | 2419 | //qDebug("CalendarView::showDatePicker( ) "); |
2420 | if ( mDateFrame->isVisible() ) | 2420 | if ( mDateFrame->isVisible() ) |
2421 | mDateFrame->hide(); | 2421 | mDateFrame->hide(); |
2422 | else { | 2422 | else { |
2423 | int w =mDatePicker->sizeHint().width() ; | 2423 | int w =mDatePicker->sizeHint().width() ; |
2424 | int h = mDatePicker->sizeHint().height() ; | 2424 | int h = mDatePicker->sizeHint().height() ; |
2425 | int dw = QApplication::desktop()->width(); | 2425 | int dw = QApplication::desktop()->width(); |
2426 | int dh = QApplication::desktop()->height(); | 2426 | int dh = QApplication::desktop()->height(); |
2427 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2427 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2428 | mDateFrame->show(); | 2428 | mDateFrame->show(); |
2429 | } | 2429 | } |
2430 | mDatePickerMode = 1; | 2430 | mDatePickerMode = 1; |
2431 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2431 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2432 | } | 2432 | } |
2433 | 2433 | ||
2434 | void CalendarView::showEventEditor() | 2434 | void CalendarView::showEventEditor() |
2435 | { | 2435 | { |
2436 | #ifdef DESKTOP_VERSION | 2436 | #ifdef DESKTOP_VERSION |
2437 | mEventEditor->show(); | 2437 | mEventEditor->show(); |
2438 | #else | 2438 | #else |
2439 | mEventEditor->showMaximized(); | 2439 | mEventEditor->showMaximized(); |
2440 | #endif | 2440 | #endif |
2441 | } | 2441 | } |
2442 | void CalendarView::showTodoEditor() | 2442 | void CalendarView::showTodoEditor() |
2443 | { | 2443 | { |
2444 | #ifdef DESKTOP_VERSION | 2444 | #ifdef DESKTOP_VERSION |
2445 | mTodoEditor->show(); | 2445 | mTodoEditor->show(); |
2446 | #else | 2446 | #else |
2447 | mTodoEditor->showMaximized(); | 2447 | mTodoEditor->showMaximized(); |
2448 | #endif | 2448 | #endif |
2449 | } | 2449 | } |
2450 | 2450 | ||
2451 | void CalendarView::cloneIncidence() | 2451 | void CalendarView::cloneIncidence() |
2452 | { | 2452 | { |
2453 | Incidence *incidence = currentSelection(); | 2453 | Incidence *incidence = currentSelection(); |
2454 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2454 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2455 | if ( incidence ) { | 2455 | if ( incidence ) { |
2456 | cloneIncidence(incidence); | 2456 | cloneIncidence(incidence); |
2457 | } | 2457 | } |
2458 | } | 2458 | } |
2459 | void CalendarView::moveIncidence() | 2459 | void CalendarView::moveIncidence() |
2460 | { | 2460 | { |
2461 | Incidence *incidence = currentSelection(); | 2461 | Incidence *incidence = currentSelection(); |
2462 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2462 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2463 | if ( incidence ) { | 2463 | if ( incidence ) { |
2464 | moveIncidence(incidence); | 2464 | moveIncidence(incidence); |
2465 | } | 2465 | } |
2466 | } | 2466 | } |
2467 | void CalendarView::beamIncidence() | 2467 | void CalendarView::beamIncidence() |
2468 | { | 2468 | { |
2469 | Incidence *incidence = currentSelection(); | 2469 | Incidence *incidence = currentSelection(); |
2470 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2470 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2471 | if ( incidence ) { | 2471 | if ( incidence ) { |
2472 | beamIncidence(incidence); | 2472 | beamIncidence(incidence); |
2473 | } | 2473 | } |
2474 | } | 2474 | } |
2475 | void CalendarView::toggleCancelIncidence() | 2475 | void CalendarView::toggleCancelIncidence() |
2476 | { | 2476 | { |
2477 | Incidence *incidence = currentSelection(); | 2477 | Incidence *incidence = currentSelection(); |
2478 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2478 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2479 | if ( incidence ) { | 2479 | if ( incidence ) { |
2480 | cancelIncidence(incidence); | 2480 | cancelIncidence(incidence); |
2481 | } | 2481 | } |
2482 | } | 2482 | } |
2483 | 2483 | ||
2484 | 2484 | ||
2485 | void CalendarView::cancelIncidence(Incidence * inc ) | 2485 | void CalendarView::cancelIncidence(Incidence * inc ) |
2486 | { | 2486 | { |
2487 | inc->setCancelled( ! inc->cancelled() ); | 2487 | inc->setCancelled( ! inc->cancelled() ); |
2488 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2488 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2489 | updateView(); | 2489 | updateView(); |
2490 | } | 2490 | } |
2491 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2491 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2492 | { | 2492 | { |
2493 | Incidence * newInc = orgInc->clone(); | 2493 | Incidence * newInc = orgInc->clone(); |
2494 | newInc->recreate(); | 2494 | newInc->recreate(); |
2495 | 2495 | ||
2496 | if ( newInc->type() == "Todo" ) { | 2496 | if ( newInc->type() == "Todo" ) { |
2497 | Todo* t = (Todo*) newInc; | 2497 | Todo* t = (Todo*) newInc; |
2498 | mTodoEditor->editTodo( t ); | 2498 | mTodoEditor->editTodo( t ); |
2499 | showTodoEditor(); | 2499 | showTodoEditor(); |
2500 | if ( mTodoEditor->exec() ) { | 2500 | if ( mTodoEditor->exec() ) { |
2501 | mCalendar->addTodo( t ); | 2501 | mCalendar->addTodo( t ); |
2502 | updateView(); | 2502 | updateView(); |
2503 | } else { | 2503 | } else { |
2504 | delete t; | 2504 | delete t; |
2505 | } | 2505 | } |
2506 | } | 2506 | } |
2507 | else { | 2507 | else { |
2508 | Event* e = (Event*) newInc; | 2508 | Event* e = (Event*) newInc; |
2509 | mEventEditor->editEvent( e ); | 2509 | mEventEditor->editEvent( e ); |
2510 | showEventEditor(); | 2510 | showEventEditor(); |
2511 | if ( mEventEditor->exec() ) { | 2511 | if ( mEventEditor->exec() ) { |
2512 | mCalendar->addEvent( e ); | 2512 | mCalendar->addEvent( e ); |
2513 | updateView(); | 2513 | updateView(); |
2514 | } else { | 2514 | } else { |
2515 | delete e; | 2515 | delete e; |
2516 | } | 2516 | } |
2517 | } | 2517 | } |
2518 | } | 2518 | } |
2519 | 2519 | ||
2520 | void CalendarView::newEvent() | 2520 | void CalendarView::newEvent() |
2521 | { | 2521 | { |
2522 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2522 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2523 | KOAgendaView *aView = mViewManager->agendaView(); | 2523 | KOAgendaView *aView = mViewManager->agendaView(); |
2524 | if (aView) { | 2524 | if (aView) { |
2525 | if (aView->selectionStart().isValid()) { | 2525 | if (aView->selectionStart().isValid()) { |
2526 | if (aView->selectedIsAllDay()) { | 2526 | if (aView->selectedIsAllDay()) { |
2527 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2527 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2528 | } else { | 2528 | } else { |
2529 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2529 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2530 | } | 2530 | } |
2531 | return; | 2531 | return; |
2532 | } | 2532 | } |
2533 | } | 2533 | } |
2534 | 2534 | ||
2535 | QDate date = mNavigator->selectedDates().first(); | 2535 | QDate date = mNavigator->selectedDates().first(); |
2536 | QDateTime current = QDateTime::currentDateTime(); | 2536 | QDateTime current = QDateTime::currentDateTime(); |
2537 | if ( date <= current.date() ) { | 2537 | if ( date <= current.date() ) { |
2538 | int hour = current.time().hour() +1; | 2538 | int hour = current.time().hour() +1; |
2539 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2539 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2540 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2540 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2541 | } else | 2541 | } else |
2542 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2542 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2543 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2543 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2544 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2544 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | void CalendarView::newEvent(QDateTime fh) | 2547 | void CalendarView::newEvent(QDateTime fh) |
2548 | { | 2548 | { |
2549 | newEvent(fh, | 2549 | newEvent(fh, |
2550 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2550 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2551 | } | 2551 | } |
2552 | 2552 | ||
2553 | void CalendarView::newEvent(QDate dt) | 2553 | void CalendarView::newEvent(QDate dt) |
2554 | { | 2554 | { |
2555 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2555 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2556 | QDateTime(dt, QTime(0,0,0)), true); | 2556 | QDateTime(dt, QTime(0,0,0)), true); |
2557 | } | 2557 | } |
2558 | 2558 | ||
2559 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2559 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2560 | { | 2560 | { |
2561 | 2561 | ||
2562 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2562 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2563 | if ( mFilterView->filtersEnabled() ) { | 2563 | if ( mFilterView->filtersEnabled() ) { |
2564 | CalFilter *filter = mFilterView->selectedFilter(); | 2564 | CalFilter *filter = mFilterView->selectedFilter(); |
2565 | if (filter && filter->showCategories()) { | 2565 | if (filter && filter->showCategories()) { |
2566 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2566 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2567 | } | 2567 | } |
2568 | if ( filter ) | 2568 | if ( filter ) |
2569 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2569 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2570 | } | 2570 | } |
2571 | showEventEditor(); | 2571 | showEventEditor(); |
2572 | } | 2572 | } |
2573 | void CalendarView::todoAdded(Todo * t) | 2573 | void CalendarView::todoAdded(Todo * t) |
2574 | { | 2574 | { |
2575 | 2575 | ||
2576 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2576 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2577 | updateTodoViews(); | 2577 | updateTodoViews(); |
2578 | } | 2578 | } |
2579 | void CalendarView::todoChanged(Todo * t) | 2579 | void CalendarView::todoChanged(Todo * t) |
2580 | { | 2580 | { |
2581 | emit todoModified( t, 4 ); | 2581 | emit todoModified( t, 4 ); |
2582 | // updateTodoViews(); | 2582 | // updateTodoViews(); |
2583 | } | 2583 | } |
2584 | void CalendarView::todoToBeDeleted(Todo *) | 2584 | void CalendarView::todoToBeDeleted(Todo *) |
2585 | { | 2585 | { |
2586 | //qDebug("todoToBeDeleted(Todo *) "); | 2586 | //qDebug("todoToBeDeleted(Todo *) "); |
2587 | updateTodoViews(); | 2587 | updateTodoViews(); |
2588 | } | 2588 | } |
2589 | void CalendarView::todoDeleted() | 2589 | void CalendarView::todoDeleted() |
2590 | { | 2590 | { |
2591 | //qDebug(" todoDeleted()"); | 2591 | //qDebug(" todoDeleted()"); |
2592 | updateTodoViews(); | 2592 | updateTodoViews(); |
2593 | } | 2593 | } |
2594 | 2594 | ||
2595 | 2595 | ||
2596 | 2596 | ||
2597 | void CalendarView::newTodo() | 2597 | void CalendarView::newTodo() |
2598 | { | 2598 | { |
2599 | 2599 | ||
2600 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2600 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2601 | if ( mFilterView->filtersEnabled() ) { | 2601 | if ( mFilterView->filtersEnabled() ) { |
2602 | CalFilter *filter = mFilterView->selectedFilter(); | 2602 | CalFilter *filter = mFilterView->selectedFilter(); |
2603 | if (filter && filter->showCategories()) { | 2603 | if (filter && filter->showCategories()) { |
2604 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2604 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2605 | } | 2605 | } |
2606 | if ( filter ) | 2606 | if ( filter ) |
2607 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2607 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2608 | } | 2608 | } |
2609 | showTodoEditor(); | 2609 | showTodoEditor(); |
2610 | } | 2610 | } |
2611 | 2611 | ||
2612 | void CalendarView::newSubTodo() | 2612 | void CalendarView::newSubTodo() |
2613 | { | 2613 | { |
2614 | Todo *todo = selectedTodo(); | 2614 | Todo *todo = selectedTodo(); |
2615 | if ( todo ) newSubTodo( todo ); | 2615 | if ( todo ) newSubTodo( todo ); |
2616 | } | 2616 | } |
2617 | 2617 | ||
2618 | void CalendarView::newSubTodo(Todo *parentEvent) | 2618 | void CalendarView::newSubTodo(Todo *parentEvent) |
2619 | { | 2619 | { |
2620 | 2620 | ||
2621 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2621 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2622 | showTodoEditor(); | 2622 | showTodoEditor(); |
2623 | } | 2623 | } |
2624 | 2624 | ||
2625 | void CalendarView::newFloatingEvent() | 2625 | void CalendarView::newFloatingEvent() |
2626 | { | 2626 | { |
2627 | DateList tmpList = mNavigator->selectedDates(); | 2627 | DateList tmpList = mNavigator->selectedDates(); |
2628 | QDate date = tmpList.first(); | 2628 | QDate date = tmpList.first(); |
2629 | 2629 | ||
2630 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2630 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2631 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2631 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2632 | } | 2632 | } |
2633 | 2633 | ||
2634 | 2634 | ||
2635 | void CalendarView::editEvent( Event *event ) | 2635 | void CalendarView::editEvent( Event *event ) |
2636 | { | 2636 | { |
2637 | 2637 | ||
2638 | if ( !event ) return; | 2638 | if ( !event ) return; |
2639 | if ( event->isReadOnly() ) { | 2639 | if ( event->isReadOnly() ) { |
2640 | showEvent( event ); | 2640 | showEvent( event ); |
2641 | return; | 2641 | return; |
2642 | } | 2642 | } |
2643 | mEventEditor->editEvent( event , mFlagEditDescription); | 2643 | mEventEditor->editEvent( event , mFlagEditDescription); |
2644 | showEventEditor(); | 2644 | showEventEditor(); |
2645 | } | 2645 | } |
2646 | void CalendarView::editJournal( Journal *jour ) | 2646 | void CalendarView::editJournal( Journal *jour ) |
2647 | { | 2647 | { |
2648 | if ( !jour ) return; | 2648 | if ( !jour ) return; |
2649 | mDialogManager->hideSearchDialog(); | 2649 | mDialogManager->hideSearchDialog(); |
2650 | mViewManager->showJournalView(); | 2650 | mViewManager->showJournalView(); |
2651 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2651 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2652 | } | 2652 | } |
2653 | void CalendarView::editTodo( Todo *todo ) | 2653 | void CalendarView::editTodo( Todo *todo ) |
2654 | { | 2654 | { |
2655 | if ( !todo ) return; | 2655 | if ( !todo ) return; |
2656 | 2656 | ||
2657 | if ( todo->isReadOnly() ) { | 2657 | if ( todo->isReadOnly() ) { |
2658 | showTodo( todo ); | 2658 | showTodo( todo ); |
2659 | return; | 2659 | return; |
2660 | } | 2660 | } |
2661 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2661 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2662 | showTodoEditor(); | 2662 | showTodoEditor(); |
2663 | 2663 | ||
2664 | } | 2664 | } |
2665 | 2665 | ||
2666 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2666 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2667 | { | 2667 | { |
2668 | if ( !mEventViewerDialog ) { | 2668 | if ( !mEventViewerDialog ) { |
2669 | mEventViewerDialog = new KOEventViewerDialog(this); | 2669 | mEventViewerDialog = new KOEventViewerDialog(this); |
2670 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2670 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2671 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2671 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2672 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2672 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2673 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2673 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2674 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2674 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2675 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2675 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2676 | mEventViewerDialog->resize( 640, 480 ); | 2676 | mEventViewerDialog->resize( 640, 480 ); |
2677 | 2677 | ||
2678 | } | 2678 | } |
2679 | return mEventViewerDialog; | 2679 | return mEventViewerDialog; |
2680 | } | 2680 | } |
2681 | void CalendarView::showEvent(Event *event) | 2681 | void CalendarView::showEvent(Event *event) |
2682 | { | 2682 | { |
2683 | getEventViewerDialog()->setEvent(event); | 2683 | getEventViewerDialog()->setEvent(event); |
2684 | getEventViewerDialog()->showMe(); | 2684 | getEventViewerDialog()->showMe(); |
2685 | } | 2685 | } |
2686 | 2686 | ||
2687 | void CalendarView::showTodo(Todo *event) | 2687 | void CalendarView::showTodo(Todo *event) |
2688 | { | 2688 | { |
2689 | getEventViewerDialog()->setTodo(event); | 2689 | getEventViewerDialog()->setTodo(event); |
2690 | getEventViewerDialog()->showMe(); | 2690 | getEventViewerDialog()->showMe(); |
2691 | } | 2691 | } |
2692 | void CalendarView::showJournal( Journal *jour ) | 2692 | void CalendarView::showJournal( Journal *jour ) |
2693 | { | 2693 | { |
2694 | getEventViewerDialog()->setJournal(jour); | 2694 | getEventViewerDialog()->setJournal(jour); |
2695 | getEventViewerDialog()->showMe(); | 2695 | getEventViewerDialog()->showMe(); |
2696 | 2696 | ||
2697 | } | 2697 | } |
2698 | // void CalendarView::todoModified (Todo *event, int changed) | 2698 | // void CalendarView::todoModified (Todo *event, int changed) |
2699 | // { | 2699 | // { |
2700 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2700 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2701 | // // kdDebug() << "Todo modified and open" << endl; | 2701 | // // kdDebug() << "Todo modified and open" << endl; |
2702 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2702 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2703 | // // temp->modified (changed); | 2703 | // // temp->modified (changed); |
2704 | 2704 | ||
2705 | // // } | 2705 | // // } |
2706 | 2706 | ||
2707 | // mViewManager->updateView(); | 2707 | // mViewManager->updateView(); |
2708 | // } | 2708 | // } |
2709 | 2709 | ||
2710 | void CalendarView::appointment_show() | 2710 | void CalendarView::appointment_show() |
2711 | { | 2711 | { |
2712 | Event *anEvent = 0; | 2712 | Event *anEvent = 0; |
2713 | 2713 | ||
2714 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2714 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2715 | 2715 | ||
2716 | if (mViewManager->currentView()->isEventView()) { | 2716 | if (mViewManager->currentView()->isEventView()) { |
2717 | if ( incidence && incidence->type() == "Event" ) { | 2717 | if ( incidence && incidence->type() == "Event" ) { |
2718 | anEvent = static_cast<Event *>(incidence); | 2718 | anEvent = static_cast<Event *>(incidence); |
2719 | } | 2719 | } |
2720 | } | 2720 | } |
2721 | 2721 | ||
2722 | if (!anEvent) { | 2722 | if (!anEvent) { |
2723 | KNotifyClient::beep(); | 2723 | KNotifyClient::beep(); |
2724 | return; | 2724 | return; |
2725 | } | 2725 | } |
2726 | 2726 | ||
2727 | showEvent(anEvent); | 2727 | showEvent(anEvent); |
2728 | } | 2728 | } |
2729 | 2729 | ||
2730 | void CalendarView::appointment_edit() | 2730 | void CalendarView::appointment_edit() |
2731 | { | 2731 | { |
2732 | Event *anEvent = 0; | 2732 | Event *anEvent = 0; |
2733 | 2733 | ||
2734 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2734 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2735 | 2735 | ||
2736 | if (mViewManager->currentView()->isEventView()) { | 2736 | if (mViewManager->currentView()->isEventView()) { |
2737 | if ( incidence && incidence->type() == "Event" ) { | 2737 | if ( incidence && incidence->type() == "Event" ) { |
2738 | anEvent = static_cast<Event *>(incidence); | 2738 | anEvent = static_cast<Event *>(incidence); |
2739 | } | 2739 | } |
2740 | } | 2740 | } |
2741 | 2741 | ||
2742 | if (!anEvent) { | 2742 | if (!anEvent) { |
2743 | KNotifyClient::beep(); | 2743 | KNotifyClient::beep(); |
2744 | return; | 2744 | return; |
2745 | } | 2745 | } |
2746 | 2746 | ||
2747 | editEvent(anEvent); | 2747 | editEvent(anEvent); |
2748 | } | 2748 | } |
2749 | 2749 | ||
2750 | void CalendarView::appointment_delete() | 2750 | void CalendarView::appointment_delete() |
2751 | { | 2751 | { |
2752 | Event *anEvent = 0; | 2752 | Event *anEvent = 0; |
2753 | 2753 | ||
2754 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2754 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2755 | 2755 | ||
2756 | if (mViewManager->currentView()->isEventView()) { | 2756 | if (mViewManager->currentView()->isEventView()) { |
2757 | if ( incidence && incidence->type() == "Event" ) { | 2757 | if ( incidence && incidence->type() == "Event" ) { |
2758 | anEvent = static_cast<Event *>(incidence); | 2758 | anEvent = static_cast<Event *>(incidence); |
2759 | } | 2759 | } |
2760 | } | 2760 | } |
2761 | 2761 | ||
2762 | if (!anEvent) { | 2762 | if (!anEvent) { |
2763 | KNotifyClient::beep(); | 2763 | KNotifyClient::beep(); |
2764 | return; | 2764 | return; |
2765 | } | 2765 | } |
2766 | 2766 | ||
2767 | deleteEvent(anEvent); | 2767 | deleteEvent(anEvent); |
2768 | } | 2768 | } |
2769 | 2769 | ||
2770 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2770 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2771 | { | 2771 | { |
2772 | if (!sub) return; | 2772 | if (!sub) return; |
2773 | if (!parent) return; | 2773 | if (!parent) return; |
2774 | if ( sub->relatedTo() ) | 2774 | if ( sub->relatedTo() ) |
2775 | sub->relatedTo()->removeRelation(sub); | 2775 | sub->relatedTo()->removeRelation(sub); |
2776 | sub->setRelatedTo(parent); | 2776 | sub->setRelatedTo(parent); |
2777 | sub->setRelatedToUid(parent->uid()); | 2777 | sub->setRelatedToUid(parent->uid()); |
2778 | parent->addRelation(sub); | 2778 | parent->addRelation(sub); |
2779 | sub->updated(); | 2779 | sub->updated(); |
2780 | parent->updated(); | 2780 | parent->updated(); |
2781 | setModified(true); | 2781 | setModified(true); |
2782 | updateView(); | 2782 | updateView(); |
2783 | } | 2783 | } |
2784 | void CalendarView::todo_unsub(Todo *anTodo ) | 2784 | void CalendarView::todo_unsub(Todo *anTodo ) |
2785 | { | 2785 | { |
2786 | // Todo *anTodo = selectedTodo(); | 2786 | // Todo *anTodo = selectedTodo(); |
2787 | if (!anTodo) return; | 2787 | if (!anTodo) return; |
2788 | if (!anTodo->relatedTo()) return; | 2788 | if (!anTodo->relatedTo()) return; |
2789 | anTodo->relatedTo()->removeRelation(anTodo); | 2789 | anTodo->relatedTo()->removeRelation(anTodo); |
2790 | anTodo->setRelatedTo(0); | 2790 | anTodo->setRelatedTo(0); |
2791 | anTodo->updated(); | 2791 | anTodo->updated(); |
2792 | anTodo->setRelatedToUid(""); | 2792 | anTodo->setRelatedToUid(""); |
2793 | setModified(true); | 2793 | setModified(true); |
2794 | updateView(); | 2794 | updateView(); |
2795 | } | 2795 | } |
2796 | 2796 | ||
2797 | void CalendarView::deleteTodo(Todo *todo) | 2797 | void CalendarView::deleteTodo(Todo *todo) |
2798 | { | 2798 | { |
2799 | if (!todo) { | 2799 | if (!todo) { |
2800 | KNotifyClient::beep(); | 2800 | KNotifyClient::beep(); |
2801 | return; | 2801 | return; |
2802 | } | 2802 | } |
2803 | if (KOPrefs::instance()->mConfirm) { | 2803 | if (KOPrefs::instance()->mConfirm) { |
2804 | switch (msgItemDelete()) { | 2804 | switch (msgItemDelete()) { |
2805 | case KMessageBox::Continue: // OK | 2805 | case KMessageBox::Continue: // OK |
2806 | if (!todo->relations().isEmpty()) { | 2806 | if (!todo->relations().isEmpty()) { |
2807 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2807 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2808 | i18n("Delete To-Do")); | 2808 | i18n("Delete To-Do")); |
2809 | } else { | 2809 | } else { |
2810 | checkExternalId( todo ); | 2810 | checkExternalId( todo ); |
2811 | calendar()->deleteTodo(todo); | 2811 | calendar()->deleteTodo(todo); |
2812 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2812 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2813 | updateView(); | 2813 | updateView(); |
2814 | } | 2814 | } |
2815 | break; | 2815 | break; |
2816 | } // switch | 2816 | } // switch |
2817 | } else { | 2817 | } else { |
2818 | if (!todo->relations().isEmpty()) { | 2818 | if (!todo->relations().isEmpty()) { |
2819 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2819 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2820 | i18n("Delete To-Do")); | 2820 | i18n("Delete To-Do")); |
2821 | } else { | 2821 | } else { |
2822 | checkExternalId( todo ); | 2822 | checkExternalId( todo ); |
2823 | mCalendar->deleteTodo(todo); | 2823 | mCalendar->deleteTodo(todo); |
2824 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2824 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2825 | updateView(); | 2825 | updateView(); |
2826 | } | 2826 | } |
2827 | } | 2827 | } |
2828 | emit updateSearchDialog(); | 2828 | emit updateSearchDialog(); |
2829 | } | 2829 | } |
2830 | void CalendarView::deleteJournal(Journal *jour) | 2830 | void CalendarView::deleteJournal(Journal *jour) |
2831 | { | 2831 | { |
2832 | if (!jour) { | 2832 | if (!jour) { |
2833 | KNotifyClient::beep(); | 2833 | KNotifyClient::beep(); |
2834 | return; | 2834 | return; |
2835 | } | 2835 | } |
2836 | if (KOPrefs::instance()->mConfirm) { | 2836 | if (KOPrefs::instance()->mConfirm) { |
2837 | switch (msgItemDelete()) { | 2837 | switch (msgItemDelete()) { |
2838 | case KMessageBox::Continue: // OK | 2838 | case KMessageBox::Continue: // OK |
2839 | calendar()->deleteJournal(jour); | 2839 | calendar()->deleteJournal(jour); |
2840 | updateView(); | 2840 | updateView(); |
2841 | break; | 2841 | break; |
2842 | } // switch | 2842 | } // switch |
2843 | } else { | 2843 | } else { |
2844 | calendar()->deleteJournal(jour);; | 2844 | calendar()->deleteJournal(jour);; |
2845 | updateView(); | 2845 | updateView(); |
2846 | } | 2846 | } |
2847 | emit updateSearchDialog(); | 2847 | emit updateSearchDialog(); |
2848 | } | 2848 | } |
2849 | 2849 | ||
2850 | void CalendarView::deleteEvent(Event *anEvent) | 2850 | void CalendarView::deleteEvent(Event *anEvent) |
2851 | { | 2851 | { |
2852 | if (!anEvent) { | 2852 | if (!anEvent) { |
2853 | KNotifyClient::beep(); | 2853 | KNotifyClient::beep(); |
2854 | return; | 2854 | return; |
2855 | } | 2855 | } |
2856 | 2856 | ||
2857 | if (anEvent->recurrence()->doesRecur()) { | 2857 | if (anEvent->recurrence()->doesRecur()) { |
2858 | QDate itemDate = mViewManager->currentSelectionDate(); | 2858 | QDate itemDate = mViewManager->currentSelectionDate(); |
2859 | int km; | 2859 | int km; |
2860 | if (!itemDate.isValid()) { | 2860 | if (!itemDate.isValid()) { |
2861 | //kdDebug() << "Date Not Valid" << endl; | 2861 | //kdDebug() << "Date Not Valid" << endl; |
2862 | if (KOPrefs::instance()->mConfirm) { | 2862 | if (KOPrefs::instance()->mConfirm) { |
2863 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2863 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2864 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2864 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2865 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2865 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2866 | if ( km == KMessageBox::Continue ) | 2866 | if ( km == KMessageBox::Continue ) |
2867 | km = KMessageBox::No; // No = all below | 2867 | km = KMessageBox::No; // No = all below |
2868 | } else | 2868 | } else |
2869 | km = KMessageBox::No; | 2869 | km = KMessageBox::No; |
2870 | } else { | 2870 | } else { |
2871 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2871 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2872 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2872 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2873 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2873 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2874 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2874 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2875 | i18n("All")); | 2875 | i18n("All")); |
2876 | } | 2876 | } |
2877 | switch(km) { | 2877 | switch(km) { |
2878 | 2878 | ||
2879 | case KMessageBox::No: // Continue // all | 2879 | case KMessageBox::No: // Continue // all |
2880 | //qDebug("KMessageBox::No "); | 2880 | //qDebug("KMessageBox::No "); |
2881 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2881 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2882 | schedule(Scheduler::Cancel,anEvent); | 2882 | schedule(Scheduler::Cancel,anEvent); |
2883 | 2883 | ||
2884 | checkExternalId( anEvent); | 2884 | checkExternalId( anEvent); |
2885 | mCalendar->deleteEvent(anEvent); | 2885 | mCalendar->deleteEvent(anEvent); |
2886 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2886 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2887 | break; | 2887 | break; |
2888 | 2888 | ||
2889 | // Disabled because it does not work | 2889 | // Disabled because it does not work |
2890 | //#if 0 | 2890 | //#if 0 |
2891 | case KMessageBox::Yes: // just this one | 2891 | case KMessageBox::Yes: // just this one |
2892 | //QDate qd = mNavigator->selectedDates().first(); | 2892 | //QDate qd = mNavigator->selectedDates().first(); |
2893 | //if (!qd.isValid()) { | 2893 | //if (!qd.isValid()) { |
2894 | // kdDebug() << "no date selected, or invalid date" << endl; | 2894 | // kdDebug() << "no date selected, or invalid date" << endl; |
2895 | // KNotifyClient::beep(); | 2895 | // KNotifyClient::beep(); |
2896 | // return; | 2896 | // return; |
2897 | //} | 2897 | //} |
2898 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2898 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2899 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2899 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2900 | anEvent->addExDate(itemDate); | 2900 | anEvent->addExDate(itemDate); |
2901 | int duration = anEvent->recurrence()->duration(); | 2901 | int duration = anEvent->recurrence()->duration(); |
2902 | if ( duration > 0 ) { | 2902 | if ( duration > 0 ) { |
2903 | anEvent->recurrence()->setDuration( duration - 1 ); | 2903 | anEvent->recurrence()->setDuration( duration - 1 ); |
2904 | } | 2904 | } |
2905 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2905 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2906 | } | 2906 | } |
2907 | break; | 2907 | break; |
2908 | //#endif | 2908 | //#endif |
2909 | } // switch | 2909 | } // switch |
2910 | } else { | 2910 | } else { |
2911 | if (KOPrefs::instance()->mConfirm) { | 2911 | if (KOPrefs::instance()->mConfirm) { |
2912 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2912 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2913 | i18n("\nAre you sure you want\nto delete this event?"), | 2913 | i18n("\nAre you sure you want\nto delete this event?"), |
2914 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2914 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2915 | case KMessageBox::Continue: // OK | 2915 | case KMessageBox::Continue: // OK |
2916 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2916 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2917 | schedule(Scheduler::Cancel,anEvent); | 2917 | schedule(Scheduler::Cancel,anEvent); |
2918 | checkExternalId( anEvent); | 2918 | checkExternalId( anEvent); |
2919 | mCalendar->deleteEvent(anEvent); | 2919 | mCalendar->deleteEvent(anEvent); |
2920 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2920 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2921 | break; | 2921 | break; |
2922 | } // switch | 2922 | } // switch |
2923 | } else { | 2923 | } else { |
2924 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2924 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2925 | schedule(Scheduler::Cancel,anEvent); | 2925 | schedule(Scheduler::Cancel,anEvent); |
2926 | checkExternalId( anEvent); | 2926 | checkExternalId( anEvent); |
2927 | mCalendar->deleteEvent(anEvent); | 2927 | mCalendar->deleteEvent(anEvent); |
2928 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2928 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2929 | } | 2929 | } |
2930 | } // if-else | 2930 | } // if-else |
2931 | emit updateSearchDialog(); | 2931 | emit updateSearchDialog(); |
2932 | } | 2932 | } |
2933 | 2933 | ||
2934 | bool CalendarView::deleteEvent(const QString &uid) | 2934 | bool CalendarView::deleteEvent(const QString &uid) |
2935 | { | 2935 | { |
2936 | Event *ev = mCalendar->event(uid); | 2936 | Event *ev = mCalendar->event(uid); |
2937 | if (ev) { | 2937 | if (ev) { |
2938 | deleteEvent(ev); | 2938 | deleteEvent(ev); |
2939 | return true; | 2939 | return true; |
2940 | } else { | 2940 | } else { |
2941 | return false; | 2941 | return false; |
2942 | } | 2942 | } |
2943 | } | 2943 | } |
2944 | 2944 | ||
2945 | /*****************************************************************************/ | 2945 | /*****************************************************************************/ |
2946 | 2946 | ||
2947 | void CalendarView::action_mail() | 2947 | void CalendarView::action_mail() |
2948 | { | 2948 | { |
2949 | #ifndef KORG_NOMAIL | 2949 | #ifndef KORG_NOMAIL |
2950 | KOMailClient mailClient; | 2950 | KOMailClient mailClient; |
2951 | 2951 | ||
2952 | Incidence *incidence = currentSelection(); | 2952 | Incidence *incidence = currentSelection(); |
2953 | 2953 | ||
2954 | if (!incidence) { | 2954 | if (!incidence) { |
2955 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2955 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2956 | return; | 2956 | return; |
2957 | } | 2957 | } |
2958 | if(incidence->attendeeCount() == 0 ) { | 2958 | if(incidence->attendeeCount() == 0 ) { |
2959 | KMessageBox::sorry(this, | 2959 | KMessageBox::sorry(this, |
2960 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2960 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2961 | return; | 2961 | return; |
2962 | } | 2962 | } |
2963 | 2963 | ||
2964 | CalendarLocal cal_tmp; | 2964 | CalendarLocal cal_tmp; |
2965 | Event *event = 0; | 2965 | Event *event = 0; |
2966 | Event *ev = 0; | 2966 | Event *ev = 0; |
2967 | if ( incidence && incidence->type() == "Event" ) { | 2967 | if ( incidence && incidence->type() == "Event" ) { |
2968 | event = static_cast<Event *>(incidence); | 2968 | event = static_cast<Event *>(incidence); |
2969 | ev = new Event(*event); | 2969 | ev = new Event(*event); |
2970 | cal_tmp.addEvent(ev); | 2970 | cal_tmp.addEvent(ev); |
2971 | } | 2971 | } |
2972 | ICalFormat mForm(); | 2972 | ICalFormat mForm(); |
2973 | QString attachment = mForm.toString( &cal_tmp ); | 2973 | QString attachment = mForm.toString( &cal_tmp ); |
2974 | if (ev) delete(ev); | 2974 | if (ev) delete(ev); |
2975 | 2975 | ||
2976 | mailClient.mailAttendees(currentSelection(), attachment); | 2976 | mailClient.mailAttendees(currentSelection(), attachment); |
2977 | 2977 | ||
2978 | #endif | 2978 | #endif |
2979 | 2979 | ||
2980 | #if 0 | 2980 | #if 0 |
2981 | Event *anEvent = 0; | 2981 | Event *anEvent = 0; |
2982 | if (mViewManager->currentView()->isEventView()) { | 2982 | if (mViewManager->currentView()->isEventView()) { |
2983 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2983 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2984 | } | 2984 | } |
2985 | 2985 | ||
2986 | if (!anEvent) { | 2986 | if (!anEvent) { |
2987 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2987 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2988 | return; | 2988 | return; |
2989 | } | 2989 | } |
2990 | if(anEvent->attendeeCount() == 0 ) { | 2990 | if(anEvent->attendeeCount() == 0 ) { |
2991 | KMessageBox::sorry(this, | 2991 | KMessageBox::sorry(this, |
2992 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2992 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2993 | return; | 2993 | return; |
2994 | } | 2994 | } |
2995 | 2995 | ||
2996 | mailobject.emailEvent(anEvent); | 2996 | mailobject.emailEvent(anEvent); |
2997 | #endif | 2997 | #endif |
2998 | } | 2998 | } |
2999 | 2999 | ||
3000 | 3000 | ||
3001 | void CalendarView::schedule_publish(Incidence *incidence) | 3001 | void CalendarView::schedule_publish(Incidence *incidence) |
3002 | { | 3002 | { |
3003 | Event *event = 0; | 3003 | Event *event = 0; |
3004 | Todo *todo = 0; | 3004 | Todo *todo = 0; |
3005 | 3005 | ||
3006 | if (incidence == 0) { | 3006 | if (incidence == 0) { |
3007 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3007 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3008 | if (incidence == 0) { | 3008 | if (incidence == 0) { |
3009 | incidence = mTodoList->selectedIncidences().first(); | 3009 | incidence = mTodoList->selectedIncidences().first(); |
3010 | } | 3010 | } |
3011 | } | 3011 | } |
3012 | if ( incidence && incidence->type() == "Event" ) { | 3012 | if ( incidence && incidence->type() == "Event" ) { |
3013 | event = static_cast<Event *>(incidence); | 3013 | event = static_cast<Event *>(incidence); |
3014 | } else { | 3014 | } else { |
3015 | if ( incidence && incidence->type() == "Todo" ) { | 3015 | if ( incidence && incidence->type() == "Todo" ) { |
3016 | todo = static_cast<Todo *>(incidence); | 3016 | todo = static_cast<Todo *>(incidence); |
3017 | } | 3017 | } |
3018 | } | 3018 | } |
3019 | 3019 | ||
3020 | if (!event && !todo) { | 3020 | if (!event && !todo) { |
3021 | KMessageBox::sorry(this,i18n("No event selected.")); | 3021 | KMessageBox::sorry(this,i18n("No event selected.")); |
3022 | return; | 3022 | return; |
3023 | } | 3023 | } |
3024 | 3024 | ||
3025 | PublishDialog *publishdlg = new PublishDialog(); | 3025 | PublishDialog *publishdlg = new PublishDialog(); |
3026 | if (incidence->attendeeCount()>0) { | 3026 | if (incidence->attendeeCount()>0) { |
3027 | QPtrList<Attendee> attendees = incidence->attendees(); | 3027 | QPtrList<Attendee> attendees = incidence->attendees(); |
3028 | attendees.first(); | 3028 | attendees.first(); |
3029 | while ( attendees.current()!=0 ) { | 3029 | while ( attendees.current()!=0 ) { |
3030 | publishdlg->addAttendee(attendees.current()); | 3030 | publishdlg->addAttendee(attendees.current()); |
3031 | attendees.next(); | 3031 | attendees.next(); |
3032 | } | 3032 | } |
3033 | } | 3033 | } |
3034 | bool send = true; | 3034 | bool send = true; |
3035 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3035 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3036 | if ( publishdlg->exec() != QDialog::Accepted ) | 3036 | if ( publishdlg->exec() != QDialog::Accepted ) |
3037 | send = false; | 3037 | send = false; |
3038 | } | 3038 | } |
3039 | if ( send ) { | 3039 | if ( send ) { |
3040 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3040 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3041 | if ( event ) { | 3041 | if ( event ) { |
3042 | Event *ev = new Event(*event); | 3042 | Event *ev = new Event(*event); |
3043 | ev->registerObserver(0); | 3043 | ev->registerObserver(0); |
3044 | ev->clearAttendees(); | 3044 | ev->clearAttendees(); |
3045 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3045 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3046 | delete(ev); | 3046 | delete(ev); |
3047 | } | 3047 | } |
3048 | } else { | 3048 | } else { |
3049 | if ( todo ) { | 3049 | if ( todo ) { |
3050 | Todo *ev = new Todo(*todo); | 3050 | Todo *ev = new Todo(*todo); |
3051 | ev->registerObserver(0); | 3051 | ev->registerObserver(0); |
3052 | ev->clearAttendees(); | 3052 | ev->clearAttendees(); |
3053 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3053 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3054 | delete(ev); | 3054 | delete(ev); |
3055 | } | 3055 | } |
3056 | } | 3056 | } |
3057 | } | 3057 | } |
3058 | } | 3058 | } |
3059 | delete publishdlg; | 3059 | delete publishdlg; |
3060 | } | 3060 | } |
3061 | 3061 | ||
3062 | void CalendarView::schedule_request(Incidence *incidence) | 3062 | void CalendarView::schedule_request(Incidence *incidence) |
3063 | { | 3063 | { |
3064 | schedule(Scheduler::Request,incidence); | 3064 | schedule(Scheduler::Request,incidence); |
3065 | } | 3065 | } |
3066 | 3066 | ||
3067 | void CalendarView::schedule_refresh(Incidence *incidence) | 3067 | void CalendarView::schedule_refresh(Incidence *incidence) |
3068 | { | 3068 | { |
3069 | schedule(Scheduler::Refresh,incidence); | 3069 | schedule(Scheduler::Refresh,incidence); |
3070 | } | 3070 | } |
3071 | 3071 | ||
3072 | void CalendarView::schedule_cancel(Incidence *incidence) | 3072 | void CalendarView::schedule_cancel(Incidence *incidence) |
3073 | { | 3073 | { |
3074 | schedule(Scheduler::Cancel,incidence); | 3074 | schedule(Scheduler::Cancel,incidence); |
3075 | } | 3075 | } |
3076 | 3076 | ||
3077 | void CalendarView::schedule_add(Incidence *incidence) | 3077 | void CalendarView::schedule_add(Incidence *incidence) |
3078 | { | 3078 | { |
3079 | schedule(Scheduler::Add,incidence); | 3079 | schedule(Scheduler::Add,incidence); |
3080 | } | 3080 | } |
3081 | 3081 | ||
3082 | void CalendarView::schedule_reply(Incidence *incidence) | 3082 | void CalendarView::schedule_reply(Incidence *incidence) |
3083 | { | 3083 | { |
3084 | schedule(Scheduler::Reply,incidence); | 3084 | schedule(Scheduler::Reply,incidence); |
3085 | } | 3085 | } |
3086 | 3086 | ||
3087 | void CalendarView::schedule_counter(Incidence *incidence) | 3087 | void CalendarView::schedule_counter(Incidence *incidence) |
3088 | { | 3088 | { |
3089 | schedule(Scheduler::Counter,incidence); | 3089 | schedule(Scheduler::Counter,incidence); |
3090 | } | 3090 | } |
3091 | 3091 | ||
3092 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3092 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3093 | { | 3093 | { |
3094 | schedule(Scheduler::Declinecounter,incidence); | 3094 | schedule(Scheduler::Declinecounter,incidence); |
3095 | } | 3095 | } |
3096 | 3096 | ||
3097 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3097 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3098 | { | 3098 | { |
3099 | QDateTime start = QDateTime::currentDateTime(); | 3099 | QDateTime start = QDateTime::currentDateTime(); |
3100 | QDateTime end = start.addDays(daysToPublish); | 3100 | QDateTime end = start.addDays(daysToPublish); |
3101 | 3101 | ||
3102 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3102 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3103 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3103 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3104 | 3104 | ||
3105 | 3105 | ||
3106 | PublishDialog *publishdlg = new PublishDialog(); | 3106 | PublishDialog *publishdlg = new PublishDialog(); |
3107 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3107 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3108 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3108 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3109 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3109 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3110 | delete(freebusy); | 3110 | delete(freebusy); |
3111 | } | 3111 | } |
3112 | } | 3112 | } |
3113 | delete publishdlg; | 3113 | delete publishdlg; |
3114 | } | 3114 | } |
3115 | 3115 | ||
3116 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3116 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3117 | { | 3117 | { |
3118 | Event *event = 0; | 3118 | Event *event = 0; |
3119 | Todo *todo = 0; | 3119 | Todo *todo = 0; |
3120 | 3120 | ||
3121 | if (incidence == 0) { | 3121 | if (incidence == 0) { |
3122 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3122 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3123 | if (incidence == 0) { | 3123 | if (incidence == 0) { |
3124 | incidence = mTodoList->selectedIncidences().first(); | 3124 | incidence = mTodoList->selectedIncidences().first(); |
3125 | } | 3125 | } |
3126 | } | 3126 | } |
3127 | if ( incidence && incidence->type() == "Event" ) { | 3127 | if ( incidence && incidence->type() == "Event" ) { |
3128 | event = static_cast<Event *>(incidence); | 3128 | event = static_cast<Event *>(incidence); |
3129 | } | 3129 | } |
3130 | if ( incidence && incidence->type() == "Todo" ) { | 3130 | if ( incidence && incidence->type() == "Todo" ) { |
3131 | todo = static_cast<Todo *>(incidence); | 3131 | todo = static_cast<Todo *>(incidence); |
3132 | } | 3132 | } |
3133 | 3133 | ||
3134 | if (!event && !todo) { | 3134 | if (!event && !todo) { |
3135 | KMessageBox::sorry(this,i18n("No event selected.")); | 3135 | KMessageBox::sorry(this,i18n("No event selected.")); |
3136 | return; | 3136 | return; |
3137 | } | 3137 | } |
3138 | 3138 | ||
3139 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3139 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3140 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3140 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3141 | return; | 3141 | return; |
3142 | } | 3142 | } |
3143 | 3143 | ||
3144 | Event *ev = 0; | 3144 | Event *ev = 0; |
3145 | if (event) ev = new Event(*event); | 3145 | if (event) ev = new Event(*event); |
3146 | Todo *to = 0; | 3146 | Todo *to = 0; |
3147 | if (todo) to = new Todo(*todo); | 3147 | if (todo) to = new Todo(*todo); |
3148 | 3148 | ||
3149 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3149 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3150 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3150 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3151 | if (!me) { | 3151 | if (!me) { |
3152 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3152 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3153 | return; | 3153 | return; |
3154 | } | 3154 | } |
3155 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3155 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3156 | StatusDialog *statdlg = new StatusDialog(this); | 3156 | StatusDialog *statdlg = new StatusDialog(this); |
3157 | if (!statdlg->exec()==QDialog::Accepted) return; | 3157 | if (!statdlg->exec()==QDialog::Accepted) return; |
3158 | me->setStatus( statdlg->status() ); | 3158 | me->setStatus( statdlg->status() ); |
3159 | delete(statdlg); | 3159 | delete(statdlg); |
3160 | } | 3160 | } |
3161 | Attendee *menew = new Attendee(*me); | 3161 | Attendee *menew = new Attendee(*me); |
3162 | if (ev) { | 3162 | if (ev) { |
3163 | ev->clearAttendees(); | 3163 | ev->clearAttendees(); |
3164 | ev->addAttendee(menew,false); | 3164 | ev->addAttendee(menew,false); |
3165 | } else { | 3165 | } else { |
3166 | if (to) { | 3166 | if (to) { |
3167 | todo->clearAttendees(); | 3167 | todo->clearAttendees(); |
3168 | todo->addAttendee(menew,false); | 3168 | todo->addAttendee(menew,false); |
3169 | } | 3169 | } |
3170 | } | 3170 | } |
3171 | } | 3171 | } |
3172 | 3172 | ||
3173 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3173 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3174 | if (ev) { | 3174 | if (ev) { |
3175 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3175 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3176 | } else { | 3176 | } else { |
3177 | if (to) { | 3177 | if (to) { |
3178 | if ( !dlg->addMessage(to,method) ) delete(to); | 3178 | if ( !dlg->addMessage(to,method) ) delete(to); |
3179 | } | 3179 | } |
3180 | } | 3180 | } |
3181 | } | 3181 | } |
3182 | 3182 | ||
3183 | void CalendarView::openAddressbook() | 3183 | void CalendarView::openAddressbook() |
3184 | { | 3184 | { |
3185 | KRun::runCommand("kaddressbook"); | 3185 | KRun::runCommand("kaddressbook"); |
3186 | } | 3186 | } |
3187 | 3187 | ||
3188 | void CalendarView::setModified(bool modified) | 3188 | void CalendarView::setModified(bool modified) |
3189 | { | 3189 | { |
3190 | if ( modified ) | 3190 | if ( modified ) |
3191 | emit signalmodified(); | 3191 | emit signalmodified(); |
3192 | if (mModified != modified) { | 3192 | if (mModified != modified) { |
3193 | mModified = modified; | 3193 | mModified = modified; |
3194 | emit modifiedChanged(mModified); | 3194 | emit modifiedChanged(mModified); |
3195 | } | 3195 | } |
3196 | } | 3196 | } |
3197 | 3197 | ||
3198 | bool CalendarView::isReadOnly() | 3198 | bool CalendarView::isReadOnly() |
3199 | { | 3199 | { |
3200 | return mReadOnly; | 3200 | return mReadOnly; |
3201 | } | 3201 | } |
3202 | 3202 | ||
3203 | void CalendarView::setReadOnly(bool readOnly) | 3203 | void CalendarView::setReadOnly(bool readOnly) |
3204 | { | 3204 | { |
3205 | if (mReadOnly != readOnly) { | 3205 | if (mReadOnly != readOnly) { |
3206 | mReadOnly = readOnly; | 3206 | mReadOnly = readOnly; |
3207 | emit readOnlyChanged(mReadOnly); | 3207 | emit readOnlyChanged(mReadOnly); |
3208 | } | 3208 | } |
3209 | } | 3209 | } |
3210 | 3210 | ||
3211 | bool CalendarView::isModified() | 3211 | bool CalendarView::isModified() |
3212 | { | 3212 | { |
3213 | return mModified; | 3213 | return mModified; |
3214 | } | 3214 | } |
3215 | 3215 | ||
3216 | void CalendarView::printSetup() | 3216 | void CalendarView::printSetup() |
3217 | { | 3217 | { |
3218 | #ifndef KORG_NOPRINTER | 3218 | #ifndef KORG_NOPRINTER |
3219 | createPrinter(); | 3219 | createPrinter(); |
3220 | 3220 | ||
3221 | mCalPrinter->setupPrinter(); | 3221 | mCalPrinter->setupPrinter(); |
3222 | #endif | 3222 | #endif |
3223 | } | 3223 | } |
3224 | 3224 | ||
3225 | void CalendarView::print() | 3225 | void CalendarView::print() |
3226 | { | 3226 | { |
3227 | #ifndef KORG_NOPRINTER | 3227 | #ifndef KORG_NOPRINTER |
3228 | createPrinter(); | 3228 | createPrinter(); |
3229 | 3229 | ||
3230 | DateList tmpDateList = mNavigator->selectedDates(); | 3230 | DateList tmpDateList = mNavigator->selectedDates(); |
3231 | mCalPrinter->print(CalPrinter::Month, | 3231 | mCalPrinter->print(CalPrinter::Month, |
3232 | tmpDateList.first(), tmpDateList.last()); | 3232 | tmpDateList.first(), tmpDateList.last()); |
3233 | #endif | 3233 | #endif |
3234 | } | 3234 | } |
3235 | 3235 | ||
3236 | void CalendarView::printPreview() | 3236 | void CalendarView::printPreview() |
3237 | { | 3237 | { |
3238 | #ifndef KORG_NOPRINTER | 3238 | #ifndef KORG_NOPRINTER |
3239 | kdDebug() << "CalendarView::printPreview()" << endl; | 3239 | kdDebug() << "CalendarView::printPreview()" << endl; |
3240 | 3240 | ||
3241 | createPrinter(); | 3241 | createPrinter(); |
3242 | 3242 | ||
3243 | DateList tmpDateList = mNavigator->selectedDates(); | 3243 | DateList tmpDateList = mNavigator->selectedDates(); |
3244 | 3244 | ||
3245 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3245 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3246 | tmpDateList.last()); | 3246 | tmpDateList.last()); |
3247 | #endif | 3247 | #endif |
3248 | } | 3248 | } |
3249 | 3249 | ||
3250 | void CalendarView::exportICalendar() | 3250 | void CalendarView::exportICalendar() |
3251 | { | 3251 | { |
3252 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3252 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3253 | 3253 | ||
3254 | // Force correct extension | 3254 | // Force correct extension |
3255 | if (filename.right(4) != ".ics") filename += ".ics"; | 3255 | if (filename.right(4) != ".ics") filename += ".ics"; |
3256 | 3256 | ||
3257 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3257 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3258 | storage.save(); | 3258 | storage.save(); |
3259 | } | 3259 | } |
3260 | 3260 | ||
3261 | bool CalendarView::exportVCalendar( QString filename ) | 3261 | bool CalendarView::exportVCalendar( QString filename ) |
3262 | { | 3262 | { |
3263 | if (mCalendar->journals().count() > 0) { | 3263 | if (mCalendar->journals().count() > 0) { |
3264 | int result = KMessageBox::warningContinueCancel(this, | 3264 | int result = KMessageBox::warningContinueCancel(this, |
3265 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3265 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3266 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3266 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3267 | true); | 3267 | true); |
3268 | if (result != KMessageBox::Continue) return false; | 3268 | if (result != KMessageBox::Continue) return false; |
3269 | } | 3269 | } |
3270 | 3270 | ||
3271 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3271 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3272 | 3272 | ||
3273 | // Force correct extension | 3273 | // Force correct extension |
3274 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3274 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3275 | 3275 | ||
3276 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3276 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3277 | return storage.save(); | 3277 | return storage.save(); |
3278 | 3278 | ||
3279 | } | 3279 | } |
3280 | 3280 | ||
3281 | void CalendarView::eventUpdated(Incidence *) | 3281 | void CalendarView::eventUpdated(Incidence *) |
3282 | { | 3282 | { |
3283 | setModified(); | 3283 | setModified(); |
3284 | // Don't call updateView here. The code, which has caused the update of the | 3284 | // Don't call updateView here. The code, which has caused the update of the |
3285 | // event is responsible for updating the view. | 3285 | // event is responsible for updating the view. |
3286 | // updateView(); | 3286 | // updateView(); |
3287 | } | 3287 | } |
3288 | 3288 | ||
3289 | void CalendarView::adaptNavigationUnits() | 3289 | void CalendarView::adaptNavigationUnits() |
3290 | { | 3290 | { |
3291 | if (mViewManager->currentView()->isEventView()) { | 3291 | if (mViewManager->currentView()->isEventView()) { |
3292 | int days = mViewManager->currentView()->currentDateCount(); | 3292 | int days = mViewManager->currentView()->currentDateCount(); |
3293 | if (days == 1) { | 3293 | if (days == 1) { |
3294 | emit changeNavStringPrev(i18n("&Previous Day")); | 3294 | emit changeNavStringPrev(i18n("&Previous Day")); |
3295 | emit changeNavStringNext(i18n("&Next Day")); | 3295 | emit changeNavStringNext(i18n("&Next Day")); |
3296 | } else { | 3296 | } else { |
3297 | emit changeNavStringPrev(i18n("&Previous Week")); | 3297 | emit changeNavStringPrev(i18n("&Previous Week")); |
3298 | emit changeNavStringNext(i18n("&Next Week")); | 3298 | emit changeNavStringNext(i18n("&Next Week")); |
3299 | } | 3299 | } |
3300 | } | 3300 | } |
3301 | } | 3301 | } |
3302 | 3302 | ||
3303 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3303 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3304 | { | 3304 | { |
3305 | if ( incidence ) mTodoList->clearSelection(); | 3305 | if ( incidence ) mTodoList->clearSelection(); |
3306 | processIncidenceSelection( incidence ); | 3306 | processIncidenceSelection( incidence ); |
3307 | } | 3307 | } |
3308 | 3308 | ||
3309 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3309 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3310 | { | 3310 | { |
3311 | if ( incidence && mViewManager->currentView() ) { | 3311 | if ( incidence && mViewManager->currentView() ) { |
3312 | mViewManager->currentView()->clearSelection(); | 3312 | mViewManager->currentView()->clearSelection(); |
3313 | } | 3313 | } |
3314 | processIncidenceSelection( incidence ); | 3314 | processIncidenceSelection( incidence ); |
3315 | } | 3315 | } |
3316 | 3316 | ||
3317 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3317 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3318 | { | 3318 | { |
3319 | if ( incidence == mSelectedIncidence ) return; | 3319 | if ( incidence == mSelectedIncidence ) return; |
3320 | 3320 | ||
3321 | mSelectedIncidence = incidence; | 3321 | mSelectedIncidence = incidence; |
3322 | 3322 | ||
3323 | emit incidenceSelected( mSelectedIncidence ); | 3323 | emit incidenceSelected( mSelectedIncidence ); |
3324 | 3324 | ||
3325 | if ( incidence && incidence->type() == "Event" ) { | 3325 | if ( incidence && incidence->type() == "Event" ) { |
3326 | Event *event = static_cast<Event *>( incidence ); | 3326 | Event *event = static_cast<Event *>( incidence ); |
3327 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3327 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3328 | emit organizerEventsSelected( true ); | 3328 | emit organizerEventsSelected( true ); |
3329 | } else { | 3329 | } else { |
3330 | emit organizerEventsSelected(false); | 3330 | emit organizerEventsSelected(false); |
3331 | } | 3331 | } |
3332 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3332 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3333 | KOPrefs::instance()->email() ) ) { | 3333 | KOPrefs::instance()->email() ) ) { |
3334 | emit groupEventsSelected( true ); | 3334 | emit groupEventsSelected( true ); |
3335 | } else { | 3335 | } else { |
3336 | emit groupEventsSelected(false); | 3336 | emit groupEventsSelected(false); |
3337 | } | 3337 | } |
3338 | return; | 3338 | return; |
3339 | } else { | 3339 | } else { |
3340 | if ( incidence && incidence->type() == "Todo" ) { | 3340 | if ( incidence && incidence->type() == "Todo" ) { |
3341 | emit todoSelected( true ); | 3341 | emit todoSelected( true ); |
3342 | Todo *event = static_cast<Todo *>( incidence ); | 3342 | Todo *event = static_cast<Todo *>( incidence ); |
3343 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3343 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3344 | emit organizerEventsSelected( true ); | 3344 | emit organizerEventsSelected( true ); |
3345 | } else { | 3345 | } else { |
3346 | emit organizerEventsSelected(false); | 3346 | emit organizerEventsSelected(false); |
3347 | } | 3347 | } |
3348 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3348 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3349 | KOPrefs::instance()->email() ) ) { | 3349 | KOPrefs::instance()->email() ) ) { |
3350 | emit groupEventsSelected( true ); | 3350 | emit groupEventsSelected( true ); |
3351 | } else { | 3351 | } else { |
3352 | emit groupEventsSelected(false); | 3352 | emit groupEventsSelected(false); |
3353 | } | 3353 | } |
3354 | return; | 3354 | return; |
3355 | } else { | 3355 | } else { |
3356 | emit todoSelected( false ); | 3356 | emit todoSelected( false ); |
3357 | emit organizerEventsSelected(false); | 3357 | emit organizerEventsSelected(false); |
3358 | emit groupEventsSelected(false); | 3358 | emit groupEventsSelected(false); |
3359 | } | 3359 | } |
3360 | return; | 3360 | return; |
3361 | } | 3361 | } |
3362 | 3362 | ||
3363 | /* if ( incidence && incidence->type() == "Todo" ) { | 3363 | /* if ( incidence && incidence->type() == "Todo" ) { |
3364 | emit todoSelected( true ); | 3364 | emit todoSelected( true ); |
3365 | } else { | 3365 | } else { |
3366 | emit todoSelected( false ); | 3366 | emit todoSelected( false ); |
3367 | }*/ | 3367 | }*/ |
3368 | } | 3368 | } |
3369 | 3369 | ||
3370 | 3370 | ||
3371 | void CalendarView::checkClipboard() | 3371 | void CalendarView::checkClipboard() |
3372 | { | 3372 | { |
3373 | #ifndef KORG_NODND | 3373 | #ifndef KORG_NODND |
3374 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3374 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3375 | emit pasteEnabled(true); | 3375 | emit pasteEnabled(true); |
3376 | } else { | 3376 | } else { |
3377 | emit pasteEnabled(false); | 3377 | emit pasteEnabled(false); |
3378 | } | 3378 | } |
3379 | #endif | 3379 | #endif |
3380 | } | 3380 | } |
3381 | 3381 | ||
3382 | void CalendarView::showDates(const DateList &selectedDates) | 3382 | void CalendarView::showDates(const DateList &selectedDates) |
3383 | { | 3383 | { |
3384 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3384 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3385 | 3385 | ||
3386 | if ( mViewManager->currentView() ) { | 3386 | if ( mViewManager->currentView() ) { |
3387 | updateView( selectedDates.first(), selectedDates.last() ); | 3387 | updateView( selectedDates.first(), selectedDates.last() ); |
3388 | } else { | 3388 | } else { |
3389 | mViewManager->showAgendaView(); | 3389 | mViewManager->showAgendaView(); |
3390 | } | 3390 | } |
3391 | 3391 | ||
3392 | QString selDates; | 3392 | QString selDates; |
3393 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3393 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3394 | if (selectedDates.first() < selectedDates.last() ) | 3394 | if (selectedDates.first() < selectedDates.last() ) |
3395 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3395 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3396 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3396 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3397 | 3397 | ||
3398 | } | 3398 | } |
3399 | 3399 | ||
3400 | QPtrList<CalFilter> CalendarView::filters() | 3400 | QPtrList<CalFilter> CalendarView::filters() |
3401 | { | 3401 | { |
3402 | return mFilters; | 3402 | return mFilters; |
3403 | 3403 | ||
3404 | } | 3404 | } |
3405 | void CalendarView::editFilters() | 3405 | void CalendarView::editFilters() |
3406 | { | 3406 | { |
3407 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3407 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3408 | 3408 | ||
3409 | CalFilter *filter = mFilters.first(); | 3409 | CalFilter *filter = mFilters.first(); |
3410 | while(filter) { | 3410 | while(filter) { |
3411 | kdDebug() << " Filter: " << filter->name() << endl; | 3411 | kdDebug() << " Filter: " << filter->name() << endl; |
3412 | filter = mFilters.next(); | 3412 | filter = mFilters.next(); |
3413 | } | 3413 | } |
3414 | 3414 | ||
3415 | mDialogManager->showFilterEditDialog(&mFilters); | 3415 | mDialogManager->showFilterEditDialog(&mFilters); |
3416 | } | 3416 | } |
3417 | void CalendarView::toggleFilter() | 3417 | void CalendarView::toggleFilter() |
3418 | { | 3418 | { |
3419 | showFilter(! mFilterView->isVisible()); | 3419 | showFilter(! mFilterView->isVisible()); |
3420 | } | 3420 | } |
3421 | 3421 | ||
3422 | KOFilterView *CalendarView::filterView() | 3422 | KOFilterView *CalendarView::filterView() |
3423 | { | 3423 | { |
3424 | return mFilterView; | 3424 | return mFilterView; |
3425 | } | 3425 | } |
3426 | void CalendarView::selectFilter( int fil ) | 3426 | void CalendarView::selectFilter( int fil ) |
3427 | { | 3427 | { |
3428 | mFilterView->setSelectedFilter( fil ); | 3428 | mFilterView->setSelectedFilter( fil ); |
3429 | } | 3429 | } |
3430 | void CalendarView::showFilter(bool visible) | 3430 | void CalendarView::showFilter(bool visible) |
3431 | { | 3431 | { |
3432 | if (visible) mFilterView->show(); | 3432 | if (visible) mFilterView->show(); |
3433 | else mFilterView->hide(); | 3433 | else mFilterView->hide(); |
3434 | } | 3434 | } |
3435 | void CalendarView::toggleFilerEnabled( ) | 3435 | void CalendarView::toggleFilerEnabled( ) |
3436 | { | 3436 | { |
3437 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3437 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3438 | if ( !mFilterView->filtersEnabled() ) | 3438 | if ( !mFilterView->filtersEnabled() ) |
3439 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3439 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3440 | 3440 | ||
3441 | } | 3441 | } |
3442 | void CalendarView::updateFilter() | 3442 | void CalendarView::updateFilter() |
3443 | { | 3443 | { |
3444 | CalFilter *filter = mFilterView->selectedFilter(); | 3444 | CalFilter *filter = mFilterView->selectedFilter(); |
3445 | if (filter) { | 3445 | if (filter) { |
3446 | if (mFilterView->filtersEnabled()) { | 3446 | if (mFilterView->filtersEnabled()) { |
3447 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3447 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3448 | filter->setEnabled(true); | 3448 | filter->setEnabled(true); |
3449 | } | 3449 | } |
3450 | else filter->setEnabled(false); | 3450 | else filter->setEnabled(false); |
3451 | mCalendar->setFilter(filter); | 3451 | mCalendar->setFilter(filter); |
3452 | updateView(); | 3452 | updateView(); |
3453 | } | 3453 | } |
3454 | } | 3454 | } |
3455 | 3455 | ||
3456 | void CalendarView::filterEdited() | 3456 | void CalendarView::filterEdited() |
3457 | { | 3457 | { |
3458 | mFilterView->updateFilters(); | 3458 | mFilterView->updateFilters(); |
3459 | updateFilter(); | 3459 | updateFilter(); |
3460 | writeSettings(); | 3460 | writeSettings(); |
3461 | } | 3461 | } |
3462 | 3462 | ||
3463 | 3463 | ||
3464 | void CalendarView::takeOverEvent() | 3464 | void CalendarView::takeOverEvent() |
3465 | { | 3465 | { |
3466 | Incidence *incidence = currentSelection(); | 3466 | Incidence *incidence = currentSelection(); |
3467 | 3467 | ||
3468 | if (!incidence) return; | 3468 | if (!incidence) return; |
3469 | 3469 | ||
3470 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3470 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3471 | incidence->recreate(); | 3471 | incidence->recreate(); |
3472 | incidence->setReadOnly(false); | 3472 | incidence->setReadOnly(false); |
3473 | 3473 | ||
3474 | updateView(); | 3474 | updateView(); |
3475 | } | 3475 | } |
3476 | 3476 | ||
3477 | void CalendarView::takeOverCalendar() | 3477 | void CalendarView::takeOverCalendar() |
3478 | { | 3478 | { |
3479 | // TODO: Create Calendar::allIncidences() function and use it here | 3479 | // TODO: Create Calendar::allIncidences() function and use it here |
3480 | 3480 | ||
3481 | QPtrList<Event> events = mCalendar->events(); | 3481 | QPtrList<Event> events = mCalendar->events(); |
3482 | for(uint i=0; i<events.count(); ++i) { | 3482 | for(uint i=0; i<events.count(); ++i) { |
3483 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3483 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3484 | events.at(i)->recreate(); | 3484 | events.at(i)->recreate(); |
3485 | events.at(i)->setReadOnly(false); | 3485 | events.at(i)->setReadOnly(false); |
3486 | } | 3486 | } |
3487 | 3487 | ||
3488 | QPtrList<Todo> todos = mCalendar->todos(); | 3488 | QPtrList<Todo> todos = mCalendar->todos(); |
3489 | for(uint i=0; i<todos.count(); ++i) { | 3489 | for(uint i=0; i<todos.count(); ++i) { |
3490 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3490 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3491 | todos.at(i)->recreate(); | 3491 | todos.at(i)->recreate(); |
3492 | todos.at(i)->setReadOnly(false); | 3492 | todos.at(i)->setReadOnly(false); |
3493 | } | 3493 | } |
3494 | 3494 | ||
3495 | QPtrList<Journal> journals = mCalendar->journals(); | 3495 | QPtrList<Journal> journals = mCalendar->journals(); |
3496 | for(uint i=0; i<journals.count(); ++i) { | 3496 | for(uint i=0; i<journals.count(); ++i) { |
3497 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3497 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3498 | journals.at(i)->recreate(); | 3498 | journals.at(i)->recreate(); |
3499 | journals.at(i)->setReadOnly(false); | 3499 | journals.at(i)->setReadOnly(false); |
3500 | } | 3500 | } |
3501 | 3501 | ||
3502 | updateView(); | 3502 | updateView(); |
3503 | } | 3503 | } |
3504 | 3504 | ||
3505 | void CalendarView::showIntro() | 3505 | void CalendarView::showIntro() |
3506 | { | 3506 | { |
3507 | kdDebug() << "To be implemented." << endl; | 3507 | kdDebug() << "To be implemented." << endl; |
3508 | } | 3508 | } |
3509 | 3509 | ||
3510 | QWidgetStack *CalendarView::viewStack() | 3510 | QWidgetStack *CalendarView::viewStack() |
3511 | { | 3511 | { |
3512 | return mRightFrame; | 3512 | return mRightFrame; |
3513 | } | 3513 | } |
3514 | 3514 | ||
3515 | QWidget *CalendarView::leftFrame() | 3515 | QWidget *CalendarView::leftFrame() |
3516 | { | 3516 | { |
3517 | return mLeftFrame; | 3517 | return mLeftFrame; |
3518 | } | 3518 | } |
3519 | 3519 | ||
3520 | DateNavigator *CalendarView::dateNavigator() | 3520 | DateNavigator *CalendarView::dateNavigator() |
3521 | { | 3521 | { |
3522 | return mNavigator; | 3522 | return mNavigator; |
3523 | } | 3523 | } |
3524 | 3524 | ||
3525 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3525 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3526 | { | 3526 | { |
3527 | return mDateNavigator; | 3527 | return mDateNavigator; |
3528 | } | 3528 | } |
3529 | void CalendarView::toggleDateNavigatorWidget() | 3529 | void CalendarView::toggleDateNavigatorWidget() |
3530 | { | 3530 | { |
3531 | if (mDateNavigator->isVisible()) | 3531 | if (mDateNavigator->isVisible()) |
3532 | mDateNavigator->hide(); | 3532 | mDateNavigator->hide(); |
3533 | else | 3533 | else |
3534 | mDateNavigator->show(); | 3534 | mDateNavigator->show(); |
3535 | } | 3535 | } |
3536 | void CalendarView::addView(KOrg::BaseView *view) | 3536 | void CalendarView::addView(KOrg::BaseView *view) |
3537 | { | 3537 | { |
3538 | mViewManager->addView(view); | 3538 | mViewManager->addView(view); |
3539 | } | 3539 | } |
3540 | 3540 | ||
3541 | void CalendarView::showView(KOrg::BaseView *view) | 3541 | void CalendarView::showView(KOrg::BaseView *view) |
3542 | { | 3542 | { |
3543 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3543 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3544 | } | 3544 | } |
3545 | 3545 | ||
3546 | Incidence *CalendarView::currentSelection() | 3546 | Incidence *CalendarView::currentSelection() |
3547 | { | 3547 | { |
3548 | return mViewManager->currentSelection(); | 3548 | return mViewManager->currentSelection(); |
3549 | } | 3549 | } |
3550 | void CalendarView::toggleAllDaySize() | 3550 | void CalendarView::toggleAllDaySize() |
3551 | { | 3551 | { |
3552 | /* | 3552 | /* |
3553 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3553 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3554 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3554 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3555 | else | 3555 | else |
3556 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3556 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3557 | */ | 3557 | */ |
3558 | viewManager()->agendaView()->toggleAllDay(); | 3558 | viewManager()->agendaView()->toggleAllDay(); |
3559 | } | 3559 | } |
3560 | void CalendarView::toggleExpand() | 3560 | void CalendarView::toggleExpand() |
3561 | { | 3561 | { |
3562 | // if ( mLeftFrame->isHidden() ) { | 3562 | // if ( mLeftFrame->isHidden() ) { |
3563 | // mLeftFrame->show(); | 3563 | // mLeftFrame->show(); |
3564 | // emit calendarViewExpanded( false ); | 3564 | // emit calendarViewExpanded( false ); |
3565 | // } else { | 3565 | // } else { |
3566 | // mLeftFrame->hide(); | 3566 | // mLeftFrame->hide(); |
3567 | // emit calendarViewExpanded( true ); | 3567 | // emit calendarViewExpanded( true ); |
3568 | // } | 3568 | // } |
3569 | 3569 | ||
3570 | globalFlagBlockAgenda = 1; | 3570 | globalFlagBlockAgenda = 1; |
3571 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3571 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3572 | globalFlagBlockAgenda = 5; | 3572 | globalFlagBlockAgenda = 5; |
3573 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3573 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3574 | //mViewManager->showView( 0, true ); | 3574 | //mViewManager->showView( 0, true ); |
3575 | } | 3575 | } |
3576 | 3576 | ||
3577 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3577 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3578 | { | 3578 | { |
3579 | setModified( modified ); | 3579 | setModified( modified ); |
3580 | } | 3580 | } |
3581 | 3581 | ||
3582 | Todo *CalendarView::selectedTodo() | 3582 | Todo *CalendarView::selectedTodo() |
3583 | { | 3583 | { |
3584 | Incidence *incidence = currentSelection(); | 3584 | Incidence *incidence = currentSelection(); |
3585 | if ( incidence && incidence->type() == "Todo" ) { | 3585 | if ( incidence && incidence->type() == "Todo" ) { |
3586 | return static_cast<Todo *>( incidence ); | 3586 | return static_cast<Todo *>( incidence ); |
3587 | } | 3587 | } |
3588 | 3588 | ||
3589 | incidence = mTodoList->selectedIncidences().first(); | 3589 | incidence = mTodoList->selectedIncidences().first(); |
3590 | if ( incidence && incidence->type() == "Todo" ) { | 3590 | if ( incidence && incidence->type() == "Todo" ) { |
3591 | return static_cast<Todo *>( incidence ); | 3591 | return static_cast<Todo *>( incidence ); |
3592 | } | 3592 | } |
3593 | 3593 | ||
3594 | return 0; | 3594 | return 0; |
3595 | } | 3595 | } |
3596 | 3596 | ||
3597 | void CalendarView::dialogClosing(Incidence *in) | 3597 | void CalendarView::dialogClosing(Incidence *in) |
3598 | { | 3598 | { |
3599 | // mDialogList.remove(in); | 3599 | // mDialogList.remove(in); |
3600 | } | 3600 | } |
3601 | 3601 | ||
3602 | void CalendarView::showIncidence() | 3602 | void CalendarView::showIncidence() |
3603 | { | 3603 | { |
3604 | Incidence *incidence = currentSelection(); | 3604 | Incidence *incidence = currentSelection(); |
3605 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3605 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3606 | if ( incidence ) { | 3606 | if ( incidence ) { |
3607 | ShowIncidenceVisitor v; | 3607 | ShowIncidenceVisitor v; |
3608 | v.act( incidence, this ); | 3608 | v.act( incidence, this ); |
3609 | } | 3609 | } |
3610 | } | 3610 | } |
3611 | void CalendarView::editIncidenceDescription() | 3611 | void CalendarView::editIncidenceDescription() |
3612 | { | 3612 | { |
3613 | mFlagEditDescription = true; | 3613 | mFlagEditDescription = true; |
3614 | editIncidence(); | 3614 | editIncidence(); |
3615 | mFlagEditDescription = false; | 3615 | mFlagEditDescription = false; |
3616 | } | 3616 | } |
3617 | void CalendarView::editIncidence() | 3617 | void CalendarView::editIncidence() |
3618 | { | 3618 | { |
3619 | // qDebug("editIncidence() "); | 3619 | // qDebug("editIncidence() "); |
3620 | Incidence *incidence = currentSelection(); | 3620 | Incidence *incidence = currentSelection(); |
3621 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3621 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3622 | if ( incidence ) { | 3622 | if ( incidence ) { |
3623 | EditIncidenceVisitor v; | 3623 | EditIncidenceVisitor v; |
3624 | v.act( incidence, this ); | 3624 | v.act( incidence, this ); |
3625 | } | 3625 | } |
3626 | } | 3626 | } |
3627 | 3627 | ||
3628 | void CalendarView::deleteIncidence() | 3628 | void CalendarView::deleteIncidence() |
3629 | { | 3629 | { |
3630 | Incidence *incidence = currentSelection(); | 3630 | Incidence *incidence = currentSelection(); |
3631 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3631 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3632 | if ( incidence ) { | 3632 | if ( incidence ) { |
3633 | deleteIncidence(incidence); | 3633 | deleteIncidence(incidence); |
3634 | } | 3634 | } |
3635 | } | 3635 | } |
3636 | 3636 | ||
3637 | void CalendarView::showIncidence(Incidence *incidence) | 3637 | void CalendarView::showIncidence(Incidence *incidence) |
3638 | { | 3638 | { |
3639 | if ( incidence ) { | 3639 | if ( incidence ) { |
3640 | ShowIncidenceVisitor v; | 3640 | ShowIncidenceVisitor v; |
3641 | v.act( incidence, this ); | 3641 | v.act( incidence, this ); |
3642 | } | 3642 | } |
3643 | } | 3643 | } |
3644 | 3644 | ||
3645 | void CalendarView::editIncidence(Incidence *incidence) | 3645 | void CalendarView::editIncidence(Incidence *incidence) |
3646 | { | 3646 | { |
3647 | if ( incidence ) { | 3647 | if ( incidence ) { |
3648 | 3648 | ||
3649 | EditIncidenceVisitor v; | 3649 | EditIncidenceVisitor v; |
3650 | v.act( incidence, this ); | 3650 | v.act( incidence, this ); |
3651 | 3651 | ||
3652 | } | 3652 | } |
3653 | } | 3653 | } |
3654 | 3654 | ||
3655 | void CalendarView::deleteIncidence(Incidence *incidence) | 3655 | void CalendarView::deleteIncidence(Incidence *incidence) |
3656 | { | 3656 | { |
3657 | //qDebug(" CalendarView::deleteIncidence "); | 3657 | //qDebug(" CalendarView::deleteIncidence "); |
3658 | if ( incidence ) { | 3658 | if ( incidence ) { |
3659 | DeleteIncidenceVisitor v; | 3659 | DeleteIncidenceVisitor v; |
3660 | v.act( incidence, this ); | 3660 | v.act( incidence, this ); |
3661 | } | 3661 | } |
3662 | } | 3662 | } |
3663 | 3663 | ||
3664 | 3664 | ||
3665 | void CalendarView::lookForOutgoingMessages() | 3665 | void CalendarView::lookForOutgoingMessages() |
3666 | { | 3666 | { |
3667 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3667 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3668 | ogd->loadMessages(); | 3668 | ogd->loadMessages(); |
3669 | } | 3669 | } |
3670 | 3670 | ||
3671 | void CalendarView::lookForIncomingMessages() | 3671 | void CalendarView::lookForIncomingMessages() |
3672 | { | 3672 | { |
3673 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3673 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3674 | icd->retrieve(); | 3674 | icd->retrieve(); |
3675 | } | 3675 | } |
3676 | 3676 | ||
3677 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3677 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3678 | { | 3678 | { |
3679 | bool deleteTodo = true; | 3679 | bool deleteTodo = true; |
3680 | QPtrList<Incidence> subTodos; | 3680 | QPtrList<Incidence> subTodos; |
3681 | Incidence *aTodo; | 3681 | Incidence *aTodo; |
3682 | subTodos = t->relations(); | 3682 | subTodos = t->relations(); |
3683 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3683 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3684 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3684 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3685 | deleteTodo = false; | 3685 | deleteTodo = false; |
3686 | } | 3686 | } |
3687 | if ( deleteTodo ) { | 3687 | if ( deleteTodo ) { |
3688 | if ( t->isCompleted() ) { | 3688 | if ( t->isCompleted() ) { |
3689 | checkExternalId( t ); | 3689 | checkExternalId( t ); |
3690 | mCalendar->deleteTodo( t ); | 3690 | mCalendar->deleteTodo( t ); |
3691 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3691 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3692 | } | 3692 | } |
3693 | else | 3693 | else |
3694 | deleteTodo = false; | 3694 | deleteTodo = false; |
3695 | } | 3695 | } |
3696 | return deleteTodo; | 3696 | return deleteTodo; |
3697 | 3697 | ||
3698 | } | 3698 | } |
3699 | void CalendarView::purgeCompleted() | 3699 | void CalendarView::purgeCompleted() |
3700 | { | 3700 | { |
3701 | int result = KMessageBox::warningContinueCancel(this, | 3701 | int result = KMessageBox::warningContinueCancel(this, |
3702 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3702 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3703 | 3703 | ||
3704 | if (result == KMessageBox::Continue) { | 3704 | if (result == KMessageBox::Continue) { |
3705 | 3705 | ||
3706 | QPtrList<Todo> todoCal; | 3706 | QPtrList<Todo> todoCal; |
3707 | QPtrList<Todo> rootTodos; | 3707 | QPtrList<Todo> rootTodos; |
3708 | //QPtrList<Incidence> rel; | 3708 | //QPtrList<Incidence> rel; |
3709 | Todo *aTodo;//, *rTodo; | 3709 | Todo *aTodo;//, *rTodo; |
3710 | Incidence *rIncidence; | 3710 | Incidence *rIncidence; |
3711 | bool childDelete = false; | 3711 | bool childDelete = false; |
3712 | bool deletedOne = true; | 3712 | bool deletedOne = true; |
3713 | todoCal = calendar()->todos(); | 3713 | todoCal = calendar()->todos(); |
3714 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3714 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3715 | if ( !aTodo->relatedTo() ) | 3715 | if ( !aTodo->relatedTo() ) |
3716 | rootTodos.append( aTodo ); | 3716 | rootTodos.append( aTodo ); |
3717 | } | 3717 | } |
3718 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3718 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3719 | removeCompletedSubTodos( aTodo ); | 3719 | removeCompletedSubTodos( aTodo ); |
3720 | } | 3720 | } |
3721 | 3721 | ||
3722 | updateView(); | 3722 | updateView(); |
3723 | } | 3723 | } |
3724 | } | 3724 | } |
3725 | 3725 | ||
3726 | void CalendarView::slotCalendarChanged() | 3726 | void CalendarView::slotCalendarChanged() |
3727 | { | 3727 | { |
3728 | ; | 3728 | ; |
3729 | } | 3729 | } |
3730 | 3730 | ||
3731 | NavigatorBar *CalendarView::navigatorBar() | 3731 | NavigatorBar *CalendarView::navigatorBar() |
3732 | { | 3732 | { |
3733 | return mNavigatorBar; | 3733 | return mNavigatorBar; |
3734 | } | 3734 | } |
3735 | 3735 | ||
3736 | 3736 | ||
3737 | 3737 | ||
3738 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3738 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3739 | { | 3739 | { |
3740 | //qDebug(" alendarView::keyPressEvent "); | 3740 | //qDebug(" alendarView::keyPressEvent "); |
3741 | e->ignore(); | 3741 | e->ignore(); |
3742 | } | 3742 | } |
3743 | 3743 | ||
3744 | 3744 | ||
3745 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3745 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3746 | { | 3746 | { |
3747 | // mSyncManager = manager; | 3747 | // mSyncManager = manager; |
3748 | mSyncKDE = false; | ||
3749 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3748 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3750 | qDebug("SyncKDE request detected!"); | 3749 | qDebug("SyncKDE request detected!"); |
3751 | mSyncKDE = true; | ||
3752 | } | 3750 | } |
3753 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3751 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3754 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3752 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3755 | return syncCalendar( filename, mode ); | 3753 | return syncCalendar( filename, mode ); |
3756 | } | 3754 | } |
3757 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3755 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3758 | { | 3756 | { |
3759 | mSyncKDE = false; | ||
3760 | //mSyncManager = manager; | 3757 | //mSyncManager = manager; |
3761 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3758 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3762 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3759 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3763 | if ( resource == "sharp" ) | 3760 | if ( resource == "sharp" ) |
3764 | syncExternal( 0 ); | 3761 | syncExternal( 0 ); |
3765 | if ( resource == "phone" ) | 3762 | if ( resource == "phone" ) |
3766 | syncExternal( 1 ); | 3763 | syncExternal( 1 ); |
3767 | // pending setmodified | 3764 | // pending setmodified |
3768 | return true; | 3765 | return true; |
3769 | } | 3766 | } |
3770 | void CalendarView::setSyncManager(KSyncManager* manager) | 3767 | void CalendarView::setSyncManager(KSyncManager* manager) |
3771 | { | 3768 | { |
3772 | mSyncManager = manager; | 3769 | mSyncManager = manager; |
3773 | } | 3770 | } |
3774 | 3771 | ||
3775 | void CalendarView::removeSyncInfo( QString syncProfile) | 3772 | void CalendarView::removeSyncInfo( QString syncProfile) |
3776 | { | 3773 | { |
3777 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3774 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3778 | mCalendar->removeSyncInfo( syncProfile ); | 3775 | mCalendar->removeSyncInfo( syncProfile ); |
3779 | 3776 | ||
3780 | } | 3777 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index acc20d6..437a51c 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,606 +1,605 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 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 CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | 42 | ||
43 | #include <korganizer/calendarviewbase.h> | 43 | #include <korganizer/calendarviewbase.h> |
44 | 44 | ||
45 | #include <ksyncmanager.h> | 45 | #include <ksyncmanager.h> |
46 | 46 | ||
47 | class QWidgetStack; | 47 | class QWidgetStack; |
48 | class QSplitter; | 48 | class QSplitter; |
49 | 49 | ||
50 | class CalPrinter; | 50 | class CalPrinter; |
51 | class KOFilterView; | 51 | class KOFilterView; |
52 | class KOViewManager; | 52 | class KOViewManager; |
53 | class KODialogManager; | 53 | class KODialogManager; |
54 | class KOTodoView; | 54 | class KOTodoView; |
55 | class KDateNavigator; | 55 | class KDateNavigator; |
56 | class DateNavigator; | 56 | class DateNavigator; |
57 | class KOIncidenceEditor; | 57 | class KOIncidenceEditor; |
58 | class KDatePicker; | 58 | class KDatePicker; |
59 | class ResourceView; | 59 | class ResourceView; |
60 | class NavigatorBar; | 60 | class NavigatorBar; |
61 | class KOEventEditor; | 61 | class KOEventEditor; |
62 | class KOTodoEditor ; | 62 | class KOTodoEditor ; |
63 | class KOEventViewerDialog; | 63 | class KOEventViewerDialog; |
64 | class KOBeamPrefs; | 64 | class KOBeamPrefs; |
65 | class KSyncProfile; | 65 | class KSyncProfile; |
66 | class AlarmDialog; | 66 | class AlarmDialog; |
67 | class KCal::Attendee; | 67 | class KCal::Attendee; |
68 | 68 | ||
69 | namespace KCal { class FileStorage; } | 69 | namespace KCal { class FileStorage; } |
70 | 70 | ||
71 | using namespace KCal; | 71 | using namespace KCal; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | This is the main calendar widget. It provides the different vies on t he | 74 | This is the main calendar widget. It provides the different vies on t he |
75 | calendar data as well as the date navigator. It also handles synchronisation | 75 | calendar data as well as the date navigator. It also handles synchronisation |
76 | of the different views and controls the different dialogs like preferences, | 76 | of the different views and controls the different dialogs like preferences, |
77 | event editor, search dialog etc. | 77 | event editor, search dialog etc. |
78 | 78 | ||
79 | @short main calendar view widget | 79 | @short main calendar view widget |
80 | @author Cornelius Schumacher | 80 | @author Cornelius Schumacher |
81 | */ | 81 | */ |
82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
83 | { | 83 | { |
84 | Q_OBJECT | 84 | Q_OBJECT |
85 | public: | 85 | public: |
86 | /** | 86 | /** |
87 | Constructs a new calendar view widget. | 87 | Constructs a new calendar view widget. |
88 | 88 | ||
89 | @param calendar calendar document | 89 | @param calendar calendar document |
90 | @param parent parent window | 90 | @param parent parent window |
91 | @param name Qt internal widget object name | 91 | @param name Qt internal widget object name |
92 | */ | 92 | */ |
93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 93 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 94 | const char *name = 0 ); |
95 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 95 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
96 | const char *name = 0 ); | 96 | const char *name = 0 ); |
97 | virtual ~CalendarView(); | 97 | virtual ~CalendarView(); |
98 | 98 | ||
99 | Calendar *calendar() { return mCalendar; } | 99 | Calendar *calendar() { return mCalendar; } |
100 | 100 | ||
101 | KOViewManager *viewManager(); | 101 | KOViewManager *viewManager(); |
102 | KODialogManager *dialogManager(); | 102 | KODialogManager *dialogManager(); |
103 | 103 | ||
104 | QDate startDate(); | 104 | QDate startDate(); |
105 | QDate endDate(); | 105 | QDate endDate(); |
106 | 106 | ||
107 | QWidgetStack *viewStack(); | 107 | QWidgetStack *viewStack(); |
108 | QWidget *leftFrame(); | 108 | QWidget *leftFrame(); |
109 | NavigatorBar *navigatorBar(); | 109 | NavigatorBar *navigatorBar(); |
110 | 110 | ||
111 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
112 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
113 | 113 | ||
114 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
115 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
116 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
117 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
118 | 118 | ||
119 | signals: | 119 | signals: |
120 | void tempDisableBR(bool); | 120 | void tempDisableBR(bool); |
121 | /** This todo has been modified */ | 121 | /** This todo has been modified */ |
122 | void todoModified(Todo *, int); | 122 | void todoModified(Todo *, int); |
123 | 123 | ||
124 | /** when change is made to options dialog, the topwidget will catch this | 124 | /** when change is made to options dialog, the topwidget will catch this |
125 | * and emit this signal which notifies all widgets which have registered | 125 | * and emit this signal which notifies all widgets which have registered |
126 | * for notification to update their settings. */ | 126 | * for notification to update their settings. */ |
127 | void configChanged(); | 127 | void configChanged(); |
128 | /** emitted when the topwidget is closing down, so that any attached | 128 | /** emitted when the topwidget is closing down, so that any attached |
129 | child windows can also close. */ | 129 | child windows can also close. */ |
130 | void closingDown(); | 130 | void closingDown(); |
131 | /** emitted right before we die */ | 131 | /** emitted right before we die */ |
132 | void closed(QWidget *); | 132 | void closed(QWidget *); |
133 | 133 | ||
134 | /** Emitted when state of modified flag changes */ | 134 | /** Emitted when state of modified flag changes */ |
135 | void modifiedChanged(bool); | 135 | void modifiedChanged(bool); |
136 | void signalmodified(); | 136 | void signalmodified(); |
137 | 137 | ||
138 | /** Emitted when state of read-only flag changes */ | 138 | /** Emitted when state of read-only flag changes */ |
139 | void readOnlyChanged(bool); | 139 | void readOnlyChanged(bool); |
140 | 140 | ||
141 | /** Emitted when the unit of navigation changes */ | 141 | /** Emitted when the unit of navigation changes */ |
142 | void changeNavStringPrev(const QString &); | 142 | void changeNavStringPrev(const QString &); |
143 | void changeNavStringNext(const QString &); | 143 | void changeNavStringNext(const QString &); |
144 | 144 | ||
145 | /** Emitted when state of events selection has changed and user is organizer*/ | 145 | /** Emitted when state of events selection has changed and user is organizer*/ |
146 | void organizerEventsSelected(bool); | 146 | void organizerEventsSelected(bool); |
147 | /** Emitted when state of events selection has changed and user is attendee*/ | 147 | /** Emitted when state of events selection has changed and user is attendee*/ |
148 | void groupEventsSelected(bool); | 148 | void groupEventsSelected(bool); |
149 | /** | 149 | /** |
150 | Emitted when an incidence gets selected. If the selection is cleared the | 150 | Emitted when an incidence gets selected. If the selection is cleared the |
151 | signal is emitted with 0 as argument. | 151 | signal is emitted with 0 as argument. |
152 | */ | 152 | */ |
153 | void incidenceSelected( Incidence * ); | 153 | void incidenceSelected( Incidence * ); |
154 | /** Emitted, when a todoitem is selected or deselected. */ | 154 | /** Emitted, when a todoitem is selected or deselected. */ |
155 | void todoSelected( bool ); | 155 | void todoSelected( bool ); |
156 | 156 | ||
157 | /** | 157 | /** |
158 | Emitted, when clipboard content changes. Parameter indicates if paste | 158 | Emitted, when clipboard content changes. Parameter indicates if paste |
159 | is possible or not. | 159 | is possible or not. |
160 | */ | 160 | */ |
161 | void pasteEnabled(bool); | 161 | void pasteEnabled(bool); |
162 | 162 | ||
163 | /** Emitted, when the number of incoming messages has changed. */ | 163 | /** Emitted, when the number of incoming messages has changed. */ |
164 | void numIncomingChanged(int); | 164 | void numIncomingChanged(int); |
165 | 165 | ||
166 | /** Emitted, when the number of outgoing messages has changed. */ | 166 | /** Emitted, when the number of outgoing messages has changed. */ |
167 | void numOutgoingChanged(int); | 167 | void numOutgoingChanged(int); |
168 | 168 | ||
169 | /** Send status message, which can e.g. be displayed in the status bar. */ | 169 | /** Send status message, which can e.g. be displayed in the status bar. */ |
170 | void statusMessage(const QString &); | 170 | void statusMessage(const QString &); |
171 | 171 | ||
172 | void calendarViewExpanded( bool ); | 172 | void calendarViewExpanded( bool ); |
173 | void updateSearchDialog(); | 173 | void updateSearchDialog(); |
174 | 174 | ||
175 | 175 | ||
176 | public slots: | 176 | public slots: |
177 | void showOpenError(); | 177 | void showOpenError(); |
178 | void watchSavedFile(); | 178 | void watchSavedFile(); |
179 | void recheckTimerAlarm(); | 179 | void recheckTimerAlarm(); |
180 | void checkNextTimerAlarm(); | 180 | void checkNextTimerAlarm(); |
181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 181 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 182 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 183 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
184 | 184 | ||
185 | /** options dialog made a changed to the configuration. we catch this | 185 | /** options dialog made a changed to the configuration. we catch this |
186 | * and notify all widgets which need to update their configuration. */ | 186 | * and notify all widgets which need to update their configuration. */ |
187 | void updateConfig(); | 187 | void updateConfig(); |
188 | 188 | ||
189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 189 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
190 | const QStringList& anniversaryList, const QStringList& realNameList, | 190 | const QStringList& anniversaryList, const QStringList& realNameList, |
191 | const QStringList& emailList, const QStringList& assembledNameList, | 191 | const QStringList& emailList, const QStringList& assembledNameList, |
192 | const QStringList& uidList); | 192 | const QStringList& uidList); |
193 | 193 | ||
194 | /** | 194 | /** |
195 | Load calendar from file \a filename. If \a merge is true, load | 195 | Load calendar from file \a filename. If \a merge is true, load |
196 | calendar into existing one, if it is false, clear calendar, before | 196 | calendar into existing one, if it is false, clear calendar, before |
197 | loading. Return true, if calendar could be successfully loaded. | 197 | loading. Return true, if calendar could be successfully loaded. |
198 | */ | 198 | */ |
199 | bool openCalendar(QString filename, bool merge=false); | 199 | bool openCalendar(QString filename, bool merge=false); |
200 | bool syncCalendar(QString filename,int mode = 0 ); | 200 | bool syncCalendar(QString filename,int mode = 0 ); |
201 | 201 | ||
202 | /** | 202 | /** |
203 | Save calendar data to file. Return true if calendar could be | 203 | Save calendar data to file. Return true if calendar could be |
204 | successfully saved. | 204 | successfully saved. |
205 | */ | 205 | */ |
206 | bool saveCalendar(QString filename); | 206 | bool saveCalendar(QString filename); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | Close calendar. Clear calendar data and reset views to display an empty | 209 | Close calendar. Clear calendar data and reset views to display an empty |
210 | calendar. | 210 | calendar. |
211 | */ | 211 | */ |
212 | void closeCalendar(); | 212 | void closeCalendar(); |
213 | 213 | ||
214 | /** Archive old events of calendar */ | 214 | /** Archive old events of calendar */ |
215 | void archiveCalendar(); | 215 | void archiveCalendar(); |
216 | 216 | ||
217 | void showIncidence(); | 217 | void showIncidence(); |
218 | void editIncidence(); | 218 | void editIncidence(); |
219 | void editIncidenceDescription(); | 219 | void editIncidenceDescription(); |
220 | void deleteIncidence(); | 220 | void deleteIncidence(); |
221 | void cloneIncidence(); | 221 | void cloneIncidence(); |
222 | void moveIncidence(); | 222 | void moveIncidence(); |
223 | void beamIncidence(); | 223 | void beamIncidence(); |
224 | void toggleCancelIncidence(); | 224 | void toggleCancelIncidence(); |
225 | 225 | ||
226 | /** create an editeventwin with supplied date/time, and if bool is true, | 226 | /** create an editeventwin with supplied date/time, and if bool is true, |
227 | * make the event take all day. */ | 227 | * make the event take all day. */ |
228 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 228 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
229 | void newEvent(QDateTime fh); | 229 | void newEvent(QDateTime fh); |
230 | void newEvent(QDate dt); | 230 | void newEvent(QDate dt); |
231 | /** create new event without having a date hint. Takes current date as | 231 | /** create new event without having a date hint. Takes current date as |
232 | default hint. */ | 232 | default hint. */ |
233 | void newEvent(); | 233 | void newEvent(); |
234 | void newFloatingEvent(); | 234 | void newFloatingEvent(); |
235 | 235 | ||
236 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 236 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
237 | void showIncidence(Incidence *); | 237 | void showIncidence(Incidence *); |
238 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 238 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
239 | void editIncidence(Incidence *); | 239 | void editIncidence(Incidence *); |
240 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 240 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
241 | void deleteIncidence(Incidence *); | 241 | void deleteIncidence(Incidence *); |
242 | void cloneIncidence(Incidence *); | 242 | void cloneIncidence(Incidence *); |
243 | void cancelIncidence(Incidence *); | 243 | void cancelIncidence(Incidence *); |
244 | /** Create an editor for the supplied event. */ | 244 | /** Create an editor for the supplied event. */ |
245 | void editEvent(Event *); | 245 | void editEvent(Event *); |
246 | /** Delete the supplied event. */ | 246 | /** Delete the supplied event. */ |
247 | void deleteEvent(Event *); | 247 | void deleteEvent(Event *); |
248 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 248 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
249 | found. */ | 249 | found. */ |
250 | bool deleteEvent(const QString &uid); | 250 | bool deleteEvent(const QString &uid); |
251 | /** Create a read-only viewer dialog for the supplied event. */ | 251 | /** Create a read-only viewer dialog for the supplied event. */ |
252 | void showEvent(Event *); | 252 | void showEvent(Event *); |
253 | 253 | ||
254 | void editJournal(Journal *); | 254 | void editJournal(Journal *); |
255 | void showJournal(Journal *); | 255 | void showJournal(Journal *); |
256 | void deleteJournal(Journal *); | 256 | void deleteJournal(Journal *); |
257 | /** Create an editor dialog for a todo */ | 257 | /** Create an editor dialog for a todo */ |
258 | void editTodo(Todo *); | 258 | void editTodo(Todo *); |
259 | /** Create a read-only viewer dialog for the supplied todo */ | 259 | /** Create a read-only viewer dialog for the supplied todo */ |
260 | void showTodo(Todo *); | 260 | void showTodo(Todo *); |
261 | /** create new todo */ | 261 | /** create new todo */ |
262 | void newTodo(); | 262 | void newTodo(); |
263 | /** create new todo with a parent todo */ | 263 | /** create new todo with a parent todo */ |
264 | void newSubTodo(); | 264 | void newSubTodo(); |
265 | /** create new todo with a parent todo */ | 265 | /** create new todo with a parent todo */ |
266 | void newSubTodo(Todo *); | 266 | void newSubTodo(Todo *); |
267 | /** Delete todo */ | 267 | /** Delete todo */ |
268 | void deleteTodo(Todo *); | 268 | void deleteTodo(Todo *); |
269 | 269 | ||
270 | 270 | ||
271 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 271 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
272 | * emitted as result. */ | 272 | * emitted as result. */ |
273 | void checkClipboard(); | 273 | void checkClipboard(); |
274 | 274 | ||
275 | /** using the KConfig associated with the kapp variable, read in the | 275 | /** using the KConfig associated with the kapp variable, read in the |
276 | * settings from the config file. | 276 | * settings from the config file. |
277 | */ | 277 | */ |
278 | void readSettings(); | 278 | void readSettings(); |
279 | 279 | ||
280 | /** write current state to config file. */ | 280 | /** write current state to config file. */ |
281 | void writeSettings(); | 281 | void writeSettings(); |
282 | 282 | ||
283 | /** read settings for calendar filters */ | 283 | /** read settings for calendar filters */ |
284 | void readFilterSettings(KConfig *config); | 284 | void readFilterSettings(KConfig *config); |
285 | 285 | ||
286 | /** write settings for calendar filters */ | 286 | /** write settings for calendar filters */ |
287 | void writeFilterSettings(KConfig *config); | 287 | void writeFilterSettings(KConfig *config); |
288 | 288 | ||
289 | /** passes on the message that an event has changed to the currently | 289 | /** passes on the message that an event has changed to the currently |
290 | * activated view so that it can make appropriate display changes. */ | 290 | * activated view so that it can make appropriate display changes. */ |
291 | void changeEventDisplay(Event *, int); | 291 | void changeEventDisplay(Event *, int); |
292 | void changeIncidenceDisplay(Incidence *, int); | 292 | void changeIncidenceDisplay(Incidence *, int); |
293 | void changeTodoDisplay(Todo *, int); | 293 | void changeTodoDisplay(Todo *, int); |
294 | 294 | ||
295 | void eventAdded(Event *); | 295 | void eventAdded(Event *); |
296 | void eventChanged(Event *); | 296 | void eventChanged(Event *); |
297 | void eventToBeDeleted(Event *); | 297 | void eventToBeDeleted(Event *); |
298 | void eventDeleted(); | 298 | void eventDeleted(); |
299 | 299 | ||
300 | void todoAdded(Todo *); | 300 | void todoAdded(Todo *); |
301 | void todoChanged(Todo *); | 301 | void todoChanged(Todo *); |
302 | void todoToBeDeleted(Todo *); | 302 | void todoToBeDeleted(Todo *); |
303 | void todoDeleted(); | 303 | void todoDeleted(); |
304 | 304 | ||
305 | void updateView(const QDate &start, const QDate &end); | 305 | void updateView(const QDate &start, const QDate &end); |
306 | void updateView(); | 306 | void updateView(); |
307 | 307 | ||
308 | /** Full update of visible todo views */ | 308 | /** Full update of visible todo views */ |
309 | void updateTodoViews(); | 309 | void updateTodoViews(); |
310 | 310 | ||
311 | void updateUnmanagedViews(); | 311 | void updateUnmanagedViews(); |
312 | 312 | ||
313 | /** cut the current appointment to the clipboard */ | 313 | /** cut the current appointment to the clipboard */ |
314 | void edit_cut(); | 314 | void edit_cut(); |
315 | 315 | ||
316 | /** copy the current appointment(s) to the clipboard */ | 316 | /** copy the current appointment(s) to the clipboard */ |
317 | void edit_copy(); | 317 | void edit_copy(); |
318 | 318 | ||
319 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 319 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
320 | void edit_paste(); | 320 | void edit_paste(); |
321 | 321 | ||
322 | /** edit viewing and configuration options. */ | 322 | /** edit viewing and configuration options. */ |
323 | void edit_options(); | 323 | void edit_options(); |
324 | /** | 324 | /** |
325 | Functions for printing, previewing a print, and setting up printing | 325 | Functions for printing, previewing a print, and setting up printing |
326 | parameters. | 326 | parameters. |
327 | */ | 327 | */ |
328 | void print(); | 328 | void print(); |
329 | void printSetup(); | 329 | void printSetup(); |
330 | void printPreview(); | 330 | void printPreview(); |
331 | 331 | ||
332 | /** Export as iCalendar file */ | 332 | /** Export as iCalendar file */ |
333 | void exportICalendar(); | 333 | void exportICalendar(); |
334 | 334 | ||
335 | /** Export as vCalendar file */ | 335 | /** Export as vCalendar file */ |
336 | bool exportVCalendar( QString fn); | 336 | bool exportVCalendar( QString fn); |
337 | 337 | ||
338 | /** pop up a dialog to show an existing appointment. */ | 338 | /** pop up a dialog to show an existing appointment. */ |
339 | void appointment_show(); | 339 | void appointment_show(); |
340 | /** | 340 | /** |
341 | * pop up an Appointment Dialog to edit an existing appointment.Get | 341 | * pop up an Appointment Dialog to edit an existing appointment.Get |
342 | * information on the appointment from the list of unique IDs that is | 342 | * information on the appointment from the list of unique IDs that is |
343 | * currently in the View, called currIds. | 343 | * currently in the View, called currIds. |
344 | */ | 344 | */ |
345 | void appointment_edit(); | 345 | void appointment_edit(); |
346 | /** | 346 | /** |
347 | * pop up dialog confirming deletion of currently selected event in the | 347 | * pop up dialog confirming deletion of currently selected event in the |
348 | * View. | 348 | * View. |
349 | */ | 349 | */ |
350 | void appointment_delete(); | 350 | void appointment_delete(); |
351 | 351 | ||
352 | /** mails the currently selected event to a particular user as a vCalendar | 352 | /** mails the currently selected event to a particular user as a vCalendar |
353 | attachment. */ | 353 | attachment. */ |
354 | void action_mail(); | 354 | void action_mail(); |
355 | 355 | ||
356 | /* frees a subtodo from it's relation */ | 356 | /* frees a subtodo from it's relation */ |
357 | void todo_unsub( Todo * ); | 357 | void todo_unsub( Todo * ); |
358 | void todo_resub( Todo * parent, Todo * sub ); | 358 | void todo_resub( Todo * parent, Todo * sub ); |
359 | 359 | ||
360 | /** Take ownership of selected event. */ | 360 | /** Take ownership of selected event. */ |
361 | void takeOverEvent(); | 361 | void takeOverEvent(); |
362 | 362 | ||
363 | /** Take ownership of all events in calendar. */ | 363 | /** Take ownership of all events in calendar. */ |
364 | void takeOverCalendar(); | 364 | void takeOverCalendar(); |
365 | 365 | ||
366 | /** query whether or not the calendar is "dirty". */ | 366 | /** query whether or not the calendar is "dirty". */ |
367 | bool isModified(); | 367 | bool isModified(); |
368 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 368 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
369 | void setModified(bool modified=true); | 369 | void setModified(bool modified=true); |
370 | 370 | ||
371 | /** query if the calendar is read-only. */ | 371 | /** query if the calendar is read-only. */ |
372 | bool isReadOnly(); | 372 | bool isReadOnly(); |
373 | /** set state of calendar to read-only */ | 373 | /** set state of calendar to read-only */ |
374 | void setReadOnly(bool readOnly=true); | 374 | void setReadOnly(bool readOnly=true); |
375 | 375 | ||
376 | void eventUpdated(Incidence *); | 376 | void eventUpdated(Incidence *); |
377 | 377 | ||
378 | /* iTIP scheduling actions */ | 378 | /* iTIP scheduling actions */ |
379 | void schedule_publish(Incidence *incidence = 0); | 379 | void schedule_publish(Incidence *incidence = 0); |
380 | void schedule_request(Incidence *incidence = 0); | 380 | void schedule_request(Incidence *incidence = 0); |
381 | void schedule_refresh(Incidence *incidence = 0); | 381 | void schedule_refresh(Incidence *incidence = 0); |
382 | void schedule_cancel(Incidence *incidence = 0); | 382 | void schedule_cancel(Incidence *incidence = 0); |
383 | void schedule_add(Incidence *incidence = 0); | 383 | void schedule_add(Incidence *incidence = 0); |
384 | void schedule_reply(Incidence *incidence = 0); | 384 | void schedule_reply(Incidence *incidence = 0); |
385 | void schedule_counter(Incidence *incidence = 0); | 385 | void schedule_counter(Incidence *incidence = 0); |
386 | void schedule_declinecounter(Incidence *incidence = 0); | 386 | void schedule_declinecounter(Incidence *incidence = 0); |
387 | void schedule_publish_freebusy(int daysToPublish = 30); | 387 | void schedule_publish_freebusy(int daysToPublish = 30); |
388 | 388 | ||
389 | void openAddressbook(); | 389 | void openAddressbook(); |
390 | 390 | ||
391 | void editFilters(); | 391 | void editFilters(); |
392 | void toggleFilerEnabled(); | 392 | void toggleFilerEnabled(); |
393 | QPtrList<CalFilter> filters(); | 393 | QPtrList<CalFilter> filters(); |
394 | void toggleFilter(); | 394 | void toggleFilter(); |
395 | void showFilter(bool visible); | 395 | void showFilter(bool visible); |
396 | void updateFilter(); | 396 | void updateFilter(); |
397 | void filterEdited(); | 397 | void filterEdited(); |
398 | void selectFilter( int ); | 398 | void selectFilter( int ); |
399 | KOFilterView *filterView(); | 399 | KOFilterView *filterView(); |
400 | 400 | ||
401 | void showIntro(); | 401 | void showIntro(); |
402 | 402 | ||
403 | /** Move the curdatepient view date to today */ | 403 | /** Move the curdatepient view date to today */ |
404 | void goToday(); | 404 | void goToday(); |
405 | 405 | ||
406 | /** Move to the next date(s) in the current view */ | 406 | /** Move to the next date(s) in the current view */ |
407 | void goNext(); | 407 | void goNext(); |
408 | 408 | ||
409 | /** Move to the previous date(s) in the current view */ | 409 | /** Move to the previous date(s) in the current view */ |
410 | void goPrevious(); | 410 | void goPrevious(); |
411 | /** Move to the next date(s) in the current view */ | 411 | /** Move to the next date(s) in the current view */ |
412 | void goNextMonth(); | 412 | void goNextMonth(); |
413 | 413 | ||
414 | /** Move to the previous date(s) in the current view */ | 414 | /** Move to the previous date(s) in the current view */ |
415 | void goPreviousMonth(); | 415 | void goPreviousMonth(); |
416 | 416 | ||
417 | void toggleExpand(); | 417 | void toggleExpand(); |
418 | void toggleDateNavigatorWidget(); | 418 | void toggleDateNavigatorWidget(); |
419 | void toggleAllDaySize(); | 419 | void toggleAllDaySize(); |
420 | void dialogClosing(Incidence *); | 420 | void dialogClosing(Incidence *); |
421 | 421 | ||
422 | /** Look for new messages in the inbox */ | 422 | /** Look for new messages in the inbox */ |
423 | void lookForIncomingMessages(); | 423 | void lookForIncomingMessages(); |
424 | /** Look for new messages in the outbox */ | 424 | /** Look for new messages in the outbox */ |
425 | void lookForOutgoingMessages(); | 425 | void lookForOutgoingMessages(); |
426 | 426 | ||
427 | void processMainViewSelection( Incidence * ); | 427 | void processMainViewSelection( Incidence * ); |
428 | void processTodoListSelection( Incidence * ); | 428 | void processTodoListSelection( Incidence * ); |
429 | 429 | ||
430 | void processIncidenceSelection( Incidence * ); | 430 | void processIncidenceSelection( Incidence * ); |
431 | 431 | ||
432 | void purgeCompleted(); | 432 | void purgeCompleted(); |
433 | bool removeCompletedSubTodos( Todo* ); | 433 | bool removeCompletedSubTodos( Todo* ); |
434 | void slotCalendarChanged(); | 434 | void slotCalendarChanged(); |
435 | bool importBday(); | 435 | bool importBday(); |
436 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 436 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
437 | bool importQtopia( const QString &categoriesFile, | 437 | bool importQtopia( const QString &categoriesFile, |
438 | const QString &datebookFile, | 438 | const QString &datebookFile, |
439 | const QString &tasklistFile ); | 439 | const QString &tasklistFile ); |
440 | void syncExternal( int mode ); | 440 | void syncExternal( int mode ); |
441 | void slotSelectPickerDate( QDate ) ; | 441 | void slotSelectPickerDate( QDate ) ; |
442 | void showDatePicker( ) ; | 442 | void showDatePicker( ) ; |
443 | void moveIncidence(Incidence *) ; | 443 | void moveIncidence(Incidence *) ; |
444 | void beamIncidence(Incidence *) ; | 444 | void beamIncidence(Incidence *) ; |
445 | void beamCalendar() ; | 445 | void beamCalendar() ; |
446 | void beamFilteredCalendar() ; | 446 | void beamFilteredCalendar() ; |
447 | void beamIncidenceList(QPtrList<Incidence>) ; | 447 | void beamIncidenceList(QPtrList<Incidence>) ; |
448 | void manageCategories(); | 448 | void manageCategories(); |
449 | int addCategories(); | 449 | int addCategories(); |
450 | void removeCategories(); | 450 | void removeCategories(); |
451 | void setSyncDevice( QString ); | 451 | void setSyncDevice( QString ); |
452 | void setSyncName( QString ); | 452 | void setSyncName( QString ); |
453 | protected slots: | 453 | protected slots: |
454 | void timerAlarm(); | 454 | void timerAlarm(); |
455 | void suspendAlarm(); | 455 | void suspendAlarm(); |
456 | void beamDone( Ir *ir ); | 456 | void beamDone( Ir *ir ); |
457 | /** Select a view or adapt the current view to display the specified dates. */ | 457 | /** Select a view or adapt the current view to display the specified dates. */ |
458 | void showDates( const KCal::DateList & ); | 458 | void showDates( const KCal::DateList & ); |
459 | void selectWeekNum ( int ); | 459 | void selectWeekNum ( int ); |
460 | 460 | ||
461 | public: | 461 | public: |
462 | // show a standard warning | 462 | // show a standard warning |
463 | // returns KMsgBox::yesNoCancel() | 463 | // returns KMsgBox::yesNoCancel() |
464 | int msgCalModified(); | 464 | int msgCalModified(); |
465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 465 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
466 | 466 | ||
467 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 467 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
468 | virtual void removeSyncInfo( QString syncProfile); | 468 | virtual void removeSyncInfo( QString syncProfile); |
469 | void setSyncManager(KSyncManager* manager); | 469 | void setSyncManager(KSyncManager* manager); |
470 | void setLoadedFileVersion(QDateTime); | 470 | void setLoadedFileVersion(QDateTime); |
471 | bool checkFileVersion(QString fn); | 471 | bool checkFileVersion(QString fn); |
472 | bool checkFileChanged(QString fn); | 472 | bool checkFileChanged(QString fn); |
473 | Event* getLastSyncEvent(); | 473 | Event* getLastSyncEvent(); |
474 | /** Adapt navigation units correpsonding to step size of navigation of the | 474 | /** Adapt navigation units correpsonding to step size of navigation of the |
475 | * current view. | 475 | * current view. |
476 | */ | 476 | */ |
477 | void adaptNavigationUnits(); | 477 | void adaptNavigationUnits(); |
478 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 478 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
479 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 479 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
480 | //Attendee* getYourAttendee(Event *event); | 480 | //Attendee* getYourAttendee(Event *event); |
481 | protected: | 481 | protected: |
482 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 482 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
483 | 483 | ||
484 | // returns KMsgBox::OKCandel() | 484 | // returns KMsgBox::OKCandel() |
485 | int msgItemDelete(); | 485 | int msgItemDelete(); |
486 | void showEventEditor(); | 486 | void showEventEditor(); |
487 | void showTodoEditor(); | 487 | void showTodoEditor(); |
488 | void writeLocale(); | 488 | void writeLocale(); |
489 | Todo *selectedTodo(); | 489 | Todo *selectedTodo(); |
490 | 490 | ||
491 | private: | 491 | private: |
492 | bool mSyncKDE; | ||
493 | KSyncManager* mSyncManager; | 492 | KSyncManager* mSyncManager; |
494 | AlarmDialog * mAlarmDialog; | 493 | AlarmDialog * mAlarmDialog; |
495 | QString mAlarmNotification; | 494 | QString mAlarmNotification; |
496 | QString mSuspendAlarmNotification; | 495 | QString mSuspendAlarmNotification; |
497 | QTimer* mSuspendTimer; | 496 | QTimer* mSuspendTimer; |
498 | QTimer* mAlarmTimer; | 497 | QTimer* mAlarmTimer; |
499 | QTimer* mRecheckAlarmTimer; | 498 | QTimer* mRecheckAlarmTimer; |
500 | void computeAlarm( QString ); | 499 | void computeAlarm( QString ); |
501 | void startAlarm( QString, QString ); | 500 | void startAlarm( QString, QString ); |
502 | void setSyncEventsReadOnly(); | 501 | void setSyncEventsReadOnly(); |
503 | 502 | ||
504 | QDateTime loadedFileVersion; | 503 | QDateTime loadedFileVersion; |
505 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 504 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
506 | void checkExternalId( Incidence * inc ); | 505 | void checkExternalId( Incidence * inc ); |
507 | int mGlobalSyncMode; | 506 | int mGlobalSyncMode; |
508 | QString mCurrentSyncDevice; | 507 | QString mCurrentSyncDevice; |
509 | QString mCurrentSyncName; | 508 | QString mCurrentSyncName; |
510 | KOBeamPrefs* beamDialog; | 509 | KOBeamPrefs* beamDialog; |
511 | void init(); | 510 | void init(); |
512 | int mDatePickerMode; | 511 | int mDatePickerMode; |
513 | bool mFlagEditDescription; | 512 | bool mFlagEditDescription; |
514 | QDateTime mLastCalendarSync; | 513 | QDateTime mLastCalendarSync; |
515 | void createPrinter(); | 514 | void createPrinter(); |
516 | 515 | ||
517 | void calendarModified( bool, Calendar * ); | 516 | void calendarModified( bool, Calendar * ); |
518 | 517 | ||
519 | CalPrinter *mCalPrinter; | 518 | CalPrinter *mCalPrinter; |
520 | 519 | ||
521 | QSplitter *mPanner; | 520 | QSplitter *mPanner; |
522 | QSplitter *mLeftSplitter; | 521 | QSplitter *mLeftSplitter; |
523 | QWidget *mLeftFrame; | 522 | QWidget *mLeftFrame; |
524 | QWidgetStack *mRightFrame; | 523 | QWidgetStack *mRightFrame; |
525 | 524 | ||
526 | KDatePicker* mDatePicker; | 525 | KDatePicker* mDatePicker; |
527 | QVBox* mDateFrame; | 526 | QVBox* mDateFrame; |
528 | NavigatorBar *mNavigatorBar; | 527 | NavigatorBar *mNavigatorBar; |
529 | 528 | ||
530 | KDateNavigator *mDateNavigator; // widget showing small month view. | 529 | KDateNavigator *mDateNavigator; // widget showing small month view. |
531 | 530 | ||
532 | KOFilterView *mFilterView; | 531 | KOFilterView *mFilterView; |
533 | 532 | ||
534 | ResourceView *mResourceView; | 533 | ResourceView *mResourceView; |
535 | 534 | ||
536 | // calendar object for this viewing instance | 535 | // calendar object for this viewing instance |
537 | Calendar *mCalendar; | 536 | Calendar *mCalendar; |
538 | 537 | ||
539 | CalendarResourceManager *mResourceManager; | 538 | CalendarResourceManager *mResourceManager; |
540 | 539 | ||
541 | FileStorage *mStorage; | 540 | FileStorage *mStorage; |
542 | 541 | ||
543 | DateNavigator *mNavigator; | 542 | DateNavigator *mNavigator; |
544 | 543 | ||
545 | KOViewManager *mViewManager; | 544 | KOViewManager *mViewManager; |
546 | KODialogManager *mDialogManager; | 545 | KODialogManager *mDialogManager; |
547 | 546 | ||
548 | // Calendar filters | 547 | // Calendar filters |
549 | QPtrList<CalFilter> mFilters; | 548 | QPtrList<CalFilter> mFilters; |
550 | 549 | ||
551 | // various housekeeping variables. | 550 | // various housekeeping variables. |
552 | bool mModified; // flag indicating if calendar is modified | 551 | bool mModified; // flag indicating if calendar is modified |
553 | bool mReadOnly; // flag indicating if calendar is read-only | 552 | bool mReadOnly; // flag indicating if calendar is read-only |
554 | QDate mSaveSingleDate; | 553 | QDate mSaveSingleDate; |
555 | 554 | ||
556 | Incidence *mSelectedIncidence; | 555 | Incidence *mSelectedIncidence; |
557 | Incidence *mMoveIncidence; | 556 | Incidence *mMoveIncidence; |
558 | KOTodoView *mTodoList; | 557 | KOTodoView *mTodoList; |
559 | KOEventEditor * mEventEditor; | 558 | KOEventEditor * mEventEditor; |
560 | KOTodoEditor * mTodoEditor; | 559 | KOTodoEditor * mTodoEditor; |
561 | KOEventViewerDialog * mEventViewerDialog; | 560 | KOEventViewerDialog * mEventViewerDialog; |
562 | void keyPressEvent ( QKeyEvent *e) ; | 561 | void keyPressEvent ( QKeyEvent *e) ; |
563 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 562 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
564 | }; | 563 | }; |
565 | 564 | ||
566 | 565 | ||
567 | class CalendarViewVisitor : public Incidence::Visitor | 566 | class CalendarViewVisitor : public Incidence::Visitor |
568 | { | 567 | { |
569 | public: | 568 | public: |
570 | CalendarViewVisitor() : mView( 0 ) {} | 569 | CalendarViewVisitor() : mView( 0 ) {} |
571 | 570 | ||
572 | bool act( Incidence *incidence, CalendarView *view ) | 571 | bool act( Incidence *incidence, CalendarView *view ) |
573 | { | 572 | { |
574 | mView = view; | 573 | mView = view; |
575 | return incidence->accept( *this ); | 574 | return incidence->accept( *this ); |
576 | } | 575 | } |
577 | 576 | ||
578 | protected: | 577 | protected: |
579 | CalendarView *mView; | 578 | CalendarView *mView; |
580 | }; | 579 | }; |
581 | 580 | ||
582 | class ShowIncidenceVisitor : public CalendarViewVisitor | 581 | class ShowIncidenceVisitor : public CalendarViewVisitor |
583 | { | 582 | { |
584 | protected: | 583 | protected: |
585 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 584 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
586 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 585 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
587 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 586 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
588 | }; | 587 | }; |
589 | 588 | ||
590 | class EditIncidenceVisitor : public CalendarViewVisitor | 589 | class EditIncidenceVisitor : public CalendarViewVisitor |
591 | { | 590 | { |
592 | protected: | 591 | protected: |
593 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 592 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
594 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 593 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
595 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 594 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
596 | }; | 595 | }; |
597 | 596 | ||
598 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 597 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
599 | { | 598 | { |
600 | protected: | 599 | protected: |
601 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 600 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
602 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 601 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
603 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 602 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
604 | }; | 603 | }; |
605 | 604 | ||
606 | #endif | 605 | #endif |