author | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-20 00:12:42 (UTC) |
commit | b01b669d88fa195261d29ecf73b1c69e608a5ebc (patch) (unidiff) | |
tree | c0e79d45242a764b49470d07a9c95be156c121cc /korganizer | |
parent | 3da2cfeab2edbe64a17251662e56668fe143f7a3 (diff) | |
download | kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.zip kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.gz kdepimpi-b01b669d88fa195261d29ecf73b1c69e608a5ebc.tar.bz2 |
more AB sync
-rw-r--r-- | korganizer/calendarview.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 0c75632..8e83723 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,1591 +1,1593 @@ | |||
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 | 66 | ||
67 | #include <libkcal/vcaldrag.h> | 67 | #include <libkcal/vcaldrag.h> |
68 | #include <libkcal/icaldrag.h> | 68 | #include <libkcal/icaldrag.h> |
69 | #include <libkcal/icalformat.h> | 69 | #include <libkcal/icalformat.h> |
70 | #include <libkcal/vcalformat.h> | 70 | #include <libkcal/vcalformat.h> |
71 | #include <libkcal/scheduler.h> | 71 | #include <libkcal/scheduler.h> |
72 | #include <libkcal/calendarlocal.h> | 72 | #include <libkcal/calendarlocal.h> |
73 | #include <libkcal/journal.h> | 73 | #include <libkcal/journal.h> |
74 | #include <libkcal/calfilter.h> | 74 | #include <libkcal/calfilter.h> |
75 | #include <libkcal/attendee.h> | 75 | #include <libkcal/attendee.h> |
76 | #include <libkcal/dndfactory.h> | 76 | #include <libkcal/dndfactory.h> |
77 | #include <libkcal/freebusy.h> | 77 | #include <libkcal/freebusy.h> |
78 | #include <libkcal/filestorage.h> | 78 | #include <libkcal/filestorage.h> |
79 | #include <libkcal/calendarresources.h> | 79 | #include <libkcal/calendarresources.h> |
80 | #include <libkcal/qtopiaformat.h> | 80 | #include <libkcal/qtopiaformat.h> |
81 | #include "../kalarmd/alarmdialog.h" | 81 | #include "../kalarmd/alarmdialog.h" |
82 | 82 | ||
83 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
84 | #include <libkcal/sharpformat.h> | 84 | #include <libkcal/sharpformat.h> |
85 | #endif | 85 | #endif |
86 | #include <libkcal/phoneformat.h> | 86 | #include <libkcal/phoneformat.h> |
87 | #ifndef KORG_NOMAIL | 87 | #ifndef KORG_NOMAIL |
88 | #include "komailclient.h" | 88 | #include "komailclient.h" |
89 | #endif | 89 | #endif |
90 | #ifndef KORG_NOPRINTER | 90 | #ifndef KORG_NOPRINTER |
91 | #include "calprinter.h" | 91 | #include "calprinter.h" |
92 | #endif | 92 | #endif |
93 | #ifndef KORG_NOPLUGINS | 93 | #ifndef KORG_NOPLUGINS |
94 | #include "kocore.h" | 94 | #include "kocore.h" |
95 | #endif | 95 | #endif |
96 | #include "koeventeditor.h" | 96 | #include "koeventeditor.h" |
97 | #include "kotodoeditor.h" | 97 | #include "kotodoeditor.h" |
98 | #include "koprefs.h" | 98 | #include "koprefs.h" |
99 | #include "koeventviewerdialog.h" | 99 | #include "koeventviewerdialog.h" |
100 | #include "publishdialog.h" | 100 | #include "publishdialog.h" |
101 | #include "kofilterview.h" | 101 | #include "kofilterview.h" |
102 | #include "koglobals.h" | 102 | #include "koglobals.h" |
103 | #include "koviewmanager.h" | 103 | #include "koviewmanager.h" |
104 | #include "koagendaview.h" | 104 | #include "koagendaview.h" |
105 | #include "kodialogmanager.h" | 105 | #include "kodialogmanager.h" |
106 | #include "outgoingdialog.h" | 106 | #include "outgoingdialog.h" |
107 | #include "incomingdialog.h" | 107 | #include "incomingdialog.h" |
108 | #include "statusdialog.h" | 108 | #include "statusdialog.h" |
109 | #include "kdatenavigator.h" | 109 | #include "kdatenavigator.h" |
110 | #include "kotodoview.h" | 110 | #include "kotodoview.h" |
111 | #include "datenavigator.h" | 111 | #include "datenavigator.h" |
112 | #include "resourceview.h" | 112 | #include "resourceview.h" |
113 | #include "navigatorbar.h" | 113 | #include "navigatorbar.h" |
114 | #include "searchdialog.h" | 114 | #include "searchdialog.h" |
115 | #include "mainwindow.h" | 115 | #include "mainwindow.h" |
116 | 116 | ||
117 | #include "calendarview.h" | 117 | #include "calendarview.h" |
118 | #ifndef DESKTOP_VERSION | 118 | #ifndef DESKTOP_VERSION |
119 | #include <qtopia/alarmserver.h> | 119 | #include <qtopia/alarmserver.h> |
120 | #endif | 120 | #endif |
121 | #ifndef _WIN32_ | 121 | #ifndef _WIN32_ |
122 | #include <stdlib.h> | 122 | #include <stdlib.h> |
123 | #include <stdio.h> | 123 | #include <stdio.h> |
124 | #include <unistd.h> | 124 | #include <unistd.h> |
125 | #else | 125 | #else |
126 | #include <qprocess.h> | 126 | #include <qprocess.h> |
127 | #endif | 127 | #endif |
128 | using namespace KOrg; | 128 | using namespace KOrg; |
129 | using namespace KCal; | 129 | using namespace KCal; |
130 | extern int globalFlagBlockAgenda; | 130 | extern int globalFlagBlockAgenda; |
131 | extern int globalFlagBlockStartup; | 131 | extern int globalFlagBlockStartup; |
132 | 132 | ||
133 | 133 | ||
134 | 134 | ||
135 | class KOBeamPrefs : public QDialog | 135 | class KOBeamPrefs : public QDialog |
136 | { | 136 | { |
137 | public: | 137 | public: |
138 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 138 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
139 | QDialog( parent, name, true ) | 139 | QDialog( parent, name, true ) |
140 | { | 140 | { |
141 | setCaption( i18n("Beam Options") ); | 141 | setCaption( i18n("Beam Options") ); |
142 | QVBoxLayout* lay = new QVBoxLayout( this ); | 142 | QVBoxLayout* lay = new QVBoxLayout( this ); |
143 | lay->setSpacing( 3 ); | 143 | lay->setSpacing( 3 ); |
144 | lay->setMargin( 3 ); | 144 | lay->setMargin( 3 ); |
145 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 145 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
146 | lay->addWidget( format ); | 146 | lay->addWidget( format ); |
147 | format->setExclusive ( true ) ; | 147 | format->setExclusive ( true ) ; |
148 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 148 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
149 | lay->addWidget( time ); time->setExclusive ( true ) ; | 149 | lay->addWidget( time ); time->setExclusive ( true ) ; |
150 | vcal = new QRadioButton(" vCalendar ", format ); | 150 | vcal = new QRadioButton(" vCalendar ", format ); |
151 | ical = new QRadioButton(" iCalendar ", format ); | 151 | ical = new QRadioButton(" iCalendar ", format ); |
152 | vcal->setChecked( true ); | 152 | vcal->setChecked( true ); |
153 | tz = new QRadioButton(i18n(" With timezone "), time ); | 153 | tz = new QRadioButton(i18n(" With timezone "), time ); |
154 | local = new QRadioButton(i18n(" Local time "), time ); | 154 | local = new QRadioButton(i18n(" Local time "), time ); |
155 | tz->setChecked( true ); | 155 | tz->setChecked( true ); |
156 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 156 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
157 | lay->addWidget( ok ); | 157 | lay->addWidget( ok ); |
158 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 158 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
159 | lay->addWidget( cancel ); | 159 | lay->addWidget( cancel ); |
160 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 160 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
161 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 161 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
162 | resize( 200, 200 ); | 162 | resize( 200, 200 ); |
163 | } | 163 | } |
164 | 164 | ||
165 | bool beamVcal() { return vcal->isChecked(); } | 165 | bool beamVcal() { return vcal->isChecked(); } |
166 | bool beamLocal() { return local->isChecked(); } | 166 | bool beamLocal() { return local->isChecked(); } |
167 | private: | 167 | private: |
168 | QRadioButton* vcal, *ical, *local, *tz; | 168 | QRadioButton* vcal, *ical, *local, *tz; |
169 | }; | 169 | }; |
170 | class KOCatPrefs : public QDialog | 170 | class KOCatPrefs : public QDialog |
171 | { | 171 | { |
172 | public: | 172 | public: |
173 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 173 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
174 | QDialog( parent, name, true ) | 174 | QDialog( parent, name, true ) |
175 | { | 175 | { |
176 | setCaption( i18n("Manage new Categories") ); | 176 | setCaption( i18n("Manage new Categories") ); |
177 | QVBoxLayout* lay = new QVBoxLayout( this ); | 177 | QVBoxLayout* lay = new QVBoxLayout( this ); |
178 | lay->setSpacing( 3 ); | 178 | lay->setSpacing( 3 ); |
179 | lay->setMargin( 3 ); | 179 | lay->setMargin( 3 ); |
180 | 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 ); | 180 | 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 ); |
181 | lay->addWidget( lab ); | 181 | lay->addWidget( lab ); |
182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
183 | lay->addWidget( format ); | 183 | lay->addWidget( format ); |
184 | format->setExclusive ( true ) ; | 184 | format->setExclusive ( true ) ; |
185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
186 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 186 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
187 | addCatBut->setChecked( true ); | 187 | addCatBut->setChecked( true ); |
188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
189 | lay->addWidget( ok ); | 189 | lay->addWidget( ok ); |
190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
191 | lay->addWidget( cancel ); | 191 | lay->addWidget( cancel ); |
192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
194 | resize( 200, 200 ); | 194 | resize( 200, 200 ); |
195 | } | 195 | } |
196 | 196 | ||
197 | bool addCat() { return addCatBut->isChecked(); } | 197 | bool addCat() { return addCatBut->isChecked(); } |
198 | private: | 198 | private: |
199 | QRadioButton* addCatBut; | 199 | QRadioButton* addCatBut; |
200 | }; | 200 | }; |
201 | 201 | ||
202 | 202 | ||
203 | 203 | ||
204 | CalendarView::CalendarView( CalendarResources *calendar, | 204 | CalendarView::CalendarView( CalendarResources *calendar, |
205 | QWidget *parent, const char *name ) | 205 | QWidget *parent, const char *name ) |
206 | : CalendarViewBase( parent, name ), | 206 | : CalendarViewBase( parent, name ), |
207 | mCalendar( calendar ), | 207 | mCalendar( calendar ), |
208 | mResourceManager( calendar->resourceManager() ) | 208 | mResourceManager( calendar->resourceManager() ) |
209 | { | 209 | { |
210 | 210 | ||
211 | mEventEditor = 0; | 211 | mEventEditor = 0; |
212 | mTodoEditor = 0; | 212 | mTodoEditor = 0; |
213 | 213 | ||
214 | init(); | 214 | init(); |
215 | } | 215 | } |
216 | 216 | ||
217 | CalendarView::CalendarView( Calendar *calendar, | 217 | CalendarView::CalendarView( Calendar *calendar, |
218 | QWidget *parent, const char *name ) | 218 | QWidget *parent, const char *name ) |
219 | : CalendarViewBase( parent, name ), | 219 | : CalendarViewBase( parent, name ), |
220 | mCalendar( calendar ), | 220 | mCalendar( calendar ), |
221 | mResourceManager( 0 ) | 221 | mResourceManager( 0 ) |
222 | { | 222 | { |
223 | 223 | ||
224 | mEventEditor = 0; | 224 | mEventEditor = 0; |
225 | mTodoEditor = 0; | 225 | mTodoEditor = 0; |
226 | init();} | 226 | init();} |
227 | 227 | ||
228 | void CalendarView::init() | 228 | void CalendarView::init() |
229 | { | 229 | { |
230 | beamDialog = new KOBeamPrefs(); | 230 | beamDialog = new KOBeamPrefs(); |
231 | mDatePickerMode = 0; | 231 | mDatePickerMode = 0; |
232 | mCurrentSyncDevice = ""; | 232 | mCurrentSyncDevice = ""; |
233 | writeLocale(); | 233 | writeLocale(); |
234 | mViewManager = new KOViewManager( this ); | 234 | mViewManager = new KOViewManager( this ); |
235 | mDialogManager = new KODialogManager( this ); | 235 | mDialogManager = new KODialogManager( this ); |
236 | mEventViewerDialog = 0; | 236 | mEventViewerDialog = 0; |
237 | mModified = false; | 237 | mModified = false; |
238 | mReadOnly = false; | 238 | mReadOnly = false; |
239 | mSelectedIncidence = 0; | 239 | mSelectedIncidence = 0; |
240 | mCalPrinter = 0; | 240 | mCalPrinter = 0; |
241 | mFilters.setAutoDelete(true); | 241 | mFilters.setAutoDelete(true); |
242 | 242 | ||
243 | mCalendar->registerObserver( this ); | 243 | mCalendar->registerObserver( this ); |
244 | // TODO: Make sure that view is updated, when calendar is changed. | 244 | // TODO: Make sure that view is updated, when calendar is changed. |
245 | 245 | ||
246 | mStorage = new FileStorage( mCalendar ); | 246 | mStorage = new FileStorage( mCalendar ); |
247 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 247 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
248 | 248 | ||
249 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 249 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
250 | #ifndef KORG_NOSPLITTER | 250 | #ifndef KORG_NOSPLITTER |
251 | // create the main layout frames. | 251 | // create the main layout frames. |
252 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 252 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
253 | topLayout->addWidget(mPanner); | 253 | topLayout->addWidget(mPanner); |
254 | 254 | ||
255 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 255 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
256 | "CalendarView::LeftFrame"); | 256 | "CalendarView::LeftFrame"); |
257 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 257 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
258 | 258 | ||
259 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 259 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
260 | "CalendarView::DateNavigator", QDate::currentDate() ); | 260 | "CalendarView::DateNavigator", QDate::currentDate() ); |
261 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 261 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
262 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 262 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
263 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 263 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
264 | 264 | ||
265 | #ifdef KORG_NORESOURCEVIEW | 265 | #ifdef KORG_NORESOURCEVIEW |
266 | mResourceView = 0; | 266 | mResourceView = 0; |
267 | #else | 267 | #else |
268 | if ( mResourceManager ) { | 268 | if ( mResourceManager ) { |
269 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 269 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
270 | mResourceView->updateView(); | 270 | mResourceView->updateView(); |
271 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 271 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
272 | SLOT( updateView() ) ); | 272 | SLOT( updateView() ) ); |
273 | } else { | 273 | } else { |
274 | mResourceView = 0; | 274 | mResourceView = 0; |
275 | } | 275 | } |
276 | #endif | 276 | #endif |
277 | QWidget *rightBox = new QWidget( mPanner ); | 277 | QWidget *rightBox = new QWidget( mPanner ); |
278 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 278 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
279 | 279 | ||
280 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 280 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
281 | rightLayout->addWidget( mNavigatorBar ); | 281 | rightLayout->addWidget( mNavigatorBar ); |
282 | 282 | ||
283 | mRightFrame = new QWidgetStack( rightBox ); | 283 | mRightFrame = new QWidgetStack( rightBox ); |
284 | rightLayout->addWidget( mRightFrame, 1 ); | 284 | rightLayout->addWidget( mRightFrame, 1 ); |
285 | 285 | ||
286 | mLeftFrame = mLeftSplitter; | 286 | mLeftFrame = mLeftSplitter; |
287 | #else | 287 | #else |
288 | QWidget *mainBox = new QWidget( this ); | 288 | QWidget *mainBox = new QWidget( this ); |
289 | QWidget *leftFrame = new QWidget( mainBox ); | 289 | QWidget *leftFrame = new QWidget( mainBox ); |
290 | 290 | ||
291 | QBoxLayout * mainBoxLayout; | 291 | QBoxLayout * mainBoxLayout; |
292 | QBoxLayout * leftFrameLayout; | 292 | QBoxLayout * leftFrameLayout; |
293 | if ( KOPrefs::instance()->mVerticalScreen ) { | 293 | if ( KOPrefs::instance()->mVerticalScreen ) { |
294 | mainBoxLayout = new QVBoxLayout(mainBox); | 294 | mainBoxLayout = new QVBoxLayout(mainBox); |
295 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 295 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
296 | } else { | 296 | } else { |
297 | mainBoxLayout = new QHBoxLayout(mainBox); | 297 | mainBoxLayout = new QHBoxLayout(mainBox); |
298 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 298 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
299 | } | 299 | } |
300 | topLayout->addWidget( mainBox ); | 300 | topLayout->addWidget( mainBox ); |
301 | mainBoxLayout->addWidget (leftFrame); | 301 | mainBoxLayout->addWidget (leftFrame); |
302 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 302 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
303 | "CalendarView::DateNavigator", QDate::currentDate()); | 303 | "CalendarView::DateNavigator", QDate::currentDate()); |
304 | // mDateNavigator->blockSignals( true ); | 304 | // mDateNavigator->blockSignals( true ); |
305 | leftFrameLayout->addWidget( mDateNavigator ); | 305 | leftFrameLayout->addWidget( mDateNavigator ); |
306 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 306 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
307 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); | 307 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); |
308 | 308 | ||
309 | if ( QApplication::desktop()->width() < 480 ) { | 309 | if ( QApplication::desktop()->width() < 480 ) { |
310 | leftFrameLayout->addWidget(mFilterView); | 310 | leftFrameLayout->addWidget(mFilterView); |
311 | leftFrameLayout->addWidget(mTodoList, 2 ); | 311 | leftFrameLayout->addWidget(mTodoList, 2 ); |
312 | 312 | ||
313 | } else { | 313 | } else { |
314 | leftFrameLayout->addWidget(mTodoList,2 ); | 314 | leftFrameLayout->addWidget(mTodoList,2 ); |
315 | leftFrameLayout->addWidget(mFilterView ); | 315 | leftFrameLayout->addWidget(mFilterView ); |
316 | } | 316 | } |
317 | mFilterView->hide(); | 317 | mFilterView->hide(); |
318 | QWidget *rightBox = new QWidget( mainBox ); | 318 | QWidget *rightBox = new QWidget( mainBox ); |
319 | mainBoxLayout->addWidget ( rightBox, 10 ); | 319 | mainBoxLayout->addWidget ( rightBox, 10 ); |
320 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 320 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
321 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 321 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
322 | mRightFrame = new QWidgetStack( rightBox ); | 322 | mRightFrame = new QWidgetStack( rightBox ); |
323 | rightLayout->addWidget( mNavigatorBar ); | 323 | rightLayout->addWidget( mNavigatorBar ); |
324 | rightLayout->addWidget( mRightFrame, 10 ); | 324 | rightLayout->addWidget( mRightFrame, 10 ); |
325 | 325 | ||
326 | mLeftFrame = leftFrame; | 326 | mLeftFrame = leftFrame; |
327 | if ( KOPrefs::instance()->mVerticalScreen ) { | 327 | if ( KOPrefs::instance()->mVerticalScreen ) { |
328 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 328 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
329 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 329 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
330 | } else { | 330 | } else { |
331 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 331 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
332 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 332 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
333 | } | 333 | } |
334 | 334 | ||
335 | //qDebug("Calendarview Size %d %d ", width(), height()); | 335 | //qDebug("Calendarview Size %d %d ", width(), height()); |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 338 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
339 | SLOT( showDates( const KCal::DateList & ) ) ); | 339 | SLOT( showDates( const KCal::DateList & ) ) ); |
340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
341 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 341 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
342 | 342 | ||
343 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 343 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
344 | mNavigator, SLOT( selectPreviousYear() ) ); | 344 | mNavigator, SLOT( selectPreviousYear() ) ); |
345 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 345 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
346 | mNavigator, SLOT( selectNextYear() ) ); | 346 | mNavigator, SLOT( selectNextYear() ) ); |
347 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 347 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
348 | mNavigator, SLOT( selectPreviousMonth() ) ); | 348 | mNavigator, SLOT( selectPreviousMonth() ) ); |
349 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 349 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
350 | mNavigator, SLOT( selectNextMonth() ) ); | 350 | mNavigator, SLOT( selectNextMonth() ) ); |
351 | 351 | ||
352 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 352 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
353 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 353 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
354 | 354 | ||
355 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 355 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
356 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 356 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
357 | 357 | ||
358 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 358 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
359 | mNavigator, SLOT( selectPreviousYear() ) ); | 359 | mNavigator, SLOT( selectPreviousYear() ) ); |
360 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 360 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
361 | mNavigator, SLOT( selectNextYear() ) ); | 361 | mNavigator, SLOT( selectNextYear() ) ); |
362 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 362 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
363 | mNavigator, SLOT( selectPreviousMonth() ) ); | 363 | mNavigator, SLOT( selectPreviousMonth() ) ); |
364 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 364 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
365 | mNavigator, SLOT( selectNextMonth() ) ); | 365 | mNavigator, SLOT( selectNextMonth() ) ); |
366 | 366 | ||
367 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 367 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
368 | mNavigator, SLOT( selectPrevious() ) ); | 368 | mNavigator, SLOT( selectPrevious() ) ); |
369 | connect( mDateNavigator, SIGNAL( goNext() ), | 369 | connect( mDateNavigator, SIGNAL( goNext() ), |
370 | mNavigator, SLOT( selectNext() ) ); | 370 | mNavigator, SLOT( selectNext() ) ); |
371 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 371 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
372 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 372 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
373 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 373 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
375 | 375 | ||
376 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 376 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
377 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 377 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
378 | 378 | ||
379 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 379 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
380 | SLOT( eventAdded( Event *) ) ); | 380 | SLOT( eventAdded( Event *) ) ); |
381 | 381 | ||
382 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 382 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
383 | 383 | ||
384 | connect( this, SIGNAL( configChanged() ), | 384 | connect( this, SIGNAL( configChanged() ), |
385 | mDateNavigator, SLOT( updateConfig() ) ); | 385 | mDateNavigator, SLOT( updateConfig() ) ); |
386 | 386 | ||
387 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 387 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
388 | SLOT( newTodo() ) ); | 388 | SLOT( newTodo() ) ); |
389 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 389 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
390 | SLOT( newSubTodo( Todo * ) ) ); | 390 | SLOT( newSubTodo( Todo * ) ) ); |
391 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 391 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
392 | SLOT( editTodo( Todo * ) ) ); | 392 | SLOT( editTodo( Todo * ) ) ); |
393 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 393 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
394 | SLOT( showTodo( Todo *) ) ); | 394 | SLOT( showTodo( Todo *) ) ); |
395 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
396 | SLOT( deleteTodo( Todo *) ) ); | 396 | SLOT( deleteTodo( Todo *) ) ); |
397 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 397 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
398 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 398 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
399 | SLOT( purgeCompleted() ) ); | 399 | SLOT( purgeCompleted() ) ); |
400 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 400 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
401 | SIGNAL( todoModified( Todo *, int ) ) ); | 401 | SIGNAL( todoModified( Todo *, int ) ) ); |
402 | 402 | ||
403 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 403 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
404 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 404 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
405 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 405 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
406 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 406 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
407 | 407 | ||
408 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 408 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
409 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 409 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
410 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 410 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
411 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 411 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
412 | 412 | ||
413 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 413 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
414 | this, SLOT ( todo_unsub( Todo * ) ) ); | 414 | this, SLOT ( todo_unsub( Todo * ) ) ); |
415 | 415 | ||
416 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 416 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
417 | SLOT( updateTodo( Todo *, int ) ) ); | 417 | SLOT( updateTodo( Todo *, int ) ) ); |
418 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 418 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
419 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 419 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
420 | 420 | ||
421 | 421 | ||
422 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 422 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
423 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 423 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
424 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 424 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
425 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 425 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | 430 | ||
431 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 431 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
432 | SLOT(checkClipboard())); | 432 | SLOT(checkClipboard())); |
433 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 433 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
434 | SLOT( processTodoListSelection( Incidence * ) ) ); | 434 | SLOT( processTodoListSelection( Incidence * ) ) ); |
435 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 435 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
436 | 436 | ||
437 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 437 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
438 | 438 | ||
439 | mDateFrame = new QVBox(0,0,WType_Popup); | 439 | mDateFrame = new QVBox(0,0,WType_Popup); |
440 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 440 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
441 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 441 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
442 | mDateFrame->setLineWidth(3); | 442 | mDateFrame->setLineWidth(3); |
443 | mDateFrame->hide(); | 443 | mDateFrame->hide(); |
444 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 444 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
445 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 445 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
446 | 446 | ||
447 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 447 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
448 | 448 | ||
449 | mEventEditor = mDialogManager->getEventEditor(); | 449 | mEventEditor = mDialogManager->getEventEditor(); |
450 | mTodoEditor = mDialogManager->getTodoEditor(); | 450 | mTodoEditor = mDialogManager->getTodoEditor(); |
451 | 451 | ||
452 | mFlagEditDescription = false; | 452 | mFlagEditDescription = false; |
453 | 453 | ||
454 | mSuspendTimer = new QTimer( this ); | 454 | mSuspendTimer = new QTimer( this ); |
455 | mAlarmTimer = new QTimer( this ); | 455 | mAlarmTimer = new QTimer( this ); |
456 | mRecheckAlarmTimer = new QTimer( this ); | 456 | mRecheckAlarmTimer = new QTimer( this ); |
457 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 457 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
460 | mAlarmDialog = new AlarmDialog( this ); | 460 | mAlarmDialog = new AlarmDialog( this ); |
461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
462 | mAlarmDialog->setServerNotification( false ); | 462 | mAlarmDialog->setServerNotification( false ); |
463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | CalendarView::~CalendarView() | 467 | CalendarView::~CalendarView() |
468 | { | 468 | { |
469 | // kdDebug() << "~CalendarView()" << endl; | 469 | // kdDebug() << "~CalendarView()" << endl; |
470 | //qDebug("CalendarView::~CalendarView() "); | 470 | //qDebug("CalendarView::~CalendarView() "); |
471 | delete mDialogManager; | 471 | delete mDialogManager; |
472 | delete mViewManager; | 472 | delete mViewManager; |
473 | delete mStorage; | 473 | delete mStorage; |
474 | delete mDateFrame ; | 474 | delete mDateFrame ; |
475 | delete beamDialog; | 475 | delete beamDialog; |
476 | //kdDebug() << "~CalendarView() done" << endl; | 476 | //kdDebug() << "~CalendarView() done" << endl; |
477 | } | 477 | } |
478 | void CalendarView::timerAlarm() | 478 | void CalendarView::timerAlarm() |
479 | { | 479 | { |
480 | //qDebug("CalendarView::timerAlarm() "); | 480 | //qDebug("CalendarView::timerAlarm() "); |
481 | computeAlarm(mAlarmNotification ); | 481 | computeAlarm(mAlarmNotification ); |
482 | } | 482 | } |
483 | 483 | ||
484 | void CalendarView::suspendAlarm() | 484 | void CalendarView::suspendAlarm() |
485 | { | 485 | { |
486 | //qDebug(" CalendarView::suspendAlarm() "); | 486 | //qDebug(" CalendarView::suspendAlarm() "); |
487 | computeAlarm(mSuspendAlarmNotification ); | 487 | computeAlarm(mSuspendAlarmNotification ); |
488 | 488 | ||
489 | } | 489 | } |
490 | 490 | ||
491 | void CalendarView::startAlarm( QString mess , QString filename) | 491 | void CalendarView::startAlarm( QString mess , QString filename) |
492 | { | 492 | { |
493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
495 | 495 | ||
496 | } | 496 | } |
497 | 497 | ||
498 | void CalendarView::checkNextTimerAlarm() | 498 | void CalendarView::checkNextTimerAlarm() |
499 | { | 499 | { |
500 | mCalendar->checkAlarmForIncidence( 0, true ); | 500 | mCalendar->checkAlarmForIncidence( 0, true ); |
501 | } | 501 | } |
502 | 502 | ||
503 | void CalendarView::computeAlarm( QString msg ) | 503 | void CalendarView::computeAlarm( QString msg ) |
504 | { | 504 | { |
505 | 505 | ||
506 | QString mess = msg; | 506 | QString mess = msg; |
507 | QString mAlarmMessage = mess.mid( 9 ); | 507 | QString mAlarmMessage = mess.mid( 9 ); |
508 | QString filename = MainWindow::resourcePath(); | 508 | QString filename = MainWindow::resourcePath(); |
509 | filename += "koalarm.wav"; | 509 | filename += "koalarm.wav"; |
510 | QString tempfilename; | 510 | QString tempfilename; |
511 | if ( mess.left( 13 ) == "suspend_alarm") { | 511 | if ( mess.left( 13 ) == "suspend_alarm") { |
512 | bool error = false; | 512 | bool error = false; |
513 | int len = mess.mid( 13 ).find("+++"); | 513 | int len = mess.mid( 13 ).find("+++"); |
514 | if ( len < 2 ) | 514 | if ( len < 2 ) |
515 | error = true; | 515 | error = true; |
516 | else { | 516 | else { |
517 | tempfilename = mess.mid( 13, len ); | 517 | tempfilename = mess.mid( 13, len ); |
518 | if ( !QFile::exists( tempfilename ) ) | 518 | if ( !QFile::exists( tempfilename ) ) |
519 | error = true; | 519 | error = true; |
520 | } | 520 | } |
521 | if ( ! error ) { | 521 | if ( ! error ) { |
522 | filename = tempfilename; | 522 | filename = tempfilename; |
523 | } | 523 | } |
524 | mAlarmMessage = mess.mid( 13+len+3 ); | 524 | mAlarmMessage = mess.mid( 13+len+3 ); |
525 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 525 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
526 | startAlarm( mAlarmMessage, filename); | 526 | startAlarm( mAlarmMessage, filename); |
527 | return; | 527 | return; |
528 | } | 528 | } |
529 | if ( mess.left( 11 ) == "timer_alarm") { | 529 | if ( mess.left( 11 ) == "timer_alarm") { |
530 | //mTimerTime = 0; | 530 | //mTimerTime = 0; |
531 | startAlarm( mess.mid( 11 ), filename ); | 531 | startAlarm( mess.mid( 11 ), filename ); |
532 | return; | 532 | return; |
533 | } | 533 | } |
534 | if ( mess.left( 10 ) == "proc_alarm") { | 534 | if ( mess.left( 10 ) == "proc_alarm") { |
535 | bool error = false; | 535 | bool error = false; |
536 | int len = mess.mid( 10 ).find("+++"); | 536 | int len = mess.mid( 10 ).find("+++"); |
537 | if ( len < 2 ) | 537 | if ( len < 2 ) |
538 | error = true; | 538 | error = true; |
539 | else { | 539 | else { |
540 | tempfilename = mess.mid( 10, len ); | 540 | tempfilename = mess.mid( 10, len ); |
541 | if ( !QFile::exists( tempfilename ) ) | 541 | if ( !QFile::exists( tempfilename ) ) |
542 | error = true; | 542 | error = true; |
543 | } | 543 | } |
544 | if ( error ) { | 544 | if ( error ) { |
545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
546 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 546 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
547 | } else { | 547 | } else { |
548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
549 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 549 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
550 | #ifndef _WIN32_ | 550 | #ifndef _WIN32_ |
551 | if ( vfork () == 0 ) { | 551 | if ( vfork () == 0 ) { |
552 | execl ( tempfilename.latin1(), 0 ); | 552 | execl ( tempfilename.latin1(), 0 ); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | #else | 555 | #else |
556 | QProcess* p = new QProcess(); | 556 | QProcess* p = new QProcess(); |
557 | p->addArgument( tempfilename.latin1() ); | 557 | p->addArgument( tempfilename.latin1() ); |
558 | p->start(); | 558 | p->start(); |
559 | return; | 559 | return; |
560 | #endif | 560 | #endif |
561 | 561 | ||
562 | return; | 562 | return; |
563 | } | 563 | } |
564 | 564 | ||
565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
566 | } | 566 | } |
567 | if ( mess.left( 11 ) == "audio_alarm") { | 567 | if ( mess.left( 11 ) == "audio_alarm") { |
568 | bool error = false; | 568 | bool error = false; |
569 | int len = mess.mid( 11 ).find("+++"); | 569 | int len = mess.mid( 11 ).find("+++"); |
570 | if ( len < 2 ) | 570 | if ( len < 2 ) |
571 | error = true; | 571 | error = true; |
572 | else { | 572 | else { |
573 | tempfilename = mess.mid( 11, len ); | 573 | tempfilename = mess.mid( 11, len ); |
574 | if ( !QFile::exists( tempfilename ) ) | 574 | if ( !QFile::exists( tempfilename ) ) |
575 | error = true; | 575 | error = true; |
576 | } | 576 | } |
577 | if ( ! error ) { | 577 | if ( ! error ) { |
578 | filename = tempfilename; | 578 | filename = tempfilename; |
579 | } | 579 | } |
580 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 580 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
581 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 581 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 9 ) == "cal_alarm") { | 583 | if ( mess.left( 9 ) == "cal_alarm") { |
584 | mAlarmMessage = mess.mid( 9 ) ; | 584 | mAlarmMessage = mess.mid( 9 ) ; |
585 | } | 585 | } |
586 | 586 | ||
587 | startAlarm( mAlarmMessage, filename ); | 587 | startAlarm( mAlarmMessage, filename ); |
588 | 588 | ||
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
593 | { | 593 | { |
594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
595 | 595 | ||
596 | mSuspendAlarmNotification = noti; | 596 | mSuspendAlarmNotification = noti; |
597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
599 | mSuspendTimer->start( ms , true ); | 599 | mSuspendTimer->start( ms , true ); |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
604 | { | 604 | { |
605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
607 | #ifndef DESKTOP_VERSION | 607 | #ifndef DESKTOP_VERSION |
608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
609 | #endif | 609 | #endif |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | int maxSec; | 612 | int maxSec; |
613 | //maxSec = 5; //testing only | 613 | //maxSec = 5; //testing only |
614 | maxSec = 86400+3600; // one day+1hour | 614 | maxSec = 86400+3600; // one day+1hour |
615 | mAlarmNotification = noti; | 615 | mAlarmNotification = noti; |
616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
617 | if ( sec > maxSec ) { | 617 | if ( sec > maxSec ) { |
618 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 618 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
620 | return; | 620 | return; |
621 | } else { | 621 | } else { |
622 | mRecheckAlarmTimer->stop(); | 622 | mRecheckAlarmTimer->stop(); |
623 | } | 623 | } |
624 | //qDebug("Alarm timer started with secs: %d ", sec); | 624 | //qDebug("Alarm timer started with secs: %d ", sec); |
625 | mAlarmTimer->start( sec *1000 , true ); | 625 | mAlarmTimer->start( sec *1000 , true ); |
626 | 626 | ||
627 | } | 627 | } |
628 | // called by mRecheckAlarmTimer to get next alarm | 628 | // called by mRecheckAlarmTimer to get next alarm |
629 | // we need this, because a QTimer has only a max range of 25 days | 629 | // we need this, because a QTimer has only a max range of 25 days |
630 | void CalendarView::recheckTimerAlarm() | 630 | void CalendarView::recheckTimerAlarm() |
631 | { | 631 | { |
632 | mAlarmTimer->stop(); | 632 | mAlarmTimer->stop(); |
633 | mRecheckAlarmTimer->stop(); | 633 | mRecheckAlarmTimer->stop(); |
634 | mCalendar->checkAlarmForIncidence( 0, true ); | 634 | mCalendar->checkAlarmForIncidence( 0, true ); |
635 | } | 635 | } |
636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
637 | { | 637 | { |
638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
640 | #ifndef DESKTOP_VERSION | 640 | #ifndef DESKTOP_VERSION |
641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
642 | #endif | 642 | #endif |
643 | return; | 643 | return; |
644 | } | 644 | } |
645 | mAlarmTimer->stop(); | 645 | mAlarmTimer->stop(); |
646 | } | 646 | } |
647 | void CalendarView::selectWeekNum ( int num ) | 647 | void CalendarView::selectWeekNum ( int num ) |
648 | { | 648 | { |
649 | dateNavigator()->selectWeek( num ); | 649 | dateNavigator()->selectWeek( num ); |
650 | mViewManager->showWeekView(); | 650 | mViewManager->showWeekView(); |
651 | } | 651 | } |
652 | KOViewManager *CalendarView::viewManager() | 652 | KOViewManager *CalendarView::viewManager() |
653 | { | 653 | { |
654 | return mViewManager; | 654 | return mViewManager; |
655 | } | 655 | } |
656 | 656 | ||
657 | KODialogManager *CalendarView::dialogManager() | 657 | KODialogManager *CalendarView::dialogManager() |
658 | { | 658 | { |
659 | return mDialogManager; | 659 | return mDialogManager; |
660 | } | 660 | } |
661 | 661 | ||
662 | QDate CalendarView::startDate() | 662 | QDate CalendarView::startDate() |
663 | { | 663 | { |
664 | DateList dates = mNavigator->selectedDates(); | 664 | DateList dates = mNavigator->selectedDates(); |
665 | 665 | ||
666 | return dates.first(); | 666 | return dates.first(); |
667 | } | 667 | } |
668 | 668 | ||
669 | QDate CalendarView::endDate() | 669 | QDate CalendarView::endDate() |
670 | { | 670 | { |
671 | DateList dates = mNavigator->selectedDates(); | 671 | DateList dates = mNavigator->selectedDates(); |
672 | 672 | ||
673 | return dates.last(); | 673 | return dates.last(); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | void CalendarView::createPrinter() | 677 | void CalendarView::createPrinter() |
678 | { | 678 | { |
679 | #ifndef KORG_NOPRINTER | 679 | #ifndef KORG_NOPRINTER |
680 | if (!mCalPrinter) { | 680 | if (!mCalPrinter) { |
681 | mCalPrinter = new CalPrinter(this, mCalendar); | 681 | mCalPrinter = new CalPrinter(this, mCalendar); |
682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | } | 685 | } |
686 | 686 | ||
687 | void CalendarView::confSync() | 687 | void CalendarView::confSync() |
688 | { | 688 | { |
689 | static KSyncPrefsDialog* sp = 0; | 689 | static KSyncPrefsDialog* sp = 0; |
690 | if ( ! sp ) { | 690 | if ( ! sp ) { |
691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
692 | } | 692 | } |
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
726 | // 2 take remote | 726 | // 2 take remote |
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | QDateTime localMod = local->lastModified(); | ||
730 | QDateTime remoteMod = remote->lastModified(); | ||
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 731 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 732 | bool remCh, locCh; |
731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 733 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
732 | //if ( remCh ) | 734 | //if ( remCh ) |
733 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 735 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
734 | locCh = ( local->lastModified() > mLastCalendarSync ); | 736 | locCh = ( localMod > mLastCalendarSync ); |
735 | if ( !remCh && ! locCh ) { | 737 | if ( !remCh && ! locCh ) { |
736 | //qDebug("both not changed "); | 738 | //qDebug("both not changed "); |
737 | lastSync = local->lastModified().addDays(1); | 739 | lastSync = localMod.addDays(1); |
738 | if ( mode <= SYNC_PREF_ASK ) | 740 | if ( mode <= SYNC_PREF_ASK ) |
739 | return 0; | 741 | return 0; |
740 | } else { | 742 | } else { |
741 | if ( locCh ) { | 743 | if ( locCh ) { |
742 | //qDebug("loc changed %d %s %s", local->revision() , local->lastModified().toString().latin1(), mLastCalendarSync.toString().latin1()); | 744 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
743 | lastSync = local->lastModified().addDays( -1 ); | 745 | lastSync = localMod.addDays( -1 ); |
744 | if ( !remCh ) | 746 | if ( !remCh ) |
745 | remote->setLastModified( lastSync.addDays( -1 ) ); | 747 | remoteMod = ( lastSync.addDays( -1 ) ); |
746 | } else { | 748 | } else { |
747 | //qDebug(" not loc changed "); | 749 | //qDebug(" not loc changed "); |
748 | lastSync = local->lastModified().addDays( 1 ); | 750 | lastSync = localMod.addDays( 1 ); |
749 | if ( remCh ) | 751 | if ( remCh ) |
750 | remote->setLastModified( lastSync.addDays( 1 ) ); | 752 | remoteMod =( lastSync.addDays( 1 ) ); |
751 | 753 | ||
752 | } | 754 | } |
753 | } | 755 | } |
754 | full = true; | 756 | full = true; |
755 | if ( mode < SYNC_PREF_ASK ) | 757 | if ( mode < SYNC_PREF_ASK ) |
756 | mode = SYNC_PREF_ASK; | 758 | mode = SYNC_PREF_ASK; |
757 | } else { | 759 | } else { |
758 | if ( local->lastModified() == remote->lastModified() ) | 760 | if ( localMod == remoteMod ) |
759 | if ( local->revision() == remote->revision() ) | 761 | if ( local->revision() == remote->revision() ) |
760 | return 0; | 762 | return 0; |
761 | 763 | ||
762 | } | 764 | } |
763 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 765 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
764 | 766 | ||
765 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 767 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
766 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 768 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
767 | //full = true; //debug only | 769 | //full = true; //debug only |
768 | if ( full ) { | 770 | if ( full ) { |
769 | bool equ = false; | 771 | bool equ = false; |
770 | if ( local->type() == "Event" ) { | 772 | if ( local->type() == "Event" ) { |
771 | equ = (*((Event*) local) == *((Event*) remote)); | 773 | equ = (*((Event*) local) == *((Event*) remote)); |
772 | } | 774 | } |
773 | else if ( local->type() =="Todo" ) | 775 | else if ( local->type() =="Todo" ) |
774 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 776 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
775 | else if ( local->type() =="Journal" ) | 777 | else if ( local->type() =="Journal" ) |
776 | equ = (*((Journal*) local) == *((Journal*) remote)); | 778 | equ = (*((Journal*) local) == *((Journal*) remote)); |
777 | if ( equ ) { | 779 | if ( equ ) { |
778 | //qDebug("equal "); | 780 | //qDebug("equal "); |
779 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 781 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
780 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 782 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
781 | } | 783 | } |
782 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 784 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
783 | return 0; | 785 | return 0; |
784 | 786 | ||
785 | }//else //debug only | 787 | }//else //debug only |
786 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 788 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
787 | } | 789 | } |
788 | int result; | 790 | int result; |
789 | bool localIsNew; | 791 | bool localIsNew; |
790 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); | 792 | //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() ); |
791 | 793 | ||
792 | if ( full && mode < SYNC_PREF_NEWEST ) | 794 | if ( full && mode < SYNC_PREF_NEWEST ) |
793 | mode = SYNC_PREF_ASK; | 795 | mode = SYNC_PREF_ASK; |
794 | 796 | ||
795 | switch( mode ) { | 797 | switch( mode ) { |
796 | case SYNC_PREF_LOCAL: | 798 | case SYNC_PREF_LOCAL: |
797 | if ( lastSync > remote->lastModified() ) | 799 | if ( lastSync > remoteMod ) |
798 | return 1; | 800 | return 1; |
799 | if ( lastSync > local->lastModified() ) | 801 | if ( lastSync > localMod ) |
800 | return 2; | 802 | return 2; |
801 | return 1; | 803 | return 1; |
802 | break; | 804 | break; |
803 | case SYNC_PREF_REMOTE: | 805 | case SYNC_PREF_REMOTE: |
804 | if ( lastSync > remote->lastModified() ) | 806 | if ( lastSync > remoteMod ) |
805 | return 1; | 807 | return 1; |
806 | if ( lastSync > local->lastModified() ) | 808 | if ( lastSync > localMod ) |
807 | return 2; | 809 | return 2; |
808 | return 2; | 810 | return 2; |
809 | break; | 811 | break; |
810 | case SYNC_PREF_NEWEST: | 812 | case SYNC_PREF_NEWEST: |
811 | if ( local->lastModified() > remote->lastModified() ) | 813 | if ( localMod > remoteMod ) |
812 | return 1; | 814 | return 1; |
813 | else | 815 | else |
814 | return 2; | 816 | return 2; |
815 | break; | 817 | break; |
816 | case SYNC_PREF_ASK: | 818 | case SYNC_PREF_ASK: |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 819 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | if ( lastSync > remote->lastModified() ) | 820 | if ( lastSync > remoteMod ) |
819 | return 1; | 821 | return 1; |
820 | if ( lastSync > local->lastModified() ) | 822 | if ( lastSync > localMod ) |
821 | return 2; | 823 | return 2; |
822 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 824 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
823 | localIsNew = local->lastModified() >= remote->lastModified(); | 825 | localIsNew = localMod >= remoteMod; |
824 | if ( localIsNew ) | 826 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
826 | else | 828 | else |
827 | getEventViewerDialog()->setColorMode( 2 ); | 829 | getEventViewerDialog()->setColorMode( 2 ); |
828 | getEventViewerDialog()->setIncidence(local); | 830 | getEventViewerDialog()->setIncidence(local); |
829 | if ( localIsNew ) | 831 | if ( localIsNew ) |
830 | getEventViewerDialog()->setColorMode( 2 ); | 832 | getEventViewerDialog()->setColorMode( 2 ); |
831 | else | 833 | else |
832 | getEventViewerDialog()->setColorMode( 1 ); | 834 | getEventViewerDialog()->setColorMode( 1 ); |
833 | getEventViewerDialog()->addIncidence(remote); | 835 | getEventViewerDialog()->addIncidence(remote); |
834 | getEventViewerDialog()->setColorMode( 0 ); | 836 | getEventViewerDialog()->setColorMode( 0 ); |
835 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 837 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
836 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 838 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
837 | getEventViewerDialog()->showMe(); | 839 | getEventViewerDialog()->showMe(); |
838 | result = getEventViewerDialog()->executeS( localIsNew ); | 840 | result = getEventViewerDialog()->executeS( localIsNew ); |
839 | return result; | 841 | return result; |
840 | 842 | ||
841 | break; | 843 | break; |
842 | case SYNC_PREF_FORCE_LOCAL: | 844 | case SYNC_PREF_FORCE_LOCAL: |
843 | return 1; | 845 | return 1; |
844 | break; | 846 | break; |
845 | case SYNC_PREF_FORCE_REMOTE: | 847 | case SYNC_PREF_FORCE_REMOTE: |
846 | return 2; | 848 | return 2; |
847 | break; | 849 | break; |
848 | 850 | ||
849 | default: | 851 | default: |
850 | // SYNC_PREF_TAKE_BOTH not implemented | 852 | // SYNC_PREF_TAKE_BOTH not implemented |
851 | break; | 853 | break; |
852 | } | 854 | } |
853 | return 0; | 855 | return 0; |
854 | } | 856 | } |
855 | Event* CalendarView::getLastSyncEvent() | 857 | Event* CalendarView::getLastSyncEvent() |
856 | { | 858 | { |
857 | Event* lse; | 859 | Event* lse; |
858 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 860 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
859 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 861 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
860 | if (!lse) { | 862 | if (!lse) { |
861 | lse = new Event(); | 863 | lse = new Event(); |
862 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 864 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
863 | QString sum = ""; | 865 | QString sum = ""; |
864 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 866 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
865 | sum = "E: "; | 867 | sum = "E: "; |
866 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 868 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
867 | lse->setDtStart( mLastCalendarSync ); | 869 | lse->setDtStart( mLastCalendarSync ); |
868 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 870 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
869 | lse->setCategories( i18n("SyncEvent") ); | 871 | lse->setCategories( i18n("SyncEvent") ); |
870 | lse->setReadOnly( true ); | 872 | lse->setReadOnly( true ); |
871 | mCalendar->addEvent( lse ); | 873 | mCalendar->addEvent( lse ); |
872 | } | 874 | } |
873 | 875 | ||
874 | return lse; | 876 | return lse; |
875 | 877 | ||
876 | } | 878 | } |
877 | // probaly useless | 879 | // probaly useless |
878 | void CalendarView::setupExternSyncProfiles() | 880 | void CalendarView::setupExternSyncProfiles() |
879 | { | 881 | { |
880 | Event* lse; | 882 | Event* lse; |
881 | mExternLastSyncEvent.clear(); | 883 | mExternLastSyncEvent.clear(); |
882 | int i; | 884 | int i; |
883 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 885 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
884 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 886 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
885 | if ( lse ) | 887 | if ( lse ) |
886 | mExternLastSyncEvent.append( lse ); | 888 | mExternLastSyncEvent.append( lse ); |
887 | else | 889 | else |
888 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 890 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
889 | } | 891 | } |
890 | 892 | ||
891 | } | 893 | } |
892 | // we check, if the to delete event has a id for a profile | 894 | // we check, if the to delete event has a id for a profile |
893 | // if yes, we set this id in the profile to delete | 895 | // if yes, we set this id in the profile to delete |
894 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 896 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
895 | { | 897 | { |
896 | if ( lastSync.count() == 0 ) { | 898 | if ( lastSync.count() == 0 ) { |
897 | //qDebug(" lastSync.count() == 0"); | 899 | //qDebug(" lastSync.count() == 0"); |
898 | return; | 900 | return; |
899 | } | 901 | } |
900 | if ( toDelete->type() == "Journal" ) | 902 | if ( toDelete->type() == "Journal" ) |
901 | return; | 903 | return; |
902 | 904 | ||
903 | Event* eve = lastSync.first(); | 905 | Event* eve = lastSync.first(); |
904 | 906 | ||
905 | while ( eve ) { | 907 | while ( eve ) { |
906 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 908 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
907 | if ( !id.isEmpty() ) { | 909 | if ( !id.isEmpty() ) { |
908 | QString des = eve->description(); | 910 | QString des = eve->description(); |
909 | QString pref = "e"; | 911 | QString pref = "e"; |
910 | if ( toDelete->type() == "Todo" ) | 912 | if ( toDelete->type() == "Todo" ) |
911 | pref = "t"; | 913 | pref = "t"; |
912 | des += pref+ id + ","; | 914 | des += pref+ id + ","; |
913 | eve->setReadOnly( false ); | 915 | eve->setReadOnly( false ); |
914 | eve->setDescription( des ); | 916 | eve->setDescription( des ); |
915 | //qDebug("setdes %s ", des.latin1()); | 917 | //qDebug("setdes %s ", des.latin1()); |
916 | eve->setReadOnly( true ); | 918 | eve->setReadOnly( true ); |
917 | } | 919 | } |
918 | eve = lastSync.next(); | 920 | eve = lastSync.next(); |
919 | } | 921 | } |
920 | 922 | ||
921 | } | 923 | } |
922 | void CalendarView::checkExternalId( Incidence * inc ) | 924 | void CalendarView::checkExternalId( Incidence * inc ) |
923 | { | 925 | { |
924 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 926 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
925 | checkExternSyncEvent( lastSync, inc ); | 927 | checkExternSyncEvent( lastSync, inc ); |
926 | 928 | ||
927 | } | 929 | } |
928 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 930 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
929 | { | 931 | { |
930 | bool syncOK = true; | 932 | bool syncOK = true; |
931 | int addedEvent = 0; | 933 | int addedEvent = 0; |
932 | int addedEventR = 0; | 934 | int addedEventR = 0; |
933 | int deletedEventR = 0; | 935 | int deletedEventR = 0; |
934 | int deletedEventL = 0; | 936 | int deletedEventL = 0; |
935 | int changedLocal = 0; | 937 | int changedLocal = 0; |
936 | int changedRemote = 0; | 938 | int changedRemote = 0; |
937 | //QPtrList<Event> el = local->rawEvents(); | 939 | //QPtrList<Event> el = local->rawEvents(); |
938 | Event* eventR; | 940 | Event* eventR; |
939 | QString uid; | 941 | QString uid; |
940 | int take; | 942 | int take; |
941 | Event* eventL; | 943 | Event* eventL; |
942 | Event* eventRSync; | 944 | Event* eventRSync; |
943 | Event* eventLSync; | 945 | Event* eventLSync; |
944 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 946 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
945 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 947 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
946 | bool fullDateRange = false; | 948 | bool fullDateRange = false; |
947 | local->resetTempSyncStat(); | 949 | local->resetTempSyncStat(); |
948 | mLastCalendarSync = QDateTime::currentDateTime(); | 950 | mLastCalendarSync = QDateTime::currentDateTime(); |
949 | QDateTime modifiedCalendar = mLastCalendarSync;; | 951 | QDateTime modifiedCalendar = mLastCalendarSync;; |
950 | eventLSync = getLastSyncEvent(); | 952 | eventLSync = getLastSyncEvent(); |
951 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 953 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
952 | if ( eventR ) { | 954 | if ( eventR ) { |
953 | eventRSync = (Event*) eventR->clone(); | 955 | eventRSync = (Event*) eventR->clone(); |
954 | remote->deleteEvent(eventR ); | 956 | remote->deleteEvent(eventR ); |
955 | 957 | ||
956 | } else { | 958 | } else { |
957 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 959 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
958 | eventRSync = (Event*)eventLSync->clone(); | 960 | eventRSync = (Event*)eventLSync->clone(); |
959 | } else { | 961 | } else { |
960 | fullDateRange = true; | 962 | fullDateRange = true; |
961 | eventRSync = new Event(); | 963 | eventRSync = new Event(); |
962 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 964 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
963 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 965 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
964 | eventRSync->setDtStart( mLastCalendarSync ); | 966 | eventRSync->setDtStart( mLastCalendarSync ); |
965 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 967 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
966 | eventRSync->setCategories( i18n("SyncEvent") ); | 968 | eventRSync->setCategories( i18n("SyncEvent") ); |
967 | } | 969 | } |
968 | } | 970 | } |
969 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 971 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
970 | fullDateRange = true; | 972 | fullDateRange = true; |
971 | 973 | ||
972 | if ( ! fullDateRange ) { | 974 | if ( ! fullDateRange ) { |
973 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 975 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
974 | 976 | ||
975 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 977 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
976 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 978 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
977 | fullDateRange = true; | 979 | fullDateRange = true; |
978 | } | 980 | } |
979 | } | 981 | } |
980 | if ( fullDateRange ) | 982 | if ( fullDateRange ) |
981 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 983 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
982 | else | 984 | else |
983 | mLastCalendarSync = eventLSync->dtStart(); | 985 | mLastCalendarSync = eventLSync->dtStart(); |
984 | // for resyncing if own file has changed | 986 | // for resyncing if own file has changed |
985 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 987 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
986 | mLastCalendarSync = loadedFileVersion; | 988 | mLastCalendarSync = loadedFileVersion; |
987 | qDebug("setting mLastCalendarSync "); | 989 | qDebug("setting mLastCalendarSync "); |
988 | } | 990 | } |
989 | //qDebug("*************************** "); | 991 | //qDebug("*************************** "); |
990 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 992 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
991 | QPtrList<Incidence> er = remote->rawIncidences(); | 993 | QPtrList<Incidence> er = remote->rawIncidences(); |
992 | Incidence* inR = er.first(); | 994 | Incidence* inR = er.first(); |
993 | Incidence* inL; | 995 | Incidence* inL; |
994 | QProgressBar bar( er.count(),0 ); | 996 | QProgressBar bar( er.count(),0 ); |
995 | bar.setCaption (i18n("Syncing - close to abort!") ); | 997 | bar.setCaption (i18n("Syncing - close to abort!") ); |
996 | 998 | ||
997 | int w = 300; | 999 | int w = 300; |
998 | if ( QApplication::desktop()->width() < 320 ) | 1000 | if ( QApplication::desktop()->width() < 320 ) |
999 | w = 220; | 1001 | w = 220; |
1000 | int h = bar.sizeHint().height() ; | 1002 | int h = bar.sizeHint().height() ; |
1001 | int dw = QApplication::desktop()->width(); | 1003 | int dw = QApplication::desktop()->width(); |
1002 | int dh = QApplication::desktop()->height(); | 1004 | int dh = QApplication::desktop()->height(); |
1003 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1005 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1004 | bar.show(); | 1006 | bar.show(); |
1005 | int modulo = (er.count()/10)+1; | 1007 | int modulo = (er.count()/10)+1; |
1006 | int incCounter = 0; | 1008 | int incCounter = 0; |
1007 | while ( inR ) { | 1009 | while ( inR ) { |
1008 | if ( ! bar.isVisible() ) | 1010 | if ( ! bar.isVisible() ) |
1009 | return false; | 1011 | return false; |
1010 | if ( incCounter % modulo == 0 ) | 1012 | if ( incCounter % modulo == 0 ) |
1011 | bar.setProgress( incCounter ); | 1013 | bar.setProgress( incCounter ); |
1012 | ++incCounter; | 1014 | ++incCounter; |
1013 | uid = inR->uid(); | 1015 | uid = inR->uid(); |
1014 | bool skipIncidence = false; | 1016 | bool skipIncidence = false; |
1015 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1017 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1016 | skipIncidence = true; | 1018 | skipIncidence = true; |
1017 | QString idS; | 1019 | QString idS; |
1018 | qApp->processEvents(); | 1020 | qApp->processEvents(); |
1019 | if ( !skipIncidence ) { | 1021 | if ( !skipIncidence ) { |
1020 | inL = local->incidence( uid ); | 1022 | inL = local->incidence( uid ); |
1021 | if ( inL ) { // maybe conflict - same uid in both calendars | 1023 | if ( inL ) { // maybe conflict - same uid in both calendars |
1022 | int maxrev = inL->revision(); | 1024 | int maxrev = inL->revision(); |
1023 | if ( maxrev < inR->revision() ) | 1025 | if ( maxrev < inR->revision() ) |
1024 | maxrev = inR->revision(); | 1026 | maxrev = inR->revision(); |
1025 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1027 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1026 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1028 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1027 | if ( take == 3 ) | 1029 | if ( take == 3 ) |
1028 | return false; | 1030 | return false; |
1029 | if ( take == 1 ) {// take local | 1031 | if ( take == 1 ) {// take local |
1030 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1032 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1031 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1033 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1032 | else | 1034 | else |
1033 | idS = inR->IDStr(); | 1035 | idS = inR->IDStr(); |
1034 | remote->deleteIncidence( inR ); | 1036 | remote->deleteIncidence( inR ); |
1035 | if ( inL->revision() < maxrev ) | 1037 | if ( inL->revision() < maxrev ) |
1036 | inL->setRevision( maxrev ); | 1038 | inL->setRevision( maxrev ); |
1037 | inR = inL->clone(); | 1039 | inR = inL->clone(); |
1038 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1040 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1039 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1041 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1040 | inR->setIDStr( idS ); | 1042 | inR->setIDStr( idS ); |
1041 | remote->addIncidence( inR ); | 1043 | remote->addIncidence( inR ); |
1042 | ++changedRemote; | 1044 | ++changedRemote; |
1043 | } else { | 1045 | } else { |
1044 | if ( inR->revision() < maxrev ) | 1046 | if ( inR->revision() < maxrev ) |
1045 | inR->setRevision( maxrev ); | 1047 | inR->setRevision( maxrev ); |
1046 | idS = inL->IDStr(); | 1048 | idS = inL->IDStr(); |
1047 | local->deleteIncidence( inL ); | 1049 | local->deleteIncidence( inL ); |
1048 | inL = inR->clone(); | 1050 | inL = inR->clone(); |
1049 | inL->setIDStr( idS ); | 1051 | inL->setIDStr( idS ); |
1050 | local->addIncidence( inL ); | 1052 | local->addIncidence( inL ); |
1051 | ++changedLocal; | 1053 | ++changedLocal; |
1052 | } | 1054 | } |
1053 | } | 1055 | } |
1054 | } else { // no conflict | 1056 | } else { // no conflict |
1055 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1057 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1056 | QString des = eventLSync->description(); | 1058 | QString des = eventLSync->description(); |
1057 | QString pref = "e"; | 1059 | QString pref = "e"; |
1058 | if ( inR->type() == "Todo" ) | 1060 | if ( inR->type() == "Todo" ) |
1059 | pref = "t"; | 1061 | pref = "t"; |
1060 | 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 |
1061 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1063 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1062 | //remote->deleteIncidence( inR ); | 1064 | //remote->deleteIncidence( inR ); |
1063 | ++deletedEventR; | 1065 | ++deletedEventR; |
1064 | } else { | 1066 | } else { |
1065 | inR->setLastModified( modifiedCalendar ); | 1067 | inR->setLastModified( modifiedCalendar ); |
1066 | inL = inR->clone(); | 1068 | inL = inR->clone(); |
1067 | local->addIncidence( inL ); | 1069 | local->addIncidence( inL ); |
1068 | ++addedEvent; | 1070 | ++addedEvent; |
1069 | } | 1071 | } |
1070 | } else { | 1072 | } else { |
1071 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1073 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1072 | inR->setLastModified( modifiedCalendar ); | 1074 | inR->setLastModified( modifiedCalendar ); |
1073 | local->addIncidence( inR->clone() ); | 1075 | local->addIncidence( inR->clone() ); |
1074 | ++addedEvent; | 1076 | ++addedEvent; |
1075 | } else { | 1077 | } else { |
1076 | checkExternSyncEvent(eventRSyncSharp, inR); | 1078 | checkExternSyncEvent(eventRSyncSharp, inR); |
1077 | remote->deleteIncidence( inR ); | 1079 | remote->deleteIncidence( inR ); |
1078 | ++deletedEventR; | 1080 | ++deletedEventR; |
1079 | } | 1081 | } |
1080 | } | 1082 | } |
1081 | } | 1083 | } |
1082 | } | 1084 | } |
1083 | inR = er.next(); | 1085 | inR = er.next(); |
1084 | } | 1086 | } |
1085 | QPtrList<Incidence> el = local->rawIncidences(); | 1087 | QPtrList<Incidence> el = local->rawIncidences(); |
1086 | inL = el.first(); | 1088 | inL = el.first(); |
1087 | modulo = (el.count()/10)+1; | 1089 | modulo = (el.count()/10)+1; |
1088 | bar.setCaption (i18n("Add / remove events") ); | 1090 | bar.setCaption (i18n("Add / remove events") ); |
1089 | bar.setTotalSteps ( el.count() ) ; | 1091 | bar.setTotalSteps ( el.count() ) ; |
1090 | bar.show(); | 1092 | bar.show(); |
1091 | incCounter = 0; | 1093 | incCounter = 0; |
1092 | 1094 | ||
1093 | while ( inL ) { | 1095 | while ( inL ) { |
1094 | 1096 | ||
1095 | qApp->processEvents(); | 1097 | qApp->processEvents(); |
1096 | if ( ! bar.isVisible() ) | 1098 | if ( ! bar.isVisible() ) |
1097 | return false; | 1099 | return false; |
1098 | if ( incCounter % modulo == 0 ) | 1100 | if ( incCounter % modulo == 0 ) |
1099 | bar.setProgress( incCounter ); | 1101 | bar.setProgress( incCounter ); |
1100 | ++incCounter; | 1102 | ++incCounter; |
1101 | uid = inL->uid(); | 1103 | uid = inL->uid(); |
1102 | bool skipIncidence = false; | 1104 | bool skipIncidence = false; |
1103 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1105 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1104 | skipIncidence = true; | 1106 | skipIncidence = true; |
1105 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1107 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1106 | skipIncidence = true; | 1108 | skipIncidence = true; |
1107 | if ( !skipIncidence ) { | 1109 | if ( !skipIncidence ) { |
1108 | inR = remote->incidence( uid ); | 1110 | inR = remote->incidence( uid ); |
1109 | if ( ! inR ) { | 1111 | if ( ! inR ) { |
1110 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1112 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1111 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1113 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1112 | checkExternSyncEvent(eventLSyncSharp, inL); | 1114 | checkExternSyncEvent(eventLSyncSharp, inL); |
1113 | local->deleteIncidence( inL ); | 1115 | local->deleteIncidence( inL ); |
1114 | ++deletedEventL; | 1116 | ++deletedEventL; |
1115 | } else { | 1117 | } else { |
1116 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1118 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1117 | inL->removeID(mCurrentSyncDevice ); | 1119 | inL->removeID(mCurrentSyncDevice ); |
1118 | ++addedEventR; | 1120 | ++addedEventR; |
1119 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1121 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1120 | inL->setLastModified( modifiedCalendar ); | 1122 | inL->setLastModified( modifiedCalendar ); |
1121 | inR = inL->clone(); | 1123 | inR = inL->clone(); |
1122 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1124 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1123 | remote->addIncidence( inR ); | 1125 | remote->addIncidence( inR ); |
1124 | } | 1126 | } |
1125 | } | 1127 | } |
1126 | } else { | 1128 | } else { |
1127 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1129 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1128 | checkExternSyncEvent(eventLSyncSharp, inL); | 1130 | checkExternSyncEvent(eventLSyncSharp, inL); |
1129 | local->deleteIncidence( inL ); | 1131 | local->deleteIncidence( inL ); |
1130 | ++deletedEventL; | 1132 | ++deletedEventL; |
1131 | } else { | 1133 | } else { |
1132 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1134 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1133 | ++addedEventR; | 1135 | ++addedEventR; |
1134 | inL->setLastModified( modifiedCalendar ); | 1136 | inL->setLastModified( modifiedCalendar ); |
1135 | remote->addIncidence( inL->clone() ); | 1137 | remote->addIncidence( inL->clone() ); |
1136 | } | 1138 | } |
1137 | } | 1139 | } |
1138 | } | 1140 | } |
1139 | } | 1141 | } |
1140 | } | 1142 | } |
1141 | inL = el.next(); | 1143 | inL = el.next(); |
1142 | } | 1144 | } |
1143 | int delFut = 0; | 1145 | int delFut = 0; |
1144 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1146 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1145 | er = remote->rawIncidences(); | 1147 | er = remote->rawIncidences(); |
1146 | inR = er.first(); | 1148 | inR = er.first(); |
1147 | QDateTime dt; | 1149 | QDateTime dt; |
1148 | QDateTime cur = QDateTime::currentDateTime(); | 1150 | QDateTime cur = QDateTime::currentDateTime(); |
1149 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); | 1151 | QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 ); |
1150 | while ( inR ) { | 1152 | while ( inR ) { |
1151 | if ( inR->type() == "Todo" ) { | 1153 | if ( inR->type() == "Todo" ) { |
1152 | Todo * t = (Todo*)inR; | 1154 | Todo * t = (Todo*)inR; |
1153 | if ( t->hasDueDate() ) | 1155 | if ( t->hasDueDate() ) |
1154 | dt = t->dtDue(); | 1156 | dt = t->dtDue(); |
1155 | else | 1157 | else |
1156 | dt = cur.addSecs( 62 ); | 1158 | dt = cur.addSecs( 62 ); |
1157 | } | 1159 | } |
1158 | else if (inR->type() == "Event" ) { | 1160 | else if (inR->type() == "Event" ) { |
1159 | bool ok; | 1161 | bool ok; |
1160 | dt = inR->getNextOccurence( cur, &ok ); | 1162 | dt = inR->getNextOccurence( cur, &ok ); |
1161 | if ( !ok ) | 1163 | if ( !ok ) |
1162 | dt = cur.addSecs( -62 ); | 1164 | dt = cur.addSecs( -62 ); |
1163 | } | 1165 | } |
1164 | else | 1166 | else |
1165 | dt = inR->dtStart(); | 1167 | dt = inR->dtStart(); |
1166 | if ( dt < cur || dt > end ) { | 1168 | if ( dt < cur || dt > end ) { |
1167 | remote->deleteIncidence( inR ); | 1169 | remote->deleteIncidence( inR ); |
1168 | ++delFut; | 1170 | ++delFut; |
1169 | } | 1171 | } |
1170 | inR = er.next(); | 1172 | inR = er.next(); |
1171 | } | 1173 | } |
1172 | } | 1174 | } |
1173 | bar.hide(); | 1175 | bar.hide(); |
1174 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1176 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1175 | eventLSync->setReadOnly( false ); | 1177 | eventLSync->setReadOnly( false ); |
1176 | eventLSync->setDtStart( mLastCalendarSync ); | 1178 | eventLSync->setDtStart( mLastCalendarSync ); |
1177 | eventRSync->setDtStart( mLastCalendarSync ); | 1179 | eventRSync->setDtStart( mLastCalendarSync ); |
1178 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1180 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1179 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1181 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1180 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1182 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1181 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1183 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1182 | eventLSync->setReadOnly( true ); | 1184 | eventLSync->setReadOnly( true ); |
1183 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1185 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1184 | remote->addEvent( eventRSync ); | 1186 | remote->addEvent( eventRSync ); |
1185 | QString mes; | 1187 | QString mes; |
1186 | 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 ); |
1187 | QString delmess; | 1189 | QString delmess; |
1188 | if ( delFut ) { | 1190 | if ( delFut ) { |
1189 | 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 ); |
1190 | mes += delmess; | 1192 | mes += delmess; |
1191 | } | 1193 | } |
1192 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1194 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1193 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1195 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1194 | } | 1196 | } |
1195 | qDebug( mes ); | 1197 | qDebug( mes ); |
1196 | mCalendar->checkAlarmForIncidence( 0, true ); | 1198 | mCalendar->checkAlarmForIncidence( 0, true ); |
1197 | return syncOK; | 1199 | return syncOK; |
1198 | } | 1200 | } |
1199 | 1201 | ||
1200 | void CalendarView::setSyncDevice( QString s ) | 1202 | void CalendarView::setSyncDevice( QString s ) |
1201 | { | 1203 | { |
1202 | mCurrentSyncDevice= s; | 1204 | mCurrentSyncDevice= s; |
1203 | } | 1205 | } |
1204 | void CalendarView::setSyncName( QString s ) | 1206 | void CalendarView::setSyncName( QString s ) |
1205 | { | 1207 | { |
1206 | mCurrentSyncName= s; | 1208 | mCurrentSyncName= s; |
1207 | } | 1209 | } |
1208 | bool CalendarView::syncCalendar(QString filename, int mode) | 1210 | bool CalendarView::syncCalendar(QString filename, int mode) |
1209 | { | 1211 | { |
1210 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1212 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1211 | CalendarLocal* calendar = new CalendarLocal(); | 1213 | CalendarLocal* calendar = new CalendarLocal(); |
1212 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1214 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1213 | FileStorage* storage = new FileStorage( calendar ); | 1215 | FileStorage* storage = new FileStorage( calendar ); |
1214 | bool syncOK = false; | 1216 | bool syncOK = false; |
1215 | storage->setFileName( filename ); | 1217 | storage->setFileName( filename ); |
1216 | // qDebug("loading ... "); | 1218 | // qDebug("loading ... "); |
1217 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1219 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1218 | getEventViewerDialog()->setSyncMode( true ); | 1220 | getEventViewerDialog()->setSyncMode( true ); |
1219 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1221 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1220 | getEventViewerDialog()->setSyncMode( false ); | 1222 | getEventViewerDialog()->setSyncMode( false ); |
1221 | if ( syncOK ) { | 1223 | if ( syncOK ) { |
1222 | if ( KOPrefs::instance()->mWriteBackFile ) | 1224 | if ( KOPrefs::instance()->mWriteBackFile ) |
1223 | { | 1225 | { |
1224 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1226 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1225 | storage->save(); | 1227 | storage->save(); |
1226 | } | 1228 | } |
1227 | } | 1229 | } |
1228 | setModified( true ); | 1230 | setModified( true ); |
1229 | } | 1231 | } |
1230 | delete storage; | 1232 | delete storage; |
1231 | delete calendar; | 1233 | delete calendar; |
1232 | if ( syncOK ) | 1234 | if ( syncOK ) |
1233 | updateView(); | 1235 | updateView(); |
1234 | return syncOK; | 1236 | return syncOK; |
1235 | } | 1237 | } |
1236 | void CalendarView::syncPhone() | 1238 | void CalendarView::syncPhone() |
1237 | { | 1239 | { |
1238 | syncExternal( 1 ); | 1240 | syncExternal( 1 ); |
1239 | } | 1241 | } |
1240 | void CalendarView::syncExternal( int mode ) | 1242 | void CalendarView::syncExternal( int mode ) |
1241 | { | 1243 | { |
1242 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1244 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1243 | //mCurrentSyncDevice = "sharp-DTM"; | 1245 | //mCurrentSyncDevice = "sharp-DTM"; |
1244 | if ( KOPrefs::instance()->mAskForPreferences ) | 1246 | if ( KOPrefs::instance()->mAskForPreferences ) |
1245 | edit_sync_options(); | 1247 | edit_sync_options(); |
1246 | qApp->processEvents(); | 1248 | qApp->processEvents(); |
1247 | CalendarLocal* calendar = new CalendarLocal(); | 1249 | CalendarLocal* calendar = new CalendarLocal(); |
1248 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1250 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1249 | bool syncOK = false; | 1251 | bool syncOK = false; |
1250 | bool loadSuccess = false; | 1252 | bool loadSuccess = false; |
1251 | PhoneFormat* phoneFormat = 0; | 1253 | PhoneFormat* phoneFormat = 0; |
1252 | #ifndef DESKTOP_VERSION | 1254 | #ifndef DESKTOP_VERSION |
1253 | SharpFormat* sharpFormat = 0; | 1255 | SharpFormat* sharpFormat = 0; |
1254 | if ( mode == 0 ) { // sharp | 1256 | if ( mode == 0 ) { // sharp |
1255 | sharpFormat = new SharpFormat () ; | 1257 | sharpFormat = new SharpFormat () ; |
1256 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1258 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1257 | 1259 | ||
1258 | } else | 1260 | } else |
1259 | #endif | 1261 | #endif |
1260 | if ( mode == 1 ) { // phone | 1262 | if ( mode == 1 ) { // phone |
1261 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1263 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1262 | KOPrefs::instance()->mPhoneDevice, | 1264 | KOPrefs::instance()->mPhoneDevice, |
1263 | KOPrefs::instance()->mPhoneConnection, | 1265 | KOPrefs::instance()->mPhoneConnection, |
1264 | KOPrefs::instance()->mPhoneModel); | 1266 | KOPrefs::instance()->mPhoneModel); |
1265 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1267 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1266 | 1268 | ||
1267 | } else | 1269 | } else |
1268 | return; | 1270 | return; |
1269 | if ( loadSuccess ) { | 1271 | if ( loadSuccess ) { |
1270 | getEventViewerDialog()->setSyncMode( true ); | 1272 | getEventViewerDialog()->setSyncMode( true ); |
1271 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1273 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1272 | getEventViewerDialog()->setSyncMode( false ); | 1274 | getEventViewerDialog()->setSyncMode( false ); |
1273 | qApp->processEvents(); | 1275 | qApp->processEvents(); |
1274 | if ( syncOK ) { | 1276 | if ( syncOK ) { |
1275 | if ( KOPrefs::instance()->mWriteBackFile ) | 1277 | if ( KOPrefs::instance()->mWriteBackFile ) |
1276 | { | 1278 | { |
1277 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1279 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1278 | Incidence* inc = iL.first(); | 1280 | Incidence* inc = iL.first(); |
1279 | if ( phoneFormat ) { | 1281 | if ( phoneFormat ) { |
1280 | while ( inc ) { | 1282 | while ( inc ) { |
1281 | inc->removeID(mCurrentSyncDevice); | 1283 | inc->removeID(mCurrentSyncDevice); |
1282 | inc = iL.next(); | 1284 | inc = iL.next(); |
1283 | } | 1285 | } |
1284 | } | 1286 | } |
1285 | #ifndef DESKTOP_VERSION | 1287 | #ifndef DESKTOP_VERSION |
1286 | if ( sharpFormat ) | 1288 | if ( sharpFormat ) |
1287 | sharpFormat->save(calendar); | 1289 | sharpFormat->save(calendar); |
1288 | #endif | 1290 | #endif |
1289 | if ( phoneFormat ) | 1291 | if ( phoneFormat ) |
1290 | phoneFormat->save(calendar); | 1292 | phoneFormat->save(calendar); |
1291 | iL = calendar->rawIncidences(); | 1293 | iL = calendar->rawIncidences(); |
1292 | inc = iL.first(); | 1294 | inc = iL.first(); |
1293 | Incidence* loc; | 1295 | Incidence* loc; |
1294 | while ( inc ) { | 1296 | while ( inc ) { |
1295 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1297 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1296 | loc = mCalendar->incidence(inc->uid() ); | 1298 | loc = mCalendar->incidence(inc->uid() ); |
1297 | if ( loc ) { | 1299 | if ( loc ) { |
1298 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1300 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1299 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1301 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1300 | } | 1302 | } |
1301 | } | 1303 | } |
1302 | inc = iL.next(); | 1304 | inc = iL.next(); |
1303 | } | 1305 | } |
1304 | Incidence* lse = getLastSyncEvent(); | 1306 | Incidence* lse = getLastSyncEvent(); |
1305 | if ( lse ) { | 1307 | if ( lse ) { |
1306 | lse->setReadOnly( false ); | 1308 | lse->setReadOnly( false ); |
1307 | lse->setDescription( "" ); | 1309 | lse->setDescription( "" ); |
1308 | lse->setReadOnly( true ); | 1310 | lse->setReadOnly( true ); |
1309 | } | 1311 | } |
1310 | } | 1312 | } |
1311 | } | 1313 | } |
1312 | setModified( true ); | 1314 | setModified( true ); |
1313 | } else { | 1315 | } else { |
1314 | 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") ; |
1315 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1317 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1316 | question, i18n("Ok")) ; | 1318 | question, i18n("Ok")) ; |
1317 | 1319 | ||
1318 | } | 1320 | } |
1319 | delete calendar; | 1321 | delete calendar; |
1320 | updateView(); | 1322 | updateView(); |
1321 | return ;//syncOK; | 1323 | return ;//syncOK; |
1322 | 1324 | ||
1323 | } | 1325 | } |
1324 | void CalendarView::syncSharp() | 1326 | void CalendarView::syncSharp() |
1325 | { | 1327 | { |
1326 | syncExternal( 0 ); | 1328 | syncExternal( 0 ); |
1327 | 1329 | ||
1328 | } | 1330 | } |
1329 | 1331 | ||
1330 | 1332 | ||
1331 | //#include <kabc/stdaddressbook.h> | 1333 | //#include <kabc/stdaddressbook.h> |
1332 | bool CalendarView::importBday() | 1334 | bool CalendarView::importBday() |
1333 | { | 1335 | { |
1334 | #if 0 | 1336 | #if 0 |
1335 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1337 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1336 | KABC::AddressBook::Iterator it; | 1338 | KABC::AddressBook::Iterator it; |
1337 | int count = 0; | 1339 | int count = 0; |
1338 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1340 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1339 | ++count; | 1341 | ++count; |
1340 | } | 1342 | } |
1341 | QProgressBar bar(count,0 ); | 1343 | QProgressBar bar(count,0 ); |
1342 | int w = 300; | 1344 | int w = 300; |
1343 | if ( QApplication::desktop()->width() < 320 ) | 1345 | if ( QApplication::desktop()->width() < 320 ) |
1344 | w = 220; | 1346 | w = 220; |
1345 | int h = bar.sizeHint().height() ; | 1347 | int h = bar.sizeHint().height() ; |
1346 | int dw = QApplication::desktop()->width(); | 1348 | int dw = QApplication::desktop()->width(); |
1347 | int dh = QApplication::desktop()->height(); | 1349 | int dh = QApplication::desktop()->height(); |
1348 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1350 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1349 | bar.show(); | 1351 | bar.show(); |
1350 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1352 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1351 | qApp->processEvents(); | 1353 | qApp->processEvents(); |
1352 | count = 0; | 1354 | count = 0; |
1353 | int addCount = 0; | 1355 | int addCount = 0; |
1354 | KCal::Attendee* a = 0; | 1356 | KCal::Attendee* a = 0; |
1355 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1357 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1356 | if ( ! bar.isVisible() ) | 1358 | if ( ! bar.isVisible() ) |
1357 | return false; | 1359 | return false; |
1358 | bar.setProgress( count++ ); | 1360 | bar.setProgress( count++ ); |
1359 | qApp->processEvents(); | 1361 | qApp->processEvents(); |
1360 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1362 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1361 | if ( (*it).birthday().date().isValid() ){ | 1363 | if ( (*it).birthday().date().isValid() ){ |
1362 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1364 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1363 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1365 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1364 | ++addCount; | 1366 | ++addCount; |
1365 | } | 1367 | } |
1366 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1368 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1367 | if ( anni.isValid() ){ | 1369 | if ( anni.isValid() ){ |
1368 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1370 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1369 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1371 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1370 | ++addCount; | 1372 | ++addCount; |
1371 | } | 1373 | } |
1372 | } | 1374 | } |
1373 | updateView(); | 1375 | updateView(); |
1374 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1376 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1375 | #endif | 1377 | #endif |
1376 | return true; | 1378 | return true; |
1377 | } | 1379 | } |
1378 | 1380 | ||
1379 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1381 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1380 | { | 1382 | { |
1381 | //qDebug("addAnni "); | 1383 | //qDebug("addAnni "); |
1382 | Event * ev = new Event(); | 1384 | Event * ev = new Event(); |
1383 | if ( a ) { | 1385 | if ( a ) { |
1384 | ev->addAttendee( a ); | 1386 | ev->addAttendee( a ); |
1385 | } | 1387 | } |
1386 | QString kind; | 1388 | QString kind; |
1387 | if ( birthday ) | 1389 | if ( birthday ) |
1388 | kind = i18n( "Birthday" ); | 1390 | kind = i18n( "Birthday" ); |
1389 | else | 1391 | else |
1390 | kind = i18n( "Anniversary" ); | 1392 | kind = i18n( "Anniversary" ); |
1391 | ev->setSummary( name + " - " + kind ); | 1393 | ev->setSummary( name + " - " + kind ); |
1392 | ev->setOrganizer( "nobody@nowhere" ); | 1394 | ev->setOrganizer( "nobody@nowhere" ); |
1393 | ev->setCategories( kind ); | 1395 | ev->setCategories( kind ); |
1394 | ev->setDtStart( QDateTime(date) ); | 1396 | ev->setDtStart( QDateTime(date) ); |
1395 | ev->setDtEnd( QDateTime(date) ); | 1397 | ev->setDtEnd( QDateTime(date) ); |
1396 | ev->setFloats( true ); | 1398 | ev->setFloats( true ); |
1397 | Recurrence * rec = ev->recurrence(); | 1399 | Recurrence * rec = ev->recurrence(); |
1398 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1400 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1399 | rec->addYearlyNum( date.month() ); | 1401 | rec->addYearlyNum( date.month() ); |
1400 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1402 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1401 | delete ev; | 1403 | delete ev; |
1402 | return false; | 1404 | return false; |
1403 | } | 1405 | } |
1404 | return true; | 1406 | return true; |
1405 | 1407 | ||
1406 | } | 1408 | } |
1407 | bool CalendarView::importQtopia( const QString &categories, | 1409 | bool CalendarView::importQtopia( const QString &categories, |
1408 | const QString &datebook, | 1410 | const QString &datebook, |
1409 | const QString &todolist ) | 1411 | const QString &todolist ) |
1410 | { | 1412 | { |
1411 | 1413 | ||
1412 | QtopiaFormat qtopiaFormat; | 1414 | QtopiaFormat qtopiaFormat; |
1413 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1415 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1414 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1416 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1415 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1417 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1416 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1418 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1417 | 1419 | ||
1418 | updateView(); | 1420 | updateView(); |
1419 | return true; | 1421 | return true; |
1420 | 1422 | ||
1421 | #if 0 | 1423 | #if 0 |
1422 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1424 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1423 | mCurrentSyncDevice = "qtopia-XML"; | 1425 | mCurrentSyncDevice = "qtopia-XML"; |
1424 | if ( KOPrefs::instance()->mAskForPreferences ) | 1426 | if ( KOPrefs::instance()->mAskForPreferences ) |
1425 | edit_sync_options(); | 1427 | edit_sync_options(); |
1426 | qApp->processEvents(); | 1428 | qApp->processEvents(); |
1427 | CalendarLocal* calendar = new CalendarLocal(); | 1429 | CalendarLocal* calendar = new CalendarLocal(); |
1428 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1430 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1429 | bool syncOK = false; | 1431 | bool syncOK = false; |
1430 | QtopiaFormat qtopiaFormat; | 1432 | QtopiaFormat qtopiaFormat; |
1431 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1433 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1432 | bool loadOk = true; | 1434 | bool loadOk = true; |
1433 | if ( !categories.isEmpty() ) | 1435 | if ( !categories.isEmpty() ) |
1434 | loadOk = qtopiaFormat.load( calendar, categories ); | 1436 | loadOk = qtopiaFormat.load( calendar, categories ); |
1435 | if ( loadOk && !datebook.isEmpty() ) | 1437 | if ( loadOk && !datebook.isEmpty() ) |
1436 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1438 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1437 | if ( loadOk && !todolist.isEmpty() ) | 1439 | if ( loadOk && !todolist.isEmpty() ) |
1438 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1440 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1439 | 1441 | ||
1440 | if ( loadOk ) { | 1442 | if ( loadOk ) { |
1441 | getEventViewerDialog()->setSyncMode( true ); | 1443 | getEventViewerDialog()->setSyncMode( true ); |
1442 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1444 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1443 | getEventViewerDialog()->setSyncMode( false ); | 1445 | getEventViewerDialog()->setSyncMode( false ); |
1444 | qApp->processEvents(); | 1446 | qApp->processEvents(); |
1445 | if ( syncOK ) { | 1447 | if ( syncOK ) { |
1446 | if ( KOPrefs::instance()->mWriteBackFile ) | 1448 | if ( KOPrefs::instance()->mWriteBackFile ) |
1447 | { | 1449 | { |
1448 | // write back XML file | 1450 | // write back XML file |
1449 | 1451 | ||
1450 | } | 1452 | } |
1451 | setModified( true ); | 1453 | setModified( true ); |
1452 | } | 1454 | } |
1453 | } else { | 1455 | } else { |
1454 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1456 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1455 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1457 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1456 | question, i18n("Ok")) ; | 1458 | question, i18n("Ok")) ; |
1457 | } | 1459 | } |
1458 | delete calendar; | 1460 | delete calendar; |
1459 | updateView(); | 1461 | updateView(); |
1460 | return syncOK; | 1462 | return syncOK; |
1461 | 1463 | ||
1462 | 1464 | ||
1463 | #endif | 1465 | #endif |
1464 | 1466 | ||
1465 | } | 1467 | } |
1466 | 1468 | ||
1467 | void CalendarView::setSyncEventsReadOnly() | 1469 | void CalendarView::setSyncEventsReadOnly() |
1468 | { | 1470 | { |
1469 | Event * ev; | 1471 | Event * ev; |
1470 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1472 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1471 | ev = eL.first(); | 1473 | ev = eL.first(); |
1472 | while ( ev ) { | 1474 | while ( ev ) { |
1473 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1475 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1474 | ev->setReadOnly( true ); | 1476 | ev->setReadOnly( true ); |
1475 | ev = eL.next(); | 1477 | ev = eL.next(); |
1476 | } | 1478 | } |
1477 | } | 1479 | } |
1478 | bool CalendarView::openCalendar(QString filename, bool merge) | 1480 | bool CalendarView::openCalendar(QString filename, bool merge) |
1479 | { | 1481 | { |
1480 | 1482 | ||
1481 | if (filename.isEmpty()) { | 1483 | if (filename.isEmpty()) { |
1482 | return false; | 1484 | return false; |
1483 | } | 1485 | } |
1484 | 1486 | ||
1485 | if (!QFile::exists(filename)) { | 1487 | if (!QFile::exists(filename)) { |
1486 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1488 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1487 | return false; | 1489 | return false; |
1488 | } | 1490 | } |
1489 | 1491 | ||
1490 | globalFlagBlockAgenda = 1; | 1492 | globalFlagBlockAgenda = 1; |
1491 | if (!merge) mCalendar->close(); | 1493 | if (!merge) mCalendar->close(); |
1492 | 1494 | ||
1493 | mStorage->setFileName( filename ); | 1495 | mStorage->setFileName( filename ); |
1494 | 1496 | ||
1495 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1497 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1496 | if ( merge ) ;//setModified( true ); | 1498 | if ( merge ) ;//setModified( true ); |
1497 | else { | 1499 | else { |
1498 | //setModified( true ); | 1500 | //setModified( true ); |
1499 | mViewManager->setDocumentId( filename ); | 1501 | mViewManager->setDocumentId( filename ); |
1500 | mDialogManager->setDocumentId( filename ); | 1502 | mDialogManager->setDocumentId( filename ); |
1501 | mTodoList->setDocumentId( filename ); | 1503 | mTodoList->setDocumentId( filename ); |
1502 | } | 1504 | } |
1503 | globalFlagBlockAgenda = 2; | 1505 | globalFlagBlockAgenda = 2; |
1504 | // if ( getLastSyncEvent() ) | 1506 | // if ( getLastSyncEvent() ) |
1505 | // getLastSyncEvent()->setReadOnly( true ); | 1507 | // getLastSyncEvent()->setReadOnly( true ); |
1506 | mCalendar->reInitAlarmSettings(); | 1508 | mCalendar->reInitAlarmSettings(); |
1507 | setSyncEventsReadOnly(); | 1509 | setSyncEventsReadOnly(); |
1508 | updateUnmanagedViews(); | 1510 | updateUnmanagedViews(); |
1509 | updateView(); | 1511 | updateView(); |
1510 | if ( filename != MainWindow::defaultFileName() ) | 1512 | if ( filename != MainWindow::defaultFileName() ) |
1511 | saveCalendar( MainWindow::defaultFileName() ); | 1513 | saveCalendar( MainWindow::defaultFileName() ); |
1512 | loadedFileVersion = QDateTime::currentDateTime(); | 1514 | loadedFileVersion = QDateTime::currentDateTime(); |
1513 | return true; | 1515 | return true; |
1514 | } else { | 1516 | } else { |
1515 | // while failing to load, the calendar object could | 1517 | // while failing to load, the calendar object could |
1516 | // have become partially populated. Clear it out. | 1518 | // have become partially populated. Clear it out. |
1517 | if ( !merge ) mCalendar->close(); | 1519 | if ( !merge ) mCalendar->close(); |
1518 | 1520 | ||
1519 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1521 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1520 | 1522 | ||
1521 | globalFlagBlockAgenda = 2; | 1523 | globalFlagBlockAgenda = 2; |
1522 | updateView(); | 1524 | updateView(); |
1523 | } | 1525 | } |
1524 | return false; | 1526 | return false; |
1525 | } | 1527 | } |
1526 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1528 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1527 | { | 1529 | { |
1528 | loadedFileVersion = dt; | 1530 | loadedFileVersion = dt; |
1529 | } | 1531 | } |
1530 | bool CalendarView::checkFileChanged(QString fn) | 1532 | bool CalendarView::checkFileChanged(QString fn) |
1531 | { | 1533 | { |
1532 | QFileInfo finf ( fn ); | 1534 | QFileInfo finf ( fn ); |
1533 | if ( !finf.exists() ) | 1535 | if ( !finf.exists() ) |
1534 | return true; | 1536 | return true; |
1535 | QDateTime dt = finf.lastModified (); | 1537 | QDateTime dt = finf.lastModified (); |
1536 | if ( dt <= loadedFileVersion ) | 1538 | if ( dt <= loadedFileVersion ) |
1537 | return false; | 1539 | return false; |
1538 | return true; | 1540 | return true; |
1539 | 1541 | ||
1540 | } | 1542 | } |
1541 | bool CalendarView::checkFileVersion(QString fn) | 1543 | bool CalendarView::checkFileVersion(QString fn) |
1542 | { | 1544 | { |
1543 | QFileInfo finf ( fn ); | 1545 | QFileInfo finf ( fn ); |
1544 | if ( !finf.exists() ) | 1546 | if ( !finf.exists() ) |
1545 | return true; | 1547 | return true; |
1546 | QDateTime dt = finf.lastModified (); | 1548 | QDateTime dt = finf.lastModified (); |
1547 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1549 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1548 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1550 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1549 | if ( dt <= loadedFileVersion ) | 1551 | if ( dt <= loadedFileVersion ) |
1550 | return true; | 1552 | return true; |
1551 | 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, false)) , | 1553 | 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, false)) , |
1552 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1554 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1553 | i18n("Sync+save")); | 1555 | i18n("Sync+save")); |
1554 | 1556 | ||
1555 | if ( km == KMessageBox::Cancel ) | 1557 | if ( km == KMessageBox::Cancel ) |
1556 | return false; | 1558 | return false; |
1557 | if ( km == KMessageBox::Yes ) | 1559 | if ( km == KMessageBox::Yes ) |
1558 | return true; | 1560 | return true; |
1559 | 1561 | ||
1560 | setSyncDevice("deleteaftersync" ); | 1562 | setSyncDevice("deleteaftersync" ); |
1561 | KOPrefs::instance()->mAskForPreferences = true; | 1563 | KOPrefs::instance()->mAskForPreferences = true; |
1562 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1564 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1563 | KOPrefs::instance()->mWriteBackFile = false; | 1565 | KOPrefs::instance()->mWriteBackFile = false; |
1564 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1566 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1565 | KOPrefs::instance()->mShowSyncSummary = false; | 1567 | KOPrefs::instance()->mShowSyncSummary = false; |
1566 | syncCalendar( fn, 3 ); | 1568 | syncCalendar( fn, 3 ); |
1567 | Event * e = getLastSyncEvent(); | 1569 | Event * e = getLastSyncEvent(); |
1568 | mCalendar->deleteEvent ( e ); | 1570 | mCalendar->deleteEvent ( e ); |
1569 | updateView(); | 1571 | updateView(); |
1570 | return true; | 1572 | return true; |
1571 | } | 1573 | } |
1572 | 1574 | ||
1573 | bool CalendarView::saveCalendar( QString filename ) | 1575 | bool CalendarView::saveCalendar( QString filename ) |
1574 | { | 1576 | { |
1575 | 1577 | ||
1576 | // Store back all unsaved data into calendar object | 1578 | // Store back all unsaved data into calendar object |
1577 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1579 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1578 | if ( mViewManager->currentView() ) | 1580 | if ( mViewManager->currentView() ) |
1579 | mViewManager->currentView()->flushView(); | 1581 | mViewManager->currentView()->flushView(); |
1580 | 1582 | ||
1581 | //mStorage->setFileName( filename ); | 1583 | //mStorage->setFileName( filename ); |
1582 | 1584 | ||
1583 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1585 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1584 | mStorage->setFileName( filename ); | 1586 | mStorage->setFileName( filename ); |
1585 | bool success; | 1587 | bool success; |
1586 | success = mStorage->save(); | 1588 | success = mStorage->save(); |
1587 | if ( !success ) { | 1589 | if ( !success ) { |
1588 | return false; | 1590 | return false; |
1589 | } | 1591 | } |
1590 | 1592 | ||
1591 | return true; | 1593 | return true; |