-rw-r--r-- | korganizer/calendarview.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1d62046..e4c067e 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,541 +1,546 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | #ifdef DESKTOP_VERSION | ||
131 | #include <kabc/stdaddressbook.h> | ||
132 | #endif | ||
130 | using namespace KOrg; | 133 | using namespace KOrg; |
131 | using namespace KCal; | 134 | using namespace KCal; |
132 | extern int globalFlagBlockAgenda; | 135 | extern int globalFlagBlockAgenda; |
133 | extern int globalFlagBlockStartup; | 136 | extern int globalFlagBlockStartup; |
134 | 137 | ||
135 | 138 | ||
136 | 139 | ||
137 | class KOBeamPrefs : public QDialog | 140 | class KOBeamPrefs : public QDialog |
138 | { | 141 | { |
139 | public: | 142 | public: |
140 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 143 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
141 | QDialog( parent, name, true ) | 144 | QDialog( parent, name, true ) |
142 | { | 145 | { |
143 | setCaption( i18n("Beam Options") ); | 146 | setCaption( i18n("Beam Options") ); |
144 | QVBoxLayout* lay = new QVBoxLayout( this ); | 147 | QVBoxLayout* lay = new QVBoxLayout( this ); |
145 | lay->setSpacing( 3 ); | 148 | lay->setSpacing( 3 ); |
146 | lay->setMargin( 3 ); | 149 | lay->setMargin( 3 ); |
147 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 150 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
148 | lay->addWidget( format ); | 151 | lay->addWidget( format ); |
149 | format->setExclusive ( true ) ; | 152 | format->setExclusive ( true ) ; |
150 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 153 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
151 | lay->addWidget( time ); time->setExclusive ( true ) ; | 154 | lay->addWidget( time ); time->setExclusive ( true ) ; |
152 | vcal = new QRadioButton(" vCalendar ", format ); | 155 | vcal = new QRadioButton(" vCalendar ", format ); |
153 | ical = new QRadioButton(" iCalendar ", format ); | 156 | ical = new QRadioButton(" iCalendar ", format ); |
154 | vcal->setChecked( true ); | 157 | vcal->setChecked( true ); |
155 | tz = new QRadioButton(i18n(" With timezone "), time ); | 158 | tz = new QRadioButton(i18n(" With timezone "), time ); |
156 | local = new QRadioButton(i18n(" Local time "), time ); | 159 | local = new QRadioButton(i18n(" Local time "), time ); |
157 | tz->setChecked( true ); | 160 | tz->setChecked( true );#ifdef DESKTOP_VERSION |
161 | #include <kabc/stdaddressbook.h> | ||
162 | #endif | ||
158 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
159 | lay->addWidget( ok ); | 164 | lay->addWidget( ok ); |
160 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
161 | lay->addWidget( cancel ); | 166 | lay->addWidget( cancel ); |
162 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
163 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
164 | resize( 200, 200 ); | 169 | resize( 200, 200 ); |
165 | } | 170 | } |
166 | 171 | ||
167 | bool beamVcal() { return vcal->isChecked(); } | 172 | bool beamVcal() { return vcal->isChecked(); } |
168 | bool beamLocal() { return local->isChecked(); } | 173 | bool beamLocal() { return local->isChecked(); } |
169 | private: | 174 | private: |
170 | QRadioButton* vcal, *ical, *local, *tz; | 175 | QRadioButton* vcal, *ical, *local, *tz; |
171 | }; | 176 | }; |
172 | class KOCatPrefs : public QDialog | 177 | class KOCatPrefs : public QDialog |
173 | { | 178 | { |
174 | public: | 179 | public: |
175 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
176 | QDialog( parent, name, true ) | 181 | QDialog( parent, name, true ) |
177 | { | 182 | { |
178 | setCaption( i18n("Manage new Categories") ); | 183 | setCaption( i18n("Manage new Categories") ); |
179 | QVBoxLayout* lay = new QVBoxLayout( this ); | 184 | QVBoxLayout* lay = new QVBoxLayout( this ); |
180 | lay->setSpacing( 3 ); | 185 | lay->setSpacing( 3 ); |
181 | lay->setMargin( 3 ); | 186 | lay->setMargin( 3 ); |
182 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 187 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
183 | lay->addWidget( lab ); | 188 | lay->addWidget( lab ); |
184 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
185 | lay->addWidget( format ); | 190 | lay->addWidget( format ); |
186 | format->setExclusive ( true ) ; | 191 | format->setExclusive ( true ) ; |
187 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
188 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
189 | addCatBut->setChecked( true ); | 194 | addCatBut->setChecked( true ); |
190 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
191 | lay->addWidget( ok ); | 196 | lay->addWidget( ok ); |
192 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
193 | lay->addWidget( cancel ); | 198 | lay->addWidget( cancel ); |
194 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
195 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
196 | resize( 200, 200 ); | 201 | resize( 200, 200 ); |
197 | } | 202 | } |
198 | 203 | ||
199 | bool addCat() { return addCatBut->isChecked(); } | 204 | bool addCat() { return addCatBut->isChecked(); } |
200 | private: | 205 | private: |
201 | QRadioButton* addCatBut; | 206 | QRadioButton* addCatBut; |
202 | }; | 207 | }; |
203 | 208 | ||
204 | 209 | ||
205 | 210 | ||
206 | CalendarView::CalendarView( CalendarResources *calendar, | 211 | CalendarView::CalendarView( CalendarResources *calendar, |
207 | QWidget *parent, const char *name ) | 212 | QWidget *parent, const char *name ) |
208 | : CalendarViewBase( parent, name ), | 213 | : CalendarViewBase( parent, name ), |
209 | mCalendar( calendar ), | 214 | mCalendar( calendar ), |
210 | mResourceManager( calendar->resourceManager() ) | 215 | mResourceManager( calendar->resourceManager() ) |
211 | { | 216 | { |
212 | 217 | ||
213 | mEventEditor = 0; | 218 | mEventEditor = 0; |
214 | mTodoEditor = 0; | 219 | mTodoEditor = 0; |
215 | 220 | ||
216 | init(); | 221 | init(); |
217 | } | 222 | } |
218 | 223 | ||
219 | CalendarView::CalendarView( Calendar *calendar, | 224 | CalendarView::CalendarView( Calendar *calendar, |
220 | QWidget *parent, const char *name ) | 225 | QWidget *parent, const char *name ) |
221 | : CalendarViewBase( parent, name ), | 226 | : CalendarViewBase( parent, name ), |
222 | mCalendar( calendar ), | 227 | mCalendar( calendar ), |
223 | mResourceManager( 0 ) | 228 | mResourceManager( 0 ) |
224 | { | 229 | { |
225 | 230 | ||
226 | mEventEditor = 0; | 231 | mEventEditor = 0; |
227 | mTodoEditor = 0; | 232 | mTodoEditor = 0; |
228 | init();} | 233 | init();} |
229 | 234 | ||
230 | void CalendarView::init() | 235 | void CalendarView::init() |
231 | { | 236 | { |
232 | beamDialog = new KOBeamPrefs(); | 237 | beamDialog = new KOBeamPrefs(); |
233 | mDatePickerMode = 0; | 238 | mDatePickerMode = 0; |
234 | mCurrentSyncDevice = ""; | 239 | mCurrentSyncDevice = ""; |
235 | writeLocale(); | 240 | writeLocale(); |
236 | mViewManager = new KOViewManager( this ); | 241 | mViewManager = new KOViewManager( this ); |
237 | mDialogManager = new KODialogManager( this ); | 242 | mDialogManager = new KODialogManager( this ); |
238 | mEventViewerDialog = 0; | 243 | mEventViewerDialog = 0; |
239 | mModified = false; | 244 | mModified = false; |
240 | mReadOnly = false; | 245 | mReadOnly = false; |
241 | mSelectedIncidence = 0; | 246 | mSelectedIncidence = 0; |
242 | mCalPrinter = 0; | 247 | mCalPrinter = 0; |
243 | mFilters.setAutoDelete(true); | 248 | mFilters.setAutoDelete(true); |
244 | 249 | ||
245 | mCalendar->registerObserver( this ); | 250 | mCalendar->registerObserver( this ); |
246 | // TODO: Make sure that view is updated, when calendar is changed. | 251 | // TODO: Make sure that view is updated, when calendar is changed. |
247 | 252 | ||
248 | mStorage = new FileStorage( mCalendar ); | 253 | mStorage = new FileStorage( mCalendar ); |
249 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 254 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
250 | 255 | ||
251 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 256 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
252 | #ifndef KORG_NOSPLITTER | 257 | #ifndef KORG_NOSPLITTER |
253 | // create the main layout frames. | 258 | // create the main layout frames. |
254 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 259 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
255 | topLayout->addWidget(mPanner); | 260 | topLayout->addWidget(mPanner); |
256 | 261 | ||
257 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 262 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
258 | "CalendarView::LeftFrame"); | 263 | "CalendarView::LeftFrame"); |
259 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 264 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
260 | 265 | ||
261 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 266 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
262 | "CalendarView::DateNavigator", QDate::currentDate() ); | 267 | "CalendarView::DateNavigator", QDate::currentDate() ); |
263 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 268 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
264 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 269 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
265 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 270 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
266 | 271 | ||
267 | #ifdef KORG_NORESOURCEVIEW | 272 | #ifdef KORG_NORESOURCEVIEW |
268 | mResourceView = 0; | 273 | mResourceView = 0; |
269 | #else | 274 | #else |
270 | if ( mResourceManager ) { | 275 | if ( mResourceManager ) { |
271 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 276 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
272 | mResourceView->updateView(); | 277 | mResourceView->updateView(); |
273 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 278 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
274 | SLOT( updateView() ) ); | 279 | SLOT( updateView() ) ); |
275 | } else { | 280 | } else { |
276 | mResourceView = 0; | 281 | mResourceView = 0; |
277 | } | 282 | } |
278 | #endif | 283 | #endif |
279 | QWidget *rightBox = new QWidget( mPanner ); | 284 | QWidget *rightBox = new QWidget( mPanner ); |
280 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 285 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
281 | 286 | ||
282 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 287 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
283 | rightLayout->addWidget( mNavigatorBar ); | 288 | rightLayout->addWidget( mNavigatorBar ); |
284 | 289 | ||
285 | mRightFrame = new QWidgetStack( rightBox ); | 290 | mRightFrame = new QWidgetStack( rightBox ); |
286 | rightLayout->addWidget( mRightFrame, 1 ); | 291 | rightLayout->addWidget( mRightFrame, 1 ); |
287 | 292 | ||
288 | mLeftFrame = mLeftSplitter; | 293 | mLeftFrame = mLeftSplitter; |
289 | #else | 294 | #else |
290 | QWidget *mainBox = new QWidget( this ); | 295 | QWidget *mainBox = new QWidget( this ); |
291 | QWidget *leftFrame = new QWidget( mainBox ); | 296 | QWidget *leftFrame = new QWidget( mainBox ); |
292 | 297 | ||
293 | QBoxLayout * mainBoxLayout; | 298 | QBoxLayout * mainBoxLayout; |
294 | QBoxLayout * leftFrameLayout; | 299 | QBoxLayout * leftFrameLayout; |
295 | if ( KOPrefs::instance()->mVerticalScreen ) { | 300 | if ( KOPrefs::instance()->mVerticalScreen ) { |
296 | mainBoxLayout = new QVBoxLayout(mainBox); | 301 | mainBoxLayout = new QVBoxLayout(mainBox); |
297 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 302 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
298 | } else { | 303 | } else { |
299 | mainBoxLayout = new QHBoxLayout(mainBox); | 304 | mainBoxLayout = new QHBoxLayout(mainBox); |
300 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 305 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
301 | } | 306 | } |
302 | topLayout->addWidget( mainBox ); | 307 | topLayout->addWidget( mainBox ); |
303 | mainBoxLayout->addWidget (leftFrame); | 308 | mainBoxLayout->addWidget (leftFrame); |
304 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 309 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
305 | "CalendarView::DateNavigator", QDate::currentDate()); | 310 | "CalendarView::DateNavigator", QDate::currentDate()); |
306 | // mDateNavigator->blockSignals( true ); | 311 | // mDateNavigator->blockSignals( true ); |
307 | leftFrameLayout->addWidget( mDateNavigator ); | 312 | leftFrameLayout->addWidget( mDateNavigator ); |
308 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 313 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
309 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); | 314 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); |
310 | 315 | ||
311 | if ( QApplication::desktop()->width() < 480 ) { | 316 | if ( QApplication::desktop()->width() < 480 ) { |
312 | leftFrameLayout->addWidget(mFilterView); | 317 | leftFrameLayout->addWidget(mFilterView); |
313 | leftFrameLayout->addWidget(mTodoList, 2 ); | 318 | leftFrameLayout->addWidget(mTodoList, 2 ); |
314 | 319 | ||
315 | } else { | 320 | } else { |
316 | leftFrameLayout->addWidget(mTodoList,2 ); | 321 | leftFrameLayout->addWidget(mTodoList,2 ); |
317 | leftFrameLayout->addWidget(mFilterView ); | 322 | leftFrameLayout->addWidget(mFilterView ); |
318 | } | 323 | } |
319 | mFilterView->hide(); | 324 | mFilterView->hide(); |
320 | QWidget *rightBox = new QWidget( mainBox ); | 325 | QWidget *rightBox = new QWidget( mainBox ); |
321 | mainBoxLayout->addWidget ( rightBox, 10 ); | 326 | mainBoxLayout->addWidget ( rightBox, 10 ); |
322 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 327 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
323 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 328 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
324 | mRightFrame = new QWidgetStack( rightBox ); | 329 | mRightFrame = new QWidgetStack( rightBox ); |
325 | rightLayout->addWidget( mNavigatorBar ); | 330 | rightLayout->addWidget( mNavigatorBar ); |
326 | rightLayout->addWidget( mRightFrame, 10 ); | 331 | rightLayout->addWidget( mRightFrame, 10 ); |
327 | 332 | ||
328 | mLeftFrame = leftFrame; | 333 | mLeftFrame = leftFrame; |
329 | if ( KOPrefs::instance()->mVerticalScreen ) { | 334 | if ( KOPrefs::instance()->mVerticalScreen ) { |
330 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 335 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
331 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 336 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
332 | } else { | 337 | } else { |
333 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 338 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
334 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 339 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
335 | } | 340 | } |
336 | 341 | ||
337 | //qDebug("Calendarview Size %d %d ", width(), height()); | 342 | //qDebug("Calendarview Size %d %d ", width(), height()); |
338 | #endif | 343 | #endif |
339 | 344 | ||
340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 345 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
341 | SLOT( showDates( const KCal::DateList & ) ) ); | 346 | SLOT( showDates( const KCal::DateList & ) ) ); |
342 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 347 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
343 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 348 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
344 | 349 | ||
345 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 350 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
346 | mNavigator, SLOT( selectPreviousYear() ) ); | 351 | mNavigator, SLOT( selectPreviousYear() ) ); |
347 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 352 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
348 | mNavigator, SLOT( selectNextYear() ) ); | 353 | mNavigator, SLOT( selectNextYear() ) ); |
349 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 354 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
350 | mNavigator, SLOT( selectPreviousMonth() ) ); | 355 | mNavigator, SLOT( selectPreviousMonth() ) ); |
351 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 356 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
352 | mNavigator, SLOT( selectNextMonth() ) ); | 357 | mNavigator, SLOT( selectNextMonth() ) ); |
353 | 358 | ||
354 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 359 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
355 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 360 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
356 | 361 | ||
357 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 362 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
358 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 363 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
359 | 364 | ||
360 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 365 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
361 | mNavigator, SLOT( selectPreviousYear() ) ); | 366 | mNavigator, SLOT( selectPreviousYear() ) ); |
362 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 367 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
363 | mNavigator, SLOT( selectNextYear() ) ); | 368 | mNavigator, SLOT( selectNextYear() ) ); |
364 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 369 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
365 | mNavigator, SLOT( selectPreviousMonth() ) ); | 370 | mNavigator, SLOT( selectPreviousMonth() ) ); |
366 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 371 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
367 | mNavigator, SLOT( selectNextMonth() ) ); | 372 | mNavigator, SLOT( selectNextMonth() ) ); |
368 | 373 | ||
369 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 374 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
370 | mNavigator, SLOT( selectPrevious() ) ); | 375 | mNavigator, SLOT( selectPrevious() ) ); |
371 | connect( mDateNavigator, SIGNAL( goNext() ), | 376 | connect( mDateNavigator, SIGNAL( goNext() ), |
372 | mNavigator, SLOT( selectNext() ) ); | 377 | mNavigator, SLOT( selectNext() ) ); |
373 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 378 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 379 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
375 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 380 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
376 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 381 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
377 | 382 | ||
378 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 383 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
379 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 384 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
380 | 385 | ||
381 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 386 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
382 | SLOT( eventAdded( Event *) ) ); | 387 | SLOT( eventAdded( Event *) ) ); |
383 | 388 | ||
384 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 389 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
385 | 390 | ||
386 | connect( this, SIGNAL( configChanged() ), | 391 | connect( this, SIGNAL( configChanged() ), |
387 | mDateNavigator, SLOT( updateConfig() ) ); | 392 | mDateNavigator, SLOT( updateConfig() ) ); |
388 | 393 | ||
389 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 394 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
390 | SLOT( newTodo() ) ); | 395 | SLOT( newTodo() ) ); |
391 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 396 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
392 | SLOT( newSubTodo( Todo * ) ) ); | 397 | SLOT( newSubTodo( Todo * ) ) ); |
393 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 398 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
394 | SLOT( editTodo( Todo * ) ) ); | 399 | SLOT( editTodo( Todo * ) ) ); |
395 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 400 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
396 | SLOT( showTodo( Todo *) ) ); | 401 | SLOT( showTodo( Todo *) ) ); |
397 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 402 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
398 | SLOT( deleteTodo( Todo *) ) ); | 403 | SLOT( deleteTodo( Todo *) ) ); |
399 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 404 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
400 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 405 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
401 | SLOT( purgeCompleted() ) ); | 406 | SLOT( purgeCompleted() ) ); |
402 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 407 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
403 | SIGNAL( todoModified( Todo *, int ) ) ); | 408 | SIGNAL( todoModified( Todo *, int ) ) ); |
404 | 409 | ||
405 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 410 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
406 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 411 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
407 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 412 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
408 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 413 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
409 | 414 | ||
410 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 415 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
411 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 416 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
412 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 417 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
413 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 418 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
414 | 419 | ||
415 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 420 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
416 | this, SLOT ( todo_unsub( Todo * ) ) ); | 421 | this, SLOT ( todo_unsub( Todo * ) ) ); |
417 | 422 | ||
418 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 423 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
419 | SLOT( updateTodo( Todo *, int ) ) ); | 424 | SLOT( updateTodo( Todo *, int ) ) ); |
420 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 425 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
421 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 426 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
422 | 427 | ||
423 | 428 | ||
424 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 429 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
425 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 430 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
426 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 431 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
427 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
428 | 433 | ||
429 | 434 | ||
430 | 435 | ||
431 | 436 | ||
432 | 437 | ||
433 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 438 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
434 | SLOT(checkClipboard())); | 439 | SLOT(checkClipboard())); |
435 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 440 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
436 | SLOT( processTodoListSelection( Incidence * ) ) ); | 441 | SLOT( processTodoListSelection( Incidence * ) ) ); |
437 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 442 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
438 | 443 | ||
439 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 444 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
440 | 445 | ||
441 | mDateFrame = new QVBox(0,0,WType_Popup); | 446 | mDateFrame = new QVBox(0,0,WType_Popup); |
442 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 447 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
443 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 448 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
444 | mDateFrame->setLineWidth(3); | 449 | mDateFrame->setLineWidth(3); |
445 | mDateFrame->hide(); | 450 | mDateFrame->hide(); |
446 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 451 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
447 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 452 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
448 | 453 | ||
449 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 454 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
450 | 455 | ||
451 | mEventEditor = mDialogManager->getEventEditor(); | 456 | mEventEditor = mDialogManager->getEventEditor(); |
452 | mTodoEditor = mDialogManager->getTodoEditor(); | 457 | mTodoEditor = mDialogManager->getTodoEditor(); |
453 | 458 | ||
454 | mFlagEditDescription = false; | 459 | mFlagEditDescription = false; |
455 | 460 | ||
456 | mSuspendTimer = new QTimer( this ); | 461 | mSuspendTimer = new QTimer( this ); |
457 | mAlarmTimer = new QTimer( this ); | 462 | mAlarmTimer = new QTimer( this ); |
458 | mRecheckAlarmTimer = new QTimer( this ); | 463 | mRecheckAlarmTimer = new QTimer( this ); |
459 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 464 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
460 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 465 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
461 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 466 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
462 | mAlarmDialog = new AlarmDialog( this ); | 467 | mAlarmDialog = new AlarmDialog( this ); |
463 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 468 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
464 | mAlarmDialog->setServerNotification( false ); | 469 | mAlarmDialog->setServerNotification( false ); |
465 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 470 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
466 | 471 | ||
467 | 472 | ||
468 | #ifndef DESKTOP_VERSION | 473 | #ifndef DESKTOP_VERSION |
469 | //US listen for arriving address resultsets | 474 | //US listen for arriving address resultsets |
470 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 475 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
471 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 476 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
472 | #endif | 477 | #endif |
473 | 478 | ||
474 | } | 479 | } |
475 | 480 | ||
476 | 481 | ||
477 | CalendarView::~CalendarView() | 482 | CalendarView::~CalendarView() |
478 | { | 483 | { |
479 | // kdDebug() << "~CalendarView()" << endl; | 484 | // kdDebug() << "~CalendarView()" << endl; |
480 | //qDebug("CalendarView::~CalendarView() "); | 485 | //qDebug("CalendarView::~CalendarView() "); |
481 | delete mDialogManager; | 486 | delete mDialogManager; |
482 | delete mViewManager; | 487 | delete mViewManager; |
483 | delete mStorage; | 488 | delete mStorage; |
484 | delete mDateFrame ; | 489 | delete mDateFrame ; |
485 | delete beamDialog; | 490 | delete beamDialog; |
486 | //kdDebug() << "~CalendarView() done" << endl; | 491 | //kdDebug() << "~CalendarView() done" << endl; |
487 | } | 492 | } |
488 | void CalendarView::timerAlarm() | 493 | void CalendarView::timerAlarm() |
489 | { | 494 | { |
490 | //qDebug("CalendarView::timerAlarm() "); | 495 | //qDebug("CalendarView::timerAlarm() "); |
491 | computeAlarm(mAlarmNotification ); | 496 | computeAlarm(mAlarmNotification ); |
492 | } | 497 | } |
493 | 498 | ||
494 | void CalendarView::suspendAlarm() | 499 | void CalendarView::suspendAlarm() |
495 | { | 500 | { |
496 | //qDebug(" CalendarView::suspendAlarm() "); | 501 | //qDebug(" CalendarView::suspendAlarm() "); |
497 | computeAlarm(mSuspendAlarmNotification ); | 502 | computeAlarm(mSuspendAlarmNotification ); |
498 | 503 | ||
499 | } | 504 | } |
500 | 505 | ||
501 | void CalendarView::startAlarm( QString mess , QString filename) | 506 | void CalendarView::startAlarm( QString mess , QString filename) |
502 | { | 507 | { |
503 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 508 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
504 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 509 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
505 | 510 | ||
506 | } | 511 | } |
507 | 512 | ||
508 | void CalendarView::checkNextTimerAlarm() | 513 | void CalendarView::checkNextTimerAlarm() |
509 | { | 514 | { |
510 | mCalendar->checkAlarmForIncidence( 0, true ); | 515 | mCalendar->checkAlarmForIncidence( 0, true ); |
511 | } | 516 | } |
512 | 517 | ||
513 | void CalendarView::computeAlarm( QString msg ) | 518 | void CalendarView::computeAlarm( QString msg ) |
514 | { | 519 | { |
515 | 520 | ||
516 | QString mess = msg; | 521 | QString mess = msg; |
517 | QString mAlarmMessage = mess.mid( 9 ); | 522 | QString mAlarmMessage = mess.mid( 9 ); |
518 | QString filename = MainWindow::resourcePath(); | 523 | QString filename = MainWindow::resourcePath(); |
519 | filename += "koalarm.wav"; | 524 | filename += "koalarm.wav"; |
520 | QString tempfilename; | 525 | QString tempfilename; |
521 | if ( mess.left( 13 ) == "suspend_alarm") { | 526 | if ( mess.left( 13 ) == "suspend_alarm") { |
522 | bool error = false; | 527 | bool error = false; |
523 | int len = mess.mid( 13 ).find("+++"); | 528 | int len = mess.mid( 13 ).find("+++"); |
524 | if ( len < 2 ) | 529 | if ( len < 2 ) |
525 | error = true; | 530 | error = true; |
526 | else { | 531 | else { |
527 | tempfilename = mess.mid( 13, len ); | 532 | tempfilename = mess.mid( 13, len ); |
528 | if ( !QFile::exists( tempfilename ) ) | 533 | if ( !QFile::exists( tempfilename ) ) |
529 | error = true; | 534 | error = true; |
530 | } | 535 | } |
531 | if ( ! error ) { | 536 | if ( ! error ) { |
532 | filename = tempfilename; | 537 | filename = tempfilename; |
533 | } | 538 | } |
534 | mAlarmMessage = mess.mid( 13+len+3 ); | 539 | mAlarmMessage = mess.mid( 13+len+3 ); |
535 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 540 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
536 | startAlarm( mAlarmMessage, filename); | 541 | startAlarm( mAlarmMessage, filename); |
537 | return; | 542 | return; |
538 | } | 543 | } |
539 | if ( mess.left( 11 ) == "timer_alarm") { | 544 | if ( mess.left( 11 ) == "timer_alarm") { |
540 | //mTimerTime = 0; | 545 | //mTimerTime = 0; |
541 | startAlarm( mess.mid( 11 ), filename ); | 546 | startAlarm( mess.mid( 11 ), filename ); |
@@ -949,769 +954,768 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
949 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 954 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
950 | if ( eventR ) { | 955 | if ( eventR ) { |
951 | eventRSync = (Event*) eventR->clone(); | 956 | eventRSync = (Event*) eventR->clone(); |
952 | remote->deleteEvent(eventR ); | 957 | remote->deleteEvent(eventR ); |
953 | 958 | ||
954 | } else { | 959 | } else { |
955 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 960 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
956 | eventRSync = (Event*)eventLSync->clone(); | 961 | eventRSync = (Event*)eventLSync->clone(); |
957 | } else { | 962 | } else { |
958 | fullDateRange = true; | 963 | fullDateRange = true; |
959 | eventRSync = new Event(); | 964 | eventRSync = new Event(); |
960 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 965 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
961 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 966 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
962 | eventRSync->setDtStart( mLastCalendarSync ); | 967 | eventRSync->setDtStart( mLastCalendarSync ); |
963 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 968 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
964 | eventRSync->setCategories( i18n("SyncEvent") ); | 969 | eventRSync->setCategories( i18n("SyncEvent") ); |
965 | } | 970 | } |
966 | } | 971 | } |
967 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 972 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
968 | fullDateRange = true; | 973 | fullDateRange = true; |
969 | 974 | ||
970 | if ( ! fullDateRange ) { | 975 | if ( ! fullDateRange ) { |
971 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 976 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
972 | 977 | ||
973 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 978 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
974 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 979 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
975 | fullDateRange = true; | 980 | fullDateRange = true; |
976 | } | 981 | } |
977 | } | 982 | } |
978 | if ( fullDateRange ) | 983 | if ( fullDateRange ) |
979 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 984 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
980 | else | 985 | else |
981 | mLastCalendarSync = eventLSync->dtStart(); | 986 | mLastCalendarSync = eventLSync->dtStart(); |
982 | // for resyncing if own file has changed | 987 | // for resyncing if own file has changed |
983 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 988 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
984 | mLastCalendarSync = loadedFileVersion; | 989 | mLastCalendarSync = loadedFileVersion; |
985 | qDebug("setting mLastCalendarSync "); | 990 | qDebug("setting mLastCalendarSync "); |
986 | } | 991 | } |
987 | //qDebug("*************************** "); | 992 | //qDebug("*************************** "); |
988 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 993 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
989 | QPtrList<Incidence> er = remote->rawIncidences(); | 994 | QPtrList<Incidence> er = remote->rawIncidences(); |
990 | Incidence* inR = er.first(); | 995 | Incidence* inR = er.first(); |
991 | Incidence* inL; | 996 | Incidence* inL; |
992 | QProgressBar bar( er.count(),0 ); | 997 | QProgressBar bar( er.count(),0 ); |
993 | bar.setCaption (i18n("Syncing - close to abort!") ); | 998 | bar.setCaption (i18n("Syncing - close to abort!") ); |
994 | 999 | ||
995 | int w = 300; | 1000 | int w = 300; |
996 | if ( QApplication::desktop()->width() < 320 ) | 1001 | if ( QApplication::desktop()->width() < 320 ) |
997 | w = 220; | 1002 | w = 220; |
998 | int h = bar.sizeHint().height() ; | 1003 | int h = bar.sizeHint().height() ; |
999 | int dw = QApplication::desktop()->width(); | 1004 | int dw = QApplication::desktop()->width(); |
1000 | int dh = QApplication::desktop()->height(); | 1005 | int dh = QApplication::desktop()->height(); |
1001 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1006 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1002 | bar.show(); | 1007 | bar.show(); |
1003 | int modulo = (er.count()/10)+1; | 1008 | int modulo = (er.count()/10)+1; |
1004 | int incCounter = 0; | 1009 | int incCounter = 0; |
1005 | while ( inR ) { | 1010 | while ( inR ) { |
1006 | if ( ! bar.isVisible() ) | 1011 | if ( ! bar.isVisible() ) |
1007 | return false; | 1012 | return false; |
1008 | if ( incCounter % modulo == 0 ) | 1013 | if ( incCounter % modulo == 0 ) |
1009 | bar.setProgress( incCounter ); | 1014 | bar.setProgress( incCounter ); |
1010 | ++incCounter; | 1015 | ++incCounter; |
1011 | uid = inR->uid(); | 1016 | uid = inR->uid(); |
1012 | bool skipIncidence = false; | 1017 | bool skipIncidence = false; |
1013 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1018 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1014 | skipIncidence = true; | 1019 | skipIncidence = true; |
1015 | QString idS; | 1020 | QString idS; |
1016 | qApp->processEvents(); | 1021 | qApp->processEvents(); |
1017 | if ( !skipIncidence ) { | 1022 | if ( !skipIncidence ) { |
1018 | inL = local->incidence( uid ); | 1023 | inL = local->incidence( uid ); |
1019 | if ( inL ) { // maybe conflict - same uid in both calendars | 1024 | if ( inL ) { // maybe conflict - same uid in both calendars |
1020 | int maxrev = inL->revision(); | 1025 | int maxrev = inL->revision(); |
1021 | if ( maxrev < inR->revision() ) | 1026 | if ( maxrev < inR->revision() ) |
1022 | maxrev = inR->revision(); | 1027 | maxrev = inR->revision(); |
1023 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1028 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1024 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1029 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1025 | if ( take == 3 ) | 1030 | if ( take == 3 ) |
1026 | return false; | 1031 | return false; |
1027 | if ( take == 1 ) {// take local | 1032 | if ( take == 1 ) {// take local |
1028 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1033 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1029 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1034 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1030 | else | 1035 | else |
1031 | idS = inR->IDStr(); | 1036 | idS = inR->IDStr(); |
1032 | remote->deleteIncidence( inR ); | 1037 | remote->deleteIncidence( inR ); |
1033 | if ( inL->revision() < maxrev ) | 1038 | if ( inL->revision() < maxrev ) |
1034 | inL->setRevision( maxrev ); | 1039 | inL->setRevision( maxrev ); |
1035 | inR = inL->clone(); | 1040 | inR = inL->clone(); |
1036 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1041 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1037 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1042 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1038 | inR->setIDStr( idS ); | 1043 | inR->setIDStr( idS ); |
1039 | remote->addIncidence( inR ); | 1044 | remote->addIncidence( inR ); |
1040 | ++changedRemote; | 1045 | ++changedRemote; |
1041 | } else { | 1046 | } else { |
1042 | if ( inR->revision() < maxrev ) | 1047 | if ( inR->revision() < maxrev ) |
1043 | inR->setRevision( maxrev ); | 1048 | inR->setRevision( maxrev ); |
1044 | idS = inL->IDStr(); | 1049 | idS = inL->IDStr(); |
1045 | local->deleteIncidence( inL ); | 1050 | local->deleteIncidence( inL ); |
1046 | inL = inR->clone(); | 1051 | inL = inR->clone(); |
1047 | inL->setIDStr( idS ); | 1052 | inL->setIDStr( idS ); |
1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1049 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1054 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1050 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1055 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1051 | } | 1056 | } |
1052 | local->addIncidence( inL ); | 1057 | local->addIncidence( inL ); |
1053 | ++changedLocal; | 1058 | ++changedLocal; |
1054 | } | 1059 | } |
1055 | } | 1060 | } |
1056 | } else { // no conflict | 1061 | } else { // no conflict |
1057 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1058 | QString des = eventLSync->description(); | 1063 | QString des = eventLSync->description(); |
1059 | QString pref = "e"; | 1064 | QString pref = "e"; |
1060 | if ( inR->type() == "Todo" ) | 1065 | if ( inR->type() == "Todo" ) |
1061 | pref = "t"; | 1066 | pref = "t"; |
1062 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1063 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1064 | //remote->deleteIncidence( inR ); | 1069 | //remote->deleteIncidence( inR ); |
1065 | ++deletedEventR; | 1070 | ++deletedEventR; |
1066 | } else { | 1071 | } else { |
1067 | inR->setLastModified( modifiedCalendar ); | 1072 | inR->setLastModified( modifiedCalendar ); |
1068 | inL = inR->clone(); | 1073 | inL = inR->clone(); |
1069 | local->addIncidence( inL ); | 1074 | local->addIncidence( inL ); |
1070 | ++addedEvent; | 1075 | ++addedEvent; |
1071 | } | 1076 | } |
1072 | } else { | 1077 | } else { |
1073 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1078 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1074 | inR->setLastModified( modifiedCalendar ); | 1079 | inR->setLastModified( modifiedCalendar ); |
1075 | local->addIncidence( inR->clone() ); | 1080 | local->addIncidence( inR->clone() ); |
1076 | ++addedEvent; | 1081 | ++addedEvent; |
1077 | } else { | 1082 | } else { |
1078 | checkExternSyncEvent(eventRSyncSharp, inR); | 1083 | checkExternSyncEvent(eventRSyncSharp, inR); |
1079 | remote->deleteIncidence( inR ); | 1084 | remote->deleteIncidence( inR ); |
1080 | ++deletedEventR; | 1085 | ++deletedEventR; |
1081 | } | 1086 | } |
1082 | } | 1087 | } |
1083 | } | 1088 | } |
1084 | } | 1089 | } |
1085 | inR = er.next(); | 1090 | inR = er.next(); |
1086 | } | 1091 | } |
1087 | QPtrList<Incidence> el = local->rawIncidences(); | 1092 | QPtrList<Incidence> el = local->rawIncidences(); |
1088 | inL = el.first(); | 1093 | inL = el.first(); |
1089 | modulo = (el.count()/10)+1; | 1094 | modulo = (el.count()/10)+1; |
1090 | bar.setCaption (i18n("Add / remove events") ); | 1095 | bar.setCaption (i18n("Add / remove events") ); |
1091 | bar.setTotalSteps ( el.count() ) ; | 1096 | bar.setTotalSteps ( el.count() ) ; |
1092 | bar.show(); | 1097 | bar.show(); |
1093 | incCounter = 0; | 1098 | incCounter = 0; |
1094 | 1099 | ||
1095 | while ( inL ) { | 1100 | while ( inL ) { |
1096 | 1101 | ||
1097 | qApp->processEvents(); | 1102 | qApp->processEvents(); |
1098 | if ( ! bar.isVisible() ) | 1103 | if ( ! bar.isVisible() ) |
1099 | return false; | 1104 | return false; |
1100 | if ( incCounter % modulo == 0 ) | 1105 | if ( incCounter % modulo == 0 ) |
1101 | bar.setProgress( incCounter ); | 1106 | bar.setProgress( incCounter ); |
1102 | ++incCounter; | 1107 | ++incCounter; |
1103 | uid = inL->uid(); | 1108 | uid = inL->uid(); |
1104 | bool skipIncidence = false; | 1109 | bool skipIncidence = false; |
1105 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1110 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1106 | skipIncidence = true; | 1111 | skipIncidence = true; |
1107 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1112 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1108 | skipIncidence = true; | 1113 | skipIncidence = true; |
1109 | if ( !skipIncidence ) { | 1114 | if ( !skipIncidence ) { |
1110 | inR = remote->incidence( uid ); | 1115 | inR = remote->incidence( uid ); |
1111 | if ( ! inR ) { | 1116 | if ( ! inR ) { |
1112 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1117 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1113 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1118 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1114 | checkExternSyncEvent(eventLSyncSharp, inL); | 1119 | checkExternSyncEvent(eventLSyncSharp, inL); |
1115 | local->deleteIncidence( inL ); | 1120 | local->deleteIncidence( inL ); |
1116 | ++deletedEventL; | 1121 | ++deletedEventL; |
1117 | } else { | 1122 | } else { |
1118 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1123 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1119 | inL->removeID(mCurrentSyncDevice ); | 1124 | inL->removeID(mCurrentSyncDevice ); |
1120 | ++addedEventR; | 1125 | ++addedEventR; |
1121 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1126 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1122 | inL->setLastModified( modifiedCalendar ); | 1127 | inL->setLastModified( modifiedCalendar ); |
1123 | inR = inL->clone(); | 1128 | inR = inL->clone(); |
1124 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1129 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1125 | remote->addIncidence( inR ); | 1130 | remote->addIncidence( inR ); |
1126 | } | 1131 | } |
1127 | } | 1132 | } |
1128 | } else { | 1133 | } else { |
1129 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1134 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1130 | checkExternSyncEvent(eventLSyncSharp, inL); | 1135 | checkExternSyncEvent(eventLSyncSharp, inL); |
1131 | local->deleteIncidence( inL ); | 1136 | local->deleteIncidence( inL ); |
1132 | ++deletedEventL; | 1137 | ++deletedEventL; |
1133 | } else { | 1138 | } else { |
1134 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1139 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1135 | ++addedEventR; | 1140 | ++addedEventR; |
1136 | inL->setLastModified( modifiedCalendar ); | 1141 | inL->setLastModified( modifiedCalendar ); |
1137 | remote->addIncidence( inL->clone() ); | 1142 | remote->addIncidence( inL->clone() ); |
1138 | } | 1143 | } |
1139 | } | 1144 | } |
1140 | } | 1145 | } |
1141 | } | 1146 | } |
1142 | } | 1147 | } |
1143 | inL = el.next(); | 1148 | inL = el.next(); |
1144 | } | 1149 | } |
1145 | int delFut = 0; | 1150 | int delFut = 0; |
1146 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1151 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1147 | er = remote->rawIncidences(); | 1152 | er = remote->rawIncidences(); |
1148 | inR = er.first(); | 1153 | inR = er.first(); |
1149 | QDateTime dt; | 1154 | QDateTime dt; |
1150 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1155 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1151 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); | 1156 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); |
1152 | while ( inR ) { | 1157 | while ( inR ) { |
1153 | if ( inR->type() == "Todo" ) { | 1158 | if ( inR->type() == "Todo" ) { |
1154 | Todo * t = (Todo*)inR; | 1159 | Todo * t = (Todo*)inR; |
1155 | if ( t->hasDueDate() ) | 1160 | if ( t->hasDueDate() ) |
1156 | dt = t->dtDue(); | 1161 | dt = t->dtDue(); |
1157 | else | 1162 | else |
1158 | dt = cur.addSecs( 62 ); | 1163 | dt = cur.addSecs( 62 ); |
1159 | } | 1164 | } |
1160 | else if (inR->type() == "Event" ) { | 1165 | else if (inR->type() == "Event" ) { |
1161 | bool ok; | 1166 | bool ok; |
1162 | dt = inR->getNextOccurence( cur, &ok ); | 1167 | dt = inR->getNextOccurence( cur, &ok ); |
1163 | if ( !ok ) | 1168 | if ( !ok ) |
1164 | dt = cur.addSecs( -62 ); | 1169 | dt = cur.addSecs( -62 ); |
1165 | } | 1170 | } |
1166 | else | 1171 | else |
1167 | dt = inR->dtStart(); | 1172 | dt = inR->dtStart(); |
1168 | if ( dt < cur || dt > end ) { | 1173 | if ( dt < cur || dt > end ) { |
1169 | remote->deleteIncidence( inR ); | 1174 | remote->deleteIncidence( inR ); |
1170 | ++delFut; | 1175 | ++delFut; |
1171 | } | 1176 | } |
1172 | inR = er.next(); | 1177 | inR = er.next(); |
1173 | } | 1178 | } |
1174 | } | 1179 | } |
1175 | bar.hide(); | 1180 | bar.hide(); |
1176 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1181 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1177 | eventLSync->setReadOnly( false ); | 1182 | eventLSync->setReadOnly( false ); |
1178 | eventLSync->setDtStart( mLastCalendarSync ); | 1183 | eventLSync->setDtStart( mLastCalendarSync ); |
1179 | eventRSync->setDtStart( mLastCalendarSync ); | 1184 | eventRSync->setDtStart( mLastCalendarSync ); |
1180 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1185 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1181 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1186 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1182 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1187 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1183 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1188 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1184 | eventLSync->setReadOnly( true ); | 1189 | eventLSync->setReadOnly( true ); |
1185 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1190 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1186 | remote->addEvent( eventRSync ); | 1191 | remote->addEvent( eventRSync ); |
1187 | QString mes; | 1192 | QString mes; |
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 ); | 1193 | 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 ); |
1189 | QString delmess; | 1194 | QString delmess; |
1190 | if ( delFut ) { | 1195 | if ( delFut ) { |
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 ); | 1196 | 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 ); |
1192 | mes += delmess; | 1197 | mes += delmess; |
1193 | } | 1198 | } |
1194 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1199 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1195 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1200 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1196 | } | 1201 | } |
1197 | qDebug( mes ); | 1202 | qDebug( mes ); |
1198 | mCalendar->checkAlarmForIncidence( 0, true ); | 1203 | mCalendar->checkAlarmForIncidence( 0, true ); |
1199 | return syncOK; | 1204 | return syncOK; |
1200 | } | 1205 | } |
1201 | 1206 | ||
1202 | void CalendarView::setSyncDevice( QString s ) | 1207 | void CalendarView::setSyncDevice( QString s ) |
1203 | { | 1208 | { |
1204 | mCurrentSyncDevice= s; | 1209 | mCurrentSyncDevice= s; |
1205 | } | 1210 | } |
1206 | void CalendarView::setSyncName( QString s ) | 1211 | void CalendarView::setSyncName( QString s ) |
1207 | { | 1212 | { |
1208 | mCurrentSyncName= s; | 1213 | mCurrentSyncName= s; |
1209 | } | 1214 | } |
1210 | bool CalendarView::syncCalendar(QString filename, int mode) | 1215 | bool CalendarView::syncCalendar(QString filename, int mode) |
1211 | { | 1216 | { |
1212 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1217 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1213 | CalendarLocal* calendar = new CalendarLocal(); | 1218 | CalendarLocal* calendar = new CalendarLocal(); |
1214 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1219 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1215 | FileStorage* storage = new FileStorage( calendar ); | 1220 | FileStorage* storage = new FileStorage( calendar ); |
1216 | bool syncOK = false; | 1221 | bool syncOK = false; |
1217 | storage->setFileName( filename ); | 1222 | storage->setFileName( filename ); |
1218 | // qDebug("loading ... "); | 1223 | // qDebug("loading ... "); |
1219 | if ( storage->load() ) { | 1224 | if ( storage->load() ) { |
1220 | getEventViewerDialog()->setSyncMode( true ); | 1225 | getEventViewerDialog()->setSyncMode( true ); |
1221 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1226 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1222 | getEventViewerDialog()->setSyncMode( false ); | 1227 | getEventViewerDialog()->setSyncMode( false ); |
1223 | if ( syncOK ) { | 1228 | if ( syncOK ) { |
1224 | if ( KOPrefs::instance()->mWriteBackFile ) | 1229 | if ( KOPrefs::instance()->mWriteBackFile ) |
1225 | { | 1230 | { |
1226 | storage->setSaveFormat( new ICalFormat() ); | 1231 | storage->setSaveFormat( new ICalFormat() ); |
1227 | storage->save(); | 1232 | storage->save(); |
1228 | } | 1233 | } |
1229 | } | 1234 | } |
1230 | setModified( true ); | 1235 | setModified( true ); |
1231 | } | 1236 | } |
1232 | delete storage; | 1237 | delete storage; |
1233 | delete calendar; | 1238 | delete calendar; |
1234 | if ( syncOK ) | 1239 | if ( syncOK ) |
1235 | updateView(); | 1240 | updateView(); |
1236 | return syncOK; | 1241 | return syncOK; |
1237 | } | 1242 | } |
1238 | void CalendarView::syncPhone() | 1243 | void CalendarView::syncPhone() |
1239 | { | 1244 | { |
1240 | syncExternal( 1 ); | 1245 | syncExternal( 1 ); |
1241 | } | 1246 | } |
1242 | void CalendarView::syncExternal( int mode ) | 1247 | void CalendarView::syncExternal( int mode ) |
1243 | { | 1248 | { |
1244 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1249 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1245 | //mCurrentSyncDevice = "sharp-DTM"; | 1250 | //mCurrentSyncDevice = "sharp-DTM"; |
1246 | if ( KOPrefs::instance()->mAskForPreferences ) | 1251 | if ( KOPrefs::instance()->mAskForPreferences ) |
1247 | edit_sync_options(); | 1252 | edit_sync_options(); |
1248 | qApp->processEvents(); | 1253 | qApp->processEvents(); |
1249 | CalendarLocal* calendar = new CalendarLocal(); | 1254 | CalendarLocal* calendar = new CalendarLocal(); |
1250 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1255 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1251 | bool syncOK = false; | 1256 | bool syncOK = false; |
1252 | bool loadSuccess = false; | 1257 | bool loadSuccess = false; |
1253 | PhoneFormat* phoneFormat = 0; | 1258 | PhoneFormat* phoneFormat = 0; |
1254 | #ifndef DESKTOP_VERSION | 1259 | #ifndef DESKTOP_VERSION |
1255 | SharpFormat* sharpFormat = 0; | 1260 | SharpFormat* sharpFormat = 0; |
1256 | if ( mode == 0 ) { // sharp | 1261 | if ( mode == 0 ) { // sharp |
1257 | sharpFormat = new SharpFormat () ; | 1262 | sharpFormat = new SharpFormat () ; |
1258 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1263 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1259 | 1264 | ||
1260 | } else | 1265 | } else |
1261 | #endif | 1266 | #endif |
1262 | if ( mode == 1 ) { // phone | 1267 | if ( mode == 1 ) { // phone |
1263 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1268 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1264 | KOPrefs::instance()->mPhoneDevice, | 1269 | KOPrefs::instance()->mPhoneDevice, |
1265 | KOPrefs::instance()->mPhoneConnection, | 1270 | KOPrefs::instance()->mPhoneConnection, |
1266 | KOPrefs::instance()->mPhoneModel); | 1271 | KOPrefs::instance()->mPhoneModel); |
1267 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1272 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1268 | 1273 | ||
1269 | } else | 1274 | } else |
1270 | return; | 1275 | return; |
1271 | if ( loadSuccess ) { | 1276 | if ( loadSuccess ) { |
1272 | getEventViewerDialog()->setSyncMode( true ); | 1277 | getEventViewerDialog()->setSyncMode( true ); |
1273 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1278 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1274 | getEventViewerDialog()->setSyncMode( false ); | 1279 | getEventViewerDialog()->setSyncMode( false ); |
1275 | qApp->processEvents(); | 1280 | qApp->processEvents(); |
1276 | if ( syncOK ) { | 1281 | if ( syncOK ) { |
1277 | if ( KOPrefs::instance()->mWriteBackFile ) | 1282 | if ( KOPrefs::instance()->mWriteBackFile ) |
1278 | { | 1283 | { |
1279 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1284 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1280 | Incidence* inc = iL.first(); | 1285 | Incidence* inc = iL.first(); |
1281 | if ( phoneFormat ) { | 1286 | if ( phoneFormat ) { |
1282 | while ( inc ) { | 1287 | while ( inc ) { |
1283 | inc->removeID(mCurrentSyncDevice); | 1288 | inc->removeID(mCurrentSyncDevice); |
1284 | inc = iL.next(); | 1289 | inc = iL.next(); |
1285 | } | 1290 | } |
1286 | } | 1291 | } |
1287 | #ifndef DESKTOP_VERSION | 1292 | #ifndef DESKTOP_VERSION |
1288 | if ( sharpFormat ) | 1293 | if ( sharpFormat ) |
1289 | sharpFormat->save(calendar); | 1294 | sharpFormat->save(calendar); |
1290 | #endif | 1295 | #endif |
1291 | if ( phoneFormat ) | 1296 | if ( phoneFormat ) |
1292 | phoneFormat->save(calendar); | 1297 | phoneFormat->save(calendar); |
1293 | iL = calendar->rawIncidences(); | 1298 | iL = calendar->rawIncidences(); |
1294 | inc = iL.first(); | 1299 | inc = iL.first(); |
1295 | Incidence* loc; | 1300 | Incidence* loc; |
1296 | while ( inc ) { | 1301 | while ( inc ) { |
1297 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1302 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1298 | loc = mCalendar->incidence(inc->uid() ); | 1303 | loc = mCalendar->incidence(inc->uid() ); |
1299 | if ( loc ) { | 1304 | if ( loc ) { |
1300 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1305 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1301 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1306 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1302 | } | 1307 | } |
1303 | } | 1308 | } |
1304 | inc = iL.next(); | 1309 | inc = iL.next(); |
1305 | } | 1310 | } |
1306 | Incidence* lse = getLastSyncEvent(); | 1311 | Incidence* lse = getLastSyncEvent(); |
1307 | if ( lse ) { | 1312 | if ( lse ) { |
1308 | lse->setReadOnly( false ); | 1313 | lse->setReadOnly( false ); |
1309 | lse->setDescription( "" ); | 1314 | lse->setDescription( "" ); |
1310 | lse->setReadOnly( true ); | 1315 | lse->setReadOnly( true ); |
1311 | } | 1316 | } |
1312 | } | 1317 | } |
1313 | } | 1318 | } |
1314 | setModified( true ); | 1319 | setModified( true ); |
1315 | } else { | 1320 | } else { |
1316 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1321 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1317 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1322 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1318 | question, i18n("Ok")) ; | 1323 | question, i18n("Ok")) ; |
1319 | 1324 | ||
1320 | } | 1325 | } |
1321 | delete calendar; | 1326 | delete calendar; |
1322 | updateView(); | 1327 | updateView(); |
1323 | return ;//syncOK; | 1328 | return ;//syncOK; |
1324 | 1329 | ||
1325 | } | 1330 | } |
1326 | void CalendarView::syncSharp() | 1331 | void CalendarView::syncSharp() |
1327 | { | 1332 | { |
1328 | syncExternal( 0 ); | 1333 | syncExternal( 0 ); |
1329 | 1334 | ||
1330 | } | 1335 | } |
1331 | 1336 | ||
1332 | 1337 | ||
1333 | //#include <kabc/stdaddressbook.h> | ||
1334 | bool CalendarView::importBday() | 1338 | bool CalendarView::importBday() |
1335 | { | 1339 | { |
1336 | #ifndef KORG_NOKABC | 1340 | #ifndef KORG_NOKABC |
1337 | 1341 | ||
1338 | #ifdef DESKTOP_VERSION | 1342 | #ifdef DESKTOP_VERSION |
1339 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1343 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1340 | KABC::AddressBook::Iterator it; | 1344 | KABC::AddressBook::Iterator it; |
1341 | int count = 0; | 1345 | int count = 0; |
1342 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1346 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1343 | ++count; | 1347 | ++count; |
1344 | } | 1348 | } |
1345 | QProgressBar bar(count,0 ); | 1349 | QProgressBar bar(count,0 ); |
1346 | int w = 300; | 1350 | int w = 300; |
1347 | if ( QApplication::desktop()->width() < 320 ) | 1351 | if ( QApplication::desktop()->width() < 320 ) |
1348 | w = 220; | 1352 | w = 220; |
1349 | int h = bar.sizeHint().height() ; | 1353 | int h = bar.sizeHint().height() ; |
1350 | int dw = QApplication::desktop()->width(); | 1354 | int dw = QApplication::desktop()->width(); |
1351 | int dh = QApplication::desktop()->height(); | 1355 | int dh = QApplication::desktop()->height(); |
1352 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1356 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1353 | bar.show(); | 1357 | bar.show(); |
1354 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1358 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1355 | qApp->processEvents(); | 1359 | qApp->processEvents(); |
1356 | count = 0; | 1360 | count = 0; |
1357 | int addCount = 0; | 1361 | int addCount = 0; |
1358 | KCal::Attendee* a = 0; | 1362 | KCal::Attendee* a = 0; |
1359 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1363 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1360 | if ( ! bar.isVisible() ) | 1364 | if ( ! bar.isVisible() ) |
1361 | return false; | 1365 | return false; |
1362 | bar.setProgress( count++ ); | 1366 | bar.setProgress( count++ ); |
1363 | qApp->processEvents(); | 1367 | qApp->processEvents(); |
1364 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1368 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1365 | if ( (*it).birthday().date().isValid() ){ | 1369 | if ( (*it).birthday().date().isValid() ){ |
1366 | 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()) ; |
1367 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1371 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1368 | ++addCount; | 1372 | ++addCount; |
1369 | } | 1373 | } |
1370 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1374 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1371 | if ( anni.isValid() ){ | 1375 | if ( anni.isValid() ){ |
1372 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1376 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1373 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1377 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1374 | ++addCount; | 1378 | ++addCount; |
1375 | } | 1379 | } |
1376 | } | 1380 | } |
1377 | updateView(); | 1381 | updateView(); |
1378 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1382 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1379 | #else //DESKTOP_VERSION | 1383 | #else //DESKTOP_VERSION |
1380 | 1384 | ||
1381 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1385 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1382 | // the result should now arrive through method insertBirthdays | 1386 | // the result should now arrive through method insertBirthdays |
1383 | 1387 | ||
1384 | #endif //DESKTOP_VERSION | 1388 | #endif //DESKTOP_VERSION |
1385 | 1389 | ||
1386 | #endif //KORG_NOKABC | 1390 | #endif //KORG_NOKABC |
1387 | 1391 | ||
1388 | 1392 | ||
1389 | return true; | 1393 | return true; |
1390 | } | 1394 | } |
1391 | 1395 | ||
1392 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1396 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1393 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1397 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1394 | const QStringList& anniversaryList, const QStringList& realNameList, | 1398 | const QStringList& anniversaryList, const QStringList& realNameList, |
1395 | const QStringList& emailList, const QStringList& assembledNameList, | 1399 | const QStringList& emailList, const QStringList& assembledNameList, |
1396 | const QStringList& uidList) | 1400 | const QStringList& uidList) |
1397 | { | 1401 | { |
1398 | qDebug("CalendarView::insertBirthdays"); | 1402 | qDebug("CalendarView::insertBirthdays"); |
1399 | if (uid == this->name()) | 1403 | if (uid == this->name()) |
1400 | { | 1404 | { |
1401 | int count = birthdayList.count(); | 1405 | int count = birthdayList.count(); |
1402 | int addCount = 0; | 1406 | int addCount = 0; |
1403 | KCal::Attendee* a = 0; | 1407 | KCal::Attendee* a = 0; |
1404 | 1408 | ||
1405 | qDebug("CalView 1 %i", count); | 1409 | qDebug("CalView 1 %i", count); |
1406 | 1410 | ||
1407 | QProgressBar bar(count,0 ); | 1411 | QProgressBar bar(count,0 ); |
1408 | int w = 300; | 1412 | int w = 300; |
1409 | if ( QApplication::desktop()->width() < 320 ) | 1413 | if ( QApplication::desktop()->width() < 320 ) |
1410 | w = 220; | 1414 | w = 220; |
1411 | int h = bar.sizeHint().height() ; | 1415 | int h = bar.sizeHint().height() ; |
1412 | int dw = QApplication::desktop()->width(); | 1416 | int dw = QApplication::desktop()->width(); |
1413 | int dh = QApplication::desktop()->height(); | 1417 | int dh = QApplication::desktop()->height(); |
1414 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1418 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1415 | bar.show(); | 1419 | bar.show(); |
1416 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1420 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1417 | qApp->processEvents(); | 1421 | qApp->processEvents(); |
1418 | 1422 | ||
1419 | QDate birthday; | 1423 | QDate birthday; |
1420 | QDate anniversary; | 1424 | QDate anniversary; |
1421 | QString realName; | 1425 | QString realName; |
1422 | QString email; | 1426 | QString email; |
1423 | QString assembledName; | 1427 | QString assembledName; |
1424 | QString uid; | 1428 | QString uid; |
1425 | bool ok = true; | 1429 | bool ok = true; |
1426 | for ( int i = 0; i < count; i++) | 1430 | for ( int i = 0; i < count; i++) |
1427 | { | 1431 | { |
1428 | if ( ! bar.isVisible() ) | 1432 | if ( ! bar.isVisible() ) |
1429 | return; | 1433 | return; |
1430 | bar.setProgress( i ); | 1434 | bar.setProgress( i ); |
1431 | qApp->processEvents(); | 1435 | qApp->processEvents(); |
1432 | 1436 | ||
1433 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1437 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1434 | if (!ok) { | 1438 | if (!ok) { |
1435 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1439 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1436 | } | 1440 | } |
1437 | 1441 | ||
1438 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1442 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1439 | if (!ok) { | 1443 | if (!ok) { |
1440 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1444 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1441 | } | 1445 | } |
1442 | realName = realNameList[i]; | 1446 | realName = realNameList[i]; |
1443 | email = emailList[i]; | 1447 | email = emailList[i]; |
1444 | assembledName = assembledNameList[i]; | 1448 | assembledName = assembledNameList[i]; |
1445 | uid = uidList[i]; | 1449 | uid = uidList[i]; |
1446 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1450 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1447 | 1451 | ||
1448 | if ( birthday.isValid() ){ | 1452 | if ( birthday.isValid() ){ |
1449 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1453 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1450 | KCal::Attendee::ReqParticipant,uid) ; | 1454 | KCal::Attendee::ReqParticipant,uid) ; |
1451 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1455 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1452 | ++addCount; | 1456 | ++addCount; |
1453 | } | 1457 | } |
1454 | 1458 | ||
1455 | if ( anniversary.isValid() ){ | 1459 | if ( anniversary.isValid() ){ |
1456 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1460 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1457 | KCal::Attendee::ReqParticipant,uid) ; | 1461 | KCal::Attendee::ReqParticipant,uid) ; |
1458 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1462 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1459 | ++addCount; | 1463 | ++addCount; |
1460 | } | 1464 | } |
1461 | } | 1465 | } |
1462 | 1466 | ||
1463 | updateView(); | 1467 | updateView(); |
1464 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1468 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1465 | 1469 | ||
1466 | } | 1470 | } |
1467 | 1471 | ||
1468 | } | 1472 | } |
1469 | 1473 | ||
1470 | 1474 | ||
1471 | 1475 | ||
1472 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1476 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1473 | { | 1477 | { |
1474 | //qDebug("addAnni "); | 1478 | //qDebug("addAnni "); |
1475 | Event * ev = new Event(); | 1479 | Event * ev = new Event(); |
1476 | if ( a ) { | 1480 | if ( a ) { |
1477 | ev->addAttendee( a ); | 1481 | ev->addAttendee( a ); |
1478 | } | 1482 | } |
1479 | QString kind; | 1483 | QString kind; |
1480 | if ( birthday ) | 1484 | if ( birthday ) |
1481 | kind = i18n( "Birthday" ); | 1485 | kind = i18n( "Birthday" ); |
1482 | else | 1486 | else |
1483 | kind = i18n( "Anniversary" ); | 1487 | kind = i18n( "Anniversary" ); |
1484 | ev->setSummary( name + " - " + kind ); | 1488 | ev->setSummary( name + " - " + kind ); |
1485 | ev->setOrganizer( "nobody@nowhere" ); | 1489 | ev->setOrganizer( "nobody@nowhere" ); |
1486 | ev->setCategories( kind ); | 1490 | ev->setCategories( kind ); |
1487 | ev->setDtStart( QDateTime(date) ); | 1491 | ev->setDtStart( QDateTime(date) ); |
1488 | ev->setDtEnd( QDateTime(date) ); | 1492 | ev->setDtEnd( QDateTime(date) ); |
1489 | ev->setFloats( true ); | 1493 | ev->setFloats( true ); |
1490 | Recurrence * rec = ev->recurrence(); | 1494 | Recurrence * rec = ev->recurrence(); |
1491 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1495 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1492 | rec->addYearlyNum( date.month() ); | 1496 | rec->addYearlyNum( date.month() ); |
1493 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1497 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1494 | delete ev; | 1498 | delete ev; |
1495 | return false; | 1499 | return false; |
1496 | } | 1500 | } |
1497 | return true; | 1501 | return true; |
1498 | 1502 | ||
1499 | } | 1503 | } |
1500 | bool CalendarView::importQtopia( const QString &categories, | 1504 | bool CalendarView::importQtopia( const QString &categories, |
1501 | const QString &datebook, | 1505 | const QString &datebook, |
1502 | const QString &todolist ) | 1506 | const QString &todolist ) |
1503 | { | 1507 | { |
1504 | 1508 | ||
1505 | QtopiaFormat qtopiaFormat; | 1509 | QtopiaFormat qtopiaFormat; |
1506 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1510 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1507 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1511 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1508 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1512 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1509 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1513 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1510 | 1514 | ||
1511 | updateView(); | 1515 | updateView(); |
1512 | return true; | 1516 | return true; |
1513 | 1517 | ||
1514 | #if 0 | 1518 | #if 0 |
1515 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1519 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1516 | mCurrentSyncDevice = "qtopia-XML"; | 1520 | mCurrentSyncDevice = "qtopia-XML"; |
1517 | if ( KOPrefs::instance()->mAskForPreferences ) | 1521 | if ( KOPrefs::instance()->mAskForPreferences ) |
1518 | edit_sync_options(); | 1522 | edit_sync_options(); |
1519 | qApp->processEvents(); | 1523 | qApp->processEvents(); |
1520 | CalendarLocal* calendar = new CalendarLocal(); | 1524 | CalendarLocal* calendar = new CalendarLocal(); |
1521 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1525 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1522 | bool syncOK = false; | 1526 | bool syncOK = false; |
1523 | QtopiaFormat qtopiaFormat; | 1527 | QtopiaFormat qtopiaFormat; |
1524 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1528 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1525 | bool loadOk = true; | 1529 | bool loadOk = true; |
1526 | if ( !categories.isEmpty() ) | 1530 | if ( !categories.isEmpty() ) |
1527 | loadOk = qtopiaFormat.load( calendar, categories ); | 1531 | loadOk = qtopiaFormat.load( calendar, categories ); |
1528 | if ( loadOk && !datebook.isEmpty() ) | 1532 | if ( loadOk && !datebook.isEmpty() ) |
1529 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1533 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1530 | if ( loadOk && !todolist.isEmpty() ) | 1534 | if ( loadOk && !todolist.isEmpty() ) |
1531 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1535 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1532 | 1536 | ||
1533 | if ( loadOk ) { | 1537 | if ( loadOk ) { |
1534 | getEventViewerDialog()->setSyncMode( true ); | 1538 | getEventViewerDialog()->setSyncMode( true ); |
1535 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1539 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1536 | getEventViewerDialog()->setSyncMode( false ); | 1540 | getEventViewerDialog()->setSyncMode( false ); |
1537 | qApp->processEvents(); | 1541 | qApp->processEvents(); |
1538 | if ( syncOK ) { | 1542 | if ( syncOK ) { |
1539 | if ( KOPrefs::instance()->mWriteBackFile ) | 1543 | if ( KOPrefs::instance()->mWriteBackFile ) |
1540 | { | 1544 | { |
1541 | // write back XML file | 1545 | // write back XML file |
1542 | 1546 | ||
1543 | } | 1547 | } |
1544 | setModified( true ); | 1548 | setModified( true ); |
1545 | } | 1549 | } |
1546 | } else { | 1550 | } else { |
1547 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1551 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1548 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1552 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1549 | question, i18n("Ok")) ; | 1553 | question, i18n("Ok")) ; |
1550 | } | 1554 | } |
1551 | delete calendar; | 1555 | delete calendar; |
1552 | updateView(); | 1556 | updateView(); |
1553 | return syncOK; | 1557 | return syncOK; |
1554 | 1558 | ||
1555 | 1559 | ||
1556 | #endif | 1560 | #endif |
1557 | 1561 | ||
1558 | } | 1562 | } |
1559 | 1563 | ||
1560 | void CalendarView::setSyncEventsReadOnly() | 1564 | void CalendarView::setSyncEventsReadOnly() |
1561 | { | 1565 | { |
1562 | Event * ev; | 1566 | Event * ev; |
1563 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1567 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1564 | ev = eL.first(); | 1568 | ev = eL.first(); |
1565 | while ( ev ) { | 1569 | while ( ev ) { |
1566 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1570 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1567 | ev->setReadOnly( true ); | 1571 | ev->setReadOnly( true ); |
1568 | ev = eL.next(); | 1572 | ev = eL.next(); |
1569 | } | 1573 | } |
1570 | } | 1574 | } |
1571 | bool CalendarView::openCalendar(QString filename, bool merge) | 1575 | bool CalendarView::openCalendar(QString filename, bool merge) |
1572 | { | 1576 | { |
1573 | 1577 | ||
1574 | if (filename.isEmpty()) { | 1578 | if (filename.isEmpty()) { |
1575 | return false; | 1579 | return false; |
1576 | } | 1580 | } |
1577 | 1581 | ||
1578 | if (!QFile::exists(filename)) { | 1582 | if (!QFile::exists(filename)) { |
1579 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1583 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1580 | return false; | 1584 | return false; |
1581 | } | 1585 | } |
1582 | 1586 | ||
1583 | globalFlagBlockAgenda = 1; | 1587 | globalFlagBlockAgenda = 1; |
1584 | if (!merge) mCalendar->close(); | 1588 | if (!merge) mCalendar->close(); |
1585 | 1589 | ||
1586 | mStorage->setFileName( filename ); | 1590 | mStorage->setFileName( filename ); |
1587 | 1591 | ||
1588 | if ( mStorage->load() ) { | 1592 | if ( mStorage->load() ) { |
1589 | if ( merge ) ;//setModified( true ); | 1593 | if ( merge ) ;//setModified( true ); |
1590 | else { | 1594 | else { |
1591 | //setModified( true ); | 1595 | //setModified( true ); |
1592 | mViewManager->setDocumentId( filename ); | 1596 | mViewManager->setDocumentId( filename ); |
1593 | mDialogManager->setDocumentId( filename ); | 1597 | mDialogManager->setDocumentId( filename ); |
1594 | mTodoList->setDocumentId( filename ); | 1598 | mTodoList->setDocumentId( filename ); |
1595 | } | 1599 | } |
1596 | globalFlagBlockAgenda = 2; | 1600 | globalFlagBlockAgenda = 2; |
1597 | // if ( getLastSyncEvent() ) | 1601 | // if ( getLastSyncEvent() ) |
1598 | // getLastSyncEvent()->setReadOnly( true ); | 1602 | // getLastSyncEvent()->setReadOnly( true ); |
1599 | mCalendar->reInitAlarmSettings(); | 1603 | mCalendar->reInitAlarmSettings(); |
1600 | setSyncEventsReadOnly(); | 1604 | setSyncEventsReadOnly(); |
1601 | updateUnmanagedViews(); | 1605 | updateUnmanagedViews(); |
1602 | updateView(); | 1606 | updateView(); |
1603 | setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); | 1607 | setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); |
1604 | if ( filename != MainWindow::defaultFileName() ) { | 1608 | if ( filename != MainWindow::defaultFileName() ) { |
1605 | saveCalendar( MainWindow::defaultFileName() ); | 1609 | saveCalendar( MainWindow::defaultFileName() ); |
1606 | watchSavedFile(); | 1610 | watchSavedFile(); |
1607 | } | 1611 | } |
1608 | return true; | 1612 | return true; |
1609 | } else { | 1613 | } else { |
1610 | // while failing to load, the calendar object could | 1614 | // while failing to load, the calendar object could |
1611 | // have become partially populated. Clear it out. | 1615 | // have become partially populated. Clear it out. |
1612 | if ( !merge ) { | 1616 | if ( !merge ) { |
1613 | mCalendar->close(); | 1617 | mCalendar->close(); |
1614 | mViewManager->setDocumentId( filename ); | 1618 | mViewManager->setDocumentId( filename ); |
1615 | mDialogManager->setDocumentId( filename ); | 1619 | mDialogManager->setDocumentId( filename ); |
1616 | mTodoList->setDocumentId( filename ); | 1620 | mTodoList->setDocumentId( filename ); |
1617 | } | 1621 | } |
1618 | 1622 | ||
1619 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1623 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1620 | 1624 | ||
1621 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1625 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1622 | globalFlagBlockAgenda = 2; | 1626 | globalFlagBlockAgenda = 2; |
1623 | mCalendar->reInitAlarmSettings(); | 1627 | mCalendar->reInitAlarmSettings(); |
1624 | setSyncEventsReadOnly(); | 1628 | setSyncEventsReadOnly(); |
1625 | updateUnmanagedViews(); | 1629 | updateUnmanagedViews(); |
1626 | updateView(); | 1630 | updateView(); |
1627 | } | 1631 | } |
1628 | return false; | 1632 | return false; |
1629 | } | 1633 | } |
1630 | void CalendarView::showOpenError() | 1634 | void CalendarView::showOpenError() |
1631 | { | 1635 | { |
1632 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1636 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1633 | } | 1637 | } |
1634 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1638 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1635 | { | 1639 | { |
1636 | loadedFileVersion = dt; | 1640 | loadedFileVersion = dt; |
1637 | } | 1641 | } |
1638 | bool CalendarView::checkFileChanged(QString fn) | 1642 | bool CalendarView::checkFileChanged(QString fn) |
1639 | { | 1643 | { |
1640 | QFileInfo finf ( fn ); | 1644 | QFileInfo finf ( fn ); |
1641 | if ( !finf.exists() ) | 1645 | if ( !finf.exists() ) |
1642 | return true; | 1646 | return true; |
1643 | QDateTime dt = finf.lastModified (); | 1647 | QDateTime dt = finf.lastModified (); |
1644 | if ( dt <= loadedFileVersion ) | 1648 | if ( dt <= loadedFileVersion ) |
1645 | return false; | 1649 | return false; |
1646 | return true; | 1650 | return true; |
1647 | 1651 | ||
1648 | } | 1652 | } |
1649 | void CalendarView::watchSavedFile() | 1653 | void CalendarView::watchSavedFile() |
1650 | { | 1654 | { |
1651 | QFileInfo finf ( MainWindow::defaultFileName()); | 1655 | QFileInfo finf ( MainWindow::defaultFileName()); |
1652 | if ( !finf.exists() ) | 1656 | if ( !finf.exists() ) |
1653 | return; | 1657 | return; |
1654 | QDateTime dt = finf.lastModified (); | 1658 | QDateTime dt = finf.lastModified (); |
1655 | if ( dt < loadedFileVersion ) { | 1659 | if ( dt < loadedFileVersion ) { |
1656 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1660 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1657 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1661 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1658 | return; | 1662 | return; |
1659 | } | 1663 | } |
1660 | loadedFileVersion = dt; | 1664 | loadedFileVersion = dt; |
1661 | } | 1665 | } |
1662 | 1666 | ||
1663 | bool CalendarView::checkFileVersion(QString fn) | 1667 | bool CalendarView::checkFileVersion(QString fn) |
1664 | { | 1668 | { |
1665 | QFileInfo finf ( fn ); | 1669 | QFileInfo finf ( fn ); |
1666 | if ( !finf.exists() ) | 1670 | if ( !finf.exists() ) |
1667 | return true; | 1671 | return true; |
1668 | QDateTime dt = finf.lastModified (); | 1672 | QDateTime dt = finf.lastModified (); |
1669 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1673 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1670 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1674 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1671 | if ( dt <= loadedFileVersion ) | 1675 | if ( dt <= loadedFileVersion ) |
1672 | return true; | 1676 | return true; |
1673 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1677 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1674 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1678 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1675 | i18n("Sync+save")); | 1679 | i18n("Sync+save")); |
1676 | 1680 | ||
1677 | if ( km == KMessageBox::Cancel ) | 1681 | if ( km == KMessageBox::Cancel ) |
1678 | return false; | 1682 | return false; |
1679 | if ( km == KMessageBox::Yes ) | 1683 | if ( km == KMessageBox::Yes ) |
1680 | return true; | 1684 | return true; |
1681 | 1685 | ||
1682 | setSyncDevice("deleteaftersync" ); | 1686 | setSyncDevice("deleteaftersync" ); |
1683 | KOPrefs::instance()->mAskForPreferences = true; | 1687 | KOPrefs::instance()->mAskForPreferences = true; |
1684 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1688 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1685 | KOPrefs::instance()->mWriteBackFile = false; | 1689 | KOPrefs::instance()->mWriteBackFile = false; |
1686 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1690 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1687 | KOPrefs::instance()->mShowSyncSummary = false; | 1691 | KOPrefs::instance()->mShowSyncSummary = false; |
1688 | syncCalendar( fn, 3 ); | 1692 | syncCalendar( fn, 3 ); |
1689 | Event * e = getLastSyncEvent(); | 1693 | Event * e = getLastSyncEvent(); |
1690 | mCalendar->deleteEvent ( e ); | 1694 | mCalendar->deleteEvent ( e ); |
1691 | updateView(); | 1695 | updateView(); |
1692 | return true; | 1696 | return true; |
1693 | } | 1697 | } |
1694 | 1698 | ||
1695 | bool CalendarView::saveCalendar( QString filename ) | 1699 | bool CalendarView::saveCalendar( QString filename ) |
1696 | { | 1700 | { |
1697 | 1701 | ||
1698 | // Store back all unsaved data into calendar object | 1702 | // Store back all unsaved data into calendar object |
1699 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1703 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1700 | if ( mViewManager->currentView() ) | 1704 | if ( mViewManager->currentView() ) |
1701 | mViewManager->currentView()->flushView(); | 1705 | mViewManager->currentView()->flushView(); |
1702 | 1706 | ||
1703 | //mStorage->setFileName( filename ); | 1707 | //mStorage->setFileName( filename ); |
1704 | 1708 | ||
1705 | mStorage->setSaveFormat( new ICalFormat() ); | 1709 | mStorage->setSaveFormat( new ICalFormat() ); |
1706 | mStorage->setFileName( filename ); | 1710 | mStorage->setFileName( filename ); |
1707 | bool success; | 1711 | bool success; |
1708 | success = mStorage->save(); | 1712 | success = mStorage->save(); |
1709 | if ( !success ) { | 1713 | if ( !success ) { |
1710 | return false; | 1714 | return false; |
1711 | } | 1715 | } |
1712 | 1716 | ||
1713 | return true; | 1717 | return true; |
1714 | } | 1718 | } |
1715 | 1719 | ||
1716 | void CalendarView::closeCalendar() | 1720 | void CalendarView::closeCalendar() |
1717 | { | 1721 | { |