summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorgeneralevent.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp
index 30b792b..adc733b 100644
--- a/korganizer/koeditorgeneralevent.cpp
+++ b/korganizer/koeditorgeneralevent.cpp
@@ -1,427 +1,427 @@
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 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 <qlayout.h> 25#include <qlayout.h>
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qvgroupbox.h> 28#include <qvgroupbox.h>
29#include <qwidgetstack.h> 29#include <qwidgetstack.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kiconloader.h> 35#include <kiconloader.h>
36#include <kmessagebox.h> 36#include <kmessagebox.h>
37#include <kfiledialog.h> 37#include <kfiledialog.h>
38#include <kstandarddirs.h> 38#include <kstandarddirs.h>
39 39
40#include <libkcal/event.h> 40#include <libkcal/event.h>
41 41
42#include <libkdepim/kdateedit.h> 42#include <libkdepim/kdateedit.h>
43 43
44#include "koprefs.h" 44#include "koprefs.h"
45 45
46#include "koeditorgeneralevent.h" 46#include "koeditorgeneralevent.h"
47#include "kolocationbox.h" 47#include "kolocationbox.h"
48 48
49KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent, 49KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent,
50 const char* name) : 50 const char* name) :
51 KOEditorGeneral( parent, name) 51 KOEditorGeneral( parent, name)
52{ 52{
53 mTemplate = false; 53 mTemplate = false;
54 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 54 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
55 SLOT(setDuration())); 55 SLOT(setDuration()));
56 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 56 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
57 SLOT(emitDateTimeStr())); 57 SLOT(emitDateTimeStr()));
58} 58}
59 59
60KOEditorGeneralEvent::~KOEditorGeneralEvent() 60KOEditorGeneralEvent::~KOEditorGeneralEvent()
61{ 61{
62} 62}
63 63
64void KOEditorGeneralEvent::finishSetup() 64void KOEditorGeneralEvent::finishSetup()
65{ 65{
66 66
67 //disabled 67 //disabled
68// QWidget::setTabOrder( mSummaryEdit, mLocationEdit ); 68// QWidget::setTabOrder( mSummaryEdit, mLocationEdit );
69// QWidget::setTabOrder( mLocationEdit, mStartDateEdit ); 69// QWidget::setTabOrder( mLocationEdit, mStartDateEdit );
70// QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit ); 70// QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit );
71// QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit ); 71// QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit );
72// QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit ); 72// QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit );
73// QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton ); 73// QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton );
74// QWidget::setTabOrder( mNoTimeButton, mAlarmButton ); 74// QWidget::setTabOrder( mNoTimeButton, mAlarmButton );
75// QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit ); 75// QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit );
76// QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton ); 76// QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton );
77// QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo ); 77// QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo );
78// QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit ); 78// QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit );
79 79
80 80
81 81
82 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); 82 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
83 mSummaryEdit->setFocus(); 83 mSummaryEdit->setFocus();
84} 84}
85 85
86void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) 86void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout)
87{ 87{
88 QBoxLayout *timeLayout = new QVBoxLayout(topLayout); 88 QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
89 89
90 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, 90 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
91 i18n("Date && Time"),parent); 91 i18n("Date && Time"),parent);
92 timeLayout->addWidget(timeGroupBox); 92 timeLayout->addWidget(timeGroupBox);
93 93
94 timeGroupBox->layout()->setSpacing( 0 ); 94 timeGroupBox->layout()->setSpacing( 0 );
95 timeGroupBox->layout()->setMargin( 5 ); 95 timeGroupBox->layout()->setMargin( 5 );
96 QFrame *timeBoxFrame = new QFrame(timeGroupBox); 96 QFrame *timeBoxFrame = new QFrame(timeGroupBox);
97 97
98 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3); 98 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3);
99 layoutTimeBox->setSpacing(topLayout->spacing()); 99 layoutTimeBox->setSpacing(topLayout->spacing());
100 100
101 mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame); 101 mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame);
102 layoutTimeBox->addWidget(mStartDateLabel,0,0); 102 layoutTimeBox->addWidget(mStartDateLabel,0,0);
103 103
104 mStartDateEdit = new KDateEdit(timeBoxFrame); 104 mStartDateEdit = new KDateEdit(timeBoxFrame);
105 layoutTimeBox->addWidget(mStartDateEdit,0,1); 105 layoutTimeBox->addWidget(mStartDateEdit,0,1);
106 106
107 mStartTimeEdit = new KOTimeEdit(timeBoxFrame); 107 mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
108 layoutTimeBox->addWidget(mStartTimeEdit,0,2); 108 layoutTimeBox->addWidget(mStartTimeEdit,0,2);
109 109
110 110
111 mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame); 111 mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame);
112 layoutTimeBox->addWidget(mEndDateLabel,1,0); 112 layoutTimeBox->addWidget(mEndDateLabel,1,0);
113 113
114 mEndDateEdit = new KDateEdit(timeBoxFrame); 114 mEndDateEdit = new KDateEdit(timeBoxFrame);
115 layoutTimeBox->addWidget(mEndDateEdit,1,1); 115 layoutTimeBox->addWidget(mEndDateEdit,1,1);
116 116
117 mEndTimeEdit = new KOTimeEdit(timeBoxFrame); 117 mEndTimeEdit = new KOTimeEdit(timeBoxFrame);
118 layoutTimeBox->addWidget(mEndTimeEdit,1,2); 118 layoutTimeBox->addWidget(mEndTimeEdit,1,2);
119 QWidget* duration = new QWidget( timeBoxFrame ); 119 QWidget* duration = new QWidget( timeBoxFrame );
120 QHBoxLayout *flagsBox = new QHBoxLayout( duration ); 120 QHBoxLayout *flagsBox = new QHBoxLayout( duration );
121 mNoTimeButton = new QCheckBox(i18n("Allday"),duration); 121 mNoTimeButton = new QCheckBox(i18n("All day event"),duration);
122 flagsBox->addWidget(mNoTimeButton); 122 flagsBox->addWidget(mNoTimeButton);
123 connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool))); 123 connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool)));
124 mDurationLabel = new QLabel( duration ); 124 mDurationLabel = new QLabel( duration );
125 // if ( KOPrefs::instance()->mCompactDialogs ) { 125 // if ( KOPrefs::instance()->mCompactDialogs ) {
126 //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 ); 126 //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 );
127 //} else { 127 //} else {
128 flagsBox->addWidget( mDurationLabel ); 128 flagsBox->addWidget( mDurationLabel );
129 //} 129 //}
130 flagsBox->setStretchFactor(mDurationLabel, 10 ); 130 flagsBox->setStretchFactor(mDurationLabel, 10 );
131 mDurationLabel->setAlignment( AlignRight | AlignVCenter); 131 mDurationLabel->setAlignment( AlignRight | AlignVCenter);
132 layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 ); 132 layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 );
133 133
134 // time widgets are checked if they contain a valid time 134 // time widgets are checked if they contain a valid time
135 connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)), 135 connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)),
136 this, SLOT(startTimeChanged(QTime))); 136 this, SLOT(startTimeChanged(QTime)));
137 connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)), 137 connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)),
138 this, SLOT(endTimeChanged(QTime))); 138 this, SLOT(endTimeChanged(QTime)));
139 139
140 // date widgets are checked if they contain a valid date 140 // date widgets are checked if they contain a valid date
141 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), 141 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)),
142 this, SLOT(startDateChanged(QDate))); 142 this, SLOT(startDateChanged(QDate)));
143 connect(mEndDateEdit, SIGNAL(dateChanged(QDate)), 143 connect(mEndDateEdit, SIGNAL(dateChanged(QDate)),
144 this, SLOT(endDateChanged(QDate))); 144 this, SLOT(endDateChanged(QDate)));
145} 145}
146 146
147void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) 147void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout)
148{ 148{
149 QBoxLayout *classLayout = new QHBoxLayout(topLayout); 149 QBoxLayout *classLayout = new QHBoxLayout(topLayout);
150 150
151 QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); 151 QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent);
152 classLayout->addWidget(freeTimeLabel); 152 classLayout->addWidget(freeTimeLabel);
153 153
154 mFreeTimeCombo = new QComboBox(false, parent); 154 mFreeTimeCombo = new QComboBox(false, parent);
155 mFreeTimeCombo->insertItem(i18n("Busy")); 155 mFreeTimeCombo->insertItem(i18n("Busy"));
156 mFreeTimeCombo->insertItem(i18n("Free")); 156 mFreeTimeCombo->insertItem(i18n("Free"));
157 classLayout->addWidget(mFreeTimeCombo); 157 classLayout->addWidget(mFreeTimeCombo);
158} 158}
159 159
160void KOEditorGeneralEvent::timeStuffDisable(bool disable) 160void KOEditorGeneralEvent::timeStuffDisable(bool disable)
161{ 161{
162 mStartTimeEdit->setEnabled( !disable ); 162 mStartTimeEdit->setEnabled( !disable );
163 mEndTimeEdit->setEnabled( !disable ); 163 mEndTimeEdit->setEnabled( !disable );
164 164
165 setDuration(); 165 setDuration();
166 emitDateTimeStr(); 166 emitDateTimeStr();
167} 167}
168 168
169void KOEditorGeneralEvent::dontAssociateTime(bool noTime) 169void KOEditorGeneralEvent::dontAssociateTime(bool noTime)
170{ 170{
171 timeStuffDisable(noTime); 171 timeStuffDisable(noTime);
172 //if(alarmButton->isChecked()) alarmStuffDisable(noTime); 172 //if(alarmButton->isChecked()) alarmStuffDisable(noTime);
173 allDayChanged(noTime); 173 allDayChanged(noTime);
174} 174}
175 175
176void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) 176void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end)
177{ 177{
178// kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; 178// kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl;
179 if ( !mTemplate ) 179 if ( !mTemplate )
180 mStartDateEdit->setDate(start.date()); 180 mStartDateEdit->setDate(start.date());
181 // KTimeEdit seems to emit some signals when setTime() is called. 181 // KTimeEdit seems to emit some signals when setTime() is called.
182 mStartTimeEdit->blockSignals( true ); 182 mStartTimeEdit->blockSignals( true );
183 mStartTimeEdit->setTime(start.time()); 183 mStartTimeEdit->setTime(start.time());
184 mStartTimeEdit->blockSignals( false ); 184 mStartTimeEdit->blockSignals( false );
185 if ( !mTemplate ) 185 if ( !mTemplate )
186 mEndDateEdit->setDate(end.date()); 186 mEndDateEdit->setDate(end.date());
187 mEndTimeEdit->setTime(end.time()); 187 mEndTimeEdit->setTime(end.time());
188 188
189 mCurrStartDateTime = start; 189 mCurrStartDateTime = start;
190 mCurrEndDateTime = end; 190 mCurrEndDateTime = end;
191 191
192 setDuration(); 192 setDuration();
193 emitDateTimeStr(); 193 emitDateTimeStr();
194} 194}
195 195
196void KOEditorGeneralEvent::startTimeChanged(QTime newtime) 196void KOEditorGeneralEvent::startTimeChanged(QTime newtime)
197{ 197{
198 kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl; 198 kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl;
199 199
200 int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); 200 int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime);
201 201
202 mCurrStartDateTime.setTime(newtime); 202 mCurrStartDateTime.setTime(newtime);
203 203
204 // adjust end time so that the event has the same duration as before. 204 // adjust end time so that the event has the same duration as before.
205 mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); 205 mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep);
206 mEndTimeEdit->setTime(mCurrEndDateTime.time()); 206 mEndTimeEdit->setTime(mCurrEndDateTime.time());
207 mEndDateEdit->setDate(mCurrEndDateTime.date()); 207 mEndDateEdit->setDate(mCurrEndDateTime.date());
208 208
209 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 209 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
210} 210}
211 211
212void KOEditorGeneralEvent::endTimeChanged(QTime newtime) 212void KOEditorGeneralEvent::endTimeChanged(QTime newtime)
213{ 213{
214// kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl; 214// kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl;
215 215
216 QDateTime newdt(mCurrEndDateTime.date(), newtime); 216 QDateTime newdt(mCurrEndDateTime.date(), newtime);
217 mCurrEndDateTime = newdt; 217 mCurrEndDateTime = newdt;
218 218
219 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 219 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
220} 220}
221 221
222void KOEditorGeneralEvent::startDateChanged(QDate newdate) 222void KOEditorGeneralEvent::startDateChanged(QDate newdate)
223{ 223{
224 int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); 224 int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime);
225 225
226 mCurrStartDateTime.setDate(newdate); 226 mCurrStartDateTime.setDate(newdate);
227 227
228 // adjust end date so that the event has the same duration as before 228 // adjust end date so that the event has the same duration as before
229 mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); 229 mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep));
230 mEndDateEdit->setDate(mCurrEndDateTime.date()); 230 mEndDateEdit->setDate(mCurrEndDateTime.date());
231 231
232 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 232 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
233} 233}
234 234
235void KOEditorGeneralEvent::endDateChanged(QDate newdate) 235void KOEditorGeneralEvent::endDateChanged(QDate newdate)
236{ 236{
237 QDateTime newdt(newdate, mCurrEndDateTime.time()); 237 QDateTime newdt(newdate, mCurrEndDateTime.time());
238 238
239 if(newdt < mCurrStartDateTime) { 239 if(newdt < mCurrStartDateTime) {
240 // oops, we can't let that happen. 240 // oops, we can't let that happen.
241 newdt = mCurrStartDateTime; 241 newdt = mCurrStartDateTime;
242 mEndDateEdit->setDate(newdt.date()); 242 mEndDateEdit->setDate(newdt.date());
243 mEndTimeEdit->setTime(newdt.time()); 243 mEndTimeEdit->setTime(newdt.time());
244 } 244 }
245 mCurrEndDateTime = newdt; 245 mCurrEndDateTime = newdt;
246 246
247 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 247 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
248} 248}
249 249
250void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay) 250void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay)
251{ 251{
252 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); 252 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
253 mLocationEdit->load(KOLocationBox::LOCATION); 253 mLocationEdit->load(KOLocationBox::LOCATION);
254 KOEditorGeneral::setDefaults(allDay); 254 KOEditorGeneral::setDefaults(allDay);
255 255
256 mNoTimeButton->setChecked(allDay); 256 mNoTimeButton->setChecked(allDay);
257 timeStuffDisable(allDay); 257 timeStuffDisable(allDay);
258 mFreeTimeCombo->setCurrentItem( 0 ); 258 mFreeTimeCombo->setCurrentItem( 0 );
259 setDateTimes(from,to); 259 setDateTimes(from,to);
260} 260}
261 261
262void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl ) 262void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl )
263{ 263{
264 QString tmpStr; 264 QString tmpStr;
265 265
266 mTemplate = tmpl; 266 mTemplate = tmpl;
267 // the rest is for the events only 267 // the rest is for the events only
268 mNoTimeButton->setChecked(event->doesFloat()); 268 mNoTimeButton->setChecked(event->doesFloat());
269 timeStuffDisable(event->doesFloat()); 269 timeStuffDisable(event->doesFloat());
270 270
271 setDateTimes(event->dtStart(),event->dtEnd()); 271 setDateTimes(event->dtStart(),event->dtEnd());
272 272
273 mTemplate = false; 273 mTemplate = false;
274 switch( event->transparency() ) { 274 switch( event->transparency() ) {
275 case Event::Transparent: 275 case Event::Transparent:
276 mFreeTimeCombo->setCurrentItem(1); 276 mFreeTimeCombo->setCurrentItem(1);
277 break; 277 break;
278 case Event::Opaque: 278 case Event::Opaque:
279 mFreeTimeCombo->setCurrentItem(0); 279 mFreeTimeCombo->setCurrentItem(0);
280 break; 280 break;
281 } 281 }
282 282
283 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); 283 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
284 mLocationEdit->load(KOLocationBox::LOCATION); 284 mLocationEdit->load(KOLocationBox::LOCATION);
285 readIncidence(event); 285 readIncidence(event);
286} 286}
287 287
288void KOEditorGeneralEvent::writeEvent(Event *event) 288void KOEditorGeneralEvent::writeEvent(Event *event)
289{ 289{
290// kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl; 290// kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl;
291 291
292 writeIncidence(event); 292 writeIncidence(event);
293 293
294 QDate tmpDate; 294 QDate tmpDate;
295 QTime tmpTime; 295 QTime tmpTime;
296 QDateTime tmpDT; 296 QDateTime tmpDT;
297 297
298 // temp. until something better happens. 298 // temp. until something better happens.
299 QString tmpStr; 299 QString tmpStr;
300 300
301 if (mNoTimeButton->isChecked()) { 301 if (mNoTimeButton->isChecked()) {
302 event->setFloats(true); 302 event->setFloats(true);
303 // need to change this. 303 // need to change this.
304 tmpDate = mStartDateEdit->date(); 304 tmpDate = mStartDateEdit->date();
305 tmpTime.setHMS(0,0,0); 305 tmpTime.setHMS(0,0,0);
306 tmpDT.setDate(tmpDate); 306 tmpDT.setDate(tmpDate);
307 tmpDT.setTime(tmpTime); 307 tmpDT.setTime(tmpTime);
308 event->setDtStart(tmpDT); 308 event->setDtStart(tmpDT);
309 309
310 tmpDate = mEndDateEdit->date(); 310 tmpDate = mEndDateEdit->date();
311 tmpTime.setHMS(0,0,0); 311 tmpTime.setHMS(0,0,0);
312 tmpDT.setDate(tmpDate); 312 tmpDT.setDate(tmpDate);
313 tmpDT.setTime(tmpTime); 313 tmpDT.setTime(tmpTime);
314 event->setDtEnd(tmpDT); 314 event->setDtEnd(tmpDT);
315 } else { 315 } else {
316 event->setFloats(false); 316 event->setFloats(false);
317 317
318 // set date/time end 318 // set date/time end
319 tmpDate = mEndDateEdit->date(); 319 tmpDate = mEndDateEdit->date();
320 tmpTime = mEndTimeEdit->getTime(); 320 tmpTime = mEndTimeEdit->getTime();
321 tmpDT.setDate(tmpDate); 321 tmpDT.setDate(tmpDate);
322 tmpDT.setTime(tmpTime); 322 tmpDT.setTime(tmpTime);
323 event->setDtEnd(tmpDT); 323 event->setDtEnd(tmpDT);
324 324
325 // set date/time start 325 // set date/time start
326 tmpDate = mStartDateEdit->date(); 326 tmpDate = mStartDateEdit->date();
327 tmpTime = mStartTimeEdit->getTime(); 327 tmpTime = mStartTimeEdit->getTime();
328 tmpDT.setDate(tmpDate); 328 tmpDT.setDate(tmpDate);
329 tmpDT.setTime(tmpTime); 329 tmpDT.setTime(tmpTime);
330 event->setDtStart(tmpDT); 330 event->setDtStart(tmpDT);
331 } // check for float 331 } // check for float
332 mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); 332 mSummaryEdit->save(KOLocationBox::SUMMARYEVENT);
333 333
334 event->setTransparency(mFreeTimeCombo->currentItem() > 0 334 event->setTransparency(mFreeTimeCombo->currentItem() > 0
335 ? KCal::Event::Transparent 335 ? KCal::Event::Transparent
336 : KCal::Event::Opaque); 336 : KCal::Event::Opaque);
337 337
338// kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; 338// kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl;
339} 339}
340 340
341void KOEditorGeneralEvent::setDuration() 341void KOEditorGeneralEvent::setDuration()
342{ 342{
343 QString tmpStr = "", catStr; 343 QString tmpStr = "", catStr;
344 int hourdiff, minutediff; 344 int hourdiff, minutediff;
345 // end<date is an accepted temporary state while typing, but don't show 345 // end<date is an accepted temporary state while typing, but don't show
346 // any duration if this happens 346 // any duration if this happens
347 if(mCurrEndDateTime >= mCurrStartDateTime) { 347 if(mCurrEndDateTime >= mCurrStartDateTime) {
348 348
349 if (mNoTimeButton->isChecked()) { 349 if (mNoTimeButton->isChecked()) {
350 int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; 350 int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1;
351 tmpStr = i18n("Duration: "); 351 tmpStr = i18n("Duration: ");
352 tmpStr.append(i18n("1 Day","%n Days",daydiff)); 352 tmpStr.append(i18n("1 Day","%n Days",daydiff));
353 } else { 353 } else {
354 int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); 354 int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime );
355 hourdiff = secto / 3600; 355 hourdiff = secto / 3600;
356 minutediff = (secto/60 ) % 60; 356 minutediff = (secto/60 ) % 60;
357 if (hourdiff || minutediff){ 357 if (hourdiff || minutediff){
358 tmpStr = i18n("Duration: "); 358 tmpStr = i18n("Duration: ");
359 if (hourdiff){ 359 if (hourdiff){
360 catStr = i18n("1 h","%n h",hourdiff); 360 catStr = i18n("1 h","%n h",hourdiff);
361 tmpStr.append(catStr); 361 tmpStr.append(catStr);
362 } 362 }
363 if (hourdiff && minutediff){ 363 if (hourdiff && minutediff){
364 tmpStr += i18n(", "); 364 tmpStr += i18n(", ");
365 } 365 }
366 if (minutediff){ 366 if (minutediff){
367 catStr = i18n("1 min","%n min",minutediff); 367 catStr = i18n("1 min","%n min",minutediff);
368 tmpStr += catStr; 368 tmpStr += catStr;
369 } 369 }
370 } else tmpStr = ""; 370 } else tmpStr = "";
371 } 371 }
372 } 372 }
373 mDurationLabel->setText(tmpStr); 373 mDurationLabel->setText(tmpStr);
374} 374}
375 375
376void KOEditorGeneralEvent::emitDateTimeStr() 376void KOEditorGeneralEvent::emitDateTimeStr()
377{ 377{
378 KLocale *l = KGlobal::locale(); 378 KLocale *l = KGlobal::locale();
379 379
380 QString from,to; 380 QString from,to;
381 if (mNoTimeButton->isChecked()) { 381 if (mNoTimeButton->isChecked()) {
382 from = l->formatDate(mCurrStartDateTime.date()); 382 from = l->formatDate(mCurrStartDateTime.date());
383 to = l->formatDate(mCurrEndDateTime.date()); 383 to = l->formatDate(mCurrEndDateTime.date());
384 } else { 384 } else {
385 from = l->formatDateTime(mCurrStartDateTime); 385 from = l->formatDateTime(mCurrStartDateTime);
386 to = l->formatDateTime(mCurrEndDateTime); 386 to = l->formatDateTime(mCurrEndDateTime);
387 } 387 }
388 388
389 QString str = i18n("From: %1 To: %2 %3").arg(from).arg(to) 389 QString str = i18n("From: %1 To: %2 %3").arg(from).arg(to)
390 .arg(mDurationLabel->text()); 390 .arg(mDurationLabel->text());
391 391
392 emit dateTimeStrChanged(str); 392 emit dateTimeStrChanged(str);
393} 393}
394 394
395bool KOEditorGeneralEvent::validateInput() 395bool KOEditorGeneralEvent::validateInput()
396{ 396{
397 397
398 if (!mStartDateEdit->inputIsValid()) { 398 if (!mStartDateEdit->inputIsValid()) {
399 KMessageBox::sorry( 0, 399 KMessageBox::sorry( 0,
400 i18n("Please specify a valid start date, for example '%1'.") 400 i18n("Please specify a valid start date, for example '%1'.")
401 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); 401 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) );
402 return false; 402 return false;
403 } 403 }
404 404
405 if (!mEndDateEdit->inputIsValid()) { 405 if (!mEndDateEdit->inputIsValid()) {
406 KMessageBox::sorry( 0, 406 KMessageBox::sorry( 0,
407 i18n("Please specify a valid end date, for example '%1'.") 407 i18n("Please specify a valid end date, for example '%1'.")
408 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); 408 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) );
409 return false; 409 return false;
410 } 410 }
411 411
412 QDateTime startDt,endDt; 412 QDateTime startDt,endDt;
413 startDt.setDate(mStartDateEdit->date()); 413 startDt.setDate(mStartDateEdit->date());
414 endDt.setDate(mEndDateEdit->date()); 414 endDt.setDate(mEndDateEdit->date());
415 if (!mNoTimeButton->isChecked()) { 415 if (!mNoTimeButton->isChecked()) {
416 startDt.setTime(mStartTimeEdit->getTime()); 416 startDt.setTime(mStartTimeEdit->getTime());
417 endDt.setTime(mEndTimeEdit->getTime()); 417 endDt.setTime(mEndTimeEdit->getTime());
418 } 418 }
419 419
420 if (startDt > endDt) { 420 if (startDt > endDt) {
421 KMessageBox::sorry(0,i18n("The event ends before it starts.\n" 421 KMessageBox::sorry(0,i18n("The event ends before it starts.\n"
422 "Please correct dates and times.")); 422 "Please correct dates and times."));
423 return false; 423 return false;
424 } 424 }
425 425
426 return KOEditorGeneral::validateInput(); 426 return KOEditorGeneral::validateInput();
427} 427}