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