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