summaryrefslogtreecommitdiffabout
path: root/korganizer/koeventeditor.cpp
Unidiff
Diffstat (limited to 'korganizer/koeventeditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventeditor.cpp4
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,75 +1,76 @@
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"
50extern int globalFlagBlockAgenda; 51extern int globalFlagBlockAgenda;
51 52
52KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : 53KOEventEditor::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
61KOEventEditor::~KOEventEditor() 62KOEventEditor::~KOEventEditor()
62{ 63{
63 //emit dialogClose( mEvent ); 64 //emit dialogClose( mEvent );
64} 65}
65 66
66void KOEventEditor::init() 67void 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)));
@@ -204,96 +205,99 @@ void KOEventEditor::editEvent(Event *event, bool showDescription)
204} 205}
205 206
206void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) 207void 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
214void KOEventEditor::loadDefaults() 215void 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
225bool KOEventEditor::processInput( bool emitTime ) 226bool 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
257void KOEventEditor::deleteEvent() 261void 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
285void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) 289void 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
294void KOEventEditor::readEvent( Event *event, bool tmpl ) 298void 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