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