-rw-r--r-- | korganizer/calendarview.cpp | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 02c5e45..685bb60 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2702 +1,2701 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | beamDialog = new KOBeamPrefs(); | 236 | beamDialog = new KOBeamPrefs(); |
237 | mDatePickerMode = 0; | 237 | mDatePickerMode = 0; |
238 | mCurrentSyncDevice = ""; | 238 | mCurrentSyncDevice = ""; |
239 | writeLocale(); | 239 | writeLocale(); |
240 | mViewManager = new KOViewManager( this ); | 240 | mViewManager = new KOViewManager( this ); |
241 | mDialogManager = new KODialogManager( this ); | 241 | mDialogManager = new KODialogManager( this ); |
242 | mEventViewerDialog = 0; | 242 | mEventViewerDialog = 0; |
243 | mModified = false; | 243 | mModified = false; |
244 | mReadOnly = false; | 244 | mReadOnly = false; |
245 | mSelectedIncidence = 0; | 245 | mSelectedIncidence = 0; |
246 | mCalPrinter = 0; | 246 | mCalPrinter = 0; |
247 | mFilters.setAutoDelete(true); | 247 | mFilters.setAutoDelete(true); |
248 | 248 | ||
249 | mCalendar->registerObserver( this ); | 249 | mCalendar->registerObserver( this ); |
250 | // TODO: Make sure that view is updated, when calendar is changed. | 250 | // TODO: Make sure that view is updated, when calendar is changed. |
251 | 251 | ||
252 | mStorage = new FileStorage( mCalendar ); | 252 | mStorage = new FileStorage( mCalendar ); |
253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 253 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
254 | 254 | ||
255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 255 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
256 | #ifndef KORG_NOSPLITTER | 256 | #ifndef KORG_NOSPLITTER |
257 | // create the main layout frames. | 257 | // create the main layout frames. |
258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 258 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
259 | topLayout->addWidget(mPanner); | 259 | topLayout->addWidget(mPanner); |
260 | 260 | ||
261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 261 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
262 | "CalendarView::LeftFrame"); | 262 | "CalendarView::LeftFrame"); |
263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 263 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
264 | 264 | ||
265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 265 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
266 | "CalendarView::DateNavigator", QDate::currentDate() ); | 266 | "CalendarView::DateNavigator", QDate::currentDate() ); |
267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 267 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 268 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
269 | mTodoList->setNavigator( mNavigator ); | 269 | mTodoList->setNavigator( mNavigator ); |
270 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 270 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
271 | 271 | ||
272 | #ifdef KORG_NORESOURCEVIEW | 272 | #ifdef KORG_NORESOURCEVIEW |
273 | mResourceView = 0; | 273 | mResourceView = 0; |
274 | #else | 274 | #else |
275 | if ( mResourceManager ) { | 275 | if ( mResourceManager ) { |
276 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 276 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
277 | mResourceView->updateView(); | 277 | mResourceView->updateView(); |
278 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 278 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
279 | SLOT( updateView() ) ); | 279 | SLOT( updateView() ) ); |
280 | } else { | 280 | } else { |
281 | mResourceView = 0; | 281 | mResourceView = 0; |
282 | } | 282 | } |
283 | #endif | 283 | #endif |
284 | QWidget *rightBox = new QWidget( mPanner ); | 284 | QWidget *rightBox = new QWidget( mPanner ); |
285 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 285 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
286 | 286 | ||
287 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 287 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
288 | rightLayout->addWidget( mNavigatorBar ); | 288 | rightLayout->addWidget( mNavigatorBar ); |
289 | 289 | ||
290 | mRightFrame = new QWidgetStack( rightBox ); | 290 | mRightFrame = new QWidgetStack( rightBox ); |
291 | rightLayout->addWidget( mRightFrame, 1 ); | 291 | rightLayout->addWidget( mRightFrame, 1 ); |
292 | 292 | ||
293 | mLeftFrame = mLeftSplitter; | 293 | mLeftFrame = mLeftSplitter; |
294 | #else | 294 | #else |
295 | QWidget *mainBox = new QWidget( this ); | 295 | QWidget *mainBox = new QWidget( this ); |
296 | QWidget *leftFrame = new QWidget( mainBox ); | 296 | QWidget *leftFrame = new QWidget( mainBox ); |
297 | 297 | ||
298 | QBoxLayout * mainBoxLayout; | 298 | QBoxLayout * mainBoxLayout; |
299 | QBoxLayout * leftFrameLayout; | 299 | QBoxLayout * leftFrameLayout; |
300 | if ( KOPrefs::instance()->mVerticalScreen ) { | 300 | if ( KOPrefs::instance()->mVerticalScreen ) { |
301 | mainBoxLayout = new QVBoxLayout(mainBox); | 301 | mainBoxLayout = new QVBoxLayout(mainBox); |
302 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 302 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
303 | } else { | 303 | } else { |
304 | mainBoxLayout = new QHBoxLayout(mainBox); | 304 | mainBoxLayout = new QHBoxLayout(mainBox); |
305 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 305 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
306 | } | 306 | } |
307 | topLayout->addWidget( mainBox ); | 307 | topLayout->addWidget( mainBox ); |
308 | mainBoxLayout->addWidget (leftFrame); | 308 | mainBoxLayout->addWidget (leftFrame); |
309 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 309 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
310 | "CalendarView::DateNavigator", QDate::currentDate()); | 310 | "CalendarView::DateNavigator", QDate::currentDate()); |
311 | // mDateNavigator->blockSignals( true ); | 311 | // mDateNavigator->blockSignals( true ); |
312 | leftFrameLayout->addWidget( mDateNavigator ); | 312 | leftFrameLayout->addWidget( mDateNavigator ); |
313 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 313 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
314 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 314 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
315 | mTodoList->setNavigator( mNavigator ); | 315 | mTodoList->setNavigator( mNavigator ); |
316 | 316 | ||
317 | if ( QApplication::desktop()->width() < 480 ) { | 317 | if ( QApplication::desktop()->width() < 480 ) { |
318 | leftFrameLayout->addWidget(mFilterView); | 318 | leftFrameLayout->addWidget(mFilterView); |
319 | leftFrameLayout->addWidget(mTodoList, 2 ); | 319 | leftFrameLayout->addWidget(mTodoList, 2 ); |
320 | 320 | ||
321 | } else { | 321 | } else { |
322 | leftFrameLayout->addWidget(mTodoList,2 ); | 322 | leftFrameLayout->addWidget(mTodoList,2 ); |
323 | leftFrameLayout->addWidget(mFilterView ); | 323 | leftFrameLayout->addWidget(mFilterView ); |
324 | } | 324 | } |
325 | mFilterView->hide(); | 325 | mFilterView->hide(); |
326 | QWidget *rightBox = new QWidget( mainBox ); | 326 | QWidget *rightBox = new QWidget( mainBox ); |
327 | mainBoxLayout->addWidget ( rightBox, 10 ); | 327 | mainBoxLayout->addWidget ( rightBox, 10 ); |
328 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 328 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
329 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 329 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
330 | mRightFrame = new QWidgetStack( rightBox ); | 330 | mRightFrame = new QWidgetStack( rightBox ); |
331 | rightLayout->addWidget( mNavigatorBar ); | 331 | rightLayout->addWidget( mNavigatorBar ); |
332 | rightLayout->addWidget( mRightFrame, 10 ); | 332 | rightLayout->addWidget( mRightFrame, 10 ); |
333 | 333 | ||
334 | mLeftFrame = leftFrame; | 334 | mLeftFrame = leftFrame; |
335 | if ( KOPrefs::instance()->mVerticalScreen ) { | 335 | if ( KOPrefs::instance()->mVerticalScreen ) { |
336 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 336 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
337 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 337 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
338 | } else { | 338 | } else { |
339 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 339 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
340 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 340 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
341 | } | 341 | } |
342 | 342 | ||
343 | //qDebug("Calendarview Size %d %d ", width(), height()); | 343 | //qDebug("Calendarview Size %d %d ", width(), height()); |
344 | #endif | 344 | #endif |
345 | 345 | ||
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | SLOT( showDates( const KCal::DateList & ) ) ); | 347 | SLOT( showDates( const KCal::DateList & ) ) ); |
348 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 348 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
349 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 349 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
350 | 350 | ||
351 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 351 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
352 | mNavigator, SLOT( selectPreviousYear() ) ); | 352 | mNavigator, SLOT( selectPreviousYear() ) ); |
353 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 353 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
354 | mNavigator, SLOT( selectNextYear() ) ); | 354 | mNavigator, SLOT( selectNextYear() ) ); |
355 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 355 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
356 | mNavigator, SLOT( selectPreviousMonth() ) ); | 356 | mNavigator, SLOT( selectPreviousMonth() ) ); |
357 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 357 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
358 | mNavigator, SLOT( selectNextMonth() ) ); | 358 | mNavigator, SLOT( selectNextMonth() ) ); |
359 | 359 | ||
360 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 360 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
361 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 361 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
362 | 362 | ||
363 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 363 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
364 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 364 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
365 | 365 | ||
366 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 366 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
367 | mNavigator, SLOT( selectPreviousYear() ) ); | 367 | mNavigator, SLOT( selectPreviousYear() ) ); |
368 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 368 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
369 | mNavigator, SLOT( selectNextYear() ) ); | 369 | mNavigator, SLOT( selectNextYear() ) ); |
370 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 370 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
371 | mNavigator, SLOT( selectPreviousMonth() ) ); | 371 | mNavigator, SLOT( selectPreviousMonth() ) ); |
372 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 372 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
373 | mNavigator, SLOT( selectNextMonth() ) ); | 373 | mNavigator, SLOT( selectNextMonth() ) ); |
374 | 374 | ||
375 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 375 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
376 | mNavigator, SLOT( selectPrevious() ) ); | 376 | mNavigator, SLOT( selectPrevious() ) ); |
377 | connect( mDateNavigator, SIGNAL( goNext() ), | 377 | connect( mDateNavigator, SIGNAL( goNext() ), |
378 | mNavigator, SLOT( selectNext() ) ); | 378 | mNavigator, SLOT( selectNext() ) ); |
379 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 379 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 381 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
382 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 382 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
383 | 383 | ||
384 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 384 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
385 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 385 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
386 | 386 | ||
387 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 387 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
388 | SLOT( eventAdded( Event *) ) ); | 388 | SLOT( eventAdded( Event *) ) ); |
389 | 389 | ||
390 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 390 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
391 | 391 | ||
392 | connect( this, SIGNAL( configChanged() ), | 392 | connect( this, SIGNAL( configChanged() ), |
393 | mDateNavigator, SLOT( updateConfig() ) ); | 393 | mDateNavigator, SLOT( updateConfig() ) ); |
394 | 394 | ||
395 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 395 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
396 | SLOT( newTodo() ) ); | 396 | SLOT( newTodo() ) ); |
397 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 397 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
398 | SLOT( newSubTodo( Todo * ) ) ); | 398 | SLOT( newSubTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
400 | SLOT( editTodo( Todo * ) ) ); | 400 | SLOT( editTodo( Todo * ) ) ); |
401 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 401 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
402 | SLOT( showTodo( Todo *) ) ); | 402 | SLOT( showTodo( Todo *) ) ); |
403 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 403 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
404 | SLOT( deleteTodo( Todo *) ) ); | 404 | SLOT( deleteTodo( Todo *) ) ); |
405 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 405 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
406 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 406 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
407 | SLOT( purgeCompleted() ) ); | 407 | SLOT( purgeCompleted() ) ); |
408 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 408 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
409 | SIGNAL( todoModified( Todo *, int ) ) ); | 409 | SIGNAL( todoModified( Todo *, int ) ) ); |
410 | 410 | ||
411 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
412 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 412 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
413 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 413 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
414 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 414 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
415 | 415 | ||
416 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
417 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 417 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
418 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 418 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
419 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 419 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
420 | 420 | ||
421 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 421 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
422 | this, SLOT ( todo_unsub( Todo * ) ) ); | 422 | this, SLOT ( todo_unsub( Todo * ) ) ); |
423 | 423 | ||
424 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 424 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
425 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 425 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
427 | SLOT( updateTodo( Todo *, int ) ) ); | 427 | SLOT( updateTodo( Todo *, int ) ) ); |
428 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 428 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
429 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 429 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
430 | 430 | ||
431 | 431 | ||
432 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 432 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
433 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 433 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
434 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 434 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
435 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 435 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | 439 | ||
440 | 440 | ||
441 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 441 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
442 | SLOT(checkClipboard())); | 442 | SLOT(checkClipboard())); |
443 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 443 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
444 | SLOT( processTodoListSelection( Incidence * ) ) ); | 444 | SLOT( processTodoListSelection( Incidence * ) ) ); |
445 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 445 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
446 | 446 | ||
447 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 447 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
448 | 448 | ||
449 | mDateFrame = new QVBox(0,0,WType_Popup); | 449 | mDateFrame = new QVBox(0,0,WType_Popup); |
450 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 450 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
451 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 451 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
452 | mDateFrame->setLineWidth(3); | 452 | mDateFrame->setLineWidth(3); |
453 | mDateFrame->hide(); | 453 | mDateFrame->hide(); |
454 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 454 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
455 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 455 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
456 | 456 | ||
457 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 457 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
458 | 458 | ||
459 | mEventEditor = mDialogManager->getEventEditor(); | 459 | mEventEditor = mDialogManager->getEventEditor(); |
460 | mTodoEditor = mDialogManager->getTodoEditor(); | 460 | mTodoEditor = mDialogManager->getTodoEditor(); |
461 | 461 | ||
462 | mFlagEditDescription = false; | 462 | mFlagEditDescription = false; |
463 | 463 | ||
464 | mSuspendTimer = new QTimer( this ); | 464 | mSuspendTimer = new QTimer( this ); |
465 | mAlarmTimer = new QTimer( this ); | 465 | mAlarmTimer = new QTimer( this ); |
466 | mRecheckAlarmTimer = new QTimer( this ); | 466 | mRecheckAlarmTimer = new QTimer( this ); |
467 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 467 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
468 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 468 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
469 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 469 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
470 | mAlarmDialog = new AlarmDialog( this ); | 470 | mAlarmDialog = new AlarmDialog( this ); |
471 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 471 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
472 | mAlarmDialog->setServerNotification( false ); | 472 | mAlarmDialog->setServerNotification( false ); |
473 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 473 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
474 | 474 | ||
475 | 475 | ||
476 | #ifndef DESKTOP_VERSION | 476 | #ifndef DESKTOP_VERSION |
477 | //US listen for arriving address resultsets | 477 | //US listen for arriving address resultsets |
478 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 478 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
479 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 479 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
480 | #endif | 480 | #endif |
481 | 481 | ||
482 | } | 482 | } |
483 | 483 | ||
484 | 484 | ||
485 | CalendarView::~CalendarView() | 485 | CalendarView::~CalendarView() |
486 | { | 486 | { |
487 | // kdDebug() << "~CalendarView()" << endl; | 487 | // kdDebug() << "~CalendarView()" << endl; |
488 | //qDebug("CalendarView::~CalendarView() "); | 488 | //qDebug("CalendarView::~CalendarView() "); |
489 | delete mDialogManager; | 489 | delete mDialogManager; |
490 | delete mViewManager; | 490 | delete mViewManager; |
491 | delete mStorage; | 491 | delete mStorage; |
492 | delete mDateFrame ; | 492 | delete mDateFrame ; |
493 | delete beamDialog; | 493 | delete beamDialog; |
494 | //kdDebug() << "~CalendarView() done" << endl; | 494 | //kdDebug() << "~CalendarView() done" << endl; |
495 | } | 495 | } |
496 | 496 | ||
497 | void CalendarView::showDay( QDate d ) | 497 | void CalendarView::showDay( QDate d ) |
498 | { | 498 | { |
499 | dateNavigator()->selectDate( d ); | 499 | dateNavigator()->selectDate( d ); |
500 | mViewManager->showWeekView(); | 500 | mViewManager->showWeekView(); |
501 | dateNavigator()->selectDate( d ); | 501 | dateNavigator()->selectDate( d ); |
502 | } | 502 | } |
503 | void CalendarView::timerAlarm() | 503 | void CalendarView::timerAlarm() |
504 | { | 504 | { |
505 | //qDebug("CalendarView::timerAlarm() "); | 505 | //qDebug("CalendarView::timerAlarm() "); |
506 | computeAlarm(mAlarmNotification ); | 506 | computeAlarm(mAlarmNotification ); |
507 | } | 507 | } |
508 | 508 | ||
509 | void CalendarView::suspendAlarm() | 509 | void CalendarView::suspendAlarm() |
510 | { | 510 | { |
511 | //qDebug(" CalendarView::suspendAlarm() "); | 511 | //qDebug(" CalendarView::suspendAlarm() "); |
512 | computeAlarm(mSuspendAlarmNotification ); | 512 | computeAlarm(mSuspendAlarmNotification ); |
513 | 513 | ||
514 | } | 514 | } |
515 | 515 | ||
516 | void CalendarView::startAlarm( QString mess , QString filename) | 516 | void CalendarView::startAlarm( QString mess , QString filename) |
517 | { | 517 | { |
518 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 518 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
519 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 519 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
520 | 520 | ||
521 | } | 521 | } |
522 | 522 | ||
523 | void CalendarView::checkNextTimerAlarm() | 523 | void CalendarView::checkNextTimerAlarm() |
524 | { | 524 | { |
525 | mCalendar->checkAlarmForIncidence( 0, true ); | 525 | mCalendar->checkAlarmForIncidence( 0, true ); |
526 | } | 526 | } |
527 | 527 | ||
528 | void CalendarView::computeAlarm( QString msg ) | 528 | void CalendarView::computeAlarm( QString msg ) |
529 | { | 529 | { |
530 | 530 | ||
531 | QString mess = msg; | 531 | QString mess = msg; |
532 | QString mAlarmMessage = mess.mid( 9 ); | 532 | QString mAlarmMessage = mess.mid( 9 ); |
533 | QString filename = MainWindow::resourcePath(); | 533 | QString filename = MainWindow::resourcePath(); |
534 | filename += "koalarm.wav"; | 534 | filename += "koalarm.wav"; |
535 | QString tempfilename; | 535 | QString tempfilename; |
536 | if ( mess.left( 13 ) == "suspend_alarm") { | 536 | if ( mess.left( 13 ) == "suspend_alarm") { |
537 | bool error = false; | 537 | bool error = false; |
538 | int len = mess.mid( 13 ).find("+++"); | 538 | int len = mess.mid( 13 ).find("+++"); |
539 | if ( len < 2 ) | 539 | if ( len < 2 ) |
540 | error = true; | 540 | error = true; |
541 | else { | 541 | else { |
542 | tempfilename = mess.mid( 13, len ); | 542 | tempfilename = mess.mid( 13, len ); |
543 | if ( !QFile::exists( tempfilename ) ) | 543 | if ( !QFile::exists( tempfilename ) ) |
544 | error = true; | 544 | error = true; |
545 | } | 545 | } |
546 | if ( ! error ) { | 546 | if ( ! error ) { |
547 | filename = tempfilename; | 547 | filename = tempfilename; |
548 | } | 548 | } |
549 | mAlarmMessage = mess.mid( 13+len+3 ); | 549 | mAlarmMessage = mess.mid( 13+len+3 ); |
550 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 550 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
551 | startAlarm( mAlarmMessage, filename); | 551 | startAlarm( mAlarmMessage, filename); |
552 | return; | 552 | return; |
553 | } | 553 | } |
554 | if ( mess.left( 11 ) == "timer_alarm") { | 554 | if ( mess.left( 11 ) == "timer_alarm") { |
555 | //mTimerTime = 0; | 555 | //mTimerTime = 0; |
556 | startAlarm( mess.mid( 11 ), filename ); | 556 | startAlarm( mess.mid( 11 ), filename ); |
557 | return; | 557 | return; |
558 | } | 558 | } |
559 | if ( mess.left( 10 ) == "proc_alarm") { | 559 | if ( mess.left( 10 ) == "proc_alarm") { |
560 | bool error = false; | 560 | bool error = false; |
561 | int len = mess.mid( 10 ).find("+++"); | 561 | int len = mess.mid( 10 ).find("+++"); |
562 | if ( len < 2 ) | 562 | if ( len < 2 ) |
563 | error = true; | 563 | error = true; |
564 | else { | 564 | else { |
565 | tempfilename = mess.mid( 10, len ); | 565 | tempfilename = mess.mid( 10, len ); |
566 | if ( !QFile::exists( tempfilename ) ) | 566 | if ( !QFile::exists( tempfilename ) ) |
567 | error = true; | 567 | error = true; |
568 | } | 568 | } |
569 | if ( error ) { | 569 | if ( error ) { |
570 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 570 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
571 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 571 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
572 | } else { | 572 | } else { |
573 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 573 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
574 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 574 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
575 | #ifndef _WIN32_ | 575 | #ifndef _WIN32_ |
576 | if ( vfork () == 0 ) { | 576 | if ( vfork () == 0 ) { |
577 | execl ( tempfilename.latin1(), 0 ); | 577 | execl ( tempfilename.latin1(), 0 ); |
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | #else | 580 | #else |
581 | QProcess* p = new QProcess(); | 581 | QProcess* p = new QProcess(); |
582 | p->addArgument( tempfilename.latin1() ); | 582 | p->addArgument( tempfilename.latin1() ); |
583 | p->start(); | 583 | p->start(); |
584 | return; | 584 | return; |
585 | #endif | 585 | #endif |
586 | 586 | ||
587 | return; | 587 | return; |
588 | } | 588 | } |
589 | 589 | ||
590 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 590 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
591 | } | 591 | } |
592 | if ( mess.left( 11 ) == "audio_alarm") { | 592 | if ( mess.left( 11 ) == "audio_alarm") { |
593 | bool error = false; | 593 | bool error = false; |
594 | int len = mess.mid( 11 ).find("+++"); | 594 | int len = mess.mid( 11 ).find("+++"); |
595 | if ( len < 2 ) | 595 | if ( len < 2 ) |
596 | error = true; | 596 | error = true; |
597 | else { | 597 | else { |
598 | tempfilename = mess.mid( 11, len ); | 598 | tempfilename = mess.mid( 11, len ); |
599 | if ( !QFile::exists( tempfilename ) ) | 599 | if ( !QFile::exists( tempfilename ) ) |
600 | error = true; | 600 | error = true; |
601 | } | 601 | } |
602 | if ( ! error ) { | 602 | if ( ! error ) { |
603 | filename = tempfilename; | 603 | filename = tempfilename; |
604 | } | 604 | } |
605 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 605 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
606 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 606 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
607 | } | 607 | } |
608 | if ( mess.left( 9 ) == "cal_alarm") { | 608 | if ( mess.left( 9 ) == "cal_alarm") { |
609 | mAlarmMessage = mess.mid( 9 ) ; | 609 | mAlarmMessage = mess.mid( 9 ) ; |
610 | } | 610 | } |
611 | 611 | ||
612 | startAlarm( mAlarmMessage, filename ); | 612 | startAlarm( mAlarmMessage, filename ); |
613 | 613 | ||
614 | 614 | ||
615 | } | 615 | } |
616 | 616 | ||
617 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 617 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
618 | { | 618 | { |
619 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 619 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
620 | 620 | ||
621 | mSuspendAlarmNotification = noti; | 621 | mSuspendAlarmNotification = noti; |
622 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 622 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
623 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 623 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
624 | mSuspendTimer->start( ms , true ); | 624 | mSuspendTimer->start( ms , true ); |
625 | 625 | ||
626 | } | 626 | } |
627 | 627 | ||
628 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 628 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
629 | { | 629 | { |
630 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 630 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
631 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 631 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
632 | #ifndef DESKTOP_VERSION | 632 | #ifndef DESKTOP_VERSION |
633 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 633 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
634 | #endif | 634 | #endif |
635 | return; | 635 | return; |
636 | } | 636 | } |
637 | int maxSec; | 637 | int maxSec; |
638 | //maxSec = 5; //testing only | 638 | //maxSec = 5; //testing only |
639 | maxSec = 86400+3600; // one day+1hour | 639 | maxSec = 86400+3600; // one day+1hour |
640 | mAlarmNotification = noti; | 640 | mAlarmNotification = noti; |
641 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 641 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
642 | if ( sec > maxSec ) { | 642 | if ( sec > maxSec ) { |
643 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 643 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
644 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 644 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
645 | return; | 645 | return; |
646 | } else { | 646 | } else { |
647 | mRecheckAlarmTimer->stop(); | 647 | mRecheckAlarmTimer->stop(); |
648 | } | 648 | } |
649 | //qDebug("Alarm timer started with secs: %d ", sec); | 649 | //qDebug("Alarm timer started with secs: %d ", sec); |
650 | mAlarmTimer->start( sec *1000 , true ); | 650 | mAlarmTimer->start( sec *1000 , true ); |
651 | 651 | ||
652 | } | 652 | } |
653 | // called by mRecheckAlarmTimer to get next alarm | 653 | // called by mRecheckAlarmTimer to get next alarm |
654 | // we need this, because a QTimer has only a max range of 25 days | 654 | // we need this, because a QTimer has only a max range of 25 days |
655 | void CalendarView::recheckTimerAlarm() | 655 | void CalendarView::recheckTimerAlarm() |
656 | { | 656 | { |
657 | mAlarmTimer->stop(); | 657 | mAlarmTimer->stop(); |
658 | mRecheckAlarmTimer->stop(); | 658 | mRecheckAlarmTimer->stop(); |
659 | mCalendar->checkAlarmForIncidence( 0, true ); | 659 | mCalendar->checkAlarmForIncidence( 0, true ); |
660 | } | 660 | } |
661 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 661 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
662 | { | 662 | { |
663 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 663 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
664 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 664 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
665 | #ifndef DESKTOP_VERSION | 665 | #ifndef DESKTOP_VERSION |
666 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 666 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
667 | #endif | 667 | #endif |
668 | return; | 668 | return; |
669 | } | 669 | } |
670 | mAlarmTimer->stop(); | 670 | mAlarmTimer->stop(); |
671 | } | 671 | } |
672 | void CalendarView::selectWeekNum ( int num ) | 672 | void CalendarView::selectWeekNum ( int num ) |
673 | { | 673 | { |
674 | dateNavigator()->selectWeek( num ); | 674 | dateNavigator()->selectWeek( num ); |
675 | mViewManager->showWeekView(); | 675 | mViewManager->showWeekView(); |
676 | } | 676 | } |
677 | KOViewManager *CalendarView::viewManager() | 677 | KOViewManager *CalendarView::viewManager() |
678 | { | 678 | { |
679 | return mViewManager; | 679 | return mViewManager; |
680 | } | 680 | } |
681 | 681 | ||
682 | KODialogManager *CalendarView::dialogManager() | 682 | KODialogManager *CalendarView::dialogManager() |
683 | { | 683 | { |
684 | return mDialogManager; | 684 | return mDialogManager; |
685 | } | 685 | } |
686 | 686 | ||
687 | QDate CalendarView::startDate() | 687 | QDate CalendarView::startDate() |
688 | { | 688 | { |
689 | DateList dates = mNavigator->selectedDates(); | 689 | DateList dates = mNavigator->selectedDates(); |
690 | 690 | ||
691 | return dates.first(); | 691 | return dates.first(); |
692 | } | 692 | } |
693 | 693 | ||
694 | QDate CalendarView::endDate() | 694 | QDate CalendarView::endDate() |
695 | { | 695 | { |
696 | DateList dates = mNavigator->selectedDates(); | 696 | DateList dates = mNavigator->selectedDates(); |
697 | 697 | ||
698 | return dates.last(); | 698 | return dates.last(); |
699 | } | 699 | } |
700 | 700 | ||
701 | 701 | ||
702 | void CalendarView::createPrinter() | 702 | void CalendarView::createPrinter() |
703 | { | 703 | { |
704 | #ifndef KORG_NOPRINTER | 704 | #ifndef KORG_NOPRINTER |
705 | if (!mCalPrinter) { | 705 | if (!mCalPrinter) { |
706 | mCalPrinter = new CalPrinter(this, mCalendar); | 706 | mCalPrinter = new CalPrinter(this, mCalendar); |
707 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 707 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
708 | } | 708 | } |
709 | #endif | 709 | #endif |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | //KOPrefs::instance()->mWriteBackFile | 713 | //KOPrefs::instance()->mWriteBackFile |
714 | //KOPrefs::instance()->mWriteBackExistingOnly | 714 | //KOPrefs::instance()->mWriteBackExistingOnly |
715 | 715 | ||
716 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 716 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
717 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 717 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
718 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 718 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
719 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 719 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
720 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 720 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
721 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 721 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
722 | 722 | ||
723 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 723 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
724 | { | 724 | { |
725 | 725 | ||
726 | // 0 equal | 726 | // 0 equal |
727 | // 1 take local | 727 | // 1 take local |
728 | // 2 take remote | 728 | // 2 take remote |
729 | // 3 cancel | 729 | // 3 cancel |
730 | QDateTime lastSync = mLastCalendarSync; | 730 | QDateTime lastSync = mLastCalendarSync; |
731 | QDateTime localMod = local->lastModified(); | 731 | QDateTime localMod = local->lastModified(); |
732 | QDateTime remoteMod = remote->lastModified(); | 732 | QDateTime remoteMod = remote->lastModified(); |
733 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 733 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
734 | bool remCh, locCh; | 734 | bool remCh, locCh; |
735 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 735 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
736 | //if ( remCh ) | 736 | //if ( remCh ) |
737 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 737 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
738 | locCh = ( localMod > mLastCalendarSync ); | 738 | locCh = ( localMod > mLastCalendarSync ); |
739 | if ( !remCh && ! locCh ) { | 739 | if ( !remCh && ! locCh ) { |
740 | //qDebug("both not changed "); | 740 | //qDebug("both not changed "); |
741 | lastSync = localMod.addDays(1); | 741 | lastSync = localMod.addDays(1); |
742 | if ( mode <= SYNC_PREF_ASK ) | 742 | if ( mode <= SYNC_PREF_ASK ) |
743 | return 0; | 743 | return 0; |
744 | } else { | 744 | } else { |
745 | if ( locCh ) { | 745 | if ( locCh ) { |
746 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 746 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
747 | lastSync = localMod.addDays( -1 ); | 747 | lastSync = localMod.addDays( -1 ); |
748 | if ( !remCh ) | 748 | if ( !remCh ) |
749 | remoteMod = ( lastSync.addDays( -1 ) ); | 749 | remoteMod = ( lastSync.addDays( -1 ) ); |
750 | } else { | 750 | } else { |
751 | //qDebug(" not loc changed "); | 751 | //qDebug(" not loc changed "); |
752 | lastSync = localMod.addDays( 1 ); | 752 | lastSync = localMod.addDays( 1 ); |
753 | if ( remCh ) | 753 | if ( remCh ) |
754 | remoteMod =( lastSync.addDays( 1 ) ); | 754 | remoteMod =( lastSync.addDays( 1 ) ); |
755 | 755 | ||
756 | } | 756 | } |
757 | } | 757 | } |
758 | full = true; | 758 | full = true; |
759 | if ( mode < SYNC_PREF_ASK ) | 759 | if ( mode < SYNC_PREF_ASK ) |
760 | mode = SYNC_PREF_ASK; | 760 | mode = SYNC_PREF_ASK; |
761 | } else { | 761 | } else { |
762 | if ( localMod == remoteMod ) | 762 | if ( localMod == remoteMod ) |
763 | // if ( local->revision() == remote->revision() ) | 763 | // if ( local->revision() == remote->revision() ) |
764 | return 0; | 764 | return 0; |
765 | 765 | ||
766 | } | 766 | } |
767 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 767 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
768 | 768 | ||
769 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 769 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
770 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 770 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
771 | //full = true; //debug only | 771 | //full = true; //debug only |
772 | if ( full ) { | 772 | if ( full ) { |
773 | bool equ = false; | 773 | bool equ = false; |
774 | if ( local->type() == "Event" ) { | 774 | if ( local->type() == "Event" ) { |
775 | equ = (*((Event*) local) == *((Event*) remote)); | 775 | equ = (*((Event*) local) == *((Event*) remote)); |
776 | } | 776 | } |
777 | else if ( local->type() =="Todo" ) | 777 | else if ( local->type() =="Todo" ) |
778 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 778 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
779 | else if ( local->type() =="Journal" ) | 779 | else if ( local->type() =="Journal" ) |
780 | equ = (*((Journal*) local) == *((Journal*) remote)); | 780 | equ = (*((Journal*) local) == *((Journal*) remote)); |
781 | if ( equ ) { | 781 | if ( equ ) { |
782 | //qDebug("equal "); | 782 | //qDebug("equal "); |
783 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 783 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
784 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 784 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
785 | } | 785 | } |
786 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 786 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
787 | return 0; | 787 | return 0; |
788 | 788 | ||
789 | }//else //debug only | 789 | }//else //debug only |
790 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 790 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
791 | } | 791 | } |
792 | int result; | 792 | int result; |
793 | bool localIsNew; | 793 | bool localIsNew; |
794 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 794 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
795 | 795 | ||
796 | if ( full && mode < SYNC_PREF_NEWEST ) | 796 | if ( full && mode < SYNC_PREF_NEWEST ) |
797 | mode = SYNC_PREF_ASK; | 797 | mode = SYNC_PREF_ASK; |
798 | 798 | ||
799 | switch( mode ) { | 799 | switch( mode ) { |
800 | case SYNC_PREF_LOCAL: | 800 | case SYNC_PREF_LOCAL: |
801 | if ( lastSync > remoteMod ) | 801 | if ( lastSync > remoteMod ) |
802 | return 1; | 802 | return 1; |
803 | if ( lastSync > localMod ) | 803 | if ( lastSync > localMod ) |
804 | return 2; | 804 | return 2; |
805 | return 1; | 805 | return 1; |
806 | break; | 806 | break; |
807 | case SYNC_PREF_REMOTE: | 807 | case SYNC_PREF_REMOTE: |
808 | if ( lastSync > remoteMod ) | 808 | if ( lastSync > remoteMod ) |
809 | return 1; | 809 | return 1; |
810 | if ( lastSync > localMod ) | 810 | if ( lastSync > localMod ) |
811 | return 2; | 811 | return 2; |
812 | return 2; | 812 | return 2; |
813 | break; | 813 | break; |
814 | case SYNC_PREF_NEWEST: | 814 | case SYNC_PREF_NEWEST: |
815 | if ( localMod > remoteMod ) | 815 | if ( localMod > remoteMod ) |
816 | return 1; | 816 | return 1; |
817 | else | 817 | else |
818 | return 2; | 818 | return 2; |
819 | break; | 819 | break; |
820 | case SYNC_PREF_ASK: | 820 | case SYNC_PREF_ASK: |
821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 821 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
822 | if ( lastSync > remoteMod ) | 822 | if ( lastSync > remoteMod ) |
823 | return 1; | 823 | return 1; |
824 | if ( lastSync > localMod ) | 824 | if ( lastSync > localMod ) |
825 | return 2; | 825 | return 2; |
826 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 826 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
827 | localIsNew = localMod >= remoteMod; | 827 | localIsNew = localMod >= remoteMod; |
828 | if ( localIsNew ) | 828 | if ( localIsNew ) |
829 | getEventViewerDialog()->setColorMode( 1 ); | 829 | getEventViewerDialog()->setColorMode( 1 ); |
830 | else | 830 | else |
831 | getEventViewerDialog()->setColorMode( 2 ); | 831 | getEventViewerDialog()->setColorMode( 2 ); |
832 | getEventViewerDialog()->setIncidence(local); | 832 | getEventViewerDialog()->setIncidence(local); |
833 | if ( localIsNew ) | 833 | if ( localIsNew ) |
834 | getEventViewerDialog()->setColorMode( 2 ); | 834 | getEventViewerDialog()->setColorMode( 2 ); |
835 | else | 835 | else |
836 | getEventViewerDialog()->setColorMode( 1 ); | 836 | getEventViewerDialog()->setColorMode( 1 ); |
837 | getEventViewerDialog()->addIncidence(remote); | 837 | getEventViewerDialog()->addIncidence(remote); |
838 | getEventViewerDialog()->setColorMode( 0 ); | 838 | getEventViewerDialog()->setColorMode( 0 ); |
839 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 839 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
840 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 840 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
841 | getEventViewerDialog()->showMe(); | 841 | getEventViewerDialog()->showMe(); |
842 | result = getEventViewerDialog()->executeS( localIsNew ); | 842 | result = getEventViewerDialog()->executeS( localIsNew ); |
843 | return result; | 843 | return result; |
844 | 844 | ||
845 | break; | 845 | break; |
846 | case SYNC_PREF_FORCE_LOCAL: | 846 | case SYNC_PREF_FORCE_LOCAL: |
847 | return 1; | 847 | return 1; |
848 | break; | 848 | break; |
849 | case SYNC_PREF_FORCE_REMOTE: | 849 | case SYNC_PREF_FORCE_REMOTE: |
850 | return 2; | 850 | return 2; |
851 | break; | 851 | break; |
852 | 852 | ||
853 | default: | 853 | default: |
854 | // SYNC_PREF_TAKE_BOTH not implemented | 854 | // SYNC_PREF_TAKE_BOTH not implemented |
855 | break; | 855 | break; |
856 | } | 856 | } |
857 | return 0; | 857 | return 0; |
858 | } | 858 | } |
859 | Event* CalendarView::getLastSyncEvent() | 859 | Event* CalendarView::getLastSyncEvent() |
860 | { | 860 | { |
861 | Event* lse; | 861 | Event* lse; |
862 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 862 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
863 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 863 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
864 | if (!lse) { | 864 | if (!lse) { |
865 | lse = new Event(); | 865 | lse = new Event(); |
866 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 866 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
867 | QString sum = ""; | 867 | QString sum = ""; |
868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
869 | sum = "E: "; | 869 | sum = "E: "; |
870 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 870 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
871 | lse->setDtStart( mLastCalendarSync ); | 871 | lse->setDtStart( mLastCalendarSync ); |
872 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 872 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
873 | lse->setCategories( i18n("SyncEvent") ); | 873 | lse->setCategories( i18n("SyncEvent") ); |
874 | lse->setReadOnly( true ); | 874 | lse->setReadOnly( true ); |
875 | mCalendar->addEvent( lse ); | 875 | mCalendar->addEvent( lse ); |
876 | } | 876 | } |
877 | 877 | ||
878 | return lse; | 878 | return lse; |
879 | 879 | ||
880 | } | 880 | } |
881 | 881 | ||
882 | // we check, if the to delete event has a id for a profile | 882 | // we check, if the to delete event has a id for a profile |
883 | // if yes, we set this id in the profile to delete | 883 | // if yes, we set this id in the profile to delete |
884 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 884 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
885 | { | 885 | { |
886 | if ( lastSync.count() == 0 ) { | 886 | if ( lastSync.count() == 0 ) { |
887 | //qDebug(" lastSync.count() == 0"); | 887 | //qDebug(" lastSync.count() == 0"); |
888 | return; | 888 | return; |
889 | } | 889 | } |
890 | if ( toDelete->type() == "Journal" ) | 890 | if ( toDelete->type() == "Journal" ) |
891 | return; | 891 | return; |
892 | 892 | ||
893 | Event* eve = lastSync.first(); | 893 | Event* eve = lastSync.first(); |
894 | 894 | ||
895 | while ( eve ) { | 895 | while ( eve ) { |
896 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 896 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
897 | if ( !id.isEmpty() ) { | 897 | if ( !id.isEmpty() ) { |
898 | QString des = eve->description(); | 898 | QString des = eve->description(); |
899 | QString pref = "e"; | 899 | QString pref = "e"; |
900 | if ( toDelete->type() == "Todo" ) | 900 | if ( toDelete->type() == "Todo" ) |
901 | pref = "t"; | 901 | pref = "t"; |
902 | des += pref+ id + ","; | 902 | des += pref+ id + ","; |
903 | eve->setReadOnly( false ); | 903 | eve->setReadOnly( false ); |
904 | eve->setDescription( des ); | 904 | eve->setDescription( des ); |
905 | //qDebug("setdes %s ", des.latin1()); | 905 | //qDebug("setdes %s ", des.latin1()); |
906 | eve->setReadOnly( true ); | 906 | eve->setReadOnly( true ); |
907 | } | 907 | } |
908 | eve = lastSync.next(); | 908 | eve = lastSync.next(); |
909 | } | 909 | } |
910 | 910 | ||
911 | } | 911 | } |
912 | void CalendarView::checkExternalId( Incidence * inc ) | 912 | void CalendarView::checkExternalId( Incidence * inc ) |
913 | { | 913 | { |
914 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 914 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
915 | checkExternSyncEvent( lastSync, inc ); | 915 | checkExternSyncEvent( lastSync, inc ); |
916 | 916 | ||
917 | } | 917 | } |
918 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 918 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
919 | { | 919 | { |
920 | bool syncOK = true; | 920 | bool syncOK = true; |
921 | int addedEvent = 0; | 921 | int addedEvent = 0; |
922 | int addedEventR = 0; | 922 | int addedEventR = 0; |
923 | int deletedEventR = 0; | 923 | int deletedEventR = 0; |
924 | int deletedEventL = 0; | 924 | int deletedEventL = 0; |
925 | int changedLocal = 0; | 925 | int changedLocal = 0; |
926 | int changedRemote = 0; | 926 | int changedRemote = 0; |
927 | //QPtrList<Event> el = local->rawEvents(); | 927 | //QPtrList<Event> el = local->rawEvents(); |
928 | Event* eventR; | 928 | Event* eventR; |
929 | QString uid; | 929 | QString uid; |
930 | int take; | 930 | int take; |
931 | Event* eventL; | 931 | Event* eventL; |
932 | Event* eventRSync; | 932 | Event* eventRSync; |
933 | Event* eventLSync; | 933 | Event* eventLSync; |
934 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 934 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
935 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 935 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
936 | bool fullDateRange = false; | 936 | bool fullDateRange = false; |
937 | local->resetTempSyncStat(); | 937 | local->resetTempSyncStat(); |
938 | mLastCalendarSync = QDateTime::currentDateTime(); | 938 | mLastCalendarSync = QDateTime::currentDateTime(); |
939 | if ( mSyncManager->syncWithDesktop() ) { | 939 | if ( mSyncManager->syncWithDesktop() ) { |
940 | remote->resetPilotStat(1); | 940 | remote->resetPilotStat(1); |
941 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 941 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
942 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 942 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
943 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 943 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
944 | } else { | 944 | } else { |
945 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 945 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
946 | } | 946 | } |
947 | } | 947 | } |
948 | QDateTime modifiedCalendar = mLastCalendarSync; | 948 | QDateTime modifiedCalendar = mLastCalendarSync; |
949 | eventLSync = getLastSyncEvent(); | 949 | eventLSync = getLastSyncEvent(); |
950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 950 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
951 | if ( eventR ) { | 951 | if ( eventR ) { |
952 | eventRSync = (Event*) eventR->clone(); | 952 | eventRSync = (Event*) eventR->clone(); |
953 | remote->deleteEvent(eventR ); | 953 | remote->deleteEvent(eventR ); |
954 | 954 | ||
955 | } else { | 955 | } else { |
956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 956 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
957 | eventRSync = (Event*)eventLSync->clone(); | 957 | eventRSync = (Event*)eventLSync->clone(); |
958 | } else { | 958 | } else { |
959 | fullDateRange = true; | 959 | fullDateRange = true; |
960 | eventRSync = new Event(); | 960 | eventRSync = new Event(); |
961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 961 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 962 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
963 | eventRSync->setDtStart( mLastCalendarSync ); | 963 | eventRSync->setDtStart( mLastCalendarSync ); |
964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 964 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
965 | eventRSync->setCategories( i18n("SyncEvent") ); | 965 | eventRSync->setCategories( i18n("SyncEvent") ); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 968 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
969 | fullDateRange = true; | 969 | fullDateRange = true; |
970 | 970 | ||
971 | if ( ! fullDateRange ) { | 971 | if ( ! fullDateRange ) { |
972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 972 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
973 | 973 | ||
974 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 974 | // 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()); | 975 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
976 | fullDateRange = true; | 976 | fullDateRange = true; |
977 | } | 977 | } |
978 | } | 978 | } |
979 | if ( mSyncManager->syncWithDesktop() ) { | 979 | if ( mSyncManager->syncWithDesktop() ) { |
980 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 980 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
981 | } | 981 | } |
982 | if ( fullDateRange ) | 982 | if ( fullDateRange ) |
983 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 983 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
984 | else | 984 | else |
985 | mLastCalendarSync = eventLSync->dtStart(); | 985 | mLastCalendarSync = eventLSync->dtStart(); |
986 | // for resyncing if own file has changed | 986 | // for resyncing if own file has changed |
987 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 987 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
988 | mLastCalendarSync = loadedFileVersion; | 988 | mLastCalendarSync = loadedFileVersion; |
989 | //qDebug("setting mLastCalendarSync "); | 989 | //qDebug("setting mLastCalendarSync "); |
990 | } | 990 | } |
991 | //qDebug("*************************** "); | 991 | //qDebug("*************************** "); |
992 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 992 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
993 | QPtrList<Incidence> er = remote->rawIncidences(); | 993 | QPtrList<Incidence> er = remote->rawIncidences(); |
994 | Incidence* inR = er.first(); | 994 | Incidence* inR = er.first(); |
995 | Incidence* inL; | 995 | Incidence* inL; |
996 | QProgressBar bar( er.count(),0 ); | 996 | QProgressBar bar( er.count(),0 ); |
997 | bar.setCaption (i18n("Syncing - close to abort!") ); | 997 | bar.setCaption (i18n("Syncing - close to abort!") ); |
998 | 998 | ||
999 | // ************** setting up filter ************* | 999 | // ************** setting up filter ************* |
1000 | CalFilter *filterIN = 0; | 1000 | CalFilter *filterIN = 0; |
1001 | CalFilter *filterOUT = 0; | 1001 | CalFilter *filterOUT = 0; |
1002 | CalFilter *filter = mFilters.first(); | 1002 | CalFilter *filter = mFilters.first(); |
1003 | while(filter) { | 1003 | while(filter) { |
1004 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1004 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1005 | filterIN = filter; | 1005 | filterIN = filter; |
1006 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1006 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1007 | filterOUT = filter; | 1007 | filterOUT = filter; |
1008 | filter = mFilters.next(); | 1008 | filter = mFilters.next(); |
1009 | } | 1009 | } |
1010 | int w = 300; | 1010 | int w = 300; |
1011 | if ( QApplication::desktop()->width() < 320 ) | 1011 | if ( QApplication::desktop()->width() < 320 ) |
1012 | w = 220; | 1012 | w = 220; |
1013 | int h = bar.sizeHint().height() ; | 1013 | int h = bar.sizeHint().height() ; |
1014 | int dw = QApplication::desktop()->width(); | 1014 | int dw = QApplication::desktop()->width(); |
1015 | int dh = QApplication::desktop()->height(); | 1015 | int dh = QApplication::desktop()->height(); |
1016 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1016 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1017 | bar.show(); | 1017 | bar.show(); |
1018 | int modulo = (er.count()/10)+1; | 1018 | int modulo = (er.count()/10)+1; |
1019 | int incCounter = 0; | 1019 | int incCounter = 0; |
1020 | while ( inR ) { | 1020 | while ( inR ) { |
1021 | if ( ! bar.isVisible() ) | 1021 | if ( ! bar.isVisible() ) |
1022 | return false; | 1022 | return false; |
1023 | if ( incCounter % modulo == 0 ) | 1023 | if ( incCounter % modulo == 0 ) |
1024 | bar.setProgress( incCounter ); | 1024 | bar.setProgress( incCounter ); |
1025 | ++incCounter; | 1025 | ++incCounter; |
1026 | uid = inR->uid(); | 1026 | uid = inR->uid(); |
1027 | bool skipIncidence = false; | 1027 | bool skipIncidence = false; |
1028 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1028 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1029 | skipIncidence = true; | 1029 | skipIncidence = true; |
1030 | QString idS; | 1030 | QString idS; |
1031 | qApp->processEvents(); | 1031 | qApp->processEvents(); |
1032 | if ( !skipIncidence ) { | 1032 | if ( !skipIncidence ) { |
1033 | inL = local->incidence( uid ); | 1033 | inL = local->incidence( uid ); |
1034 | if ( inL ) { // maybe conflict - same uid in both calendars | 1034 | if ( inL ) { // maybe conflict - same uid in both calendars |
1035 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1035 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1036 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1036 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1037 | if ( take == 3 ) | 1037 | if ( take == 3 ) |
1038 | return false; | 1038 | return false; |
1039 | if ( take == 1 ) {// take local ********************** | 1039 | if ( take == 1 ) {// take local ********************** |
1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1040 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1041 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1041 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1042 | else | 1042 | else |
1043 | idS = inR->IDStr(); | 1043 | idS = inR->IDStr(); |
1044 | remote->deleteIncidence( inR ); | 1044 | remote->deleteIncidence( inR ); |
1045 | inR = inL->clone(); | 1045 | inR = inL->clone(); |
1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1046 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1047 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1047 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1048 | inR->setIDStr( idS ); | 1048 | inR->setIDStr( idS ); |
1049 | remote->addIncidence( inR ); | 1049 | remote->addIncidence( inR ); |
1050 | if ( mSyncManager->syncWithDesktop() ) | 1050 | if ( mSyncManager->syncWithDesktop() ) |
1051 | inR->setPilotId( 2 ); | 1051 | inR->setPilotId( 2 ); |
1052 | ++changedRemote; | 1052 | ++changedRemote; |
1053 | } else {// take remote ********************** | 1053 | } else {// take remote ********************** |
1054 | idS = inL->IDStr(); | 1054 | idS = inL->IDStr(); |
1055 | int pid = inL->pilotId(); | 1055 | int pid = inL->pilotId(); |
1056 | local->deleteIncidence( inL ); | 1056 | local->deleteIncidence( inL ); |
1057 | inL = inR->clone(); | 1057 | inL = inR->clone(); |
1058 | if ( mSyncManager->syncWithDesktop() ) | 1058 | if ( mSyncManager->syncWithDesktop() ) |
1059 | inL->setPilotId( pid ); | 1059 | inL->setPilotId( pid ); |
1060 | inL->setIDStr( idS ); | 1060 | inL->setIDStr( idS ); |
1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1061 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1062 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1062 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1063 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1063 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1064 | } | 1064 | } |
1065 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1066 | ++changedLocal; | 1066 | ++changedLocal; |
1067 | } | 1067 | } |
1068 | } | 1068 | } |
1069 | } else { // no conflict ********** add or delete remote | 1069 | } else { // no conflict ********** add or delete remote |
1070 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1070 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1071 | QString des = eventLSync->description(); | 1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1072 | QString pref = "e"; | 1072 | QString des = eventLSync->description(); |
1073 | if ( inR->type() == "Todo" ) | 1073 | QString pref = "e"; |
1074 | pref = "t"; | 1074 | if ( inR->type() == "Todo" ) |
1075 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1075 | pref = "t"; |
1076 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1076 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1077 | //remote->deleteIncidence( inR ); | 1077 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1078 | ++deletedEventR; | 1078 | //remote->deleteIncidence( inR ); |
1079 | } else { | 1079 | ++deletedEventR; |
1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1080 | } else { |
1081 | inR->setLastModified( modifiedCalendar ); | 1081 | inR->setLastModified( modifiedCalendar ); |
1082 | inL = inR->clone(); | 1082 | inL = inR->clone(); |
1083 | inL->setIDStr( ":" ); | 1083 | inL->setIDStr( ":" ); |
1084 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1084 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1085 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1085 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1086 | local->addIncidence( inL ); | 1086 | local->addIncidence( inL ); |
1087 | ++addedEvent; | 1087 | ++addedEvent; |
1088 | |||
1088 | } | 1089 | } |
1089 | } | 1090 | } else { |
1090 | } else { | 1091 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1091 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | ||
1092 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | ||
1093 | inR->setLastModified( modifiedCalendar ); | 1092 | inR->setLastModified( modifiedCalendar ); |
1094 | inL = inR->clone(); | 1093 | inL = inR->clone(); |
1095 | inL->setIDStr( ":" ); | 1094 | inL->setIDStr( ":" ); |
1096 | local->addIncidence( inL ); | 1095 | local->addIncidence( inL ); |
1097 | ++addedEvent; | 1096 | ++addedEvent; |
1097 | |||
1098 | } else { | ||
1099 | checkExternSyncEvent(eventRSyncSharp, inR); | ||
1100 | remote->deleteIncidence( inR ); | ||
1101 | ++deletedEventR; | ||
1098 | } | 1102 | } |
1099 | } else { | ||
1100 | checkExternSyncEvent(eventRSyncSharp, inR); | ||
1101 | remote->deleteIncidence( inR ); | ||
1102 | ++deletedEventR; | ||
1103 | } | 1103 | } |
1104 | } | 1104 | } |
1105 | } | 1105 | } |
1106 | } | 1106 | } |
1107 | inR = er.next(); | 1107 | inR = er.next(); |
1108 | } | 1108 | } |
1109 | QPtrList<Incidence> el = local->rawIncidences(); | 1109 | QPtrList<Incidence> el = local->rawIncidences(); |
1110 | inL = el.first(); | 1110 | inL = el.first(); |
1111 | modulo = (el.count()/10)+1; | 1111 | modulo = (el.count()/10)+1; |
1112 | bar.setCaption (i18n("Add / remove events") ); | 1112 | bar.setCaption (i18n("Add / remove events") ); |
1113 | bar.setTotalSteps ( el.count() ) ; | 1113 | bar.setTotalSteps ( el.count() ) ; |
1114 | bar.show(); | 1114 | bar.show(); |
1115 | incCounter = 0; | 1115 | incCounter = 0; |
1116 | 1116 | ||
1117 | while ( inL ) { | 1117 | while ( inL ) { |
1118 | 1118 | ||
1119 | qApp->processEvents(); | 1119 | qApp->processEvents(); |
1120 | if ( ! bar.isVisible() ) | 1120 | if ( ! bar.isVisible() ) |
1121 | return false; | 1121 | return false; |
1122 | if ( incCounter % modulo == 0 ) | 1122 | if ( incCounter % modulo == 0 ) |
1123 | bar.setProgress( incCounter ); | 1123 | bar.setProgress( incCounter ); |
1124 | ++incCounter; | 1124 | ++incCounter; |
1125 | uid = inL->uid(); | 1125 | uid = inL->uid(); |
1126 | bool skipIncidence = false; | 1126 | bool skipIncidence = false; |
1127 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1127 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1128 | skipIncidence = true; | 1128 | skipIncidence = true; |
1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1130 | skipIncidence = true; | 1130 | skipIncidence = true; |
1131 | if ( filterOUT && ! filterOUT->filterCalendarItem( inL ) ){ | ||
1132 | skipIncidence = true; | ||
1133 | } | ||
1131 | if ( !skipIncidence ) { | 1134 | if ( !skipIncidence ) { |
1132 | inR = remote->incidence( uid ); | 1135 | inR = remote->incidence( uid ); |
1133 | if ( ! inR ) { // no conflict ********** add or delete local | 1136 | if ( ! inR ) { // no conflict ********** add or delete local |
1134 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1137 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1135 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1138 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1136 | checkExternSyncEvent(eventLSyncSharp, inL); | 1139 | checkExternSyncEvent(eventLSyncSharp, inL); |
1137 | local->deleteIncidence( inL ); | 1140 | local->deleteIncidence( inL ); |
1138 | ++deletedEventL; | 1141 | ++deletedEventL; |
1139 | } else { | 1142 | } else { |
1140 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1143 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1141 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1144 | inL->removeID(mCurrentSyncDevice ); |
1142 | inL->removeID(mCurrentSyncDevice ); | 1145 | ++addedEventR; |
1143 | ++addedEventR; | 1146 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1144 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1147 | inL->setLastModified( modifiedCalendar ); |
1145 | inL->setLastModified( modifiedCalendar ); | 1148 | inR = inL->clone(); |
1146 | inR = inL->clone(); | 1149 | inR->setIDStr( ":" ); |
1147 | inR->setIDStr( ":" ); | 1150 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1148 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1151 | remote->addIncidence( inR ); |
1149 | remote->addIncidence( inR ); | ||
1150 | } | ||
1151 | } | 1152 | } |
1152 | } | 1153 | } |
1153 | } else { | 1154 | } else { |
1154 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1155 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1155 | checkExternSyncEvent(eventLSyncSharp, inL); | 1156 | checkExternSyncEvent(eventLSyncSharp, inL); |
1156 | local->deleteIncidence( inL ); | 1157 | local->deleteIncidence( inL ); |
1157 | ++deletedEventL; | 1158 | ++deletedEventL; |
1158 | } else { | 1159 | } else { |
1159 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1160 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1160 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1161 | ++addedEventR; |
1161 | ++addedEventR; | 1162 | inL->setLastModified( modifiedCalendar ); |
1162 | inL->setLastModified( modifiedCalendar ); | 1163 | inR = inL->clone(); |
1163 | inR = inL->clone(); | 1164 | inR->setIDStr( ":" ); |
1164 | inR->setIDStr( ":" ); | 1165 | remote->addIncidence( inR ); |
1165 | remote->addIncidence( inR ); | ||
1166 | } | ||
1167 | } | 1166 | } |
1168 | } | 1167 | } |
1169 | } | 1168 | } |
1170 | } | 1169 | } |
1171 | } | 1170 | } |
1172 | inL = el.next(); | 1171 | inL = el.next(); |
1173 | } | 1172 | } |
1174 | int delFut = 0; | 1173 | int delFut = 0; |
1175 | int remRem = 0; | 1174 | int remRem = 0; |
1176 | if ( mSyncManager->mWriteBackInFuture ) { | 1175 | if ( mSyncManager->mWriteBackInFuture ) { |
1177 | er = remote->rawIncidences(); | 1176 | er = remote->rawIncidences(); |
1178 | remRem = er.count(); | 1177 | remRem = er.count(); |
1179 | inR = er.first(); | 1178 | inR = er.first(); |
1180 | QDateTime dt; | 1179 | QDateTime dt; |
1181 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1180 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1182 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1181 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1183 | while ( inR ) { | 1182 | while ( inR ) { |
1184 | if ( inR->type() == "Todo" ) { | 1183 | if ( inR->type() == "Todo" ) { |
1185 | Todo * t = (Todo*)inR; | 1184 | Todo * t = (Todo*)inR; |
1186 | if ( t->hasDueDate() ) | 1185 | if ( t->hasDueDate() ) |
1187 | dt = t->dtDue(); | 1186 | dt = t->dtDue(); |
1188 | else | 1187 | else |
1189 | dt = cur.addSecs( 62 ); | 1188 | dt = cur.addSecs( 62 ); |
1190 | } | 1189 | } |
1191 | else if (inR->type() == "Event" ) { | 1190 | else if (inR->type() == "Event" ) { |
1192 | bool ok; | 1191 | bool ok; |
1193 | dt = inR->getNextOccurence( cur, &ok ); | 1192 | dt = inR->getNextOccurence( cur, &ok ); |
1194 | if ( !ok ) | 1193 | if ( !ok ) |
1195 | dt = cur.addSecs( -62 ); | 1194 | dt = cur.addSecs( -62 ); |
1196 | } | 1195 | } |
1197 | else | 1196 | else |
1198 | dt = inR->dtStart(); | 1197 | dt = inR->dtStart(); |
1199 | if ( dt < cur || dt > end ) { | 1198 | if ( dt < cur || dt > end ) { |
1200 | remote->deleteIncidence( inR ); | 1199 | remote->deleteIncidence( inR ); |
1201 | ++delFut; | 1200 | ++delFut; |
1202 | } | 1201 | } |
1203 | inR = er.next(); | 1202 | inR = er.next(); |
1204 | } | 1203 | } |
1205 | } | 1204 | } |
1206 | bar.hide(); | 1205 | bar.hide(); |
1207 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1206 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1208 | eventLSync->setReadOnly( false ); | 1207 | eventLSync->setReadOnly( false ); |
1209 | eventLSync->setDtStart( mLastCalendarSync ); | 1208 | eventLSync->setDtStart( mLastCalendarSync ); |
1210 | eventRSync->setDtStart( mLastCalendarSync ); | 1209 | eventRSync->setDtStart( mLastCalendarSync ); |
1211 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1210 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1212 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1211 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1213 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1212 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1214 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1213 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1215 | eventLSync->setReadOnly( true ); | 1214 | eventLSync->setReadOnly( true ); |
1216 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); | 1215 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); |
1217 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1216 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1218 | remote->addEvent( eventRSync ); | 1217 | remote->addEvent( eventRSync ); |
1219 | else | 1218 | else |
1220 | delete eventRSync; | 1219 | delete eventRSync; |
1221 | QString mes; | 1220 | QString mes; |
1222 | 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 ); | 1221 | 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 ); |
1223 | QString delmess; | 1222 | QString delmess; |
1224 | if ( delFut ) { | 1223 | if ( delFut ) { |
1225 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1224 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1226 | mes += delmess; | 1225 | mes += delmess; |
1227 | } | 1226 | } |
1228 | mes = i18n("Local calendar changed!\n") +mes; | 1227 | mes = i18n("Local calendar changed!\n") +mes; |
1229 | mCalendar->checkAlarmForIncidence( 0, true ); | 1228 | mCalendar->checkAlarmForIncidence( 0, true ); |
1230 | qDebug( mes ); | 1229 | qDebug( mes ); |
1231 | if ( mSyncManager->mShowSyncSummary ) { | 1230 | if ( mSyncManager->mShowSyncSummary ) { |
1232 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1231 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1233 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1232 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1234 | qDebug("cancelled "); | 1233 | qDebug("cancelled "); |
1235 | return false; | 1234 | return false; |
1236 | } | 1235 | } |
1237 | } | 1236 | } |
1238 | return syncOK; | 1237 | return syncOK; |
1239 | } | 1238 | } |
1240 | 1239 | ||
1241 | void CalendarView::setSyncDevice( QString s ) | 1240 | void CalendarView::setSyncDevice( QString s ) |
1242 | { | 1241 | { |
1243 | mCurrentSyncDevice= s; | 1242 | mCurrentSyncDevice= s; |
1244 | } | 1243 | } |
1245 | void CalendarView::setSyncName( QString s ) | 1244 | void CalendarView::setSyncName( QString s ) |
1246 | { | 1245 | { |
1247 | mCurrentSyncName= s; | 1246 | mCurrentSyncName= s; |
1248 | } | 1247 | } |
1249 | bool CalendarView::syncCalendar(QString filename, int mode) | 1248 | bool CalendarView::syncCalendar(QString filename, int mode) |
1250 | { | 1249 | { |
1251 | //qDebug("syncCalendar %s ", filename.latin1()); | 1250 | //qDebug("syncCalendar %s ", filename.latin1()); |
1252 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1251 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1253 | CalendarLocal* calendar = new CalendarLocal(); | 1252 | CalendarLocal* calendar = new CalendarLocal(); |
1254 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1253 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1255 | FileStorage* storage = new FileStorage( calendar ); | 1254 | FileStorage* storage = new FileStorage( calendar ); |
1256 | bool syncOK = false; | 1255 | bool syncOK = false; |
1257 | storage->setFileName( filename ); | 1256 | storage->setFileName( filename ); |
1258 | // qDebug("loading ... "); | 1257 | // qDebug("loading ... "); |
1259 | if ( storage->load() ) { | 1258 | if ( storage->load() ) { |
1260 | getEventViewerDialog()->setSyncMode( true ); | 1259 | getEventViewerDialog()->setSyncMode( true ); |
1261 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1260 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1262 | getEventViewerDialog()->setSyncMode( false ); | 1261 | getEventViewerDialog()->setSyncMode( false ); |
1263 | if ( syncOK ) { | 1262 | if ( syncOK ) { |
1264 | if ( mSyncManager->mWriteBackFile ) | 1263 | if ( mSyncManager->mWriteBackFile ) |
1265 | { | 1264 | { |
1266 | storage->setSaveFormat( new ICalFormat() ); | 1265 | storage->setSaveFormat( new ICalFormat() ); |
1267 | storage->save(); | 1266 | storage->save(); |
1268 | } | 1267 | } |
1269 | } | 1268 | } |
1270 | setModified( true ); | 1269 | setModified( true ); |
1271 | } | 1270 | } |
1272 | delete storage; | 1271 | delete storage; |
1273 | delete calendar; | 1272 | delete calendar; |
1274 | if ( syncOK ) | 1273 | if ( syncOK ) |
1275 | updateView(); | 1274 | updateView(); |
1276 | return syncOK; | 1275 | return syncOK; |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | void CalendarView::syncExternal( int mode ) | 1278 | void CalendarView::syncExternal( int mode ) |
1280 | { | 1279 | { |
1281 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1280 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1282 | 1281 | ||
1283 | qApp->processEvents(); | 1282 | qApp->processEvents(); |
1284 | CalendarLocal* calendar = new CalendarLocal(); | 1283 | CalendarLocal* calendar = new CalendarLocal(); |
1285 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1284 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1286 | bool syncOK = false; | 1285 | bool syncOK = false; |
1287 | bool loadSuccess = false; | 1286 | bool loadSuccess = false; |
1288 | PhoneFormat* phoneFormat = 0; | 1287 | PhoneFormat* phoneFormat = 0; |
1289 | emit tempDisableBR(true); | 1288 | emit tempDisableBR(true); |
1290 | #ifndef DESKTOP_VERSION | 1289 | #ifndef DESKTOP_VERSION |
1291 | SharpFormat* sharpFormat = 0; | 1290 | SharpFormat* sharpFormat = 0; |
1292 | if ( mode == 0 ) { // sharp | 1291 | if ( mode == 0 ) { // sharp |
1293 | sharpFormat = new SharpFormat () ; | 1292 | sharpFormat = new SharpFormat () ; |
1294 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1293 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1295 | 1294 | ||
1296 | } else | 1295 | } else |
1297 | #endif | 1296 | #endif |
1298 | if ( mode == 1 ) { // phone | 1297 | if ( mode == 1 ) { // phone |
1299 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1298 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1300 | mSyncManager->mPhoneDevice, | 1299 | mSyncManager->mPhoneDevice, |
1301 | mSyncManager->mPhoneConnection, | 1300 | mSyncManager->mPhoneConnection, |
1302 | mSyncManager->mPhoneModel); | 1301 | mSyncManager->mPhoneModel); |
1303 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1302 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1304 | 1303 | ||
1305 | } else { | 1304 | } else { |
1306 | emit tempDisableBR(false); | 1305 | emit tempDisableBR(false); |
1307 | return; | 1306 | return; |
1308 | } | 1307 | } |
1309 | if ( loadSuccess ) { | 1308 | if ( loadSuccess ) { |
1310 | getEventViewerDialog()->setSyncMode( true ); | 1309 | getEventViewerDialog()->setSyncMode( true ); |
1311 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1310 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1312 | getEventViewerDialog()->setSyncMode( false ); | 1311 | getEventViewerDialog()->setSyncMode( false ); |
1313 | qApp->processEvents(); | 1312 | qApp->processEvents(); |
1314 | if ( syncOK ) { | 1313 | if ( syncOK ) { |
1315 | if ( mSyncManager->mWriteBackFile ) | 1314 | if ( mSyncManager->mWriteBackFile ) |
1316 | { | 1315 | { |
1317 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1316 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1318 | Incidence* inc = iL.first(); | 1317 | Incidence* inc = iL.first(); |
1319 | if ( phoneFormat ) { | 1318 | if ( phoneFormat ) { |
1320 | while ( inc ) { | 1319 | while ( inc ) { |
1321 | inc->removeID(mCurrentSyncDevice); | 1320 | inc->removeID(mCurrentSyncDevice); |
1322 | inc = iL.next(); | 1321 | inc = iL.next(); |
1323 | } | 1322 | } |
1324 | } | 1323 | } |
1325 | #ifndef DESKTOP_VERSION | 1324 | #ifndef DESKTOP_VERSION |
1326 | if ( sharpFormat ) | 1325 | if ( sharpFormat ) |
1327 | sharpFormat->save(calendar); | 1326 | sharpFormat->save(calendar); |
1328 | #endif | 1327 | #endif |
1329 | if ( phoneFormat ) | 1328 | if ( phoneFormat ) |
1330 | phoneFormat->save(calendar); | 1329 | phoneFormat->save(calendar); |
1331 | iL = calendar->rawIncidences(); | 1330 | iL = calendar->rawIncidences(); |
1332 | inc = iL.first(); | 1331 | inc = iL.first(); |
1333 | Incidence* loc; | 1332 | Incidence* loc; |
1334 | while ( inc ) { | 1333 | while ( inc ) { |
1335 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1334 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1336 | loc = mCalendar->incidence(inc->uid() ); | 1335 | loc = mCalendar->incidence(inc->uid() ); |
1337 | if ( loc ) { | 1336 | if ( loc ) { |
1338 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1337 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1339 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1338 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1340 | } | 1339 | } |
1341 | } | 1340 | } |
1342 | inc = iL.next(); | 1341 | inc = iL.next(); |
1343 | } | 1342 | } |
1344 | Incidence* lse = getLastSyncEvent(); | 1343 | Incidence* lse = getLastSyncEvent(); |
1345 | if ( lse ) { | 1344 | if ( lse ) { |
1346 | lse->setReadOnly( false ); | 1345 | lse->setReadOnly( false ); |
1347 | lse->setDescription( "" ); | 1346 | lse->setDescription( "" ); |
1348 | lse->setReadOnly( true ); | 1347 | lse->setReadOnly( true ); |
1349 | } | 1348 | } |
1350 | } | 1349 | } |
1351 | } else { | 1350 | } else { |
1352 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1351 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1353 | } | 1352 | } |
1354 | setModified( true ); | 1353 | setModified( true ); |
1355 | } else { | 1354 | } else { |
1356 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1355 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1357 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1356 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1358 | question, i18n("Ok")) ; | 1357 | question, i18n("Ok")) ; |
1359 | 1358 | ||
1360 | } | 1359 | } |
1361 | delete calendar; | 1360 | delete calendar; |
1362 | updateView(); | 1361 | updateView(); |
1363 | emit tempDisableBR(false); | 1362 | emit tempDisableBR(false); |
1364 | return ;//syncOK; | 1363 | return ;//syncOK; |
1365 | 1364 | ||
1366 | } | 1365 | } |
1367 | 1366 | ||
1368 | bool CalendarView::importBday() | 1367 | bool CalendarView::importBday() |
1369 | { | 1368 | { |
1370 | #ifndef KORG_NOKABC | 1369 | #ifndef KORG_NOKABC |
1371 | 1370 | ||
1372 | #ifdef DESKTOP_VERSION | 1371 | #ifdef DESKTOP_VERSION |
1373 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1372 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1374 | KABC::AddressBook::Iterator it; | 1373 | KABC::AddressBook::Iterator it; |
1375 | int count = 0; | 1374 | int count = 0; |
1376 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1375 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1377 | ++count; | 1376 | ++count; |
1378 | } | 1377 | } |
1379 | QProgressBar bar(count,0 ); | 1378 | QProgressBar bar(count,0 ); |
1380 | int w = 300; | 1379 | int w = 300; |
1381 | if ( QApplication::desktop()->width() < 320 ) | 1380 | if ( QApplication::desktop()->width() < 320 ) |
1382 | w = 220; | 1381 | w = 220; |
1383 | int h = bar.sizeHint().height() ; | 1382 | int h = bar.sizeHint().height() ; |
1384 | int dw = QApplication::desktop()->width(); | 1383 | int dw = QApplication::desktop()->width(); |
1385 | int dh = QApplication::desktop()->height(); | 1384 | int dh = QApplication::desktop()->height(); |
1386 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1385 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1387 | bar.show(); | 1386 | bar.show(); |
1388 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1387 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1389 | qApp->processEvents(); | 1388 | qApp->processEvents(); |
1390 | count = 0; | 1389 | count = 0; |
1391 | int addCount = 0; | 1390 | int addCount = 0; |
1392 | KCal::Attendee* a = 0; | 1391 | KCal::Attendee* a = 0; |
1393 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1392 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1394 | if ( ! bar.isVisible() ) | 1393 | if ( ! bar.isVisible() ) |
1395 | return false; | 1394 | return false; |
1396 | bar.setProgress( count++ ); | 1395 | bar.setProgress( count++ ); |
1397 | qApp->processEvents(); | 1396 | qApp->processEvents(); |
1398 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1397 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1399 | if ( (*it).birthday().date().isValid() ){ | 1398 | if ( (*it).birthday().date().isValid() ){ |
1400 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1399 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1401 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1400 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1402 | ++addCount; | 1401 | ++addCount; |
1403 | } | 1402 | } |
1404 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1403 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1405 | if ( anni.isValid() ){ | 1404 | if ( anni.isValid() ){ |
1406 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1405 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1407 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1406 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1408 | ++addCount; | 1407 | ++addCount; |
1409 | } | 1408 | } |
1410 | } | 1409 | } |
1411 | updateView(); | 1410 | updateView(); |
1412 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1411 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1413 | #else //DESKTOP_VERSION | 1412 | #else //DESKTOP_VERSION |
1414 | 1413 | ||
1415 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1414 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1416 | // the result should now arrive through method insertBirthdays | 1415 | // the result should now arrive through method insertBirthdays |
1417 | 1416 | ||
1418 | #endif //DESKTOP_VERSION | 1417 | #endif //DESKTOP_VERSION |
1419 | 1418 | ||
1420 | #endif //KORG_NOKABC | 1419 | #endif //KORG_NOKABC |
1421 | 1420 | ||
1422 | 1421 | ||
1423 | return true; | 1422 | return true; |
1424 | } | 1423 | } |
1425 | 1424 | ||
1426 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1425 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1427 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1426 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1428 | const QStringList& anniversaryList, const QStringList& realNameList, | 1427 | const QStringList& anniversaryList, const QStringList& realNameList, |
1429 | const QStringList& emailList, const QStringList& assembledNameList, | 1428 | const QStringList& emailList, const QStringList& assembledNameList, |
1430 | const QStringList& uidList) | 1429 | const QStringList& uidList) |
1431 | { | 1430 | { |
1432 | qDebug("CalendarView::insertBirthdays"); | 1431 | qDebug("CalendarView::insertBirthdays"); |
1433 | if (uid == this->name()) | 1432 | if (uid == this->name()) |
1434 | { | 1433 | { |
1435 | int count = birthdayList.count(); | 1434 | int count = birthdayList.count(); |
1436 | int addCount = 0; | 1435 | int addCount = 0; |
1437 | KCal::Attendee* a = 0; | 1436 | KCal::Attendee* a = 0; |
1438 | 1437 | ||
1439 | qDebug("CalView 1 %i", count); | 1438 | qDebug("CalView 1 %i", count); |
1440 | 1439 | ||
1441 | QProgressBar bar(count,0 ); | 1440 | QProgressBar bar(count,0 ); |
1442 | int w = 300; | 1441 | int w = 300; |
1443 | if ( QApplication::desktop()->width() < 320 ) | 1442 | if ( QApplication::desktop()->width() < 320 ) |
1444 | w = 220; | 1443 | w = 220; |
1445 | int h = bar.sizeHint().height() ; | 1444 | int h = bar.sizeHint().height() ; |
1446 | int dw = QApplication::desktop()->width(); | 1445 | int dw = QApplication::desktop()->width(); |
1447 | int dh = QApplication::desktop()->height(); | 1446 | int dh = QApplication::desktop()->height(); |
1448 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1447 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1449 | bar.show(); | 1448 | bar.show(); |
1450 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1449 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1451 | qApp->processEvents(); | 1450 | qApp->processEvents(); |
1452 | 1451 | ||
1453 | QDate birthday; | 1452 | QDate birthday; |
1454 | QDate anniversary; | 1453 | QDate anniversary; |
1455 | QString realName; | 1454 | QString realName; |
1456 | QString email; | 1455 | QString email; |
1457 | QString assembledName; | 1456 | QString assembledName; |
1458 | QString uid; | 1457 | QString uid; |
1459 | bool ok = true; | 1458 | bool ok = true; |
1460 | for ( int i = 0; i < count; i++) | 1459 | for ( int i = 0; i < count; i++) |
1461 | { | 1460 | { |
1462 | if ( ! bar.isVisible() ) | 1461 | if ( ! bar.isVisible() ) |
1463 | return; | 1462 | return; |
1464 | bar.setProgress( i ); | 1463 | bar.setProgress( i ); |
1465 | qApp->processEvents(); | 1464 | qApp->processEvents(); |
1466 | 1465 | ||
1467 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1466 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1468 | if (!ok) { | 1467 | if (!ok) { |
1469 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1468 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1470 | } | 1469 | } |
1471 | 1470 | ||
1472 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1471 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1473 | if (!ok) { | 1472 | if (!ok) { |
1474 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1473 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1475 | } | 1474 | } |
1476 | realName = realNameList[i]; | 1475 | realName = realNameList[i]; |
1477 | email = emailList[i]; | 1476 | email = emailList[i]; |
1478 | assembledName = assembledNameList[i]; | 1477 | assembledName = assembledNameList[i]; |
1479 | uid = uidList[i]; | 1478 | uid = uidList[i]; |
1480 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1479 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1481 | 1480 | ||
1482 | if ( birthday.isValid() ){ | 1481 | if ( birthday.isValid() ){ |
1483 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1482 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1484 | KCal::Attendee::ReqParticipant,uid) ; | 1483 | KCal::Attendee::ReqParticipant,uid) ; |
1485 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1484 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1486 | ++addCount; | 1485 | ++addCount; |
1487 | } | 1486 | } |
1488 | 1487 | ||
1489 | if ( anniversary.isValid() ){ | 1488 | if ( anniversary.isValid() ){ |
1490 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1489 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1491 | KCal::Attendee::ReqParticipant,uid) ; | 1490 | KCal::Attendee::ReqParticipant,uid) ; |
1492 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1491 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1493 | ++addCount; | 1492 | ++addCount; |
1494 | } | 1493 | } |
1495 | } | 1494 | } |
1496 | 1495 | ||
1497 | updateView(); | 1496 | updateView(); |
1498 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1497 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1499 | 1498 | ||
1500 | } | 1499 | } |
1501 | 1500 | ||
1502 | } | 1501 | } |
1503 | 1502 | ||
1504 | 1503 | ||
1505 | 1504 | ||
1506 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1505 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1507 | { | 1506 | { |
1508 | //qDebug("addAnni "); | 1507 | //qDebug("addAnni "); |
1509 | Event * ev = new Event(); | 1508 | Event * ev = new Event(); |
1510 | if ( a ) { | 1509 | if ( a ) { |
1511 | ev->addAttendee( a ); | 1510 | ev->addAttendee( a ); |
1512 | } | 1511 | } |
1513 | QString kind; | 1512 | QString kind; |
1514 | if ( birthday ) | 1513 | if ( birthday ) |
1515 | kind = i18n( "Birthday" ); | 1514 | kind = i18n( "Birthday" ); |
1516 | else | 1515 | else |
1517 | kind = i18n( "Anniversary" ); | 1516 | kind = i18n( "Anniversary" ); |
1518 | ev->setSummary( name + " - " + kind ); | 1517 | ev->setSummary( name + " - " + kind ); |
1519 | ev->setOrganizer(a->email()); | 1518 | ev->setOrganizer(a->email()); |
1520 | ev->setCategories( kind ); | 1519 | ev->setCategories( kind ); |
1521 | ev->setDtStart( QDateTime(date) ); | 1520 | ev->setDtStart( QDateTime(date) ); |
1522 | ev->setDtEnd( QDateTime(date) ); | 1521 | ev->setDtEnd( QDateTime(date) ); |
1523 | ev->setFloats( true ); | 1522 | ev->setFloats( true ); |
1524 | Recurrence * rec = ev->recurrence(); | 1523 | Recurrence * rec = ev->recurrence(); |
1525 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1524 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1526 | rec->addYearlyNum( date.month() ); | 1525 | rec->addYearlyNum( date.month() ); |
1527 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1526 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1528 | delete ev; | 1527 | delete ev; |
1529 | return false; | 1528 | return false; |
1530 | } | 1529 | } |
1531 | return true; | 1530 | return true; |
1532 | 1531 | ||
1533 | } | 1532 | } |
1534 | bool CalendarView::importQtopia( const QString &categories, | 1533 | bool CalendarView::importQtopia( const QString &categories, |
1535 | const QString &datebook, | 1534 | const QString &datebook, |
1536 | const QString &todolist ) | 1535 | const QString &todolist ) |
1537 | { | 1536 | { |
1538 | 1537 | ||
1539 | QtopiaFormat qtopiaFormat; | 1538 | QtopiaFormat qtopiaFormat; |
1540 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1539 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1541 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1540 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1542 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1541 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1543 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1542 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1544 | 1543 | ||
1545 | updateView(); | 1544 | updateView(); |
1546 | return true; | 1545 | return true; |
1547 | 1546 | ||
1548 | #if 0 | 1547 | #if 0 |
1549 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1548 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1550 | mCurrentSyncDevice = "qtopia-XML"; | 1549 | mCurrentSyncDevice = "qtopia-XML"; |
1551 | if ( mSyncManager->mAskForPreferences ) | 1550 | if ( mSyncManager->mAskForPreferences ) |
1552 | edit_sync_options(); | 1551 | edit_sync_options(); |
1553 | qApp->processEvents(); | 1552 | qApp->processEvents(); |
1554 | CalendarLocal* calendar = new CalendarLocal(); | 1553 | CalendarLocal* calendar = new CalendarLocal(); |
1555 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1554 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1556 | bool syncOK = false; | 1555 | bool syncOK = false; |
1557 | QtopiaFormat qtopiaFormat; | 1556 | QtopiaFormat qtopiaFormat; |
1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1557 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1559 | bool loadOk = true; | 1558 | bool loadOk = true; |
1560 | if ( !categories.isEmpty() ) | 1559 | if ( !categories.isEmpty() ) |
1561 | loadOk = qtopiaFormat.load( calendar, categories ); | 1560 | loadOk = qtopiaFormat.load( calendar, categories ); |
1562 | if ( loadOk && !datebook.isEmpty() ) | 1561 | if ( loadOk && !datebook.isEmpty() ) |
1563 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1562 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1564 | if ( loadOk && !todolist.isEmpty() ) | 1563 | if ( loadOk && !todolist.isEmpty() ) |
1565 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1564 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1566 | 1565 | ||
1567 | if ( loadOk ) { | 1566 | if ( loadOk ) { |
1568 | getEventViewerDialog()->setSyncMode( true ); | 1567 | getEventViewerDialog()->setSyncMode( true ); |
1569 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1568 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1570 | getEventViewerDialog()->setSyncMode( false ); | 1569 | getEventViewerDialog()->setSyncMode( false ); |
1571 | qApp->processEvents(); | 1570 | qApp->processEvents(); |
1572 | if ( syncOK ) { | 1571 | if ( syncOK ) { |
1573 | if ( mSyncManager->mWriteBackFile ) | 1572 | if ( mSyncManager->mWriteBackFile ) |
1574 | { | 1573 | { |
1575 | // write back XML file | 1574 | // write back XML file |
1576 | 1575 | ||
1577 | } | 1576 | } |
1578 | setModified( true ); | 1577 | setModified( true ); |
1579 | } | 1578 | } |
1580 | } else { | 1579 | } else { |
1581 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1580 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1582 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1581 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1583 | question, i18n("Ok")) ; | 1582 | question, i18n("Ok")) ; |
1584 | } | 1583 | } |
1585 | delete calendar; | 1584 | delete calendar; |
1586 | updateView(); | 1585 | updateView(); |
1587 | return syncOK; | 1586 | return syncOK; |
1588 | 1587 | ||
1589 | 1588 | ||
1590 | #endif | 1589 | #endif |
1591 | 1590 | ||
1592 | } | 1591 | } |
1593 | 1592 | ||
1594 | void CalendarView::setSyncEventsReadOnly() | 1593 | void CalendarView::setSyncEventsReadOnly() |
1595 | { | 1594 | { |
1596 | Event * ev; | 1595 | Event * ev; |
1597 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1596 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1598 | ev = eL.first(); | 1597 | ev = eL.first(); |
1599 | while ( ev ) { | 1598 | while ( ev ) { |
1600 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1599 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1601 | ev->setReadOnly( true ); | 1600 | ev->setReadOnly( true ); |
1602 | ev = eL.next(); | 1601 | ev = eL.next(); |
1603 | } | 1602 | } |
1604 | } | 1603 | } |
1605 | bool CalendarView::openCalendar(QString filename, bool merge) | 1604 | bool CalendarView::openCalendar(QString filename, bool merge) |
1606 | { | 1605 | { |
1607 | 1606 | ||
1608 | if (filename.isEmpty()) { | 1607 | if (filename.isEmpty()) { |
1609 | return false; | 1608 | return false; |
1610 | } | 1609 | } |
1611 | 1610 | ||
1612 | if (!QFile::exists(filename)) { | 1611 | if (!QFile::exists(filename)) { |
1613 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1612 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1614 | return false; | 1613 | return false; |
1615 | } | 1614 | } |
1616 | 1615 | ||
1617 | globalFlagBlockAgenda = 1; | 1616 | globalFlagBlockAgenda = 1; |
1618 | if (!merge) mCalendar->close(); | 1617 | if (!merge) mCalendar->close(); |
1619 | 1618 | ||
1620 | mStorage->setFileName( filename ); | 1619 | mStorage->setFileName( filename ); |
1621 | 1620 | ||
1622 | if ( mStorage->load() ) { | 1621 | if ( mStorage->load() ) { |
1623 | if ( merge ) ;//setModified( true ); | 1622 | if ( merge ) ;//setModified( true ); |
1624 | else { | 1623 | else { |
1625 | //setModified( true ); | 1624 | //setModified( true ); |
1626 | mViewManager->setDocumentId( filename ); | 1625 | mViewManager->setDocumentId( filename ); |
1627 | mDialogManager->setDocumentId( filename ); | 1626 | mDialogManager->setDocumentId( filename ); |
1628 | mTodoList->setDocumentId( filename ); | 1627 | mTodoList->setDocumentId( filename ); |
1629 | } | 1628 | } |
1630 | globalFlagBlockAgenda = 2; | 1629 | globalFlagBlockAgenda = 2; |
1631 | // if ( getLastSyncEvent() ) | 1630 | // if ( getLastSyncEvent() ) |
1632 | // getLastSyncEvent()->setReadOnly( true ); | 1631 | // getLastSyncEvent()->setReadOnly( true ); |
1633 | mCalendar->reInitAlarmSettings(); | 1632 | mCalendar->reInitAlarmSettings(); |
1634 | setSyncEventsReadOnly(); | 1633 | setSyncEventsReadOnly(); |
1635 | updateUnmanagedViews(); | 1634 | updateUnmanagedViews(); |
1636 | updateView(); | 1635 | updateView(); |
1637 | if ( filename != MainWindow::defaultFileName() ) { | 1636 | if ( filename != MainWindow::defaultFileName() ) { |
1638 | saveCalendar( MainWindow::defaultFileName() ); | 1637 | saveCalendar( MainWindow::defaultFileName() ); |
1639 | } else { | 1638 | } else { |
1640 | QFileInfo finf ( MainWindow::defaultFileName()); | 1639 | QFileInfo finf ( MainWindow::defaultFileName()); |
1641 | if ( finf.exists() ) { | 1640 | if ( finf.exists() ) { |
1642 | setLoadedFileVersion( finf.lastModified () ); | 1641 | setLoadedFileVersion( finf.lastModified () ); |
1643 | } | 1642 | } |
1644 | } | 1643 | } |
1645 | return true; | 1644 | return true; |
1646 | } else { | 1645 | } else { |
1647 | // while failing to load, the calendar object could | 1646 | // while failing to load, the calendar object could |
1648 | // have become partially populated. Clear it out. | 1647 | // have become partially populated. Clear it out. |
1649 | if ( !merge ) { | 1648 | if ( !merge ) { |
1650 | mCalendar->close(); | 1649 | mCalendar->close(); |
1651 | mViewManager->setDocumentId( filename ); | 1650 | mViewManager->setDocumentId( filename ); |
1652 | mDialogManager->setDocumentId( filename ); | 1651 | mDialogManager->setDocumentId( filename ); |
1653 | mTodoList->setDocumentId( filename ); | 1652 | mTodoList->setDocumentId( filename ); |
1654 | } | 1653 | } |
1655 | 1654 | ||
1656 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1655 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1657 | 1656 | ||
1658 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1657 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1659 | globalFlagBlockAgenda = 2; | 1658 | globalFlagBlockAgenda = 2; |
1660 | mCalendar->reInitAlarmSettings(); | 1659 | mCalendar->reInitAlarmSettings(); |
1661 | setSyncEventsReadOnly(); | 1660 | setSyncEventsReadOnly(); |
1662 | updateUnmanagedViews(); | 1661 | updateUnmanagedViews(); |
1663 | updateView(); | 1662 | updateView(); |
1664 | } | 1663 | } |
1665 | return false; | 1664 | return false; |
1666 | } | 1665 | } |
1667 | void CalendarView::showOpenError() | 1666 | void CalendarView::showOpenError() |
1668 | { | 1667 | { |
1669 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1668 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1670 | } | 1669 | } |
1671 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1670 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1672 | { | 1671 | { |
1673 | loadedFileVersion = dt; | 1672 | loadedFileVersion = dt; |
1674 | } | 1673 | } |
1675 | bool CalendarView::checkFileChanged(QString fn) | 1674 | bool CalendarView::checkFileChanged(QString fn) |
1676 | { | 1675 | { |
1677 | QFileInfo finf ( fn ); | 1676 | QFileInfo finf ( fn ); |
1678 | if ( !finf.exists() ) | 1677 | if ( !finf.exists() ) |
1679 | return true; | 1678 | return true; |
1680 | QDateTime dt = finf.lastModified (); | 1679 | QDateTime dt = finf.lastModified (); |
1681 | if ( dt <= loadedFileVersion ) | 1680 | if ( dt <= loadedFileVersion ) |
1682 | return false; | 1681 | return false; |
1683 | return true; | 1682 | return true; |
1684 | 1683 | ||
1685 | } | 1684 | } |
1686 | void CalendarView::watchSavedFile() | 1685 | void CalendarView::watchSavedFile() |
1687 | { | 1686 | { |
1688 | QFileInfo finf ( MainWindow::defaultFileName()); | 1687 | QFileInfo finf ( MainWindow::defaultFileName()); |
1689 | if ( !finf.exists() ) | 1688 | if ( !finf.exists() ) |
1690 | return; | 1689 | return; |
1691 | QDateTime dt = finf.lastModified (); | 1690 | QDateTime dt = finf.lastModified (); |
1692 | if ( dt < loadedFileVersion ) { | 1691 | if ( dt < loadedFileVersion ) { |
1693 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1692 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1694 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1693 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1695 | return; | 1694 | return; |
1696 | } | 1695 | } |
1697 | loadedFileVersion = dt; | 1696 | loadedFileVersion = dt; |
1698 | } | 1697 | } |
1699 | 1698 | ||
1700 | bool CalendarView::checkFileVersion(QString fn) | 1699 | bool CalendarView::checkFileVersion(QString fn) |
1701 | { | 1700 | { |
1702 | QFileInfo finf ( fn ); | 1701 | QFileInfo finf ( fn ); |
1703 | if ( !finf.exists() ) | 1702 | if ( !finf.exists() ) |
1704 | return true; | 1703 | return true; |
1705 | QDateTime dt = finf.lastModified (); | 1704 | QDateTime dt = finf.lastModified (); |
1706 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1705 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1707 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1706 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1708 | if ( dt <= loadedFileVersion ) | 1707 | if ( dt <= loadedFileVersion ) |
1709 | return true; | 1708 | return true; |
1710 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1709 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1711 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1710 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1712 | i18n("Sync+save")); | 1711 | i18n("Sync+save")); |
1713 | 1712 | ||
1714 | if ( km == KMessageBox::Cancel ) | 1713 | if ( km == KMessageBox::Cancel ) |
1715 | return false; | 1714 | return false; |
1716 | if ( km == KMessageBox::Yes ) | 1715 | if ( km == KMessageBox::Yes ) |
1717 | return true; | 1716 | return true; |
1718 | 1717 | ||
1719 | setSyncDevice("deleteaftersync" ); | 1718 | setSyncDevice("deleteaftersync" ); |
1720 | mSyncManager->mAskForPreferences = true; | 1719 | mSyncManager->mAskForPreferences = true; |
1721 | mSyncManager->mSyncAlgoPrefs = 3; | 1720 | mSyncManager->mSyncAlgoPrefs = 3; |
1722 | mSyncManager->mWriteBackFile = false; | 1721 | mSyncManager->mWriteBackFile = false; |
1723 | mSyncManager->mWriteBackExistingOnly = false; | 1722 | mSyncManager->mWriteBackExistingOnly = false; |
1724 | mSyncManager->mShowSyncSummary = false; | 1723 | mSyncManager->mShowSyncSummary = false; |
1725 | syncCalendar( fn, 3 ); | 1724 | syncCalendar( fn, 3 ); |
1726 | Event * e = getLastSyncEvent(); | 1725 | Event * e = getLastSyncEvent(); |
1727 | mCalendar->deleteEvent ( e ); | 1726 | mCalendar->deleteEvent ( e ); |
1728 | updateView(); | 1727 | updateView(); |
1729 | return true; | 1728 | return true; |
1730 | } | 1729 | } |
1731 | 1730 | ||
1732 | bool CalendarView::saveCalendar( QString filename ) | 1731 | bool CalendarView::saveCalendar( QString filename ) |
1733 | { | 1732 | { |
1734 | 1733 | ||
1735 | // Store back all unsaved data into calendar object | 1734 | // Store back all unsaved data into calendar object |
1736 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1735 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1737 | if ( mViewManager->currentView() ) | 1736 | if ( mViewManager->currentView() ) |
1738 | mViewManager->currentView()->flushView(); | 1737 | mViewManager->currentView()->flushView(); |
1739 | 1738 | ||
1740 | 1739 | ||
1741 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1740 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1742 | mStorage->setSaveFormat( new ICalFormat() ); | 1741 | mStorage->setSaveFormat( new ICalFormat() ); |
1743 | mStorage->setFileName( filename ); | 1742 | mStorage->setFileName( filename ); |
1744 | bool success; | 1743 | bool success; |
1745 | success = mStorage->save(); | 1744 | success = mStorage->save(); |
1746 | if ( !success ) { | 1745 | if ( !success ) { |
1747 | return false; | 1746 | return false; |
1748 | } | 1747 | } |
1749 | if ( filename == MainWindow::defaultFileName() ) { | 1748 | if ( filename == MainWindow::defaultFileName() ) { |
1750 | setLoadedFileVersion( lfv ); | 1749 | setLoadedFileVersion( lfv ); |
1751 | watchSavedFile(); | 1750 | watchSavedFile(); |
1752 | } | 1751 | } |
1753 | return true; | 1752 | return true; |
1754 | } | 1753 | } |
1755 | 1754 | ||
1756 | void CalendarView::closeCalendar() | 1755 | void CalendarView::closeCalendar() |
1757 | { | 1756 | { |
1758 | 1757 | ||
1759 | // child windows no longer valid | 1758 | // child windows no longer valid |
1760 | emit closingDown(); | 1759 | emit closingDown(); |
1761 | 1760 | ||
1762 | mCalendar->close(); | 1761 | mCalendar->close(); |
1763 | setModified(false); | 1762 | setModified(false); |
1764 | updateView(); | 1763 | updateView(); |
1765 | } | 1764 | } |
1766 | 1765 | ||
1767 | void CalendarView::archiveCalendar() | 1766 | void CalendarView::archiveCalendar() |
1768 | { | 1767 | { |
1769 | mDialogManager->showArchiveDialog(); | 1768 | mDialogManager->showArchiveDialog(); |
1770 | } | 1769 | } |
1771 | 1770 | ||
1772 | 1771 | ||
1773 | void CalendarView::readSettings() | 1772 | void CalendarView::readSettings() |
1774 | { | 1773 | { |
1775 | 1774 | ||
1776 | 1775 | ||
1777 | // mViewManager->showAgendaView(); | 1776 | // mViewManager->showAgendaView(); |
1778 | QString str; | 1777 | QString str; |
1779 | //qDebug("CalendarView::readSettings() "); | 1778 | //qDebug("CalendarView::readSettings() "); |
1780 | // read settings from the KConfig, supplying reasonable | 1779 | // read settings from the KConfig, supplying reasonable |
1781 | // defaults where none are to be found | 1780 | // defaults where none are to be found |
1782 | KConfig *config = KOGlobals::config(); | 1781 | KConfig *config = KOGlobals::config(); |
1783 | #ifndef KORG_NOSPLITTER | 1782 | #ifndef KORG_NOSPLITTER |
1784 | config->setGroup("KOrganizer Geometry"); | 1783 | config->setGroup("KOrganizer Geometry"); |
1785 | 1784 | ||
1786 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1785 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1787 | if (sizes.count() != 2) { | 1786 | if (sizes.count() != 2) { |
1788 | sizes << mDateNavigator->minimumSizeHint().width(); | 1787 | sizes << mDateNavigator->minimumSizeHint().width(); |
1789 | sizes << 300; | 1788 | sizes << 300; |
1790 | } | 1789 | } |
1791 | mPanner->setSizes(sizes); | 1790 | mPanner->setSizes(sizes); |
1792 | 1791 | ||
1793 | sizes = config->readIntListEntry("Separator2"); | 1792 | sizes = config->readIntListEntry("Separator2"); |
1794 | if ( ( mResourceView && sizes.count() == 4 ) || | 1793 | if ( ( mResourceView && sizes.count() == 4 ) || |
1795 | ( !mResourceView && sizes.count() == 3 ) ) { | 1794 | ( !mResourceView && sizes.count() == 3 ) ) { |
1796 | mLeftSplitter->setSizes(sizes); | 1795 | mLeftSplitter->setSizes(sizes); |
1797 | } | 1796 | } |
1798 | #endif | 1797 | #endif |
1799 | globalFlagBlockAgenda = 1; | 1798 | globalFlagBlockAgenda = 1; |
1800 | mViewManager->showAgendaView(); | 1799 | mViewManager->showAgendaView(); |
1801 | //mViewManager->readSettings( config ); | 1800 | //mViewManager->readSettings( config ); |
1802 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1801 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1803 | readFilterSettings(config); | 1802 | readFilterSettings(config); |
1804 | config->setGroup( "Views" ); | 1803 | config->setGroup( "Views" ); |
1805 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1804 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1806 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1805 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1807 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1806 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1808 | else mNavigator->selectDates( dateCount ); | 1807 | else mNavigator->selectDates( dateCount ); |
1809 | // mViewManager->readSettings( config ); | 1808 | // mViewManager->readSettings( config ); |
1810 | updateConfig(); | 1809 | updateConfig(); |
1811 | globalFlagBlockAgenda = 2; | 1810 | globalFlagBlockAgenda = 2; |
1812 | mViewManager->readSettings( config ); | 1811 | mViewManager->readSettings( config ); |
1813 | #ifdef DESKTOP_VERSION | 1812 | #ifdef DESKTOP_VERSION |
1814 | config->setGroup("WidgetLayout"); | 1813 | config->setGroup("WidgetLayout"); |
1815 | QStringList list; | 1814 | QStringList list; |
1816 | list = config->readListEntry("MainLayout"); | 1815 | list = config->readListEntry("MainLayout"); |
1817 | int x,y,w,h; | 1816 | int x,y,w,h; |
1818 | if ( ! list.isEmpty() ) { | 1817 | if ( ! list.isEmpty() ) { |
1819 | x = list[0].toInt(); | 1818 | x = list[0].toInt(); |
1820 | y = list[1].toInt(); | 1819 | y = list[1].toInt(); |
1821 | w = list[2].toInt(); | 1820 | w = list[2].toInt(); |
1822 | h = list[3].toInt(); | 1821 | h = list[3].toInt(); |
1823 | topLevelWidget()->setGeometry(x,y,w,h); | 1822 | topLevelWidget()->setGeometry(x,y,w,h); |
1824 | 1823 | ||
1825 | } else { | 1824 | } else { |
1826 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1825 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1827 | } | 1826 | } |
1828 | list = config->readListEntry("EditEventLayout"); | 1827 | list = config->readListEntry("EditEventLayout"); |
1829 | if ( ! list.isEmpty() ) { | 1828 | if ( ! list.isEmpty() ) { |
1830 | x = list[0].toInt(); | 1829 | x = list[0].toInt(); |
1831 | y = list[1].toInt(); | 1830 | y = list[1].toInt(); |
1832 | w = list[2].toInt(); | 1831 | w = list[2].toInt(); |
1833 | h = list[3].toInt(); | 1832 | h = list[3].toInt(); |
1834 | mEventEditor->setGeometry(x,y,w,h); | 1833 | mEventEditor->setGeometry(x,y,w,h); |
1835 | 1834 | ||
1836 | } | 1835 | } |
1837 | list = config->readListEntry("EditTodoLayout"); | 1836 | list = config->readListEntry("EditTodoLayout"); |
1838 | if ( ! list.isEmpty() ) { | 1837 | if ( ! list.isEmpty() ) { |
1839 | x = list[0].toInt(); | 1838 | x = list[0].toInt(); |
1840 | y = list[1].toInt(); | 1839 | y = list[1].toInt(); |
1841 | w = list[2].toInt(); | 1840 | w = list[2].toInt(); |
1842 | h = list[3].toInt(); | 1841 | h = list[3].toInt(); |
1843 | mTodoEditor->setGeometry(x,y,w,h); | 1842 | mTodoEditor->setGeometry(x,y,w,h); |
1844 | 1843 | ||
1845 | } | 1844 | } |
1846 | list = config->readListEntry("ViewerLayout"); | 1845 | list = config->readListEntry("ViewerLayout"); |
1847 | if ( ! list.isEmpty() ) { | 1846 | if ( ! list.isEmpty() ) { |
1848 | x = list[0].toInt(); | 1847 | x = list[0].toInt(); |
1849 | y = list[1].toInt(); | 1848 | y = list[1].toInt(); |
1850 | w = list[2].toInt(); | 1849 | w = list[2].toInt(); |
1851 | h = list[3].toInt(); | 1850 | h = list[3].toInt(); |
1852 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1851 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1853 | } | 1852 | } |
1854 | #endif | 1853 | #endif |
1855 | 1854 | ||
1856 | } | 1855 | } |
1857 | 1856 | ||
1858 | 1857 | ||
1859 | void CalendarView::writeSettings() | 1858 | void CalendarView::writeSettings() |
1860 | { | 1859 | { |
1861 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1860 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1862 | 1861 | ||
1863 | KConfig *config = KOGlobals::config(); | 1862 | KConfig *config = KOGlobals::config(); |
1864 | 1863 | ||
1865 | #ifndef KORG_NOSPLITTER | 1864 | #ifndef KORG_NOSPLITTER |
1866 | config->setGroup("KOrganizer Geometry"); | 1865 | config->setGroup("KOrganizer Geometry"); |
1867 | 1866 | ||
1868 | QValueList<int> list = mPanner->sizes(); | 1867 | QValueList<int> list = mPanner->sizes(); |
1869 | config->writeEntry("Separator1",list); | 1868 | config->writeEntry("Separator1",list); |
1870 | 1869 | ||
1871 | list = mLeftSplitter->sizes(); | 1870 | list = mLeftSplitter->sizes(); |
1872 | config->writeEntry("Separator2",list); | 1871 | config->writeEntry("Separator2",list); |
1873 | #endif | 1872 | #endif |
1874 | 1873 | ||
1875 | mViewManager->writeSettings( config ); | 1874 | mViewManager->writeSettings( config ); |
1876 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1875 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1877 | mDialogManager->writeSettings( config ); | 1876 | mDialogManager->writeSettings( config ); |
1878 | //KOPrefs::instance()->usrWriteConfig(); | 1877 | //KOPrefs::instance()->usrWriteConfig(); |
1879 | KOPrefs::instance()->writeConfig(); | 1878 | KOPrefs::instance()->writeConfig(); |
1880 | 1879 | ||
1881 | writeFilterSettings(config); | 1880 | writeFilterSettings(config); |
1882 | 1881 | ||
1883 | config->setGroup( "Views" ); | 1882 | config->setGroup( "Views" ); |
1884 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1883 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1885 | 1884 | ||
1886 | #ifdef DESKTOP_VERSION | 1885 | #ifdef DESKTOP_VERSION |
1887 | config->setGroup("WidgetLayout"); | 1886 | config->setGroup("WidgetLayout"); |
1888 | QStringList list ;//= config->readListEntry("MainLayout"); | 1887 | QStringList list ;//= config->readListEntry("MainLayout"); |
1889 | int x,y,w,h; | 1888 | int x,y,w,h; |
1890 | QWidget* wid; | 1889 | QWidget* wid; |
1891 | wid = topLevelWidget(); | 1890 | wid = topLevelWidget(); |
1892 | x = wid->geometry().x(); | 1891 | x = wid->geometry().x(); |
1893 | y = wid->geometry().y(); | 1892 | y = wid->geometry().y(); |
1894 | w = wid->width(); | 1893 | w = wid->width(); |
1895 | h = wid->height(); | 1894 | h = wid->height(); |
1896 | list.clear(); | 1895 | list.clear(); |
1897 | list << QString::number( x ); | 1896 | list << QString::number( x ); |
1898 | list << QString::number( y ); | 1897 | list << QString::number( y ); |
1899 | list << QString::number( w ); | 1898 | list << QString::number( w ); |
1900 | list << QString::number( h ); | 1899 | list << QString::number( h ); |
1901 | config->writeEntry("MainLayout",list ); | 1900 | config->writeEntry("MainLayout",list ); |
1902 | 1901 | ||
1903 | wid = mEventEditor; | 1902 | wid = mEventEditor; |
1904 | x = wid->geometry().x(); | 1903 | x = wid->geometry().x(); |
1905 | y = wid->geometry().y(); | 1904 | y = wid->geometry().y(); |
1906 | w = wid->width(); | 1905 | w = wid->width(); |
1907 | h = wid->height(); | 1906 | h = wid->height(); |
1908 | list.clear(); | 1907 | list.clear(); |
1909 | list << QString::number( x ); | 1908 | list << QString::number( x ); |
1910 | list << QString::number( y ); | 1909 | list << QString::number( y ); |
1911 | list << QString::number( w ); | 1910 | list << QString::number( w ); |
1912 | list << QString::number( h ); | 1911 | list << QString::number( h ); |
1913 | config->writeEntry("EditEventLayout",list ); | 1912 | config->writeEntry("EditEventLayout",list ); |
1914 | 1913 | ||
1915 | wid = mTodoEditor; | 1914 | wid = mTodoEditor; |
1916 | x = wid->geometry().x(); | 1915 | x = wid->geometry().x(); |
1917 | y = wid->geometry().y(); | 1916 | y = wid->geometry().y(); |
1918 | w = wid->width(); | 1917 | w = wid->width(); |
1919 | h = wid->height(); | 1918 | h = wid->height(); |
1920 | list.clear(); | 1919 | list.clear(); |
1921 | list << QString::number( x ); | 1920 | list << QString::number( x ); |
1922 | list << QString::number( y ); | 1921 | list << QString::number( y ); |
1923 | list << QString::number( w ); | 1922 | list << QString::number( w ); |
1924 | list << QString::number( h ); | 1923 | list << QString::number( h ); |
1925 | config->writeEntry("EditTodoLayout",list ); | 1924 | config->writeEntry("EditTodoLayout",list ); |
1926 | wid = getEventViewerDialog(); | 1925 | wid = getEventViewerDialog(); |
1927 | x = wid->geometry().x(); | 1926 | x = wid->geometry().x(); |
1928 | y = wid->geometry().y(); | 1927 | y = wid->geometry().y(); |
1929 | w = wid->width(); | 1928 | w = wid->width(); |
1930 | h = wid->height(); | 1929 | h = wid->height(); |
1931 | list.clear(); | 1930 | list.clear(); |
1932 | list << QString::number( x ); | 1931 | list << QString::number( x ); |
1933 | list << QString::number( y ); | 1932 | list << QString::number( y ); |
1934 | list << QString::number( w ); | 1933 | list << QString::number( w ); |
1935 | list << QString::number( h ); | 1934 | list << QString::number( h ); |
1936 | config->writeEntry("ViewerLayout",list ); | 1935 | config->writeEntry("ViewerLayout",list ); |
1937 | wid = mDialogManager->getSearchDialog(); | 1936 | wid = mDialogManager->getSearchDialog(); |
1938 | if ( wid ) { | 1937 | if ( wid ) { |
1939 | x = wid->geometry().x(); | 1938 | x = wid->geometry().x(); |
1940 | y = wid->geometry().y(); | 1939 | y = wid->geometry().y(); |
1941 | w = wid->width(); | 1940 | w = wid->width(); |
1942 | h = wid->height(); | 1941 | h = wid->height(); |
1943 | list.clear(); | 1942 | list.clear(); |
1944 | list << QString::number( x ); | 1943 | list << QString::number( x ); |
1945 | list << QString::number( y ); | 1944 | list << QString::number( y ); |
1946 | list << QString::number( w ); | 1945 | list << QString::number( w ); |
1947 | list << QString::number( h ); | 1946 | list << QString::number( h ); |
1948 | config->writeEntry("SearchLayout",list ); | 1947 | config->writeEntry("SearchLayout",list ); |
1949 | } | 1948 | } |
1950 | #endif | 1949 | #endif |
1951 | 1950 | ||
1952 | 1951 | ||
1953 | config->sync(); | 1952 | config->sync(); |
1954 | } | 1953 | } |
1955 | 1954 | ||
1956 | void CalendarView::readFilterSettings(KConfig *config) | 1955 | void CalendarView::readFilterSettings(KConfig *config) |
1957 | { | 1956 | { |
1958 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1957 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1959 | 1958 | ||
1960 | mFilters.clear(); | 1959 | mFilters.clear(); |
1961 | 1960 | ||
1962 | config->setGroup("General"); | 1961 | config->setGroup("General"); |
1963 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1962 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1964 | 1963 | ||
1965 | QStringList::ConstIterator it = filterList.begin(); | 1964 | QStringList::ConstIterator it = filterList.begin(); |
1966 | QStringList::ConstIterator end = filterList.end(); | 1965 | QStringList::ConstIterator end = filterList.end(); |
1967 | while(it != end) { | 1966 | while(it != end) { |
1968 | // kdDebug() << " filter: " << (*it) << endl; | 1967 | // kdDebug() << " filter: " << (*it) << endl; |
1969 | 1968 | ||
1970 | CalFilter *filter; | 1969 | CalFilter *filter; |
1971 | filter = new CalFilter(*it); | 1970 | filter = new CalFilter(*it); |
1972 | config->setGroup("Filter_" + (*it)); | 1971 | config->setGroup("Filter_" + (*it)); |
1973 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1972 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1974 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1973 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1975 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1974 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1976 | mFilters.append(filter); | 1975 | mFilters.append(filter); |
1977 | 1976 | ||
1978 | ++it; | 1977 | ++it; |
1979 | } | 1978 | } |
1980 | 1979 | ||
1981 | if (mFilters.count() == 0) { | 1980 | if (mFilters.count() == 0) { |
1982 | CalFilter *filter = new CalFilter(i18n("Default")); | 1981 | CalFilter *filter = new CalFilter(i18n("Default")); |
1983 | mFilters.append(filter); | 1982 | mFilters.append(filter); |
1984 | } | 1983 | } |
1985 | mFilterView->updateFilters(); | 1984 | mFilterView->updateFilters(); |
1986 | config->setGroup("FilterView"); | 1985 | config->setGroup("FilterView"); |
1987 | 1986 | ||
1988 | mFilterView->blockSignals(true); | 1987 | mFilterView->blockSignals(true); |
1989 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1988 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1990 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1989 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1991 | mFilterView->blockSignals(false); | 1990 | mFilterView->blockSignals(false); |
1992 | // We do it manually to avoid it being done twice by the above calls | 1991 | // We do it manually to avoid it being done twice by the above calls |
1993 | updateFilter(); | 1992 | updateFilter(); |
1994 | } | 1993 | } |
1995 | 1994 | ||
1996 | void CalendarView::writeFilterSettings(KConfig *config) | 1995 | void CalendarView::writeFilterSettings(KConfig *config) |
1997 | { | 1996 | { |
1998 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1997 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1999 | 1998 | ||
2000 | QStringList filterList; | 1999 | QStringList filterList; |
2001 | 2000 | ||
2002 | CalFilter *filter = mFilters.first(); | 2001 | CalFilter *filter = mFilters.first(); |
2003 | while(filter) { | 2002 | while(filter) { |
2004 | // kdDebug() << " fn: " << filter->name() << endl; | 2003 | // kdDebug() << " fn: " << filter->name() << endl; |
2005 | filterList << filter->name(); | 2004 | filterList << filter->name(); |
2006 | config->setGroup("Filter_" + filter->name()); | 2005 | config->setGroup("Filter_" + filter->name()); |
2007 | config->writeEntry("Criteria",filter->criteria()); | 2006 | config->writeEntry("Criteria",filter->criteria()); |
2008 | config->writeEntry("CategoryList",filter->categoryList()); | 2007 | config->writeEntry("CategoryList",filter->categoryList()); |
2009 | filter = mFilters.next(); | 2008 | filter = mFilters.next(); |
2010 | } | 2009 | } |
2011 | config->setGroup("General"); | 2010 | config->setGroup("General"); |
2012 | config->writeEntry("CalendarFilters",filterList); | 2011 | config->writeEntry("CalendarFilters",filterList); |
2013 | 2012 | ||
2014 | config->setGroup("FilterView"); | 2013 | config->setGroup("FilterView"); |
2015 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2014 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2016 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2015 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2017 | } | 2016 | } |
2018 | 2017 | ||
2019 | 2018 | ||
2020 | void CalendarView::goToday() | 2019 | void CalendarView::goToday() |
2021 | { | 2020 | { |
2022 | if ( mViewManager->currentView()->isMonthView() ) | 2021 | if ( mViewManager->currentView()->isMonthView() ) |
2023 | mNavigator->selectTodayMonth(); | 2022 | mNavigator->selectTodayMonth(); |
2024 | else | 2023 | else |
2025 | mNavigator->selectToday(); | 2024 | mNavigator->selectToday(); |
2026 | } | 2025 | } |
2027 | 2026 | ||
2028 | void CalendarView::goNext() | 2027 | void CalendarView::goNext() |
2029 | { | 2028 | { |
2030 | mNavigator->selectNext(); | 2029 | mNavigator->selectNext(); |
2031 | } | 2030 | } |
2032 | 2031 | ||
2033 | void CalendarView::goPrevious() | 2032 | void CalendarView::goPrevious() |
2034 | { | 2033 | { |
2035 | mNavigator->selectPrevious(); | 2034 | mNavigator->selectPrevious(); |
2036 | } | 2035 | } |
2037 | void CalendarView::goNextMonth() | 2036 | void CalendarView::goNextMonth() |
2038 | { | 2037 | { |
2039 | mNavigator->selectNextMonth(); | 2038 | mNavigator->selectNextMonth(); |
2040 | } | 2039 | } |
2041 | 2040 | ||
2042 | void CalendarView::goPreviousMonth() | 2041 | void CalendarView::goPreviousMonth() |
2043 | { | 2042 | { |
2044 | mNavigator->selectPreviousMonth(); | 2043 | mNavigator->selectPreviousMonth(); |
2045 | } | 2044 | } |
2046 | void CalendarView::writeLocale() | 2045 | void CalendarView::writeLocale() |
2047 | { | 2046 | { |
2048 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2047 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2049 | #if 0 | 2048 | #if 0 |
2050 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2049 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2051 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2050 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2052 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2051 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2053 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2052 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2054 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2053 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2055 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2054 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2056 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2055 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2057 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2056 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2058 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2057 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2059 | KOPrefs::instance()->mDaylightsavingStart, | 2058 | KOPrefs::instance()->mDaylightsavingStart, |
2060 | KOPrefs::instance()->mDaylightsavingEnd ); | 2059 | KOPrefs::instance()->mDaylightsavingEnd ); |
2061 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2060 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2062 | #endif | 2061 | #endif |
2063 | } | 2062 | } |
2064 | void CalendarView::updateConfig() | 2063 | void CalendarView::updateConfig() |
2065 | { | 2064 | { |
2066 | writeLocale(); | 2065 | writeLocale(); |
2067 | if ( KOPrefs::instance()->mUseAppColors ) | 2066 | if ( KOPrefs::instance()->mUseAppColors ) |
2068 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2067 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2069 | emit configChanged(); | 2068 | emit configChanged(); |
2070 | mTodoList->updateConfig(); | 2069 | mTodoList->updateConfig(); |
2071 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2070 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2072 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2071 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2073 | // To make the "fill window" configurations work | 2072 | // To make the "fill window" configurations work |
2074 | //mViewManager->raiseCurrentView(); | 2073 | //mViewManager->raiseCurrentView(); |
2075 | } | 2074 | } |
2076 | 2075 | ||
2077 | 2076 | ||
2078 | void CalendarView::eventChanged(Event *event) | 2077 | void CalendarView::eventChanged(Event *event) |
2079 | { | 2078 | { |
2080 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2079 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2081 | //updateUnmanagedViews(); | 2080 | //updateUnmanagedViews(); |
2082 | } | 2081 | } |
2083 | 2082 | ||
2084 | void CalendarView::eventAdded(Event *event) | 2083 | void CalendarView::eventAdded(Event *event) |
2085 | { | 2084 | { |
2086 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2085 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2087 | } | 2086 | } |
2088 | 2087 | ||
2089 | void CalendarView::eventToBeDeleted(Event *) | 2088 | void CalendarView::eventToBeDeleted(Event *) |
2090 | { | 2089 | { |
2091 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2090 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2092 | } | 2091 | } |
2093 | 2092 | ||
2094 | void CalendarView::eventDeleted() | 2093 | void CalendarView::eventDeleted() |
2095 | { | 2094 | { |
2096 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2095 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2097 | } | 2096 | } |
2098 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2097 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2099 | { | 2098 | { |
2100 | changeIncidenceDisplay((Incidence *)which, action); | 2099 | changeIncidenceDisplay((Incidence *)which, action); |
2101 | mDateNavigator->updateView(); //LR | 2100 | mDateNavigator->updateView(); //LR |
2102 | //mDialogManager->updateSearchDialog(); | 2101 | //mDialogManager->updateSearchDialog(); |
2103 | 2102 | ||
2104 | if (which) { | 2103 | if (which) { |
2105 | mViewManager->updateWNview(); | 2104 | mViewManager->updateWNview(); |
2106 | //mTodoList->updateView(); | 2105 | //mTodoList->updateView(); |
2107 | } | 2106 | } |
2108 | 2107 | ||
2109 | } | 2108 | } |
2110 | 2109 | ||
2111 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2110 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2112 | { | 2111 | { |
2113 | updateUnmanagedViews(); | 2112 | updateUnmanagedViews(); |
2114 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2113 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2115 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2114 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2116 | mCalendar->checkAlarmForIncidence( 0, true ); | 2115 | mCalendar->checkAlarmForIncidence( 0, true ); |
2117 | if ( mEventViewerDialog ) | 2116 | if ( mEventViewerDialog ) |
2118 | mEventViewerDialog->hide(); | 2117 | mEventViewerDialog->hide(); |
2119 | } | 2118 | } |
2120 | else | 2119 | else |
2121 | mCalendar->checkAlarmForIncidence( which , false ); | 2120 | mCalendar->checkAlarmForIncidence( which , false ); |
2122 | } | 2121 | } |
2123 | 2122 | ||
2124 | // most of the changeEventDisplays() right now just call the view's | 2123 | // most of the changeEventDisplays() right now just call the view's |
2125 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2124 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2126 | void CalendarView::changeEventDisplay(Event *which, int action) | 2125 | void CalendarView::changeEventDisplay(Event *which, int action) |
2127 | { | 2126 | { |
2128 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2127 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2129 | changeIncidenceDisplay((Incidence *)which, action); | 2128 | changeIncidenceDisplay((Incidence *)which, action); |
2130 | mDateNavigator->updateView(); | 2129 | mDateNavigator->updateView(); |
2131 | //mDialogManager->updateSearchDialog(); | 2130 | //mDialogManager->updateSearchDialog(); |
2132 | 2131 | ||
2133 | if (which) { | 2132 | if (which) { |
2134 | // If there is an event view visible update the display | 2133 | // If there is an event view visible update the display |
2135 | mViewManager->currentView()->changeEventDisplay(which,action); | 2134 | mViewManager->currentView()->changeEventDisplay(which,action); |
2136 | // TODO: check, if update needed | 2135 | // TODO: check, if update needed |
2137 | // if (which->getTodoStatus()) { | 2136 | // if (which->getTodoStatus()) { |
2138 | mTodoList->updateView(); | 2137 | mTodoList->updateView(); |
2139 | // } | 2138 | // } |
2140 | } else { | 2139 | } else { |
2141 | mViewManager->currentView()->updateView(); | 2140 | mViewManager->currentView()->updateView(); |
2142 | } | 2141 | } |
2143 | } | 2142 | } |
2144 | 2143 | ||
2145 | 2144 | ||
2146 | void CalendarView::updateTodoViews() | 2145 | void CalendarView::updateTodoViews() |
2147 | { | 2146 | { |
2148 | 2147 | ||
2149 | mTodoList->updateView(); | 2148 | mTodoList->updateView(); |
2150 | mViewManager->currentView()->updateView(); | 2149 | mViewManager->currentView()->updateView(); |
2151 | 2150 | ||
2152 | } | 2151 | } |
2153 | 2152 | ||
2154 | 2153 | ||
2155 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2154 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2156 | { | 2155 | { |
2157 | mTodoList->updateView(); | 2156 | mTodoList->updateView(); |
2158 | mViewManager->updateView(start, end); | 2157 | mViewManager->updateView(start, end); |
2159 | //mDateNavigator->updateView(); | 2158 | //mDateNavigator->updateView(); |
2160 | } | 2159 | } |
2161 | 2160 | ||
2162 | void CalendarView::updateView() | 2161 | void CalendarView::updateView() |
2163 | { | 2162 | { |
2164 | DateList tmpList = mNavigator->selectedDates(); | 2163 | DateList tmpList = mNavigator->selectedDates(); |
2165 | 2164 | ||
2166 | // We assume that the navigator only selects consecutive days. | 2165 | // We assume that the navigator only selects consecutive days. |
2167 | updateView( tmpList.first(), tmpList.last() ); | 2166 | updateView( tmpList.first(), tmpList.last() ); |
2168 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2167 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2169 | mTodoList->updateView(); | 2168 | mTodoList->updateView(); |
2170 | } | 2169 | } |
2171 | 2170 | ||
2172 | void CalendarView::updateUnmanagedViews() | 2171 | void CalendarView::updateUnmanagedViews() |
2173 | { | 2172 | { |
2174 | mDateNavigator->updateDayMatrix(); | 2173 | mDateNavigator->updateDayMatrix(); |
2175 | } | 2174 | } |
2176 | 2175 | ||
2177 | int CalendarView::msgItemDelete() | 2176 | int CalendarView::msgItemDelete() |
2178 | { | 2177 | { |
2179 | return KMessageBox::warningContinueCancel(this, | 2178 | return KMessageBox::warningContinueCancel(this, |
2180 | i18n("This item will be\npermanently deleted."), | 2179 | i18n("This item will be\npermanently deleted."), |
2181 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2180 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2182 | } | 2181 | } |
2183 | 2182 | ||
2184 | 2183 | ||
2185 | void CalendarView::edit_cut() | 2184 | void CalendarView::edit_cut() |
2186 | { | 2185 | { |
2187 | Event *anEvent=0; | 2186 | Event *anEvent=0; |
2188 | 2187 | ||
2189 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2188 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2190 | 2189 | ||
2191 | if (mViewManager->currentView()->isEventView()) { | 2190 | if (mViewManager->currentView()->isEventView()) { |
2192 | if ( incidence && incidence->type() == "Event" ) { | 2191 | if ( incidence && incidence->type() == "Event" ) { |
2193 | anEvent = static_cast<Event *>(incidence); | 2192 | anEvent = static_cast<Event *>(incidence); |
2194 | } | 2193 | } |
2195 | } | 2194 | } |
2196 | 2195 | ||
2197 | if (!anEvent) { | 2196 | if (!anEvent) { |
2198 | KNotifyClient::beep(); | 2197 | KNotifyClient::beep(); |
2199 | return; | 2198 | return; |
2200 | } | 2199 | } |
2201 | DndFactory factory( mCalendar ); | 2200 | DndFactory factory( mCalendar ); |
2202 | factory.cutEvent(anEvent); | 2201 | factory.cutEvent(anEvent); |
2203 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2202 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2204 | } | 2203 | } |
2205 | 2204 | ||
2206 | void CalendarView::edit_copy() | 2205 | void CalendarView::edit_copy() |
2207 | { | 2206 | { |
2208 | Event *anEvent=0; | 2207 | Event *anEvent=0; |
2209 | 2208 | ||
2210 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2209 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2211 | 2210 | ||
2212 | if (mViewManager->currentView()->isEventView()) { | 2211 | if (mViewManager->currentView()->isEventView()) { |
2213 | if ( incidence && incidence->type() == "Event" ) { | 2212 | if ( incidence && incidence->type() == "Event" ) { |
2214 | anEvent = static_cast<Event *>(incidence); | 2213 | anEvent = static_cast<Event *>(incidence); |
2215 | } | 2214 | } |
2216 | } | 2215 | } |
2217 | 2216 | ||
2218 | if (!anEvent) { | 2217 | if (!anEvent) { |
2219 | KNotifyClient::beep(); | 2218 | KNotifyClient::beep(); |
2220 | return; | 2219 | return; |
2221 | } | 2220 | } |
2222 | DndFactory factory( mCalendar ); | 2221 | DndFactory factory( mCalendar ); |
2223 | factory.copyEvent(anEvent); | 2222 | factory.copyEvent(anEvent); |
2224 | } | 2223 | } |
2225 | 2224 | ||
2226 | void CalendarView::edit_paste() | 2225 | void CalendarView::edit_paste() |
2227 | { | 2226 | { |
2228 | QDate date = mNavigator->selectedDates().first(); | 2227 | QDate date = mNavigator->selectedDates().first(); |
2229 | 2228 | ||
2230 | DndFactory factory( mCalendar ); | 2229 | DndFactory factory( mCalendar ); |
2231 | Event *pastedEvent = factory.pasteEvent( date ); | 2230 | Event *pastedEvent = factory.pasteEvent( date ); |
2232 | 2231 | ||
2233 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2232 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2234 | } | 2233 | } |
2235 | 2234 | ||
2236 | void CalendarView::edit_options() | 2235 | void CalendarView::edit_options() |
2237 | { | 2236 | { |
2238 | mDialogManager->showOptionsDialog(); | 2237 | mDialogManager->showOptionsDialog(); |
2239 | //writeSettings(); | 2238 | //writeSettings(); |
2240 | } | 2239 | } |
2241 | 2240 | ||
2242 | 2241 | ||
2243 | void CalendarView::slotSelectPickerDate( QDate d) | 2242 | void CalendarView::slotSelectPickerDate( QDate d) |
2244 | { | 2243 | { |
2245 | mDateFrame->hide(); | 2244 | mDateFrame->hide(); |
2246 | if ( mDatePickerMode == 1 ) { | 2245 | if ( mDatePickerMode == 1 ) { |
2247 | mNavigator->slotDaySelect( d ); | 2246 | mNavigator->slotDaySelect( d ); |
2248 | } else if ( mDatePickerMode == 2 ) { | 2247 | } else if ( mDatePickerMode == 2 ) { |
2249 | if ( mMoveIncidence->type() == "Todo" ) { | 2248 | if ( mMoveIncidence->type() == "Todo" ) { |
2250 | Todo * to = (Todo *) mMoveIncidence; | 2249 | Todo * to = (Todo *) mMoveIncidence; |
2251 | QTime tim; | 2250 | QTime tim; |
2252 | if ( to->hasDueDate() ) | 2251 | if ( to->hasDueDate() ) |
2253 | tim = to->dtDue().time(); | 2252 | tim = to->dtDue().time(); |
2254 | else { | 2253 | else { |
2255 | tim = QTime ( 0,0,0 ); | 2254 | tim = QTime ( 0,0,0 ); |
2256 | to->setFloats( true ); | 2255 | to->setFloats( true ); |
2257 | to->setHasDueDate( true ); | 2256 | to->setHasDueDate( true ); |
2258 | } | 2257 | } |
2259 | QDateTime dt ( d,tim ); | 2258 | QDateTime dt ( d,tim ); |
2260 | to->setDtDue( dt ); | 2259 | to->setDtDue( dt ); |
2261 | todoChanged( to ); | 2260 | todoChanged( to ); |
2262 | } else { | 2261 | } else { |
2263 | if ( mMoveIncidence->doesRecur() ) { | 2262 | if ( mMoveIncidence->doesRecur() ) { |
2264 | #if 0 | 2263 | #if 0 |
2265 | // PENDING implement this | 2264 | // PENDING implement this |
2266 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2265 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2267 | mCalendar()->addIncidence( newInc ); | 2266 | mCalendar()->addIncidence( newInc ); |
2268 | if ( mMoveIncidence->type() == "Todo" ) | 2267 | if ( mMoveIncidence->type() == "Todo" ) |
2269 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2268 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2270 | else | 2269 | else |
2271 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2270 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2272 | mMoveIncidence = newInc; | 2271 | mMoveIncidence = newInc; |
2273 | 2272 | ||
2274 | #endif | 2273 | #endif |
2275 | } | 2274 | } |
2276 | QTime tim = mMoveIncidence->dtStart().time(); | 2275 | QTime tim = mMoveIncidence->dtStart().time(); |
2277 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2276 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2278 | QDateTime dt ( d,tim ); | 2277 | QDateTime dt ( d,tim ); |
2279 | mMoveIncidence->setDtStart( dt ); | 2278 | mMoveIncidence->setDtStart( dt ); |
2280 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2279 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2281 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2280 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2282 | } | 2281 | } |
2283 | 2282 | ||
2284 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2283 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2285 | } | 2284 | } |
2286 | } | 2285 | } |
2287 | 2286 | ||
2288 | void CalendarView::removeCategories() | 2287 | void CalendarView::removeCategories() |
2289 | { | 2288 | { |
2290 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2289 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2291 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2290 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2292 | QStringList catIncList; | 2291 | QStringList catIncList; |
2293 | QStringList newCatList; | 2292 | QStringList newCatList; |
2294 | Incidence* inc = incList.first(); | 2293 | Incidence* inc = incList.first(); |
2295 | int i; | 2294 | int i; |
2296 | int count = 0; | 2295 | int count = 0; |
2297 | while ( inc ) { | 2296 | while ( inc ) { |
2298 | newCatList.clear(); | 2297 | newCatList.clear(); |
2299 | catIncList = inc->categories() ; | 2298 | catIncList = inc->categories() ; |
2300 | for( i = 0; i< catIncList.count(); ++i ) { | 2299 | for( i = 0; i< catIncList.count(); ++i ) { |
2301 | if ( catList.contains (catIncList[i])) | 2300 | if ( catList.contains (catIncList[i])) |
2302 | newCatList.append( catIncList[i] ); | 2301 | newCatList.append( catIncList[i] ); |
2303 | } | 2302 | } |
2304 | newCatList.sort(); | 2303 | newCatList.sort(); |
2305 | inc->setCategories( newCatList.join(",") ); | 2304 | inc->setCategories( newCatList.join(",") ); |
2306 | inc = incList.next(); | 2305 | inc = incList.next(); |
2307 | } | 2306 | } |
2308 | } | 2307 | } |
2309 | 2308 | ||
2310 | int CalendarView::addCategories() | 2309 | int CalendarView::addCategories() |
2311 | { | 2310 | { |
2312 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2311 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2313 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2312 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2314 | QStringList catIncList; | 2313 | QStringList catIncList; |
2315 | Incidence* inc = incList.first(); | 2314 | Incidence* inc = incList.first(); |
2316 | int i; | 2315 | int i; |
2317 | int count = 0; | 2316 | int count = 0; |
2318 | while ( inc ) { | 2317 | while ( inc ) { |
2319 | catIncList = inc->categories() ; | 2318 | catIncList = inc->categories() ; |
2320 | for( i = 0; i< catIncList.count(); ++i ) { | 2319 | for( i = 0; i< catIncList.count(); ++i ) { |
2321 | if ( !catList.contains (catIncList[i])) { | 2320 | if ( !catList.contains (catIncList[i])) { |
2322 | catList.append( catIncList[i] ); | 2321 | catList.append( catIncList[i] ); |
2323 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2322 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2324 | ++count; | 2323 | ++count; |
2325 | } | 2324 | } |
2326 | } | 2325 | } |
2327 | inc = incList.next(); | 2326 | inc = incList.next(); |
2328 | } | 2327 | } |
2329 | catList.sort(); | 2328 | catList.sort(); |
2330 | KOPrefs::instance()->mCustomCategories = catList; | 2329 | KOPrefs::instance()->mCustomCategories = catList; |
2331 | return count; | 2330 | return count; |
2332 | } | 2331 | } |
2333 | 2332 | ||
2334 | void CalendarView::manageCategories() | 2333 | void CalendarView::manageCategories() |
2335 | { | 2334 | { |
2336 | KOCatPrefs* cp = new KOCatPrefs(); | 2335 | KOCatPrefs* cp = new KOCatPrefs(); |
2337 | cp->show(); | 2336 | cp->show(); |
2338 | int w =cp->sizeHint().width() ; | 2337 | int w =cp->sizeHint().width() ; |
2339 | int h = cp->sizeHint().height() ; | 2338 | int h = cp->sizeHint().height() ; |
2340 | int dw = QApplication::desktop()->width(); | 2339 | int dw = QApplication::desktop()->width(); |
2341 | int dh = QApplication::desktop()->height(); | 2340 | int dh = QApplication::desktop()->height(); |
2342 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2341 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2343 | if ( !cp->exec() ) { | 2342 | if ( !cp->exec() ) { |
2344 | delete cp; | 2343 | delete cp; |
2345 | return; | 2344 | return; |
2346 | } | 2345 | } |
2347 | int count = 0; | 2346 | int count = 0; |
2348 | if ( cp->addCat() ) { | 2347 | if ( cp->addCat() ) { |
2349 | count = addCategories(); | 2348 | count = addCategories(); |
2350 | if ( count ) { | 2349 | if ( count ) { |
2351 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2350 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2352 | writeSettings(); | 2351 | writeSettings(); |
2353 | } else | 2352 | } else |
2354 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2353 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2355 | } else { | 2354 | } else { |
2356 | removeCategories(); | 2355 | removeCategories(); |
2357 | updateView(); | 2356 | updateView(); |
2358 | } | 2357 | } |
2359 | delete cp; | 2358 | delete cp; |
2360 | } | 2359 | } |
2361 | 2360 | ||
2362 | void CalendarView::beamIncidence(Incidence * Inc) | 2361 | void CalendarView::beamIncidence(Incidence * Inc) |
2363 | { | 2362 | { |
2364 | QPtrList<Incidence> delSel ; | 2363 | QPtrList<Incidence> delSel ; |
2365 | delSel.append(Inc); | 2364 | delSel.append(Inc); |
2366 | beamIncidenceList( delSel ); | 2365 | beamIncidenceList( delSel ); |
2367 | } | 2366 | } |
2368 | void CalendarView::beamCalendar() | 2367 | void CalendarView::beamCalendar() |
2369 | { | 2368 | { |
2370 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2369 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2371 | //qDebug("beamCalendar() "); | 2370 | //qDebug("beamCalendar() "); |
2372 | beamIncidenceList( delSel ); | 2371 | beamIncidenceList( delSel ); |
2373 | } | 2372 | } |
2374 | void CalendarView::beamFilteredCalendar() | 2373 | void CalendarView::beamFilteredCalendar() |
2375 | { | 2374 | { |
2376 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2375 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2377 | //qDebug("beamFilteredCalendar() "); | 2376 | //qDebug("beamFilteredCalendar() "); |
2378 | beamIncidenceList( delSel ); | 2377 | beamIncidenceList( delSel ); |
2379 | } | 2378 | } |
2380 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2379 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2381 | { | 2380 | { |
2382 | if ( beamDialog->exec () == QDialog::Rejected ) | 2381 | if ( beamDialog->exec () == QDialog::Rejected ) |
2383 | return; | 2382 | return; |
2384 | #ifdef DESKTOP_VERSION | 2383 | #ifdef DESKTOP_VERSION |
2385 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2384 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2386 | #else | 2385 | #else |
2387 | QString fn = "/tmp/kopibeamfile"; | 2386 | QString fn = "/tmp/kopibeamfile"; |
2388 | #endif | 2387 | #endif |
2389 | QString mes; | 2388 | QString mes; |
2390 | bool createbup = true; | 2389 | bool createbup = true; |
2391 | if ( createbup ) { | 2390 | if ( createbup ) { |
2392 | QString description = "\n"; | 2391 | QString description = "\n"; |
2393 | CalendarLocal* cal = new CalendarLocal(); | 2392 | CalendarLocal* cal = new CalendarLocal(); |
2394 | if ( beamDialog->beamLocal() ) | 2393 | if ( beamDialog->beamLocal() ) |
2395 | cal->setLocalTime(); | 2394 | cal->setLocalTime(); |
2396 | else | 2395 | else |
2397 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2396 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2398 | Incidence *incidence = delSel.first(); | 2397 | Incidence *incidence = delSel.first(); |
2399 | bool addText = false; | 2398 | bool addText = false; |
2400 | if ( delSel.count() < 10 ) | 2399 | if ( delSel.count() < 10 ) |
2401 | addText = true; | 2400 | addText = true; |
2402 | else { | 2401 | else { |
2403 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2402 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2404 | } | 2403 | } |
2405 | while ( incidence ) { | 2404 | while ( incidence ) { |
2406 | Incidence *in = incidence->clone(); | 2405 | Incidence *in = incidence->clone(); |
2407 | if ( ! in->summary().isEmpty() ) { | 2406 | if ( ! in->summary().isEmpty() ) { |
2408 | in->setDescription(""); | 2407 | in->setDescription(""); |
2409 | } else { | 2408 | } else { |
2410 | in->setSummary( in->description().left(20)); | 2409 | in->setSummary( in->description().left(20)); |
2411 | in->setDescription(""); | 2410 | in->setDescription(""); |
2412 | } | 2411 | } |
2413 | if ( addText ) | 2412 | if ( addText ) |
2414 | description += in->summary() + "\n"; | 2413 | description += in->summary() + "\n"; |
2415 | cal->addIncidence( in ); | 2414 | cal->addIncidence( in ); |
2416 | incidence = delSel.next(); | 2415 | incidence = delSel.next(); |
2417 | } | 2416 | } |
2418 | if ( beamDialog->beamVcal() ) { | 2417 | if ( beamDialog->beamVcal() ) { |
2419 | fn += ".vcs"; | 2418 | fn += ".vcs"; |
2420 | FileStorage storage( cal, fn, new VCalFormat ); | 2419 | FileStorage storage( cal, fn, new VCalFormat ); |
2421 | storage.save(); | 2420 | storage.save(); |
2422 | } else { | 2421 | } else { |
2423 | fn += ".ics"; | 2422 | fn += ".ics"; |
2424 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2423 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2425 | storage.save(); | 2424 | storage.save(); |
2426 | } | 2425 | } |
2427 | delete cal; | 2426 | delete cal; |
2428 | mes = i18n("KO/Pi: Ready for beaming"); | 2427 | mes = i18n("KO/Pi: Ready for beaming"); |
2429 | topLevelWidget()->setCaption(mes); | 2428 | topLevelWidget()->setCaption(mes); |
2430 | KApplication::convert2latin1( fn ); | 2429 | KApplication::convert2latin1( fn ); |
2431 | #ifndef DESKTOP_VERSION | 2430 | #ifndef DESKTOP_VERSION |
2432 | Ir *ir = new Ir( this ); | 2431 | Ir *ir = new Ir( this ); |
2433 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2432 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2434 | ir->send( fn, description, "text/x-vCalendar" ); | 2433 | ir->send( fn, description, "text/x-vCalendar" ); |
2435 | #endif | 2434 | #endif |
2436 | } | 2435 | } |
2437 | } | 2436 | } |
2438 | void CalendarView::beamDone( Ir *ir ) | 2437 | void CalendarView::beamDone( Ir *ir ) |
2439 | { | 2438 | { |
2440 | #ifndef DESKTOP_VERSION | 2439 | #ifndef DESKTOP_VERSION |
2441 | delete ir; | 2440 | delete ir; |
2442 | #endif | 2441 | #endif |
2443 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2442 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2444 | topLevelWidget()->raise(); | 2443 | topLevelWidget()->raise(); |
2445 | } | 2444 | } |
2446 | 2445 | ||
2447 | void CalendarView::moveIncidence(Incidence * inc ) | 2446 | void CalendarView::moveIncidence(Incidence * inc ) |
2448 | { | 2447 | { |
2449 | if ( !inc ) return; | 2448 | if ( !inc ) return; |
2450 | // qDebug("showDatePickerForIncidence( ) "); | 2449 | // qDebug("showDatePickerForIncidence( ) "); |
2451 | if ( mDateFrame->isVisible() ) | 2450 | if ( mDateFrame->isVisible() ) |
2452 | mDateFrame->hide(); | 2451 | mDateFrame->hide(); |
2453 | else { | 2452 | else { |
2454 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2453 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2455 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2454 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2456 | int dw = QApplication::desktop()->width(); | 2455 | int dw = QApplication::desktop()->width(); |
2457 | int dh = QApplication::desktop()->height(); | 2456 | int dh = QApplication::desktop()->height(); |
2458 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2457 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2459 | mDateFrame->show(); | 2458 | mDateFrame->show(); |
2460 | } | 2459 | } |
2461 | mDatePickerMode = 2; | 2460 | mDatePickerMode = 2; |
2462 | mMoveIncidence = inc ; | 2461 | mMoveIncidence = inc ; |
2463 | QDate da; | 2462 | QDate da; |
2464 | if ( mMoveIncidence->type() == "Todo" ) { | 2463 | if ( mMoveIncidence->type() == "Todo" ) { |
2465 | Todo * to = (Todo *) mMoveIncidence; | 2464 | Todo * to = (Todo *) mMoveIncidence; |
2466 | if ( to->hasDueDate() ) | 2465 | if ( to->hasDueDate() ) |
2467 | da = to->dtDue().date(); | 2466 | da = to->dtDue().date(); |
2468 | else | 2467 | else |
2469 | da = QDate::currentDate(); | 2468 | da = QDate::currentDate(); |
2470 | } else { | 2469 | } else { |
2471 | da = mMoveIncidence->dtStart().date(); | 2470 | da = mMoveIncidence->dtStart().date(); |
2472 | } | 2471 | } |
2473 | //PENDING set date for recurring incidence to date of recurrence | 2472 | //PENDING set date for recurring incidence to date of recurrence |
2474 | //mMoveIncidenceOldDate; | 2473 | //mMoveIncidenceOldDate; |
2475 | mDatePicker->setDate( da ); | 2474 | mDatePicker->setDate( da ); |
2476 | } | 2475 | } |
2477 | void CalendarView::showDatePicker( ) | 2476 | void CalendarView::showDatePicker( ) |
2478 | { | 2477 | { |
2479 | //qDebug("CalendarView::showDatePicker( ) "); | 2478 | //qDebug("CalendarView::showDatePicker( ) "); |
2480 | if ( mDateFrame->isVisible() ) | 2479 | if ( mDateFrame->isVisible() ) |
2481 | mDateFrame->hide(); | 2480 | mDateFrame->hide(); |
2482 | else { | 2481 | else { |
2483 | int w =mDatePicker->sizeHint().width() ; | 2482 | int w =mDatePicker->sizeHint().width() ; |
2484 | int h = mDatePicker->sizeHint().height() ; | 2483 | int h = mDatePicker->sizeHint().height() ; |
2485 | int dw = QApplication::desktop()->width(); | 2484 | int dw = QApplication::desktop()->width(); |
2486 | int dh = QApplication::desktop()->height(); | 2485 | int dh = QApplication::desktop()->height(); |
2487 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2486 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2488 | mDateFrame->show(); | 2487 | mDateFrame->show(); |
2489 | } | 2488 | } |
2490 | mDatePickerMode = 1; | 2489 | mDatePickerMode = 1; |
2491 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2490 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2492 | } | 2491 | } |
2493 | 2492 | ||
2494 | void CalendarView::showEventEditor() | 2493 | void CalendarView::showEventEditor() |
2495 | { | 2494 | { |
2496 | #ifdef DESKTOP_VERSION | 2495 | #ifdef DESKTOP_VERSION |
2497 | mEventEditor->show(); | 2496 | mEventEditor->show(); |
2498 | #else | 2497 | #else |
2499 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2498 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2500 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2499 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2501 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2500 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2502 | delete mEventEditor; | 2501 | delete mEventEditor; |
2503 | mEventEditor = mDialogManager->getEventEditor(); | 2502 | mEventEditor = mDialogManager->getEventEditor(); |
2504 | } | 2503 | } |
2505 | mEventEditor->showMaximized(); | 2504 | mEventEditor->showMaximized(); |
2506 | #endif | 2505 | #endif |
2507 | } | 2506 | } |
2508 | void CalendarView::showTodoEditor() | 2507 | void CalendarView::showTodoEditor() |
2509 | { | 2508 | { |
2510 | #ifdef DESKTOP_VERSION | 2509 | #ifdef DESKTOP_VERSION |
2511 | mTodoEditor->show(); | 2510 | mTodoEditor->show(); |
2512 | #else | 2511 | #else |
2513 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2512 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2514 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2513 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2515 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2514 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2516 | delete mTodoEditor; | 2515 | delete mTodoEditor; |
2517 | mTodoEditor = mDialogManager->getTodoEditor(); | 2516 | mTodoEditor = mDialogManager->getTodoEditor(); |
2518 | } | 2517 | } |
2519 | mTodoEditor->showMaximized(); | 2518 | mTodoEditor->showMaximized(); |
2520 | #endif | 2519 | #endif |
2521 | } | 2520 | } |
2522 | 2521 | ||
2523 | void CalendarView::cloneIncidence() | 2522 | void CalendarView::cloneIncidence() |
2524 | { | 2523 | { |
2525 | Incidence *incidence = currentSelection(); | 2524 | Incidence *incidence = currentSelection(); |
2526 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2525 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2527 | if ( incidence ) { | 2526 | if ( incidence ) { |
2528 | cloneIncidence(incidence); | 2527 | cloneIncidence(incidence); |
2529 | } | 2528 | } |
2530 | } | 2529 | } |
2531 | void CalendarView::moveIncidence() | 2530 | void CalendarView::moveIncidence() |
2532 | { | 2531 | { |
2533 | Incidence *incidence = currentSelection(); | 2532 | Incidence *incidence = currentSelection(); |
2534 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2533 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2535 | if ( incidence ) { | 2534 | if ( incidence ) { |
2536 | moveIncidence(incidence); | 2535 | moveIncidence(incidence); |
2537 | } | 2536 | } |
2538 | } | 2537 | } |
2539 | void CalendarView::beamIncidence() | 2538 | void CalendarView::beamIncidence() |
2540 | { | 2539 | { |
2541 | Incidence *incidence = currentSelection(); | 2540 | Incidence *incidence = currentSelection(); |
2542 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2541 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2543 | if ( incidence ) { | 2542 | if ( incidence ) { |
2544 | beamIncidence(incidence); | 2543 | beamIncidence(incidence); |
2545 | } | 2544 | } |
2546 | } | 2545 | } |
2547 | void CalendarView::toggleCancelIncidence() | 2546 | void CalendarView::toggleCancelIncidence() |
2548 | { | 2547 | { |
2549 | Incidence *incidence = currentSelection(); | 2548 | Incidence *incidence = currentSelection(); |
2550 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2549 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2551 | if ( incidence ) { | 2550 | if ( incidence ) { |
2552 | cancelIncidence(incidence); | 2551 | cancelIncidence(incidence); |
2553 | } | 2552 | } |
2554 | } | 2553 | } |
2555 | 2554 | ||
2556 | 2555 | ||
2557 | void CalendarView::cancelIncidence(Incidence * inc ) | 2556 | void CalendarView::cancelIncidence(Incidence * inc ) |
2558 | { | 2557 | { |
2559 | inc->setCancelled( ! inc->cancelled() ); | 2558 | inc->setCancelled( ! inc->cancelled() ); |
2560 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2559 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2561 | updateView(); | 2560 | updateView(); |
2562 | } | 2561 | } |
2563 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2562 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2564 | { | 2563 | { |
2565 | Incidence * newInc = orgInc->clone(); | 2564 | Incidence * newInc = orgInc->clone(); |
2566 | newInc->recreate(); | 2565 | newInc->recreate(); |
2567 | 2566 | ||
2568 | if ( newInc->type() == "Todo" ) { | 2567 | if ( newInc->type() == "Todo" ) { |
2569 | Todo* t = (Todo*) newInc; | 2568 | Todo* t = (Todo*) newInc; |
2570 | showTodoEditor(); | 2569 | showTodoEditor(); |
2571 | mTodoEditor->editTodo( t ); | 2570 | mTodoEditor->editTodo( t ); |
2572 | if ( mTodoEditor->exec() ) { | 2571 | if ( mTodoEditor->exec() ) { |
2573 | mCalendar->addTodo( t ); | 2572 | mCalendar->addTodo( t ); |
2574 | updateView(); | 2573 | updateView(); |
2575 | } else { | 2574 | } else { |
2576 | delete t; | 2575 | delete t; |
2577 | } | 2576 | } |
2578 | } | 2577 | } |
2579 | else { | 2578 | else { |
2580 | Event* e = (Event*) newInc; | 2579 | Event* e = (Event*) newInc; |
2581 | showEventEditor(); | 2580 | showEventEditor(); |
2582 | mEventEditor->editEvent( e ); | 2581 | mEventEditor->editEvent( e ); |
2583 | if ( mEventEditor->exec() ) { | 2582 | if ( mEventEditor->exec() ) { |
2584 | mCalendar->addEvent( e ); | 2583 | mCalendar->addEvent( e ); |
2585 | updateView(); | 2584 | updateView(); |
2586 | } else { | 2585 | } else { |
2587 | delete e; | 2586 | delete e; |
2588 | } | 2587 | } |
2589 | } | 2588 | } |
2590 | } | 2589 | } |
2591 | 2590 | ||
2592 | void CalendarView::newEvent() | 2591 | void CalendarView::newEvent() |
2593 | { | 2592 | { |
2594 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2593 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2595 | KOAgendaView *aView = mViewManager->agendaView(); | 2594 | KOAgendaView *aView = mViewManager->agendaView(); |
2596 | if (aView) { | 2595 | if (aView) { |
2597 | if (aView->selectionStart().isValid()) { | 2596 | if (aView->selectionStart().isValid()) { |
2598 | if (aView->selectedIsAllDay()) { | 2597 | if (aView->selectedIsAllDay()) { |
2599 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2598 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2600 | } else { | 2599 | } else { |
2601 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2600 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2602 | } | 2601 | } |
2603 | return; | 2602 | return; |
2604 | } | 2603 | } |
2605 | } | 2604 | } |
2606 | 2605 | ||
2607 | QDate date = mNavigator->selectedDates().first(); | 2606 | QDate date = mNavigator->selectedDates().first(); |
2608 | QDateTime current = QDateTime::currentDateTime(); | 2607 | QDateTime current = QDateTime::currentDateTime(); |
2609 | if ( date <= current.date() ) { | 2608 | if ( date <= current.date() ) { |
2610 | int hour = current.time().hour() +1; | 2609 | int hour = current.time().hour() +1; |
2611 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2610 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2612 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2611 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2613 | } else | 2612 | } else |
2614 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2613 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2615 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2614 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2616 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2615 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2617 | } | 2616 | } |
2618 | 2617 | ||
2619 | void CalendarView::newEvent(QDateTime fh) | 2618 | void CalendarView::newEvent(QDateTime fh) |
2620 | { | 2619 | { |
2621 | newEvent(fh, | 2620 | newEvent(fh, |
2622 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2621 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2623 | } | 2622 | } |
2624 | 2623 | ||
2625 | void CalendarView::newEvent(QDate dt) | 2624 | void CalendarView::newEvent(QDate dt) |
2626 | { | 2625 | { |
2627 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2626 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2628 | QDateTime(dt, QTime(0,0,0)), true); | 2627 | QDateTime(dt, QTime(0,0,0)), true); |
2629 | } | 2628 | } |
2630 | 2629 | ||
2631 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2630 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2632 | { | 2631 | { |
2633 | 2632 | ||
2634 | showEventEditor(); | 2633 | showEventEditor(); |
2635 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2634 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2636 | if ( mFilterView->filtersEnabled() ) { | 2635 | if ( mFilterView->filtersEnabled() ) { |
2637 | CalFilter *filter = mFilterView->selectedFilter(); | 2636 | CalFilter *filter = mFilterView->selectedFilter(); |
2638 | if (filter && filter->showCategories()) { | 2637 | if (filter && filter->showCategories()) { |
2639 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2638 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2640 | } | 2639 | } |
2641 | if ( filter ) | 2640 | if ( filter ) |
2642 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2641 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2643 | } | 2642 | } |
2644 | } | 2643 | } |
2645 | void CalendarView::todoAdded(Todo * t) | 2644 | void CalendarView::todoAdded(Todo * t) |
2646 | { | 2645 | { |
2647 | 2646 | ||
2648 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2647 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2649 | updateTodoViews(); | 2648 | updateTodoViews(); |
2650 | } | 2649 | } |
2651 | void CalendarView::todoChanged(Todo * t) | 2650 | void CalendarView::todoChanged(Todo * t) |
2652 | { | 2651 | { |
2653 | emit todoModified( t, 4 ); | 2652 | emit todoModified( t, 4 ); |
2654 | // updateTodoViews(); | 2653 | // updateTodoViews(); |
2655 | } | 2654 | } |
2656 | void CalendarView::todoToBeDeleted(Todo *) | 2655 | void CalendarView::todoToBeDeleted(Todo *) |
2657 | { | 2656 | { |
2658 | //qDebug("todoToBeDeleted(Todo *) "); | 2657 | //qDebug("todoToBeDeleted(Todo *) "); |
2659 | updateTodoViews(); | 2658 | updateTodoViews(); |
2660 | } | 2659 | } |
2661 | void CalendarView::todoDeleted() | 2660 | void CalendarView::todoDeleted() |
2662 | { | 2661 | { |
2663 | //qDebug(" todoDeleted()"); | 2662 | //qDebug(" todoDeleted()"); |
2664 | updateTodoViews(); | 2663 | updateTodoViews(); |
2665 | } | 2664 | } |
2666 | 2665 | ||
2667 | 2666 | ||
2668 | 2667 | ||
2669 | void CalendarView::newTodo() | 2668 | void CalendarView::newTodo() |
2670 | { | 2669 | { |
2671 | 2670 | ||
2672 | showTodoEditor(); | 2671 | showTodoEditor(); |
2673 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2672 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2674 | if ( mFilterView->filtersEnabled() ) { | 2673 | if ( mFilterView->filtersEnabled() ) { |
2675 | CalFilter *filter = mFilterView->selectedFilter(); | 2674 | CalFilter *filter = mFilterView->selectedFilter(); |
2676 | if (filter && filter->showCategories()) { | 2675 | if (filter && filter->showCategories()) { |
2677 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2676 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2678 | } | 2677 | } |
2679 | if ( filter ) | 2678 | if ( filter ) |
2680 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2679 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2681 | } | 2680 | } |
2682 | } | 2681 | } |
2683 | 2682 | ||
2684 | void CalendarView::newSubTodo() | 2683 | void CalendarView::newSubTodo() |
2685 | { | 2684 | { |
2686 | Todo *todo = selectedTodo(); | 2685 | Todo *todo = selectedTodo(); |
2687 | if ( todo ) newSubTodo( todo ); | 2686 | if ( todo ) newSubTodo( todo ); |
2688 | } | 2687 | } |
2689 | 2688 | ||
2690 | void CalendarView::newSubTodo(Todo *parentEvent) | 2689 | void CalendarView::newSubTodo(Todo *parentEvent) |
2691 | { | 2690 | { |
2692 | 2691 | ||
2693 | showTodoEditor(); | 2692 | showTodoEditor(); |
2694 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2693 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2695 | } | 2694 | } |
2696 | 2695 | ||
2697 | void CalendarView::newFloatingEvent() | 2696 | void CalendarView::newFloatingEvent() |
2698 | { | 2697 | { |
2699 | DateList tmpList = mNavigator->selectedDates(); | 2698 | DateList tmpList = mNavigator->selectedDates(); |
2700 | QDate date = tmpList.first(); | 2699 | QDate date = tmpList.first(); |
2701 | 2700 | ||
2702 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2701 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |