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