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