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