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