author | zautrix <zautrix> | 2005-01-30 00:33:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-30 00:33:46 (UTC) |
commit | a8fae20ad7bcb59df9a603c88accf3a10401c2f9 (patch) (unidiff) | |
tree | 12deeef9bae6d470c244ce9a9916c59d6879f9b2 | |
parent | d94b52aa95cc52aa1bef7c9cd99f43c725ed8042 (diff) | |
download | kdepimpi-a8fae20ad7bcb59df9a603c88accf3a10401c2f9.zip kdepimpi-a8fae20ad7bcb59df9a603c88accf3a10401c2f9.tar.gz kdepimpi-a8fae20ad7bcb59df9a603c88accf3a10401c2f9.tar.bz2 |
f
-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditordetails.cpp | 13 | ||||
-rw-r--r-- | korganizer/koeditordetails.h | 1 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 6 | ||||
-rw-r--r-- | libkcal/dndfactory.h | 9 |
5 files changed, 28 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 74aefb7..96fb5ca 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3917 +1,3917 @@ | |||
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 | ev->setOrganizer(KOPrefs::instance()->email()); | ||
1522 | if ( a ) { | 1523 | if ( a ) { |
1523 | ev->addAttendee( a ); | 1524 | ev->addAttendee( a ); |
1524 | } | 1525 | } |
1525 | QString kind; | 1526 | QString kind; |
1526 | if ( birthday ) { | 1527 | if ( birthday ) { |
1527 | kind = i18n( "Birthday" ); | 1528 | kind = i18n( "Birthday" ); |
1528 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1529 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1529 | } | 1530 | } |
1530 | else { | 1531 | else { |
1531 | kind = i18n( "Anniversary" ); | 1532 | kind = i18n( "Anniversary" ); |
1532 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1533 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1533 | } | 1534 | } |
1534 | //ev->setOrganizer(a->email()); | ||
1535 | ev->setCategories( kind ); | 1535 | ev->setCategories( kind ); |
1536 | ev->setDtStart( QDateTime(date) ); | 1536 | ev->setDtStart( QDateTime(date) ); |
1537 | ev->setDtEnd( QDateTime(date) ); | 1537 | ev->setDtEnd( QDateTime(date) ); |
1538 | ev->setFloats( true ); | 1538 | ev->setFloats( true ); |
1539 | Recurrence * rec = ev->recurrence(); | 1539 | Recurrence * rec = ev->recurrence(); |
1540 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1540 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1541 | rec->addYearlyNum( date.month() ); | 1541 | rec->addYearlyNum( date.month() ); |
1542 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1542 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1543 | delete ev; | 1543 | delete ev; |
1544 | return false; | 1544 | return false; |
1545 | } | 1545 | } |
1546 | return true; | 1546 | return true; |
1547 | 1547 | ||
1548 | } | 1548 | } |
1549 | bool CalendarView::importQtopia( const QString &categories, | 1549 | bool CalendarView::importQtopia( const QString &categories, |
1550 | const QString &datebook, | 1550 | const QString &datebook, |
1551 | const QString &todolist ) | 1551 | const QString &todolist ) |
1552 | { | 1552 | { |
1553 | 1553 | ||
1554 | QtopiaFormat qtopiaFormat; | 1554 | QtopiaFormat qtopiaFormat; |
1555 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1555 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1556 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1556 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1557 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1557 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1558 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1558 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1559 | 1559 | ||
1560 | updateView(); | 1560 | updateView(); |
1561 | return true; | 1561 | return true; |
1562 | 1562 | ||
1563 | #if 0 | 1563 | #if 0 |
1564 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1564 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1565 | mCurrentSyncDevice = "qtopia-XML"; | 1565 | mCurrentSyncDevice = "qtopia-XML"; |
1566 | if ( mSyncManager->mAskForPreferences ) | 1566 | if ( mSyncManager->mAskForPreferences ) |
1567 | edit_sync_options(); | 1567 | edit_sync_options(); |
1568 | qApp->processEvents(); | 1568 | qApp->processEvents(); |
1569 | CalendarLocal* calendar = new CalendarLocal(); | 1569 | CalendarLocal* calendar = new CalendarLocal(); |
1570 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1570 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1571 | bool syncOK = false; | 1571 | bool syncOK = false; |
1572 | QtopiaFormat qtopiaFormat; | 1572 | QtopiaFormat qtopiaFormat; |
1573 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1573 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1574 | bool loadOk = true; | 1574 | bool loadOk = true; |
1575 | if ( !categories.isEmpty() ) | 1575 | if ( !categories.isEmpty() ) |
1576 | loadOk = qtopiaFormat.load( calendar, categories ); | 1576 | loadOk = qtopiaFormat.load( calendar, categories ); |
1577 | if ( loadOk && !datebook.isEmpty() ) | 1577 | if ( loadOk && !datebook.isEmpty() ) |
1578 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1578 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1579 | if ( loadOk && !todolist.isEmpty() ) | 1579 | if ( loadOk && !todolist.isEmpty() ) |
1580 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1580 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1581 | 1581 | ||
1582 | if ( loadOk ) { | 1582 | if ( loadOk ) { |
1583 | getEventViewerDialog()->setSyncMode( true ); | 1583 | getEventViewerDialog()->setSyncMode( true ); |
1584 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1584 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1585 | getEventViewerDialog()->setSyncMode( false ); | 1585 | getEventViewerDialog()->setSyncMode( false ); |
1586 | qApp->processEvents(); | 1586 | qApp->processEvents(); |
1587 | if ( syncOK ) { | 1587 | if ( syncOK ) { |
1588 | if ( mSyncManager->mWriteBackFile ) | 1588 | if ( mSyncManager->mWriteBackFile ) |
1589 | { | 1589 | { |
1590 | // write back XML file | 1590 | // write back XML file |
1591 | 1591 | ||
1592 | } | 1592 | } |
1593 | setModified( true ); | 1593 | setModified( true ); |
1594 | } | 1594 | } |
1595 | } else { | 1595 | } else { |
1596 | 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") ; |
1597 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1597 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1598 | question, i18n("Ok")) ; | 1598 | question, i18n("Ok")) ; |
1599 | } | 1599 | } |
1600 | delete calendar; | 1600 | delete calendar; |
1601 | updateView(); | 1601 | updateView(); |
1602 | return syncOK; | 1602 | return syncOK; |
1603 | 1603 | ||
1604 | 1604 | ||
1605 | #endif | 1605 | #endif |
1606 | 1606 | ||
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | void CalendarView::setSyncEventsReadOnly() | 1609 | void CalendarView::setSyncEventsReadOnly() |
1610 | { | 1610 | { |
1611 | Event * ev; | 1611 | Event * ev; |
1612 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1612 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1613 | ev = eL.first(); | 1613 | ev = eL.first(); |
1614 | while ( ev ) { | 1614 | while ( ev ) { |
1615 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1615 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1616 | ev->setReadOnly( true ); | 1616 | ev->setReadOnly( true ); |
1617 | ev = eL.next(); | 1617 | ev = eL.next(); |
1618 | } | 1618 | } |
1619 | } | 1619 | } |
1620 | bool CalendarView::openCalendar(QString filename, bool merge) | 1620 | bool CalendarView::openCalendar(QString filename, bool merge) |
1621 | { | 1621 | { |
1622 | 1622 | ||
1623 | if (filename.isEmpty()) { | 1623 | if (filename.isEmpty()) { |
1624 | return false; | 1624 | return false; |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | if (!QFile::exists(filename)) { | 1627 | if (!QFile::exists(filename)) { |
1628 | 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)); |
1629 | return false; | 1629 | return false; |
1630 | } | 1630 | } |
1631 | 1631 | ||
1632 | globalFlagBlockAgenda = 1; | 1632 | globalFlagBlockAgenda = 1; |
1633 | if (!merge) mCalendar->close(); | 1633 | if (!merge) mCalendar->close(); |
1634 | 1634 | ||
1635 | mStorage->setFileName( filename ); | 1635 | mStorage->setFileName( filename ); |
1636 | 1636 | ||
1637 | if ( mStorage->load() ) { | 1637 | if ( mStorage->load() ) { |
1638 | if ( merge ) ;//setModified( true ); | 1638 | if ( merge ) ;//setModified( true ); |
1639 | else { | 1639 | else { |
1640 | //setModified( true ); | 1640 | //setModified( true ); |
1641 | mViewManager->setDocumentId( filename ); | 1641 | mViewManager->setDocumentId( filename ); |
1642 | mDialogManager->setDocumentId( filename ); | 1642 | mDialogManager->setDocumentId( filename ); |
1643 | mTodoList->setDocumentId( filename ); | 1643 | mTodoList->setDocumentId( filename ); |
1644 | } | 1644 | } |
1645 | globalFlagBlockAgenda = 2; | 1645 | globalFlagBlockAgenda = 2; |
1646 | // if ( getLastSyncEvent() ) | 1646 | // if ( getLastSyncEvent() ) |
1647 | // getLastSyncEvent()->setReadOnly( true ); | 1647 | // getLastSyncEvent()->setReadOnly( true ); |
1648 | mCalendar->reInitAlarmSettings(); | 1648 | mCalendar->reInitAlarmSettings(); |
1649 | setSyncEventsReadOnly(); | 1649 | setSyncEventsReadOnly(); |
1650 | updateUnmanagedViews(); | 1650 | updateUnmanagedViews(); |
1651 | updateView(); | 1651 | updateView(); |
1652 | if ( filename != MainWindow::defaultFileName() ) { | 1652 | if ( filename != MainWindow::defaultFileName() ) { |
1653 | saveCalendar( MainWindow::defaultFileName() ); | 1653 | saveCalendar( MainWindow::defaultFileName() ); |
1654 | } else { | 1654 | } else { |
1655 | QFileInfo finf ( MainWindow::defaultFileName()); | 1655 | QFileInfo finf ( MainWindow::defaultFileName()); |
1656 | if ( finf.exists() ) { | 1656 | if ( finf.exists() ) { |
1657 | setLoadedFileVersion( finf.lastModified () ); | 1657 | setLoadedFileVersion( finf.lastModified () ); |
1658 | } | 1658 | } |
1659 | } | 1659 | } |
1660 | return true; | 1660 | return true; |
1661 | } else { | 1661 | } else { |
1662 | // while failing to load, the calendar object could | 1662 | // while failing to load, the calendar object could |
1663 | // have become partially populated. Clear it out. | 1663 | // have become partially populated. Clear it out. |
1664 | if ( !merge ) { | 1664 | if ( !merge ) { |
1665 | mCalendar->close(); | 1665 | mCalendar->close(); |
1666 | mViewManager->setDocumentId( filename ); | 1666 | mViewManager->setDocumentId( filename ); |
1667 | mDialogManager->setDocumentId( filename ); | 1667 | mDialogManager->setDocumentId( filename ); |
1668 | mTodoList->setDocumentId( filename ); | 1668 | mTodoList->setDocumentId( filename ); |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | //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)); |
1672 | 1672 | ||
1673 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1673 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1674 | globalFlagBlockAgenda = 2; | 1674 | globalFlagBlockAgenda = 2; |
1675 | mCalendar->reInitAlarmSettings(); | 1675 | mCalendar->reInitAlarmSettings(); |
1676 | setSyncEventsReadOnly(); | 1676 | setSyncEventsReadOnly(); |
1677 | updateUnmanagedViews(); | 1677 | updateUnmanagedViews(); |
1678 | updateView(); | 1678 | updateView(); |
1679 | } | 1679 | } |
1680 | return false; | 1680 | return false; |
1681 | } | 1681 | } |
1682 | void CalendarView::showOpenError() | 1682 | void CalendarView::showOpenError() |
1683 | { | 1683 | { |
1684 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1684 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1685 | } | 1685 | } |
1686 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1686 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1687 | { | 1687 | { |
1688 | loadedFileVersion = dt; | 1688 | loadedFileVersion = dt; |
1689 | } | 1689 | } |
1690 | bool CalendarView::checkFileChanged(QString fn) | 1690 | bool CalendarView::checkFileChanged(QString fn) |
1691 | { | 1691 | { |
1692 | QFileInfo finf ( fn ); | 1692 | QFileInfo finf ( fn ); |
1693 | if ( !finf.exists() ) | 1693 | if ( !finf.exists() ) |
1694 | return true; | 1694 | return true; |
1695 | QDateTime dt = finf.lastModified (); | 1695 | QDateTime dt = finf.lastModified (); |
1696 | if ( dt <= loadedFileVersion ) | 1696 | if ( dt <= loadedFileVersion ) |
1697 | return false; | 1697 | return false; |
1698 | return true; | 1698 | return true; |
1699 | 1699 | ||
1700 | } | 1700 | } |
1701 | void CalendarView::watchSavedFile() | 1701 | void CalendarView::watchSavedFile() |
1702 | { | 1702 | { |
1703 | QFileInfo finf ( MainWindow::defaultFileName()); | 1703 | QFileInfo finf ( MainWindow::defaultFileName()); |
1704 | if ( !finf.exists() ) | 1704 | if ( !finf.exists() ) |
1705 | return; | 1705 | return; |
1706 | QDateTime dt = finf.lastModified (); | 1706 | QDateTime dt = finf.lastModified (); |
1707 | if ( dt < loadedFileVersion ) { | 1707 | if ( dt < loadedFileVersion ) { |
1708 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1708 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1709 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1709 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1710 | return; | 1710 | return; |
1711 | } | 1711 | } |
1712 | loadedFileVersion = dt; | 1712 | loadedFileVersion = dt; |
1713 | } | 1713 | } |
1714 | 1714 | ||
1715 | bool CalendarView::checkFileVersion(QString fn) | 1715 | bool CalendarView::checkFileVersion(QString fn) |
1716 | { | 1716 | { |
1717 | QFileInfo finf ( fn ); | 1717 | QFileInfo finf ( fn ); |
1718 | if ( !finf.exists() ) | 1718 | if ( !finf.exists() ) |
1719 | return true; | 1719 | return true; |
1720 | QDateTime dt = finf.lastModified (); | 1720 | QDateTime dt = finf.lastModified (); |
1721 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1721 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1722 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1722 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1723 | if ( dt <= loadedFileVersion ) | 1723 | if ( dt <= loadedFileVersion ) |
1724 | return true; | 1724 | return 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)) , | 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)) , |
1726 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1726 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1727 | i18n("Sync+save")); | 1727 | i18n("Sync+save")); |
1728 | 1728 | ||
1729 | if ( km == KMessageBox::Cancel ) | 1729 | if ( km == KMessageBox::Cancel ) |
1730 | return false; | 1730 | return false; |
1731 | if ( km == KMessageBox::Yes ) | 1731 | if ( km == KMessageBox::Yes ) |
1732 | return true; | 1732 | return true; |
1733 | 1733 | ||
1734 | setSyncDevice("deleteaftersync" ); | 1734 | setSyncDevice("deleteaftersync" ); |
1735 | mSyncManager->mAskForPreferences = true; | 1735 | mSyncManager->mAskForPreferences = true; |
1736 | mSyncManager->mSyncAlgoPrefs = 3; | 1736 | mSyncManager->mSyncAlgoPrefs = 3; |
1737 | mSyncManager->mWriteBackFile = false; | 1737 | mSyncManager->mWriteBackFile = false; |
1738 | mSyncManager->mWriteBackExistingOnly = false; | 1738 | mSyncManager->mWriteBackExistingOnly = false; |
1739 | mSyncManager->mShowSyncSummary = false; | 1739 | mSyncManager->mShowSyncSummary = false; |
1740 | syncCalendar( fn, 3 ); | 1740 | syncCalendar( fn, 3 ); |
1741 | Event * e = getLastSyncEvent(); | 1741 | Event * e = getLastSyncEvent(); |
1742 | mCalendar->deleteEvent ( e ); | 1742 | mCalendar->deleteEvent ( e ); |
1743 | updateView(); | 1743 | updateView(); |
1744 | return true; | 1744 | return true; |
1745 | } | 1745 | } |
1746 | 1746 | ||
1747 | bool CalendarView::saveCalendar( QString filename ) | 1747 | bool CalendarView::saveCalendar( QString filename ) |
1748 | { | 1748 | { |
1749 | 1749 | ||
1750 | // Store back all unsaved data into calendar object | 1750 | // Store back all unsaved data into calendar object |
1751 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1751 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1752 | if ( mViewManager->currentView() ) | 1752 | if ( mViewManager->currentView() ) |
1753 | mViewManager->currentView()->flushView(); | 1753 | mViewManager->currentView()->flushView(); |
1754 | 1754 | ||
1755 | 1755 | ||
1756 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1756 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1757 | mStorage->setSaveFormat( new ICalFormat() ); | 1757 | mStorage->setSaveFormat( new ICalFormat() ); |
1758 | mStorage->setFileName( filename ); | 1758 | mStorage->setFileName( filename ); |
1759 | bool success; | 1759 | bool success; |
1760 | success = mStorage->save(); | 1760 | success = mStorage->save(); |
1761 | if ( !success ) { | 1761 | if ( !success ) { |
1762 | return false; | 1762 | return false; |
1763 | } | 1763 | } |
1764 | if ( filename == MainWindow::defaultFileName() ) { | 1764 | if ( filename == MainWindow::defaultFileName() ) { |
1765 | setLoadedFileVersion( lfv ); | 1765 | setLoadedFileVersion( lfv ); |
1766 | watchSavedFile(); | 1766 | watchSavedFile(); |
1767 | } | 1767 | } |
1768 | return true; | 1768 | return true; |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | void CalendarView::closeCalendar() | 1771 | void CalendarView::closeCalendar() |
1772 | { | 1772 | { |
1773 | 1773 | ||
1774 | // child windows no longer valid | 1774 | // child windows no longer valid |
1775 | emit closingDown(); | 1775 | emit closingDown(); |
1776 | 1776 | ||
1777 | mCalendar->close(); | 1777 | mCalendar->close(); |
1778 | setModified(false); | 1778 | setModified(false); |
1779 | updateView(); | 1779 | updateView(); |
1780 | } | 1780 | } |
1781 | 1781 | ||
1782 | void CalendarView::archiveCalendar() | 1782 | void CalendarView::archiveCalendar() |
1783 | { | 1783 | { |
1784 | mDialogManager->showArchiveDialog(); | 1784 | mDialogManager->showArchiveDialog(); |
1785 | } | 1785 | } |
1786 | 1786 | ||
1787 | 1787 | ||
1788 | void CalendarView::readSettings() | 1788 | void CalendarView::readSettings() |
1789 | { | 1789 | { |
1790 | 1790 | ||
1791 | 1791 | ||
1792 | // mViewManager->showAgendaView(); | 1792 | // mViewManager->showAgendaView(); |
1793 | QString str; | 1793 | QString str; |
1794 | //qDebug("CalendarView::readSettings() "); | 1794 | //qDebug("CalendarView::readSettings() "); |
1795 | // read settings from the KConfig, supplying reasonable | 1795 | // read settings from the KConfig, supplying reasonable |
1796 | // defaults where none are to be found | 1796 | // defaults where none are to be found |
1797 | KConfig *config = KOGlobals::config(); | 1797 | KConfig *config = KOGlobals::config(); |
1798 | #ifndef KORG_NOSPLITTER | 1798 | #ifndef KORG_NOSPLITTER |
1799 | config->setGroup("KOrganizer Geometry"); | 1799 | config->setGroup("KOrganizer Geometry"); |
1800 | 1800 | ||
1801 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1801 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1802 | if (sizes.count() != 2) { | 1802 | if (sizes.count() != 2) { |
1803 | sizes << mDateNavigator->minimumSizeHint().width(); | 1803 | sizes << mDateNavigator->minimumSizeHint().width(); |
1804 | sizes << 300; | 1804 | sizes << 300; |
1805 | } | 1805 | } |
1806 | mPanner->setSizes(sizes); | 1806 | mPanner->setSizes(sizes); |
1807 | 1807 | ||
1808 | sizes = config->readIntListEntry("Separator2"); | 1808 | sizes = config->readIntListEntry("Separator2"); |
1809 | if ( ( mResourceView && sizes.count() == 4 ) || | 1809 | if ( ( mResourceView && sizes.count() == 4 ) || |
1810 | ( !mResourceView && sizes.count() == 3 ) ) { | 1810 | ( !mResourceView && sizes.count() == 3 ) ) { |
1811 | mLeftSplitter->setSizes(sizes); | 1811 | mLeftSplitter->setSizes(sizes); |
1812 | } | 1812 | } |
1813 | #endif | 1813 | #endif |
1814 | globalFlagBlockAgenda = 1; | 1814 | globalFlagBlockAgenda = 1; |
1815 | mViewManager->showAgendaView(); | 1815 | mViewManager->showAgendaView(); |
1816 | //mViewManager->readSettings( config ); | 1816 | //mViewManager->readSettings( config ); |
1817 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1817 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1818 | readFilterSettings(config); | 1818 | readFilterSettings(config); |
1819 | config->setGroup( "Views" ); | 1819 | config->setGroup( "Views" ); |
1820 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1820 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1821 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1821 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1822 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1822 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1823 | else mNavigator->selectDates( dateCount ); | 1823 | else mNavigator->selectDates( dateCount ); |
1824 | // mViewManager->readSettings( config ); | 1824 | // mViewManager->readSettings( config ); |
1825 | updateConfig(); | 1825 | updateConfig(); |
1826 | globalFlagBlockAgenda = 2; | 1826 | globalFlagBlockAgenda = 2; |
1827 | mViewManager->readSettings( config ); | 1827 | mViewManager->readSettings( config ); |
1828 | #ifdef DESKTOP_VERSION | 1828 | #ifdef DESKTOP_VERSION |
1829 | config->setGroup("WidgetLayout"); | 1829 | config->setGroup("WidgetLayout"); |
1830 | QStringList list; | 1830 | QStringList list; |
1831 | list = config->readListEntry("MainLayout"); | 1831 | list = config->readListEntry("MainLayout"); |
1832 | int x,y,w,h; | 1832 | int x,y,w,h; |
1833 | if ( ! list.isEmpty() ) { | 1833 | if ( ! list.isEmpty() ) { |
1834 | x = list[0].toInt(); | 1834 | x = list[0].toInt(); |
1835 | y = list[1].toInt(); | 1835 | y = list[1].toInt(); |
1836 | w = list[2].toInt(); | 1836 | w = list[2].toInt(); |
1837 | h = list[3].toInt(); | 1837 | h = list[3].toInt(); |
1838 | topLevelWidget()->setGeometry(x,y,w,h); | 1838 | topLevelWidget()->setGeometry(x,y,w,h); |
1839 | 1839 | ||
1840 | } else { | 1840 | } else { |
1841 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1841 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1842 | } | 1842 | } |
1843 | list = config->readListEntry("EditEventLayout"); | 1843 | list = config->readListEntry("EditEventLayout"); |
1844 | if ( ! list.isEmpty() ) { | 1844 | if ( ! list.isEmpty() ) { |
1845 | x = list[0].toInt(); | 1845 | x = list[0].toInt(); |
1846 | y = list[1].toInt(); | 1846 | y = list[1].toInt(); |
1847 | w = list[2].toInt(); | 1847 | w = list[2].toInt(); |
1848 | h = list[3].toInt(); | 1848 | h = list[3].toInt(); |
1849 | mEventEditor->setGeometry(x,y,w,h); | 1849 | mEventEditor->setGeometry(x,y,w,h); |
1850 | 1850 | ||
1851 | } | 1851 | } |
1852 | list = config->readListEntry("EditTodoLayout"); | 1852 | list = config->readListEntry("EditTodoLayout"); |
1853 | if ( ! list.isEmpty() ) { | 1853 | if ( ! list.isEmpty() ) { |
1854 | x = list[0].toInt(); | 1854 | x = list[0].toInt(); |
1855 | y = list[1].toInt(); | 1855 | y = list[1].toInt(); |
1856 | w = list[2].toInt(); | 1856 | w = list[2].toInt(); |
1857 | h = list[3].toInt(); | 1857 | h = list[3].toInt(); |
1858 | mTodoEditor->setGeometry(x,y,w,h); | 1858 | mTodoEditor->setGeometry(x,y,w,h); |
1859 | 1859 | ||
1860 | } | 1860 | } |
1861 | list = config->readListEntry("ViewerLayout"); | 1861 | list = config->readListEntry("ViewerLayout"); |
1862 | if ( ! list.isEmpty() ) { | 1862 | if ( ! list.isEmpty() ) { |
1863 | x = list[0].toInt(); | 1863 | x = list[0].toInt(); |
1864 | y = list[1].toInt(); | 1864 | y = list[1].toInt(); |
1865 | w = list[2].toInt(); | 1865 | w = list[2].toInt(); |
1866 | h = list[3].toInt(); | 1866 | h = list[3].toInt(); |
1867 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1867 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1868 | } | 1868 | } |
1869 | #endif | 1869 | #endif |
1870 | 1870 | ||
1871 | } | 1871 | } |
1872 | 1872 | ||
1873 | 1873 | ||
1874 | void CalendarView::writeSettings() | 1874 | void CalendarView::writeSettings() |
1875 | { | 1875 | { |
1876 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1876 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1877 | 1877 | ||
1878 | KConfig *config = KOGlobals::config(); | 1878 | KConfig *config = KOGlobals::config(); |
1879 | 1879 | ||
1880 | #ifndef KORG_NOSPLITTER | 1880 | #ifndef KORG_NOSPLITTER |
1881 | config->setGroup("KOrganizer Geometry"); | 1881 | config->setGroup("KOrganizer Geometry"); |
1882 | 1882 | ||
1883 | QValueList<int> list = mPanner->sizes(); | 1883 | QValueList<int> list = mPanner->sizes(); |
1884 | config->writeEntry("Separator1",list); | 1884 | config->writeEntry("Separator1",list); |
1885 | 1885 | ||
1886 | list = mLeftSplitter->sizes(); | 1886 | list = mLeftSplitter->sizes(); |
1887 | config->writeEntry("Separator2",list); | 1887 | config->writeEntry("Separator2",list); |
1888 | #endif | 1888 | #endif |
1889 | 1889 | ||
1890 | mViewManager->writeSettings( config ); | 1890 | mViewManager->writeSettings( config ); |
1891 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1891 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1892 | mDialogManager->writeSettings( config ); | 1892 | mDialogManager->writeSettings( config ); |
1893 | //KOPrefs::instance()->usrWriteConfig(); | 1893 | //KOPrefs::instance()->usrWriteConfig(); |
1894 | KOPrefs::instance()->writeConfig(); | 1894 | KOPrefs::instance()->writeConfig(); |
1895 | 1895 | ||
1896 | writeFilterSettings(config); | 1896 | writeFilterSettings(config); |
1897 | 1897 | ||
1898 | config->setGroup( "Views" ); | 1898 | config->setGroup( "Views" ); |
1899 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1899 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1900 | 1900 | ||
1901 | #ifdef DESKTOP_VERSION | 1901 | #ifdef DESKTOP_VERSION |
1902 | config->setGroup("WidgetLayout"); | 1902 | config->setGroup("WidgetLayout"); |
1903 | QStringList list ;//= config->readListEntry("MainLayout"); | 1903 | QStringList list ;//= config->readListEntry("MainLayout"); |
1904 | int x,y,w,h; | 1904 | int x,y,w,h; |
1905 | QWidget* wid; | 1905 | QWidget* wid; |
1906 | wid = topLevelWidget(); | 1906 | wid = topLevelWidget(); |
1907 | x = wid->geometry().x(); | 1907 | x = wid->geometry().x(); |
1908 | y = wid->geometry().y(); | 1908 | y = wid->geometry().y(); |
1909 | w = wid->width(); | 1909 | w = wid->width(); |
1910 | h = wid->height(); | 1910 | h = wid->height(); |
1911 | list.clear(); | 1911 | list.clear(); |
1912 | list << QString::number( x ); | 1912 | list << QString::number( x ); |
1913 | list << QString::number( y ); | 1913 | list << QString::number( y ); |
1914 | list << QString::number( w ); | 1914 | list << QString::number( w ); |
1915 | list << QString::number( h ); | 1915 | list << QString::number( h ); |
1916 | config->writeEntry("MainLayout",list ); | 1916 | config->writeEntry("MainLayout",list ); |
1917 | 1917 | ||
1918 | wid = mEventEditor; | 1918 | wid = mEventEditor; |
1919 | x = wid->geometry().x(); | 1919 | x = wid->geometry().x(); |
1920 | y = wid->geometry().y(); | 1920 | y = wid->geometry().y(); |
1921 | w = wid->width(); | 1921 | w = wid->width(); |
1922 | h = wid->height(); | 1922 | h = wid->height(); |
1923 | list.clear(); | 1923 | list.clear(); |
1924 | list << QString::number( x ); | 1924 | list << QString::number( x ); |
1925 | list << QString::number( y ); | 1925 | list << QString::number( y ); |
1926 | list << QString::number( w ); | 1926 | list << QString::number( w ); |
1927 | list << QString::number( h ); | 1927 | list << QString::number( h ); |
1928 | config->writeEntry("EditEventLayout",list ); | 1928 | config->writeEntry("EditEventLayout",list ); |
1929 | 1929 | ||
1930 | wid = mTodoEditor; | 1930 | wid = mTodoEditor; |
1931 | x = wid->geometry().x(); | 1931 | x = wid->geometry().x(); |
1932 | y = wid->geometry().y(); | 1932 | y = wid->geometry().y(); |
1933 | w = wid->width(); | 1933 | w = wid->width(); |
1934 | h = wid->height(); | 1934 | h = wid->height(); |
1935 | list.clear(); | 1935 | list.clear(); |
1936 | list << QString::number( x ); | 1936 | list << QString::number( x ); |
1937 | list << QString::number( y ); | 1937 | list << QString::number( y ); |
1938 | list << QString::number( w ); | 1938 | list << QString::number( w ); |
1939 | list << QString::number( h ); | 1939 | list << QString::number( h ); |
1940 | config->writeEntry("EditTodoLayout",list ); | 1940 | config->writeEntry("EditTodoLayout",list ); |
1941 | wid = getEventViewerDialog(); | 1941 | wid = getEventViewerDialog(); |
1942 | x = wid->geometry().x(); | 1942 | x = wid->geometry().x(); |
1943 | y = wid->geometry().y(); | 1943 | y = wid->geometry().y(); |
1944 | w = wid->width(); | 1944 | w = wid->width(); |
1945 | h = wid->height(); | 1945 | h = wid->height(); |
1946 | list.clear(); | 1946 | list.clear(); |
1947 | list << QString::number( x ); | 1947 | list << QString::number( x ); |
1948 | list << QString::number( y ); | 1948 | list << QString::number( y ); |
1949 | list << QString::number( w ); | 1949 | list << QString::number( w ); |
1950 | list << QString::number( h ); | 1950 | list << QString::number( h ); |
1951 | config->writeEntry("ViewerLayout",list ); | 1951 | config->writeEntry("ViewerLayout",list ); |
1952 | wid = mDialogManager->getSearchDialog(); | 1952 | wid = mDialogManager->getSearchDialog(); |
1953 | if ( wid ) { | 1953 | if ( wid ) { |
1954 | x = wid->geometry().x(); | 1954 | x = wid->geometry().x(); |
1955 | y = wid->geometry().y(); | 1955 | y = wid->geometry().y(); |
1956 | w = wid->width(); | 1956 | w = wid->width(); |
1957 | h = wid->height(); | 1957 | h = wid->height(); |
1958 | list.clear(); | 1958 | list.clear(); |
1959 | list << QString::number( x ); | 1959 | list << QString::number( x ); |
1960 | list << QString::number( y ); | 1960 | list << QString::number( y ); |
1961 | list << QString::number( w ); | 1961 | list << QString::number( w ); |
1962 | list << QString::number( h ); | 1962 | list << QString::number( h ); |
1963 | config->writeEntry("SearchLayout",list ); | 1963 | config->writeEntry("SearchLayout",list ); |
1964 | } | 1964 | } |
1965 | #endif | 1965 | #endif |
1966 | 1966 | ||
1967 | 1967 | ||
1968 | config->sync(); | 1968 | config->sync(); |
1969 | } | 1969 | } |
1970 | 1970 | ||
1971 | void CalendarView::readFilterSettings(KConfig *config) | 1971 | void CalendarView::readFilterSettings(KConfig *config) |
1972 | { | 1972 | { |
1973 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1973 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1974 | 1974 | ||
1975 | mFilters.clear(); | 1975 | mFilters.clear(); |
1976 | 1976 | ||
1977 | config->setGroup("General"); | 1977 | config->setGroup("General"); |
1978 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1978 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1979 | 1979 | ||
1980 | QStringList::ConstIterator it = filterList.begin(); | 1980 | QStringList::ConstIterator it = filterList.begin(); |
1981 | QStringList::ConstIterator end = filterList.end(); | 1981 | QStringList::ConstIterator end = filterList.end(); |
1982 | while(it != end) { | 1982 | while(it != end) { |
1983 | // kdDebug() << " filter: " << (*it) << endl; | 1983 | // kdDebug() << " filter: " << (*it) << endl; |
1984 | 1984 | ||
1985 | CalFilter *filter; | 1985 | CalFilter *filter; |
1986 | filter = new CalFilter(*it); | 1986 | filter = new CalFilter(*it); |
1987 | config->setGroup("Filter_" + (*it)); | 1987 | config->setGroup("Filter_" + (*it)); |
1988 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1988 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1989 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1989 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1990 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1990 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1991 | mFilters.append(filter); | 1991 | mFilters.append(filter); |
1992 | 1992 | ||
1993 | ++it; | 1993 | ++it; |
1994 | } | 1994 | } |
1995 | 1995 | ||
1996 | if (mFilters.count() == 0) { | 1996 | if (mFilters.count() == 0) { |
1997 | CalFilter *filter = new CalFilter(i18n("Default")); | 1997 | CalFilter *filter = new CalFilter(i18n("Default")); |
1998 | mFilters.append(filter); | 1998 | mFilters.append(filter); |
1999 | } | 1999 | } |
2000 | mFilterView->updateFilters(); | 2000 | mFilterView->updateFilters(); |
2001 | config->setGroup("FilterView"); | 2001 | config->setGroup("FilterView"); |
2002 | 2002 | ||
2003 | mFilterView->blockSignals(true); | 2003 | mFilterView->blockSignals(true); |
2004 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2004 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2005 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2005 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2006 | mFilterView->blockSignals(false); | 2006 | mFilterView->blockSignals(false); |
2007 | // 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 |
2008 | updateFilter(); | 2008 | updateFilter(); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | void CalendarView::writeFilterSettings(KConfig *config) | 2011 | void CalendarView::writeFilterSettings(KConfig *config) |
2012 | { | 2012 | { |
2013 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2013 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2014 | 2014 | ||
2015 | QStringList filterList; | 2015 | QStringList filterList; |
2016 | 2016 | ||
2017 | CalFilter *filter = mFilters.first(); | 2017 | CalFilter *filter = mFilters.first(); |
2018 | while(filter) { | 2018 | while(filter) { |
2019 | // kdDebug() << " fn: " << filter->name() << endl; | 2019 | // kdDebug() << " fn: " << filter->name() << endl; |
2020 | filterList << filter->name(); | 2020 | filterList << filter->name(); |
2021 | config->setGroup("Filter_" + filter->name()); | 2021 | config->setGroup("Filter_" + filter->name()); |
2022 | config->writeEntry("Criteria",filter->criteria()); | 2022 | config->writeEntry("Criteria",filter->criteria()); |
2023 | config->writeEntry("CategoryList",filter->categoryList()); | 2023 | config->writeEntry("CategoryList",filter->categoryList()); |
2024 | filter = mFilters.next(); | 2024 | filter = mFilters.next(); |
2025 | } | 2025 | } |
2026 | config->setGroup("General"); | 2026 | config->setGroup("General"); |
2027 | config->writeEntry("CalendarFilters",filterList); | 2027 | config->writeEntry("CalendarFilters",filterList); |
2028 | 2028 | ||
2029 | config->setGroup("FilterView"); | 2029 | config->setGroup("FilterView"); |
2030 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2030 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2031 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2031 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2032 | } | 2032 | } |
2033 | 2033 | ||
2034 | 2034 | ||
2035 | void CalendarView::goToday() | 2035 | void CalendarView::goToday() |
2036 | { | 2036 | { |
2037 | if ( mViewManager->currentView()->isMonthView() ) | 2037 | if ( mViewManager->currentView()->isMonthView() ) |
2038 | mNavigator->selectTodayMonth(); | 2038 | mNavigator->selectTodayMonth(); |
2039 | else | 2039 | else |
2040 | mNavigator->selectToday(); | 2040 | mNavigator->selectToday(); |
2041 | } | 2041 | } |
2042 | 2042 | ||
2043 | void CalendarView::goNext() | 2043 | void CalendarView::goNext() |
2044 | { | 2044 | { |
2045 | mNavigator->selectNext(); | 2045 | mNavigator->selectNext(); |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | void CalendarView::goPrevious() | 2048 | void CalendarView::goPrevious() |
2049 | { | 2049 | { |
2050 | mNavigator->selectPrevious(); | 2050 | mNavigator->selectPrevious(); |
2051 | } | 2051 | } |
2052 | void CalendarView::goNextMonth() | 2052 | void CalendarView::goNextMonth() |
2053 | { | 2053 | { |
2054 | mNavigator->selectNextMonth(); | 2054 | mNavigator->selectNextMonth(); |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void CalendarView::goPreviousMonth() | 2057 | void CalendarView::goPreviousMonth() |
2058 | { | 2058 | { |
2059 | mNavigator->selectPreviousMonth(); | 2059 | mNavigator->selectPreviousMonth(); |
2060 | } | 2060 | } |
2061 | void CalendarView::writeLocale() | 2061 | void CalendarView::writeLocale() |
2062 | { | 2062 | { |
2063 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2063 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2064 | #if 0 | 2064 | #if 0 |
2065 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2065 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2066 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2066 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2067 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2067 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2068 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2068 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2069 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2069 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2070 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2070 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2071 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2071 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2072 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2072 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2073 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2073 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2074 | KOPrefs::instance()->mDaylightsavingStart, | 2074 | KOPrefs::instance()->mDaylightsavingStart, |
2075 | KOPrefs::instance()->mDaylightsavingEnd ); | 2075 | KOPrefs::instance()->mDaylightsavingEnd ); |
2076 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2076 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2077 | #endif | 2077 | #endif |
2078 | } | 2078 | } |
2079 | void CalendarView::updateConfig() | 2079 | void CalendarView::updateConfig() |
2080 | { | 2080 | { |
2081 | writeLocale(); | 2081 | writeLocale(); |
2082 | if ( KOPrefs::instance()->mUseAppColors ) | 2082 | if ( KOPrefs::instance()->mUseAppColors ) |
2083 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2083 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2084 | emit configChanged(); | 2084 | emit configChanged(); |
2085 | mTodoList->updateConfig(); | 2085 | mTodoList->updateConfig(); |
2086 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2086 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2087 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2087 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2088 | // To make the "fill window" configurations work | 2088 | // To make the "fill window" configurations work |
2089 | //mViewManager->raiseCurrentView(); | 2089 | //mViewManager->raiseCurrentView(); |
2090 | } | 2090 | } |
2091 | 2091 | ||
2092 | 2092 | ||
2093 | void CalendarView::eventChanged(Event *event) | 2093 | void CalendarView::eventChanged(Event *event) |
2094 | { | 2094 | { |
2095 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2095 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2096 | //updateUnmanagedViews(); | 2096 | //updateUnmanagedViews(); |
2097 | } | 2097 | } |
2098 | 2098 | ||
2099 | void CalendarView::eventAdded(Event *event) | 2099 | void CalendarView::eventAdded(Event *event) |
2100 | { | 2100 | { |
2101 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2101 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2102 | } | 2102 | } |
2103 | 2103 | ||
2104 | void CalendarView::eventToBeDeleted(Event *) | 2104 | void CalendarView::eventToBeDeleted(Event *) |
2105 | { | 2105 | { |
2106 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2106 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | void CalendarView::eventDeleted() | 2109 | void CalendarView::eventDeleted() |
2110 | { | 2110 | { |
2111 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2111 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2112 | } | 2112 | } |
2113 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2113 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2114 | { | 2114 | { |
2115 | changeIncidenceDisplay((Incidence *)which, action); | 2115 | changeIncidenceDisplay((Incidence *)which, action); |
2116 | mDateNavigator->updateView(); //LR | 2116 | mDateNavigator->updateView(); //LR |
2117 | //mDialogManager->updateSearchDialog(); | 2117 | //mDialogManager->updateSearchDialog(); |
2118 | 2118 | ||
2119 | if (which) { | 2119 | if (which) { |
2120 | mViewManager->updateWNview(); | 2120 | mViewManager->updateWNview(); |
2121 | //mTodoList->updateView(); | 2121 | //mTodoList->updateView(); |
2122 | } | 2122 | } |
2123 | 2123 | ||
2124 | } | 2124 | } |
2125 | 2125 | ||
2126 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2126 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2127 | { | 2127 | { |
2128 | updateUnmanagedViews(); | 2128 | updateUnmanagedViews(); |
2129 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2129 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2130 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2130 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2131 | mCalendar->checkAlarmForIncidence( 0, true ); | 2131 | mCalendar->checkAlarmForIncidence( 0, true ); |
2132 | if ( mEventViewerDialog ) | 2132 | if ( mEventViewerDialog ) |
2133 | mEventViewerDialog->hide(); | 2133 | mEventViewerDialog->hide(); |
2134 | } | 2134 | } |
2135 | else | 2135 | else |
2136 | mCalendar->checkAlarmForIncidence( which , false ); | 2136 | mCalendar->checkAlarmForIncidence( which , false ); |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | // most of the changeEventDisplays() right now just call the view's | 2139 | // most of the changeEventDisplays() right now just call the view's |
2140 | // 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. |
2141 | void CalendarView::changeEventDisplay(Event *which, int action) | 2141 | void CalendarView::changeEventDisplay(Event *which, int action) |
2142 | { | 2142 | { |
2143 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2143 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2144 | changeIncidenceDisplay((Incidence *)which, action); | 2144 | changeIncidenceDisplay((Incidence *)which, action); |
2145 | mDateNavigator->updateView(); | 2145 | mDateNavigator->updateView(); |
2146 | //mDialogManager->updateSearchDialog(); | 2146 | //mDialogManager->updateSearchDialog(); |
2147 | 2147 | ||
2148 | if (which) { | 2148 | if (which) { |
2149 | // If there is an event view visible update the display | 2149 | // If there is an event view visible update the display |
2150 | mViewManager->currentView()->changeEventDisplay(which,action); | 2150 | mViewManager->currentView()->changeEventDisplay(which,action); |
2151 | // TODO: check, if update needed | 2151 | // TODO: check, if update needed |
2152 | // if (which->getTodoStatus()) { | 2152 | // if (which->getTodoStatus()) { |
2153 | mTodoList->updateView(); | 2153 | mTodoList->updateView(); |
2154 | // } | 2154 | // } |
2155 | } else { | 2155 | } else { |
2156 | mViewManager->currentView()->updateView(); | 2156 | mViewManager->currentView()->updateView(); |
2157 | } | 2157 | } |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | 2160 | ||
2161 | void CalendarView::updateTodoViews() | 2161 | void CalendarView::updateTodoViews() |
2162 | { | 2162 | { |
2163 | 2163 | ||
2164 | mTodoList->updateView(); | 2164 | mTodoList->updateView(); |
2165 | mViewManager->currentView()->updateView(); | 2165 | mViewManager->currentView()->updateView(); |
2166 | 2166 | ||
2167 | } | 2167 | } |
2168 | 2168 | ||
2169 | 2169 | ||
2170 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2170 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2171 | { | 2171 | { |
2172 | mTodoList->updateView(); | 2172 | mTodoList->updateView(); |
2173 | mViewManager->updateView(start, end); | 2173 | mViewManager->updateView(start, end); |
2174 | //mDateNavigator->updateView(); | 2174 | //mDateNavigator->updateView(); |
2175 | } | 2175 | } |
2176 | 2176 | ||
2177 | void CalendarView::updateView() | 2177 | void CalendarView::updateView() |
2178 | { | 2178 | { |
2179 | DateList tmpList = mNavigator->selectedDates(); | 2179 | DateList tmpList = mNavigator->selectedDates(); |
2180 | 2180 | ||
2181 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2181 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2182 | mTodoList->updateView(); | 2182 | mTodoList->updateView(); |
2183 | // We assume that the navigator only selects consecutive days. | 2183 | // We assume that the navigator only selects consecutive days. |
2184 | updateView( tmpList.first(), tmpList.last() ); | 2184 | updateView( tmpList.first(), tmpList.last() ); |
2185 | } | 2185 | } |
2186 | 2186 | ||
2187 | void CalendarView::updateUnmanagedViews() | 2187 | void CalendarView::updateUnmanagedViews() |
2188 | { | 2188 | { |
2189 | mDateNavigator->updateDayMatrix(); | 2189 | mDateNavigator->updateDayMatrix(); |
2190 | } | 2190 | } |
2191 | 2191 | ||
2192 | int CalendarView::msgItemDelete(const QString name) | 2192 | int CalendarView::msgItemDelete(const QString name) |
2193 | { | 2193 | { |
2194 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2194 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2195 | i18n("This item will be\npermanently deleted."), | 2195 | i18n("This item will be\npermanently deleted."), |
2196 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2196 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2197 | } | 2197 | } |
2198 | 2198 | ||
2199 | 2199 | ||
2200 | void CalendarView::edit_cut() | 2200 | void CalendarView::edit_cut() |
2201 | { | 2201 | { |
2202 | Event *anEvent=0; | 2202 | Event *anEvent=0; |
2203 | 2203 | ||
2204 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2204 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2205 | 2205 | ||
2206 | if (mViewManager->currentView()->isEventView()) { | 2206 | if (mViewManager->currentView()->isEventView()) { |
2207 | if ( incidence && incidence->type() == "Event" ) { | 2207 | if ( incidence && incidence->type() == "Event" ) { |
2208 | anEvent = static_cast<Event *>(incidence); | 2208 | anEvent = static_cast<Event *>(incidence); |
2209 | } | 2209 | } |
2210 | } | 2210 | } |
2211 | 2211 | ||
2212 | if (!anEvent) { | 2212 | if (!anEvent) { |
2213 | KNotifyClient::beep(); | 2213 | KNotifyClient::beep(); |
2214 | return; | 2214 | return; |
2215 | } | 2215 | } |
2216 | DndFactory factory( mCalendar ); | 2216 | DndFactory factory( mCalendar ); |
2217 | factory.cutIncidence(anEvent); | 2217 | factory.cutIncidence(anEvent); |
2218 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2218 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2219 | } | 2219 | } |
2220 | 2220 | ||
2221 | void CalendarView::edit_copy() | 2221 | void CalendarView::edit_copy() |
2222 | { | 2222 | { |
2223 | Event *anEvent=0; | 2223 | Event *anEvent=0; |
2224 | 2224 | ||
2225 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2225 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2226 | 2226 | ||
2227 | if (mViewManager->currentView()->isEventView()) { | 2227 | if (mViewManager->currentView()->isEventView()) { |
2228 | if ( incidence && incidence->type() == "Event" ) { | 2228 | if ( incidence && incidence->type() == "Event" ) { |
2229 | anEvent = static_cast<Event *>(incidence); | 2229 | anEvent = static_cast<Event *>(incidence); |
2230 | } | 2230 | } |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | if (!anEvent) { | 2233 | if (!anEvent) { |
2234 | KNotifyClient::beep(); | 2234 | KNotifyClient::beep(); |
2235 | return; | 2235 | return; |
2236 | } | 2236 | } |
2237 | DndFactory factory( mCalendar ); | 2237 | DndFactory factory( mCalendar ); |
2238 | factory.copyIncidence(anEvent); | 2238 | factory.copyIncidence(anEvent); |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void CalendarView::edit_paste() | 2241 | void CalendarView::edit_paste() |
2242 | { | 2242 | { |
2243 | QDate date = mNavigator->selectedDates().first(); | 2243 | QDate date = mNavigator->selectedDates().first(); |
2244 | 2244 | ||
2245 | DndFactory factory( mCalendar ); | 2245 | DndFactory factory( mCalendar ); |
2246 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2246 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2247 | 2247 | ||
2248 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2248 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2249 | } | 2249 | } |
2250 | 2250 | ||
2251 | void CalendarView::edit_options() | 2251 | void CalendarView::edit_options() |
2252 | { | 2252 | { |
2253 | mDialogManager->showOptionsDialog(); | 2253 | mDialogManager->showOptionsDialog(); |
2254 | //writeSettings(); | 2254 | //writeSettings(); |
2255 | } | 2255 | } |
2256 | 2256 | ||
2257 | 2257 | ||
2258 | void CalendarView::slotSelectPickerDate( QDate d) | 2258 | void CalendarView::slotSelectPickerDate( QDate d) |
2259 | { | 2259 | { |
2260 | mDateFrame->hide(); | 2260 | mDateFrame->hide(); |
2261 | if ( mDatePickerMode == 1 ) { | 2261 | if ( mDatePickerMode == 1 ) { |
2262 | mNavigator->slotDaySelect( d ); | 2262 | mNavigator->slotDaySelect( d ); |
2263 | } else if ( mDatePickerMode == 2 ) { | 2263 | } else if ( mDatePickerMode == 2 ) { |
2264 | if ( mMoveIncidence->type() == "Todo" ) { | 2264 | if ( mMoveIncidence->type() == "Todo" ) { |
2265 | Todo * to = (Todo *) mMoveIncidence; | 2265 | Todo * to = (Todo *) mMoveIncidence; |
2266 | QTime tim; | 2266 | QTime tim; |
2267 | if ( to->hasDueDate() ) | 2267 | if ( to->hasDueDate() ) |
2268 | tim = to->dtDue().time(); | 2268 | tim = to->dtDue().time(); |
2269 | else { | 2269 | else { |
2270 | tim = QTime ( 0,0,0 ); | 2270 | tim = QTime ( 0,0,0 ); |
2271 | to->setFloats( true ); | 2271 | to->setFloats( true ); |
2272 | to->setHasDueDate( true ); | 2272 | to->setHasDueDate( true ); |
2273 | } | 2273 | } |
2274 | QDateTime dt ( d,tim ); | 2274 | QDateTime dt ( d,tim ); |
2275 | to->setDtDue( dt ); | 2275 | to->setDtDue( dt ); |
2276 | todoChanged( to ); | 2276 | todoChanged( to ); |
2277 | } else { | 2277 | } else { |
2278 | if ( mMoveIncidence->doesRecur() ) { | 2278 | if ( mMoveIncidence->doesRecur() ) { |
2279 | #if 0 | 2279 | #if 0 |
2280 | // PENDING implement this | 2280 | // PENDING implement this |
2281 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2281 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2282 | mCalendar()->addIncidence( newInc ); | 2282 | mCalendar()->addIncidence( newInc ); |
2283 | if ( mMoveIncidence->type() == "Todo" ) | 2283 | if ( mMoveIncidence->type() == "Todo" ) |
2284 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2284 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2285 | else | 2285 | else |
2286 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2286 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2287 | mMoveIncidence = newInc; | 2287 | mMoveIncidence = newInc; |
2288 | 2288 | ||
2289 | #endif | 2289 | #endif |
2290 | } | 2290 | } |
2291 | QTime tim = mMoveIncidence->dtStart().time(); | 2291 | QTime tim = mMoveIncidence->dtStart().time(); |
2292 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2292 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2293 | QDateTime dt ( d,tim ); | 2293 | QDateTime dt ( d,tim ); |
2294 | mMoveIncidence->setDtStart( dt ); | 2294 | mMoveIncidence->setDtStart( dt ); |
2295 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2295 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2296 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2296 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2297 | } | 2297 | } |
2298 | 2298 | ||
2299 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2299 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2300 | } | 2300 | } |
2301 | } | 2301 | } |
2302 | 2302 | ||
2303 | void CalendarView::removeCategories() | 2303 | void CalendarView::removeCategories() |
2304 | { | 2304 | { |
2305 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2305 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2306 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2306 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2307 | QStringList catIncList; | 2307 | QStringList catIncList; |
2308 | QStringList newCatList; | 2308 | QStringList newCatList; |
2309 | Incidence* inc = incList.first(); | 2309 | Incidence* inc = incList.first(); |
2310 | int i; | 2310 | int i; |
2311 | int count = 0; | 2311 | int count = 0; |
2312 | while ( inc ) { | 2312 | while ( inc ) { |
2313 | newCatList.clear(); | 2313 | newCatList.clear(); |
2314 | catIncList = inc->categories() ; | 2314 | catIncList = inc->categories() ; |
2315 | for( i = 0; i< catIncList.count(); ++i ) { | 2315 | for( i = 0; i< catIncList.count(); ++i ) { |
2316 | if ( catList.contains (catIncList[i])) | 2316 | if ( catList.contains (catIncList[i])) |
2317 | newCatList.append( catIncList[i] ); | 2317 | newCatList.append( catIncList[i] ); |
2318 | } | 2318 | } |
2319 | newCatList.sort(); | 2319 | newCatList.sort(); |
2320 | inc->setCategories( newCatList.join(",") ); | 2320 | inc->setCategories( newCatList.join(",") ); |
2321 | inc = incList.next(); | 2321 | inc = incList.next(); |
2322 | } | 2322 | } |
2323 | } | 2323 | } |
2324 | 2324 | ||
2325 | int CalendarView::addCategories() | 2325 | int CalendarView::addCategories() |
2326 | { | 2326 | { |
2327 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2327 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2328 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2328 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2329 | QStringList catIncList; | 2329 | QStringList catIncList; |
2330 | Incidence* inc = incList.first(); | 2330 | Incidence* inc = incList.first(); |
2331 | int i; | 2331 | int i; |
2332 | int count = 0; | 2332 | int count = 0; |
2333 | while ( inc ) { | 2333 | while ( inc ) { |
2334 | catIncList = inc->categories() ; | 2334 | catIncList = inc->categories() ; |
2335 | for( i = 0; i< catIncList.count(); ++i ) { | 2335 | for( i = 0; i< catIncList.count(); ++i ) { |
2336 | if ( !catList.contains (catIncList[i])) { | 2336 | if ( !catList.contains (catIncList[i])) { |
2337 | catList.append( catIncList[i] ); | 2337 | catList.append( catIncList[i] ); |
2338 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2338 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2339 | ++count; | 2339 | ++count; |
2340 | } | 2340 | } |
2341 | } | 2341 | } |
2342 | inc = incList.next(); | 2342 | inc = incList.next(); |
2343 | } | 2343 | } |
2344 | catList.sort(); | 2344 | catList.sort(); |
2345 | KOPrefs::instance()->mCustomCategories = catList; | 2345 | KOPrefs::instance()->mCustomCategories = catList; |
2346 | return count; | 2346 | return count; |
2347 | } | 2347 | } |
2348 | 2348 | ||
2349 | void CalendarView::manageCategories() | 2349 | void CalendarView::manageCategories() |
2350 | { | 2350 | { |
2351 | KOCatPrefs* cp = new KOCatPrefs(); | 2351 | KOCatPrefs* cp = new KOCatPrefs(); |
2352 | cp->show(); | 2352 | cp->show(); |
2353 | int w =cp->sizeHint().width() ; | 2353 | int w =cp->sizeHint().width() ; |
2354 | int h = cp->sizeHint().height() ; | 2354 | int h = cp->sizeHint().height() ; |
2355 | int dw = QApplication::desktop()->width(); | 2355 | int dw = QApplication::desktop()->width(); |
2356 | int dh = QApplication::desktop()->height(); | 2356 | int dh = QApplication::desktop()->height(); |
2357 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2357 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2358 | if ( !cp->exec() ) { | 2358 | if ( !cp->exec() ) { |
2359 | delete cp; | 2359 | delete cp; |
2360 | return; | 2360 | return; |
2361 | } | 2361 | } |
2362 | int count = 0; | 2362 | int count = 0; |
2363 | if ( cp->addCat() ) { | 2363 | if ( cp->addCat() ) { |
2364 | count = addCategories(); | 2364 | count = addCategories(); |
2365 | if ( count ) { | 2365 | if ( count ) { |
2366 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2366 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2367 | writeSettings(); | 2367 | writeSettings(); |
2368 | } else | 2368 | } else |
2369 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2369 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2370 | } else { | 2370 | } else { |
2371 | removeCategories(); | 2371 | removeCategories(); |
2372 | updateView(); | 2372 | updateView(); |
2373 | } | 2373 | } |
2374 | delete cp; | 2374 | delete cp; |
2375 | } | 2375 | } |
2376 | 2376 | ||
2377 | void CalendarView::beamIncidence(Incidence * Inc) | 2377 | void CalendarView::beamIncidence(Incidence * Inc) |
2378 | { | 2378 | { |
2379 | QPtrList<Incidence> delSel ; | 2379 | QPtrList<Incidence> delSel ; |
2380 | delSel.append(Inc); | 2380 | delSel.append(Inc); |
2381 | beamIncidenceList( delSel ); | 2381 | beamIncidenceList( delSel ); |
2382 | } | 2382 | } |
2383 | void CalendarView::beamCalendar() | 2383 | void CalendarView::beamCalendar() |
2384 | { | 2384 | { |
2385 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2385 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2386 | //qDebug("beamCalendar() "); | 2386 | //qDebug("beamCalendar() "); |
2387 | beamIncidenceList( delSel ); | 2387 | beamIncidenceList( delSel ); |
2388 | } | 2388 | } |
2389 | void CalendarView::beamFilteredCalendar() | 2389 | void CalendarView::beamFilteredCalendar() |
2390 | { | 2390 | { |
2391 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2391 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2392 | //qDebug("beamFilteredCalendar() "); | 2392 | //qDebug("beamFilteredCalendar() "); |
2393 | beamIncidenceList( delSel ); | 2393 | beamIncidenceList( delSel ); |
2394 | } | 2394 | } |
2395 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2395 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2396 | { | 2396 | { |
2397 | if ( beamDialog->exec () == QDialog::Rejected ) | 2397 | if ( beamDialog->exec () == QDialog::Rejected ) |
2398 | return; | 2398 | return; |
2399 | #ifdef DESKTOP_VERSION | 2399 | #ifdef DESKTOP_VERSION |
2400 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2400 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2401 | #else | 2401 | #else |
2402 | QString fn = "/tmp/kopibeamfile"; | 2402 | QString fn = "/tmp/kopibeamfile"; |
2403 | #endif | 2403 | #endif |
2404 | QString mes; | 2404 | QString mes; |
2405 | bool createbup = true; | 2405 | bool createbup = true; |
2406 | if ( createbup ) { | 2406 | if ( createbup ) { |
2407 | QString description = "\n"; | 2407 | QString description = "\n"; |
2408 | CalendarLocal* cal = new CalendarLocal(); | 2408 | CalendarLocal* cal = new CalendarLocal(); |
2409 | if ( beamDialog->beamLocal() ) | 2409 | if ( beamDialog->beamLocal() ) |
2410 | cal->setLocalTime(); | 2410 | cal->setLocalTime(); |
2411 | else | 2411 | else |
2412 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2412 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2413 | Incidence *incidence = delSel.first(); | 2413 | Incidence *incidence = delSel.first(); |
2414 | bool addText = false; | 2414 | bool addText = false; |
2415 | if ( delSel.count() < 10 ) | 2415 | if ( delSel.count() < 10 ) |
2416 | addText = true; | 2416 | addText = true; |
2417 | else { | 2417 | else { |
2418 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2418 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2419 | } | 2419 | } |
2420 | while ( incidence ) { | 2420 | while ( incidence ) { |
2421 | Incidence *in = incidence->clone(); | 2421 | Incidence *in = incidence->clone(); |
2422 | if ( ! in->summary().isEmpty() ) { | 2422 | if ( ! in->summary().isEmpty() ) { |
2423 | in->setDescription(""); | 2423 | in->setDescription(""); |
2424 | } else { | 2424 | } else { |
2425 | in->setSummary( in->description().left(20)); | 2425 | in->setSummary( in->description().left(20)); |
2426 | in->setDescription(""); | 2426 | in->setDescription(""); |
2427 | } | 2427 | } |
2428 | if ( addText ) | 2428 | if ( addText ) |
2429 | description += in->summary() + "\n"; | 2429 | description += in->summary() + "\n"; |
2430 | cal->addIncidence( in ); | 2430 | cal->addIncidence( in ); |
2431 | incidence = delSel.next(); | 2431 | incidence = delSel.next(); |
2432 | } | 2432 | } |
2433 | if ( beamDialog->beamVcal() ) { | 2433 | if ( beamDialog->beamVcal() ) { |
2434 | fn += ".vcs"; | 2434 | fn += ".vcs"; |
2435 | FileStorage storage( cal, fn, new VCalFormat ); | 2435 | FileStorage storage( cal, fn, new VCalFormat ); |
2436 | storage.save(); | 2436 | storage.save(); |
2437 | } else { | 2437 | } else { |
2438 | fn += ".ics"; | 2438 | fn += ".ics"; |
2439 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2439 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2440 | storage.save(); | 2440 | storage.save(); |
2441 | } | 2441 | } |
2442 | delete cal; | 2442 | delete cal; |
2443 | mes = i18n("KO/Pi: Ready for beaming"); | 2443 | mes = i18n("KO/Pi: Ready for beaming"); |
2444 | topLevelWidget()->setCaption(mes); | 2444 | topLevelWidget()->setCaption(mes); |
2445 | KApplication::convert2latin1( fn ); | 2445 | KApplication::convert2latin1( fn ); |
2446 | #ifndef DESKTOP_VERSION | 2446 | #ifndef DESKTOP_VERSION |
2447 | Ir *ir = new Ir( this ); | 2447 | Ir *ir = new Ir( this ); |
2448 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2448 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2449 | ir->send( fn, description, "text/x-vCalendar" ); | 2449 | ir->send( fn, description, "text/x-vCalendar" ); |
2450 | #endif | 2450 | #endif |
2451 | } | 2451 | } |
2452 | } | 2452 | } |
2453 | void CalendarView::beamDone( Ir *ir ) | 2453 | void CalendarView::beamDone( Ir *ir ) |
2454 | { | 2454 | { |
2455 | #ifndef DESKTOP_VERSION | 2455 | #ifndef DESKTOP_VERSION |
2456 | delete ir; | 2456 | delete ir; |
2457 | #endif | 2457 | #endif |
2458 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2458 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2459 | topLevelWidget()->raise(); | 2459 | topLevelWidget()->raise(); |
2460 | } | 2460 | } |
2461 | 2461 | ||
2462 | void CalendarView::moveIncidence(Incidence * inc ) | 2462 | void CalendarView::moveIncidence(Incidence * inc ) |
2463 | { | 2463 | { |
2464 | if ( !inc ) return; | 2464 | if ( !inc ) return; |
2465 | // qDebug("showDatePickerForIncidence( ) "); | 2465 | // qDebug("showDatePickerForIncidence( ) "); |
2466 | if ( mDateFrame->isVisible() ) | 2466 | if ( mDateFrame->isVisible() ) |
2467 | mDateFrame->hide(); | 2467 | mDateFrame->hide(); |
2468 | else { | 2468 | else { |
2469 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2469 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2470 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2470 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2471 | int dw = QApplication::desktop()->width(); | 2471 | int dw = QApplication::desktop()->width(); |
2472 | int dh = QApplication::desktop()->height(); | 2472 | int dh = QApplication::desktop()->height(); |
2473 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2473 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2474 | mDateFrame->show(); | 2474 | mDateFrame->show(); |
2475 | } | 2475 | } |
2476 | mDatePickerMode = 2; | 2476 | mDatePickerMode = 2; |
2477 | mMoveIncidence = inc ; | 2477 | mMoveIncidence = inc ; |
2478 | QDate da; | 2478 | QDate da; |
2479 | if ( mMoveIncidence->type() == "Todo" ) { | 2479 | if ( mMoveIncidence->type() == "Todo" ) { |
2480 | Todo * to = (Todo *) mMoveIncidence; | 2480 | Todo * to = (Todo *) mMoveIncidence; |
2481 | if ( to->hasDueDate() ) | 2481 | if ( to->hasDueDate() ) |
2482 | da = to->dtDue().date(); | 2482 | da = to->dtDue().date(); |
2483 | else | 2483 | else |
2484 | da = QDate::currentDate(); | 2484 | da = QDate::currentDate(); |
2485 | } else { | 2485 | } else { |
2486 | da = mMoveIncidence->dtStart().date(); | 2486 | da = mMoveIncidence->dtStart().date(); |
2487 | } | 2487 | } |
2488 | //PENDING set date for recurring incidence to date of recurrence | 2488 | //PENDING set date for recurring incidence to date of recurrence |
2489 | //mMoveIncidenceOldDate; | 2489 | //mMoveIncidenceOldDate; |
2490 | mDatePicker->setDate( da ); | 2490 | mDatePicker->setDate( da ); |
2491 | } | 2491 | } |
2492 | void CalendarView::showDatePicker( ) | 2492 | void CalendarView::showDatePicker( ) |
2493 | { | 2493 | { |
2494 | //qDebug("CalendarView::showDatePicker( ) "); | 2494 | //qDebug("CalendarView::showDatePicker( ) "); |
2495 | if ( mDateFrame->isVisible() ) | 2495 | if ( mDateFrame->isVisible() ) |
2496 | mDateFrame->hide(); | 2496 | mDateFrame->hide(); |
2497 | else { | 2497 | else { |
2498 | int w =mDatePicker->sizeHint().width() ; | 2498 | int w =mDatePicker->sizeHint().width() ; |
2499 | int h = mDatePicker->sizeHint().height() ; | 2499 | int h = mDatePicker->sizeHint().height() ; |
2500 | int dw = QApplication::desktop()->width(); | 2500 | int dw = QApplication::desktop()->width(); |
2501 | int dh = QApplication::desktop()->height(); | 2501 | int dh = QApplication::desktop()->height(); |
2502 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2502 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2503 | mDateFrame->show(); | 2503 | mDateFrame->show(); |
2504 | } | 2504 | } |
2505 | mDatePickerMode = 1; | 2505 | mDatePickerMode = 1; |
2506 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2506 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2507 | } | 2507 | } |
2508 | 2508 | ||
2509 | void CalendarView::showEventEditor() | 2509 | void CalendarView::showEventEditor() |
2510 | { | 2510 | { |
2511 | #ifdef DESKTOP_VERSION | 2511 | #ifdef DESKTOP_VERSION |
2512 | mEventEditor->show(); | 2512 | mEventEditor->show(); |
2513 | #else | 2513 | #else |
2514 | 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() ) { |
2515 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2515 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2516 | 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(); | 2517 | qApp->processEvents(); |
2518 | delete mEventEditor; | 2518 | delete mEventEditor; |
2519 | mEventEditor = mDialogManager->getEventEditor(); | 2519 | mEventEditor = mDialogManager->getEventEditor(); |
2520 | topLevelWidget()->setCaption( i18n("") ); | 2520 | topLevelWidget()->setCaption( i18n("") ); |
2521 | } | 2521 | } |
2522 | mEventEditor->showMaximized(); | 2522 | mEventEditor->showMaximized(); |
2523 | #endif | 2523 | #endif |
2524 | } | 2524 | } |
2525 | void CalendarView::showTodoEditor() | 2525 | void CalendarView::showTodoEditor() |
2526 | { | 2526 | { |
2527 | #ifdef DESKTOP_VERSION | 2527 | #ifdef DESKTOP_VERSION |
2528 | mTodoEditor->show(); | 2528 | mTodoEditor->show(); |
2529 | #else | 2529 | #else |
2530 | 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() ) { |
2531 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2531 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2532 | 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(); | 2533 | qApp->processEvents(); |
2534 | delete mTodoEditor; | 2534 | delete mTodoEditor; |
2535 | mTodoEditor = mDialogManager->getTodoEditor(); | 2535 | mTodoEditor = mDialogManager->getTodoEditor(); |
2536 | topLevelWidget()->setCaption( i18n("") ); | 2536 | topLevelWidget()->setCaption( i18n("") ); |
2537 | } | 2537 | } |
2538 | mTodoEditor->showMaximized(); | 2538 | mTodoEditor->showMaximized(); |
2539 | #endif | 2539 | #endif |
2540 | } | 2540 | } |
2541 | 2541 | ||
2542 | void CalendarView::cloneIncidence() | 2542 | void CalendarView::cloneIncidence() |
2543 | { | 2543 | { |
2544 | Incidence *incidence = currentSelection(); | 2544 | Incidence *incidence = currentSelection(); |
2545 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2545 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2546 | if ( incidence ) { | 2546 | if ( incidence ) { |
2547 | cloneIncidence(incidence); | 2547 | cloneIncidence(incidence); |
2548 | } | 2548 | } |
2549 | } | 2549 | } |
2550 | void CalendarView::moveIncidence() | 2550 | void CalendarView::moveIncidence() |
2551 | { | 2551 | { |
2552 | Incidence *incidence = currentSelection(); | 2552 | Incidence *incidence = currentSelection(); |
2553 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2553 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2554 | if ( incidence ) { | 2554 | if ( incidence ) { |
2555 | moveIncidence(incidence); | 2555 | moveIncidence(incidence); |
2556 | } | 2556 | } |
2557 | } | 2557 | } |
2558 | void CalendarView::beamIncidence() | 2558 | void CalendarView::beamIncidence() |
2559 | { | 2559 | { |
2560 | Incidence *incidence = currentSelection(); | 2560 | Incidence *incidence = currentSelection(); |
2561 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2561 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2562 | if ( incidence ) { | 2562 | if ( incidence ) { |
2563 | beamIncidence(incidence); | 2563 | beamIncidence(incidence); |
2564 | } | 2564 | } |
2565 | } | 2565 | } |
2566 | void CalendarView::toggleCancelIncidence() | 2566 | void CalendarView::toggleCancelIncidence() |
2567 | { | 2567 | { |
2568 | Incidence *incidence = currentSelection(); | 2568 | Incidence *incidence = currentSelection(); |
2569 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2569 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2570 | if ( incidence ) { | 2570 | if ( incidence ) { |
2571 | cancelIncidence(incidence); | 2571 | cancelIncidence(incidence); |
2572 | } | 2572 | } |
2573 | } | 2573 | } |
2574 | 2574 | ||
2575 | 2575 | ||
2576 | void CalendarView::cancelIncidence(Incidence * inc ) | 2576 | void CalendarView::cancelIncidence(Incidence * inc ) |
2577 | { | 2577 | { |
2578 | inc->setCancelled( ! inc->cancelled() ); | 2578 | inc->setCancelled( ! inc->cancelled() ); |
2579 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2579 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2580 | updateView(); | 2580 | updateView(); |
2581 | } | 2581 | } |
2582 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2582 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2583 | { | 2583 | { |
2584 | Incidence * newInc = orgInc->clone(); | 2584 | Incidence * newInc = orgInc->clone(); |
2585 | newInc->recreate(); | 2585 | newInc->recreate(); |
2586 | 2586 | ||
2587 | if ( newInc->type() == "Todo" ) { | 2587 | if ( newInc->type() == "Todo" ) { |
2588 | Todo* t = (Todo*) newInc; | 2588 | Todo* t = (Todo*) newInc; |
2589 | showTodoEditor(); | 2589 | showTodoEditor(); |
2590 | mTodoEditor->editTodo( t ); | 2590 | mTodoEditor->editTodo( t ); |
2591 | if ( mTodoEditor->exec() ) { | 2591 | if ( mTodoEditor->exec() ) { |
2592 | mCalendar->addTodo( t ); | 2592 | mCalendar->addTodo( t ); |
2593 | updateView(); | 2593 | updateView(); |
2594 | } else { | 2594 | } else { |
2595 | delete t; | 2595 | delete t; |
2596 | } | 2596 | } |
2597 | } | 2597 | } |
2598 | else { | 2598 | else { |
2599 | Event* e = (Event*) newInc; | 2599 | Event* e = (Event*) newInc; |
2600 | showEventEditor(); | 2600 | showEventEditor(); |
2601 | mEventEditor->editEvent( e ); | 2601 | mEventEditor->editEvent( e ); |
2602 | if ( mEventEditor->exec() ) { | 2602 | if ( mEventEditor->exec() ) { |
2603 | mCalendar->addEvent( e ); | 2603 | mCalendar->addEvent( e ); |
2604 | updateView(); | 2604 | updateView(); |
2605 | } else { | 2605 | } else { |
2606 | delete e; | 2606 | delete e; |
2607 | } | 2607 | } |
2608 | } | 2608 | } |
2609 | } | 2609 | } |
2610 | 2610 | ||
2611 | void CalendarView::newEvent() | 2611 | void CalendarView::newEvent() |
2612 | { | 2612 | { |
2613 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2613 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2614 | KOAgendaView *aView = mViewManager->agendaView(); | 2614 | KOAgendaView *aView = mViewManager->agendaView(); |
2615 | if (aView) { | 2615 | if (aView) { |
2616 | if (aView->selectionStart().isValid()) { | 2616 | if (aView->selectionStart().isValid()) { |
2617 | if (aView->selectedIsAllDay()) { | 2617 | if (aView->selectedIsAllDay()) { |
2618 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2618 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2619 | } else { | 2619 | } else { |
2620 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2620 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2621 | } | 2621 | } |
2622 | return; | 2622 | return; |
2623 | } | 2623 | } |
2624 | } | 2624 | } |
2625 | 2625 | ||
2626 | QDate date = mNavigator->selectedDates().first(); | 2626 | QDate date = mNavigator->selectedDates().first(); |
2627 | QDateTime current = QDateTime::currentDateTime(); | 2627 | QDateTime current = QDateTime::currentDateTime(); |
2628 | if ( date <= current.date() ) { | 2628 | if ( date <= current.date() ) { |
2629 | int hour = current.time().hour() +1; | 2629 | int hour = current.time().hour() +1; |
2630 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2630 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2631 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2631 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2632 | } else | 2632 | } else |
2633 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2633 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2634 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2634 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2635 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2635 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2636 | } | 2636 | } |
2637 | 2637 | ||
2638 | void CalendarView::newEvent(QDateTime fh) | 2638 | void CalendarView::newEvent(QDateTime fh) |
2639 | { | 2639 | { |
2640 | newEvent(fh, | 2640 | newEvent(fh, |
2641 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2641 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2642 | } | 2642 | } |
2643 | 2643 | ||
2644 | void CalendarView::newEvent(QDate dt) | 2644 | void CalendarView::newEvent(QDate dt) |
2645 | { | 2645 | { |
2646 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2646 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2647 | QDateTime(dt, QTime(0,0,0)), true); | 2647 | QDateTime(dt, QTime(0,0,0)), true); |
2648 | } | 2648 | } |
2649 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2649 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2650 | { | 2650 | { |
2651 | newEvent(fromHint, toHint, false); | 2651 | newEvent(fromHint, toHint, false); |
2652 | } | 2652 | } |
2653 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2653 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2654 | { | 2654 | { |
2655 | 2655 | ||
2656 | showEventEditor(); | 2656 | showEventEditor(); |
2657 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2657 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2658 | if ( mFilterView->filtersEnabled() ) { | 2658 | if ( mFilterView->filtersEnabled() ) { |
2659 | CalFilter *filter = mFilterView->selectedFilter(); | 2659 | CalFilter *filter = mFilterView->selectedFilter(); |
2660 | if (filter && filter->showCategories()) { | 2660 | if (filter && filter->showCategories()) { |
2661 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2661 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2662 | } | 2662 | } |
2663 | if ( filter ) | 2663 | if ( filter ) |
2664 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2664 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2665 | } | 2665 | } |
2666 | } | 2666 | } |
2667 | void CalendarView::todoAdded(Todo * t) | 2667 | void CalendarView::todoAdded(Todo * t) |
2668 | { | 2668 | { |
2669 | 2669 | ||
2670 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2670 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2671 | updateTodoViews(); | 2671 | updateTodoViews(); |
2672 | } | 2672 | } |
2673 | void CalendarView::todoChanged(Todo * t) | 2673 | void CalendarView::todoChanged(Todo * t) |
2674 | { | 2674 | { |
2675 | emit todoModified( t, 4 ); | 2675 | emit todoModified( t, 4 ); |
2676 | // updateTodoViews(); | 2676 | // updateTodoViews(); |
2677 | } | 2677 | } |
2678 | void CalendarView::todoToBeDeleted(Todo *) | 2678 | void CalendarView::todoToBeDeleted(Todo *) |
2679 | { | 2679 | { |
2680 | //qDebug("todoToBeDeleted(Todo *) "); | 2680 | //qDebug("todoToBeDeleted(Todo *) "); |
2681 | updateTodoViews(); | 2681 | updateTodoViews(); |
2682 | } | 2682 | } |
2683 | void CalendarView::todoDeleted() | 2683 | void CalendarView::todoDeleted() |
2684 | { | 2684 | { |
2685 | //qDebug(" todoDeleted()"); | 2685 | //qDebug(" todoDeleted()"); |
2686 | updateTodoViews(); | 2686 | updateTodoViews(); |
2687 | } | 2687 | } |
2688 | 2688 | ||
2689 | 2689 | ||
2690 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2690 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2691 | { | 2691 | { |
2692 | showTodoEditor(); | 2692 | showTodoEditor(); |
2693 | mTodoEditor->newTodo(dt,0,allday); | 2693 | mTodoEditor->newTodo(dt,0,allday); |
2694 | if ( mFilterView->filtersEnabled() ) { | 2694 | if ( mFilterView->filtersEnabled() ) { |
2695 | CalFilter *filter = mFilterView->selectedFilter(); | 2695 | CalFilter *filter = mFilterView->selectedFilter(); |
2696 | if (filter && filter->showCategories()) { | 2696 | if (filter && filter->showCategories()) { |
2697 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2697 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2698 | } | 2698 | } |
2699 | if ( filter ) | 2699 | if ( filter ) |
2700 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2700 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2701 | } | 2701 | } |
2702 | } | 2702 | } |
2703 | 2703 | ||
2704 | void CalendarView::newTodo() | 2704 | void CalendarView::newTodo() |
2705 | { | 2705 | { |
2706 | newTodoDateTime( QDateTime(),true ); | 2706 | newTodoDateTime( QDateTime(),true ); |
2707 | } | 2707 | } |
2708 | 2708 | ||
2709 | void CalendarView::newSubTodo() | 2709 | void CalendarView::newSubTodo() |
2710 | { | 2710 | { |
2711 | Todo *todo = selectedTodo(); | 2711 | Todo *todo = selectedTodo(); |
2712 | if ( todo ) newSubTodo( todo ); | 2712 | if ( todo ) newSubTodo( todo ); |
2713 | } | 2713 | } |
2714 | 2714 | ||
2715 | void CalendarView::newSubTodo(Todo *parentEvent) | 2715 | void CalendarView::newSubTodo(Todo *parentEvent) |
2716 | { | 2716 | { |
2717 | 2717 | ||
2718 | showTodoEditor(); | 2718 | showTodoEditor(); |
2719 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2719 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2720 | } | 2720 | } |
2721 | 2721 | ||
2722 | void CalendarView::newFloatingEvent() | 2722 | void CalendarView::newFloatingEvent() |
2723 | { | 2723 | { |
2724 | DateList tmpList = mNavigator->selectedDates(); | 2724 | DateList tmpList = mNavigator->selectedDates(); |
2725 | QDate date = tmpList.first(); | 2725 | QDate date = tmpList.first(); |
2726 | 2726 | ||
2727 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2727 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2728 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2728 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2729 | } | 2729 | } |
2730 | 2730 | ||
2731 | 2731 | ||
2732 | void CalendarView::editEvent( Event *event ) | 2732 | void CalendarView::editEvent( Event *event ) |
2733 | { | 2733 | { |
2734 | 2734 | ||
2735 | if ( !event ) return; | 2735 | if ( !event ) return; |
2736 | if ( event->isReadOnly() ) { | 2736 | if ( event->isReadOnly() ) { |
2737 | showEvent( event ); | 2737 | showEvent( event ); |
2738 | return; | 2738 | return; |
2739 | } | 2739 | } |
2740 | showEventEditor(); | 2740 | showEventEditor(); |
2741 | mEventEditor->editEvent( event , mFlagEditDescription); | 2741 | mEventEditor->editEvent( event , mFlagEditDescription); |
2742 | } | 2742 | } |
2743 | void CalendarView::editJournal( Journal *jour ) | 2743 | void CalendarView::editJournal( Journal *jour ) |
2744 | { | 2744 | { |
2745 | if ( !jour ) return; | 2745 | if ( !jour ) return; |
2746 | mDialogManager->hideSearchDialog(); | 2746 | mDialogManager->hideSearchDialog(); |
2747 | mViewManager->showJournalView(); | 2747 | mViewManager->showJournalView(); |
2748 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2748 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2749 | } | 2749 | } |
2750 | void CalendarView::editTodo( Todo *todo ) | 2750 | void CalendarView::editTodo( Todo *todo ) |
2751 | { | 2751 | { |
2752 | if ( !todo ) return; | 2752 | if ( !todo ) return; |
2753 | 2753 | ||
2754 | if ( todo->isReadOnly() ) { | 2754 | if ( todo->isReadOnly() ) { |
2755 | showTodo( todo ); | 2755 | showTodo( todo ); |
2756 | return; | 2756 | return; |
2757 | } | 2757 | } |
2758 | showTodoEditor(); | 2758 | showTodoEditor(); |
2759 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2759 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2760 | 2760 | ||
2761 | } | 2761 | } |
2762 | 2762 | ||
2763 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2763 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2764 | { | 2764 | { |
2765 | if ( !mEventViewerDialog ) { | 2765 | if ( !mEventViewerDialog ) { |
2766 | mEventViewerDialog = new KOEventViewerDialog(this); | 2766 | mEventViewerDialog = new KOEventViewerDialog(this); |
2767 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2767 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2768 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2768 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2769 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2769 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2770 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2770 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2771 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2771 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2772 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2772 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2773 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2773 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2774 | this, SLOT( todoChanged(Todo *) ) ); | 2774 | this, SLOT( todoChanged(Todo *) ) ); |
2775 | mEventViewerDialog->resize( 640, 480 ); | 2775 | mEventViewerDialog->resize( 640, 480 ); |
2776 | 2776 | ||
2777 | } | 2777 | } |
2778 | return mEventViewerDialog; | 2778 | return mEventViewerDialog; |
2779 | } | 2779 | } |
2780 | void CalendarView::showEvent(Event *event) | 2780 | void CalendarView::showEvent(Event *event) |
2781 | { | 2781 | { |
2782 | getEventViewerDialog()->setEvent(event); | 2782 | getEventViewerDialog()->setEvent(event); |
2783 | getEventViewerDialog()->showMe(); | 2783 | getEventViewerDialog()->showMe(); |
2784 | } | 2784 | } |
2785 | 2785 | ||
2786 | void CalendarView::showTodo(Todo *event) | 2786 | void CalendarView::showTodo(Todo *event) |
2787 | { | 2787 | { |
2788 | getEventViewerDialog()->setTodo(event); | 2788 | getEventViewerDialog()->setTodo(event); |
2789 | getEventViewerDialog()->showMe(); | 2789 | getEventViewerDialog()->showMe(); |
2790 | } | 2790 | } |
2791 | void CalendarView::showJournal( Journal *jour ) | 2791 | void CalendarView::showJournal( Journal *jour ) |
2792 | { | 2792 | { |
2793 | getEventViewerDialog()->setJournal(jour); | 2793 | getEventViewerDialog()->setJournal(jour); |
2794 | getEventViewerDialog()->showMe(); | 2794 | getEventViewerDialog()->showMe(); |
2795 | 2795 | ||
2796 | } | 2796 | } |
2797 | // void CalendarView::todoModified (Todo *event, int changed) | 2797 | // void CalendarView::todoModified (Todo *event, int changed) |
2798 | // { | 2798 | // { |
2799 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2799 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2800 | // // kdDebug() << "Todo modified and open" << endl; | 2800 | // // kdDebug() << "Todo modified and open" << endl; |
2801 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2801 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2802 | // // temp->modified (changed); | 2802 | // // temp->modified (changed); |
2803 | 2803 | ||
2804 | // // } | 2804 | // // } |
2805 | 2805 | ||
2806 | // mViewManager->updateView(); | 2806 | // mViewManager->updateView(); |
2807 | // } | 2807 | // } |
2808 | 2808 | ||
2809 | void CalendarView::appointment_show() | 2809 | void CalendarView::appointment_show() |
2810 | { | 2810 | { |
2811 | Event *anEvent = 0; | 2811 | Event *anEvent = 0; |
2812 | 2812 | ||
2813 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2813 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2814 | 2814 | ||
2815 | if (mViewManager->currentView()->isEventView()) { | 2815 | if (mViewManager->currentView()->isEventView()) { |
2816 | if ( incidence && incidence->type() == "Event" ) { | 2816 | if ( incidence && incidence->type() == "Event" ) { |
2817 | anEvent = static_cast<Event *>(incidence); | 2817 | anEvent = static_cast<Event *>(incidence); |
2818 | } | 2818 | } |
2819 | } | 2819 | } |
2820 | 2820 | ||
2821 | if (!anEvent) { | 2821 | if (!anEvent) { |
2822 | KNotifyClient::beep(); | 2822 | KNotifyClient::beep(); |
2823 | return; | 2823 | return; |
2824 | } | 2824 | } |
2825 | 2825 | ||
2826 | showEvent(anEvent); | 2826 | showEvent(anEvent); |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | void CalendarView::appointment_edit() | 2829 | void CalendarView::appointment_edit() |
2830 | { | 2830 | { |
2831 | Event *anEvent = 0; | 2831 | Event *anEvent = 0; |
2832 | 2832 | ||
2833 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2833 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2834 | 2834 | ||
2835 | if (mViewManager->currentView()->isEventView()) { | 2835 | if (mViewManager->currentView()->isEventView()) { |
2836 | if ( incidence && incidence->type() == "Event" ) { | 2836 | if ( incidence && incidence->type() == "Event" ) { |
2837 | anEvent = static_cast<Event *>(incidence); | 2837 | anEvent = static_cast<Event *>(incidence); |
2838 | } | 2838 | } |
2839 | } | 2839 | } |
2840 | 2840 | ||
2841 | if (!anEvent) { | 2841 | if (!anEvent) { |
2842 | KNotifyClient::beep(); | 2842 | KNotifyClient::beep(); |
2843 | return; | 2843 | return; |
2844 | } | 2844 | } |
2845 | 2845 | ||
2846 | editEvent(anEvent); | 2846 | editEvent(anEvent); |
2847 | } | 2847 | } |
2848 | 2848 | ||
2849 | void CalendarView::appointment_delete() | 2849 | void CalendarView::appointment_delete() |
2850 | { | 2850 | { |
2851 | Event *anEvent = 0; | 2851 | Event *anEvent = 0; |
2852 | 2852 | ||
2853 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2853 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2854 | 2854 | ||
2855 | if (mViewManager->currentView()->isEventView()) { | 2855 | if (mViewManager->currentView()->isEventView()) { |
2856 | if ( incidence && incidence->type() == "Event" ) { | 2856 | if ( incidence && incidence->type() == "Event" ) { |
2857 | anEvent = static_cast<Event *>(incidence); | 2857 | anEvent = static_cast<Event *>(incidence); |
2858 | } | 2858 | } |
2859 | } | 2859 | } |
2860 | 2860 | ||
2861 | if (!anEvent) { | 2861 | if (!anEvent) { |
2862 | KNotifyClient::beep(); | 2862 | KNotifyClient::beep(); |
2863 | return; | 2863 | return; |
2864 | } | 2864 | } |
2865 | 2865 | ||
2866 | deleteEvent(anEvent); | 2866 | deleteEvent(anEvent); |
2867 | } | 2867 | } |
2868 | 2868 | ||
2869 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2869 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2870 | { | 2870 | { |
2871 | if (!sub) return; | 2871 | if (!sub) return; |
2872 | if (!parent) return; | 2872 | if (!parent) return; |
2873 | if ( sub->relatedTo() ) | 2873 | if ( sub->relatedTo() ) |
2874 | sub->relatedTo()->removeRelation(sub); | 2874 | sub->relatedTo()->removeRelation(sub); |
2875 | sub->setRelatedTo(parent); | 2875 | sub->setRelatedTo(parent); |
2876 | sub->setRelatedToUid(parent->uid()); | 2876 | sub->setRelatedToUid(parent->uid()); |
2877 | parent->addRelation(sub); | 2877 | parent->addRelation(sub); |
2878 | sub->updated(); | 2878 | sub->updated(); |
2879 | parent->updated(); | 2879 | parent->updated(); |
2880 | setModified(true); | 2880 | setModified(true); |
2881 | updateView(); | 2881 | updateView(); |
2882 | } | 2882 | } |
2883 | void CalendarView::todo_unsub(Todo *anTodo ) | 2883 | void CalendarView::todo_unsub(Todo *anTodo ) |
2884 | { | 2884 | { |
2885 | // Todo *anTodo = selectedTodo(); | 2885 | // Todo *anTodo = selectedTodo(); |
2886 | if (!anTodo) return; | 2886 | if (!anTodo) return; |
2887 | if (!anTodo->relatedTo()) return; | 2887 | if (!anTodo->relatedTo()) return; |
2888 | anTodo->relatedTo()->removeRelation(anTodo); | 2888 | anTodo->relatedTo()->removeRelation(anTodo); |
2889 | anTodo->setRelatedTo(0); | 2889 | anTodo->setRelatedTo(0); |
2890 | anTodo->updated(); | 2890 | anTodo->updated(); |
2891 | anTodo->setRelatedToUid(""); | 2891 | anTodo->setRelatedToUid(""); |
2892 | setModified(true); | 2892 | setModified(true); |
2893 | updateView(); | 2893 | updateView(); |
2894 | } | 2894 | } |
2895 | 2895 | ||
2896 | void CalendarView::deleteTodo(Todo *todo) | 2896 | void CalendarView::deleteTodo(Todo *todo) |
2897 | { | 2897 | { |
2898 | if (!todo) { | 2898 | if (!todo) { |
2899 | KNotifyClient::beep(); | 2899 | KNotifyClient::beep(); |
2900 | return; | 2900 | return; |
2901 | } | 2901 | } |
2902 | if (KOPrefs::instance()->mConfirm) { | 2902 | if (KOPrefs::instance()->mConfirm) { |
2903 | QString text = todo->summary().left(20); | 2903 | QString text = todo->summary().left(20); |
2904 | if (!todo->relations().isEmpty()) { | 2904 | if (!todo->relations().isEmpty()) { |
2905 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2905 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2906 | 2906 | ||
2907 | } | 2907 | } |
2908 | switch (msgItemDelete(text)) { | 2908 | switch (msgItemDelete(text)) { |
2909 | case KMessageBox::Continue: // OK | 2909 | case KMessageBox::Continue: // OK |
2910 | bool deleteT = false; | 2910 | bool deleteT = false; |
2911 | if (!todo->relations().isEmpty()) { | 2911 | if (!todo->relations().isEmpty()) { |
2912 | deleteT = removeCompletedSubTodos( todo ); | 2912 | deleteT = removeCompletedSubTodos( todo ); |
2913 | } | 2913 | } |
2914 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2914 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2915 | if ( !deleteT ) { | 2915 | if ( !deleteT ) { |
2916 | checkExternalId( todo ); | 2916 | checkExternalId( todo ); |
2917 | calendar()->deleteTodo(todo); | 2917 | calendar()->deleteTodo(todo); |
2918 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2918 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2919 | updateView(); | 2919 | updateView(); |
2920 | } | 2920 | } |
2921 | break; | 2921 | break; |
2922 | } // switch | 2922 | } // switch |
2923 | } else { | 2923 | } else { |
2924 | checkExternalId( todo ); | 2924 | checkExternalId( todo ); |
2925 | mCalendar->deleteTodo(todo); | 2925 | mCalendar->deleteTodo(todo); |
2926 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2926 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2927 | updateView(); | 2927 | updateView(); |
2928 | } | 2928 | } |
2929 | 2929 | ||
2930 | emit updateSearchDialog(); | 2930 | emit updateSearchDialog(); |
2931 | } | 2931 | } |
2932 | void CalendarView::deleteJournal(Journal *jour) | 2932 | void CalendarView::deleteJournal(Journal *jour) |
2933 | { | 2933 | { |
2934 | if (!jour) { | 2934 | if (!jour) { |
2935 | KNotifyClient::beep(); | 2935 | KNotifyClient::beep(); |
2936 | return; | 2936 | return; |
2937 | } | 2937 | } |
2938 | if (KOPrefs::instance()->mConfirm) { | 2938 | if (KOPrefs::instance()->mConfirm) { |
2939 | switch (msgItemDelete( jour->description().left(20))) { | 2939 | switch (msgItemDelete( jour->description().left(20))) { |
2940 | case KMessageBox::Continue: // OK | 2940 | case KMessageBox::Continue: // OK |
2941 | calendar()->deleteJournal(jour); | 2941 | calendar()->deleteJournal(jour); |
2942 | updateView(); | 2942 | updateView(); |
2943 | break; | 2943 | break; |
2944 | } // switch | 2944 | } // switch |
2945 | } else { | 2945 | } else { |
2946 | calendar()->deleteJournal(jour);; | 2946 | calendar()->deleteJournal(jour);; |
2947 | updateView(); | 2947 | updateView(); |
2948 | } | 2948 | } |
2949 | emit updateSearchDialog(); | 2949 | emit updateSearchDialog(); |
2950 | } | 2950 | } |
2951 | 2951 | ||
2952 | void CalendarView::deleteEvent(Event *anEvent) | 2952 | void CalendarView::deleteEvent(Event *anEvent) |
2953 | { | 2953 | { |
2954 | if (!anEvent) { | 2954 | if (!anEvent) { |
2955 | KNotifyClient::beep(); | 2955 | KNotifyClient::beep(); |
2956 | return; | 2956 | return; |
2957 | } | 2957 | } |
2958 | 2958 | ||
2959 | if (anEvent->recurrence()->doesRecur()) { | 2959 | if (anEvent->recurrence()->doesRecur()) { |
2960 | QDate itemDate = mViewManager->currentSelectionDate(); | 2960 | QDate itemDate = mViewManager->currentSelectionDate(); |
2961 | int km; | 2961 | int km; |
2962 | if (!itemDate.isValid()) { | 2962 | if (!itemDate.isValid()) { |
2963 | //kdDebug() << "Date Not Valid" << endl; | 2963 | //kdDebug() << "Date Not Valid" << endl; |
2964 | if (KOPrefs::instance()->mConfirm) { | 2964 | if (KOPrefs::instance()->mConfirm) { |
2965 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2965 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2966 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2966 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2967 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2967 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2968 | if ( km == KMessageBox::Continue ) | 2968 | if ( km == KMessageBox::Continue ) |
2969 | km = KMessageBox::No; // No = all below | 2969 | km = KMessageBox::No; // No = all below |
2970 | } else | 2970 | } else |
2971 | km = KMessageBox::No; | 2971 | km = KMessageBox::No; |
2972 | } else { | 2972 | } else { |
2973 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2973 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2974 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2974 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2975 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2975 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2976 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2976 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2977 | i18n("All")); | 2977 | i18n("All")); |
2978 | } | 2978 | } |
2979 | switch(km) { | 2979 | switch(km) { |
2980 | 2980 | ||
2981 | case KMessageBox::No: // Continue // all | 2981 | case KMessageBox::No: // Continue // all |
2982 | //qDebug("KMessageBox::No "); | 2982 | //qDebug("KMessageBox::No "); |
2983 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2983 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2984 | schedule(Scheduler::Cancel,anEvent); | 2984 | schedule(Scheduler::Cancel,anEvent); |
2985 | 2985 | ||
2986 | checkExternalId( anEvent); | 2986 | checkExternalId( anEvent); |
2987 | mCalendar->deleteEvent(anEvent); | 2987 | mCalendar->deleteEvent(anEvent); |
2988 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2988 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2989 | break; | 2989 | break; |
2990 | 2990 | ||
2991 | // Disabled because it does not work | 2991 | // Disabled because it does not work |
2992 | //#if 0 | 2992 | //#if 0 |
2993 | case KMessageBox::Yes: // just this one | 2993 | case KMessageBox::Yes: // just this one |
2994 | //QDate qd = mNavigator->selectedDates().first(); | 2994 | //QDate qd = mNavigator->selectedDates().first(); |
2995 | //if (!qd.isValid()) { | 2995 | //if (!qd.isValid()) { |
2996 | // kdDebug() << "no date selected, or invalid date" << endl; | 2996 | // kdDebug() << "no date selected, or invalid date" << endl; |
2997 | // KNotifyClient::beep(); | 2997 | // KNotifyClient::beep(); |
2998 | // return; | 2998 | // return; |
2999 | //} | 2999 | //} |
3000 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3000 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3001 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3001 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3002 | anEvent->addExDate(itemDate); | 3002 | anEvent->addExDate(itemDate); |
3003 | int duration = anEvent->recurrence()->duration(); | 3003 | int duration = anEvent->recurrence()->duration(); |
3004 | if ( duration > 0 ) { | 3004 | if ( duration > 0 ) { |
3005 | anEvent->recurrence()->setDuration( duration - 1 ); | 3005 | anEvent->recurrence()->setDuration( duration - 1 ); |
3006 | } | 3006 | } |
3007 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3007 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3008 | } | 3008 | } |
3009 | break; | 3009 | break; |
3010 | //#endif | 3010 | //#endif |
3011 | } // switch | 3011 | } // switch |
3012 | } else { | 3012 | } else { |
3013 | if (KOPrefs::instance()->mConfirm) { | 3013 | if (KOPrefs::instance()->mConfirm) { |
3014 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3014 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3015 | i18n("\nAre you sure you want\nto delete this event?"), | 3015 | i18n("\nAre you sure you want\nto delete this event?"), |
3016 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3016 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3017 | case KMessageBox::Continue: // OK | 3017 | case KMessageBox::Continue: // OK |
3018 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3018 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3019 | schedule(Scheduler::Cancel,anEvent); | 3019 | schedule(Scheduler::Cancel,anEvent); |
3020 | checkExternalId( anEvent); | 3020 | checkExternalId( anEvent); |
3021 | mCalendar->deleteEvent(anEvent); | 3021 | mCalendar->deleteEvent(anEvent); |
3022 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3022 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3023 | break; | 3023 | break; |
3024 | } // switch | 3024 | } // switch |
3025 | } else { | 3025 | } else { |
3026 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3026 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3027 | schedule(Scheduler::Cancel,anEvent); | 3027 | schedule(Scheduler::Cancel,anEvent); |
3028 | checkExternalId( anEvent); | 3028 | checkExternalId( anEvent); |
3029 | mCalendar->deleteEvent(anEvent); | 3029 | mCalendar->deleteEvent(anEvent); |
3030 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3030 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3031 | } | 3031 | } |
3032 | } // if-else | 3032 | } // if-else |
3033 | emit updateSearchDialog(); | 3033 | emit updateSearchDialog(); |
3034 | } | 3034 | } |
3035 | 3035 | ||
3036 | bool CalendarView::deleteEvent(const QString &uid) | 3036 | bool CalendarView::deleteEvent(const QString &uid) |
3037 | { | 3037 | { |
3038 | Event *ev = mCalendar->event(uid); | 3038 | Event *ev = mCalendar->event(uid); |
3039 | if (ev) { | 3039 | if (ev) { |
3040 | deleteEvent(ev); | 3040 | deleteEvent(ev); |
3041 | return true; | 3041 | return true; |
3042 | } else { | 3042 | } else { |
3043 | return false; | 3043 | return false; |
3044 | } | 3044 | } |
3045 | } | 3045 | } |
3046 | 3046 | ||
3047 | /*****************************************************************************/ | 3047 | /*****************************************************************************/ |
3048 | 3048 | ||
3049 | void CalendarView::action_mail() | 3049 | void CalendarView::action_mail() |
3050 | { | 3050 | { |
3051 | #ifndef KORG_NOMAIL | 3051 | #ifndef KORG_NOMAIL |
3052 | KOMailClient mailClient; | 3052 | KOMailClient mailClient; |
3053 | 3053 | ||
3054 | Incidence *incidence = currentSelection(); | 3054 | Incidence *incidence = currentSelection(); |
3055 | 3055 | ||
3056 | if (!incidence) { | 3056 | if (!incidence) { |
3057 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3057 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3058 | return; | 3058 | return; |
3059 | } | 3059 | } |
3060 | if(incidence->attendeeCount() == 0 ) { | 3060 | if(incidence->attendeeCount() == 0 ) { |
3061 | KMessageBox::sorry(this, | 3061 | KMessageBox::sorry(this, |
3062 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3062 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3063 | return; | 3063 | return; |
3064 | } | 3064 | } |
3065 | 3065 | ||
3066 | CalendarLocal cal_tmp; | 3066 | CalendarLocal cal_tmp; |
3067 | Event *event = 0; | 3067 | Event *event = 0; |
3068 | Event *ev = 0; | 3068 | Event *ev = 0; |
3069 | if ( incidence && incidence->type() == "Event" ) { | 3069 | if ( incidence && incidence->type() == "Event" ) { |
3070 | event = static_cast<Event *>(incidence); | 3070 | event = static_cast<Event *>(incidence); |
3071 | ev = new Event(*event); | 3071 | ev = new Event(*event); |
3072 | cal_tmp.addEvent(ev); | 3072 | cal_tmp.addEvent(ev); |
3073 | } | 3073 | } |
3074 | ICalFormat mForm(); | 3074 | ICalFormat mForm(); |
3075 | QString attachment = mForm.toString( &cal_tmp ); | 3075 | QString attachment = mForm.toString( &cal_tmp ); |
3076 | if (ev) delete(ev); | 3076 | if (ev) delete(ev); |
3077 | 3077 | ||
3078 | mailClient.mailAttendees(currentSelection(), attachment); | 3078 | mailClient.mailAttendees(currentSelection(), attachment); |
3079 | 3079 | ||
3080 | #endif | 3080 | #endif |
3081 | 3081 | ||
3082 | #if 0 | 3082 | #if 0 |
3083 | Event *anEvent = 0; | 3083 | Event *anEvent = 0; |
3084 | if (mViewManager->currentView()->isEventView()) { | 3084 | if (mViewManager->currentView()->isEventView()) { |
3085 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3085 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3086 | } | 3086 | } |
3087 | 3087 | ||
3088 | if (!anEvent) { | 3088 | if (!anEvent) { |
3089 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3089 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3090 | return; | 3090 | return; |
3091 | } | 3091 | } |
3092 | if(anEvent->attendeeCount() == 0 ) { | 3092 | if(anEvent->attendeeCount() == 0 ) { |
3093 | KMessageBox::sorry(this, | 3093 | KMessageBox::sorry(this, |
3094 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3094 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3095 | return; | 3095 | return; |
3096 | } | 3096 | } |
3097 | 3097 | ||
3098 | mailobject.emailEvent(anEvent); | 3098 | mailobject.emailEvent(anEvent); |
3099 | #endif | 3099 | #endif |
3100 | } | 3100 | } |
3101 | 3101 | ||
3102 | 3102 | ||
3103 | void CalendarView::schedule_publish(Incidence *incidence) | 3103 | void CalendarView::schedule_publish(Incidence *incidence) |
3104 | { | 3104 | { |
3105 | Event *event = 0; | 3105 | Event *event = 0; |
3106 | Todo *todo = 0; | 3106 | Todo *todo = 0; |
3107 | 3107 | ||
3108 | if (incidence == 0) { | 3108 | if (incidence == 0) { |
3109 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3109 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3110 | if (incidence == 0) { | 3110 | if (incidence == 0) { |
3111 | incidence = mTodoList->selectedIncidences().first(); | 3111 | incidence = mTodoList->selectedIncidences().first(); |
3112 | } | 3112 | } |
3113 | } | 3113 | } |
3114 | if ( incidence && incidence->type() == "Event" ) { | 3114 | if ( incidence && incidence->type() == "Event" ) { |
3115 | event = static_cast<Event *>(incidence); | 3115 | event = static_cast<Event *>(incidence); |
3116 | } else { | 3116 | } else { |
3117 | if ( incidence && incidence->type() == "Todo" ) { | 3117 | if ( incidence && incidence->type() == "Todo" ) { |
3118 | todo = static_cast<Todo *>(incidence); | 3118 | todo = static_cast<Todo *>(incidence); |
3119 | } | 3119 | } |
3120 | } | 3120 | } |
3121 | 3121 | ||
3122 | if (!event && !todo) { | 3122 | if (!event && !todo) { |
3123 | KMessageBox::sorry(this,i18n("No event selected.")); | 3123 | KMessageBox::sorry(this,i18n("No event selected.")); |
3124 | return; | 3124 | return; |
3125 | } | 3125 | } |
3126 | 3126 | ||
3127 | PublishDialog *publishdlg = new PublishDialog(); | 3127 | PublishDialog *publishdlg = new PublishDialog(); |
3128 | if (incidence->attendeeCount()>0) { | 3128 | if (incidence->attendeeCount()>0) { |
3129 | QPtrList<Attendee> attendees = incidence->attendees(); | 3129 | QPtrList<Attendee> attendees = incidence->attendees(); |
3130 | attendees.first(); | 3130 | attendees.first(); |
3131 | while ( attendees.current()!=0 ) { | 3131 | while ( attendees.current()!=0 ) { |
3132 | publishdlg->addAttendee(attendees.current()); | 3132 | publishdlg->addAttendee(attendees.current()); |
3133 | attendees.next(); | 3133 | attendees.next(); |
3134 | } | 3134 | } |
3135 | } | 3135 | } |
3136 | bool send = true; | 3136 | bool send = true; |
3137 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3137 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3138 | if ( publishdlg->exec() != QDialog::Accepted ) | 3138 | if ( publishdlg->exec() != QDialog::Accepted ) |
3139 | send = false; | 3139 | send = false; |
3140 | } | 3140 | } |
3141 | if ( send ) { | 3141 | if ( send ) { |
3142 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3142 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3143 | if ( event ) { | 3143 | if ( event ) { |
3144 | Event *ev = new Event(*event); | 3144 | Event *ev = new Event(*event); |
3145 | ev->registerObserver(0); | 3145 | ev->registerObserver(0); |
3146 | ev->clearAttendees(); | 3146 | ev->clearAttendees(); |
3147 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3147 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3148 | delete(ev); | 3148 | delete(ev); |
3149 | } | 3149 | } |
3150 | } else { | 3150 | } else { |
3151 | if ( todo ) { | 3151 | if ( todo ) { |
3152 | Todo *ev = new Todo(*todo); | 3152 | Todo *ev = new Todo(*todo); |
3153 | ev->registerObserver(0); | 3153 | ev->registerObserver(0); |
3154 | ev->clearAttendees(); | 3154 | ev->clearAttendees(); |
3155 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3155 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3156 | delete(ev); | 3156 | delete(ev); |
3157 | } | 3157 | } |
3158 | } | 3158 | } |
3159 | } | 3159 | } |
3160 | } | 3160 | } |
3161 | delete publishdlg; | 3161 | delete publishdlg; |
3162 | } | 3162 | } |
3163 | 3163 | ||
3164 | void CalendarView::schedule_request(Incidence *incidence) | 3164 | void CalendarView::schedule_request(Incidence *incidence) |
3165 | { | 3165 | { |
3166 | schedule(Scheduler::Request,incidence); | 3166 | schedule(Scheduler::Request,incidence); |
3167 | } | 3167 | } |
3168 | 3168 | ||
3169 | void CalendarView::schedule_refresh(Incidence *incidence) | 3169 | void CalendarView::schedule_refresh(Incidence *incidence) |
3170 | { | 3170 | { |
3171 | schedule(Scheduler::Refresh,incidence); | 3171 | schedule(Scheduler::Refresh,incidence); |
3172 | } | 3172 | } |
3173 | 3173 | ||
3174 | void CalendarView::schedule_cancel(Incidence *incidence) | 3174 | void CalendarView::schedule_cancel(Incidence *incidence) |
3175 | { | 3175 | { |
3176 | schedule(Scheduler::Cancel,incidence); | 3176 | schedule(Scheduler::Cancel,incidence); |
3177 | } | 3177 | } |
3178 | 3178 | ||
3179 | void CalendarView::schedule_add(Incidence *incidence) | 3179 | void CalendarView::schedule_add(Incidence *incidence) |
3180 | { | 3180 | { |
3181 | schedule(Scheduler::Add,incidence); | 3181 | schedule(Scheduler::Add,incidence); |
3182 | } | 3182 | } |
3183 | 3183 | ||
3184 | void CalendarView::schedule_reply(Incidence *incidence) | 3184 | void CalendarView::schedule_reply(Incidence *incidence) |
3185 | { | 3185 | { |
3186 | schedule(Scheduler::Reply,incidence); | 3186 | schedule(Scheduler::Reply,incidence); |
3187 | } | 3187 | } |
3188 | 3188 | ||
3189 | void CalendarView::schedule_counter(Incidence *incidence) | 3189 | void CalendarView::schedule_counter(Incidence *incidence) |
3190 | { | 3190 | { |
3191 | schedule(Scheduler::Counter,incidence); | 3191 | schedule(Scheduler::Counter,incidence); |
3192 | } | 3192 | } |
3193 | 3193 | ||
3194 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3194 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3195 | { | 3195 | { |
3196 | schedule(Scheduler::Declinecounter,incidence); | 3196 | schedule(Scheduler::Declinecounter,incidence); |
3197 | } | 3197 | } |
3198 | 3198 | ||
3199 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3199 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3200 | { | 3200 | { |
3201 | QDateTime start = QDateTime::currentDateTime(); | 3201 | QDateTime start = QDateTime::currentDateTime(); |
3202 | QDateTime end = start.addDays(daysToPublish); | 3202 | QDateTime end = start.addDays(daysToPublish); |
3203 | 3203 | ||
3204 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3204 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3205 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3205 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3206 | 3206 | ||
3207 | 3207 | ||
3208 | PublishDialog *publishdlg = new PublishDialog(); | 3208 | PublishDialog *publishdlg = new PublishDialog(); |
3209 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3209 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3210 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3210 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3211 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3211 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3212 | delete(freebusy); | 3212 | delete(freebusy); |
3213 | } | 3213 | } |
3214 | } | 3214 | } |
3215 | delete publishdlg; | 3215 | delete publishdlg; |
3216 | } | 3216 | } |
3217 | 3217 | ||
3218 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3218 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3219 | { | 3219 | { |
3220 | Event *event = 0; | 3220 | Event *event = 0; |
3221 | Todo *todo = 0; | 3221 | Todo *todo = 0; |
3222 | 3222 | ||
3223 | if (incidence == 0) { | 3223 | if (incidence == 0) { |
3224 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3224 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3225 | if (incidence == 0) { | 3225 | if (incidence == 0) { |
3226 | incidence = mTodoList->selectedIncidences().first(); | 3226 | incidence = mTodoList->selectedIncidences().first(); |
3227 | } | 3227 | } |
3228 | } | 3228 | } |
3229 | if ( incidence && incidence->type() == "Event" ) { | 3229 | if ( incidence && incidence->type() == "Event" ) { |
3230 | event = static_cast<Event *>(incidence); | 3230 | event = static_cast<Event *>(incidence); |
3231 | } | 3231 | } |
3232 | if ( incidence && incidence->type() == "Todo" ) { | 3232 | if ( incidence && incidence->type() == "Todo" ) { |
3233 | todo = static_cast<Todo *>(incidence); | 3233 | todo = static_cast<Todo *>(incidence); |
3234 | } | 3234 | } |
3235 | 3235 | ||
3236 | if (!event && !todo) { | 3236 | if (!event && !todo) { |
3237 | KMessageBox::sorry(this,i18n("No event selected.")); | 3237 | KMessageBox::sorry(this,i18n("No event selected.")); |
3238 | return; | 3238 | return; |
3239 | } | 3239 | } |
3240 | 3240 | ||
3241 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3241 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3242 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3242 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3243 | return; | 3243 | return; |
3244 | } | 3244 | } |
3245 | 3245 | ||
3246 | Event *ev = 0; | 3246 | Event *ev = 0; |
3247 | if (event) ev = new Event(*event); | 3247 | if (event) ev = new Event(*event); |
3248 | Todo *to = 0; | 3248 | Todo *to = 0; |
3249 | if (todo) to = new Todo(*todo); | 3249 | if (todo) to = new Todo(*todo); |
3250 | 3250 | ||
3251 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3251 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3252 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3252 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3253 | if (!me) { | 3253 | if (!me) { |
3254 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3254 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3255 | return; | 3255 | return; |
3256 | } | 3256 | } |
3257 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3257 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3258 | StatusDialog *statdlg = new StatusDialog(this); | 3258 | StatusDialog *statdlg = new StatusDialog(this); |
3259 | if (!statdlg->exec()==QDialog::Accepted) return; | 3259 | if (!statdlg->exec()==QDialog::Accepted) return; |
3260 | me->setStatus( statdlg->status() ); | 3260 | me->setStatus( statdlg->status() ); |
3261 | delete(statdlg); | 3261 | delete(statdlg); |
3262 | } | 3262 | } |
3263 | Attendee *menew = new Attendee(*me); | 3263 | Attendee *menew = new Attendee(*me); |
3264 | if (ev) { | 3264 | if (ev) { |
3265 | ev->clearAttendees(); | 3265 | ev->clearAttendees(); |
3266 | ev->addAttendee(menew,false); | 3266 | ev->addAttendee(menew,false); |
3267 | } else { | 3267 | } else { |
3268 | if (to) { | 3268 | if (to) { |
3269 | todo->clearAttendees(); | 3269 | todo->clearAttendees(); |
3270 | todo->addAttendee(menew,false); | 3270 | todo->addAttendee(menew,false); |
3271 | } | 3271 | } |
3272 | } | 3272 | } |
3273 | } | 3273 | } |
3274 | 3274 | ||
3275 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3275 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3276 | if (ev) { | 3276 | if (ev) { |
3277 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3277 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3278 | } else { | 3278 | } else { |
3279 | if (to) { | 3279 | if (to) { |
3280 | if ( !dlg->addMessage(to,method) ) delete(to); | 3280 | if ( !dlg->addMessage(to,method) ) delete(to); |
3281 | } | 3281 | } |
3282 | } | 3282 | } |
3283 | } | 3283 | } |
3284 | 3284 | ||
3285 | void CalendarView::openAddressbook() | 3285 | void CalendarView::openAddressbook() |
3286 | { | 3286 | { |
3287 | KRun::runCommand("kaddressbook"); | 3287 | KRun::runCommand("kaddressbook"); |
3288 | } | 3288 | } |
3289 | 3289 | ||
3290 | void CalendarView::setModified(bool modified) | 3290 | void CalendarView::setModified(bool modified) |
3291 | { | 3291 | { |
3292 | if ( modified ) | 3292 | if ( modified ) |
3293 | emit signalmodified(); | 3293 | emit signalmodified(); |
3294 | if (mModified != modified) { | 3294 | if (mModified != modified) { |
3295 | mModified = modified; | 3295 | mModified = modified; |
3296 | emit modifiedChanged(mModified); | 3296 | emit modifiedChanged(mModified); |
3297 | } | 3297 | } |
3298 | } | 3298 | } |
3299 | 3299 | ||
3300 | bool CalendarView::isReadOnly() | 3300 | bool CalendarView::isReadOnly() |
3301 | { | 3301 | { |
3302 | return mReadOnly; | 3302 | return mReadOnly; |
3303 | } | 3303 | } |
3304 | 3304 | ||
3305 | void CalendarView::setReadOnly(bool readOnly) | 3305 | void CalendarView::setReadOnly(bool readOnly) |
3306 | { | 3306 | { |
3307 | if (mReadOnly != readOnly) { | 3307 | if (mReadOnly != readOnly) { |
3308 | mReadOnly = readOnly; | 3308 | mReadOnly = readOnly; |
3309 | emit readOnlyChanged(mReadOnly); | 3309 | emit readOnlyChanged(mReadOnly); |
3310 | } | 3310 | } |
3311 | } | 3311 | } |
3312 | 3312 | ||
3313 | bool CalendarView::isModified() | 3313 | bool CalendarView::isModified() |
3314 | { | 3314 | { |
3315 | return mModified; | 3315 | return mModified; |
3316 | } | 3316 | } |
3317 | 3317 | ||
3318 | void CalendarView::printSetup() | 3318 | void CalendarView::printSetup() |
3319 | { | 3319 | { |
3320 | #ifndef KORG_NOPRINTER | 3320 | #ifndef KORG_NOPRINTER |
3321 | createPrinter(); | 3321 | createPrinter(); |
3322 | 3322 | ||
3323 | mCalPrinter->setupPrinter(); | 3323 | mCalPrinter->setupPrinter(); |
3324 | #endif | 3324 | #endif |
3325 | } | 3325 | } |
3326 | 3326 | ||
3327 | void CalendarView::print() | 3327 | void CalendarView::print() |
3328 | { | 3328 | { |
3329 | #ifndef KORG_NOPRINTER | 3329 | #ifndef KORG_NOPRINTER |
3330 | createPrinter(); | 3330 | createPrinter(); |
3331 | 3331 | ||
3332 | DateList tmpDateList = mNavigator->selectedDates(); | 3332 | DateList tmpDateList = mNavigator->selectedDates(); |
3333 | mCalPrinter->print(CalPrinter::Month, | 3333 | mCalPrinter->print(CalPrinter::Month, |
3334 | tmpDateList.first(), tmpDateList.last()); | 3334 | tmpDateList.first(), tmpDateList.last()); |
3335 | #endif | 3335 | #endif |
3336 | } | 3336 | } |
3337 | 3337 | ||
3338 | void CalendarView::printPreview() | 3338 | void CalendarView::printPreview() |
3339 | { | 3339 | { |
3340 | #ifndef KORG_NOPRINTER | 3340 | #ifndef KORG_NOPRINTER |
3341 | kdDebug() << "CalendarView::printPreview()" << endl; | 3341 | kdDebug() << "CalendarView::printPreview()" << endl; |
3342 | 3342 | ||
3343 | createPrinter(); | 3343 | createPrinter(); |
3344 | 3344 | ||
3345 | DateList tmpDateList = mNavigator->selectedDates(); | 3345 | DateList tmpDateList = mNavigator->selectedDates(); |
3346 | 3346 | ||
3347 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3347 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3348 | tmpDateList.last()); | 3348 | tmpDateList.last()); |
3349 | #endif | 3349 | #endif |
3350 | } | 3350 | } |
3351 | 3351 | ||
3352 | void CalendarView::exportICalendar() | 3352 | void CalendarView::exportICalendar() |
3353 | { | 3353 | { |
3354 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3354 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3355 | 3355 | ||
3356 | // Force correct extension | 3356 | // Force correct extension |
3357 | if (filename.right(4) != ".ics") filename += ".ics"; | 3357 | if (filename.right(4) != ".ics") filename += ".ics"; |
3358 | 3358 | ||
3359 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3359 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3360 | storage.save(); | 3360 | storage.save(); |
3361 | } | 3361 | } |
3362 | 3362 | ||
3363 | bool CalendarView::exportVCalendar( QString filename ) | 3363 | bool CalendarView::exportVCalendar( QString filename ) |
3364 | { | 3364 | { |
3365 | if (mCalendar->journals().count() > 0) { | 3365 | if (mCalendar->journals().count() > 0) { |
3366 | int result = KMessageBox::warningContinueCancel(this, | 3366 | int result = KMessageBox::warningContinueCancel(this, |
3367 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3367 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3368 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3368 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3369 | true); | 3369 | true); |
3370 | if (result != KMessageBox::Continue) return false; | 3370 | if (result != KMessageBox::Continue) return false; |
3371 | } | 3371 | } |
3372 | 3372 | ||
3373 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3373 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3374 | 3374 | ||
3375 | // Force correct extension | 3375 | // Force correct extension |
3376 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3376 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3377 | 3377 | ||
3378 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3378 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3379 | return storage.save(); | 3379 | return storage.save(); |
3380 | 3380 | ||
3381 | } | 3381 | } |
3382 | 3382 | ||
3383 | void CalendarView::eventUpdated(Incidence *) | 3383 | void CalendarView::eventUpdated(Incidence *) |
3384 | { | 3384 | { |
3385 | setModified(); | 3385 | setModified(); |
3386 | // Don't call updateView here. The code, which has caused the update of the | 3386 | // Don't call updateView here. The code, which has caused the update of the |
3387 | // event is responsible for updating the view. | 3387 | // event is responsible for updating the view. |
3388 | // updateView(); | 3388 | // updateView(); |
3389 | } | 3389 | } |
3390 | 3390 | ||
3391 | void CalendarView::adaptNavigationUnits() | 3391 | void CalendarView::adaptNavigationUnits() |
3392 | { | 3392 | { |
3393 | if (mViewManager->currentView()->isEventView()) { | 3393 | if (mViewManager->currentView()->isEventView()) { |
3394 | int days = mViewManager->currentView()->currentDateCount(); | 3394 | int days = mViewManager->currentView()->currentDateCount(); |
3395 | if (days == 1) { | 3395 | if (days == 1) { |
3396 | emit changeNavStringPrev(i18n("&Previous Day")); | 3396 | emit changeNavStringPrev(i18n("&Previous Day")); |
3397 | emit changeNavStringNext(i18n("&Next Day")); | 3397 | emit changeNavStringNext(i18n("&Next Day")); |
3398 | } else { | 3398 | } else { |
3399 | emit changeNavStringPrev(i18n("&Previous Week")); | 3399 | emit changeNavStringPrev(i18n("&Previous Week")); |
3400 | emit changeNavStringNext(i18n("&Next Week")); | 3400 | emit changeNavStringNext(i18n("&Next Week")); |
3401 | } | 3401 | } |
3402 | } | 3402 | } |
3403 | } | 3403 | } |
3404 | 3404 | ||
3405 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3405 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3406 | { | 3406 | { |
3407 | if ( incidence ) mTodoList->clearSelection(); | 3407 | if ( incidence ) mTodoList->clearSelection(); |
3408 | processIncidenceSelection( incidence ); | 3408 | processIncidenceSelection( incidence ); |
3409 | } | 3409 | } |
3410 | 3410 | ||
3411 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3411 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3412 | { | 3412 | { |
3413 | if ( incidence && mViewManager->currentView() ) { | 3413 | if ( incidence && mViewManager->currentView() ) { |
3414 | mViewManager->currentView()->clearSelection(); | 3414 | mViewManager->currentView()->clearSelection(); |
3415 | } | 3415 | } |
3416 | processIncidenceSelection( incidence ); | 3416 | processIncidenceSelection( incidence ); |
3417 | } | 3417 | } |
3418 | 3418 | ||
3419 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3419 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3420 | { | 3420 | { |
3421 | if ( incidence == mSelectedIncidence ) return; | 3421 | if ( incidence == mSelectedIncidence ) return; |
3422 | 3422 | ||
3423 | mSelectedIncidence = incidence; | 3423 | mSelectedIncidence = incidence; |
3424 | 3424 | ||
3425 | emit incidenceSelected( mSelectedIncidence ); | 3425 | emit incidenceSelected( mSelectedIncidence ); |
3426 | 3426 | ||
3427 | if ( incidence && incidence->type() == "Event" ) { | 3427 | if ( incidence && incidence->type() == "Event" ) { |
3428 | Event *event = static_cast<Event *>( incidence ); | 3428 | Event *event = static_cast<Event *>( incidence ); |
3429 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3429 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3430 | emit organizerEventsSelected( true ); | 3430 | emit organizerEventsSelected( true ); |
3431 | } else { | 3431 | } else { |
3432 | emit organizerEventsSelected(false); | 3432 | emit organizerEventsSelected(false); |
3433 | } | 3433 | } |
3434 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3434 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3435 | KOPrefs::instance()->email() ) ) { | 3435 | KOPrefs::instance()->email() ) ) { |
3436 | emit groupEventsSelected( true ); | 3436 | emit groupEventsSelected( true ); |
3437 | } else { | 3437 | } else { |
3438 | emit groupEventsSelected(false); | 3438 | emit groupEventsSelected(false); |
3439 | } | 3439 | } |
3440 | return; | 3440 | return; |
3441 | } else { | 3441 | } else { |
3442 | if ( incidence && incidence->type() == "Todo" ) { | 3442 | if ( incidence && incidence->type() == "Todo" ) { |
3443 | emit todoSelected( true ); | 3443 | emit todoSelected( true ); |
3444 | Todo *event = static_cast<Todo *>( incidence ); | 3444 | Todo *event = static_cast<Todo *>( incidence ); |
3445 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3445 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3446 | emit organizerEventsSelected( true ); | 3446 | emit organizerEventsSelected( true ); |
3447 | } else { | 3447 | } else { |
3448 | emit organizerEventsSelected(false); | 3448 | emit organizerEventsSelected(false); |
3449 | } | 3449 | } |
3450 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3450 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3451 | KOPrefs::instance()->email() ) ) { | 3451 | KOPrefs::instance()->email() ) ) { |
3452 | emit groupEventsSelected( true ); | 3452 | emit groupEventsSelected( true ); |
3453 | } else { | 3453 | } else { |
3454 | emit groupEventsSelected(false); | 3454 | emit groupEventsSelected(false); |
3455 | } | 3455 | } |
3456 | return; | 3456 | return; |
3457 | } else { | 3457 | } else { |
3458 | emit todoSelected( false ); | 3458 | emit todoSelected( false ); |
3459 | emit organizerEventsSelected(false); | 3459 | emit organizerEventsSelected(false); |
3460 | emit groupEventsSelected(false); | 3460 | emit groupEventsSelected(false); |
3461 | } | 3461 | } |
3462 | return; | 3462 | return; |
3463 | } | 3463 | } |
3464 | 3464 | ||
3465 | /* if ( incidence && incidence->type() == "Todo" ) { | 3465 | /* if ( incidence && incidence->type() == "Todo" ) { |
3466 | emit todoSelected( true ); | 3466 | emit todoSelected( true ); |
3467 | } else { | 3467 | } else { |
3468 | emit todoSelected( false ); | 3468 | emit todoSelected( false ); |
3469 | }*/ | 3469 | }*/ |
3470 | } | 3470 | } |
3471 | 3471 | ||
3472 | 3472 | ||
3473 | void CalendarView::checkClipboard() | 3473 | void CalendarView::checkClipboard() |
3474 | { | 3474 | { |
3475 | #ifndef KORG_NODND | 3475 | #ifndef KORG_NODND |
3476 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3476 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3477 | emit pasteEnabled(true); | 3477 | emit pasteEnabled(true); |
3478 | } else { | 3478 | } else { |
3479 | emit pasteEnabled(false); | 3479 | emit pasteEnabled(false); |
3480 | } | 3480 | } |
3481 | #endif | 3481 | #endif |
3482 | } | 3482 | } |
3483 | 3483 | ||
3484 | void CalendarView::showDates(const DateList &selectedDates) | 3484 | void CalendarView::showDates(const DateList &selectedDates) |
3485 | { | 3485 | { |
3486 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3486 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3487 | 3487 | ||
3488 | 3488 | ||
3489 | if ( !mBlockShowDates ) { | 3489 | if ( !mBlockShowDates ) { |
3490 | if ( mViewManager->currentView() ) { | 3490 | if ( mViewManager->currentView() ) { |
3491 | updateView( selectedDates.first(), selectedDates.last() ); | 3491 | updateView( selectedDates.first(), selectedDates.last() ); |
3492 | } else { | 3492 | } else { |
3493 | mViewManager->showAgendaView(); | 3493 | mViewManager->showAgendaView(); |
3494 | } | 3494 | } |
3495 | } | 3495 | } |
3496 | 3496 | ||
3497 | QString selDates; | 3497 | QString selDates; |
3498 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3498 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3499 | if (selectedDates.first() < selectedDates.last() ) | 3499 | if (selectedDates.first() < selectedDates.last() ) |
3500 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3500 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3501 | else { | 3501 | else { |
3502 | QString addString; | 3502 | QString addString; |
3503 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3503 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3504 | addString = i18n("Today"); | 3504 | addString = i18n("Today"); |
3505 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3505 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3506 | addString = i18n("Tomorrow"); | 3506 | addString = i18n("Tomorrow"); |
3507 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3507 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3508 | addString = i18n("Yesterday"); | 3508 | addString = i18n("Yesterday"); |
3509 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3509 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3510 | addString = i18n("Day before yesterday"); | 3510 | addString = i18n("Day before yesterday"); |
3511 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3511 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3512 | addString = i18n("Day after tomorrow"); | 3512 | addString = i18n("Day after tomorrow"); |
3513 | if ( !addString.isEmpty() ) { | 3513 | if ( !addString.isEmpty() ) { |
3514 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3514 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3515 | return; | 3515 | return; |
3516 | } | 3516 | } |
3517 | } | 3517 | } |
3518 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3518 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3519 | 3519 | ||
3520 | } | 3520 | } |
3521 | 3521 | ||
3522 | QPtrList<CalFilter> CalendarView::filters() | 3522 | QPtrList<CalFilter> CalendarView::filters() |
3523 | { | 3523 | { |
3524 | return mFilters; | 3524 | return mFilters; |
3525 | 3525 | ||
3526 | } | 3526 | } |
3527 | void CalendarView::editFilters() | 3527 | void CalendarView::editFilters() |
3528 | { | 3528 | { |
3529 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3529 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3530 | 3530 | ||
3531 | CalFilter *filter = mFilters.first(); | 3531 | CalFilter *filter = mFilters.first(); |
3532 | while(filter) { | 3532 | while(filter) { |
3533 | kdDebug() << " Filter: " << filter->name() << endl; | 3533 | kdDebug() << " Filter: " << filter->name() << endl; |
3534 | filter = mFilters.next(); | 3534 | filter = mFilters.next(); |
3535 | } | 3535 | } |
3536 | 3536 | ||
3537 | mDialogManager->showFilterEditDialog(&mFilters); | 3537 | mDialogManager->showFilterEditDialog(&mFilters); |
3538 | } | 3538 | } |
3539 | void CalendarView::toggleFilter() | 3539 | void CalendarView::toggleFilter() |
3540 | { | 3540 | { |
3541 | showFilter(! mFilterView->isVisible()); | 3541 | showFilter(! mFilterView->isVisible()); |
3542 | } | 3542 | } |
3543 | 3543 | ||
3544 | KOFilterView *CalendarView::filterView() | 3544 | KOFilterView *CalendarView::filterView() |
3545 | { | 3545 | { |
3546 | return mFilterView; | 3546 | return mFilterView; |
3547 | } | 3547 | } |
3548 | void CalendarView::selectFilter( int fil ) | 3548 | void CalendarView::selectFilter( int fil ) |
3549 | { | 3549 | { |
3550 | mFilterView->setSelectedFilter( fil ); | 3550 | mFilterView->setSelectedFilter( fil ); |
3551 | } | 3551 | } |
3552 | void CalendarView::showFilter(bool visible) | 3552 | void CalendarView::showFilter(bool visible) |
3553 | { | 3553 | { |
3554 | if (visible) mFilterView->show(); | 3554 | if (visible) mFilterView->show(); |
3555 | else mFilterView->hide(); | 3555 | else mFilterView->hide(); |
3556 | } | 3556 | } |
3557 | void CalendarView::toggleFilerEnabled( ) | 3557 | void CalendarView::toggleFilerEnabled( ) |
3558 | { | 3558 | { |
3559 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3559 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3560 | if ( !mFilterView->filtersEnabled() ) | 3560 | if ( !mFilterView->filtersEnabled() ) |
3561 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3561 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3562 | 3562 | ||
3563 | } | 3563 | } |
3564 | void CalendarView::updateFilter() | 3564 | void CalendarView::updateFilter() |
3565 | { | 3565 | { |
3566 | CalFilter *filter = mFilterView->selectedFilter(); | 3566 | CalFilter *filter = mFilterView->selectedFilter(); |
3567 | if (filter) { | 3567 | if (filter) { |
3568 | if (mFilterView->filtersEnabled()) { | 3568 | if (mFilterView->filtersEnabled()) { |
3569 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3569 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3570 | filter->setEnabled(true); | 3570 | filter->setEnabled(true); |
3571 | } | 3571 | } |
3572 | else filter->setEnabled(false); | 3572 | else filter->setEnabled(false); |
3573 | mCalendar->setFilter(filter); | 3573 | mCalendar->setFilter(filter); |
3574 | updateView(); | 3574 | updateView(); |
3575 | } | 3575 | } |
3576 | } | 3576 | } |
3577 | 3577 | ||
3578 | void CalendarView::filterEdited() | 3578 | void CalendarView::filterEdited() |
3579 | { | 3579 | { |
3580 | mFilterView->updateFilters(); | 3580 | mFilterView->updateFilters(); |
3581 | updateFilter(); | 3581 | updateFilter(); |
3582 | writeSettings(); | 3582 | writeSettings(); |
3583 | } | 3583 | } |
3584 | 3584 | ||
3585 | 3585 | ||
3586 | void CalendarView::takeOverEvent() | 3586 | void CalendarView::takeOverEvent() |
3587 | { | 3587 | { |
3588 | Incidence *incidence = currentSelection(); | 3588 | Incidence *incidence = currentSelection(); |
3589 | 3589 | ||
3590 | if (!incidence) return; | 3590 | if (!incidence) return; |
3591 | 3591 | ||
3592 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3592 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3593 | incidence->recreate(); | 3593 | incidence->recreate(); |
3594 | incidence->setReadOnly(false); | 3594 | incidence->setReadOnly(false); |
3595 | 3595 | ||
3596 | updateView(); | 3596 | updateView(); |
3597 | } | 3597 | } |
3598 | 3598 | ||
3599 | void CalendarView::takeOverCalendar() | 3599 | void CalendarView::takeOverCalendar() |
3600 | { | 3600 | { |
3601 | // TODO: Create Calendar::allIncidences() function and use it here | 3601 | // TODO: Create Calendar::allIncidences() function and use it here |
3602 | 3602 | ||
3603 | QPtrList<Event> events = mCalendar->events(); | 3603 | QPtrList<Event> events = mCalendar->events(); |
3604 | for(uint i=0; i<events.count(); ++i) { | 3604 | for(uint i=0; i<events.count(); ++i) { |
3605 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3605 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3606 | events.at(i)->recreate(); | 3606 | events.at(i)->recreate(); |
3607 | events.at(i)->setReadOnly(false); | 3607 | events.at(i)->setReadOnly(false); |
3608 | } | 3608 | } |
3609 | 3609 | ||
3610 | QPtrList<Todo> todos = mCalendar->todos(); | 3610 | QPtrList<Todo> todos = mCalendar->todos(); |
3611 | for(uint i=0; i<todos.count(); ++i) { | 3611 | for(uint i=0; i<todos.count(); ++i) { |
3612 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3612 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3613 | todos.at(i)->recreate(); | 3613 | todos.at(i)->recreate(); |
3614 | todos.at(i)->setReadOnly(false); | 3614 | todos.at(i)->setReadOnly(false); |
3615 | } | 3615 | } |
3616 | 3616 | ||
3617 | QPtrList<Journal> journals = mCalendar->journals(); | 3617 | QPtrList<Journal> journals = mCalendar->journals(); |
3618 | for(uint i=0; i<journals.count(); ++i) { | 3618 | for(uint i=0; i<journals.count(); ++i) { |
3619 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3619 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3620 | journals.at(i)->recreate(); | 3620 | journals.at(i)->recreate(); |
3621 | journals.at(i)->setReadOnly(false); | 3621 | journals.at(i)->setReadOnly(false); |
3622 | } | 3622 | } |
3623 | 3623 | ||
3624 | updateView(); | 3624 | updateView(); |
3625 | } | 3625 | } |
3626 | 3626 | ||
3627 | void CalendarView::showIntro() | 3627 | void CalendarView::showIntro() |
3628 | { | 3628 | { |
3629 | kdDebug() << "To be implemented." << endl; | 3629 | kdDebug() << "To be implemented." << endl; |
3630 | } | 3630 | } |
3631 | 3631 | ||
3632 | QWidgetStack *CalendarView::viewStack() | 3632 | QWidgetStack *CalendarView::viewStack() |
3633 | { | 3633 | { |
3634 | return mRightFrame; | 3634 | return mRightFrame; |
3635 | } | 3635 | } |
3636 | 3636 | ||
3637 | QWidget *CalendarView::leftFrame() | 3637 | QWidget *CalendarView::leftFrame() |
3638 | { | 3638 | { |
3639 | return mLeftFrame; | 3639 | return mLeftFrame; |
3640 | } | 3640 | } |
3641 | 3641 | ||
3642 | DateNavigator *CalendarView::dateNavigator() | 3642 | DateNavigator *CalendarView::dateNavigator() |
3643 | { | 3643 | { |
3644 | return mNavigator; | 3644 | return mNavigator; |
3645 | } | 3645 | } |
3646 | 3646 | ||
3647 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3647 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3648 | { | 3648 | { |
3649 | return mDateNavigator; | 3649 | return mDateNavigator; |
3650 | } | 3650 | } |
3651 | void CalendarView::toggleDateNavigatorWidget() | 3651 | void CalendarView::toggleDateNavigatorWidget() |
3652 | { | 3652 | { |
3653 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3653 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3654 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3654 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3655 | mDateNavigator->hide(); | 3655 | mDateNavigator->hide(); |
3656 | else | 3656 | else |
3657 | mDateNavigator->show(); | 3657 | mDateNavigator->show(); |
3658 | } | 3658 | } |
3659 | void CalendarView::addView(KOrg::BaseView *view) | 3659 | void CalendarView::addView(KOrg::BaseView *view) |
3660 | { | 3660 | { |
3661 | mViewManager->addView(view); | 3661 | mViewManager->addView(view); |
3662 | } | 3662 | } |
3663 | 3663 | ||
3664 | void CalendarView::showView(KOrg::BaseView *view) | 3664 | void CalendarView::showView(KOrg::BaseView *view) |
3665 | { | 3665 | { |
3666 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3666 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3667 | } | 3667 | } |
3668 | 3668 | ||
3669 | Incidence *CalendarView::currentSelection() | 3669 | Incidence *CalendarView::currentSelection() |
3670 | { | 3670 | { |
3671 | return mViewManager->currentSelection(); | 3671 | return mViewManager->currentSelection(); |
3672 | } | 3672 | } |
3673 | void CalendarView::toggleAllDaySize() | 3673 | void CalendarView::toggleAllDaySize() |
3674 | { | 3674 | { |
3675 | /* | 3675 | /* |
3676 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3676 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3677 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3677 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3678 | else | 3678 | else |
3679 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3679 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3680 | */ | 3680 | */ |
3681 | viewManager()->agendaView()->toggleAllDay(); | 3681 | viewManager()->agendaView()->toggleAllDay(); |
3682 | } | 3682 | } |
3683 | void CalendarView::toggleExpand() | 3683 | void CalendarView::toggleExpand() |
3684 | { | 3684 | { |
3685 | // if ( mLeftFrame->isHidden() ) { | 3685 | // if ( mLeftFrame->isHidden() ) { |
3686 | // mLeftFrame->show(); | 3686 | // mLeftFrame->show(); |
3687 | // emit calendarViewExpanded( false ); | 3687 | // emit calendarViewExpanded( false ); |
3688 | // } else { | 3688 | // } else { |
3689 | // mLeftFrame->hide(); | 3689 | // mLeftFrame->hide(); |
3690 | // emit calendarViewExpanded( true ); | 3690 | // emit calendarViewExpanded( true ); |
3691 | // } | 3691 | // } |
3692 | 3692 | ||
3693 | globalFlagBlockAgenda = 1; | 3693 | globalFlagBlockAgenda = 1; |
3694 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3694 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3695 | globalFlagBlockAgenda = 5; | 3695 | globalFlagBlockAgenda = 5; |
3696 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3696 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3697 | //mViewManager->showView( 0, true ); | 3697 | //mViewManager->showView( 0, true ); |
3698 | } | 3698 | } |
3699 | 3699 | ||
3700 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3700 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3701 | { | 3701 | { |
3702 | setModified( modified ); | 3702 | setModified( modified ); |
3703 | } | 3703 | } |
3704 | 3704 | ||
3705 | Todo *CalendarView::selectedTodo() | 3705 | Todo *CalendarView::selectedTodo() |
3706 | { | 3706 | { |
3707 | Incidence *incidence = currentSelection(); | 3707 | Incidence *incidence = currentSelection(); |
3708 | if ( incidence && incidence->type() == "Todo" ) { | 3708 | if ( incidence && incidence->type() == "Todo" ) { |
3709 | return static_cast<Todo *>( incidence ); | 3709 | return static_cast<Todo *>( incidence ); |
3710 | } | 3710 | } |
3711 | 3711 | ||
3712 | incidence = mTodoList->selectedIncidences().first(); | 3712 | incidence = mTodoList->selectedIncidences().first(); |
3713 | if ( incidence && incidence->type() == "Todo" ) { | 3713 | if ( incidence && incidence->type() == "Todo" ) { |
3714 | return static_cast<Todo *>( incidence ); | 3714 | return static_cast<Todo *>( incidence ); |
3715 | } | 3715 | } |
3716 | 3716 | ||
3717 | return 0; | 3717 | return 0; |
3718 | } | 3718 | } |
3719 | 3719 | ||
3720 | void CalendarView::dialogClosing(Incidence *in) | 3720 | void CalendarView::dialogClosing(Incidence *in) |
3721 | { | 3721 | { |
3722 | // mDialogList.remove(in); | 3722 | // mDialogList.remove(in); |
3723 | } | 3723 | } |
3724 | 3724 | ||
3725 | void CalendarView::showIncidence() | 3725 | void CalendarView::showIncidence() |
3726 | { | 3726 | { |
3727 | Incidence *incidence = currentSelection(); | 3727 | Incidence *incidence = currentSelection(); |
3728 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3728 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3729 | if ( incidence ) { | 3729 | if ( incidence ) { |
3730 | ShowIncidenceVisitor v; | 3730 | ShowIncidenceVisitor v; |
3731 | v.act( incidence, this ); | 3731 | v.act( incidence, this ); |
3732 | } | 3732 | } |
3733 | } | 3733 | } |
3734 | void CalendarView::editIncidenceDescription() | 3734 | void CalendarView::editIncidenceDescription() |
3735 | { | 3735 | { |
3736 | mFlagEditDescription = true; | 3736 | mFlagEditDescription = true; |
3737 | editIncidence(); | 3737 | editIncidence(); |
3738 | mFlagEditDescription = false; | 3738 | mFlagEditDescription = false; |
3739 | } | 3739 | } |
3740 | void CalendarView::editIncidence() | 3740 | void CalendarView::editIncidence() |
3741 | { | 3741 | { |
3742 | // qDebug("editIncidence() "); | 3742 | // qDebug("editIncidence() "); |
3743 | Incidence *incidence = currentSelection(); | 3743 | Incidence *incidence = currentSelection(); |
3744 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3744 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3745 | if ( incidence ) { | 3745 | if ( incidence ) { |
3746 | EditIncidenceVisitor v; | 3746 | EditIncidenceVisitor v; |
3747 | v.act( incidence, this ); | 3747 | v.act( incidence, this ); |
3748 | } | 3748 | } |
3749 | } | 3749 | } |
3750 | 3750 | ||
3751 | void CalendarView::deleteIncidence() | 3751 | void CalendarView::deleteIncidence() |
3752 | { | 3752 | { |
3753 | Incidence *incidence = currentSelection(); | 3753 | Incidence *incidence = currentSelection(); |
3754 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3754 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3755 | if ( incidence ) { | 3755 | if ( incidence ) { |
3756 | deleteIncidence(incidence); | 3756 | deleteIncidence(incidence); |
3757 | } | 3757 | } |
3758 | } | 3758 | } |
3759 | 3759 | ||
3760 | void CalendarView::showIncidence(Incidence *incidence) | 3760 | void CalendarView::showIncidence(Incidence *incidence) |
3761 | { | 3761 | { |
3762 | if ( incidence ) { | 3762 | if ( incidence ) { |
3763 | ShowIncidenceVisitor v; | 3763 | ShowIncidenceVisitor v; |
3764 | v.act( incidence, this ); | 3764 | v.act( incidence, this ); |
3765 | } | 3765 | } |
3766 | } | 3766 | } |
3767 | 3767 | ||
3768 | void CalendarView::editIncidence(Incidence *incidence) | 3768 | void CalendarView::editIncidence(Incidence *incidence) |
3769 | { | 3769 | { |
3770 | if ( incidence ) { | 3770 | if ( incidence ) { |
3771 | 3771 | ||
3772 | EditIncidenceVisitor v; | 3772 | EditIncidenceVisitor v; |
3773 | v.act( incidence, this ); | 3773 | v.act( incidence, this ); |
3774 | 3774 | ||
3775 | } | 3775 | } |
3776 | } | 3776 | } |
3777 | 3777 | ||
3778 | void CalendarView::deleteIncidence(Incidence *incidence) | 3778 | void CalendarView::deleteIncidence(Incidence *incidence) |
3779 | { | 3779 | { |
3780 | //qDebug(" CalendarView::deleteIncidence "); | 3780 | //qDebug(" CalendarView::deleteIncidence "); |
3781 | if ( incidence ) { | 3781 | if ( incidence ) { |
3782 | DeleteIncidenceVisitor v; | 3782 | DeleteIncidenceVisitor v; |
3783 | v.act( incidence, this ); | 3783 | v.act( incidence, this ); |
3784 | } | 3784 | } |
3785 | } | 3785 | } |
3786 | 3786 | ||
3787 | 3787 | ||
3788 | void CalendarView::lookForOutgoingMessages() | 3788 | void CalendarView::lookForOutgoingMessages() |
3789 | { | 3789 | { |
3790 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3790 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3791 | ogd->loadMessages(); | 3791 | ogd->loadMessages(); |
3792 | } | 3792 | } |
3793 | 3793 | ||
3794 | void CalendarView::lookForIncomingMessages() | 3794 | void CalendarView::lookForIncomingMessages() |
3795 | { | 3795 | { |
3796 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3796 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3797 | icd->retrieve(); | 3797 | icd->retrieve(); |
3798 | } | 3798 | } |
3799 | 3799 | ||
3800 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3800 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3801 | { | 3801 | { |
3802 | bool deleteTodo = true; | 3802 | bool deleteTodo = true; |
3803 | QPtrList<Incidence> subTodos; | 3803 | QPtrList<Incidence> subTodos; |
3804 | Incidence *aTodo; | 3804 | Incidence *aTodo; |
3805 | subTodos = t->relations(); | 3805 | subTodos = t->relations(); |
3806 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3806 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3807 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3807 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3808 | deleteTodo = false; | 3808 | deleteTodo = false; |
3809 | } | 3809 | } |
3810 | if ( deleteTodo ) { | 3810 | if ( deleteTodo ) { |
3811 | if ( t->isCompleted() ) { | 3811 | if ( t->isCompleted() ) { |
3812 | checkExternalId( t ); | 3812 | checkExternalId( t ); |
3813 | mCalendar->deleteTodo( t ); | 3813 | mCalendar->deleteTodo( t ); |
3814 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3814 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3815 | } | 3815 | } |
3816 | else | 3816 | else |
3817 | deleteTodo = false; | 3817 | deleteTodo = false; |
3818 | } | 3818 | } |
3819 | return deleteTodo; | 3819 | return deleteTodo; |
3820 | 3820 | ||
3821 | } | 3821 | } |
3822 | void CalendarView::purgeCompleted() | 3822 | void CalendarView::purgeCompleted() |
3823 | { | 3823 | { |
3824 | int result = KMessageBox::warningContinueCancel(this, | 3824 | int result = KMessageBox::warningContinueCancel(this, |
3825 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3825 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3826 | 3826 | ||
3827 | if (result == KMessageBox::Continue) { | 3827 | if (result == KMessageBox::Continue) { |
3828 | 3828 | ||
3829 | QPtrList<Todo> todoCal; | 3829 | QPtrList<Todo> todoCal; |
3830 | QPtrList<Todo> rootTodos; | 3830 | QPtrList<Todo> rootTodos; |
3831 | //QPtrList<Incidence> rel; | 3831 | //QPtrList<Incidence> rel; |
3832 | Todo *aTodo;//, *rTodo; | 3832 | Todo *aTodo;//, *rTodo; |
3833 | Incidence *rIncidence; | 3833 | Incidence *rIncidence; |
3834 | bool childDelete = false; | 3834 | bool childDelete = false; |
3835 | bool deletedOne = true; | 3835 | bool deletedOne = true; |
3836 | todoCal = calendar()->todos(); | 3836 | todoCal = calendar()->todos(); |
3837 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3837 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3838 | if ( !aTodo->relatedTo() ) | 3838 | if ( !aTodo->relatedTo() ) |
3839 | rootTodos.append( aTodo ); | 3839 | rootTodos.append( aTodo ); |
3840 | } | 3840 | } |
3841 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3841 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3842 | removeCompletedSubTodos( aTodo ); | 3842 | removeCompletedSubTodos( aTodo ); |
3843 | } | 3843 | } |
3844 | 3844 | ||
3845 | updateView(); | 3845 | updateView(); |
3846 | } | 3846 | } |
3847 | } | 3847 | } |
3848 | 3848 | ||
3849 | void CalendarView::slotCalendarChanged() | 3849 | void CalendarView::slotCalendarChanged() |
3850 | { | 3850 | { |
3851 | ; | 3851 | ; |
3852 | } | 3852 | } |
3853 | 3853 | ||
3854 | NavigatorBar *CalendarView::navigatorBar() | 3854 | NavigatorBar *CalendarView::navigatorBar() |
3855 | { | 3855 | { |
3856 | return mNavigatorBar; | 3856 | return mNavigatorBar; |
3857 | } | 3857 | } |
3858 | 3858 | ||
3859 | 3859 | ||
3860 | 3860 | ||
3861 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3861 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3862 | { | 3862 | { |
3863 | //qDebug(" alendarView::keyPressEvent "); | 3863 | //qDebug(" alendarView::keyPressEvent "); |
3864 | e->ignore(); | 3864 | e->ignore(); |
3865 | } | 3865 | } |
3866 | 3866 | ||
3867 | 3867 | ||
3868 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3868 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3869 | { | 3869 | { |
3870 | // mSyncManager = manager; | 3870 | // mSyncManager = manager; |
3871 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3871 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3872 | qDebug("KO: SyncKDE request detected!"); | 3872 | qDebug("KO: SyncKDE request detected!"); |
3873 | } | 3873 | } |
3874 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3874 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3875 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3875 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3876 | return syncCalendar( filename, mode ); | 3876 | return syncCalendar( filename, mode ); |
3877 | } | 3877 | } |
3878 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3878 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3879 | { | 3879 | { |
3880 | //mSyncManager = manager; | 3880 | //mSyncManager = manager; |
3881 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3881 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3882 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3882 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3883 | if ( resource == "sharp" ) | 3883 | if ( resource == "sharp" ) |
3884 | syncExternal( 0 ); | 3884 | syncExternal( 0 ); |
3885 | if ( resource == "phone" ) | 3885 | if ( resource == "phone" ) |
3886 | syncExternal( 1 ); | 3886 | syncExternal( 1 ); |
3887 | // pending setmodified | 3887 | // pending setmodified |
3888 | return true; | 3888 | return true; |
3889 | } | 3889 | } |
3890 | void CalendarView::setSyncManager(KSyncManager* manager) | 3890 | void CalendarView::setSyncManager(KSyncManager* manager) |
3891 | { | 3891 | { |
3892 | mSyncManager = manager; | 3892 | mSyncManager = manager; |
3893 | } | 3893 | } |
3894 | 3894 | ||
3895 | void CalendarView::removeSyncInfo( QString syncProfile) | 3895 | void CalendarView::removeSyncInfo( QString syncProfile) |
3896 | { | 3896 | { |
3897 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3897 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3898 | mCalendar->removeSyncInfo( syncProfile ); | 3898 | mCalendar->removeSyncInfo( syncProfile ); |
3899 | 3899 | ||
3900 | } | 3900 | } |
3901 | 3901 | ||
3902 | void CalendarView::undo_delete() | 3902 | void CalendarView::undo_delete() |
3903 | { | 3903 | { |
3904 | //qDebug("undo_delete() "); | 3904 | //qDebug("undo_delete() "); |
3905 | Incidence* undo = mCalendar->undoIncidence(); | 3905 | Incidence* undo = mCalendar->undoIncidence(); |
3906 | if ( !undo ) { | 3906 | if ( !undo ) { |
3907 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3907 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3908 | i18n("KO/Pi")); | 3908 | i18n("KO/Pi")); |
3909 | return; | 3909 | return; |
3910 | } | 3910 | } |
3911 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3911 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3912 | i18n("\nAre you sure you want\nto restore this?"), | 3912 | i18n("\nAre you sure you want\nto restore this?"), |
3913 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3913 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3914 | mCalendar->undoDeleteIncidence(); | 3914 | mCalendar->undoDeleteIncidence(); |
3915 | updateView(); | 3915 | updateView(); |
3916 | } | 3916 | } |
3917 | } | 3917 | } |
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp index cf0a458..ef8025b 100644 --- a/korganizer/koeditordetails.cpp +++ b/korganizer/koeditordetails.cpp | |||
@@ -1,441 +1,452 @@ | |||
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 thse hope that it will be useful, | 10 | This program is distributed in thse 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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qfiledialog.h> | 25 | #include <qfiledialog.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapp.h> | 32 | #include <qapp.h> |
33 | 33 | ||
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | #ifndef KORG_NOKABC | 39 | #ifndef KORG_NOKABC |
40 | 40 | ||
41 | #ifdef DESKTOP_VERSION | 41 | #ifdef DESKTOP_VERSION |
42 | #include <kabc/addresseedialog.h> | 42 | #include <kabc/addresseedialog.h> |
43 | #else //DESKTOP_VERSION | 43 | #else //DESKTOP_VERSION |
44 | #include <externalapphandler.h> | 44 | #include <externalapphandler.h> |
45 | #endif //DESKTOP_VERSION | 45 | #endif //DESKTOP_VERSION |
46 | 46 | ||
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <libkcal/incidence.h> | 49 | #include <libkcal/incidence.h> |
50 | 50 | ||
51 | #include "koprefs.h" | 51 | #include "koprefs.h" |
52 | 52 | ||
53 | #include "koeditordetails.h" | 53 | #include "koeditordetails.h" |
54 | 54 | ||
55 | template <> | 55 | template <> |
56 | CustomListViewItem<class Attendee *>::~CustomListViewItem() | 56 | CustomListViewItem<class Attendee *>::~CustomListViewItem() |
57 | { | 57 | { |
58 | delete mData; | 58 | delete mData; |
59 | } | 59 | } |
60 | 60 | ||
61 | template <> | 61 | template <> |
62 | void CustomListViewItem<class Attendee *>::updateItem() | 62 | void CustomListViewItem<class Attendee *>::updateItem() |
63 | { | 63 | { |
64 | setText(0,mData->name()); | 64 | setText(0,mData->name()); |
65 | setText(1,mData->email()); | 65 | setText(1,mData->email()); |
66 | setText(2,mData->roleStr()); | 66 | setText(2,mData->roleStr()); |
67 | setText(3,mData->statusStr()); | 67 | setText(3,mData->statusStr()); |
68 | if (mData->RSVP() && !mData->email().isEmpty()) | 68 | if (mData->RSVP() && !mData->email().isEmpty()) |
69 | setPixmap(4,SmallIcon("mailappt")); | 69 | setPixmap(4,SmallIcon("mailappt")); |
70 | else | 70 | else |
71 | setPixmap(4,SmallIcon("nomailappt")); | 71 | setPixmap(4,SmallIcon("nomailappt")); |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) | 75 | KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) |
76 | : QWidget( parent, name), mDisableItemUpdate( false ) | 76 | : QWidget( parent, name), mDisableItemUpdate( false ) |
77 | { | 77 | { |
78 | QGridLayout *topLayout = new QGridLayout(this); | 78 | QGridLayout *topLayout = new QGridLayout(this); |
79 | topLayout->setSpacing(spacing); | 79 | topLayout->setSpacing(spacing); |
80 | 80 | ||
81 | QString organizer = KOPrefs::instance()->email(); | 81 | QString organizer = KOPrefs::instance()->email(); |
82 | mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); | 82 | mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); |
83 | 83 | ||
84 | mListView = new KListView(this,"mListView"); | 84 | mListView = new KListView(this,"mListView"); |
85 | mListView->addColumn(i18n("Name"),180); | 85 | mListView->addColumn(i18n("Name"),180); |
86 | mListView->addColumn(i18n("Email"),180); | 86 | mListView->addColumn(i18n("Email"),180); |
87 | mListView->addColumn(i18n("Role"),60); | 87 | mListView->addColumn(i18n("Role"),60); |
88 | mListView->addColumn(i18n("Status"),100); | 88 | mListView->addColumn(i18n("Status"),100); |
89 | mListView->addColumn(i18n("RSVP"),35); | 89 | mListView->addColumn(i18n("RSVP"),35); |
90 | if ( KOPrefs::instance()->mCompactDialogs ) { | 90 | if ( KOPrefs::instance()->mCompactDialogs ) { |
91 | //mListView->setFixedHeight(78); | 91 | //mListView->setFixedHeight(78); |
92 | } | 92 | } |
93 | 93 | mListView->setAllColumnsShowFocus (true ); | |
94 | //mListView->setSingleClick( true ); | ||
94 | connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), | 95 | connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), |
95 | SLOT(updateAttendeeInput())); | 96 | SLOT(updateAttendeeInput())); |
96 | 97 | ||
98 | connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )), | ||
99 | SLOT(itemClicked(QListViewItem * ,const QPoint& , int ))); | ||
100 | |||
97 | QLabel *attendeeLabel = new QLabel(this); | 101 | QLabel *attendeeLabel = new QLabel(this); |
98 | attendeeLabel->setText(i18n("Name:")); | 102 | attendeeLabel->setText(i18n("Name:")); |
99 | attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); | 103 | attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); |
100 | mNameEdit = new QLineEdit(this); | 104 | mNameEdit = new QLineEdit(this); |
101 | connect(mNameEdit,SIGNAL(textChanged(const QString &)), | 105 | connect(mNameEdit,SIGNAL(textChanged(const QString &)), |
102 | SLOT(updateAttendeeItem())); | 106 | SLOT(updateAttendeeItem())); |
103 | 107 | ||
104 | mUidEdit = new QLineEdit(0); | 108 | mUidEdit = new QLineEdit(0); |
105 | mUidEdit->setText(""); | 109 | mUidEdit->setText(""); |
106 | 110 | ||
107 | QLabel *emailLabel = new QLabel(this); | 111 | QLabel *emailLabel = new QLabel(this); |
108 | emailLabel->setText(i18n("Email:")); | 112 | emailLabel->setText(i18n("Email:")); |
109 | mEmailEdit = new QLineEdit(this); | 113 | mEmailEdit = new QLineEdit(this); |
110 | connect(mEmailEdit,SIGNAL(textChanged(const QString &)), | 114 | connect(mEmailEdit,SIGNAL(textChanged(const QString &)), |
111 | SLOT(updateAttendeeItem())); | 115 | SLOT(updateAttendeeItem())); |
112 | 116 | ||
113 | QLabel *attendeeRoleLabel = new QLabel(this); | 117 | QLabel *attendeeRoleLabel = new QLabel(this); |
114 | attendeeRoleLabel->setText(i18n("Role:")); | 118 | attendeeRoleLabel->setText(i18n("Role:")); |
115 | mRoleCombo = new QComboBox(false,this); | 119 | mRoleCombo = new QComboBox(false,this); |
116 | mRoleCombo->insertStringList(Attendee::roleList()); | 120 | mRoleCombo->insertStringList(Attendee::roleList()); |
117 | connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); | 121 | connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); |
118 | 122 | ||
119 | QLabel *statusLabel = new QLabel(this); | 123 | QLabel *statusLabel = new QLabel(this); |
120 | statusLabel->setText( i18n("Status:") ); | 124 | statusLabel->setText( i18n("Status:") ); |
121 | 125 | ||
122 | mStatusCombo = new QComboBox(false,this); | 126 | mStatusCombo = new QComboBox(false,this); |
123 | mStatusCombo->insertStringList(Attendee::statusList()); | 127 | mStatusCombo->insertStringList(Attendee::statusList()); |
124 | connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); | 128 | connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); |
125 | 129 | ||
126 | mRsvpButton = new QCheckBox(this); | 130 | mRsvpButton = new QCheckBox(this); |
127 | mRsvpButton->setText(i18n("Request response")); | 131 | mRsvpButton->setText(i18n("Request response")); |
128 | connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); | 132 | connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); |
129 | QWidget *buttonBox = new QWidget(this); | 133 | QWidget *buttonBox = new QWidget(this); |
130 | QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); | 134 | QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); |
131 | 135 | ||
132 | QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); | 136 | QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); |
133 | buttonLayout->addWidget(newButton); | 137 | buttonLayout->addWidget(newButton); |
134 | connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); | 138 | connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); |
135 | 139 | ||
136 | mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); | 140 | mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); |
137 | buttonLayout->addWidget(mRemoveButton); | 141 | buttonLayout->addWidget(mRemoveButton); |
138 | connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); | 142 | connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); |
139 | 143 | ||
140 | mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); | 144 | mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); |
141 | // buttonLayout->addWidget(mAddressBookButton); | 145 | // buttonLayout->addWidget(mAddressBookButton); |
142 | connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); | 146 | connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); |
143 | //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); | 147 | //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); |
144 | 148 | ||
145 | if (qApp->desktop()->width() < 640 ) { | 149 | if (qApp->desktop()->width() < 640 ) { |
146 | if ( qApp->desktop()->width() < 300 ) | 150 | if ( qApp->desktop()->width() < 300 ) |
147 | topLayout->setSpacing(1); | 151 | topLayout->setSpacing(1); |
148 | ;//mListView->setFixedHeight(80); | 152 | ;//mListView->setFixedHeight(80); |
149 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); | 153 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); |
150 | topLayout->addMultiCellWidget(mListView,1,1,0,3); | 154 | topLayout->addMultiCellWidget(mListView,1,1,0,3); |
151 | topLayout->addWidget(attendeeLabel,3,0); | 155 | topLayout->addWidget(attendeeLabel,3,0); |
152 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); | 156 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); |
153 | topLayout->addWidget(emailLabel,4,0); | 157 | topLayout->addWidget(emailLabel,4,0); |
154 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); | 158 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); |
155 | topLayout->addWidget(attendeeRoleLabel,5,0); | 159 | topLayout->addWidget(attendeeRoleLabel,5,0); |
156 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); | 160 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); |
157 | topLayout->addWidget(statusLabel,6,0); | 161 | topLayout->addWidget(statusLabel,6,0); |
158 | topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); | 162 | topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); |
159 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); | 163 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); |
160 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | 164 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); |
161 | topLayout->addMultiCellWidget(buttonBox,3,4,3,3); | 165 | topLayout->addMultiCellWidget(buttonBox,3,4,3,3); |
162 | topLayout->setRowStretch(1,2); | 166 | topLayout->setRowStretch(1,2); |
163 | topLayout->setColStretch(0,0); | 167 | topLayout->setColStretch(0,0); |
164 | topLayout->setColStretch(1,2); | 168 | topLayout->setColStretch(1,2); |
165 | topLayout->setColStretch(2,1); | 169 | topLayout->setColStretch(2,1); |
166 | topLayout->setColStretch(3,1); | 170 | topLayout->setColStretch(3,1); |
167 | 171 | ||
168 | } else { | 172 | } else { |
169 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); | 173 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); |
170 | topLayout->addMultiCellWidget(mListView,1,1,0,5); | 174 | topLayout->addMultiCellWidget(mListView,1,1,0,5); |
171 | topLayout->addWidget(attendeeLabel,3,0); | 175 | topLayout->addWidget(attendeeLabel,3,0); |
172 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); | 176 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); |
173 | topLayout->addWidget(emailLabel,4,0); | 177 | topLayout->addWidget(emailLabel,4,0); |
174 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); | 178 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); |
175 | topLayout->addWidget(attendeeRoleLabel,5,0); | 179 | topLayout->addWidget(attendeeRoleLabel,5,0); |
176 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); | 180 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); |
177 | topLayout->addWidget(statusLabel,5,3); | 181 | topLayout->addWidget(statusLabel,5,3); |
178 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); | 182 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); |
179 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); | 183 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); |
180 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | 184 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); |
181 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); | 185 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); |
182 | topLayout->setRowStretch(1,5); | 186 | topLayout->setRowStretch(1,5); |
183 | topLayout->setColStretch(0,0); | 187 | topLayout->setColStretch(0,0); |
184 | } | 188 | } |
185 | // #if 0 | 189 | // #if 0 |
186 | // topLayout->setColStretch(2,1); | 190 | // topLayout->setColStretch(2,1); |
187 | // topLayout->addWidget(statusLabel,3,3); | 191 | // topLayout->addWidget(statusLabel,3,3); |
188 | // topLayout->addWidget(mStatusCombo,3,4); | 192 | // topLayout->addWidget(mStatusCombo,3,4); |
189 | // #else | 193 | // #else |
190 | // topLayout->addWidget(statusLabel,4,3); | 194 | // topLayout->addWidget(statusLabel,4,3); |
191 | // // topLayout->addWidget(mStatusCombo,4,3); | 195 | // // topLayout->addWidget(mStatusCombo,4,3); |
192 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); | 196 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); |
193 | 197 | ||
194 | // #endif | 198 | // #endif |
195 | // // topLayout->setRowStretch(5,1); | 199 | // // topLayout->setRowStretch(5,1); |
196 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); | 200 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); |
197 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); | 201 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); |
198 | // topLayout->setRowStretch(1,5); | 202 | // topLayout->setRowStretch(1,5); |
199 | // topLayout->setColStretch(0,0); | 203 | // topLayout->setColStretch(0,0); |
200 | 204 | ||
201 | #ifdef KORG_NOKABC | 205 | #ifdef KORG_NOKABC |
202 | mAddressBookButton->hide(); | 206 | mAddressBookButton->hide(); |
203 | #endif | 207 | #endif |
204 | 208 | ||
205 | updateAttendeeInput(); | 209 | updateAttendeeInput(); |
206 | #ifndef DESKTOP_VERSION | 210 | #ifndef DESKTOP_VERSION |
207 | //US listen for arriving address resultsets | 211 | //US listen for arriving address resultsets |
208 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 212 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
209 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 213 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
210 | #endif | 214 | #endif |
211 | 215 | ||
212 | } | 216 | } |
213 | 217 | ||
214 | KOEditorDetails::~KOEditorDetails() | 218 | KOEditorDetails::~KOEditorDetails() |
215 | { | 219 | { |
216 | } | 220 | } |
217 | 221 | ||
218 | void KOEditorDetails::removeAttendee() | 222 | void KOEditorDetails::removeAttendee() |
219 | { | 223 | { |
220 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); | 224 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); |
221 | if (!aItem) return; | 225 | if (!aItem) return; |
222 | 226 | ||
223 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), | 227 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), |
224 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), | 228 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), |
225 | aItem->data()->uid()); | 229 | aItem->data()->uid()); |
226 | mdelAttendees.append(delA); | 230 | mdelAttendees.append(delA); |
227 | 231 | ||
228 | delete aItem; | 232 | delete aItem; |
229 | 233 | ||
230 | updateAttendeeInput(); | 234 | updateAttendeeInput(); |
231 | } | 235 | } |
232 | 236 | ||
233 | 237 | ||
234 | void KOEditorDetails::openAddressBook() | 238 | void KOEditorDetails::openAddressBook() |
235 | { | 239 | { |
236 | #ifndef KORG_NOKABC | 240 | #ifndef KORG_NOKABC |
237 | 241 | ||
238 | #ifdef DESKTOP_VERSION | 242 | #ifdef DESKTOP_VERSION |
239 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 243 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
240 | uint i=0; | 244 | uint i=0; |
241 | for (i=0; i < list.count(); i++) { | 245 | for (i=0; i < list.count(); i++) { |
242 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); | 246 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); |
243 | } | 247 | } |
244 | #else | 248 | #else |
245 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 249 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
246 | // the result should now arrive through method insertAttendees | 250 | // the result should now arrive through method insertAttendees |
247 | #endif | 251 | #endif |
248 | 252 | ||
249 | 253 | ||
250 | #if 0 | 254 | #if 0 |
251 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); | 255 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); |
252 | if (!a.isEmpty()) { | 256 | if (!a.isEmpty()) { |
253 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); | 257 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); |
254 | } | 258 | } |
255 | #endif | 259 | #endif |
256 | #endif | 260 | #endif |
257 | } | 261 | } |
258 | 262 | ||
259 | 263 | ||
260 | void KOEditorDetails::addNewAttendee() | 264 | void KOEditorDetails::addNewAttendee() |
261 | { | 265 | { |
262 | #if 0 | 266 | #if 0 |
263 | // this is cool. If they didn't enter an email address, | 267 | // this is cool. If they didn't enter an email address, |
264 | // try to look it up in the address book and fill it in for them. | 268 | // try to look it up in the address book and fill it in for them. |
265 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { | 269 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { |
266 | KabAPI addrBook; | 270 | KabAPI addrBook; |
267 | QString name; | 271 | QString name; |
268 | std::list<AddressBook::Entry> entries; | 272 | std::list<AddressBook::Entry> entries; |
269 | name = mNameEdit->text(); | 273 | name = mNameEdit->text(); |
270 | if (addrBook.init() == AddressBook::NoError) { | 274 | if (addrBook.init() == AddressBook::NoError) { |
271 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { | 275 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { |
272 | kdDebug() << "positive match" << endl; | 276 | kdDebug() << "positive match" << endl; |
273 | // take first email address | 277 | // take first email address |
274 | if (!entries.front().emails.isEmpty() && | 278 | if (!entries.front().emails.isEmpty() && |
275 | entries.front().emails.first().length()>0) | 279 | entries.front().emails.first().length()>0) |
276 | mEmailEdit->setText(entries.front().emails.first()); | 280 | mEmailEdit->setText(entries.front().emails.first()); |
277 | } | 281 | } |
278 | } | 282 | } |
279 | } | 283 | } |
280 | #endif | 284 | #endif |
281 | 285 | ||
282 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); | 286 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); |
283 | insertAttendee(a); | 287 | insertAttendee(a); |
284 | } | 288 | } |
285 | 289 | ||
286 | //the map includes name/email pairs, that comes from Ka/Pi | 290 | //the map includes name/email pairs, that comes from Ka/Pi |
287 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 291 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
288 | { | 292 | { |
289 | if (uid == this->name()) | 293 | if (uid == this->name()) |
290 | { | 294 | { |
291 | for ( int i = 0; i < nameList.count(); i++) | 295 | for ( int i = 0; i < nameList.count(); i++) |
292 | { | 296 | { |
293 | QString _name = nameList[i]; | 297 | QString _name = nameList[i]; |
294 | QString _email = emailList[i]; | 298 | QString _email = emailList[i]; |
295 | QString _uid = uidList[i]; | 299 | QString _uid = uidList[i]; |
296 | 300 | ||
297 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); | 301 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); |
298 | insertAttendee(a); | 302 | insertAttendee(a); |
299 | } | 303 | } |
300 | } | 304 | } |
301 | 305 | ||
302 | } | 306 | } |
303 | 307 | ||
304 | void KOEditorDetails::insertAttendee(Attendee *a) | 308 | void KOEditorDetails::insertAttendee(Attendee *a) |
305 | { | 309 | { |
306 | AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); | 310 | AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); |
307 | while (first) { | 311 | while (first) { |
308 | if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) | 312 | if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) |
309 | return; | 313 | return; |
310 | first = (AttendeeListItem*) first->nextSibling(); | 314 | first = (AttendeeListItem*) first->nextSibling(); |
311 | } | 315 | } |
312 | 316 | ||
313 | AttendeeListItem *item = new AttendeeListItem(a,mListView); | 317 | AttendeeListItem *item = new AttendeeListItem(a,mListView); |
314 | mListView->setSelected( item, true ); | 318 | mListView->setSelected( item, true ); |
315 | } | 319 | } |
316 | 320 | ||
317 | void KOEditorDetails::setDefaults() | 321 | void KOEditorDetails::setDefaults() |
318 | { | 322 | { |
319 | mRsvpButton->setChecked(true); | 323 | mRsvpButton->setChecked(true); |
320 | mListView->clear(); | 324 | mListView->clear(); |
321 | mdelAttendees.clear(); | 325 | mdelAttendees.clear(); |
322 | clearAttendeeInput(); | 326 | clearAttendeeInput(); |
323 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); | 327 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); |
324 | 328 | ||
325 | mNameEdit->setText(""); | 329 | mNameEdit->setText(""); |
326 | mUidEdit->setText(""); | 330 | mUidEdit->setText(""); |
327 | mEmailEdit->setText(""); | 331 | mEmailEdit->setText(""); |
328 | mRoleCombo->setCurrentItem( 0 ); | 332 | mRoleCombo->setCurrentItem( 0 ); |
329 | mStatusCombo->setCurrentItem( 0 ); | 333 | mStatusCombo->setCurrentItem( 0 ); |
330 | 334 | ||
331 | } | 335 | } |
332 | 336 | ||
333 | void KOEditorDetails::readEvent(Incidence *event) | 337 | void KOEditorDetails::readEvent(Incidence *event) |
334 | { | 338 | { |
335 | setDefaults(); | 339 | setDefaults(); |
336 | //mListView->clear(); | 340 | //mListView->clear(); |
337 | //mdelAttendees.clear(); | 341 | //mdelAttendees.clear(); |
338 | QPtrList<Attendee> tmpAList = event->attendees(); | 342 | QPtrList<Attendee> tmpAList = event->attendees(); |
339 | Attendee *a; | 343 | Attendee *a; |
340 | for (a = tmpAList.first(); a; a = tmpAList.next()) | 344 | for (a = tmpAList.first(); a; a = tmpAList.next()) |
341 | insertAttendee(new Attendee(*a)); | 345 | insertAttendee(new Attendee(*a)); |
342 | 346 | ||
343 | mListView->setSelected( mListView->firstChild(), true ); | 347 | mListView->setSelected( mListView->firstChild(), true ); |
344 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); | 348 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); |
345 | } | 349 | } |
346 | 350 | ||
347 | void KOEditorDetails::writeEvent(Incidence *event) | 351 | void KOEditorDetails::writeEvent(Incidence *event) |
348 | { | 352 | { |
349 | event->clearAttendees(); | 353 | event->clearAttendees(); |
350 | QListViewItem *item; | 354 | QListViewItem *item; |
351 | AttendeeListItem *a; | 355 | AttendeeListItem *a; |
352 | for (item = mListView->firstChild(); item; | 356 | for (item = mListView->firstChild(); item; |
353 | item = item->nextSibling()) { | 357 | item = item->nextSibling()) { |
354 | a = (AttendeeListItem *)item; | 358 | a = (AttendeeListItem *)item; |
355 | event->addAttendee(new Attendee(*(a->data()))); | 359 | event->addAttendee(new Attendee(*(a->data()))); |
356 | } | 360 | } |
357 | event->setOrganizer(KOPrefs::instance()->email()); | 361 | event->setOrganizer(KOPrefs::instance()->email()); |
358 | } | 362 | } |
359 | 363 | ||
360 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) | 364 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) |
361 | { | 365 | { |
362 | event->clearAttendees(); | 366 | event->clearAttendees(); |
363 | Attendee * att; | 367 | Attendee * att; |
364 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { | 368 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { |
365 | event->addAttendee(new Attendee(*att)); | 369 | event->addAttendee(new Attendee(*att)); |
366 | } | 370 | } |
367 | mdelAttendees.clear(); | 371 | mdelAttendees.clear(); |
368 | } | 372 | } |
369 | 373 | ||
370 | bool KOEditorDetails::validateInput() | 374 | bool KOEditorDetails::validateInput() |
371 | { | 375 | { |
372 | return true; | 376 | return true; |
373 | } | 377 | } |
374 | 378 | ||
375 | void KOEditorDetails::updateAttendeeInput() | 379 | void KOEditorDetails::updateAttendeeInput() |
376 | { | 380 | { |
377 | QListViewItem *item = mListView->selectedItem(); | 381 | QListViewItem *item = mListView->selectedItem(); |
378 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); | 382 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); |
379 | if (aItem) { | 383 | if (aItem) { |
380 | fillAttendeeInput( aItem ); | 384 | fillAttendeeInput( aItem ); |
381 | } else { | 385 | } else { |
382 | clearAttendeeInput(); | 386 | clearAttendeeInput(); |
383 | } | 387 | } |
384 | } | 388 | } |
385 | 389 | ||
386 | void KOEditorDetails::clearAttendeeInput() | 390 | void KOEditorDetails::clearAttendeeInput() |
387 | { | 391 | { |
388 | mNameEdit->setText(""); | 392 | mNameEdit->setText(""); |
389 | mUidEdit->setText(""); | 393 | mUidEdit->setText(""); |
390 | mEmailEdit->setText(""); | 394 | mEmailEdit->setText(""); |
391 | mRoleCombo->setCurrentItem(0); | 395 | mRoleCombo->setCurrentItem(0); |
392 | mStatusCombo->setCurrentItem(0); | 396 | mStatusCombo->setCurrentItem(0); |
393 | mRsvpButton->setChecked(true); | 397 | mRsvpButton->setChecked(true); |
394 | setEnabledAttendeeInput( false ); | 398 | setEnabledAttendeeInput( false ); |
395 | } | 399 | } |
396 | 400 | ||
397 | void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) | 401 | void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) |
398 | { | 402 | { |
399 | Attendee *a = aItem->data(); | 403 | Attendee *a = aItem->data(); |
400 | mDisableItemUpdate = true; | 404 | mDisableItemUpdate = true; |
401 | mNameEdit->setText(a->name()); | 405 | mNameEdit->setText(a->name()); |
402 | mUidEdit->setText(a->uid()); | 406 | mUidEdit->setText(a->uid()); |
403 | mEmailEdit->setText(a->email()); | 407 | mEmailEdit->setText(a->email()); |
404 | mRoleCombo->setCurrentItem(a->role()); | 408 | mRoleCombo->setCurrentItem(a->role()); |
405 | mStatusCombo->setCurrentItem(a->status()); | 409 | mStatusCombo->setCurrentItem(a->status()); |
406 | mRsvpButton->setChecked(a->RSVP()); | 410 | mRsvpButton->setChecked(a->RSVP()); |
407 | 411 | ||
408 | mDisableItemUpdate = false; | 412 | mDisableItemUpdate = false; |
409 | 413 | ||
410 | setEnabledAttendeeInput( true ); | 414 | setEnabledAttendeeInput( true ); |
411 | } | 415 | } |
412 | 416 | ||
413 | void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) | 417 | void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) |
414 | { | 418 | { |
415 | mNameEdit->setEnabled( enabled ); | 419 | mNameEdit->setEnabled( enabled ); |
416 | mEmailEdit->setEnabled( enabled ); | 420 | mEmailEdit->setEnabled( enabled ); |
417 | mRoleCombo->setEnabled( enabled ); | 421 | mRoleCombo->setEnabled( enabled ); |
418 | mStatusCombo->setEnabled( enabled ); | 422 | mStatusCombo->setEnabled( enabled ); |
419 | mRsvpButton->setEnabled( enabled ); | 423 | mRsvpButton->setEnabled( enabled ); |
420 | 424 | ||
421 | mRemoveButton->setEnabled( enabled ); | 425 | mRemoveButton->setEnabled( enabled ); |
422 | } | 426 | } |
423 | 427 | ||
428 | void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c ) | ||
429 | { | ||
430 | if ( item && c == 4 ) { | ||
431 | mRsvpButton->setChecked( !mRsvpButton->isChecked() ); | ||
432 | updateAttendeeItem(); | ||
433 | } | ||
434 | } | ||
424 | void KOEditorDetails::updateAttendeeItem() | 435 | void KOEditorDetails::updateAttendeeItem() |
425 | { | 436 | { |
426 | if (mDisableItemUpdate) return; | 437 | if (mDisableItemUpdate) return; |
427 | 438 | ||
428 | QListViewItem *item = mListView->selectedItem(); | 439 | QListViewItem *item = mListView->selectedItem(); |
429 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); | 440 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); |
430 | if ( !aItem ) return; | 441 | if ( !aItem ) return; |
431 | 442 | ||
432 | Attendee *a = aItem->data(); | 443 | Attendee *a = aItem->data(); |
433 | 444 | ||
434 | a->setName( mNameEdit->text() ); | 445 | a->setName( mNameEdit->text() ); |
435 | a->setUid( mUidEdit->text() ); | 446 | a->setUid( mUidEdit->text() ); |
436 | a->setEmail( mEmailEdit->text() ); | 447 | a->setEmail( mEmailEdit->text() ); |
437 | a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); | 448 | a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); |
438 | a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); | 449 | a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); |
439 | a->setRSVP( mRsvpButton->isChecked() ); | 450 | a->setRSVP( mRsvpButton->isChecked() ); |
440 | aItem->updateItem(); | 451 | aItem->updateItem(); |
441 | } | 452 | } |
diff --git a/korganizer/koeditordetails.h b/korganizer/koeditordetails.h index 0cc807f..a33ee82 100644 --- a/korganizer/koeditordetails.h +++ b/korganizer/koeditordetails.h | |||
@@ -1,108 +1,109 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,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 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KOEDITORDETAILS_H | 23 | #ifndef _KOEDITORDETAILS_H |
24 | #define _KOEDITORDETAILS_H | 24 | #define _KOEDITORDETAILS_H |
25 | 25 | ||
26 | #include <qmap.h> | 26 | #include <qmap.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qcheckbox.h> | 29 | #include <qcheckbox.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qgroupbox.h> | 31 | #include <qgroupbox.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qmultilineedit.h> | 34 | #include <qmultilineedit.h> |
35 | #include <klistview.h> | 35 | #include <klistview.h> |
36 | #include <qradiobutton.h> | 36 | #include <qradiobutton.h> |
37 | #include <qptrlist.h> | 37 | #include <qptrlist.h> |
38 | 38 | ||
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | 40 | ||
41 | #include <libkcal/event.h> | 41 | #include <libkcal/event.h> |
42 | 42 | ||
43 | #include "ktimeedit.h" | 43 | #include "ktimeedit.h" |
44 | #include "customlistviewitem.h" | 44 | #include "customlistviewitem.h" |
45 | 45 | ||
46 | class KDateEdit; | 46 | class KDateEdit; |
47 | 47 | ||
48 | using namespace KCal; | 48 | using namespace KCal; |
49 | 49 | ||
50 | typedef CustomListViewItem<Attendee *> AttendeeListItem; | 50 | typedef CustomListViewItem<Attendee *> AttendeeListItem; |
51 | 51 | ||
52 | 52 | ||
53 | class KOEditorDetails : public QWidget | 53 | class KOEditorDetails : public QWidget |
54 | { | 54 | { |
55 | Q_OBJECT | 55 | Q_OBJECT |
56 | public: | 56 | public: |
57 | KOEditorDetails (int spacing = 8,QWidget* parent = 0, const char* name = 0); | 57 | KOEditorDetails (int spacing = 8,QWidget* parent = 0, const char* name = 0); |
58 | virtual ~KOEditorDetails(); | 58 | virtual ~KOEditorDetails(); |
59 | 59 | ||
60 | /** Set widgets to default values */ | 60 | /** Set widgets to default values */ |
61 | void setDefaults(); | 61 | void setDefaults(); |
62 | /** Read event object and setup widgets accordingly */ | 62 | /** Read event object and setup widgets accordingly */ |
63 | void readEvent(Incidence *); | 63 | void readEvent(Incidence *); |
64 | /** Write event settings to event object */ | 64 | /** Write event settings to event object */ |
65 | void writeEvent(Incidence *); | 65 | void writeEvent(Incidence *); |
66 | 66 | ||
67 | /** return a clone of the event with attendees to be canceld*/ | 67 | /** return a clone of the event with attendees to be canceld*/ |
68 | void cancelAttendeeEvent(Incidence *); | 68 | void cancelAttendeeEvent(Incidence *); |
69 | /** Check if the input is valid. */ | 69 | /** Check if the input is valid. */ |
70 | bool validateInput(); | 70 | bool validateInput(); |
71 | 71 | ||
72 | public slots: | 72 | public slots: |
73 | void insertAttendee(Attendee *); | 73 | void insertAttendee(Attendee *); |
74 | // called when the app recieves a list of name/email/uid (=addresses) from another app. Usually Ka/Pi | 74 | // called when the app recieves a list of name/email/uid (=addresses) from another app. Usually Ka/Pi |
75 | // The first parameter is a uniqueid. It can be used to identify if event | 75 | // The first parameter is a uniqueid. It can be used to identify if event |
76 | void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); | 76 | void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); |
77 | 77 | ||
78 | 78 | ||
79 | protected slots: | 79 | protected slots: |
80 | void addNewAttendee(); | 80 | void addNewAttendee(); |
81 | void removeAttendee(); | 81 | void removeAttendee(); |
82 | void openAddressBook(); | 82 | void openAddressBook(); |
83 | void updateAttendeeInput(); | 83 | void updateAttendeeInput(); |
84 | void clearAttendeeInput(); | 84 | void clearAttendeeInput(); |
85 | void fillAttendeeInput(AttendeeListItem *); | 85 | void fillAttendeeInput(AttendeeListItem *); |
86 | void itemClicked(QListViewItem *,const QPoint & pnt, int c); | ||
86 | void updateAttendeeItem(); | 87 | void updateAttendeeItem(); |
87 | void setEnabledAttendeeInput(bool); | 88 | void setEnabledAttendeeInput(bool); |
88 | 89 | ||
89 | private: | 90 | private: |
90 | bool mDisableItemUpdate; | 91 | bool mDisableItemUpdate; |
91 | 92 | ||
92 | QLineEdit *mNameEdit; | 93 | QLineEdit *mNameEdit; |
93 | QLineEdit *mUidEdit; | 94 | QLineEdit *mUidEdit; |
94 | QLineEdit *mEmailEdit; | 95 | QLineEdit *mEmailEdit; |
95 | KListView *mListView; | 96 | KListView *mListView; |
96 | QComboBox* mRoleCombo; | 97 | QComboBox* mRoleCombo; |
97 | QCheckBox* mRsvpButton; | 98 | QCheckBox* mRsvpButton; |
98 | QComboBox* mStatusCombo; | 99 | QComboBox* mStatusCombo; |
99 | QLabel *mOrganizerLabel; | 100 | QLabel *mOrganizerLabel; |
100 | 101 | ||
101 | QPushButton* mAddButton; | 102 | QPushButton* mAddButton; |
102 | QPushButton* mRemoveButton; | 103 | QPushButton* mRemoveButton; |
103 | QPushButton* mAddressBookButton; | 104 | QPushButton* mAddressBookButton; |
104 | 105 | ||
105 | QPtrList<Attendee> mdelAttendees; | 106 | QPtrList<Attendee> mdelAttendees; |
106 | }; | 107 | }; |
107 | 108 | ||
108 | #endif | 109 | #endif |
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 5de667e..2f0fa9e 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,595 +1,599 @@ | |||
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 <qcstring.h> | 20 | #include <qcstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <qwhatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 29 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 30 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <krun.h> | 33 | #include <krun.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <kprocess.h> | 35 | #include <kprocess.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | #include <kabc/stdaddressbook.h> | 38 | #include <kabc/stdaddressbook.h> |
39 | 39 | ||
40 | #ifndef KORG_NODCOP | 40 | #ifndef KORG_NODCOP |
41 | #include <dcopclient.h> | 41 | #include <dcopclient.h> |
42 | #include "korganizer.h" | 42 | #include "korganizer.h" |
43 | #include "koprefs.h" | 43 | #include "koprefs.h" |
44 | #include "actionmanager.h" | 44 | #include "actionmanager.h" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include "koeventviewer.h" | 47 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 48 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 49 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 50 | //#define size count |
51 | //#endif | 51 | //#endif |
52 | 52 | ||
53 | #ifdef DESKTOP_VERSION | 53 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 54 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 55 | #include <kabc/addresseeview.h> |
56 | #else //DESKTOP_VERSION | 56 | #else //DESKTOP_VERSION |
57 | #include <externalapphandler.h> | 57 | #include <externalapphandler.h> |
58 | #include <qtopia/qcopenvelope_qws.h> | 58 | #include <qtopia/qcopenvelope_qws.h> |
59 | #endif //DESKTOP_VERSION | 59 | #endif //DESKTOP_VERSION |
60 | 60 | ||
61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
62 | : QTextBrowser(parent,name) | 62 | : QTextBrowser(parent,name) |
63 | { | 63 | { |
64 | mSyncMode = false; | 64 | mSyncMode = false; |
65 | mColorMode = 0; | 65 | mColorMode = 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | KOEventViewer::~KOEventViewer() | 68 | KOEventViewer::~KOEventViewer() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void KOEventViewer::setSource(const QString& n) | 72 | void KOEventViewer::setSource(const QString& n) |
73 | { | 73 | { |
74 | 74 | ||
75 | if ( n.left(3) == "uid" ) | 75 | if ( n.left(3) == "uid" ) |
76 | #ifdef DESKTOP_VERSION | 76 | #ifdef DESKTOP_VERSION |
77 | { | 77 | { |
78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
79 | KABC::AddressBook::Iterator it; | 79 | KABC::AddressBook::Iterator it; |
80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
81 | // LR I do not understand, why the uid string is different on zaurus and desktop | 81 | // LR I do not understand, why the uid string is different on zaurus and desktop |
82 | QString uid = "uid://"+(*it).uid(); | 82 | QString uid = "uid://"+(*it).uid(); |
83 | 83 | ||
84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
85 | if (n == uid ) { | 85 | if (n == uid ) { |
86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
87 | QDialog dia( this,"dia123", true ); | 87 | QDialog dia( this,"dia123", true ); |
88 | dia.setCaption( i18n("Details of attendee") ); | 88 | dia.setCaption( i18n("Details of attendee") ); |
89 | QVBoxLayout lay ( &dia ); | 89 | QVBoxLayout lay ( &dia ); |
90 | KABC::AddresseeView av ( &dia ); | 90 | KABC::AddresseeView av ( &dia ); |
91 | av.setAddressee( (*it) ); | 91 | av.setAddressee( (*it) ); |
92 | lay.addWidget( &av ); | 92 | lay.addWidget( &av ); |
93 | if ( QApplication::desktop()->width() < 480 ) | 93 | if ( QApplication::desktop()->width() < 480 ) |
94 | dia.resize( 220, 240); | 94 | dia.resize( 220, 240); |
95 | else { | 95 | else { |
96 | dia.resize( 400,400); | 96 | dia.resize( 400,400); |
97 | } | 97 | } |
98 | dia.exec(); | 98 | dia.exec(); |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | #else | 104 | #else |
105 | { | 105 | { |
106 | if ( "uid:organizer" == n ) { | 106 | if ( "uid:organizer" == n ) { |
107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
111 | if (attendees.count()) { | 111 | if (attendees.count()) { |
112 | Attendee *a; | 112 | Attendee *a; |
113 | for(a=attendees.first();a;a=attendees.next()) { | 113 | for(a=attendees.first();a;a=attendees.next()) { |
114 | if ( "uid:"+a->uid() == n ) { | 114 | if ( "uid:"+a->uid() == n ) { |
115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
123 | // the result should now arrive through method insertAttendees | 123 | // the result should now arrive through method insertAttendees |
124 | //QString uid = "uid:"+(*it).uid(); | 124 | //QString uid = "uid:"+(*it).uid(); |
125 | #endif | 125 | #endif |
126 | if ( n.left(6) == "mailto" ) { | 126 | if ( n.left(6) == "mailto" ) { |
127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
128 | #ifndef DESKTOP_VERSION | 128 | #ifndef DESKTOP_VERSION |
129 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 129 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
130 | e << n.mid(7); | 130 | e << n.mid(7); |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | #ifndef KORG_NODCOP | 136 | #ifndef KORG_NODCOP |
137 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 137 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
138 | QString tmpStr; | 138 | QString tmpStr; |
139 | if (n.startsWith("mailto:")) { | 139 | if (n.startsWith("mailto:")) { |
140 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 140 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
141 | //emit showIncidence(n); | 141 | //emit showIncidence(n); |
142 | return; | 142 | return; |
143 | } else if (n.startsWith("uid:")) { | 143 | } else if (n.startsWith("uid:")) { |
144 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 144 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
145 | const QByteArray noParamData; | 145 | const QByteArray noParamData; |
146 | const QByteArray paramData; | 146 | const QByteArray paramData; |
147 | QByteArray replyData; | 147 | QByteArray replyData; |
148 | QCString replyTypeStr; | 148 | QCString replyTypeStr; |
149 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 149 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
150 | bool foundAbbrowser = PING_ABBROWSER; | 150 | bool foundAbbrowser = PING_ABBROWSER; |
151 | 151 | ||
152 | if (foundAbbrowser) { | 152 | if (foundAbbrowser) { |
153 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 153 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
154 | //client->send("kaddressbook","KAddressBookIface", | 154 | //client->send("kaddressbook","KAddressBookIface", |
155 | QDataStream arg(paramData, IO_WriteOnly); | 155 | QDataStream arg(paramData, IO_WriteOnly); |
156 | arg << n.mid(6); | 156 | arg << n.mid(6); |
157 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 157 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
158 | return; | 158 | return; |
159 | } else { | 159 | } else { |
160 | /* | 160 | /* |
161 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 161 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
162 | We start it without its main interface | 162 | We start it without its main interface |
163 | */ | 163 | */ |
164 | KIconLoader* iconLoader = new KIconLoader(); | 164 | KIconLoader* iconLoader = new KIconLoader(); |
165 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 165 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
166 | ActionManager::setStartedKAddressBook(true); | 166 | ActionManager::setStartedKAddressBook(true); |
167 | tmpStr = "kaddressbook --editor-only --uid "; | 167 | tmpStr = "kaddressbook --editor-only --uid "; |
168 | tmpStr += KProcess::quote(n.mid(6)); | 168 | tmpStr += KProcess::quote(n.mid(6)); |
169 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 169 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | } else { | 172 | } else { |
173 | //QTextBrowser::setSource(n); | 173 | //QTextBrowser::setSource(n); |
174 | } | 174 | } |
175 | #endif | 175 | #endif |
176 | } | 176 | } |
177 | 177 | ||
178 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 178 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
179 | { | 179 | { |
180 | int number=text.contains("\n"); | 180 | int number=text.contains("\n"); |
181 | QString str = "<" + tag + ">"; | 181 | QString str = "<" + tag + ">"; |
182 | QString tmpText=text; | 182 | QString tmpText=text; |
183 | QString tmpStr=str; | 183 | QString tmpStr=str; |
184 | if(number !=-1) | 184 | if(number !=-1) |
185 | { | 185 | { |
186 | if (number > 0) { | 186 | if (number > 0) { |
187 | int pos=0; | 187 | int pos=0; |
188 | QString tmp; | 188 | QString tmp; |
189 | for(int i=0;i<=number;i++) { | 189 | for(int i=0;i<=number;i++) { |
190 | pos=tmpText.find("\n"); | 190 | pos=tmpText.find("\n"); |
191 | tmp=tmpText.left(pos); | 191 | tmp=tmpText.left(pos); |
192 | tmpText=tmpText.right(tmpText.length()-pos-1); | 192 | tmpText=tmpText.right(tmpText.length()-pos-1); |
193 | tmpStr+=tmp+"<br>"; | 193 | tmpStr+=tmp+"<br>"; |
194 | } | 194 | } |
195 | } | 195 | } |
196 | else tmpStr += tmpText; | 196 | else tmpStr += tmpText; |
197 | tmpStr+="</" + tag + ">"; | 197 | tmpStr+="</" + tag + ">"; |
198 | mText.append(tmpStr); | 198 | mText.append(tmpStr); |
199 | } | 199 | } |
200 | else | 200 | else |
201 | { | 201 | { |
202 | str += text + "</" + tag + ">"; | 202 | str += text + "</" + tag + ">"; |
203 | mText.append(str); | 203 | mText.append(str); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | void KOEventViewer::setColorMode( int m ) | 207 | void KOEventViewer::setColorMode( int m ) |
208 | { | 208 | { |
209 | mColorMode = m; | 209 | mColorMode = m; |
210 | } | 210 | } |
211 | void KOEventViewer::appendEvent(Event *event, int mode ) | 211 | void KOEventViewer::appendEvent(Event *event, int mode ) |
212 | { | 212 | { |
213 | mMailSubject = ""; | 213 | mMailSubject = ""; |
214 | mCurrentIncidence = event; | 214 | mCurrentIncidence = event; |
215 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 215 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
216 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 216 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
217 | if ( mode == 0 ) { | 217 | if ( mode == 0 ) { |
218 | addTag("h2",event->summary()); | 218 | addTag("h2",event->summary()); |
219 | } | 219 | } |
220 | else { | 220 | else { |
221 | if ( mColorMode == 1 ) { | 221 | if ( mColorMode == 1 ) { |
222 | mText +="<font color=\"#00A000\">"; | 222 | mText +="<font color=\"#00A000\">"; |
223 | } | 223 | } |
224 | if ( mColorMode == 2 ) { | 224 | if ( mColorMode == 2 ) { |
225 | mText +="<font color=\"#C00000\">"; | 225 | mText +="<font color=\"#C00000\">"; |
226 | } | 226 | } |
227 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 227 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
228 | if ( mode == 1 ) { | 228 | if ( mode == 1 ) { |
229 | addTag("h2",i18n( "Local: " ) +event->summary()); | 229 | addTag("h2",i18n( "Local: " ) +event->summary()); |
230 | } else { | 230 | } else { |
231 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 231 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
232 | } | 232 | } |
233 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 233 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
234 | if ( mColorMode ) | 234 | if ( mColorMode ) |
235 | mText += "</font>"; | 235 | mText += "</font>"; |
236 | } | 236 | } |
237 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 237 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
238 | if (event->cancelled ()) { | 238 | if (event->cancelled ()) { |
239 | mText +="<font color=\"#B00000\">"; | 239 | mText +="<font color=\"#B00000\">"; |
240 | addTag("i",i18n("This event has been cancelled!")); | 240 | addTag("i",i18n("This event has been cancelled!")); |
241 | mText.append("<br>"); | 241 | mText.append("<br>"); |
242 | mText += "</font>"; | 242 | mText += "</font>"; |
243 | mMailSubject += i18n("(cancelled)"); | 243 | mMailSubject += i18n("(cancelled)"); |
244 | } | 244 | } |
245 | if (!event->location().isEmpty()) { | 245 | if (!event->location().isEmpty()) { |
246 | addTag("b",i18n("Location: ")); | 246 | addTag("b",i18n("Location: ")); |
247 | mText.append(event->location()+"<br>"); | 247 | mText.append(event->location()+"<br>"); |
248 | mMailSubject += i18n(" at ") + event->location(); | 248 | mMailSubject += i18n(" at ") + event->location(); |
249 | } | 249 | } |
250 | if (event->doesFloat()) { | 250 | if (event->doesFloat()) { |
251 | if (event->isMultiDay()) { | 251 | if (event->isMultiDay()) { |
252 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 252 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
253 | .arg(event->dtStartDateStr(shortDate)) | 253 | .arg(event->dtStartDateStr(shortDate)) |
254 | .arg(event->dtEndDateStr(shortDate))); | 254 | .arg(event->dtEndDateStr(shortDate))); |
255 | } else { | 255 | } else { |
256 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 256 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
257 | } | 257 | } |
258 | } else { | 258 | } else { |
259 | if (event->isMultiDay()) { | 259 | if (event->isMultiDay()) { |
260 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 260 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
261 | .arg(event->dtStartStr( shortDate))); | 261 | .arg(event->dtStartStr( shortDate))); |
262 | mText.append(i18n("<p><b>To:</b> %1</p>") | 262 | mText.append(i18n("<p><b>To:</b> %1</p>") |
263 | .arg(event->dtEndStr(shortDate))); | 263 | .arg(event->dtEndStr(shortDate))); |
264 | } else { | 264 | } else { |
265 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 265 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
266 | .arg(event->dtStartDateStr( shortDate ))); | 266 | .arg(event->dtStartDateStr( shortDate ))); |
267 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 267 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
268 | .arg(event->dtStartTimeStr()) | 268 | .arg(event->dtStartTimeStr()) |
269 | .arg(event->dtEndTimeStr())); | 269 | .arg(event->dtEndTimeStr())); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | if (event->recurrence()->doesRecur()) { | 273 | if (event->recurrence()->doesRecur()) { |
274 | 274 | ||
275 | QString recurText = event->recurrence()->recurrenceText(); | 275 | QString recurText = event->recurrence()->recurrenceText(); |
276 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 276 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
277 | bool last; | 277 | bool last; |
278 | QDate start = QDate::currentDate(); | 278 | QDate start = QDate::currentDate(); |
279 | QDate next; | 279 | QDate next; |
280 | next = event->recurrence()->getPreviousDate( start , &last ); | 280 | next = event->recurrence()->getPreviousDate( start , &last ); |
281 | if ( !last ) { | 281 | if ( !last ) { |
282 | next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); | 282 | next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); |
283 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 283 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
284 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); | 284 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); |
285 | QDateTime nextdt = QDateTime( next, event->dtStart().time()); | 285 | QDateTime nextdt = QDateTime( next, event->dtStart().time()); |
286 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); | 286 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); |
287 | 287 | ||
288 | } else { | 288 | } else { |
289 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 289 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
290 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); | 290 | addTag("p", KGlobal::locale()->formatDate( next, shortDate )); |
291 | } | 291 | } |
292 | } else { | 292 | } else { |
293 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 293 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
294 | 294 | ||
295 | } | 295 | } |
296 | 296 | ||
297 | 297 | ||
298 | if (event->isAlarmEnabled()) { | 298 | if (event->isAlarmEnabled()) { |
299 | Alarm *alarm =event->alarms().first() ; | 299 | Alarm *alarm =event->alarms().first() ; |
300 | QDateTime t = alarm->time(); | 300 | QDateTime t = alarm->time(); |
301 | int min = t.secsTo( event->dtStart() )/60; | 301 | int min = t.secsTo( event->dtStart() )/60; |
302 | QString s =i18n("( %1 min before )").arg( min ); | 302 | QString s =i18n("( %1 min before )").arg( min ); |
303 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 303 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
304 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 304 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
305 | //addTag("p",s); | 305 | //addTag("p",s); |
306 | } | 306 | } |
307 | 307 | ||
308 | addTag("b",i18n("Access: ")); | 308 | addTag("b",i18n("Access: ")); |
309 | mText.append(event->secrecyStr()+"<br>"); | 309 | mText.append(event->secrecyStr()+"<br>"); |
310 | if (!event->description().isEmpty()) { | 310 | if (!event->description().isEmpty()) { |
311 | addTag("p",i18n("<b>Details: </b>")); | 311 | addTag("p",i18n("<b>Details: </b>")); |
312 | addTag("p",event->description()); | 312 | addTag("p",event->description()); |
313 | } | 313 | } |
314 | 314 | ||
315 | formatCategories(event); | 315 | formatCategories(event); |
316 | 316 | ||
317 | formatReadOnly(event); | 317 | formatReadOnly(event); |
318 | formatAttendees(event); | 318 | formatAttendees(event); |
319 | 319 | ||
320 | setText(mText); | 320 | setText(mText); |
321 | //QWhatsThis::add(this,mText); | 321 | //QWhatsThis::add(this,mText); |
322 | 322 | ||
323 | } | 323 | } |
324 | 324 | ||
325 | void KOEventViewer::appendTodo(Todo *event, int mode ) | 325 | void KOEventViewer::appendTodo(Todo *event, int mode ) |
326 | { | 326 | { |
327 | mMailSubject = ""; | 327 | mMailSubject = ""; |
328 | mCurrentIncidence = event; | 328 | mCurrentIncidence = event; |
329 | topLevelWidget()->setCaption(i18n("Todo Viewer")); | 329 | topLevelWidget()->setCaption(i18n("Todo Viewer")); |
330 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 330 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
331 | if (mode == 0 ) | 331 | if (mode == 0 ) |
332 | addTag("h2",event->summary()); | 332 | addTag("h2",event->summary()); |
333 | else { | 333 | else { |
334 | if ( mColorMode == 1 ) { | 334 | if ( mColorMode == 1 ) { |
335 | mText +="<font color=\"#00A000\">"; | 335 | mText +="<font color=\"#00A000\">"; |
336 | } | 336 | } |
337 | if ( mColorMode == 2 ) { | 337 | if ( mColorMode == 2 ) { |
338 | mText +="<font color=\"#B00000\">"; | 338 | mText +="<font color=\"#B00000\">"; |
339 | } | 339 | } |
340 | if ( mode == 1 ) { | 340 | if ( mode == 1 ) { |
341 | addTag("h2",i18n( "Local: " ) +event->summary()); | 341 | addTag("h2",i18n( "Local: " ) +event->summary()); |
342 | } else { | 342 | } else { |
343 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 343 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
344 | } | 344 | } |
345 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 345 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
346 | if ( mColorMode ) | 346 | if ( mColorMode ) |
347 | mText += "</font>"; | 347 | mText += "</font>"; |
348 | } | 348 | } |
349 | mMailSubject += i18n( "Todo " )+ event->summary(); | 349 | mMailSubject += i18n( "Todo " )+ event->summary(); |
350 | if (event->cancelled ()) { | 350 | if (event->cancelled ()) { |
351 | mText +="<font color=\"#B00000\">"; | 351 | mText +="<font color=\"#B00000\">"; |
352 | addTag("i",i18n("This todo has been cancelled!")); | 352 | addTag("i",i18n("This todo has been cancelled!")); |
353 | mText.append("<br>"); | 353 | mText.append("<br>"); |
354 | mText += "</font>"; | 354 | mText += "</font>"; |
355 | mMailSubject += i18n("(cancelled)"); | 355 | mMailSubject += i18n("(cancelled)"); |
356 | } | 356 | } |
357 | 357 | ||
358 | if (!event->location().isEmpty()) { | 358 | if (!event->location().isEmpty()) { |
359 | addTag("b",i18n("Location: ")); | 359 | addTag("b",i18n("Location: ")); |
360 | mText.append(event->location()+"<br>"); | 360 | mText.append(event->location()+"<br>"); |
361 | mMailSubject += i18n(" at ") + event->location(); | 361 | mMailSubject += i18n(" at ") + event->location(); |
362 | } | 362 | } |
363 | if (event->hasStartDate()) { | 363 | if (event->hasStartDate()) { |
364 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); | 364 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); |
365 | } | 365 | } |
366 | if (event->hasDueDate()) { | 366 | if (event->hasDueDate()) { |
367 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); | 367 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); |
368 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 368 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
369 | } | 369 | } |
370 | addTag("b",i18n("Access: ")); | 370 | addTag("b",i18n("Access: ")); |
371 | mText.append(event->secrecyStr()+"<br>"); | 371 | mText.append(event->secrecyStr()+"<br>"); |
372 | if (!event->description().isEmpty()) { | 372 | if (!event->description().isEmpty()) { |
373 | addTag("p",i18n("<b>Details: </b>")); | 373 | addTag("p",i18n("<b>Details: </b>")); |
374 | addTag("p",event->description()); | 374 | addTag("p",event->description()); |
375 | } | 375 | } |
376 | 376 | ||
377 | formatCategories(event); | 377 | formatCategories(event); |
378 | 378 | ||
379 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 379 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
380 | .arg(QString::number(event->priority()))); | 380 | .arg(QString::number(event->priority()))); |
381 | 381 | ||
382 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 382 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
383 | .arg(event->percentComplete())); | 383 | .arg(event->percentComplete())); |
384 | 384 | ||
385 | formatReadOnly(event); | 385 | formatReadOnly(event); |
386 | formatAttendees(event); | 386 | formatAttendees(event); |
387 | if ( event->relatedTo() ) { | 387 | if ( event->relatedTo() ) { |
388 | addTag("b",i18n("Parent todo: ")); | 388 | addTag("b",i18n("Parent todo: ")); |
389 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); | 389 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); |
390 | } | 390 | } |
391 | QPtrList<Incidence> Relations = event->relations(); | 391 | QPtrList<Incidence> Relations = event->relations(); |
392 | Incidence *to; | 392 | Incidence *to; |
393 | if ( Relations.first() ) | 393 | if ( Relations.first() ) |
394 | addTag("b",i18n("Sub todos:<br>")); | 394 | addTag("b",i18n("Sub todos:<br>")); |
395 | for (to=Relations.first();to;to=Relations.next()) { | 395 | for (to=Relations.first();to;to=Relations.next()) { |
396 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); | 396 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); |
397 | 397 | ||
398 | } | 398 | } |
399 | setText(mText); | 399 | setText(mText); |
400 | } | 400 | } |
401 | 401 | ||
402 | void KOEventViewer::formatCategories(Incidence *event) | 402 | void KOEventViewer::formatCategories(Incidence *event) |
403 | { | 403 | { |
404 | if (!event->categoriesStr().isEmpty()) { | 404 | if (!event->categoriesStr().isEmpty()) { |
405 | if (event->categories().count() == 1) { | 405 | if (event->categories().count() == 1) { |
406 | addTag("h3",i18n("Category")); | 406 | addTag("h3",i18n("Category")); |
407 | } else { | 407 | } else { |
408 | addTag("h3",i18n("Categories")); | 408 | addTag("h3",i18n("Categories")); |
409 | } | 409 | } |
410 | addTag("p",event->categoriesStr()); | 410 | addTag("p",event->categoriesStr()); |
411 | } | 411 | } |
412 | } | 412 | } |
413 | void KOEventViewer::formatAttendees(Incidence *event) | 413 | void KOEventViewer::formatAttendees(Incidence *event) |
414 | { | 414 | { |
415 | QPtrList<Attendee> attendees = event->attendees(); | 415 | QPtrList<Attendee> attendees = event->attendees(); |
416 | if (attendees.count()) { | 416 | if (attendees.count()) { |
417 | 417 | ||
418 | 418 | ||
419 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 419 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
420 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | ||
420 | addTag("h3",i18n("Organizer")); | 421 | addTag("h3",i18n("Organizer")); |
421 | mText.append("<ul><li>"); | 422 | mText.append("<ul><li>"); |
422 | #ifndef KORG_NOKABC | 423 | #ifndef KORG_NOKABC |
423 | 424 | ||
424 | #ifdef DESKTOP_VERSION | 425 | #ifdef DESKTOP_VERSION |
425 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 426 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
426 | KABC::Addressee::List addressList; | 427 | KABC::Addressee::List addressList; |
427 | addressList = add_book->findByEmail(event->organizer()); | 428 | addressList = add_book->findByEmail(event->organizer()); |
428 | KABC::Addressee o = addressList.first(); | 429 | KABC::Addressee o = addressList.first(); |
429 | if (!o.isEmpty() && addressList.size()<2) { | 430 | if (!o.isEmpty() && addressList.size()<2) { |
430 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 431 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
431 | mText += o.formattedName(); | 432 | mText += o.formattedName(); |
432 | mText += "</a>\n"; | 433 | mText += "</a>\n"; |
433 | } else { | 434 | } else { |
434 | mText.append(event->organizer()); | 435 | mText.append(event->organizer()); |
435 | } | 436 | } |
436 | #else //DESKTOP_VERSION | 437 | #else //DESKTOP_VERSION |
437 | mText += "<a href=\"uid:organizer\">"; | 438 | mText += "<a href=\"uid:organizer\">"; |
438 | mText += event->organizer(); | 439 | mText += event->organizer(); |
439 | mText += "</a>\n"; | 440 | mText += "</a>\n"; |
440 | #endif //DESKTOP_VERSION | 441 | #endif //DESKTOP_VERSION |
441 | 442 | ||
442 | 443 | ||
443 | #else | 444 | #else |
444 | mText.append(event->organizer()); | 445 | mText.append(event->organizer()); |
445 | #endif | 446 | #endif |
446 | 447 | ||
447 | if (iconPath) { | 448 | if (iconPath) { |
448 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 449 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
449 | mText += "<IMG src=\"" + iconPath + "\">"; | 450 | mText += "<IMG src=\"" + iconPath + "\">"; |
450 | mText += "</a>\n"; | 451 | mText += "</a>\n"; |
451 | } | 452 | } |
452 | mText.append("</li></ul>"); | 453 | mText.append("</li></ul>"); |
453 | 454 | ||
454 | addTag("h3",i18n("Attendees")); | 455 | addTag("h3",i18n("Attendees")); |
455 | Attendee *a; | 456 | Attendee *a; |
456 | mText.append("<ul>"); | 457 | mText.append("<ul>"); |
457 | for(a=attendees.first();a;a=attendees.next()) { | 458 | for(a=attendees.first();a;a=attendees.next()) { |
458 | #ifndef KORG_NOKABC | 459 | #ifndef KORG_NOKABC |
459 | #ifdef DESKTOP_VERSION | 460 | #ifdef DESKTOP_VERSION |
460 | if (a->name().isEmpty()) { | 461 | if (a->name().isEmpty()) { |
461 | addressList = add_book->findByEmail(a->email()); | 462 | addressList = add_book->findByEmail(a->email()); |
462 | KABC::Addressee o = addressList.first(); | 463 | KABC::Addressee o = addressList.first(); |
463 | if (!o.isEmpty() && addressList.size()<2) { | 464 | if (!o.isEmpty() && addressList.size()<2) { |
464 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 465 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
465 | mText += o.formattedName(); | 466 | mText += o.formattedName(); |
466 | mText += "</a>\n"; | 467 | mText += "</a>\n"; |
467 | } else { | 468 | } else { |
468 | mText += "<li>"; | 469 | mText += "<li>"; |
469 | mText.append(a->email()); | 470 | mText.append(a->email()); |
470 | mText += "\n"; | 471 | mText += "\n"; |
471 | } | 472 | } |
472 | } else { | 473 | } else { |
473 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 474 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
474 | if (!a->name().isEmpty()) mText += a->name(); | 475 | if (!a->name().isEmpty()) mText += a->name(); |
475 | else mText += a->email(); | 476 | else mText += a->email(); |
476 | mText += "</a>\n"; | 477 | mText += "</a>\n"; |
477 | } | 478 | } |
478 | #else //DESKTOP_VERSION | 479 | #else //DESKTOP_VERSION |
479 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 480 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
480 | if (!a->name().isEmpty()) mText += a->name(); | 481 | if (!a->name().isEmpty()) mText += a->name(); |
481 | else mText += a->email(); | 482 | else mText += a->email(); |
482 | mText += "</a>\n"; | 483 | mText += "</a>\n"; |
483 | #endif //DESKTOP_VERSION | 484 | #endif //DESKTOP_VERSION |
484 | #else | 485 | #else |
485 | //qDebug("nokabc "); | 486 | //qDebug("nokabc "); |
486 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 487 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
487 | if (!a->name().isEmpty()) mText += a->name(); | 488 | if (!a->name().isEmpty()) mText += a->name(); |
488 | else mText += a->email(); | 489 | else mText += a->email(); |
489 | mText += "</a>\n"; | 490 | mText += "</a>\n"; |
490 | #endif | 491 | #endif |
491 | 492 | ||
492 | 493 | ||
493 | if (!a->email().isEmpty()) { | 494 | if (!a->email().isEmpty()) { |
494 | if (iconPath) { | 495 | if (iconPath) { |
495 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 496 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
496 | mText += "<IMG src=\"" + iconPath + "\">"; | 497 | if ( a->RSVP() ) |
498 | mText += "<IMG src=\"" + iconPath + "\">"; | ||
499 | else | ||
500 | mText += "<IMG src=\"" + NOiconPath + "\">"; | ||
497 | mText += "</a>\n"; | 501 | mText += "</a>\n"; |
498 | } | 502 | } |
499 | } | 503 | } |
500 | if (a->status() != Attendee::NeedsAction ) | 504 | if (a->status() != Attendee::NeedsAction ) |
501 | mText +="[" + a->statusStr() + "] "; | 505 | mText +="[" + a->statusStr() + "] "; |
502 | if (a->role() == Attendee::Chair ) | 506 | if (a->role() == Attendee::Chair ) |
503 | mText +="(" + a->roleStr().left(1) + ".)"; | 507 | mText +="(" + a->roleStr().left(1) + ".)"; |
504 | } | 508 | } |
505 | mText.append("</li></ul>"); | 509 | mText.append("</li></ul>"); |
506 | } | 510 | } |
507 | 511 | ||
508 | } | 512 | } |
509 | void KOEventViewer::appendJournal(Journal *jour, int mode ) | 513 | void KOEventViewer::appendJournal(Journal *jour, int mode ) |
510 | { | 514 | { |
511 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 515 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
512 | if (mode == 0 ) { | 516 | if (mode == 0 ) { |
513 | addTag("h2",i18n("Journal from: ")); | 517 | addTag("h2",i18n("Journal from: ")); |
514 | } | 518 | } |
515 | else { | 519 | else { |
516 | if ( mode == 1 ) { | 520 | if ( mode == 1 ) { |
517 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); | 521 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); |
518 | } else { | 522 | } else { |
519 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); | 523 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); |
520 | } | 524 | } |
521 | } | 525 | } |
522 | topLevelWidget()->setCaption("Journal Viewer"); | 526 | topLevelWidget()->setCaption("Journal Viewer"); |
523 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); | 527 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); |
524 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); | 528 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); |
525 | if (!jour->description().isEmpty()) { | 529 | if (!jour->description().isEmpty()) { |
526 | addTag("p",jour->description()); | 530 | addTag("p",jour->description()); |
527 | } | 531 | } |
528 | setText(mText); | 532 | setText(mText); |
529 | } | 533 | } |
530 | 534 | ||
531 | void KOEventViewer::formatReadOnly(Incidence *event) | 535 | void KOEventViewer::formatReadOnly(Incidence *event) |
532 | { | 536 | { |
533 | if (event->isReadOnly()) { | 537 | if (event->isReadOnly()) { |
534 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 538 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
535 | } | 539 | } |
536 | } | 540 | } |
537 | void KOEventViewer::setSyncMode( bool b ) | 541 | void KOEventViewer::setSyncMode( bool b ) |
538 | { | 542 | { |
539 | mSyncMode = b; | 543 | mSyncMode = b; |
540 | } | 544 | } |
541 | 545 | ||
542 | 546 | ||
543 | void KOEventViewer::setTodo(Todo *event, bool clearV ) | 547 | void KOEventViewer::setTodo(Todo *event, bool clearV ) |
544 | { | 548 | { |
545 | if ( clearV ) | 549 | if ( clearV ) |
546 | clearEvents(); | 550 | clearEvents(); |
547 | if ( mSyncMode ) { | 551 | if ( mSyncMode ) { |
548 | if ( clearV ) | 552 | if ( clearV ) |
549 | appendTodo(event,1 ); | 553 | appendTodo(event,1 ); |
550 | else | 554 | else |
551 | appendTodo(event,2); | 555 | appendTodo(event,2); |
552 | } else | 556 | } else |
553 | appendTodo(event); | 557 | appendTodo(event); |
554 | } | 558 | } |
555 | void KOEventViewer::setJournal(Journal *event, bool clearV ) | 559 | void KOEventViewer::setJournal(Journal *event, bool clearV ) |
556 | { | 560 | { |
557 | if ( clearV ) | 561 | if ( clearV ) |
558 | clearEvents(); | 562 | clearEvents(); |
559 | if ( mSyncMode ) { | 563 | if ( mSyncMode ) { |
560 | if ( clearV ) | 564 | if ( clearV ) |
561 | appendJournal(event, 1); | 565 | appendJournal(event, 1); |
562 | else | 566 | else |
563 | appendJournal(event, 2); | 567 | appendJournal(event, 2); |
564 | } else | 568 | } else |
565 | appendJournal(event); | 569 | appendJournal(event); |
566 | } | 570 | } |
567 | 571 | ||
568 | void KOEventViewer::setEvent(Event *event) | 572 | void KOEventViewer::setEvent(Event *event) |
569 | { | 573 | { |
570 | clearEvents(); | 574 | clearEvents(); |
571 | if ( mSyncMode ) | 575 | if ( mSyncMode ) |
572 | appendEvent(event, 1); | 576 | appendEvent(event, 1); |
573 | else | 577 | else |
574 | appendEvent(event); | 578 | appendEvent(event); |
575 | } | 579 | } |
576 | 580 | ||
577 | void KOEventViewer::addEvent(Event *event) | 581 | void KOEventViewer::addEvent(Event *event) |
578 | { | 582 | { |
579 | if ( mSyncMode ) | 583 | if ( mSyncMode ) |
580 | appendEvent(event, 2); | 584 | appendEvent(event, 2); |
581 | else | 585 | else |
582 | appendEvent(event); | 586 | appendEvent(event); |
583 | } | 587 | } |
584 | 588 | ||
585 | void KOEventViewer::clearEvents(bool now) | 589 | void KOEventViewer::clearEvents(bool now) |
586 | { | 590 | { |
587 | mText = ""; | 591 | mText = ""; |
588 | if (now) setText(mText); | 592 | if (now) setText(mText); |
589 | } | 593 | } |
590 | 594 | ||
591 | void KOEventViewer::addText(QString text) | 595 | void KOEventViewer::addText(QString text) |
592 | { | 596 | { |
593 | mText.append(text); | 597 | mText.append(text); |
594 | setText(mText); | 598 | setText(mText); |
595 | } | 599 | } |
diff --git a/libkcal/dndfactory.h b/libkcal/dndfactory.h index 7e2ca04..2df5259 100644 --- a/libkcal/dndfactory.h +++ b/libkcal/dndfactory.h | |||
@@ -1,74 +1,83 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 1998 Preston Brown | 4 | Copyright (c) 1998 Preston Brown |
5 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> | 5 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> |
6 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 6 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
7 | 7 | ||
8 | This library is free software; you can redistribute it and/or | 8 | This library is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU Library General Public | 9 | modify it under the terms of the GNU Library General Public |
10 | License as published by the Free Software Foundation; either | 10 | License as published by the Free Software Foundation; either |
11 | version 2 of the License, or (at your option) any later version. | 11 | version 2 of the License, or (at your option) any later version. |
12 | 12 | ||
13 | This library is distributed in the hope that it will be useful, | 13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifdef DESKTOP_VERSION | ||
25 | |||
24 | #ifndef KCAL_DNDFACTORY_H | 26 | #ifndef KCAL_DNDFACTORY_H |
25 | #define KCAL_DNDFACTORY_H | 27 | #define KCAL_DNDFACTORY_H |
26 | 28 | ||
27 | //#include "libkcal_export.h" | 29 | //#include "libkcal_export.h" |
28 | 30 | ||
29 | namespace KCal { | 31 | namespace KCal { |
30 | 32 | ||
31 | class ICalDrag; | 33 | class ICalDrag; |
32 | class Event; | 34 | class Event; |
33 | class Todo; | 35 | class Todo; |
34 | class Calendar; | 36 | class Calendar; |
35 | #define LIBKCAL_EXPORT | 37 | #define LIBKCAL_EXPORT |
36 | 38 | ||
37 | /** | 39 | /** |
38 | This class implements functions to create Drag and Drop objects used for | 40 | This class implements functions to create Drag and Drop objects used for |
39 | Drag-and-Drop and Copy-and-Paste. | 41 | Drag-and-Drop and Copy-and-Paste. |
40 | 42 | ||
41 | @short vCalendar/iCalendar Drag-and-Drop object factory. | 43 | @short vCalendar/iCalendar Drag-and-Drop object factory. |
42 | */ | 44 | */ |
43 | class LIBKCAL_EXPORT DndFactory | 45 | class LIBKCAL_EXPORT DndFactory |
44 | { | 46 | { |
45 | public: | 47 | public: |
46 | DndFactory( Calendar * ); | 48 | DndFactory( Calendar * ); |
47 | 49 | ||
48 | /** | 50 | /** |
49 | Create a drag object. | 51 | Create a drag object. |
50 | */ | 52 | */ |
51 | ICalDrag *createDrag( Incidence *incidence, QWidget *owner ); | 53 | ICalDrag *createDrag( Incidence *incidence, QWidget *owner ); |
52 | 54 | ||
53 | /** Create Todo object from drop event */ | 55 | /** Create Todo object from drop event */ |
54 | Todo *createDropTodo(QDropEvent *de); | 56 | Todo *createDropTodo(QDropEvent *de); |
55 | /** Create Event object from drop event */ | 57 | /** Create Event object from drop event */ |
56 | Event *createDrop(QDropEvent *de); | 58 | Event *createDrop(QDropEvent *de); |
57 | 59 | ||
58 | /** cut incidence to clipboard */ | 60 | /** cut incidence to clipboard */ |
59 | void cutIncidence( Incidence * ); | 61 | void cutIncidence( Incidence * ); |
60 | /** copy the incidence to clipboard */ | 62 | /** copy the incidence to clipboard */ |
61 | bool copyIncidence( Incidence * ); | 63 | bool copyIncidence( Incidence * ); |
62 | /** pastes the event or todo and returns a pointer to the new incidence pasted. */ | 64 | /** pastes the event or todo and returns a pointer to the new incidence pasted. */ |
63 | Incidence *pasteIncidence( const QDate &, const QTime *newTime = 0 ); | 65 | Incidence *pasteIncidence( const QDate &, const QTime *newTime = 0 ); |
64 | 66 | ||
65 | private: | 67 | private: |
66 | Calendar *mCalendar; | 68 | Calendar *mCalendar; |
67 | 69 | ||
68 | class Private; | 70 | class Private; |
69 | Private *d; | 71 | Private *d; |
70 | }; | 72 | }; |
71 | 73 | ||
72 | } | 74 | } |
73 | 75 | ||
74 | #endif | 76 | #endif |
77 | |||
78 | #else // dummy implementation for embedded | ||
79 | #include "dndfactory_dummy.h" | ||
80 | #define cutIncidence cutEvent | ||
81 | #define pasteIncidence pasteEvent | ||
82 | #define copyIncidence copyEvent | ||
83 | #endif | ||