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