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