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