-rw-r--r-- | korganizer/calendarview.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 7ddbe23..363dc32 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3847 +1,3847 @@ | |||
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 | int w = 300; | 999 | int w = 300; |
1000 | if ( QApplication::desktop()->width() < 320 ) | 1000 | if ( QApplication::desktop()->width() < 320 ) |
1001 | w = 220; | 1001 | w = 220; |
1002 | int h = bar.sizeHint().height() ; | 1002 | int h = bar.sizeHint().height() ; |
1003 | int dw = QApplication::desktop()->width(); | 1003 | int dw = QApplication::desktop()->width(); |
1004 | int dh = QApplication::desktop()->height(); | 1004 | int dh = QApplication::desktop()->height(); |
1005 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1005 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1006 | bar.show(); | 1006 | bar.show(); |
1007 | int modulo = (er.count()/10)+1; | 1007 | int modulo = (er.count()/10)+1; |
1008 | int incCounter = 0; | 1008 | int incCounter = 0; |
1009 | while ( inR ) { | 1009 | while ( inR ) { |
1010 | if ( ! bar.isVisible() ) | 1010 | if ( ! bar.isVisible() ) |
1011 | return false; | 1011 | return false; |
1012 | if ( incCounter % modulo == 0 ) | 1012 | if ( incCounter % modulo == 0 ) |
1013 | bar.setProgress( incCounter ); | 1013 | bar.setProgress( incCounter ); |
1014 | ++incCounter; | 1014 | ++incCounter; |
1015 | uid = inR->uid(); | 1015 | uid = inR->uid(); |
1016 | bool skipIncidence = false; | 1016 | bool skipIncidence = false; |
1017 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1017 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1018 | skipIncidence = true; | 1018 | skipIncidence = true; |
1019 | QString idS; | 1019 | QString idS; |
1020 | qApp->processEvents(); | 1020 | qApp->processEvents(); |
1021 | if ( !skipIncidence ) { | 1021 | if ( !skipIncidence ) { |
1022 | inL = local->incidence( uid ); | 1022 | inL = local->incidence( uid ); |
1023 | if ( inL ) { // maybe conflict - same uid in both calendars | 1023 | if ( inL ) { // maybe conflict - same uid in both calendars |
1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1024 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1025 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1026 | if ( take == 3 ) | 1026 | if ( take == 3 ) |
1027 | return false; | 1027 | return false; |
1028 | if ( take == 1 ) {// take local ********************** | 1028 | if ( take == 1 ) {// take local ********************** |
1029 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1029 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1030 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1030 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1031 | else | 1031 | else |
1032 | idS = inR->IDStr(); | 1032 | idS = inR->IDStr(); |
1033 | remote->deleteIncidence( inR ); | 1033 | remote->deleteIncidence( inR ); |
1034 | inR = inL->clone(); | 1034 | inR = inL->clone(); |
1035 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1035 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1036 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1036 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1037 | inR->setIDStr( idS ); | 1037 | inR->setIDStr( idS ); |
1038 | remote->addIncidence( inR ); | 1038 | remote->addIncidence( inR ); |
1039 | if ( mSyncManager->syncWithDesktop() ) | 1039 | if ( mSyncManager->syncWithDesktop() ) |
1040 | inR->setPilotId( 2 ); | 1040 | inR->setPilotId( 2 ); |
1041 | ++changedRemote; | 1041 | ++changedRemote; |
1042 | } else {// take remote ********************** | 1042 | } else {// take remote ********************** |
1043 | idS = inL->IDStr(); | 1043 | idS = inL->IDStr(); |
1044 | int pid = inL->pilotId(); | 1044 | int pid = inL->pilotId(); |
1045 | local->deleteIncidence( inL ); | 1045 | local->deleteIncidence( inL ); |
1046 | inL = inR->clone(); | 1046 | inL = inR->clone(); |
1047 | if ( mSyncManager->syncWithDesktop() ) | 1047 | if ( mSyncManager->syncWithDesktop() ) |
1048 | inL->setPilotId( pid ); | 1048 | inL->setPilotId( pid ); |
1049 | inL->setIDStr( idS ); | 1049 | inL->setIDStr( idS ); |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1051 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1052 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1052 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1053 | } | 1053 | } |
1054 | local->addIncidence( inL ); | 1054 | local->addIncidence( inL ); |
1055 | ++changedLocal; | 1055 | ++changedLocal; |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | } else { // no conflict ********** add or delete remote | 1058 | } else { // no conflict ********** add or delete remote |
1059 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1059 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1060 | QString des = eventLSync->description(); | 1060 | QString des = eventLSync->description(); |
1061 | QString pref = "e"; | 1061 | QString pref = "e"; |
1062 | if ( inR->type() == "Todo" ) | 1062 | if ( inR->type() == "Todo" ) |
1063 | pref = "t"; | 1063 | pref = "t"; |
1064 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1064 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1065 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1065 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1066 | //remote->deleteIncidence( inR ); | 1066 | //remote->deleteIncidence( inR ); |
1067 | ++deletedEventR; | 1067 | ++deletedEventR; |
1068 | } else { | 1068 | } else { |
1069 | inR->setLastModified( modifiedCalendar ); | 1069 | inR->setLastModified( modifiedCalendar ); |
1070 | inL = inR->clone(); | 1070 | inL = inR->clone(); |
1071 | inL->setIDStr( ":" ); | 1071 | inL->setIDStr( ":" ); |
1072 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1072 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1073 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1073 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1074 | local->addIncidence( inL ); | 1074 | local->addIncidence( inL ); |
1075 | ++addedEvent; | 1075 | ++addedEvent; |
1076 | } | 1076 | } |
1077 | } else { | 1077 | } else { |
1078 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1078 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1079 | inR->setLastModified( modifiedCalendar ); | 1079 | inR->setLastModified( modifiedCalendar ); |
1080 | inL = inR->clone(); | 1080 | inL = inR->clone(); |
1081 | inL->setIDStr( ":" ); | 1081 | inL->setIDStr( ":" ); |
1082 | local->addIncidence( inL ); | 1082 | local->addIncidence( inL ); |
1083 | ++addedEvent; | 1083 | ++addedEvent; |
1084 | } else { | 1084 | } else { |
1085 | checkExternSyncEvent(eventRSyncSharp, inR); | 1085 | checkExternSyncEvent(eventRSyncSharp, inR); |
1086 | remote->deleteIncidence( inR ); | 1086 | remote->deleteIncidence( inR ); |
1087 | ++deletedEventR; | 1087 | ++deletedEventR; |
1088 | } | 1088 | } |
1089 | } | 1089 | } |
1090 | } | 1090 | } |
1091 | } | 1091 | } |
1092 | inR = er.next(); | 1092 | inR = er.next(); |
1093 | } | 1093 | } |
1094 | QPtrList<Incidence> el = local->rawIncidences(); | 1094 | QPtrList<Incidence> el = local->rawIncidences(); |
1095 | inL = el.first(); | 1095 | inL = el.first(); |
1096 | modulo = (el.count()/10)+1; | 1096 | modulo = (el.count()/10)+1; |
1097 | bar.setCaption (i18n("Add / remove events") ); | 1097 | bar.setCaption (i18n("Add / remove events") ); |
1098 | bar.setTotalSteps ( el.count() ) ; | 1098 | bar.setTotalSteps ( el.count() ) ; |
1099 | bar.show(); | 1099 | bar.show(); |
1100 | incCounter = 0; | 1100 | incCounter = 0; |
1101 | 1101 | ||
1102 | while ( inL ) { | 1102 | while ( inL ) { |
1103 | 1103 | ||
1104 | qApp->processEvents(); | 1104 | qApp->processEvents(); |
1105 | if ( ! bar.isVisible() ) | 1105 | if ( ! bar.isVisible() ) |
1106 | return false; | 1106 | return false; |
1107 | if ( incCounter % modulo == 0 ) | 1107 | if ( incCounter % modulo == 0 ) |
1108 | bar.setProgress( incCounter ); | 1108 | bar.setProgress( incCounter ); |
1109 | ++incCounter; | 1109 | ++incCounter; |
1110 | uid = inL->uid(); | 1110 | uid = inL->uid(); |
1111 | bool skipIncidence = false; | 1111 | bool skipIncidence = false; |
1112 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1112 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1113 | skipIncidence = true; | 1113 | skipIncidence = true; |
1114 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1114 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1115 | skipIncidence = true; | 1115 | skipIncidence = true; |
1116 | if ( !skipIncidence ) { | 1116 | if ( !skipIncidence ) { |
1117 | inR = remote->incidence( uid ); | 1117 | inR = remote->incidence( uid ); |
1118 | if ( ! inR ) { // no conflict ********** add or delete local | 1118 | if ( ! inR ) { // no conflict ********** add or delete local |
1119 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1119 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1120 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1120 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1121 | checkExternSyncEvent(eventLSyncSharp, inL); | 1121 | checkExternSyncEvent(eventLSyncSharp, inL); |
1122 | local->deleteIncidence( inL ); | 1122 | local->deleteIncidence( inL ); |
1123 | ++deletedEventL; | 1123 | ++deletedEventL; |
1124 | } else { | 1124 | } else { |
1125 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1125 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1126 | inL->removeID(mCurrentSyncDevice ); | 1126 | inL->removeID(mCurrentSyncDevice ); |
1127 | ++addedEventR; | 1127 | ++addedEventR; |
1128 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1128 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1129 | inL->setLastModified( modifiedCalendar ); | 1129 | inL->setLastModified( modifiedCalendar ); |
1130 | inR = inL->clone(); | 1130 | inR = inL->clone(); |
1131 | inR->setIDStr( ":" ); | 1131 | inR->setIDStr( ":" ); |
1132 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1132 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1133 | remote->addIncidence( inR ); | 1133 | remote->addIncidence( inR ); |
1134 | } | 1134 | } |
1135 | } | 1135 | } |
1136 | } else { | 1136 | } else { |
1137 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1137 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1138 | checkExternSyncEvent(eventLSyncSharp, inL); | 1138 | checkExternSyncEvent(eventLSyncSharp, inL); |
1139 | local->deleteIncidence( inL ); | 1139 | local->deleteIncidence( inL ); |
1140 | ++deletedEventL; | 1140 | ++deletedEventL; |
1141 | } else { | 1141 | } else { |
1142 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1142 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1143 | ++addedEventR; | 1143 | ++addedEventR; |
1144 | inL->setLastModified( modifiedCalendar ); | 1144 | inL->setLastModified( modifiedCalendar ); |
1145 | inR = inL->clone(); | 1145 | inR = inL->clone(); |
1146 | inR->setIDStr( ":" ); | 1146 | inR->setIDStr( ":" ); |
1147 | remote->addIncidence( inR ); | 1147 | remote->addIncidence( inR ); |
1148 | } | 1148 | } |
1149 | } | 1149 | } |
1150 | } | 1150 | } |
1151 | } | 1151 | } |
1152 | } | 1152 | } |
1153 | inL = el.next(); | 1153 | inL = el.next(); |
1154 | } | 1154 | } |
1155 | int delFut = 0; | 1155 | int delFut = 0; |
1156 | int remRem = 0; | 1156 | int remRem = 0; |
1157 | if ( mSyncManager->mWriteBackInFuture ) { | 1157 | if ( mSyncManager->mWriteBackInFuture ) { |
1158 | er = remote->rawIncidences(); | 1158 | er = remote->rawIncidences(); |
1159 | remRem = er.count(); | 1159 | remRem = er.count(); |
1160 | inR = er.first(); | 1160 | inR = er.first(); |
1161 | QDateTime dt; | 1161 | QDateTime dt; |
1162 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1162 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1163 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1163 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1164 | while ( inR ) { | 1164 | while ( inR ) { |
1165 | if ( inR->type() == "Todo" ) { | 1165 | if ( inR->type() == "Todo" ) { |
1166 | Todo * t = (Todo*)inR; | 1166 | Todo * t = (Todo*)inR; |
1167 | if ( t->hasDueDate() ) | 1167 | if ( t->hasDueDate() ) |
1168 | dt = t->dtDue(); | 1168 | dt = t->dtDue(); |
1169 | else | 1169 | else |
1170 | dt = cur.addSecs( 62 ); | 1170 | dt = cur.addSecs( 62 ); |
1171 | } | 1171 | } |
1172 | else if (inR->type() == "Event" ) { | 1172 | else if (inR->type() == "Event" ) { |
1173 | bool ok; | 1173 | bool ok; |
1174 | dt = inR->getNextOccurence( cur, &ok ); | 1174 | dt = inR->getNextOccurence( cur, &ok ); |
1175 | if ( !ok ) | 1175 | if ( !ok ) |
1176 | dt = cur.addSecs( -62 ); | 1176 | dt = cur.addSecs( -62 ); |
1177 | } | 1177 | } |
1178 | else | 1178 | else |
1179 | dt = inR->dtStart(); | 1179 | dt = inR->dtStart(); |
1180 | if ( dt < cur || dt > end ) { | 1180 | if ( dt < cur || dt > end ) { |
1181 | remote->deleteIncidence( inR ); | 1181 | remote->deleteIncidence( inR ); |
1182 | ++delFut; | 1182 | ++delFut; |
1183 | } | 1183 | } |
1184 | inR = er.next(); | 1184 | inR = er.next(); |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | bar.hide(); | 1187 | bar.hide(); |
1188 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1188 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1189 | eventLSync->setReadOnly( false ); | 1189 | eventLSync->setReadOnly( false ); |
1190 | eventLSync->setDtStart( mLastCalendarSync ); | 1190 | eventLSync->setDtStart( mLastCalendarSync ); |
1191 | eventRSync->setDtStart( mLastCalendarSync ); | 1191 | eventRSync->setDtStart( mLastCalendarSync ); |
1192 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1192 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1193 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1193 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1194 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1194 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1195 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1195 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1196 | eventLSync->setReadOnly( true ); | 1196 | eventLSync->setReadOnly( true ); |
1197 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); | 1197 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); |
1198 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1198 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1199 | remote->addEvent( eventRSync ); | 1199 | remote->addEvent( eventRSync ); |
1200 | else | 1200 | else |
1201 | delete eventRSync; | 1201 | delete eventRSync; |
1202 | QString mes; | 1202 | QString mes; |
1203 | 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 ); | 1203 | 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 ); |
1204 | QString delmess; | 1204 | QString delmess; |
1205 | if ( delFut ) { | 1205 | if ( delFut ) { |
1206 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1206 | 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); |
1207 | mes += delmess; | 1207 | mes += delmess; |
1208 | } | 1208 | } |
1209 | mes = i18n("Local calendar changed!\n") +mes; | 1209 | mes = i18n("Local calendar changed!\n") +mes; |
1210 | mCalendar->checkAlarmForIncidence( 0, true ); | 1210 | mCalendar->checkAlarmForIncidence( 0, true ); |
1211 | qDebug( mes ); | 1211 | qDebug( mes ); |
1212 | if ( mSyncManager->mShowSyncSummary ) { | 1212 | if ( mSyncManager->mShowSyncSummary ) { |
1213 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1213 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1214 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1214 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1215 | qDebug("cancelled "); | 1215 | qDebug("cancelled "); |
1216 | return false; | 1216 | return false; |
1217 | } | 1217 | } |
1218 | } | 1218 | } |
1219 | return syncOK; | 1219 | return syncOK; |
1220 | } | 1220 | } |
1221 | 1221 | ||
1222 | void CalendarView::setSyncDevice( QString s ) | 1222 | void CalendarView::setSyncDevice( QString s ) |
1223 | { | 1223 | { |
1224 | mCurrentSyncDevice= s; | 1224 | mCurrentSyncDevice= s; |
1225 | } | 1225 | } |
1226 | void CalendarView::setSyncName( QString s ) | 1226 | void CalendarView::setSyncName( QString s ) |
1227 | { | 1227 | { |
1228 | mCurrentSyncName= s; | 1228 | mCurrentSyncName= s; |
1229 | } | 1229 | } |
1230 | bool CalendarView::syncCalendar(QString filename, int mode) | 1230 | bool CalendarView::syncCalendar(QString filename, int mode) |
1231 | { | 1231 | { |
1232 | //qDebug("syncCalendar %s ", filename.latin1()); | 1232 | //qDebug("syncCalendar %s ", filename.latin1()); |
1233 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1233 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1234 | CalendarLocal* calendar = new CalendarLocal(); | 1234 | CalendarLocal* calendar = new CalendarLocal(); |
1235 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1235 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1236 | FileStorage* storage = new FileStorage( calendar ); | 1236 | FileStorage* storage = new FileStorage( calendar ); |
1237 | bool syncOK = false; | 1237 | bool syncOK = false; |
1238 | storage->setFileName( filename ); | 1238 | storage->setFileName( filename ); |
1239 | // qDebug("loading ... "); | 1239 | // qDebug("loading ... "); |
1240 | if ( storage->load() ) { | 1240 | if ( storage->load() ) { |
1241 | getEventViewerDialog()->setSyncMode( true ); | 1241 | getEventViewerDialog()->setSyncMode( true ); |
1242 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1242 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1243 | getEventViewerDialog()->setSyncMode( false ); | 1243 | getEventViewerDialog()->setSyncMode( false ); |
1244 | if ( syncOK ) { | 1244 | if ( syncOK ) { |
1245 | if ( mSyncManager->mWriteBackFile ) | 1245 | if ( mSyncManager->mWriteBackFile ) |
1246 | { | 1246 | { |
1247 | storage->setSaveFormat( new ICalFormat() ); | 1247 | storage->setSaveFormat( new ICalFormat() ); |
1248 | storage->save(); | 1248 | storage->save(); |
1249 | } | 1249 | } |
1250 | } | 1250 | } |
1251 | setModified( true ); | 1251 | setModified( true ); |
1252 | } | 1252 | } |
1253 | delete storage; | 1253 | delete storage; |
1254 | delete calendar; | 1254 | delete calendar; |
1255 | if ( syncOK ) | 1255 | if ( syncOK ) |
1256 | updateView(); | 1256 | updateView(); |
1257 | return syncOK; | 1257 | return syncOK; |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | void CalendarView::syncExternal( int mode ) | 1260 | void CalendarView::syncExternal( int mode ) |
1261 | { | 1261 | { |
1262 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1262 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1263 | 1263 | ||
1264 | qApp->processEvents(); | 1264 | qApp->processEvents(); |
1265 | CalendarLocal* calendar = new CalendarLocal(); | 1265 | CalendarLocal* calendar = new CalendarLocal(); |
1266 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1266 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1267 | bool syncOK = false; | 1267 | bool syncOK = false; |
1268 | bool loadSuccess = false; | 1268 | bool loadSuccess = false; |
1269 | PhoneFormat* phoneFormat = 0; | 1269 | PhoneFormat* phoneFormat = 0; |
1270 | emit tempDisableBR(true); | 1270 | emit tempDisableBR(true); |
1271 | #ifndef DESKTOP_VERSION | 1271 | #ifndef DESKTOP_VERSION |
1272 | SharpFormat* sharpFormat = 0; | 1272 | SharpFormat* sharpFormat = 0; |
1273 | if ( mode == 0 ) { // sharp | 1273 | if ( mode == 0 ) { // sharp |
1274 | sharpFormat = new SharpFormat () ; | 1274 | sharpFormat = new SharpFormat () ; |
1275 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1275 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1276 | 1276 | ||
1277 | } else | 1277 | } else |
1278 | #endif | 1278 | #endif |
1279 | if ( mode == 1 ) { // phone | 1279 | if ( mode == 1 ) { // phone |
1280 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1280 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1281 | mSyncManager->mPhoneDevice, | 1281 | mSyncManager->mPhoneDevice, |
1282 | mSyncManager->mPhoneConnection, | 1282 | mSyncManager->mPhoneConnection, |
1283 | mSyncManager->mPhoneModel); | 1283 | mSyncManager->mPhoneModel); |
1284 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1284 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1285 | 1285 | ||
1286 | } else { | 1286 | } else { |
1287 | emit tempDisableBR(false); | 1287 | emit tempDisableBR(false); |
1288 | return; | 1288 | return; |
1289 | } | 1289 | } |
1290 | if ( loadSuccess ) { | 1290 | if ( loadSuccess ) { |
1291 | getEventViewerDialog()->setSyncMode( true ); | 1291 | getEventViewerDialog()->setSyncMode( true ); |
1292 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1292 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1293 | getEventViewerDialog()->setSyncMode( false ); | 1293 | getEventViewerDialog()->setSyncMode( false ); |
1294 | qApp->processEvents(); | 1294 | qApp->processEvents(); |
1295 | if ( syncOK ) { | 1295 | if ( syncOK ) { |
1296 | if ( mSyncManager->mWriteBackFile ) | 1296 | if ( mSyncManager->mWriteBackFile ) |
1297 | { | 1297 | { |
1298 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1298 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1299 | Incidence* inc = iL.first(); | 1299 | Incidence* inc = iL.first(); |
1300 | if ( phoneFormat ) { | 1300 | if ( phoneFormat ) { |
1301 | while ( inc ) { | 1301 | while ( inc ) { |
1302 | inc->removeID(mCurrentSyncDevice); | 1302 | inc->removeID(mCurrentSyncDevice); |
1303 | inc = iL.next(); | 1303 | inc = iL.next(); |
1304 | } | 1304 | } |
1305 | } | 1305 | } |
1306 | #ifndef DESKTOP_VERSION | 1306 | #ifndef DESKTOP_VERSION |
1307 | if ( sharpFormat ) | 1307 | if ( sharpFormat ) |
1308 | sharpFormat->save(calendar); | 1308 | sharpFormat->save(calendar); |
1309 | #endif | 1309 | #endif |
1310 | if ( phoneFormat ) | 1310 | if ( phoneFormat ) |
1311 | phoneFormat->save(calendar); | 1311 | phoneFormat->save(calendar); |
1312 | iL = calendar->rawIncidences(); | 1312 | iL = calendar->rawIncidences(); |
1313 | inc = iL.first(); | 1313 | inc = iL.first(); |
1314 | Incidence* loc; | 1314 | Incidence* loc; |
1315 | while ( inc ) { | 1315 | while ( inc ) { |
1316 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1316 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1317 | loc = mCalendar->incidence(inc->uid() ); | 1317 | loc = mCalendar->incidence(inc->uid() ); |
1318 | if ( loc ) { | 1318 | if ( loc ) { |
1319 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1319 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1320 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1320 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1321 | } | 1321 | } |
1322 | } | 1322 | } |
1323 | inc = iL.next(); | 1323 | inc = iL.next(); |
1324 | } | 1324 | } |
1325 | Incidence* lse = getLastSyncEvent(); | 1325 | Incidence* lse = getLastSyncEvent(); |
1326 | if ( lse ) { | 1326 | if ( lse ) { |
1327 | lse->setReadOnly( false ); | 1327 | lse->setReadOnly( false ); |
1328 | lse->setDescription( "" ); | 1328 | lse->setDescription( "" ); |
1329 | lse->setReadOnly( true ); | 1329 | lse->setReadOnly( true ); |
1330 | } | 1330 | } |
1331 | } | 1331 | } |
1332 | } else { | 1332 | } else { |
1333 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1333 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1334 | } | 1334 | } |
1335 | setModified( true ); | 1335 | setModified( true ); |
1336 | } else { | 1336 | } else { |
1337 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1337 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1338 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1338 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1339 | question, i18n("Ok")) ; | 1339 | question, i18n("Ok")) ; |
1340 | 1340 | ||
1341 | } | 1341 | } |
1342 | delete calendar; | 1342 | delete calendar; |
1343 | updateView(); | 1343 | updateView(); |
1344 | emit tempDisableBR(false); | 1344 | emit tempDisableBR(false); |
1345 | return ;//syncOK; | 1345 | return ;//syncOK; |
1346 | 1346 | ||
1347 | } | 1347 | } |
1348 | 1348 | ||
1349 | bool CalendarView::importBday() | 1349 | bool CalendarView::importBday() |
1350 | { | 1350 | { |
1351 | #ifndef KORG_NOKABC | 1351 | #ifndef KORG_NOKABC |
1352 | 1352 | ||
1353 | #ifdef DESKTOP_VERSION | 1353 | #ifdef DESKTOP_VERSION |
1354 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1354 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1355 | KABC::AddressBook::Iterator it; | 1355 | KABC::AddressBook::Iterator it; |
1356 | int count = 0; | 1356 | int count = 0; |
1357 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1357 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1358 | ++count; | 1358 | ++count; |
1359 | } | 1359 | } |
1360 | QProgressBar bar(count,0 ); | 1360 | QProgressBar bar(count,0 ); |
1361 | int w = 300; | 1361 | int w = 300; |
1362 | if ( QApplication::desktop()->width() < 320 ) | 1362 | if ( QApplication::desktop()->width() < 320 ) |
1363 | w = 220; | 1363 | w = 220; |
1364 | int h = bar.sizeHint().height() ; | 1364 | int h = bar.sizeHint().height() ; |
1365 | int dw = QApplication::desktop()->width(); | 1365 | int dw = QApplication::desktop()->width(); |
1366 | int dh = QApplication::desktop()->height(); | 1366 | int dh = QApplication::desktop()->height(); |
1367 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1367 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1368 | bar.show(); | 1368 | bar.show(); |
1369 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1369 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1370 | qApp->processEvents(); | 1370 | qApp->processEvents(); |
1371 | count = 0; | 1371 | count = 0; |
1372 | int addCount = 0; | 1372 | int addCount = 0; |
1373 | KCal::Attendee* a = 0; | 1373 | KCal::Attendee* a = 0; |
1374 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1374 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1375 | if ( ! bar.isVisible() ) | 1375 | if ( ! bar.isVisible() ) |
1376 | return false; | 1376 | return false; |
1377 | bar.setProgress( count++ ); | 1377 | bar.setProgress( count++ ); |
1378 | qApp->processEvents(); | 1378 | qApp->processEvents(); |
1379 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1379 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1380 | if ( (*it).birthday().date().isValid() ){ | 1380 | if ( (*it).birthday().date().isValid() ){ |
1381 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1381 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1382 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1382 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1383 | ++addCount; | 1383 | ++addCount; |
1384 | } | 1384 | } |
1385 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1385 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1386 | if ( anni.isValid() ){ | 1386 | if ( anni.isValid() ){ |
1387 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1387 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1388 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1388 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1389 | ++addCount; | 1389 | ++addCount; |
1390 | } | 1390 | } |
1391 | } | 1391 | } |
1392 | updateView(); | 1392 | updateView(); |
1393 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1393 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1394 | #else //DESKTOP_VERSION | 1394 | #else //DESKTOP_VERSION |
1395 | 1395 | ||
1396 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1396 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1397 | // the result should now arrive through method insertBirthdays | 1397 | // the result should now arrive through method insertBirthdays |
1398 | 1398 | ||
1399 | #endif //DESKTOP_VERSION | 1399 | #endif //DESKTOP_VERSION |
1400 | 1400 | ||
1401 | #endif //KORG_NOKABC | 1401 | #endif //KORG_NOKABC |
1402 | 1402 | ||
1403 | 1403 | ||
1404 | return true; | 1404 | return true; |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1407 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1408 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1408 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1409 | const QStringList& anniversaryList, const QStringList& realNameList, | 1409 | const QStringList& anniversaryList, const QStringList& realNameList, |
1410 | const QStringList& emailList, const QStringList& assembledNameList, | 1410 | const QStringList& emailList, const QStringList& assembledNameList, |
1411 | const QStringList& uidList) | 1411 | const QStringList& uidList) |
1412 | { | 1412 | { |
1413 | qDebug("CalendarView::insertBirthdays"); | 1413 | qDebug("CalendarView::insertBirthdays"); |
1414 | if (uid == this->name()) | 1414 | if (uid == this->name()) |
1415 | { | 1415 | { |
1416 | int count = birthdayList.count(); | 1416 | int count = birthdayList.count(); |
1417 | int addCount = 0; | 1417 | int addCount = 0; |
1418 | KCal::Attendee* a = 0; | 1418 | KCal::Attendee* a = 0; |
1419 | 1419 | ||
1420 | qDebug("CalView 1 %i", count); | 1420 | qDebug("CalView 1 %i", count); |
1421 | 1421 | ||
1422 | QProgressBar bar(count,0 ); | 1422 | QProgressBar bar(count,0 ); |
1423 | int w = 300; | 1423 | int w = 300; |
1424 | if ( QApplication::desktop()->width() < 320 ) | 1424 | if ( QApplication::desktop()->width() < 320 ) |
1425 | w = 220; | 1425 | w = 220; |
1426 | int h = bar.sizeHint().height() ; | 1426 | int h = bar.sizeHint().height() ; |
1427 | int dw = QApplication::desktop()->width(); | 1427 | int dw = QApplication::desktop()->width(); |
1428 | int dh = QApplication::desktop()->height(); | 1428 | int dh = QApplication::desktop()->height(); |
1429 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1429 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1430 | bar.show(); | 1430 | bar.show(); |
1431 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1431 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1432 | qApp->processEvents(); | 1432 | qApp->processEvents(); |
1433 | 1433 | ||
1434 | QDate birthday; | 1434 | QDate birthday; |
1435 | QDate anniversary; | 1435 | QDate anniversary; |
1436 | QString realName; | 1436 | QString realName; |
1437 | QString email; | 1437 | QString email; |
1438 | QString assembledName; | 1438 | QString assembledName; |
1439 | QString uid; | 1439 | QString uid; |
1440 | bool ok = true; | 1440 | bool ok = true; |
1441 | for ( int i = 0; i < count; i++) | 1441 | for ( int i = 0; i < count; i++) |
1442 | { | 1442 | { |
1443 | if ( ! bar.isVisible() ) | 1443 | if ( ! bar.isVisible() ) |
1444 | return; | 1444 | return; |
1445 | bar.setProgress( i ); | 1445 | bar.setProgress( i ); |
1446 | qApp->processEvents(); | 1446 | qApp->processEvents(); |
1447 | 1447 | ||
1448 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1448 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1449 | if (!ok) { | 1449 | if (!ok) { |
1450 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1450 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1451 | } | 1451 | } |
1452 | 1452 | ||
1453 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1453 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1454 | if (!ok) { | 1454 | if (!ok) { |
1455 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1455 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1456 | } | 1456 | } |
1457 | realName = realNameList[i]; | 1457 | realName = realNameList[i]; |
1458 | email = emailList[i]; | 1458 | email = emailList[i]; |
1459 | assembledName = assembledNameList[i]; | 1459 | assembledName = assembledNameList[i]; |
1460 | uid = uidList[i]; | 1460 | uid = uidList[i]; |
1461 | //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() ); | 1461 | //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() ); |
1462 | 1462 | ||
1463 | if ( birthday.isValid() ){ | 1463 | if ( birthday.isValid() ){ |
1464 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1464 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1465 | KCal::Attendee::ReqParticipant,uid) ; | 1465 | KCal::Attendee::ReqParticipant,uid) ; |
1466 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1466 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1467 | ++addCount; | 1467 | ++addCount; |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | if ( anniversary.isValid() ){ | 1470 | if ( anniversary.isValid() ){ |
1471 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1471 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1472 | KCal::Attendee::ReqParticipant,uid) ; | 1472 | KCal::Attendee::ReqParticipant,uid) ; |
1473 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1473 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1474 | ++addCount; | 1474 | ++addCount; |
1475 | } | 1475 | } |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | updateView(); | 1478 | updateView(); |
1479 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1479 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1480 | 1480 | ||
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | 1485 | ||
1486 | 1486 | ||
1487 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1487 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1488 | { | 1488 | { |
1489 | //qDebug("addAnni "); | 1489 | //qDebug("addAnni "); |
1490 | Event * ev = new Event(); | 1490 | Event * ev = new Event(); |
1491 | if ( a ) { | 1491 | if ( a ) { |
1492 | ev->addAttendee( a ); | 1492 | ev->addAttendee( a ); |
1493 | } | 1493 | } |
1494 | QString kind; | 1494 | QString kind; |
1495 | if ( birthday ) | 1495 | if ( birthday ) |
1496 | kind = i18n( "Birthday" ); | 1496 | kind = i18n( "Birthday" ); |
1497 | else | 1497 | else |
1498 | kind = i18n( "Anniversary" ); | 1498 | kind = i18n( "Anniversary" ); |
1499 | ev->setSummary( name + " - " + kind ); | 1499 | ev->setSummary( name + " - " + kind ); |
1500 | ev->setOrganizer(a->email()); | 1500 | ev->setOrganizer(a->email()); |
1501 | ev->setCategories( kind ); | 1501 | ev->setCategories( kind ); |
1502 | ev->setDtStart( QDateTime(date) ); | 1502 | ev->setDtStart( QDateTime(date) ); |
1503 | ev->setDtEnd( QDateTime(date) ); | 1503 | ev->setDtEnd( QDateTime(date) ); |
1504 | ev->setFloats( true ); | 1504 | ev->setFloats( true ); |
1505 | Recurrence * rec = ev->recurrence(); | 1505 | Recurrence * rec = ev->recurrence(); |
1506 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1506 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1507 | rec->addYearlyNum( date.month() ); | 1507 | rec->addYearlyNum( date.month() ); |
1508 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1508 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1509 | delete ev; | 1509 | delete ev; |
1510 | return false; | 1510 | return false; |
1511 | } | 1511 | } |
1512 | return true; | 1512 | return true; |
1513 | 1513 | ||
1514 | } | 1514 | } |
1515 | bool CalendarView::importQtopia( const QString &categories, | 1515 | bool CalendarView::importQtopia( const QString &categories, |
1516 | const QString &datebook, | 1516 | const QString &datebook, |
1517 | const QString &todolist ) | 1517 | const QString &todolist ) |
1518 | { | 1518 | { |
1519 | 1519 | ||
1520 | QtopiaFormat qtopiaFormat; | 1520 | QtopiaFormat qtopiaFormat; |
1521 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1521 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1522 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1522 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1523 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1523 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1524 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1524 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1525 | 1525 | ||
1526 | updateView(); | 1526 | updateView(); |
1527 | return true; | 1527 | return true; |
1528 | 1528 | ||
1529 | #if 0 | 1529 | #if 0 |
1530 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1530 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1531 | mCurrentSyncDevice = "qtopia-XML"; | 1531 | mCurrentSyncDevice = "qtopia-XML"; |
1532 | if ( mSyncManager->mAskForPreferences ) | 1532 | if ( mSyncManager->mAskForPreferences ) |
1533 | edit_sync_options(); | 1533 | edit_sync_options(); |
1534 | qApp->processEvents(); | 1534 | qApp->processEvents(); |
1535 | CalendarLocal* calendar = new CalendarLocal(); | 1535 | CalendarLocal* calendar = new CalendarLocal(); |
1536 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1536 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1537 | bool syncOK = false; | 1537 | bool syncOK = false; |
1538 | QtopiaFormat qtopiaFormat; | 1538 | QtopiaFormat qtopiaFormat; |
1539 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1539 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1540 | bool loadOk = true; | 1540 | bool loadOk = true; |
1541 | if ( !categories.isEmpty() ) | 1541 | if ( !categories.isEmpty() ) |
1542 | loadOk = qtopiaFormat.load( calendar, categories ); | 1542 | loadOk = qtopiaFormat.load( calendar, categories ); |
1543 | if ( loadOk && !datebook.isEmpty() ) | 1543 | if ( loadOk && !datebook.isEmpty() ) |
1544 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1544 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1545 | if ( loadOk && !todolist.isEmpty() ) | 1545 | if ( loadOk && !todolist.isEmpty() ) |
1546 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1546 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1547 | 1547 | ||
1548 | if ( loadOk ) { | 1548 | if ( loadOk ) { |
1549 | getEventViewerDialog()->setSyncMode( true ); | 1549 | getEventViewerDialog()->setSyncMode( true ); |
1550 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1550 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1551 | getEventViewerDialog()->setSyncMode( false ); | 1551 | getEventViewerDialog()->setSyncMode( false ); |
1552 | qApp->processEvents(); | 1552 | qApp->processEvents(); |
1553 | if ( syncOK ) { | 1553 | if ( syncOK ) { |
1554 | if ( mSyncManager->mWriteBackFile ) | 1554 | if ( mSyncManager->mWriteBackFile ) |
1555 | { | 1555 | { |
1556 | // write back XML file | 1556 | // write back XML file |
1557 | 1557 | ||
1558 | } | 1558 | } |
1559 | setModified( true ); | 1559 | setModified( true ); |
1560 | } | 1560 | } |
1561 | } else { | 1561 | } else { |
1562 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1562 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1563 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1563 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1564 | question, i18n("Ok")) ; | 1564 | question, i18n("Ok")) ; |
1565 | } | 1565 | } |
1566 | delete calendar; | 1566 | delete calendar; |
1567 | updateView(); | 1567 | updateView(); |
1568 | return syncOK; | 1568 | return syncOK; |
1569 | 1569 | ||
1570 | 1570 | ||
1571 | #endif | 1571 | #endif |
1572 | 1572 | ||
1573 | } | 1573 | } |
1574 | 1574 | ||
1575 | void CalendarView::setSyncEventsReadOnly() | 1575 | void CalendarView::setSyncEventsReadOnly() |
1576 | { | 1576 | { |
1577 | Event * ev; | 1577 | Event * ev; |
1578 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1578 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1579 | ev = eL.first(); | 1579 | ev = eL.first(); |
1580 | while ( ev ) { | 1580 | while ( ev ) { |
1581 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1581 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1582 | ev->setReadOnly( true ); | 1582 | ev->setReadOnly( true ); |
1583 | ev = eL.next(); | 1583 | ev = eL.next(); |
1584 | } | 1584 | } |
1585 | } | 1585 | } |
1586 | bool CalendarView::openCalendar(QString filename, bool merge) | 1586 | bool CalendarView::openCalendar(QString filename, bool merge) |
1587 | { | 1587 | { |
1588 | 1588 | ||
1589 | if (filename.isEmpty()) { | 1589 | if (filename.isEmpty()) { |
1590 | return false; | 1590 | return false; |
1591 | } | 1591 | } |
1592 | 1592 | ||
1593 | if (!QFile::exists(filename)) { | 1593 | if (!QFile::exists(filename)) { |
1594 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1594 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1595 | return false; | 1595 | return false; |
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | globalFlagBlockAgenda = 1; | 1598 | globalFlagBlockAgenda = 1; |
1599 | if (!merge) mCalendar->close(); | 1599 | if (!merge) mCalendar->close(); |
1600 | 1600 | ||
1601 | mStorage->setFileName( filename ); | 1601 | mStorage->setFileName( filename ); |
1602 | 1602 | ||
1603 | if ( mStorage->load() ) { | 1603 | if ( mStorage->load() ) { |
1604 | if ( merge ) ;//setModified( true ); | 1604 | if ( merge ) ;//setModified( true ); |
1605 | else { | 1605 | else { |
1606 | //setModified( true ); | 1606 | //setModified( true ); |
1607 | mViewManager->setDocumentId( filename ); | 1607 | mViewManager->setDocumentId( filename ); |
1608 | mDialogManager->setDocumentId( filename ); | 1608 | mDialogManager->setDocumentId( filename ); |
1609 | mTodoList->setDocumentId( filename ); | 1609 | mTodoList->setDocumentId( filename ); |
1610 | } | 1610 | } |
1611 | globalFlagBlockAgenda = 2; | 1611 | globalFlagBlockAgenda = 2; |
1612 | // if ( getLastSyncEvent() ) | 1612 | // if ( getLastSyncEvent() ) |
1613 | // getLastSyncEvent()->setReadOnly( true ); | 1613 | // getLastSyncEvent()->setReadOnly( true ); |
1614 | mCalendar->reInitAlarmSettings(); | 1614 | mCalendar->reInitAlarmSettings(); |
1615 | setSyncEventsReadOnly(); | 1615 | setSyncEventsReadOnly(); |
1616 | updateUnmanagedViews(); | 1616 | updateUnmanagedViews(); |
1617 | updateView(); | 1617 | updateView(); |
1618 | if ( filename != MainWindow::defaultFileName() ) { | 1618 | if ( filename != MainWindow::defaultFileName() ) { |
1619 | saveCalendar( MainWindow::defaultFileName() ); | 1619 | saveCalendar( MainWindow::defaultFileName() ); |
1620 | } else { | 1620 | } else { |
1621 | QFileInfo finf ( MainWindow::defaultFileName()); | 1621 | QFileInfo finf ( MainWindow::defaultFileName()); |
1622 | if ( finf.exists() ) { | 1622 | if ( finf.exists() ) { |
1623 | setLoadedFileVersion( finf.lastModified () ); | 1623 | setLoadedFileVersion( finf.lastModified () ); |
1624 | } | 1624 | } |
1625 | } | 1625 | } |
1626 | return true; | 1626 | return true; |
1627 | } else { | 1627 | } else { |
1628 | // while failing to load, the calendar object could | 1628 | // while failing to load, the calendar object could |
1629 | // have become partially populated. Clear it out. | 1629 | // have become partially populated. Clear it out. |
1630 | if ( !merge ) { | 1630 | if ( !merge ) { |
1631 | mCalendar->close(); | 1631 | mCalendar->close(); |
1632 | mViewManager->setDocumentId( filename ); | 1632 | mViewManager->setDocumentId( filename ); |
1633 | mDialogManager->setDocumentId( filename ); | 1633 | mDialogManager->setDocumentId( filename ); |
1634 | mTodoList->setDocumentId( filename ); | 1634 | mTodoList->setDocumentId( filename ); |
1635 | } | 1635 | } |
1636 | 1636 | ||
1637 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1637 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1638 | 1638 | ||
1639 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1639 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1640 | globalFlagBlockAgenda = 2; | 1640 | globalFlagBlockAgenda = 2; |
1641 | mCalendar->reInitAlarmSettings(); | 1641 | mCalendar->reInitAlarmSettings(); |
1642 | setSyncEventsReadOnly(); | 1642 | setSyncEventsReadOnly(); |
1643 | updateUnmanagedViews(); | 1643 | updateUnmanagedViews(); |
1644 | updateView(); | 1644 | updateView(); |
1645 | } | 1645 | } |
1646 | return false; | 1646 | return false; |
1647 | } | 1647 | } |
1648 | void CalendarView::showOpenError() | 1648 | void CalendarView::showOpenError() |
1649 | { | 1649 | { |
1650 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1650 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1651 | } | 1651 | } |
1652 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1652 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1653 | { | 1653 | { |
1654 | loadedFileVersion = dt; | 1654 | loadedFileVersion = dt; |
1655 | } | 1655 | } |
1656 | bool CalendarView::checkFileChanged(QString fn) | 1656 | bool CalendarView::checkFileChanged(QString fn) |
1657 | { | 1657 | { |
1658 | QFileInfo finf ( fn ); | 1658 | QFileInfo finf ( fn ); |
1659 | if ( !finf.exists() ) | 1659 | if ( !finf.exists() ) |
1660 | return true; | 1660 | return true; |
1661 | QDateTime dt = finf.lastModified (); | 1661 | QDateTime dt = finf.lastModified (); |
1662 | if ( dt <= loadedFileVersion ) | 1662 | if ( dt <= loadedFileVersion ) |
1663 | return false; | 1663 | return false; |
1664 | return true; | 1664 | return true; |
1665 | 1665 | ||
1666 | } | 1666 | } |
1667 | void CalendarView::watchSavedFile() | 1667 | void CalendarView::watchSavedFile() |
1668 | { | 1668 | { |
1669 | QFileInfo finf ( MainWindow::defaultFileName()); | 1669 | QFileInfo finf ( MainWindow::defaultFileName()); |
1670 | if ( !finf.exists() ) | 1670 | if ( !finf.exists() ) |
1671 | return; | 1671 | return; |
1672 | QDateTime dt = finf.lastModified (); | 1672 | QDateTime dt = finf.lastModified (); |
1673 | if ( dt < loadedFileVersion ) { | 1673 | if ( dt < loadedFileVersion ) { |
1674 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1674 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1675 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1675 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1676 | return; | 1676 | return; |
1677 | } | 1677 | } |
1678 | loadedFileVersion = dt; | 1678 | loadedFileVersion = dt; |
1679 | } | 1679 | } |
1680 | 1680 | ||
1681 | bool CalendarView::checkFileVersion(QString fn) | 1681 | bool CalendarView::checkFileVersion(QString fn) |
1682 | { | 1682 | { |
1683 | QFileInfo finf ( fn ); | 1683 | QFileInfo finf ( fn ); |
1684 | if ( !finf.exists() ) | 1684 | if ( !finf.exists() ) |
1685 | return true; | 1685 | return true; |
1686 | QDateTime dt = finf.lastModified (); | 1686 | QDateTime dt = finf.lastModified (); |
1687 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1687 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1688 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1688 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1689 | if ( dt <= loadedFileVersion ) | 1689 | if ( dt <= loadedFileVersion ) |
1690 | return true; | 1690 | return true; |
1691 | 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)) , | 1691 | 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)) , |
1692 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1692 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1693 | i18n("Sync+save")); | 1693 | i18n("Sync+save")); |
1694 | 1694 | ||
1695 | if ( km == KMessageBox::Cancel ) | 1695 | if ( km == KMessageBox::Cancel ) |
1696 | return false; | 1696 | return false; |
1697 | if ( km == KMessageBox::Yes ) | 1697 | if ( km == KMessageBox::Yes ) |
1698 | return true; | 1698 | return true; |
1699 | 1699 | ||
1700 | setSyncDevice("deleteaftersync" ); | 1700 | setSyncDevice("deleteaftersync" ); |
1701 | mSyncManager->mAskForPreferences = true; | 1701 | mSyncManager->mAskForPreferences = true; |
1702 | mSyncManager->mSyncAlgoPrefs = 3; | 1702 | mSyncManager->mSyncAlgoPrefs = 3; |
1703 | mSyncManager->mWriteBackFile = false; | 1703 | mSyncManager->mWriteBackFile = false; |
1704 | mSyncManager->mWriteBackExistingOnly = false; | 1704 | mSyncManager->mWriteBackExistingOnly = false; |
1705 | mSyncManager->mShowSyncSummary = false; | 1705 | mSyncManager->mShowSyncSummary = false; |
1706 | syncCalendar( fn, 3 ); | 1706 | syncCalendar( fn, 3 ); |
1707 | Event * e = getLastSyncEvent(); | 1707 | Event * e = getLastSyncEvent(); |
1708 | mCalendar->deleteEvent ( e ); | 1708 | mCalendar->deleteEvent ( e ); |
1709 | updateView(); | 1709 | updateView(); |
1710 | return true; | 1710 | return true; |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | bool CalendarView::saveCalendar( QString filename ) | 1713 | bool CalendarView::saveCalendar( QString filename ) |
1714 | { | 1714 | { |
1715 | 1715 | ||
1716 | // Store back all unsaved data into calendar object | 1716 | // Store back all unsaved data into calendar object |
1717 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1717 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1718 | if ( mViewManager->currentView() ) | 1718 | if ( mViewManager->currentView() ) |
1719 | mViewManager->currentView()->flushView(); | 1719 | mViewManager->currentView()->flushView(); |
1720 | 1720 | ||
1721 | 1721 | ||
1722 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1722 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1723 | mStorage->setSaveFormat( new ICalFormat() ); | 1723 | mStorage->setSaveFormat( new ICalFormat() ); |
1724 | mStorage->setFileName( filename ); | 1724 | mStorage->setFileName( filename ); |
1725 | bool success; | 1725 | bool success; |
1726 | success = mStorage->save(); | 1726 | success = mStorage->save(); |
1727 | if ( !success ) { | 1727 | if ( !success ) { |
1728 | return false; | 1728 | return false; |
1729 | } | 1729 | } |
1730 | if ( filename == MainWindow::defaultFileName() ) { | 1730 | if ( filename == MainWindow::defaultFileName() ) { |
1731 | setLoadedFileVersion( lfv ); | 1731 | setLoadedFileVersion( lfv ); |
1732 | watchSavedFile(); | 1732 | watchSavedFile(); |
1733 | } | 1733 | } |
1734 | return true; | 1734 | return true; |
1735 | } | 1735 | } |
1736 | 1736 | ||
1737 | void CalendarView::closeCalendar() | 1737 | void CalendarView::closeCalendar() |
1738 | { | 1738 | { |
1739 | 1739 | ||
1740 | // child windows no longer valid | 1740 | // child windows no longer valid |
1741 | emit closingDown(); | 1741 | emit closingDown(); |
1742 | 1742 | ||
1743 | mCalendar->close(); | 1743 | mCalendar->close(); |
1744 | setModified(false); | 1744 | setModified(false); |
1745 | updateView(); | 1745 | updateView(); |
1746 | } | 1746 | } |
1747 | 1747 | ||
1748 | void CalendarView::archiveCalendar() | 1748 | void CalendarView::archiveCalendar() |
1749 | { | 1749 | { |
1750 | mDialogManager->showArchiveDialog(); | 1750 | mDialogManager->showArchiveDialog(); |
1751 | } | 1751 | } |
1752 | 1752 | ||
1753 | 1753 | ||
1754 | void CalendarView::readSettings() | 1754 | void CalendarView::readSettings() |
1755 | { | 1755 | { |
1756 | 1756 | ||
1757 | 1757 | ||
1758 | // mViewManager->showAgendaView(); | 1758 | // mViewManager->showAgendaView(); |
1759 | QString str; | 1759 | QString str; |
1760 | //qDebug("CalendarView::readSettings() "); | 1760 | //qDebug("CalendarView::readSettings() "); |
1761 | // read settings from the KConfig, supplying reasonable | 1761 | // read settings from the KConfig, supplying reasonable |
1762 | // defaults where none are to be found | 1762 | // defaults where none are to be found |
1763 | KConfig *config = KOGlobals::config(); | 1763 | KConfig *config = KOGlobals::config(); |
1764 | #ifndef KORG_NOSPLITTER | 1764 | #ifndef KORG_NOSPLITTER |
1765 | config->setGroup("KOrganizer Geometry"); | 1765 | config->setGroup("KOrganizer Geometry"); |
1766 | 1766 | ||
1767 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1767 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1768 | if (sizes.count() != 2) { | 1768 | if (sizes.count() != 2) { |
1769 | sizes << mDateNavigator->minimumSizeHint().width(); | 1769 | sizes << mDateNavigator->minimumSizeHint().width(); |
1770 | sizes << 300; | 1770 | sizes << 300; |
1771 | } | 1771 | } |
1772 | mPanner->setSizes(sizes); | 1772 | mPanner->setSizes(sizes); |
1773 | 1773 | ||
1774 | sizes = config->readIntListEntry("Separator2"); | 1774 | sizes = config->readIntListEntry("Separator2"); |
1775 | if ( ( mResourceView && sizes.count() == 4 ) || | 1775 | if ( ( mResourceView && sizes.count() == 4 ) || |
1776 | ( !mResourceView && sizes.count() == 3 ) ) { | 1776 | ( !mResourceView && sizes.count() == 3 ) ) { |
1777 | mLeftSplitter->setSizes(sizes); | 1777 | mLeftSplitter->setSizes(sizes); |
1778 | } | 1778 | } |
1779 | #endif | 1779 | #endif |
1780 | globalFlagBlockAgenda = 1; | 1780 | globalFlagBlockAgenda = 1; |
1781 | mViewManager->showAgendaView(); | 1781 | mViewManager->showAgendaView(); |
1782 | //mViewManager->readSettings( config ); | 1782 | //mViewManager->readSettings( config ); |
1783 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1783 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1784 | readFilterSettings(config); | 1784 | readFilterSettings(config); |
1785 | config->setGroup( "Views" ); | 1785 | config->setGroup( "Views" ); |
1786 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1786 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1787 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1787 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1788 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1788 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1789 | else mNavigator->selectDates( dateCount ); | 1789 | else mNavigator->selectDates( dateCount ); |
1790 | // mViewManager->readSettings( config ); | 1790 | // mViewManager->readSettings( config ); |
1791 | updateConfig(); | 1791 | updateConfig(); |
1792 | globalFlagBlockAgenda = 2; | 1792 | globalFlagBlockAgenda = 2; |
1793 | mViewManager->readSettings( config ); | 1793 | mViewManager->readSettings( config ); |
1794 | #ifdef DESKTOP_VERSION | 1794 | #ifdef DESKTOP_VERSION |
1795 | config->setGroup("WidgetLayout"); | 1795 | config->setGroup("WidgetLayout"); |
1796 | QStringList list; | 1796 | QStringList list; |
1797 | list = config->readListEntry("MainLayout"); | 1797 | list = config->readListEntry("MainLayout"); |
1798 | int x,y,w,h; | 1798 | int x,y,w,h; |
1799 | if ( ! list.isEmpty() ) { | 1799 | if ( ! list.isEmpty() ) { |
1800 | x = list[0].toInt(); | 1800 | x = list[0].toInt(); |
1801 | y = list[1].toInt(); | 1801 | y = list[1].toInt(); |
1802 | w = list[2].toInt(); | 1802 | w = list[2].toInt(); |
1803 | h = list[3].toInt(); | 1803 | h = list[3].toInt(); |
1804 | topLevelWidget()->setGeometry(x,y,w,h); | 1804 | topLevelWidget()->setGeometry(x,y,w,h); |
1805 | 1805 | ||
1806 | } else { | 1806 | } else { |
1807 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1807 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1808 | } | 1808 | } |
1809 | list = config->readListEntry("EditEventLayout"); | 1809 | list = config->readListEntry("EditEventLayout"); |
1810 | if ( ! list.isEmpty() ) { | 1810 | if ( ! list.isEmpty() ) { |
1811 | x = list[0].toInt(); | 1811 | x = list[0].toInt(); |
1812 | y = list[1].toInt(); | 1812 | y = list[1].toInt(); |
1813 | w = list[2].toInt(); | 1813 | w = list[2].toInt(); |
1814 | h = list[3].toInt(); | 1814 | h = list[3].toInt(); |
1815 | mEventEditor->setGeometry(x,y,w,h); | 1815 | mEventEditor->setGeometry(x,y,w,h); |
1816 | 1816 | ||
1817 | } | 1817 | } |
1818 | list = config->readListEntry("EditTodoLayout"); | 1818 | list = config->readListEntry("EditTodoLayout"); |
1819 | if ( ! list.isEmpty() ) { | 1819 | if ( ! list.isEmpty() ) { |
1820 | x = list[0].toInt(); | 1820 | x = list[0].toInt(); |
1821 | y = list[1].toInt(); | 1821 | y = list[1].toInt(); |
1822 | w = list[2].toInt(); | 1822 | w = list[2].toInt(); |
1823 | h = list[3].toInt(); | 1823 | h = list[3].toInt(); |
1824 | mTodoEditor->setGeometry(x,y,w,h); | 1824 | mTodoEditor->setGeometry(x,y,w,h); |
1825 | 1825 | ||
1826 | } | 1826 | } |
1827 | list = config->readListEntry("ViewerLayout"); | 1827 | list = config->readListEntry("ViewerLayout"); |
1828 | if ( ! list.isEmpty() ) { | 1828 | if ( ! list.isEmpty() ) { |
1829 | x = list[0].toInt(); | 1829 | x = list[0].toInt(); |
1830 | y = list[1].toInt(); | 1830 | y = list[1].toInt(); |
1831 | w = list[2].toInt(); | 1831 | w = list[2].toInt(); |
1832 | h = list[3].toInt(); | 1832 | h = list[3].toInt(); |
1833 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1833 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1834 | } | 1834 | } |
1835 | #endif | 1835 | #endif |
1836 | 1836 | ||
1837 | } | 1837 | } |
1838 | 1838 | ||
1839 | 1839 | ||
1840 | void CalendarView::writeSettings() | 1840 | void CalendarView::writeSettings() |
1841 | { | 1841 | { |
1842 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1842 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1843 | 1843 | ||
1844 | KConfig *config = KOGlobals::config(); | 1844 | KConfig *config = KOGlobals::config(); |
1845 | 1845 | ||
1846 | #ifndef KORG_NOSPLITTER | 1846 | #ifndef KORG_NOSPLITTER |
1847 | config->setGroup("KOrganizer Geometry"); | 1847 | config->setGroup("KOrganizer Geometry"); |
1848 | 1848 | ||
1849 | QValueList<int> list = mPanner->sizes(); | 1849 | QValueList<int> list = mPanner->sizes(); |
1850 | config->writeEntry("Separator1",list); | 1850 | config->writeEntry("Separator1",list); |
1851 | 1851 | ||
1852 | list = mLeftSplitter->sizes(); | 1852 | list = mLeftSplitter->sizes(); |
1853 | config->writeEntry("Separator2",list); | 1853 | config->writeEntry("Separator2",list); |
1854 | #endif | 1854 | #endif |
1855 | 1855 | ||
1856 | mViewManager->writeSettings( config ); | 1856 | mViewManager->writeSettings( config ); |
1857 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1857 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1858 | mDialogManager->writeSettings( config ); | 1858 | mDialogManager->writeSettings( config ); |
1859 | //KOPrefs::instance()->usrWriteConfig(); | 1859 | //KOPrefs::instance()->usrWriteConfig(); |
1860 | KOPrefs::instance()->writeConfig(); | 1860 | KOPrefs::instance()->writeConfig(); |
1861 | 1861 | ||
1862 | writeFilterSettings(config); | 1862 | writeFilterSettings(config); |
1863 | 1863 | ||
1864 | config->setGroup( "Views" ); | 1864 | config->setGroup( "Views" ); |
1865 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1865 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1866 | 1866 | ||
1867 | #ifdef DESKTOP_VERSION | 1867 | #ifdef DESKTOP_VERSION |
1868 | config->setGroup("WidgetLayout"); | 1868 | config->setGroup("WidgetLayout"); |
1869 | QStringList list ;//= config->readListEntry("MainLayout"); | 1869 | QStringList list ;//= config->readListEntry("MainLayout"); |
1870 | int x,y,w,h; | 1870 | int x,y,w,h; |
1871 | QWidget* wid; | 1871 | QWidget* wid; |
1872 | wid = topLevelWidget(); | 1872 | wid = topLevelWidget(); |
1873 | x = wid->geometry().x(); | 1873 | x = wid->geometry().x(); |
1874 | y = wid->geometry().y(); | 1874 | y = wid->geometry().y(); |
1875 | w = wid->width(); | 1875 | w = wid->width(); |
1876 | h = wid->height(); | 1876 | h = wid->height(); |
1877 | list.clear(); | 1877 | list.clear(); |
1878 | list << QString::number( x ); | 1878 | list << QString::number( x ); |
1879 | list << QString::number( y ); | 1879 | list << QString::number( y ); |
1880 | list << QString::number( w ); | 1880 | list << QString::number( w ); |
1881 | list << QString::number( h ); | 1881 | list << QString::number( h ); |
1882 | config->writeEntry("MainLayout",list ); | 1882 | config->writeEntry("MainLayout",list ); |
1883 | 1883 | ||
1884 | wid = mEventEditor; | 1884 | wid = mEventEditor; |
1885 | x = wid->geometry().x(); | 1885 | x = wid->geometry().x(); |
1886 | y = wid->geometry().y(); | 1886 | y = wid->geometry().y(); |
1887 | w = wid->width(); | 1887 | w = wid->width(); |
1888 | h = wid->height(); | 1888 | h = wid->height(); |
1889 | list.clear(); | 1889 | list.clear(); |
1890 | list << QString::number( x ); | 1890 | list << QString::number( x ); |
1891 | list << QString::number( y ); | 1891 | list << QString::number( y ); |
1892 | list << QString::number( w ); | 1892 | list << QString::number( w ); |
1893 | list << QString::number( h ); | 1893 | list << QString::number( h ); |
1894 | config->writeEntry("EditEventLayout",list ); | 1894 | config->writeEntry("EditEventLayout",list ); |
1895 | 1895 | ||
1896 | wid = mTodoEditor; | 1896 | wid = mTodoEditor; |
1897 | x = wid->geometry().x(); | 1897 | x = wid->geometry().x(); |
1898 | y = wid->geometry().y(); | 1898 | y = wid->geometry().y(); |
1899 | w = wid->width(); | 1899 | w = wid->width(); |
1900 | h = wid->height(); | 1900 | h = wid->height(); |
1901 | list.clear(); | 1901 | list.clear(); |
1902 | list << QString::number( x ); | 1902 | list << QString::number( x ); |
1903 | list << QString::number( y ); | 1903 | list << QString::number( y ); |
1904 | list << QString::number( w ); | 1904 | list << QString::number( w ); |
1905 | list << QString::number( h ); | 1905 | list << QString::number( h ); |
1906 | config->writeEntry("EditTodoLayout",list ); | 1906 | config->writeEntry("EditTodoLayout",list ); |
1907 | wid = getEventViewerDialog(); | 1907 | wid = getEventViewerDialog(); |
1908 | x = wid->geometry().x(); | 1908 | x = wid->geometry().x(); |
1909 | y = wid->geometry().y(); | 1909 | y = wid->geometry().y(); |
1910 | w = wid->width(); | 1910 | w = wid->width(); |
1911 | h = wid->height(); | 1911 | h = wid->height(); |
1912 | list.clear(); | 1912 | list.clear(); |
1913 | list << QString::number( x ); | 1913 | list << QString::number( x ); |
1914 | list << QString::number( y ); | 1914 | list << QString::number( y ); |
1915 | list << QString::number( w ); | 1915 | list << QString::number( w ); |
1916 | list << QString::number( h ); | 1916 | list << QString::number( h ); |
1917 | config->writeEntry("ViewerLayout",list ); | 1917 | config->writeEntry("ViewerLayout",list ); |
1918 | wid = mDialogManager->getSearchDialog(); | 1918 | wid = mDialogManager->getSearchDialog(); |
1919 | if ( wid ) { | 1919 | if ( wid ) { |
1920 | x = wid->geometry().x(); | 1920 | x = wid->geometry().x(); |
1921 | y = wid->geometry().y(); | 1921 | y = wid->geometry().y(); |
1922 | w = wid->width(); | 1922 | w = wid->width(); |
1923 | h = wid->height(); | 1923 | h = wid->height(); |
1924 | list.clear(); | 1924 | list.clear(); |
1925 | list << QString::number( x ); | 1925 | list << QString::number( x ); |
1926 | list << QString::number( y ); | 1926 | list << QString::number( y ); |
1927 | list << QString::number( w ); | 1927 | list << QString::number( w ); |
1928 | list << QString::number( h ); | 1928 | list << QString::number( h ); |
1929 | config->writeEntry("SearchLayout",list ); | 1929 | config->writeEntry("SearchLayout",list ); |
1930 | } | 1930 | } |
1931 | #endif | 1931 | #endif |
1932 | 1932 | ||
1933 | 1933 | ||
1934 | config->sync(); | 1934 | config->sync(); |
1935 | } | 1935 | } |
1936 | 1936 | ||
1937 | void CalendarView::readFilterSettings(KConfig *config) | 1937 | void CalendarView::readFilterSettings(KConfig *config) |
1938 | { | 1938 | { |
1939 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1939 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1940 | 1940 | ||
1941 | mFilters.clear(); | 1941 | mFilters.clear(); |
1942 | 1942 | ||
1943 | config->setGroup("General"); | 1943 | config->setGroup("General"); |
1944 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1944 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1945 | 1945 | ||
1946 | QStringList::ConstIterator it = filterList.begin(); | 1946 | QStringList::ConstIterator it = filterList.begin(); |
1947 | QStringList::ConstIterator end = filterList.end(); | 1947 | QStringList::ConstIterator end = filterList.end(); |
1948 | while(it != end) { | 1948 | while(it != end) { |
1949 | // kdDebug() << " filter: " << (*it) << endl; | 1949 | // kdDebug() << " filter: " << (*it) << endl; |
1950 | 1950 | ||
1951 | CalFilter *filter; | 1951 | CalFilter *filter; |
1952 | filter = new CalFilter(*it); | 1952 | filter = new CalFilter(*it); |
1953 | config->setGroup("Filter_" + (*it)); | 1953 | config->setGroup("Filter_" + (*it)); |
1954 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1954 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1955 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1955 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1956 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1956 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1957 | mFilters.append(filter); | 1957 | mFilters.append(filter); |
1958 | 1958 | ||
1959 | ++it; | 1959 | ++it; |
1960 | } | 1960 | } |
1961 | 1961 | ||
1962 | if (mFilters.count() == 0) { | 1962 | if (mFilters.count() == 0) { |
1963 | CalFilter *filter = new CalFilter(i18n("Default")); | 1963 | CalFilter *filter = new CalFilter(i18n("Default")); |
1964 | mFilters.append(filter); | 1964 | mFilters.append(filter); |
1965 | } | 1965 | } |
1966 | mFilterView->updateFilters(); | 1966 | mFilterView->updateFilters(); |
1967 | config->setGroup("FilterView"); | 1967 | config->setGroup("FilterView"); |
1968 | 1968 | ||
1969 | mFilterView->blockSignals(true); | 1969 | mFilterView->blockSignals(true); |
1970 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1970 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1971 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1971 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1972 | mFilterView->blockSignals(false); | 1972 | mFilterView->blockSignals(false); |
1973 | // We do it manually to avoid it being done twice by the above calls | 1973 | // We do it manually to avoid it being done twice by the above calls |
1974 | updateFilter(); | 1974 | updateFilter(); |
1975 | } | 1975 | } |
1976 | 1976 | ||
1977 | void CalendarView::writeFilterSettings(KConfig *config) | 1977 | void CalendarView::writeFilterSettings(KConfig *config) |
1978 | { | 1978 | { |
1979 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1979 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1980 | 1980 | ||
1981 | QStringList filterList; | 1981 | QStringList filterList; |
1982 | 1982 | ||
1983 | CalFilter *filter = mFilters.first(); | 1983 | CalFilter *filter = mFilters.first(); |
1984 | while(filter) { | 1984 | while(filter) { |
1985 | // kdDebug() << " fn: " << filter->name() << endl; | 1985 | // kdDebug() << " fn: " << filter->name() << endl; |
1986 | filterList << filter->name(); | 1986 | filterList << filter->name(); |
1987 | config->setGroup("Filter_" + filter->name()); | 1987 | config->setGroup("Filter_" + filter->name()); |
1988 | config->writeEntry("Criteria",filter->criteria()); | 1988 | config->writeEntry("Criteria",filter->criteria()); |
1989 | config->writeEntry("CategoryList",filter->categoryList()); | 1989 | config->writeEntry("CategoryList",filter->categoryList()); |
1990 | filter = mFilters.next(); | 1990 | filter = mFilters.next(); |
1991 | } | 1991 | } |
1992 | config->setGroup("General"); | 1992 | config->setGroup("General"); |
1993 | config->writeEntry("CalendarFilters",filterList); | 1993 | config->writeEntry("CalendarFilters",filterList); |
1994 | 1994 | ||
1995 | config->setGroup("FilterView"); | 1995 | config->setGroup("FilterView"); |
1996 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1996 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1997 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1997 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | 2000 | ||
2001 | void CalendarView::goToday() | 2001 | void CalendarView::goToday() |
2002 | { | 2002 | { |
2003 | if ( mViewManager->currentView()->isMonthView() ) | 2003 | if ( mViewManager->currentView()->isMonthView() ) |
2004 | mNavigator->selectTodayMonth(); | 2004 | mNavigator->selectTodayMonth(); |
2005 | else | 2005 | else |
2006 | mNavigator->selectToday(); | 2006 | mNavigator->selectToday(); |
2007 | } | 2007 | } |
2008 | 2008 | ||
2009 | void CalendarView::goNext() | 2009 | void CalendarView::goNext() |
2010 | { | 2010 | { |
2011 | mNavigator->selectNext(); | 2011 | mNavigator->selectNext(); |
2012 | } | 2012 | } |
2013 | 2013 | ||
2014 | void CalendarView::goPrevious() | 2014 | void CalendarView::goPrevious() |
2015 | { | 2015 | { |
2016 | mNavigator->selectPrevious(); | 2016 | mNavigator->selectPrevious(); |
2017 | } | 2017 | } |
2018 | void CalendarView::goNextMonth() | 2018 | void CalendarView::goNextMonth() |
2019 | { | 2019 | { |
2020 | mNavigator->selectNextMonth(); | 2020 | mNavigator->selectNextMonth(); |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | void CalendarView::goPreviousMonth() | 2023 | void CalendarView::goPreviousMonth() |
2024 | { | 2024 | { |
2025 | mNavigator->selectPreviousMonth(); | 2025 | mNavigator->selectPreviousMonth(); |
2026 | } | 2026 | } |
2027 | void CalendarView::writeLocale() | 2027 | void CalendarView::writeLocale() |
2028 | { | 2028 | { |
2029 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2029 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2030 | #if 0 | 2030 | #if 0 |
2031 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2031 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2032 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2032 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2033 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2033 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2034 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2034 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2035 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2035 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2036 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2036 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2037 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2037 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2038 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2038 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2039 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2039 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2040 | KOPrefs::instance()->mDaylightsavingStart, | 2040 | KOPrefs::instance()->mDaylightsavingStart, |
2041 | KOPrefs::instance()->mDaylightsavingEnd ); | 2041 | KOPrefs::instance()->mDaylightsavingEnd ); |
2042 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2042 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2043 | #endif | 2043 | #endif |
2044 | } | 2044 | } |
2045 | void CalendarView::updateConfig() | 2045 | void CalendarView::updateConfig() |
2046 | { | 2046 | { |
2047 | writeLocale(); | 2047 | writeLocale(); |
2048 | if ( KOPrefs::instance()->mUseAppColors ) | 2048 | if ( KOPrefs::instance()->mUseAppColors ) |
2049 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2049 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2050 | emit configChanged(); | 2050 | emit configChanged(); |
2051 | mTodoList->updateConfig(); | 2051 | mTodoList->updateConfig(); |
2052 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2052 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2053 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2053 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2054 | // To make the "fill window" configurations work | 2054 | // To make the "fill window" configurations work |
2055 | //mViewManager->raiseCurrentView(); | 2055 | //mViewManager->raiseCurrentView(); |
2056 | } | 2056 | } |
2057 | 2057 | ||
2058 | 2058 | ||
2059 | void CalendarView::eventChanged(Event *event) | 2059 | void CalendarView::eventChanged(Event *event) |
2060 | { | 2060 | { |
2061 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2061 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2062 | //updateUnmanagedViews(); | 2062 | //updateUnmanagedViews(); |
2063 | } | 2063 | } |
2064 | 2064 | ||
2065 | void CalendarView::eventAdded(Event *event) | 2065 | void CalendarView::eventAdded(Event *event) |
2066 | { | 2066 | { |
2067 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2067 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2068 | } | 2068 | } |
2069 | 2069 | ||
2070 | void CalendarView::eventToBeDeleted(Event *) | 2070 | void CalendarView::eventToBeDeleted(Event *) |
2071 | { | 2071 | { |
2072 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2072 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2073 | } | 2073 | } |
2074 | 2074 | ||
2075 | void CalendarView::eventDeleted() | 2075 | void CalendarView::eventDeleted() |
2076 | { | 2076 | { |
2077 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2077 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2078 | } | 2078 | } |
2079 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2079 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2080 | { | 2080 | { |
2081 | changeIncidenceDisplay((Incidence *)which, action); | 2081 | changeIncidenceDisplay((Incidence *)which, action); |
2082 | mDateNavigator->updateView(); //LR | 2082 | mDateNavigator->updateView(); //LR |
2083 | //mDialogManager->updateSearchDialog(); | 2083 | //mDialogManager->updateSearchDialog(); |
2084 | 2084 | ||
2085 | if (which) { | 2085 | if (which) { |
2086 | mViewManager->updateWNview(); | 2086 | mViewManager->updateWNview(); |
2087 | //mTodoList->updateView(); | 2087 | //mTodoList->updateView(); |
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | } | 2090 | } |
2091 | 2091 | ||
2092 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2092 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2093 | { | 2093 | { |
2094 | updateUnmanagedViews(); | 2094 | updateUnmanagedViews(); |
2095 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2095 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2096 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2096 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2097 | mCalendar->checkAlarmForIncidence( 0, true ); | 2097 | mCalendar->checkAlarmForIncidence( 0, true ); |
2098 | if ( mEventViewerDialog ) | 2098 | if ( mEventViewerDialog ) |
2099 | mEventViewerDialog->hide(); | 2099 | mEventViewerDialog->hide(); |
2100 | } | 2100 | } |
2101 | else | 2101 | else |
2102 | mCalendar->checkAlarmForIncidence( which , false ); | 2102 | mCalendar->checkAlarmForIncidence( which , false ); |
2103 | } | 2103 | } |
2104 | 2104 | ||
2105 | // most of the changeEventDisplays() right now just call the view's | 2105 | // most of the changeEventDisplays() right now just call the view's |
2106 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2106 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2107 | void CalendarView::changeEventDisplay(Event *which, int action) | 2107 | void CalendarView::changeEventDisplay(Event *which, int action) |
2108 | { | 2108 | { |
2109 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2109 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2110 | changeIncidenceDisplay((Incidence *)which, action); | 2110 | changeIncidenceDisplay((Incidence *)which, action); |
2111 | mDateNavigator->updateView(); | 2111 | mDateNavigator->updateView(); |
2112 | //mDialogManager->updateSearchDialog(); | 2112 | //mDialogManager->updateSearchDialog(); |
2113 | 2113 | ||
2114 | if (which) { | 2114 | if (which) { |
2115 | // If there is an event view visible update the display | 2115 | // If there is an event view visible update the display |
2116 | mViewManager->currentView()->changeEventDisplay(which,action); | 2116 | mViewManager->currentView()->changeEventDisplay(which,action); |
2117 | // TODO: check, if update needed | 2117 | // TODO: check, if update needed |
2118 | // if (which->getTodoStatus()) { | 2118 | // if (which->getTodoStatus()) { |
2119 | mTodoList->updateView(); | 2119 | mTodoList->updateView(); |
2120 | // } | 2120 | // } |
2121 | } else { | 2121 | } else { |
2122 | mViewManager->currentView()->updateView(); | 2122 | mViewManager->currentView()->updateView(); |
2123 | } | 2123 | } |
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | 2126 | ||
2127 | void CalendarView::updateTodoViews() | 2127 | void CalendarView::updateTodoViews() |
2128 | { | 2128 | { |
2129 | 2129 | ||
2130 | mTodoList->updateView(); | 2130 | mTodoList->updateView(); |
2131 | mViewManager->currentView()->updateView(); | 2131 | mViewManager->currentView()->updateView(); |
2132 | 2132 | ||
2133 | } | 2133 | } |
2134 | 2134 | ||
2135 | 2135 | ||
2136 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2136 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2137 | { | 2137 | { |
2138 | mTodoList->updateView(); | 2138 | mTodoList->updateView(); |
2139 | mViewManager->updateView(start, end); | 2139 | mViewManager->updateView(start, end); |
2140 | //mDateNavigator->updateView(); | 2140 | //mDateNavigator->updateView(); |
2141 | } | 2141 | } |
2142 | 2142 | ||
2143 | void CalendarView::updateView() | 2143 | void CalendarView::updateView() |
2144 | { | 2144 | { |
2145 | DateList tmpList = mNavigator->selectedDates(); | 2145 | DateList tmpList = mNavigator->selectedDates(); |
2146 | 2146 | ||
2147 | // We assume that the navigator only selects consecutive days. | 2147 | // We assume that the navigator only selects consecutive days. |
2148 | updateView( tmpList.first(), tmpList.last() ); | 2148 | updateView( tmpList.first(), tmpList.last() ); |
2149 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2149 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2150 | mTodoList->updateView(); | 2150 | mTodoList->updateView(); |
2151 | } | 2151 | } |
2152 | 2152 | ||
2153 | void CalendarView::updateUnmanagedViews() | 2153 | void CalendarView::updateUnmanagedViews() |
2154 | { | 2154 | { |
2155 | mDateNavigator->updateDayMatrix(); | 2155 | mDateNavigator->updateDayMatrix(); |
2156 | } | 2156 | } |
2157 | 2157 | ||
2158 | int CalendarView::msgItemDelete() | 2158 | int CalendarView::msgItemDelete() |
2159 | { | 2159 | { |
2160 | return KMessageBox::warningContinueCancel(this, | 2160 | return KMessageBox::warningContinueCancel(this, |
2161 | i18n("This item will be\npermanently deleted."), | 2161 | i18n("This item will be\npermanently deleted."), |
2162 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2162 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2163 | } | 2163 | } |
2164 | 2164 | ||
2165 | 2165 | ||
2166 | void CalendarView::edit_cut() | 2166 | void CalendarView::edit_cut() |
2167 | { | 2167 | { |
2168 | Event *anEvent=0; | 2168 | Event *anEvent=0; |
2169 | 2169 | ||
2170 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2170 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2171 | 2171 | ||
2172 | if (mViewManager->currentView()->isEventView()) { | 2172 | if (mViewManager->currentView()->isEventView()) { |
2173 | if ( incidence && incidence->type() == "Event" ) { | 2173 | if ( incidence && incidence->type() == "Event" ) { |
2174 | anEvent = static_cast<Event *>(incidence); | 2174 | anEvent = static_cast<Event *>(incidence); |
2175 | } | 2175 | } |
2176 | } | 2176 | } |
2177 | 2177 | ||
2178 | if (!anEvent) { | 2178 | if (!anEvent) { |
2179 | KNotifyClient::beep(); | 2179 | KNotifyClient::beep(); |
2180 | return; | 2180 | return; |
2181 | } | 2181 | } |
2182 | DndFactory factory( mCalendar ); | 2182 | DndFactory factory( mCalendar ); |
2183 | factory.cutEvent(anEvent); | 2183 | factory.cutEvent(anEvent); |
2184 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2184 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2185 | } | 2185 | } |
2186 | 2186 | ||
2187 | void CalendarView::edit_copy() | 2187 | void CalendarView::edit_copy() |
2188 | { | 2188 | { |
2189 | Event *anEvent=0; | 2189 | Event *anEvent=0; |
2190 | 2190 | ||
2191 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2191 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2192 | 2192 | ||
2193 | if (mViewManager->currentView()->isEventView()) { | 2193 | if (mViewManager->currentView()->isEventView()) { |
2194 | if ( incidence && incidence->type() == "Event" ) { | 2194 | if ( incidence && incidence->type() == "Event" ) { |
2195 | anEvent = static_cast<Event *>(incidence); | 2195 | anEvent = static_cast<Event *>(incidence); |
2196 | } | 2196 | } |
2197 | } | 2197 | } |
2198 | 2198 | ||
2199 | if (!anEvent) { | 2199 | if (!anEvent) { |
2200 | KNotifyClient::beep(); | 2200 | KNotifyClient::beep(); |
2201 | return; | 2201 | return; |
2202 | } | 2202 | } |
2203 | DndFactory factory( mCalendar ); | 2203 | DndFactory factory( mCalendar ); |
2204 | factory.copyEvent(anEvent); | 2204 | factory.copyEvent(anEvent); |
2205 | } | 2205 | } |
2206 | 2206 | ||
2207 | void CalendarView::edit_paste() | 2207 | void CalendarView::edit_paste() |
2208 | { | 2208 | { |
2209 | QDate date = mNavigator->selectedDates().first(); | 2209 | QDate date = mNavigator->selectedDates().first(); |
2210 | 2210 | ||
2211 | DndFactory factory( mCalendar ); | 2211 | DndFactory factory( mCalendar ); |
2212 | Event *pastedEvent = factory.pasteEvent( date ); | 2212 | Event *pastedEvent = factory.pasteEvent( date ); |
2213 | 2213 | ||
2214 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2214 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2215 | } | 2215 | } |
2216 | 2216 | ||
2217 | void CalendarView::edit_options() | 2217 | void CalendarView::edit_options() |
2218 | { | 2218 | { |
2219 | mDialogManager->showOptionsDialog(); | 2219 | mDialogManager->showOptionsDialog(); |
2220 | //writeSettings(); | 2220 | //writeSettings(); |
2221 | } | 2221 | } |
2222 | 2222 | ||
2223 | 2223 | ||
2224 | void CalendarView::slotSelectPickerDate( QDate d) | 2224 | void CalendarView::slotSelectPickerDate( QDate d) |
2225 | { | 2225 | { |
2226 | mDateFrame->hide(); | 2226 | mDateFrame->hide(); |
2227 | if ( mDatePickerMode == 1 ) { | 2227 | if ( mDatePickerMode == 1 ) { |
2228 | mNavigator->slotDaySelect( d ); | 2228 | mNavigator->slotDaySelect( d ); |
2229 | } else if ( mDatePickerMode == 2 ) { | 2229 | } else if ( mDatePickerMode == 2 ) { |
2230 | if ( mMoveIncidence->type() == "Todo" ) { | 2230 | if ( mMoveIncidence->type() == "Todo" ) { |
2231 | Todo * to = (Todo *) mMoveIncidence; | 2231 | Todo * to = (Todo *) mMoveIncidence; |
2232 | QTime tim; | 2232 | QTime tim; |
2233 | if ( to->hasDueDate() ) | 2233 | if ( to->hasDueDate() ) |
2234 | tim = to->dtDue().time(); | 2234 | tim = to->dtDue().time(); |
2235 | else { | 2235 | else { |
2236 | tim = QTime ( 0,0,0 ); | 2236 | tim = QTime ( 0,0,0 ); |
2237 | to->setFloats( true ); | 2237 | to->setFloats( true ); |
2238 | to->setHasDueDate( true ); | 2238 | to->setHasDueDate( true ); |
2239 | } | 2239 | } |
2240 | QDateTime dt ( d,tim ); | 2240 | QDateTime dt ( d,tim ); |
2241 | to->setDtDue( dt ); | 2241 | to->setDtDue( dt ); |
2242 | todoChanged( to ); | 2242 | todoChanged( to ); |
2243 | } else { | 2243 | } else { |
2244 | if ( mMoveIncidence->doesRecur() ) { | 2244 | if ( mMoveIncidence->doesRecur() ) { |
2245 | #if 0 | 2245 | #if 0 |
2246 | // PENDING implement this | 2246 | // PENDING implement this |
2247 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2247 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2248 | mCalendar()->addIncidence( newInc ); | 2248 | mCalendar()->addIncidence( newInc ); |
2249 | if ( mMoveIncidence->type() == "Todo" ) | 2249 | if ( mMoveIncidence->type() == "Todo" ) |
2250 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2250 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2251 | else | 2251 | else |
2252 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2252 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2253 | mMoveIncidence = newInc; | 2253 | mMoveIncidence = newInc; |
2254 | 2254 | ||
2255 | #endif | 2255 | #endif |
2256 | } | 2256 | } |
2257 | QTime tim = mMoveIncidence->dtStart().time(); | 2257 | QTime tim = mMoveIncidence->dtStart().time(); |
2258 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2258 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2259 | QDateTime dt ( d,tim ); | 2259 | QDateTime dt ( d,tim ); |
2260 | mMoveIncidence->setDtStart( dt ); | 2260 | mMoveIncidence->setDtStart( dt ); |
2261 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2261 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2262 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2262 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2263 | } | 2263 | } |
2264 | 2264 | ||
2265 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2265 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2266 | } | 2266 | } |
2267 | } | 2267 | } |
2268 | 2268 | ||
2269 | void CalendarView::removeCategories() | 2269 | void CalendarView::removeCategories() |
2270 | { | 2270 | { |
2271 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2271 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2272 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2272 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2273 | QStringList catIncList; | 2273 | QStringList catIncList; |
2274 | QStringList newCatList; | 2274 | QStringList newCatList; |
2275 | Incidence* inc = incList.first(); | 2275 | Incidence* inc = incList.first(); |
2276 | int i; | 2276 | int i; |
2277 | int count = 0; | 2277 | int count = 0; |
2278 | while ( inc ) { | 2278 | while ( inc ) { |
2279 | newCatList.clear(); | 2279 | newCatList.clear(); |
2280 | catIncList = inc->categories() ; | 2280 | catIncList = inc->categories() ; |
2281 | for( i = 0; i< catIncList.count(); ++i ) { | 2281 | for( i = 0; i< catIncList.count(); ++i ) { |
2282 | if ( catList.contains (catIncList[i])) | 2282 | if ( catList.contains (catIncList[i])) |
2283 | newCatList.append( catIncList[i] ); | 2283 | newCatList.append( catIncList[i] ); |
2284 | } | 2284 | } |
2285 | newCatList.sort(); | 2285 | newCatList.sort(); |
2286 | inc->setCategories( newCatList.join(",") ); | 2286 | inc->setCategories( newCatList.join(",") ); |
2287 | inc = incList.next(); | 2287 | inc = incList.next(); |
2288 | } | 2288 | } |
2289 | } | 2289 | } |
2290 | 2290 | ||
2291 | int CalendarView::addCategories() | 2291 | int CalendarView::addCategories() |
2292 | { | 2292 | { |
2293 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2293 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2294 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2294 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2295 | QStringList catIncList; | 2295 | QStringList catIncList; |
2296 | Incidence* inc = incList.first(); | 2296 | Incidence* inc = incList.first(); |
2297 | int i; | 2297 | int i; |
2298 | int count = 0; | 2298 | int count = 0; |
2299 | while ( inc ) { | 2299 | while ( inc ) { |
2300 | catIncList = inc->categories() ; | 2300 | catIncList = inc->categories() ; |
2301 | for( i = 0; i< catIncList.count(); ++i ) { | 2301 | for( i = 0; i< catIncList.count(); ++i ) { |
2302 | if ( !catList.contains (catIncList[i])) { | 2302 | if ( !catList.contains (catIncList[i])) { |
2303 | catList.append( catIncList[i] ); | 2303 | catList.append( catIncList[i] ); |
2304 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2304 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2305 | ++count; | 2305 | ++count; |
2306 | } | 2306 | } |
2307 | } | 2307 | } |
2308 | inc = incList.next(); | 2308 | inc = incList.next(); |
2309 | } | 2309 | } |
2310 | catList.sort(); | 2310 | catList.sort(); |
2311 | KOPrefs::instance()->mCustomCategories = catList; | 2311 | KOPrefs::instance()->mCustomCategories = catList; |
2312 | return count; | 2312 | return count; |
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | void CalendarView::manageCategories() | 2315 | void CalendarView::manageCategories() |
2316 | { | 2316 | { |
2317 | KOCatPrefs* cp = new KOCatPrefs(); | 2317 | KOCatPrefs* cp = new KOCatPrefs(); |
2318 | cp->show(); | 2318 | cp->show(); |
2319 | int w =cp->sizeHint().width() ; | 2319 | int w =cp->sizeHint().width() ; |
2320 | int h = cp->sizeHint().height() ; | 2320 | int h = cp->sizeHint().height() ; |
2321 | int dw = QApplication::desktop()->width(); | 2321 | int dw = QApplication::desktop()->width(); |
2322 | int dh = QApplication::desktop()->height(); | 2322 | int dh = QApplication::desktop()->height(); |
2323 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2323 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2324 | if ( !cp->exec() ) { | 2324 | if ( !cp->exec() ) { |
2325 | delete cp; | 2325 | delete cp; |
2326 | return; | 2326 | return; |
2327 | } | 2327 | } |
2328 | int count = 0; | 2328 | int count = 0; |
2329 | if ( cp->addCat() ) { | 2329 | if ( cp->addCat() ) { |
2330 | count = addCategories(); | 2330 | count = addCategories(); |
2331 | if ( count ) { | 2331 | if ( count ) { |
2332 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2332 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2333 | writeSettings(); | 2333 | writeSettings(); |
2334 | } else | 2334 | } else |
2335 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2335 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2336 | } else { | 2336 | } else { |
2337 | removeCategories(); | 2337 | removeCategories(); |
2338 | updateView(); | 2338 | updateView(); |
2339 | } | 2339 | } |
2340 | delete cp; | 2340 | delete cp; |
2341 | } | 2341 | } |
2342 | 2342 | ||
2343 | void CalendarView::beamIncidence(Incidence * Inc) | 2343 | void CalendarView::beamIncidence(Incidence * Inc) |
2344 | { | 2344 | { |
2345 | QPtrList<Incidence> delSel ; | 2345 | QPtrList<Incidence> delSel ; |
2346 | delSel.append(Inc); | 2346 | delSel.append(Inc); |
2347 | beamIncidenceList( delSel ); | 2347 | beamIncidenceList( delSel ); |
2348 | } | 2348 | } |
2349 | void CalendarView::beamCalendar() | 2349 | void CalendarView::beamCalendar() |
2350 | { | 2350 | { |
2351 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2351 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2352 | //qDebug("beamCalendar() "); | 2352 | //qDebug("beamCalendar() "); |
2353 | beamIncidenceList( delSel ); | 2353 | beamIncidenceList( delSel ); |
2354 | } | 2354 | } |
2355 | void CalendarView::beamFilteredCalendar() | 2355 | void CalendarView::beamFilteredCalendar() |
2356 | { | 2356 | { |
2357 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2357 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2358 | //qDebug("beamFilteredCalendar() "); | 2358 | //qDebug("beamFilteredCalendar() "); |
2359 | beamIncidenceList( delSel ); | 2359 | beamIncidenceList( delSel ); |
2360 | } | 2360 | } |
2361 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2361 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2362 | { | 2362 | { |
2363 | if ( beamDialog->exec () == QDialog::Rejected ) | 2363 | if ( beamDialog->exec () == QDialog::Rejected ) |
2364 | return; | 2364 | return; |
2365 | #ifdef DESKTOP_VERSION | 2365 | #ifdef DESKTOP_VERSION |
2366 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2366 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2367 | #else | 2367 | #else |
2368 | QString fn = "/tmp/kopibeamfile"; | 2368 | QString fn = "/tmp/kopibeamfile"; |
2369 | #endif | 2369 | #endif |
2370 | QString mes; | 2370 | QString mes; |
2371 | bool createbup = true; | 2371 | bool createbup = true; |
2372 | if ( createbup ) { | 2372 | if ( createbup ) { |
2373 | QString description = "\n"; | 2373 | QString description = "\n"; |
2374 | CalendarLocal* cal = new CalendarLocal(); | 2374 | CalendarLocal* cal = new CalendarLocal(); |
2375 | if ( beamDialog->beamLocal() ) | 2375 | if ( beamDialog->beamLocal() ) |
2376 | cal->setLocalTime(); | 2376 | cal->setLocalTime(); |
2377 | else | 2377 | else |
2378 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2378 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2379 | Incidence *incidence = delSel.first(); | 2379 | Incidence *incidence = delSel.first(); |
2380 | bool addText = false; | 2380 | bool addText = false; |
2381 | if ( delSel.count() < 10 ) | 2381 | if ( delSel.count() < 10 ) |
2382 | addText = true; | 2382 | addText = true; |
2383 | else { | 2383 | else { |
2384 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2384 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2385 | } | 2385 | } |
2386 | while ( incidence ) { | 2386 | while ( incidence ) { |
2387 | Incidence *in = incidence->clone(); | 2387 | Incidence *in = incidence->clone(); |
2388 | if ( ! in->summary().isEmpty() ) { | 2388 | if ( ! in->summary().isEmpty() ) { |
2389 | in->setDescription(""); | 2389 | in->setDescription(""); |
2390 | } else { | 2390 | } else { |
2391 | in->setSummary( in->description().left(20)); | 2391 | in->setSummary( in->description().left(20)); |
2392 | in->setDescription(""); | 2392 | in->setDescription(""); |
2393 | } | 2393 | } |
2394 | if ( addText ) | 2394 | if ( addText ) |
2395 | description += in->summary() + "\n"; | 2395 | description += in->summary() + "\n"; |
2396 | cal->addIncidence( in ); | 2396 | cal->addIncidence( in ); |
2397 | incidence = delSel.next(); | 2397 | incidence = delSel.next(); |
2398 | } | 2398 | } |
2399 | if ( beamDialog->beamVcal() ) { | 2399 | if ( beamDialog->beamVcal() ) { |
2400 | fn += ".vcs"; | 2400 | fn += ".vcs"; |
2401 | FileStorage storage( cal, fn, new VCalFormat ); | 2401 | FileStorage storage( cal, fn, new VCalFormat ); |
2402 | storage.save(); | 2402 | storage.save(); |
2403 | } else { | 2403 | } else { |
2404 | fn += ".ics"; | 2404 | fn += ".ics"; |
2405 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2405 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2406 | storage.save(); | 2406 | storage.save(); |
2407 | } | 2407 | } |
2408 | delete cal; | 2408 | delete cal; |
2409 | mes = i18n("KO/Pi: Ready for beaming"); | 2409 | mes = i18n("KO/Pi: Ready for beaming"); |
2410 | topLevelWidget()->setCaption(mes); | 2410 | topLevelWidget()->setCaption(mes); |
2411 | KApplication::convert2latin1( fn ); | 2411 | KApplication::convert2latin1( fn ); |
2412 | #ifndef DESKTOP_VERSION | 2412 | #ifndef DESKTOP_VERSION |
2413 | Ir *ir = new Ir( this ); | 2413 | Ir *ir = new Ir( this ); |
2414 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2414 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2415 | ir->send( fn, description, "text/x-vCalendar" ); | 2415 | ir->send( fn, description, "text/x-vCalendar" ); |
2416 | #endif | 2416 | #endif |
2417 | } | 2417 | } |
2418 | } | 2418 | } |
2419 | void CalendarView::beamDone( Ir *ir ) | 2419 | void CalendarView::beamDone( Ir *ir ) |
2420 | { | 2420 | { |
2421 | #ifndef DESKTOP_VERSION | 2421 | #ifndef DESKTOP_VERSION |
2422 | delete ir; | 2422 | delete ir; |
2423 | #endif | 2423 | #endif |
2424 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2424 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2425 | topLevelWidget()->raise(); | 2425 | topLevelWidget()->raise(); |
2426 | } | 2426 | } |
2427 | 2427 | ||
2428 | void CalendarView::moveIncidence(Incidence * inc ) | 2428 | void CalendarView::moveIncidence(Incidence * inc ) |
2429 | { | 2429 | { |
2430 | if ( !inc ) return; | 2430 | if ( !inc ) return; |
2431 | // qDebug("showDatePickerForIncidence( ) "); | 2431 | // qDebug("showDatePickerForIncidence( ) "); |
2432 | if ( mDateFrame->isVisible() ) | 2432 | if ( mDateFrame->isVisible() ) |
2433 | mDateFrame->hide(); | 2433 | mDateFrame->hide(); |
2434 | else { | 2434 | else { |
2435 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2435 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2436 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2436 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2437 | int dw = QApplication::desktop()->width(); | 2437 | int dw = QApplication::desktop()->width(); |
2438 | int dh = QApplication::desktop()->height(); | 2438 | int dh = QApplication::desktop()->height(); |
2439 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2439 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2440 | mDateFrame->show(); | 2440 | mDateFrame->show(); |
2441 | } | 2441 | } |
2442 | mDatePickerMode = 2; | 2442 | mDatePickerMode = 2; |
2443 | mMoveIncidence = inc ; | 2443 | mMoveIncidence = inc ; |
2444 | QDate da; | 2444 | QDate da; |
2445 | if ( mMoveIncidence->type() == "Todo" ) { | 2445 | if ( mMoveIncidence->type() == "Todo" ) { |
2446 | Todo * to = (Todo *) mMoveIncidence; | 2446 | Todo * to = (Todo *) mMoveIncidence; |
2447 | if ( to->hasDueDate() ) | 2447 | if ( to->hasDueDate() ) |
2448 | da = to->dtDue().date(); | 2448 | da = to->dtDue().date(); |
2449 | else | 2449 | else |
2450 | da = QDate::currentDate(); | 2450 | da = QDate::currentDate(); |
2451 | } else { | 2451 | } else { |
2452 | da = mMoveIncidence->dtStart().date(); | 2452 | da = mMoveIncidence->dtStart().date(); |
2453 | } | 2453 | } |
2454 | //PENDING set date for recurring incidence to date of recurrence | 2454 | //PENDING set date for recurring incidence to date of recurrence |
2455 | //mMoveIncidenceOldDate; | 2455 | //mMoveIncidenceOldDate; |
2456 | mDatePicker->setDate( da ); | 2456 | mDatePicker->setDate( da ); |
2457 | } | 2457 | } |
2458 | void CalendarView::showDatePicker( ) | 2458 | void CalendarView::showDatePicker( ) |
2459 | { | 2459 | { |
2460 | //qDebug("CalendarView::showDatePicker( ) "); | 2460 | //qDebug("CalendarView::showDatePicker( ) "); |
2461 | if ( mDateFrame->isVisible() ) | 2461 | if ( mDateFrame->isVisible() ) |
2462 | mDateFrame->hide(); | 2462 | mDateFrame->hide(); |
2463 | else { | 2463 | else { |
2464 | int w =mDatePicker->sizeHint().width() ; | 2464 | int w =mDatePicker->sizeHint().width() ; |
2465 | int h = mDatePicker->sizeHint().height() ; | 2465 | int h = mDatePicker->sizeHint().height() ; |
2466 | int dw = QApplication::desktop()->width(); | 2466 | int dw = QApplication::desktop()->width(); |
2467 | int dh = QApplication::desktop()->height(); | 2467 | int dh = QApplication::desktop()->height(); |
2468 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2468 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2469 | mDateFrame->show(); | 2469 | mDateFrame->show(); |
2470 | } | 2470 | } |
2471 | mDatePickerMode = 1; | 2471 | mDatePickerMode = 1; |
2472 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2472 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2473 | } | 2473 | } |
2474 | 2474 | ||
2475 | void CalendarView::showEventEditor() | 2475 | void CalendarView::showEventEditor() |
2476 | { | 2476 | { |
2477 | #ifdef DESKTOP_VERSION | 2477 | #ifdef DESKTOP_VERSION |
2478 | mEventEditor->show(); | 2478 | mEventEditor->show(); |
2479 | #else | 2479 | #else |
2480 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2480 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2481 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2481 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2482 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2482 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2483 | delete mEventEditor; | 2483 | delete mEventEditor; |
2484 | mEventEditor = mDialogManager->getEventEditor(); | 2484 | mEventEditor = mDialogManager->getEventEditor(); |
2485 | } | 2485 | } |
2486 | mEventEditor->showMaximized(); | 2486 | mEventEditor->showMaximized(); |
2487 | #endif | 2487 | #endif |
2488 | } | 2488 | } |
2489 | void CalendarView::showTodoEditor() | 2489 | void CalendarView::showTodoEditor() |
2490 | { | 2490 | { |
2491 | #ifdef DESKTOP_VERSION | 2491 | #ifdef DESKTOP_VERSION |
2492 | mTodoEditor->show(); | 2492 | mTodoEditor->show(); |
2493 | #else | 2493 | #else |
2494 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2494 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2495 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2495 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2496 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2496 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2497 | delete mTodoEditor; | 2497 | delete mTodoEditor; |
2498 | mTodoEditor = mDialogManager->getTodoEditor(); | 2498 | mTodoEditor = mDialogManager->getTodoEditor(); |
2499 | } | 2499 | } |
2500 | mTodoEditor->showMaximized(); | 2500 | mTodoEditor->showMaximized(); |
2501 | #endif | 2501 | #endif |
2502 | } | 2502 | } |
2503 | 2503 | ||
2504 | void CalendarView::cloneIncidence() | 2504 | void CalendarView::cloneIncidence() |
2505 | { | 2505 | { |
2506 | Incidence *incidence = currentSelection(); | 2506 | Incidence *incidence = currentSelection(); |
2507 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2507 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2508 | if ( incidence ) { | 2508 | if ( incidence ) { |
2509 | cloneIncidence(incidence); | 2509 | cloneIncidence(incidence); |
2510 | } | 2510 | } |
2511 | } | 2511 | } |
2512 | void CalendarView::moveIncidence() | 2512 | void CalendarView::moveIncidence() |
2513 | { | 2513 | { |
2514 | Incidence *incidence = currentSelection(); | 2514 | Incidence *incidence = currentSelection(); |
2515 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2515 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2516 | if ( incidence ) { | 2516 | if ( incidence ) { |
2517 | moveIncidence(incidence); | 2517 | moveIncidence(incidence); |
2518 | } | 2518 | } |
2519 | } | 2519 | } |
2520 | void CalendarView::beamIncidence() | 2520 | void CalendarView::beamIncidence() |
2521 | { | 2521 | { |
2522 | Incidence *incidence = currentSelection(); | 2522 | Incidence *incidence = currentSelection(); |
2523 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2523 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2524 | if ( incidence ) { | 2524 | if ( incidence ) { |
2525 | beamIncidence(incidence); | 2525 | beamIncidence(incidence); |
2526 | } | 2526 | } |
2527 | } | 2527 | } |
2528 | void CalendarView::toggleCancelIncidence() | 2528 | void CalendarView::toggleCancelIncidence() |
2529 | { | 2529 | { |
2530 | Incidence *incidence = currentSelection(); | 2530 | Incidence *incidence = currentSelection(); |
2531 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2531 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2532 | if ( incidence ) { | 2532 | if ( incidence ) { |
2533 | cancelIncidence(incidence); | 2533 | cancelIncidence(incidence); |
2534 | } | 2534 | } |
2535 | } | 2535 | } |
2536 | 2536 | ||
2537 | 2537 | ||
2538 | void CalendarView::cancelIncidence(Incidence * inc ) | 2538 | void CalendarView::cancelIncidence(Incidence * inc ) |
2539 | { | 2539 | { |
2540 | inc->setCancelled( ! inc->cancelled() ); | 2540 | inc->setCancelled( ! inc->cancelled() ); |
2541 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2541 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2542 | updateView(); | 2542 | updateView(); |
2543 | } | 2543 | } |
2544 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2544 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2545 | { | 2545 | { |
2546 | Incidence * newInc = orgInc->clone(); | 2546 | Incidence * newInc = orgInc->clone(); |
2547 | newInc->recreate(); | 2547 | newInc->recreate(); |
2548 | 2548 | ||
2549 | if ( newInc->type() == "Todo" ) { | 2549 | if ( newInc->type() == "Todo" ) { |
2550 | Todo* t = (Todo*) newInc; | 2550 | Todo* t = (Todo*) newInc; |
2551 | showTodoEditor(); | 2551 | showTodoEditor(); |
2552 | mTodoEditor->editTodo( t ); | 2552 | mTodoEditor->editTodo( t ); |
2553 | if ( mTodoEditor->exec() ) { | 2553 | if ( mTodoEditor->exec() ) { |
2554 | mCalendar->addTodo( t ); | 2554 | mCalendar->addTodo( t ); |
2555 | updateView(); | 2555 | updateView(); |
2556 | } else { | 2556 | } else { |
2557 | delete t; | 2557 | delete t; |
2558 | } | 2558 | } |
2559 | } | 2559 | } |
2560 | else { | 2560 | else { |
2561 | Event* e = (Event*) newInc; | 2561 | Event* e = (Event*) newInc; |
2562 | showEventEditor(); | 2562 | showEventEditor(); |
2563 | mEventEditor->editEvent( e ); | 2563 | mEventEditor->editEvent( e ); |
2564 | if ( mEventEditor->exec() ) { | 2564 | if ( mEventEditor->exec() ) { |
2565 | mCalendar->addEvent( e ); | 2565 | mCalendar->addEvent( e ); |
2566 | updateView(); | 2566 | updateView(); |
2567 | } else { | 2567 | } else { |
2568 | delete e; | 2568 | delete e; |
2569 | } | 2569 | } |
2570 | } | 2570 | } |
2571 | } | 2571 | } |
2572 | 2572 | ||
2573 | void CalendarView::newEvent() | 2573 | void CalendarView::newEvent() |
2574 | { | 2574 | { |
2575 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2575 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2576 | KOAgendaView *aView = mViewManager->agendaView(); | 2576 | KOAgendaView *aView = mViewManager->agendaView(); |
2577 | if (aView) { | 2577 | if (aView) { |
2578 | if (aView->selectionStart().isValid()) { | 2578 | if (aView->selectionStart().isValid()) { |
2579 | if (aView->selectedIsAllDay()) { | 2579 | if (aView->selectedIsAllDay()) { |
2580 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2580 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2581 | } else { | 2581 | } else { |
2582 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2582 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2583 | } | 2583 | } |
2584 | return; | 2584 | return; |
2585 | } | 2585 | } |
2586 | } | 2586 | } |
2587 | 2587 | ||
2588 | QDate date = mNavigator->selectedDates().first(); | 2588 | QDate date = mNavigator->selectedDates().first(); |
2589 | QDateTime current = QDateTime::currentDateTime(); | 2589 | QDateTime current = QDateTime::currentDateTime(); |
2590 | if ( date <= current.date() ) { | 2590 | if ( date <= current.date() ) { |
2591 | int hour = current.time().hour() +1; | 2591 | int hour = current.time().hour() +1; |
2592 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2592 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2593 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2593 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2594 | } else | 2594 | } else |
2595 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2595 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2596 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2596 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2597 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2597 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2598 | } | 2598 | } |
2599 | 2599 | ||
2600 | void CalendarView::newEvent(QDateTime fh) | 2600 | void CalendarView::newEvent(QDateTime fh) |
2601 | { | 2601 | { |
2602 | newEvent(fh, | 2602 | newEvent(fh, |
2603 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2603 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2604 | } | 2604 | } |
2605 | 2605 | ||
2606 | void CalendarView::newEvent(QDate dt) | 2606 | void CalendarView::newEvent(QDate dt) |
2607 | { | 2607 | { |
2608 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2608 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2609 | QDateTime(dt, QTime(0,0,0)), true); | 2609 | QDateTime(dt, QTime(0,0,0)), true); |
2610 | } | 2610 | } |
2611 | 2611 | ||
2612 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2612 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2613 | { | 2613 | { |
2614 | 2614 | ||
2615 | showEventEditor(); | 2615 | showEventEditor(); |
2616 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2616 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2617 | if ( mFilterView->filtersEnabled() ) { | 2617 | if ( mFilterView->filtersEnabled() ) { |
2618 | CalFilter *filter = mFilterView->selectedFilter(); | 2618 | CalFilter *filter = mFilterView->selectedFilter(); |
2619 | if (filter && filter->showCategories()) { | 2619 | if (filter && filter->showCategories()) { |
2620 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2620 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2621 | } | 2621 | } |
2622 | if ( filter ) | 2622 | if ( filter ) |
2623 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2623 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2624 | } | 2624 | } |
2625 | } | 2625 | } |
2626 | void CalendarView::todoAdded(Todo * t) | 2626 | void CalendarView::todoAdded(Todo * t) |
2627 | { | 2627 | { |
2628 | 2628 | ||
2629 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2629 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2630 | updateTodoViews(); | 2630 | updateTodoViews(); |
2631 | } | 2631 | } |
2632 | void CalendarView::todoChanged(Todo * t) | 2632 | void CalendarView::todoChanged(Todo * t) |
2633 | { | 2633 | { |
2634 | emit todoModified( t, 4 ); | 2634 | emit todoModified( t, 4 ); |
2635 | // updateTodoViews(); | 2635 | // updateTodoViews(); |
2636 | } | 2636 | } |
2637 | void CalendarView::todoToBeDeleted(Todo *) | 2637 | void CalendarView::todoToBeDeleted(Todo *) |
2638 | { | 2638 | { |
2639 | //qDebug("todoToBeDeleted(Todo *) "); | 2639 | //qDebug("todoToBeDeleted(Todo *) "); |
2640 | updateTodoViews(); | 2640 | updateTodoViews(); |
2641 | } | 2641 | } |
2642 | void CalendarView::todoDeleted() | 2642 | void CalendarView::todoDeleted() |
2643 | { | 2643 | { |
2644 | //qDebug(" todoDeleted()"); | 2644 | //qDebug(" todoDeleted()"); |
2645 | updateTodoViews(); | 2645 | updateTodoViews(); |
2646 | } | 2646 | } |
2647 | 2647 | ||
2648 | 2648 | ||
2649 | 2649 | ||
2650 | void CalendarView::newTodo() | 2650 | void CalendarView::newTodo() |
2651 | { | 2651 | { |
2652 | 2652 | ||
2653 | showTodoEditor(); | 2653 | showTodoEditor(); |
2654 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2654 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2655 | if ( mFilterView->filtersEnabled() ) { | 2655 | if ( mFilterView->filtersEnabled() ) { |
2656 | CalFilter *filter = mFilterView->selectedFilter(); | 2656 | CalFilter *filter = mFilterView->selectedFilter(); |
2657 | if (filter && filter->showCategories()) { | 2657 | if (filter && filter->showCategories()) { |
2658 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2658 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2659 | } | 2659 | } |
2660 | if ( filter ) | 2660 | if ( filter ) |
2661 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2661 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2662 | } | 2662 | } |
2663 | } | 2663 | } |
2664 | 2664 | ||
2665 | void CalendarView::newSubTodo() | 2665 | void CalendarView::newSubTodo() |
2666 | { | 2666 | { |
2667 | Todo *todo = selectedTodo(); | 2667 | Todo *todo = selectedTodo(); |
2668 | if ( todo ) newSubTodo( todo ); | 2668 | if ( todo ) newSubTodo( todo ); |
2669 | } | 2669 | } |
2670 | 2670 | ||
2671 | void CalendarView::newSubTodo(Todo *parentEvent) | 2671 | void CalendarView::newSubTodo(Todo *parentEvent) |
2672 | { | 2672 | { |
2673 | 2673 | ||
2674 | showTodoEditor(); | 2674 | showTodoEditor(); |
2675 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2675 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2676 | } | 2676 | } |
2677 | 2677 | ||
2678 | void CalendarView::newFloatingEvent() | 2678 | void CalendarView::newFloatingEvent() |
2679 | { | 2679 | { |
2680 | DateList tmpList = mNavigator->selectedDates(); | 2680 | DateList tmpList = mNavigator->selectedDates(); |
2681 | QDate date = tmpList.first(); | 2681 | QDate date = tmpList.first(); |
2682 | 2682 | ||
2683 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2683 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2684 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2684 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2685 | } | 2685 | } |
2686 | 2686 | ||
2687 | 2687 | ||
2688 | void CalendarView::editEvent( Event *event ) | 2688 | void CalendarView::editEvent( Event *event ) |
2689 | { | 2689 | { |
2690 | 2690 | ||
2691 | if ( !event ) return; | 2691 | if ( !event ) return; |
2692 | if ( event->isReadOnly() ) { | 2692 | if ( event->isReadOnly() ) { |
2693 | showEvent( event ); | 2693 | showEvent( event ); |
2694 | return; | 2694 | return; |
2695 | } | 2695 | } |
2696 | showEventEditor(); | 2696 | showEventEditor(); |
2697 | mEventEditor->editEvent( event , mFlagEditDescription); | 2697 | mEventEditor->editEvent( event , mFlagEditDescription); |
2698 | } | 2698 | } |
2699 | void CalendarView::editJournal( Journal *jour ) | 2699 | void CalendarView::editJournal( Journal *jour ) |
2700 | { | 2700 | { |
2701 | if ( !jour ) return; | 2701 | if ( !jour ) return; |
2702 | mDialogManager->hideSearchDialog(); | 2702 | mDialogManager->hideSearchDialog(); |
2703 | mViewManager->showJournalView(); | 2703 | mViewManager->showJournalView(); |
2704 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2704 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2705 | } | 2705 | } |
2706 | void CalendarView::editTodo( Todo *todo ) | 2706 | void CalendarView::editTodo( Todo *todo ) |
2707 | { | 2707 | { |
2708 | if ( !todo ) return; | 2708 | if ( !todo ) return; |
2709 | 2709 | ||
2710 | if ( todo->isReadOnly() ) { | 2710 | if ( todo->isReadOnly() ) { |
2711 | showTodo( todo ); | 2711 | showTodo( todo ); |
2712 | return; | 2712 | return; |
2713 | } | 2713 | } |
2714 | showTodoEditor(); | 2714 | showTodoEditor(); |
2715 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2715 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2716 | 2716 | ||
2717 | } | 2717 | } |
2718 | 2718 | ||
2719 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2719 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2720 | { | 2720 | { |
2721 | if ( !mEventViewerDialog ) { | 2721 | if ( !mEventViewerDialog ) { |
2722 | mEventViewerDialog = new KOEventViewerDialog(this); | 2722 | mEventViewerDialog = new KOEventViewerDialog(this); |
2723 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2723 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2724 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2724 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2725 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2725 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2726 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2726 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2727 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2727 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2728 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2728 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2729 | mEventViewerDialog->resize( 640, 480 ); | 2729 | mEventViewerDialog->resize( 640, 480 ); |
2730 | 2730 | ||
2731 | } | 2731 | } |
2732 | return mEventViewerDialog; | 2732 | return mEventViewerDialog; |
2733 | } | 2733 | } |
2734 | void CalendarView::showEvent(Event *event) | 2734 | void CalendarView::showEvent(Event *event) |
2735 | { | 2735 | { |
2736 | getEventViewerDialog()->setEvent(event); | 2736 | getEventViewerDialog()->setEvent(event); |
2737 | getEventViewerDialog()->showMe(); | 2737 | getEventViewerDialog()->showMe(); |
2738 | } | 2738 | } |
2739 | 2739 | ||
2740 | void CalendarView::showTodo(Todo *event) | 2740 | void CalendarView::showTodo(Todo *event) |
2741 | { | 2741 | { |
2742 | getEventViewerDialog()->setTodo(event); | 2742 | getEventViewerDialog()->setTodo(event); |
2743 | getEventViewerDialog()->showMe(); | 2743 | getEventViewerDialog()->showMe(); |
2744 | } | 2744 | } |
2745 | void CalendarView::showJournal( Journal *jour ) | 2745 | void CalendarView::showJournal( Journal *jour ) |
2746 | { | 2746 | { |
2747 | getEventViewerDialog()->setJournal(jour); | 2747 | getEventViewerDialog()->setJournal(jour); |
2748 | getEventViewerDialog()->showMe(); | 2748 | getEventViewerDialog()->showMe(); |
2749 | 2749 | ||
2750 | } | 2750 | } |
2751 | // void CalendarView::todoModified (Todo *event, int changed) | 2751 | // void CalendarView::todoModified (Todo *event, int changed) |
2752 | // { | 2752 | // { |
2753 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2753 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2754 | // // kdDebug() << "Todo modified and open" << endl; | 2754 | // // kdDebug() << "Todo modified and open" << endl; |
2755 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2755 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2756 | // // temp->modified (changed); | 2756 | // // temp->modified (changed); |
2757 | 2757 | ||
2758 | // // } | 2758 | // // } |
2759 | 2759 | ||
2760 | // mViewManager->updateView(); | 2760 | // mViewManager->updateView(); |
2761 | // } | 2761 | // } |
2762 | 2762 | ||
2763 | void CalendarView::appointment_show() | 2763 | void CalendarView::appointment_show() |
2764 | { | 2764 | { |
2765 | Event *anEvent = 0; | 2765 | Event *anEvent = 0; |
2766 | 2766 | ||
2767 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2767 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2768 | 2768 | ||
2769 | if (mViewManager->currentView()->isEventView()) { | 2769 | if (mViewManager->currentView()->isEventView()) { |
2770 | if ( incidence && incidence->type() == "Event" ) { | 2770 | if ( incidence && incidence->type() == "Event" ) { |
2771 | anEvent = static_cast<Event *>(incidence); | 2771 | anEvent = static_cast<Event *>(incidence); |
2772 | } | 2772 | } |
2773 | } | 2773 | } |
2774 | 2774 | ||
2775 | if (!anEvent) { | 2775 | if (!anEvent) { |
2776 | KNotifyClient::beep(); | 2776 | KNotifyClient::beep(); |
2777 | return; | 2777 | return; |
2778 | } | 2778 | } |
2779 | 2779 | ||
2780 | showEvent(anEvent); | 2780 | showEvent(anEvent); |
2781 | } | 2781 | } |
2782 | 2782 | ||
2783 | void CalendarView::appointment_edit() | 2783 | void CalendarView::appointment_edit() |
2784 | { | 2784 | { |
2785 | Event *anEvent = 0; | 2785 | Event *anEvent = 0; |
2786 | 2786 | ||
2787 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2787 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2788 | 2788 | ||
2789 | if (mViewManager->currentView()->isEventView()) { | 2789 | if (mViewManager->currentView()->isEventView()) { |
2790 | if ( incidence && incidence->type() == "Event" ) { | 2790 | if ( incidence && incidence->type() == "Event" ) { |
2791 | anEvent = static_cast<Event *>(incidence); | 2791 | anEvent = static_cast<Event *>(incidence); |
2792 | } | 2792 | } |
2793 | } | 2793 | } |
2794 | 2794 | ||
2795 | if (!anEvent) { | 2795 | if (!anEvent) { |
2796 | KNotifyClient::beep(); | 2796 | KNotifyClient::beep(); |
2797 | return; | 2797 | return; |
2798 | } | 2798 | } |
2799 | 2799 | ||
2800 | editEvent(anEvent); | 2800 | editEvent(anEvent); |
2801 | } | 2801 | } |
2802 | 2802 | ||
2803 | void CalendarView::appointment_delete() | 2803 | void CalendarView::appointment_delete() |
2804 | { | 2804 | { |
2805 | Event *anEvent = 0; | 2805 | Event *anEvent = 0; |
2806 | 2806 | ||
2807 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2807 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2808 | 2808 | ||
2809 | if (mViewManager->currentView()->isEventView()) { | 2809 | if (mViewManager->currentView()->isEventView()) { |
2810 | if ( incidence && incidence->type() == "Event" ) { | 2810 | if ( incidence && incidence->type() == "Event" ) { |
2811 | anEvent = static_cast<Event *>(incidence); | 2811 | anEvent = static_cast<Event *>(incidence); |
2812 | } | 2812 | } |
2813 | } | 2813 | } |
2814 | 2814 | ||
2815 | if (!anEvent) { | 2815 | if (!anEvent) { |
2816 | KNotifyClient::beep(); | 2816 | KNotifyClient::beep(); |
2817 | return; | 2817 | return; |
2818 | } | 2818 | } |
2819 | 2819 | ||
2820 | deleteEvent(anEvent); | 2820 | deleteEvent(anEvent); |
2821 | } | 2821 | } |
2822 | 2822 | ||
2823 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2823 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2824 | { | 2824 | { |
2825 | if (!sub) return; | 2825 | if (!sub) return; |
2826 | if (!parent) return; | 2826 | if (!parent) return; |
2827 | if ( sub->relatedTo() ) | 2827 | if ( sub->relatedTo() ) |
2828 | sub->relatedTo()->removeRelation(sub); | 2828 | sub->relatedTo()->removeRelation(sub); |
2829 | sub->setRelatedTo(parent); | 2829 | sub->setRelatedTo(parent); |
2830 | sub->setRelatedToUid(parent->uid()); | 2830 | sub->setRelatedToUid(parent->uid()); |
2831 | parent->addRelation(sub); | 2831 | parent->addRelation(sub); |
2832 | sub->updated(); | 2832 | sub->updated(); |
2833 | parent->updated(); | 2833 | parent->updated(); |
2834 | setModified(true); | 2834 | setModified(true); |
2835 | updateView(); | 2835 | updateView(); |
2836 | } | 2836 | } |
2837 | void CalendarView::todo_unsub(Todo *anTodo ) | 2837 | void CalendarView::todo_unsub(Todo *anTodo ) |
2838 | { | 2838 | { |
2839 | // Todo *anTodo = selectedTodo(); | 2839 | // Todo *anTodo = selectedTodo(); |
2840 | if (!anTodo) return; | 2840 | if (!anTodo) return; |
2841 | if (!anTodo->relatedTo()) return; | 2841 | if (!anTodo->relatedTo()) return; |
2842 | anTodo->relatedTo()->removeRelation(anTodo); | 2842 | anTodo->relatedTo()->removeRelation(anTodo); |
2843 | anTodo->setRelatedTo(0); | 2843 | anTodo->setRelatedTo(0); |
2844 | anTodo->updated(); | 2844 | anTodo->updated(); |
2845 | anTodo->setRelatedToUid(""); | 2845 | anTodo->setRelatedToUid(""); |
2846 | setModified(true); | 2846 | setModified(true); |
2847 | updateView(); | 2847 | updateView(); |
2848 | } | 2848 | } |
2849 | 2849 | ||
2850 | void CalendarView::deleteTodo(Todo *todo) | 2850 | void CalendarView::deleteTodo(Todo *todo) |
2851 | { | 2851 | { |
2852 | if (!todo) { | 2852 | if (!todo) { |
2853 | KNotifyClient::beep(); | 2853 | KNotifyClient::beep(); |
2854 | return; | 2854 | return; |
2855 | } | 2855 | } |
2856 | if (KOPrefs::instance()->mConfirm) { | 2856 | if (KOPrefs::instance()->mConfirm) { |
2857 | switch (msgItemDelete()) { | 2857 | switch (msgItemDelete()) { |
2858 | case KMessageBox::Continue: // OK | 2858 | case KMessageBox::Continue: // OK |
2859 | if (!todo->relations().isEmpty()) { | 2859 | if (!todo->relations().isEmpty()) { |
2860 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2860 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2861 | i18n("Delete To-Do")); | 2861 | i18n("Delete To-Do")); |
2862 | } else { | 2862 | } else { |
2863 | checkExternalId( todo ); | 2863 | checkExternalId( todo ); |
2864 | calendar()->deleteTodo(todo); | 2864 | calendar()->deleteTodo(todo); |
2865 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2865 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2866 | updateView(); | 2866 | updateView(); |
2867 | } | 2867 | } |
2868 | break; | 2868 | break; |
2869 | } // switch | 2869 | } // switch |
2870 | } else { | 2870 | } else { |
2871 | if (!todo->relations().isEmpty()) { | 2871 | if (!todo->relations().isEmpty()) { |
2872 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2872 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2873 | i18n("Delete To-Do")); | 2873 | i18n("Delete To-Do")); |
2874 | } else { | 2874 | } else { |
2875 | checkExternalId( todo ); | 2875 | checkExternalId( todo ); |
2876 | mCalendar->deleteTodo(todo); | 2876 | mCalendar->deleteTodo(todo); |
2877 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2877 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2878 | updateView(); | 2878 | updateView(); |
2879 | } | 2879 | } |
2880 | } | 2880 | } |
2881 | emit updateSearchDialog(); | 2881 | emit updateSearchDialog(); |
2882 | } | 2882 | } |
2883 | void CalendarView::deleteJournal(Journal *jour) | 2883 | void CalendarView::deleteJournal(Journal *jour) |
2884 | { | 2884 | { |
2885 | if (!jour) { | 2885 | if (!jour) { |
2886 | KNotifyClient::beep(); | 2886 | KNotifyClient::beep(); |
2887 | return; | 2887 | return; |
2888 | } | 2888 | } |
2889 | if (KOPrefs::instance()->mConfirm) { | 2889 | if (KOPrefs::instance()->mConfirm) { |
2890 | switch (msgItemDelete()) { | 2890 | switch (msgItemDelete()) { |
2891 | case KMessageBox::Continue: // OK | 2891 | case KMessageBox::Continue: // OK |
2892 | calendar()->deleteJournal(jour); | 2892 | calendar()->deleteJournal(jour); |
2893 | updateView(); | 2893 | updateView(); |
2894 | break; | 2894 | break; |
2895 | } // switch | 2895 | } // switch |
2896 | } else { | 2896 | } else { |
2897 | calendar()->deleteJournal(jour);; | 2897 | calendar()->deleteJournal(jour);; |
2898 | updateView(); | 2898 | updateView(); |
2899 | } | 2899 | } |
2900 | emit updateSearchDialog(); | 2900 | emit updateSearchDialog(); |
2901 | } | 2901 | } |
2902 | 2902 | ||
2903 | void CalendarView::deleteEvent(Event *anEvent) | 2903 | void CalendarView::deleteEvent(Event *anEvent) |
2904 | { | 2904 | { |
2905 | if (!anEvent) { | 2905 | if (!anEvent) { |
2906 | KNotifyClient::beep(); | 2906 | KNotifyClient::beep(); |
2907 | return; | 2907 | return; |
2908 | } | 2908 | } |
2909 | 2909 | ||
2910 | if (anEvent->recurrence()->doesRecur()) { | 2910 | if (anEvent->recurrence()->doesRecur()) { |
2911 | QDate itemDate = mViewManager->currentSelectionDate(); | 2911 | QDate itemDate = mViewManager->currentSelectionDate(); |
2912 | int km; | 2912 | int km; |
2913 | if (!itemDate.isValid()) { | 2913 | if (!itemDate.isValid()) { |
2914 | //kdDebug() << "Date Not Valid" << endl; | 2914 | //kdDebug() << "Date Not Valid" << endl; |
2915 | if (KOPrefs::instance()->mConfirm) { | 2915 | if (KOPrefs::instance()->mConfirm) { |
2916 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2916 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2917 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2917 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2918 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2918 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2919 | if ( km == KMessageBox::Continue ) | 2919 | if ( km == KMessageBox::Continue ) |
2920 | km = KMessageBox::No; // No = all below | 2920 | km = KMessageBox::No; // No = all below |
2921 | } else | 2921 | } else |
2922 | km = KMessageBox::No; | 2922 | km = KMessageBox::No; |
2923 | } else { | 2923 | } else { |
2924 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2924 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2925 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2925 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2926 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2926 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2927 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2927 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2928 | i18n("All")); | 2928 | i18n("All")); |
2929 | } | 2929 | } |
2930 | switch(km) { | 2930 | switch(km) { |
2931 | 2931 | ||
2932 | case KMessageBox::No: // Continue // all | 2932 | case KMessageBox::No: // Continue // all |
2933 | //qDebug("KMessageBox::No "); | 2933 | //qDebug("KMessageBox::No "); |
2934 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2934 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2935 | schedule(Scheduler::Cancel,anEvent); | 2935 | schedule(Scheduler::Cancel,anEvent); |
2936 | 2936 | ||
2937 | checkExternalId( anEvent); | 2937 | checkExternalId( anEvent); |
2938 | mCalendar->deleteEvent(anEvent); | 2938 | mCalendar->deleteEvent(anEvent); |
2939 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2939 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2940 | break; | 2940 | break; |
2941 | 2941 | ||
2942 | // Disabled because it does not work | 2942 | // Disabled because it does not work |
2943 | //#if 0 | 2943 | //#if 0 |
2944 | case KMessageBox::Yes: // just this one | 2944 | case KMessageBox::Yes: // just this one |
2945 | //QDate qd = mNavigator->selectedDates().first(); | 2945 | //QDate qd = mNavigator->selectedDates().first(); |
2946 | //if (!qd.isValid()) { | 2946 | //if (!qd.isValid()) { |
2947 | // kdDebug() << "no date selected, or invalid date" << endl; | 2947 | // kdDebug() << "no date selected, or invalid date" << endl; |
2948 | // KNotifyClient::beep(); | 2948 | // KNotifyClient::beep(); |
2949 | // return; | 2949 | // return; |
2950 | //} | 2950 | //} |
2951 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2951 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2952 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2952 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2953 | anEvent->addExDate(itemDate); | 2953 | anEvent->addExDate(itemDate); |
2954 | int duration = anEvent->recurrence()->duration(); | 2954 | int duration = anEvent->recurrence()->duration(); |
2955 | if ( duration > 0 ) { | 2955 | if ( duration > 0 ) { |
2956 | anEvent->recurrence()->setDuration( duration - 1 ); | 2956 | anEvent->recurrence()->setDuration( duration - 1 ); |
2957 | } | 2957 | } |
2958 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2958 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2959 | } | 2959 | } |
2960 | break; | 2960 | break; |
2961 | //#endif | 2961 | //#endif |
2962 | } // switch | 2962 | } // switch |
2963 | } else { | 2963 | } else { |
2964 | if (KOPrefs::instance()->mConfirm) { | 2964 | if (KOPrefs::instance()->mConfirm) { |
2965 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2965 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2966 | i18n("\nAre you sure you want\nto delete this event?"), | 2966 | i18n("\nAre you sure you want\nto delete this event?"), |
2967 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2967 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2968 | case KMessageBox::Continue: // OK | 2968 | case KMessageBox::Continue: // OK |
2969 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2969 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2970 | schedule(Scheduler::Cancel,anEvent); | 2970 | schedule(Scheduler::Cancel,anEvent); |
2971 | checkExternalId( anEvent); | 2971 | checkExternalId( anEvent); |
2972 | mCalendar->deleteEvent(anEvent); | 2972 | mCalendar->deleteEvent(anEvent); |
2973 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2973 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2974 | break; | 2974 | break; |
2975 | } // switch | 2975 | } // switch |
2976 | } else { | 2976 | } else { |
2977 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2977 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2978 | schedule(Scheduler::Cancel,anEvent); | 2978 | schedule(Scheduler::Cancel,anEvent); |
2979 | checkExternalId( anEvent); | 2979 | checkExternalId( anEvent); |
2980 | mCalendar->deleteEvent(anEvent); | 2980 | mCalendar->deleteEvent(anEvent); |
2981 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2981 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2982 | } | 2982 | } |
2983 | } // if-else | 2983 | } // if-else |
2984 | emit updateSearchDialog(); | 2984 | emit updateSearchDialog(); |
2985 | } | 2985 | } |
2986 | 2986 | ||
2987 | bool CalendarView::deleteEvent(const QString &uid) | 2987 | bool CalendarView::deleteEvent(const QString &uid) |
2988 | { | 2988 | { |
2989 | Event *ev = mCalendar->event(uid); | 2989 | Event *ev = mCalendar->event(uid); |
2990 | if (ev) { | 2990 | if (ev) { |
2991 | deleteEvent(ev); | 2991 | deleteEvent(ev); |
2992 | return true; | 2992 | return true; |
2993 | } else { | 2993 | } else { |
2994 | return false; | 2994 | return false; |
2995 | } | 2995 | } |
2996 | } | 2996 | } |
2997 | 2997 | ||
2998 | /*****************************************************************************/ | 2998 | /*****************************************************************************/ |
2999 | 2999 | ||
3000 | void CalendarView::action_mail() | 3000 | void CalendarView::action_mail() |
3001 | { | 3001 | { |
3002 | #ifndef KORG_NOMAIL | 3002 | #ifndef KORG_NOMAIL |
3003 | KOMailClient mailClient; | 3003 | KOMailClient mailClient; |
3004 | 3004 | ||
3005 | Incidence *incidence = currentSelection(); | 3005 | Incidence *incidence = currentSelection(); |
3006 | 3006 | ||
3007 | if (!incidence) { | 3007 | if (!incidence) { |
3008 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3008 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3009 | return; | 3009 | return; |
3010 | } | 3010 | } |
3011 | if(incidence->attendeeCount() == 0 ) { | 3011 | if(incidence->attendeeCount() == 0 ) { |
3012 | KMessageBox::sorry(this, | 3012 | KMessageBox::sorry(this, |
3013 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3013 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3014 | return; | 3014 | return; |
3015 | } | 3015 | } |
3016 | 3016 | ||
3017 | CalendarLocal cal_tmp; | 3017 | CalendarLocal cal_tmp; |
3018 | Event *event = 0; | 3018 | Event *event = 0; |
3019 | Event *ev = 0; | 3019 | Event *ev = 0; |
3020 | if ( incidence && incidence->type() == "Event" ) { | 3020 | if ( incidence && incidence->type() == "Event" ) { |
3021 | event = static_cast<Event *>(incidence); | 3021 | event = static_cast<Event *>(incidence); |
3022 | ev = new Event(*event); | 3022 | ev = new Event(*event); |
3023 | cal_tmp.addEvent(ev); | 3023 | cal_tmp.addEvent(ev); |
3024 | } | 3024 | } |
3025 | ICalFormat mForm(); | 3025 | ICalFormat mForm(); |
3026 | QString attachment = mForm.toString( &cal_tmp ); | 3026 | QString attachment = mForm.toString( &cal_tmp ); |
3027 | if (ev) delete(ev); | 3027 | if (ev) delete(ev); |
3028 | 3028 | ||
3029 | mailClient.mailAttendees(currentSelection(), attachment); | 3029 | mailClient.mailAttendees(currentSelection(), attachment); |
3030 | 3030 | ||
3031 | #endif | 3031 | #endif |
3032 | 3032 | ||
3033 | #if 0 | 3033 | #if 0 |
3034 | Event *anEvent = 0; | 3034 | Event *anEvent = 0; |
3035 | if (mViewManager->currentView()->isEventView()) { | 3035 | if (mViewManager->currentView()->isEventView()) { |
3036 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3036 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3037 | } | 3037 | } |
3038 | 3038 | ||
3039 | if (!anEvent) { | 3039 | if (!anEvent) { |
3040 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3040 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3041 | return; | 3041 | return; |
3042 | } | 3042 | } |
3043 | if(anEvent->attendeeCount() == 0 ) { | 3043 | if(anEvent->attendeeCount() == 0 ) { |
3044 | KMessageBox::sorry(this, | 3044 | KMessageBox::sorry(this, |
3045 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3045 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3046 | return; | 3046 | return; |
3047 | } | 3047 | } |
3048 | 3048 | ||
3049 | mailobject.emailEvent(anEvent); | 3049 | mailobject.emailEvent(anEvent); |
3050 | #endif | 3050 | #endif |
3051 | } | 3051 | } |
3052 | 3052 | ||
3053 | 3053 | ||
3054 | void CalendarView::schedule_publish(Incidence *incidence) | 3054 | void CalendarView::schedule_publish(Incidence *incidence) |
3055 | { | 3055 | { |
3056 | Event *event = 0; | 3056 | Event *event = 0; |
3057 | Todo *todo = 0; | 3057 | Todo *todo = 0; |
3058 | 3058 | ||
3059 | if (incidence == 0) { | 3059 | if (incidence == 0) { |
3060 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3060 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3061 | if (incidence == 0) { | 3061 | if (incidence == 0) { |
3062 | incidence = mTodoList->selectedIncidences().first(); | 3062 | incidence = mTodoList->selectedIncidences().first(); |
3063 | } | 3063 | } |
3064 | } | 3064 | } |
3065 | if ( incidence && incidence->type() == "Event" ) { | 3065 | if ( incidence && incidence->type() == "Event" ) { |
3066 | event = static_cast<Event *>(incidence); | 3066 | event = static_cast<Event *>(incidence); |
3067 | } else { | 3067 | } else { |
3068 | if ( incidence && incidence->type() == "Todo" ) { | 3068 | if ( incidence && incidence->type() == "Todo" ) { |
3069 | todo = static_cast<Todo *>(incidence); | 3069 | todo = static_cast<Todo *>(incidence); |
3070 | } | 3070 | } |
3071 | } | 3071 | } |
3072 | 3072 | ||
3073 | if (!event && !todo) { | 3073 | if (!event && !todo) { |
3074 | KMessageBox::sorry(this,i18n("No event selected.")); | 3074 | KMessageBox::sorry(this,i18n("No event selected.")); |
3075 | return; | 3075 | return; |
3076 | } | 3076 | } |
3077 | 3077 | ||
3078 | PublishDialog *publishdlg = new PublishDialog(); | 3078 | PublishDialog *publishdlg = new PublishDialog(); |
3079 | if (incidence->attendeeCount()>0) { | 3079 | if (incidence->attendeeCount()>0) { |
3080 | QPtrList<Attendee> attendees = incidence->attendees(); | 3080 | QPtrList<Attendee> attendees = incidence->attendees(); |
3081 | attendees.first(); | 3081 | attendees.first(); |
3082 | while ( attendees.current()!=0 ) { | 3082 | while ( attendees.current()!=0 ) { |
3083 | publishdlg->addAttendee(attendees.current()); | 3083 | publishdlg->addAttendee(attendees.current()); |
3084 | attendees.next(); | 3084 | attendees.next(); |
3085 | } | 3085 | } |
3086 | } | 3086 | } |
3087 | bool send = true; | 3087 | bool send = true; |
3088 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3088 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3089 | if ( publishdlg->exec() != QDialog::Accepted ) | 3089 | if ( publishdlg->exec() != QDialog::Accepted ) |
3090 | send = false; | 3090 | send = false; |
3091 | } | 3091 | } |
3092 | if ( send ) { | 3092 | if ( send ) { |
3093 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3093 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3094 | if ( event ) { | 3094 | if ( event ) { |
3095 | Event *ev = new Event(*event); | 3095 | Event *ev = new Event(*event); |
3096 | ev->registerObserver(0); | 3096 | ev->registerObserver(0); |
3097 | ev->clearAttendees(); | 3097 | ev->clearAttendees(); |
3098 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3098 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3099 | delete(ev); | 3099 | delete(ev); |
3100 | } | 3100 | } |
3101 | } else { | 3101 | } else { |
3102 | if ( todo ) { | 3102 | if ( todo ) { |
3103 | Todo *ev = new Todo(*todo); | 3103 | Todo *ev = new Todo(*todo); |
3104 | ev->registerObserver(0); | 3104 | ev->registerObserver(0); |
3105 | ev->clearAttendees(); | 3105 | ev->clearAttendees(); |
3106 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3106 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3107 | delete(ev); | 3107 | delete(ev); |
3108 | } | 3108 | } |
3109 | } | 3109 | } |
3110 | } | 3110 | } |
3111 | } | 3111 | } |
3112 | delete publishdlg; | 3112 | delete publishdlg; |
3113 | } | 3113 | } |
3114 | 3114 | ||
3115 | void CalendarView::schedule_request(Incidence *incidence) | 3115 | void CalendarView::schedule_request(Incidence *incidence) |
3116 | { | 3116 | { |
3117 | schedule(Scheduler::Request,incidence); | 3117 | schedule(Scheduler::Request,incidence); |
3118 | } | 3118 | } |
3119 | 3119 | ||
3120 | void CalendarView::schedule_refresh(Incidence *incidence) | 3120 | void CalendarView::schedule_refresh(Incidence *incidence) |
3121 | { | 3121 | { |
3122 | schedule(Scheduler::Refresh,incidence); | 3122 | schedule(Scheduler::Refresh,incidence); |
3123 | } | 3123 | } |
3124 | 3124 | ||
3125 | void CalendarView::schedule_cancel(Incidence *incidence) | 3125 | void CalendarView::schedule_cancel(Incidence *incidence) |
3126 | { | 3126 | { |
3127 | schedule(Scheduler::Cancel,incidence); | 3127 | schedule(Scheduler::Cancel,incidence); |
3128 | } | 3128 | } |
3129 | 3129 | ||
3130 | void CalendarView::schedule_add(Incidence *incidence) | 3130 | void CalendarView::schedule_add(Incidence *incidence) |
3131 | { | 3131 | { |
3132 | schedule(Scheduler::Add,incidence); | 3132 | schedule(Scheduler::Add,incidence); |
3133 | } | 3133 | } |
3134 | 3134 | ||
3135 | void CalendarView::schedule_reply(Incidence *incidence) | 3135 | void CalendarView::schedule_reply(Incidence *incidence) |
3136 | { | 3136 | { |
3137 | schedule(Scheduler::Reply,incidence); | 3137 | schedule(Scheduler::Reply,incidence); |
3138 | } | 3138 | } |
3139 | 3139 | ||
3140 | void CalendarView::schedule_counter(Incidence *incidence) | 3140 | void CalendarView::schedule_counter(Incidence *incidence) |
3141 | { | 3141 | { |
3142 | schedule(Scheduler::Counter,incidence); | 3142 | schedule(Scheduler::Counter,incidence); |
3143 | } | 3143 | } |
3144 | 3144 | ||
3145 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3145 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3146 | { | 3146 | { |
3147 | schedule(Scheduler::Declinecounter,incidence); | 3147 | schedule(Scheduler::Declinecounter,incidence); |
3148 | } | 3148 | } |
3149 | 3149 | ||
3150 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3150 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3151 | { | 3151 | { |
3152 | QDateTime start = QDateTime::currentDateTime(); | 3152 | QDateTime start = QDateTime::currentDateTime(); |
3153 | QDateTime end = start.addDays(daysToPublish); | 3153 | QDateTime end = start.addDays(daysToPublish); |
3154 | 3154 | ||
3155 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3155 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3156 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3156 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3157 | 3157 | ||
3158 | 3158 | ||
3159 | PublishDialog *publishdlg = new PublishDialog(); | 3159 | PublishDialog *publishdlg = new PublishDialog(); |
3160 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3160 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3161 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3161 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3162 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3162 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3163 | delete(freebusy); | 3163 | delete(freebusy); |
3164 | } | 3164 | } |
3165 | } | 3165 | } |
3166 | delete publishdlg; | 3166 | delete publishdlg; |
3167 | } | 3167 | } |
3168 | 3168 | ||
3169 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3169 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3170 | { | 3170 | { |
3171 | Event *event = 0; | 3171 | Event *event = 0; |
3172 | Todo *todo = 0; | 3172 | Todo *todo = 0; |
3173 | 3173 | ||
3174 | if (incidence == 0) { | 3174 | if (incidence == 0) { |
3175 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3175 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3176 | if (incidence == 0) { | 3176 | if (incidence == 0) { |
3177 | incidence = mTodoList->selectedIncidences().first(); | 3177 | incidence = mTodoList->selectedIncidences().first(); |
3178 | } | 3178 | } |
3179 | } | 3179 | } |
3180 | if ( incidence && incidence->type() == "Event" ) { | 3180 | if ( incidence && incidence->type() == "Event" ) { |
3181 | event = static_cast<Event *>(incidence); | 3181 | event = static_cast<Event *>(incidence); |
3182 | } | 3182 | } |
3183 | if ( incidence && incidence->type() == "Todo" ) { | 3183 | if ( incidence && incidence->type() == "Todo" ) { |
3184 | todo = static_cast<Todo *>(incidence); | 3184 | todo = static_cast<Todo *>(incidence); |
3185 | } | 3185 | } |
3186 | 3186 | ||
3187 | if (!event && !todo) { | 3187 | if (!event && !todo) { |
3188 | KMessageBox::sorry(this,i18n("No event selected.")); | 3188 | KMessageBox::sorry(this,i18n("No event selected.")); |
3189 | return; | 3189 | return; |
3190 | } | 3190 | } |
3191 | 3191 | ||
3192 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3192 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3193 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3193 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3194 | return; | 3194 | return; |
3195 | } | 3195 | } |
3196 | 3196 | ||
3197 | Event *ev = 0; | 3197 | Event *ev = 0; |
3198 | if (event) ev = new Event(*event); | 3198 | if (event) ev = new Event(*event); |
3199 | Todo *to = 0; | 3199 | Todo *to = 0; |
3200 | if (todo) to = new Todo(*todo); | 3200 | if (todo) to = new Todo(*todo); |
3201 | 3201 | ||
3202 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3202 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3203 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3203 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3204 | if (!me) { | 3204 | if (!me) { |
3205 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3205 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3206 | return; | 3206 | return; |
3207 | } | 3207 | } |
3208 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3208 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3209 | StatusDialog *statdlg = new StatusDialog(this); | 3209 | StatusDialog *statdlg = new StatusDialog(this); |
3210 | if (!statdlg->exec()==QDialog::Accepted) return; | 3210 | if (!statdlg->exec()==QDialog::Accepted) return; |
3211 | me->setStatus( statdlg->status() ); | 3211 | me->setStatus( statdlg->status() ); |
3212 | delete(statdlg); | 3212 | delete(statdlg); |
3213 | } | 3213 | } |
3214 | Attendee *menew = new Attendee(*me); | 3214 | Attendee *menew = new Attendee(*me); |
3215 | if (ev) { | 3215 | if (ev) { |
3216 | ev->clearAttendees(); | 3216 | ev->clearAttendees(); |
3217 | ev->addAttendee(menew,false); | 3217 | ev->addAttendee(menew,false); |
3218 | } else { | 3218 | } else { |
3219 | if (to) { | 3219 | if (to) { |
3220 | todo->clearAttendees(); | 3220 | todo->clearAttendees(); |
3221 | todo->addAttendee(menew,false); | 3221 | todo->addAttendee(menew,false); |
3222 | } | 3222 | } |
3223 | } | 3223 | } |
3224 | } | 3224 | } |
3225 | 3225 | ||
3226 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3226 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3227 | if (ev) { | 3227 | if (ev) { |
3228 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3228 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3229 | } else { | 3229 | } else { |
3230 | if (to) { | 3230 | if (to) { |
3231 | if ( !dlg->addMessage(to,method) ) delete(to); | 3231 | if ( !dlg->addMessage(to,method) ) delete(to); |
3232 | } | 3232 | } |
3233 | } | 3233 | } |
3234 | } | 3234 | } |
3235 | 3235 | ||
3236 | void CalendarView::openAddressbook() | 3236 | void CalendarView::openAddressbook() |
3237 | { | 3237 | { |
3238 | KRun::runCommand("kaddressbook"); | 3238 | KRun::runCommand("kaddressbook"); |
3239 | } | 3239 | } |
3240 | 3240 | ||
3241 | void CalendarView::setModified(bool modified) | 3241 | void CalendarView::setModified(bool modified) |
3242 | { | 3242 | { |
3243 | if ( modified ) | 3243 | if ( modified ) |
3244 | emit signalmodified(); | 3244 | emit signalmodified(); |
3245 | if (mModified != modified) { | 3245 | if (mModified != modified) { |
3246 | mModified = modified; | 3246 | mModified = modified; |
3247 | emit modifiedChanged(mModified); | 3247 | emit modifiedChanged(mModified); |
3248 | } | 3248 | } |
3249 | } | 3249 | } |
3250 | 3250 | ||
3251 | bool CalendarView::isReadOnly() | 3251 | bool CalendarView::isReadOnly() |
3252 | { | 3252 | { |
3253 | return mReadOnly; | 3253 | return mReadOnly; |
3254 | } | 3254 | } |
3255 | 3255 | ||
3256 | void CalendarView::setReadOnly(bool readOnly) | 3256 | void CalendarView::setReadOnly(bool readOnly) |
3257 | { | 3257 | { |
3258 | if (mReadOnly != readOnly) { | 3258 | if (mReadOnly != readOnly) { |
3259 | mReadOnly = readOnly; | 3259 | mReadOnly = readOnly; |
3260 | emit readOnlyChanged(mReadOnly); | 3260 | emit readOnlyChanged(mReadOnly); |
3261 | } | 3261 | } |
3262 | } | 3262 | } |
3263 | 3263 | ||
3264 | bool CalendarView::isModified() | 3264 | bool CalendarView::isModified() |
3265 | { | 3265 | { |
3266 | return mModified; | 3266 | return mModified; |
3267 | } | 3267 | } |
3268 | 3268 | ||
3269 | void CalendarView::printSetup() | 3269 | void CalendarView::printSetup() |
3270 | { | 3270 | { |
3271 | #ifndef KORG_NOPRINTER | 3271 | #ifndef KORG_NOPRINTER |
3272 | createPrinter(); | 3272 | createPrinter(); |
3273 | 3273 | ||
3274 | mCalPrinter->setupPrinter(); | 3274 | mCalPrinter->setupPrinter(); |
3275 | #endif | 3275 | #endif |
3276 | } | 3276 | } |
3277 | 3277 | ||
3278 | void CalendarView::print() | 3278 | void CalendarView::print() |
3279 | { | 3279 | { |
3280 | #ifndef KORG_NOPRINTER | 3280 | #ifndef KORG_NOPRINTER |
3281 | createPrinter(); | 3281 | createPrinter(); |
3282 | 3282 | ||
3283 | DateList tmpDateList = mNavigator->selectedDates(); | 3283 | DateList tmpDateList = mNavigator->selectedDates(); |
3284 | mCalPrinter->print(CalPrinter::Month, | 3284 | mCalPrinter->print(CalPrinter::Month, |
3285 | tmpDateList.first(), tmpDateList.last()); | 3285 | tmpDateList.first(), tmpDateList.last()); |
3286 | #endif | 3286 | #endif |
3287 | } | 3287 | } |
3288 | 3288 | ||
3289 | void CalendarView::printPreview() | 3289 | void CalendarView::printPreview() |
3290 | { | 3290 | { |
3291 | #ifndef KORG_NOPRINTER | 3291 | #ifndef KORG_NOPRINTER |
3292 | kdDebug() << "CalendarView::printPreview()" << endl; | 3292 | kdDebug() << "CalendarView::printPreview()" << endl; |
3293 | 3293 | ||
3294 | createPrinter(); | 3294 | createPrinter(); |
3295 | 3295 | ||
3296 | DateList tmpDateList = mNavigator->selectedDates(); | 3296 | DateList tmpDateList = mNavigator->selectedDates(); |
3297 | 3297 | ||
3298 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3298 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3299 | tmpDateList.last()); | 3299 | tmpDateList.last()); |
3300 | #endif | 3300 | #endif |
3301 | } | 3301 | } |
3302 | 3302 | ||
3303 | void CalendarView::exportICalendar() | 3303 | void CalendarView::exportICalendar() |
3304 | { | 3304 | { |
3305 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3305 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3306 | 3306 | ||
3307 | // Force correct extension | 3307 | // Force correct extension |
3308 | if (filename.right(4) != ".ics") filename += ".ics"; | 3308 | if (filename.right(4) != ".ics") filename += ".ics"; |
3309 | 3309 | ||
3310 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3310 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3311 | storage.save(); | 3311 | storage.save(); |
3312 | } | 3312 | } |
3313 | 3313 | ||
3314 | bool CalendarView::exportVCalendar( QString filename ) | 3314 | bool CalendarView::exportVCalendar( QString filename ) |
3315 | { | 3315 | { |
3316 | if (mCalendar->journals().count() > 0) { | 3316 | if (mCalendar->journals().count() > 0) { |
3317 | int result = KMessageBox::warningContinueCancel(this, | 3317 | int result = KMessageBox::warningContinueCancel(this, |
3318 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3318 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3319 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3319 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3320 | true); | 3320 | true); |
3321 | if (result != KMessageBox::Continue) return false; | 3321 | if (result != KMessageBox::Continue) return false; |
3322 | } | 3322 | } |
3323 | 3323 | ||
3324 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3324 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3325 | 3325 | ||
3326 | // Force correct extension | 3326 | // Force correct extension |
3327 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3327 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3328 | 3328 | ||
3329 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3329 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3330 | return storage.save(); | 3330 | return storage.save(); |
3331 | 3331 | ||
3332 | } | 3332 | } |
3333 | 3333 | ||
3334 | void CalendarView::eventUpdated(Incidence *) | 3334 | void CalendarView::eventUpdated(Incidence *) |
3335 | { | 3335 | { |
3336 | setModified(); | 3336 | setModified(); |
3337 | // Don't call updateView here. The code, which has caused the update of the | 3337 | // Don't call updateView here. The code, which has caused the update of the |
3338 | // event is responsible for updating the view. | 3338 | // event is responsible for updating the view. |
3339 | // updateView(); | 3339 | // updateView(); |
3340 | } | 3340 | } |
3341 | 3341 | ||
3342 | void CalendarView::adaptNavigationUnits() | 3342 | void CalendarView::adaptNavigationUnits() |
3343 | { | 3343 | { |
3344 | if (mViewManager->currentView()->isEventView()) { | 3344 | if (mViewManager->currentView()->isEventView()) { |
3345 | int days = mViewManager->currentView()->currentDateCount(); | 3345 | int days = mViewManager->currentView()->currentDateCount(); |
3346 | if (days == 1) { | 3346 | if (days == 1) { |
3347 | emit changeNavStringPrev(i18n("&Previous Day")); | 3347 | emit changeNavStringPrev(i18n("&Previous Day")); |
3348 | emit changeNavStringNext(i18n("&Next Day")); | 3348 | emit changeNavStringNext(i18n("&Next Day")); |
3349 | } else { | 3349 | } else { |
3350 | emit changeNavStringPrev(i18n("&Previous Week")); | 3350 | emit changeNavStringPrev(i18n("&Previous Week")); |
3351 | emit changeNavStringNext(i18n("&Next Week")); | 3351 | emit changeNavStringNext(i18n("&Next Week")); |
3352 | } | 3352 | } |
3353 | } | 3353 | } |
3354 | } | 3354 | } |
3355 | 3355 | ||
3356 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3356 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3357 | { | 3357 | { |
3358 | if ( incidence ) mTodoList->clearSelection(); | 3358 | if ( incidence ) mTodoList->clearSelection(); |
3359 | processIncidenceSelection( incidence ); | 3359 | processIncidenceSelection( incidence ); |
3360 | } | 3360 | } |
3361 | 3361 | ||
3362 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3362 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3363 | { | 3363 | { |
3364 | if ( incidence && mViewManager->currentView() ) { | 3364 | if ( incidence && mViewManager->currentView() ) { |
3365 | mViewManager->currentView()->clearSelection(); | 3365 | mViewManager->currentView()->clearSelection(); |
3366 | } | 3366 | } |
3367 | processIncidenceSelection( incidence ); | 3367 | processIncidenceSelection( incidence ); |
3368 | } | 3368 | } |
3369 | 3369 | ||
3370 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3370 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3371 | { | 3371 | { |
3372 | if ( incidence == mSelectedIncidence ) return; | 3372 | if ( incidence == mSelectedIncidence ) return; |
3373 | 3373 | ||
3374 | mSelectedIncidence = incidence; | 3374 | mSelectedIncidence = incidence; |
3375 | 3375 | ||
3376 | emit incidenceSelected( mSelectedIncidence ); | 3376 | emit incidenceSelected( mSelectedIncidence ); |
3377 | 3377 | ||
3378 | if ( incidence && incidence->type() == "Event" ) { | 3378 | if ( incidence && incidence->type() == "Event" ) { |
3379 | Event *event = static_cast<Event *>( incidence ); | 3379 | Event *event = static_cast<Event *>( incidence ); |
3380 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3380 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3381 | emit organizerEventsSelected( true ); | 3381 | emit organizerEventsSelected( true ); |
3382 | } else { | 3382 | } else { |
3383 | emit organizerEventsSelected(false); | 3383 | emit organizerEventsSelected(false); |
3384 | } | 3384 | } |
3385 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3385 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3386 | KOPrefs::instance()->email() ) ) { | 3386 | KOPrefs::instance()->email() ) ) { |
3387 | emit groupEventsSelected( true ); | 3387 | emit groupEventsSelected( true ); |
3388 | } else { | 3388 | } else { |
3389 | emit groupEventsSelected(false); | 3389 | emit groupEventsSelected(false); |
3390 | } | 3390 | } |
3391 | return; | 3391 | return; |
3392 | } else { | 3392 | } else { |
3393 | if ( incidence && incidence->type() == "Todo" ) { | 3393 | if ( incidence && incidence->type() == "Todo" ) { |
3394 | emit todoSelected( true ); | 3394 | emit todoSelected( true ); |
3395 | Todo *event = static_cast<Todo *>( incidence ); | 3395 | Todo *event = static_cast<Todo *>( incidence ); |
3396 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3396 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3397 | emit organizerEventsSelected( true ); | 3397 | emit organizerEventsSelected( true ); |
3398 | } else { | 3398 | } else { |
3399 | emit organizerEventsSelected(false); | 3399 | emit organizerEventsSelected(false); |
3400 | } | 3400 | } |
3401 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3401 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3402 | KOPrefs::instance()->email() ) ) { | 3402 | KOPrefs::instance()->email() ) ) { |
3403 | emit groupEventsSelected( true ); | 3403 | emit groupEventsSelected( true ); |
3404 | } else { | 3404 | } else { |
3405 | emit groupEventsSelected(false); | 3405 | emit groupEventsSelected(false); |
3406 | } | 3406 | } |
3407 | return; | 3407 | return; |
3408 | } else { | 3408 | } else { |
3409 | emit todoSelected( false ); | 3409 | emit todoSelected( false ); |
3410 | emit organizerEventsSelected(false); | 3410 | emit organizerEventsSelected(false); |
3411 | emit groupEventsSelected(false); | 3411 | emit groupEventsSelected(false); |
3412 | } | 3412 | } |
3413 | return; | 3413 | return; |
3414 | } | 3414 | } |
3415 | 3415 | ||
3416 | /* if ( incidence && incidence->type() == "Todo" ) { | 3416 | /* if ( incidence && incidence->type() == "Todo" ) { |
3417 | emit todoSelected( true ); | 3417 | emit todoSelected( true ); |
3418 | } else { | 3418 | } else { |
3419 | emit todoSelected( false ); | 3419 | emit todoSelected( false ); |
3420 | }*/ | 3420 | }*/ |
3421 | } | 3421 | } |
3422 | 3422 | ||
3423 | 3423 | ||
3424 | void CalendarView::checkClipboard() | 3424 | void CalendarView::checkClipboard() |
3425 | { | 3425 | { |
3426 | #ifndef KORG_NODND | 3426 | #ifndef KORG_NODND |
3427 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3427 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3428 | emit pasteEnabled(true); | 3428 | emit pasteEnabled(true); |
3429 | } else { | 3429 | } else { |
3430 | emit pasteEnabled(false); | 3430 | emit pasteEnabled(false); |
3431 | } | 3431 | } |
3432 | #endif | 3432 | #endif |
3433 | } | 3433 | } |
3434 | 3434 | ||
3435 | void CalendarView::showDates(const DateList &selectedDates) | 3435 | void CalendarView::showDates(const DateList &selectedDates) |
3436 | { | 3436 | { |
3437 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3437 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3438 | 3438 | ||
3439 | if ( mViewManager->currentView() ) { | 3439 | if ( mViewManager->currentView() ) { |
3440 | updateView( selectedDates.first(), selectedDates.last() ); | 3440 | updateView( selectedDates.first(), selectedDates.last() ); |
3441 | } else { | 3441 | } else { |
3442 | mViewManager->showAgendaView(); | 3442 | mViewManager->showAgendaView(); |
3443 | } | 3443 | } |
3444 | 3444 | ||
3445 | QString selDates; | 3445 | QString selDates; |
3446 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3446 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3447 | if (selectedDates.first() < selectedDates.last() ) | 3447 | if (selectedDates.first() < selectedDates.last() ) |
3448 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3448 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3449 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3449 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3450 | 3450 | ||
3451 | } | 3451 | } |
3452 | 3452 | ||
3453 | QPtrList<CalFilter> CalendarView::filters() | 3453 | QPtrList<CalFilter> CalendarView::filters() |
3454 | { | 3454 | { |
3455 | return mFilters; | 3455 | return mFilters; |
3456 | 3456 | ||
3457 | } | 3457 | } |
3458 | void CalendarView::editFilters() | 3458 | void CalendarView::editFilters() |
3459 | { | 3459 | { |
3460 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3460 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3461 | 3461 | ||
3462 | CalFilter *filter = mFilters.first(); | 3462 | CalFilter *filter = mFilters.first(); |
3463 | while(filter) { | 3463 | while(filter) { |
3464 | kdDebug() << " Filter: " << filter->name() << endl; | 3464 | kdDebug() << " Filter: " << filter->name() << endl; |
3465 | filter = mFilters.next(); | 3465 | filter = mFilters.next(); |
3466 | } | 3466 | } |
3467 | 3467 | ||
3468 | mDialogManager->showFilterEditDialog(&mFilters); | 3468 | mDialogManager->showFilterEditDialog(&mFilters); |
3469 | } | 3469 | } |
3470 | void CalendarView::toggleFilter() | 3470 | void CalendarView::toggleFilter() |
3471 | { | 3471 | { |
3472 | showFilter(! mFilterView->isVisible()); | 3472 | showFilter(! mFilterView->isVisible()); |
3473 | } | 3473 | } |
3474 | 3474 | ||
3475 | KOFilterView *CalendarView::filterView() | 3475 | KOFilterView *CalendarView::filterView() |
3476 | { | 3476 | { |
3477 | return mFilterView; | 3477 | return mFilterView; |
3478 | } | 3478 | } |
3479 | void CalendarView::selectFilter( int fil ) | 3479 | void CalendarView::selectFilter( int fil ) |
3480 | { | 3480 | { |
3481 | mFilterView->setSelectedFilter( fil ); | 3481 | mFilterView->setSelectedFilter( fil ); |
3482 | } | 3482 | } |
3483 | void CalendarView::showFilter(bool visible) | 3483 | void CalendarView::showFilter(bool visible) |
3484 | { | 3484 | { |
3485 | if (visible) mFilterView->show(); | 3485 | if (visible) mFilterView->show(); |
3486 | else mFilterView->hide(); | 3486 | else mFilterView->hide(); |
3487 | } | 3487 | } |
3488 | void CalendarView::toggleFilerEnabled( ) | 3488 | void CalendarView::toggleFilerEnabled( ) |
3489 | { | 3489 | { |
3490 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3490 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3491 | if ( !mFilterView->filtersEnabled() ) | 3491 | if ( !mFilterView->filtersEnabled() ) |
3492 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3492 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3493 | 3493 | ||
3494 | } | 3494 | } |
3495 | void CalendarView::updateFilter() | 3495 | void CalendarView::updateFilter() |
3496 | { | 3496 | { |
3497 | CalFilter *filter = mFilterView->selectedFilter(); | 3497 | CalFilter *filter = mFilterView->selectedFilter(); |
3498 | if (filter) { | 3498 | if (filter) { |
3499 | if (mFilterView->filtersEnabled()) { | 3499 | if (mFilterView->filtersEnabled()) { |
3500 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3500 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3501 | filter->setEnabled(true); | 3501 | filter->setEnabled(true); |
3502 | } | 3502 | } |
3503 | else filter->setEnabled(false); | 3503 | else filter->setEnabled(false); |
3504 | mCalendar->setFilter(filter); | 3504 | mCalendar->setFilter(filter); |
3505 | updateView(); | 3505 | updateView(); |
3506 | } | 3506 | } |
3507 | } | 3507 | } |
3508 | 3508 | ||
3509 | void CalendarView::filterEdited() | 3509 | void CalendarView::filterEdited() |
3510 | { | 3510 | { |
3511 | mFilterView->updateFilters(); | 3511 | mFilterView->updateFilters(); |
3512 | updateFilter(); | 3512 | updateFilter(); |
3513 | writeSettings(); | 3513 | writeSettings(); |
3514 | } | 3514 | } |
3515 | 3515 | ||
3516 | 3516 | ||
3517 | void CalendarView::takeOverEvent() | 3517 | void CalendarView::takeOverEvent() |
3518 | { | 3518 | { |
3519 | Incidence *incidence = currentSelection(); | 3519 | Incidence *incidence = currentSelection(); |
3520 | 3520 | ||
3521 | if (!incidence) return; | 3521 | if (!incidence) return; |
3522 | 3522 | ||
3523 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3523 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3524 | incidence->recreate(); | 3524 | incidence->recreate(); |
3525 | incidence->setReadOnly(false); | 3525 | incidence->setReadOnly(false); |
3526 | 3526 | ||
3527 | updateView(); | 3527 | updateView(); |
3528 | } | 3528 | } |
3529 | 3529 | ||
3530 | void CalendarView::takeOverCalendar() | 3530 | void CalendarView::takeOverCalendar() |
3531 | { | 3531 | { |
3532 | // TODO: Create Calendar::allIncidences() function and use it here | 3532 | // TODO: Create Calendar::allIncidences() function and use it here |
3533 | 3533 | ||
3534 | QPtrList<Event> events = mCalendar->events(); | 3534 | QPtrList<Event> events = mCalendar->events(); |
3535 | for(uint i=0; i<events.count(); ++i) { | 3535 | for(uint i=0; i<events.count(); ++i) { |
3536 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3536 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3537 | events.at(i)->recreate(); | 3537 | events.at(i)->recreate(); |
3538 | events.at(i)->setReadOnly(false); | 3538 | events.at(i)->setReadOnly(false); |
3539 | } | 3539 | } |
3540 | 3540 | ||
3541 | QPtrList<Todo> todos = mCalendar->todos(); | 3541 | QPtrList<Todo> todos = mCalendar->todos(); |
3542 | for(uint i=0; i<todos.count(); ++i) { | 3542 | for(uint i=0; i<todos.count(); ++i) { |
3543 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3543 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3544 | todos.at(i)->recreate(); | 3544 | todos.at(i)->recreate(); |
3545 | todos.at(i)->setReadOnly(false); | 3545 | todos.at(i)->setReadOnly(false); |
3546 | } | 3546 | } |
3547 | 3547 | ||
3548 | QPtrList<Journal> journals = mCalendar->journals(); | 3548 | QPtrList<Journal> journals = mCalendar->journals(); |
3549 | for(uint i=0; i<journals.count(); ++i) { | 3549 | for(uint i=0; i<journals.count(); ++i) { |
3550 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3550 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3551 | journals.at(i)->recreate(); | 3551 | journals.at(i)->recreate(); |
3552 | journals.at(i)->setReadOnly(false); | 3552 | journals.at(i)->setReadOnly(false); |
3553 | } | 3553 | } |
3554 | 3554 | ||
3555 | updateView(); | 3555 | updateView(); |
3556 | } | 3556 | } |
3557 | 3557 | ||
3558 | void CalendarView::showIntro() | 3558 | void CalendarView::showIntro() |
3559 | { | 3559 | { |
3560 | kdDebug() << "To be implemented." << endl; | 3560 | kdDebug() << "To be implemented." << endl; |
3561 | } | 3561 | } |
3562 | 3562 | ||
3563 | QWidgetStack *CalendarView::viewStack() | 3563 | QWidgetStack *CalendarView::viewStack() |
3564 | { | 3564 | { |
3565 | return mRightFrame; | 3565 | return mRightFrame; |
3566 | } | 3566 | } |
3567 | 3567 | ||
3568 | QWidget *CalendarView::leftFrame() | 3568 | QWidget *CalendarView::leftFrame() |
3569 | { | 3569 | { |
3570 | return mLeftFrame; | 3570 | return mLeftFrame; |
3571 | } | 3571 | } |
3572 | 3572 | ||
3573 | DateNavigator *CalendarView::dateNavigator() | 3573 | DateNavigator *CalendarView::dateNavigator() |
3574 | { | 3574 | { |
3575 | return mNavigator; | 3575 | return mNavigator; |
3576 | } | 3576 | } |
3577 | 3577 | ||
3578 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3578 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3579 | { | 3579 | { |
3580 | return mDateNavigator; | 3580 | return mDateNavigator; |
3581 | } | 3581 | } |
3582 | void CalendarView::toggleDateNavigatorWidget() | 3582 | void CalendarView::toggleDateNavigatorWidget() |
3583 | { | 3583 | { |
3584 | if (mDateNavigator->isVisible()) | 3584 | if (mDateNavigator->isVisible()) |
3585 | mDateNavigator->hide(); | 3585 | mDateNavigator->hide(); |
3586 | else | 3586 | else |
3587 | mDateNavigator->show(); | 3587 | mDateNavigator->show(); |
3588 | } | 3588 | } |
3589 | void CalendarView::addView(KOrg::BaseView *view) | 3589 | void CalendarView::addView(KOrg::BaseView *view) |
3590 | { | 3590 | { |
3591 | mViewManager->addView(view); | 3591 | mViewManager->addView(view); |
3592 | } | 3592 | } |
3593 | 3593 | ||
3594 | void CalendarView::showView(KOrg::BaseView *view) | 3594 | void CalendarView::showView(KOrg::BaseView *view) |
3595 | { | 3595 | { |
3596 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3596 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3597 | } | 3597 | } |
3598 | 3598 | ||
3599 | Incidence *CalendarView::currentSelection() | 3599 | Incidence *CalendarView::currentSelection() |
3600 | { | 3600 | { |
3601 | return mViewManager->currentSelection(); | 3601 | return mViewManager->currentSelection(); |
3602 | } | 3602 | } |
3603 | void CalendarView::toggleAllDaySize() | 3603 | void CalendarView::toggleAllDaySize() |
3604 | { | 3604 | { |
3605 | /* | 3605 | /* |
3606 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3606 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3607 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3607 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3608 | else | 3608 | else |
3609 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3609 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3610 | */ | 3610 | */ |
3611 | viewManager()->agendaView()->toggleAllDay(); | 3611 | viewManager()->agendaView()->toggleAllDay(); |
3612 | } | 3612 | } |
3613 | void CalendarView::toggleExpand() | 3613 | void CalendarView::toggleExpand() |
3614 | { | 3614 | { |
3615 | // if ( mLeftFrame->isHidden() ) { | 3615 | // if ( mLeftFrame->isHidden() ) { |
3616 | // mLeftFrame->show(); | 3616 | // mLeftFrame->show(); |
3617 | // emit calendarViewExpanded( false ); | 3617 | // emit calendarViewExpanded( false ); |
3618 | // } else { | 3618 | // } else { |
3619 | // mLeftFrame->hide(); | 3619 | // mLeftFrame->hide(); |
3620 | // emit calendarViewExpanded( true ); | 3620 | // emit calendarViewExpanded( true ); |
3621 | // } | 3621 | // } |
3622 | 3622 | ||
3623 | globalFlagBlockAgenda = 1; | 3623 | globalFlagBlockAgenda = 1; |
3624 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3624 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3625 | globalFlagBlockAgenda = 5; | 3625 | globalFlagBlockAgenda = 5; |
3626 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3626 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3627 | //mViewManager->showView( 0, true ); | 3627 | //mViewManager->showView( 0, true ); |
3628 | } | 3628 | } |
3629 | 3629 | ||
3630 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3630 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3631 | { | 3631 | { |
3632 | setModified( modified ); | 3632 | setModified( modified ); |
3633 | } | 3633 | } |
3634 | 3634 | ||
3635 | Todo *CalendarView::selectedTodo() | 3635 | Todo *CalendarView::selectedTodo() |
3636 | { | 3636 | { |
3637 | Incidence *incidence = currentSelection(); | 3637 | Incidence *incidence = currentSelection(); |
3638 | if ( incidence && incidence->type() == "Todo" ) { | 3638 | if ( incidence && incidence->type() == "Todo" ) { |
3639 | return static_cast<Todo *>( incidence ); | 3639 | return static_cast<Todo *>( incidence ); |
3640 | } | 3640 | } |
3641 | 3641 | ||
3642 | incidence = mTodoList->selectedIncidences().first(); | 3642 | incidence = mTodoList->selectedIncidences().first(); |
3643 | if ( incidence && incidence->type() == "Todo" ) { | 3643 | if ( incidence && incidence->type() == "Todo" ) { |
3644 | return static_cast<Todo *>( incidence ); | 3644 | return static_cast<Todo *>( incidence ); |
3645 | } | 3645 | } |
3646 | 3646 | ||
3647 | return 0; | 3647 | return 0; |
3648 | } | 3648 | } |
3649 | 3649 | ||
3650 | void CalendarView::dialogClosing(Incidence *in) | 3650 | void CalendarView::dialogClosing(Incidence *in) |
3651 | { | 3651 | { |
3652 | // mDialogList.remove(in); | 3652 | // mDialogList.remove(in); |
3653 | } | 3653 | } |
3654 | 3654 | ||
3655 | void CalendarView::showIncidence() | 3655 | void CalendarView::showIncidence() |
3656 | { | 3656 | { |
3657 | Incidence *incidence = currentSelection(); | 3657 | Incidence *incidence = currentSelection(); |
3658 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3658 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3659 | if ( incidence ) { | 3659 | if ( incidence ) { |
3660 | ShowIncidenceVisitor v; | 3660 | ShowIncidenceVisitor v; |
3661 | v.act( incidence, this ); | 3661 | v.act( incidence, this ); |
3662 | } | 3662 | } |
3663 | } | 3663 | } |
3664 | void CalendarView::editIncidenceDescription() | 3664 | void CalendarView::editIncidenceDescription() |
3665 | { | 3665 | { |
3666 | mFlagEditDescription = true; | 3666 | mFlagEditDescription = true; |
3667 | editIncidence(); | 3667 | editIncidence(); |
3668 | mFlagEditDescription = false; | 3668 | mFlagEditDescription = false; |
3669 | } | 3669 | } |
3670 | void CalendarView::editIncidence() | 3670 | void CalendarView::editIncidence() |
3671 | { | 3671 | { |
3672 | // qDebug("editIncidence() "); | 3672 | // qDebug("editIncidence() "); |
3673 | Incidence *incidence = currentSelection(); | 3673 | Incidence *incidence = currentSelection(); |
3674 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3674 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3675 | if ( incidence ) { | 3675 | if ( incidence ) { |
3676 | EditIncidenceVisitor v; | 3676 | EditIncidenceVisitor v; |
3677 | v.act( incidence, this ); | 3677 | v.act( incidence, this ); |
3678 | } | 3678 | } |
3679 | } | 3679 | } |
3680 | 3680 | ||
3681 | void CalendarView::deleteIncidence() | 3681 | void CalendarView::deleteIncidence() |
3682 | { | 3682 | { |
3683 | Incidence *incidence = currentSelection(); | 3683 | Incidence *incidence = currentSelection(); |
3684 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3684 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3685 | if ( incidence ) { | 3685 | if ( incidence ) { |
3686 | deleteIncidence(incidence); | 3686 | deleteIncidence(incidence); |
3687 | } | 3687 | } |
3688 | } | 3688 | } |
3689 | 3689 | ||
3690 | void CalendarView::showIncidence(Incidence *incidence) | 3690 | void CalendarView::showIncidence(Incidence *incidence) |
3691 | { | 3691 | { |
3692 | if ( incidence ) { | 3692 | if ( incidence ) { |
3693 | ShowIncidenceVisitor v; | 3693 | ShowIncidenceVisitor v; |
3694 | v.act( incidence, this ); | 3694 | v.act( incidence, this ); |
3695 | } | 3695 | } |
3696 | } | 3696 | } |
3697 | 3697 | ||
3698 | void CalendarView::editIncidence(Incidence *incidence) | 3698 | void CalendarView::editIncidence(Incidence *incidence) |
3699 | { | 3699 | { |
3700 | if ( incidence ) { | 3700 | if ( incidence ) { |
3701 | 3701 | ||
3702 | EditIncidenceVisitor v; | 3702 | EditIncidenceVisitor v; |
3703 | v.act( incidence, this ); | 3703 | v.act( incidence, this ); |
3704 | 3704 | ||
3705 | } | 3705 | } |
3706 | } | 3706 | } |
3707 | 3707 | ||
3708 | void CalendarView::deleteIncidence(Incidence *incidence) | 3708 | void CalendarView::deleteIncidence(Incidence *incidence) |
3709 | { | 3709 | { |
3710 | //qDebug(" CalendarView::deleteIncidence "); | 3710 | //qDebug(" CalendarView::deleteIncidence "); |
3711 | if ( incidence ) { | 3711 | if ( incidence ) { |
3712 | DeleteIncidenceVisitor v; | 3712 | DeleteIncidenceVisitor v; |
3713 | v.act( incidence, this ); | 3713 | v.act( incidence, this ); |
3714 | } | 3714 | } |
3715 | } | 3715 | } |
3716 | 3716 | ||
3717 | 3717 | ||
3718 | void CalendarView::lookForOutgoingMessages() | 3718 | void CalendarView::lookForOutgoingMessages() |
3719 | { | 3719 | { |
3720 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3720 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3721 | ogd->loadMessages(); | 3721 | ogd->loadMessages(); |
3722 | } | 3722 | } |
3723 | 3723 | ||
3724 | void CalendarView::lookForIncomingMessages() | 3724 | void CalendarView::lookForIncomingMessages() |
3725 | { | 3725 | { |
3726 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3726 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3727 | icd->retrieve(); | 3727 | icd->retrieve(); |
3728 | } | 3728 | } |
3729 | 3729 | ||
3730 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3730 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3731 | { | 3731 | { |
3732 | bool deleteTodo = true; | 3732 | bool deleteTodo = true; |
3733 | QPtrList<Incidence> subTodos; | 3733 | QPtrList<Incidence> subTodos; |
3734 | Incidence *aTodo; | 3734 | Incidence *aTodo; |
3735 | subTodos = t->relations(); | 3735 | subTodos = t->relations(); |
3736 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3736 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3737 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3737 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3738 | deleteTodo = false; | 3738 | deleteTodo = false; |
3739 | } | 3739 | } |
3740 | if ( deleteTodo ) { | 3740 | if ( deleteTodo ) { |
3741 | if ( t->isCompleted() ) { | 3741 | if ( t->isCompleted() ) { |
3742 | checkExternalId( t ); | 3742 | checkExternalId( t ); |
3743 | mCalendar->deleteTodo( t ); | 3743 | mCalendar->deleteTodo( t ); |
3744 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3744 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3745 | } | 3745 | } |
3746 | else | 3746 | else |
3747 | deleteTodo = false; | 3747 | deleteTodo = false; |
3748 | } | 3748 | } |
3749 | return deleteTodo; | 3749 | return deleteTodo; |
3750 | 3750 | ||
3751 | } | 3751 | } |
3752 | void CalendarView::purgeCompleted() | 3752 | void CalendarView::purgeCompleted() |
3753 | { | 3753 | { |
3754 | int result = KMessageBox::warningContinueCancel(this, | 3754 | int result = KMessageBox::warningContinueCancel(this, |
3755 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3755 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3756 | 3756 | ||
3757 | if (result == KMessageBox::Continue) { | 3757 | if (result == KMessageBox::Continue) { |
3758 | 3758 | ||
3759 | QPtrList<Todo> todoCal; | 3759 | QPtrList<Todo> todoCal; |
3760 | QPtrList<Todo> rootTodos; | 3760 | QPtrList<Todo> rootTodos; |
3761 | //QPtrList<Incidence> rel; | 3761 | //QPtrList<Incidence> rel; |
3762 | Todo *aTodo;//, *rTodo; | 3762 | Todo *aTodo;//, *rTodo; |
3763 | Incidence *rIncidence; | 3763 | Incidence *rIncidence; |
3764 | bool childDelete = false; | 3764 | bool childDelete = false; |
3765 | bool deletedOne = true; | 3765 | bool deletedOne = true; |
3766 | todoCal = calendar()->todos(); | 3766 | todoCal = calendar()->todos(); |
3767 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3767 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3768 | if ( !aTodo->relatedTo() ) | 3768 | if ( !aTodo->relatedTo() ) |
3769 | rootTodos.append( aTodo ); | 3769 | rootTodos.append( aTodo ); |
3770 | } | 3770 | } |
3771 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3771 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3772 | removeCompletedSubTodos( aTodo ); | 3772 | removeCompletedSubTodos( aTodo ); |
3773 | } | 3773 | } |
3774 | 3774 | ||
3775 | updateView(); | 3775 | updateView(); |
3776 | } | 3776 | } |
3777 | } | 3777 | } |
3778 | 3778 | ||
3779 | void CalendarView::slotCalendarChanged() | 3779 | void CalendarView::slotCalendarChanged() |
3780 | { | 3780 | { |
3781 | ; | 3781 | ; |
3782 | } | 3782 | } |
3783 | 3783 | ||
3784 | NavigatorBar *CalendarView::navigatorBar() | 3784 | NavigatorBar *CalendarView::navigatorBar() |
3785 | { | 3785 | { |
3786 | return mNavigatorBar; | 3786 | return mNavigatorBar; |
3787 | } | 3787 | } |
3788 | 3788 | ||
3789 | 3789 | ||
3790 | 3790 | ||
3791 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3791 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3792 | { | 3792 | { |
3793 | //qDebug(" alendarView::keyPressEvent "); | 3793 | //qDebug(" alendarView::keyPressEvent "); |
3794 | e->ignore(); | 3794 | e->ignore(); |
3795 | } | 3795 | } |
3796 | 3796 | ||
3797 | 3797 | ||
3798 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3798 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3799 | { | 3799 | { |
3800 | // mSyncManager = manager; | 3800 | // mSyncManager = manager; |
3801 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3801 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3802 | qDebug("SyncKDE request detected!"); | 3802 | qDebug("SyncKDE request detected!"); |
3803 | } | 3803 | } |
3804 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3804 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3805 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3805 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3806 | return syncCalendar( filename, mode ); | 3806 | return syncCalendar( filename, mode ); |
3807 | } | 3807 | } |
3808 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3808 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3809 | { | 3809 | { |
3810 | //mSyncManager = manager; | 3810 | //mSyncManager = manager; |
3811 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3811 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3812 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3812 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3813 | if ( resource == "sharp" ) | 3813 | if ( resource == "sharp" ) |
3814 | syncExternal( 0 ); | 3814 | syncExternal( 0 ); |
3815 | if ( resource == "phone" ) | 3815 | if ( resource == "phone" ) |
3816 | syncExternal( 1 ); | 3816 | syncExternal( 1 ); |
3817 | // pending setmodified | 3817 | // pending setmodified |
3818 | return true; | 3818 | return true; |
3819 | } | 3819 | } |
3820 | void CalendarView::setSyncManager(KSyncManager* manager) | 3820 | void CalendarView::setSyncManager(KSyncManager* manager) |
3821 | { | 3821 | { |
3822 | mSyncManager = manager; | 3822 | mSyncManager = manager; |
3823 | } | 3823 | } |
3824 | 3824 | ||
3825 | void CalendarView::removeSyncInfo( QString syncProfile) | 3825 | void CalendarView::removeSyncInfo( QString syncProfile) |
3826 | { | 3826 | { |
3827 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3827 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3828 | mCalendar->removeSyncInfo( syncProfile ); | 3828 | mCalendar->removeSyncInfo( syncProfile ); |
3829 | 3829 | ||
3830 | } | 3830 | } |
3831 | 3831 | ||
3832 | void CalendarView::undo_delete() | 3832 | void CalendarView::undo_delete() |
3833 | { | 3833 | { |
3834 | //qDebug("undo_delete() "); | 3834 | //qDebug("undo_delete() "); |
3835 | Incidence* undo = mCalendar->undoIncidence(); | 3835 | Incidence* undo = mCalendar->undoIncidence(); |
3836 | if ( !undo ) { | 3836 | if ( !undo ) { |
3837 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3837 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3838 | i18n("KO/Pi")); | 3838 | i18n("KO/Pi")); |
3839 | return; | 3839 | return; |
3840 | } | 3840 | } |
3841 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3841 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3842 | i18n("\nAre you sure you want\nto restore this?"), | 3842 | i18n("\nAre you sure you want\nto restore this?"), |
3843 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3843 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3844 | mCalendar->undoDeleteIncidence(); | 3844 | mCalendar->undoDeleteIncidence(); |
3845 | updateView(); | 3845 | updateView(); |
3846 | } | 3846 | } |
3847 | } | 3847 | } |