author | zautrix <zautrix> | 2005-11-30 08:30:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-30 08:30:24 (UTC) |
commit | 042f35a481acf6c4e711e98184abb6c9f6542429 (patch) (unidiff) | |
tree | 47622f89ebfb6c677797d7906f167ba80976ab7d /korganizer/koeventeditor.cpp | |
parent | 14bd7cc7412ffdbca09e1cd63a230222a3fbfd53 (diff) | |
download | kdepimpi-042f35a481acf6c4e711e98184abb6c9f6542429.zip kdepimpi-042f35a481acf6c4e711e98184abb6c9f6542429.tar.gz kdepimpi-042f35a481acf6c4e711e98184abb6c9f6542429.tar.bz2 |
commit
Diffstat (limited to 'korganizer/koeventeditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeventeditor.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp index 9ede543..3e87197 100644 --- a/korganizer/koeventeditor.cpp +++ b/korganizer/koeventeditor.cpp | |||
@@ -1,384 +1,388 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 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 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qframe.h> | 25 | #include <qframe.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qhbox.h> | 27 | #include <qhbox.h> |
28 | #include <qtimer.h> | ||
28 | #include <qdir.h> | 29 | #include <qdir.h> |
29 | #include <qlayout.h> | 30 | #include <qlayout.h> |
30 | #include <qwidgetstack.h> | 31 | #include <qwidgetstack.h> |
31 | #include <qapplication.h> | 32 | #include <qapplication.h> |
32 | 33 | ||
33 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
34 | #include <kstandarddirs.h> | 35 | #include <kstandarddirs.h> |
35 | #include <kdebug.h> | 36 | #include <kdebug.h> |
36 | #include <klocale.h> | 37 | #include <klocale.h> |
37 | #include <kfiledialog.h> | 38 | #include <kfiledialog.h> |
38 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
39 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
40 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
41 | #include <kresources/resourceselectdialog.h> | 42 | #include <kresources/resourceselectdialog.h> |
42 | 43 | ||
43 | #include <libkdepim/categoryselectdialog.h> | 44 | #include <libkdepim/categoryselectdialog.h> |
44 | #include <libkcal/calendarlocal.h> | 45 | #include <libkcal/calendarlocal.h> |
45 | #include <libkcal/icalformat.h> | 46 | #include <libkcal/icalformat.h> |
46 | 47 | ||
47 | #include "koprefs.h" | 48 | #include "koprefs.h" |
48 | 49 | ||
49 | #include "koeventeditor.h" | 50 | #include "koeventeditor.h" |
50 | extern int globalFlagBlockAgenda; | 51 | extern int globalFlagBlockAgenda; |
51 | 52 | ||
52 | KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : | 53 | KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : |
53 | KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) | 54 | KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) |
54 | { | 55 | { |
55 | mEvent = 0; | 56 | mEvent = 0; |
56 | init(); | 57 | init(); |
57 | if ( QApplication::desktop()->height() <= 240 ) | 58 | if ( QApplication::desktop()->height() <= 240 ) |
58 | hideButtons(); | 59 | hideButtons(); |
59 | } | 60 | } |
60 | 61 | ||
61 | KOEventEditor::~KOEventEditor() | 62 | KOEventEditor::~KOEventEditor() |
62 | { | 63 | { |
63 | //emit dialogClose( mEvent ); | 64 | //emit dialogClose( mEvent ); |
64 | } | 65 | } |
65 | 66 | ||
66 | void KOEventEditor::init() | 67 | void KOEventEditor::init() |
67 | { | 68 | { |
68 | 69 | ||
69 | setupGeneral(); | 70 | setupGeneral(); |
70 | setupAttendeesTab(); | 71 | setupAttendeesTab(); |
71 | setupRecurrence(); | 72 | setupRecurrence(); |
72 | 73 | ||
73 | // Propagate date time settings to recurrence tab | 74 | // Propagate date time settings to recurrence tab |
74 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), | 75 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), |
75 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); | 76 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); |
76 | connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), | 77 | connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), |
77 | mRecurrence,SLOT(setDateTimeStr(const QString &))); | 78 | mRecurrence,SLOT(setDateTimeStr(const QString &))); |
78 | 79 | ||
79 | // Category dialog | 80 | // Category dialog |
80 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 81 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
81 | //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), | 82 | //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), |
82 | // mGeneral,SLOT(setCategories(const QString &))); | 83 | // mGeneral,SLOT(setCategories(const QString &))); |
83 | 84 | ||
84 | 85 | ||
85 | } | 86 | } |
86 | 87 | ||
87 | void KOEventEditor::reload() | 88 | void KOEventEditor::reload() |
88 | { | 89 | { |
89 | if ( mEvent ) readEvent( mEvent ); | 90 | if ( mEvent ) readEvent( mEvent ); |
90 | } | 91 | } |
91 | 92 | ||
92 | void KOEventEditor::setSecrecy( int sec ) | 93 | void KOEventEditor::setSecrecy( int sec ) |
93 | { | 94 | { |
94 | mGeneral->setSecrecy( sec ); | 95 | mGeneral->setSecrecy( sec ); |
95 | } | 96 | } |
96 | void KOEventEditor::setCategories( QString s ) | 97 | void KOEventEditor::setCategories( QString s ) |
97 | { | 98 | { |
98 | mGeneral->setCategories(s); | 99 | mGeneral->setCategories(s); |
99 | 100 | ||
100 | } | 101 | } |
101 | void KOEventEditor::setupGeneral() | 102 | void KOEventEditor::setupGeneral() |
102 | { | 103 | { |
103 | mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); | 104 | mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); |
104 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 105 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
105 | 106 | ||
106 | if( KOPrefs::instance()->mCompactDialogs ) { | 107 | if( KOPrefs::instance()->mCompactDialogs ) { |
107 | QFrame *topFrame = addPage(i18n("General")); | 108 | QFrame *topFrame = addPage(i18n("General")); |
108 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 109 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
109 | topLayout->setSpacing(spacingHint()-1); | 110 | topLayout->setSpacing(spacingHint()-1); |
110 | topLayout->setMargin(marginHint()-1); | 111 | topLayout->setMargin(marginHint()-1); |
111 | topLayout->addStretch ( 1 ); | 112 | topLayout->addStretch ( 1 ); |
112 | mGeneral->initHeader(topFrame,topLayout); | 113 | mGeneral->initHeader(topFrame,topLayout); |
113 | topLayout->addStretch ( 1 ); | 114 | topLayout->addStretch ( 1 ); |
114 | mGeneral->initTime(topFrame,topLayout); | 115 | mGeneral->initTime(topFrame,topLayout); |
115 | topLayout->addStretch ( 1 ); | 116 | topLayout->addStretch ( 1 ); |
116 | // QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 117 | // QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
117 | mGeneral->initAlarm(topFrame,topLayout); | 118 | mGeneral->initAlarm(topFrame,topLayout); |
118 | topLayout->addStretch ( 1 ); | 119 | topLayout->addStretch ( 1 ); |
119 | mGeneral->enableAlarm( false ); | 120 | mGeneral->enableAlarm( false ); |
120 | 121 | ||
121 | QBoxLayout *buttonLayout; | 122 | QBoxLayout *buttonLayout; |
122 | if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 ) | 123 | if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 ) |
123 | buttonLayout = new QVBoxLayout( topLayout ); | 124 | buttonLayout = new QVBoxLayout( topLayout ); |
124 | else | 125 | else |
125 | buttonLayout = new QHBoxLayout( topLayout ); | 126 | buttonLayout = new QHBoxLayout( topLayout ); |
126 | QHBox* buttonWidget = new QHBox (topFrame); | 127 | QHBox* buttonWidget = new QHBox (topFrame); |
127 | QIconSet icon; | 128 | QIconSet icon; |
128 | if ( QApplication::desktop()->width() < 321 ) | 129 | if ( QApplication::desktop()->width() < 321 ) |
129 | icon = SmallIcon("fileexport16"); | 130 | icon = SmallIcon("fileexport16"); |
130 | else | 131 | else |
131 | icon = SmallIcon("fileexport"); | 132 | icon = SmallIcon("fileexport"); |
132 | QPushButton * loadTemplate = new QPushButton( buttonWidget); | 133 | QPushButton * loadTemplate = new QPushButton( buttonWidget); |
133 | QPushButton * saveTemplate = new QPushButton( buttonWidget); | 134 | QPushButton * saveTemplate = new QPushButton( buttonWidget); |
134 | saveTemplate->setIconSet (icon ) ; | 135 | saveTemplate->setIconSet (icon ) ; |
135 | int size = saveTemplate->sizeHint().height(); | 136 | int size = saveTemplate->sizeHint().height(); |
136 | saveTemplate->setFixedSize( size, size ); | 137 | saveTemplate->setFixedSize( size, size ); |
137 | if ( QApplication::desktop()->width() < 321 ) | 138 | if ( QApplication::desktop()->width() < 321 ) |
138 | icon = SmallIcon("fileimport16"); | 139 | icon = SmallIcon("fileimport16"); |
139 | else | 140 | else |
140 | icon = SmallIcon("fileimport"); | 141 | icon = SmallIcon("fileimport"); |
141 | loadTemplate->setIconSet (icon ) ; | 142 | loadTemplate->setIconSet (icon ) ; |
142 | loadTemplate->setFixedSize( size, size ); | 143 | loadTemplate->setFixedSize( size, size ); |
143 | buttonLayout->addWidget( buttonWidget ); | 144 | buttonLayout->addWidget( buttonWidget ); |
144 | mGeneral->initCategories( topFrame, buttonLayout ); | 145 | mGeneral->initCategories( topFrame, buttonLayout ); |
145 | 146 | ||
146 | topLayout->addStretch( 1 ); | 147 | topLayout->addStretch( 1 ); |
147 | 148 | ||
148 | QFrame *topFrame2 = addPage(i18n("Details")); | 149 | QFrame *topFrame2 = addPage(i18n("Details")); |
149 | 150 | ||
150 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 151 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
151 | topLayout2->setSpacing(spacingHint()-1); | 152 | topLayout2->setSpacing(spacingHint()-1); |
152 | topLayout2->setMargin(marginHint()-1); | 153 | topLayout2->setMargin(marginHint()-1); |
153 | topLayout2->setSpacing(spacingHint()); | 154 | topLayout2->setSpacing(spacingHint()); |
154 | 155 | ||
155 | mGeneral->initClass(topFrame2,topLayout2); | 156 | mGeneral->initClass(topFrame2,topLayout2); |
156 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 157 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
157 | mGeneral->initDescription(topFrame2,topLayout2); | 158 | mGeneral->initDescription(topFrame2,topLayout2); |
158 | 159 | ||
159 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 160 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
160 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 161 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
161 | } else { | 162 | } else { |
162 | QFrame *topFrame = addPage(i18n("General")); | 163 | QFrame *topFrame = addPage(i18n("General")); |
163 | 164 | ||
164 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 165 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
165 | topLayout->setSpacing(spacingHint()); | 166 | topLayout->setSpacing(spacingHint()); |
166 | 167 | ||
167 | mGeneral->initHeader(topFrame,topLayout); | 168 | mGeneral->initHeader(topFrame,topLayout); |
168 | mGeneral->initTime(topFrame,topLayout); | 169 | mGeneral->initTime(topFrame,topLayout); |
169 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 170 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
170 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 171 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
171 | mGeneral->initClass(topFrame,alarmLineLayout); | 172 | mGeneral->initClass(topFrame,alarmLineLayout); |
172 | mGeneral->initDescription(topFrame,topLayout); | 173 | mGeneral->initDescription(topFrame,topLayout); |
173 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 174 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
174 | mGeneral->initCategories( topFrame, detailsLayout ); | 175 | mGeneral->initCategories( topFrame, detailsLayout ); |
175 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 176 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
176 | } | 177 | } |
177 | 178 | ||
178 | mGeneral->finishSetup(); | 179 | mGeneral->finishSetup(); |
179 | 180 | ||
180 | } | 181 | } |
181 | 182 | ||
182 | void KOEventEditor::setupRecurrence() | 183 | void KOEventEditor::setupRecurrence() |
183 | { | 184 | { |
184 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 185 | QFrame *topFrame = addPage( i18n("Recurrence") ); |
185 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 186 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
186 | 187 | ||
187 | mRecurrence = new KOEditorRecurrence( topFrame ); | 188 | mRecurrence = new KOEditorRecurrence( topFrame ); |
188 | topLayout->addWidget( mRecurrence ); | 189 | topLayout->addWidget( mRecurrence ); |
189 | } | 190 | } |
190 | 191 | ||
191 | void KOEventEditor::editEvent(Event *event, bool showDescription) | 192 | void KOEventEditor::editEvent(Event *event, bool showDescription) |
192 | { | 193 | { |
193 | // init(); | 194 | // init(); |
194 | 195 | ||
195 | mEvent = event; | 196 | mEvent = event; |
196 | readEvent(mEvent); | 197 | readEvent(mEvent); |
197 | if ( showDescription ) { | 198 | if ( showDescription ) { |
198 | showPage( 1 ); | 199 | showPage( 1 ); |
199 | mGeneral->setFocusOn( 1 ); | 200 | mGeneral->setFocusOn( 1 ); |
200 | } else { | 201 | } else { |
201 | showPage( 0 ); | 202 | showPage( 0 ); |
202 | mGeneral->setFocusOn( 2 ); | 203 | mGeneral->setFocusOn( 2 ); |
203 | } | 204 | } |
204 | } | 205 | } |
205 | 206 | ||
206 | void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) | 207 | void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) |
207 | { | 208 | { |
208 | // init(); | 209 | // init(); |
209 | 210 | ||
210 | mEvent = 0; | 211 | mEvent = 0; |
211 | setDefaults(from,to,allDay); | 212 | setDefaults(from,to,allDay); |
212 | } | 213 | } |
213 | 214 | ||
214 | void KOEventEditor::loadDefaults() | 215 | void KOEventEditor::loadDefaults() |
215 | { | 216 | { |
216 | int fmt = KOPrefs::instance()->mStartTime; | 217 | int fmt = KOPrefs::instance()->mStartTime; |
217 | 218 | ||
218 | QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); | 219 | QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); |
219 | QDateTime to(QDate::currentDate(), | 220 | QDateTime to(QDate::currentDate(), |
220 | QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); | 221 | QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); |
221 | 222 | ||
222 | setDefaults(from,to,false); | 223 | setDefaults(from,to,false); |
223 | } | 224 | } |
224 | 225 | ||
225 | bool KOEventEditor::processInput( bool emitTime ) | 226 | bool KOEventEditor::processInput( bool emitTime ) |
226 | { | 227 | { |
227 | if (!validateInput()) return false; | 228 | if (!validateInput()) return false; |
228 | 229 | ||
229 | Event *event = 0; | 230 | Event *event = 0; |
230 | 231 | ||
231 | if (mEvent) event = mEvent; | 232 | if (mEvent) event = mEvent; |
232 | else { | 233 | else { |
233 | event = new Event; | 234 | event = new Event; |
234 | event->setOrganizer(KOPrefs::instance()->email()); | 235 | event->setOrganizer(KOPrefs::instance()->email()); |
235 | } | 236 | } |
236 | 237 | ||
237 | writeEvent(event); | 238 | writeEvent(event); |
238 | if ( emitTime ) { | 239 | if ( emitTime ) { |
239 | globalFlagBlockAgenda = 1; | 240 | globalFlagBlockAgenda = 1; |
240 | emit showAgendaView( false ); | 241 | emit showAgendaView( false ); |
241 | emit jumpToTime( event->dtStart().date() ); | 242 | emit jumpToTime( event->dtStart().date() ); |
242 | globalFlagBlockAgenda = 2; | 243 | globalFlagBlockAgenda = 2; |
243 | 244 | ||
244 | } | 245 | } |
245 | if (mEvent) { | 246 | if (mEvent) { |
246 | event->setRevision(event->revision()+1); | 247 | event->setRevision(event->revision()+1); |
247 | emit eventChanged(event); | 248 | emit eventChanged(event); |
248 | } else { | 249 | } else { |
249 | mCalendar->addEvent(event); | 250 | mCalendar->addEvent(event); |
250 | mEvent = event; | 251 | mEvent = event; |
251 | emit eventAdded(event); | 252 | emit eventAdded(event); |
253 | if ( event->isAlarmEnabled () && !event->alarmEnabled () ) { | ||
254 | QTimer::singleShot( 0, this, SLOT ( alarmWarning() ) ); | ||
255 | } | ||
252 | } | 256 | } |
253 | 257 | ||
254 | return true; | 258 | return true; |
255 | } | 259 | } |
256 | 260 | ||
257 | void KOEventEditor::deleteEvent() | 261 | void KOEventEditor::deleteEvent() |
258 | { | 262 | { |
259 | kdDebug() << "Delete event" << endl; | 263 | kdDebug() << "Delete event" << endl; |
260 | 264 | ||
261 | if (mEvent) { | 265 | if (mEvent) { |
262 | if (KOPrefs::instance()->mConfirm) { | 266 | if (KOPrefs::instance()->mConfirm) { |
263 | switch (msgItemDelete()) { | 267 | switch (msgItemDelete()) { |
264 | case KMessageBox::Continue: // OK | 268 | case KMessageBox::Continue: // OK |
265 | emit eventToBeDeleted(mEvent); | 269 | emit eventToBeDeleted(mEvent); |
266 | emit dialogClose(mEvent); | 270 | emit dialogClose(mEvent); |
267 | mCalendar->deleteEvent(mEvent); | 271 | mCalendar->deleteEvent(mEvent); |
268 | emit eventDeleted(); | 272 | emit eventDeleted(); |
269 | reject(); | 273 | reject(); |
270 | break; | 274 | break; |
271 | } | 275 | } |
272 | } | 276 | } |
273 | else { | 277 | else { |
274 | emit eventToBeDeleted(mEvent); | 278 | emit eventToBeDeleted(mEvent); |
275 | emit dialogClose(mEvent); | 279 | emit dialogClose(mEvent); |
276 | mCalendar->deleteEvent(mEvent); | 280 | mCalendar->deleteEvent(mEvent); |
277 | emit eventDeleted(); | 281 | emit eventDeleted(); |
278 | reject(); | 282 | reject(); |
279 | } | 283 | } |
280 | } else { | 284 | } else { |
281 | reject(); | 285 | reject(); |
282 | } | 286 | } |
283 | } | 287 | } |
284 | 288 | ||
285 | void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) | 289 | void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) |
286 | { | 290 | { |
287 | mGeneral->setDefaults(from,to,allDay); | 291 | mGeneral->setDefaults(from,to,allDay); |
288 | mDetails->setDefaults(); | 292 | mDetails->setDefaults(); |
289 | mRecurrence->setDefaults(from,to); | 293 | mRecurrence->setDefaults(from,to); |
290 | showPage( 0 ); | 294 | showPage( 0 ); |
291 | mGeneral->setFocusOn( 2 ); | 295 | mGeneral->setFocusOn( 2 ); |
292 | } | 296 | } |
293 | 297 | ||
294 | void KOEventEditor::readEvent( Event *event, bool tmpl ) | 298 | void KOEventEditor::readEvent( Event *event, bool tmpl ) |
295 | { | 299 | { |
296 | mGeneral->readEvent( event, tmpl ); | 300 | mGeneral->readEvent( event, tmpl ); |
297 | mDetails->readEvent( event ); | 301 | mDetails->readEvent( event ); |
298 | mRecurrence->readEvent( event ); | 302 | mRecurrence->readEvent( event ); |
299 | 303 | ||
300 | // categories | 304 | // categories |
301 | //mCategoryDialog->setSelected( event->categories() ); | 305 | //mCategoryDialog->setSelected( event->categories() ); |
302 | } | 306 | } |
303 | 307 | ||
304 | void KOEventEditor::writeEvent(Event *event) | 308 | void KOEventEditor::writeEvent(Event *event) |
305 | { | 309 | { |
306 | mGeneral->writeEvent( event ); | 310 | mGeneral->writeEvent( event ); |
307 | mDetails->writeEvent( event ); | 311 | mDetails->writeEvent( event ); |
308 | 312 | ||
309 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 313 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
310 | Event *ev = new Event( *event ); | 314 | Event *ev = new Event( *event ); |
311 | ev->registerObserver(0); | 315 | ev->registerObserver(0); |
312 | mDetails->cancelAttendeeEvent( ev ); | 316 | mDetails->cancelAttendeeEvent( ev ); |
313 | if ( ev->attendeeCount() > 0 ) { | 317 | if ( ev->attendeeCount() > 0 ) { |
314 | emit deleteAttendee( ev ); | 318 | emit deleteAttendee( ev ); |
315 | } | 319 | } |
316 | delete(ev); | 320 | delete(ev); |
317 | } | 321 | } |
318 | 322 | ||
319 | mRecurrence->writeEvent(event); | 323 | mRecurrence->writeEvent(event); |
320 | } | 324 | } |
321 | 325 | ||
322 | bool KOEventEditor::validateInput() | 326 | bool KOEventEditor::validateInput() |
323 | { | 327 | { |
324 | if (!mGeneral->validateInput()) return false; | 328 | if (!mGeneral->validateInput()) return false; |
325 | if (!mDetails->validateInput()) return false; | 329 | if (!mDetails->validateInput()) return false; |
326 | if (!mRecurrence->validateInput()) return false; | 330 | if (!mRecurrence->validateInput()) return false; |
327 | return true; | 331 | return true; |
328 | } | 332 | } |
329 | 333 | ||
330 | int KOEventEditor::msgItemDelete() | 334 | int KOEventEditor::msgItemDelete() |
331 | { | 335 | { |
332 | return KMessageBox::warningContinueCancel(this, | 336 | return KMessageBox::warningContinueCancel(this, |
333 | i18n("This item will be permanently deleted."), | 337 | i18n("This item will be permanently deleted."), |
334 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 338 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
335 | } | 339 | } |
336 | 340 | ||
337 | void KOEventEditor::slotLoadTemplate() | 341 | void KOEventEditor::slotLoadTemplate() |
338 | { | 342 | { |
339 | 343 | ||
340 | QString fileName =locateLocal( "templates", "events" ); | 344 | QString fileName =locateLocal( "templates", "events" ); |
341 | QDir t_dir; | 345 | QDir t_dir; |
342 | if ( !t_dir.exists(fileName) ) | 346 | if ( !t_dir.exists(fileName) ) |
343 | t_dir.mkdir ( fileName ); | 347 | t_dir.mkdir ( fileName ); |
344 | fileName += "/event"; | 348 | fileName += "/event"; |
345 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); | 349 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); |
346 | if ( fileName.length() == 0 ) | 350 | if ( fileName.length() == 0 ) |
347 | return; | 351 | return; |
348 | CalendarLocal cal; | 352 | CalendarLocal cal; |
349 | ICalFormat format; | 353 | ICalFormat format; |
350 | if ( !format.load( &cal, fileName ) ) { | 354 | if ( !format.load( &cal, fileName ) ) { |
351 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 355 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
352 | .arg( fileName ) ); | 356 | .arg( fileName ) ); |
353 | return ; | 357 | return ; |
354 | } | 358 | } |
355 | QPtrList<Event> events = cal.events(); | 359 | QPtrList<Event> events = cal.events(); |
356 | Event* event = events.first(); | 360 | Event* event = events.first(); |
357 | if ( !event ) { | 361 | if ( !event ) { |
358 | KMessageBox::error( this, | 362 | KMessageBox::error( this, |
359 | i18n("Template does not contain\na valid Event.")); | 363 | i18n("Template does not contain\na valid Event.")); |
360 | } else { | 364 | } else { |
361 | kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; | 365 | kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; |
362 | readEvent( event, true ); | 366 | readEvent( event, true ); |
363 | } | 367 | } |
364 | } | 368 | } |
365 | 369 | ||
366 | 370 | ||
367 | void KOEventEditor::slotSaveTemplate() | 371 | void KOEventEditor::slotSaveTemplate() |
368 | { | 372 | { |
369 | QString fileName =locateLocal( "templates", "events" ); | 373 | QString fileName =locateLocal( "templates", "events" ); |
370 | QDir t_dir; | 374 | QDir t_dir; |
371 | if ( !t_dir.exists(fileName) ) | 375 | if ( !t_dir.exists(fileName) ) |
372 | t_dir.mkdir ( fileName ); | 376 | t_dir.mkdir ( fileName ); |
373 | fileName += "/event"; | 377 | fileName += "/event"; |
374 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); | 378 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); |
375 | if ( fileName.length() > 0 ) | 379 | if ( fileName.length() > 0 ) |
376 | saveTemplate( fileName ); | 380 | saveTemplate( fileName ); |
377 | } | 381 | } |
378 | 382 | ||
379 | void KOEventEditor::saveTemplate( const QString &templateName ) | 383 | void KOEventEditor::saveTemplate( const QString &templateName ) |
380 | { | 384 | { |
381 | Event *event = new Event; | 385 | Event *event = new Event; |
382 | writeEvent( event ); | 386 | writeEvent( event ); |
383 | saveAsTemplate( event, templateName ); | 387 | saveAsTemplate( event, templateName ); |
384 | } | 388 | } |