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