Diffstat (limited to 'korganizer/koeditorgeneralevent.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp index af97ee9..3dd7f5c 100644 --- a/korganizer/koeditorgeneralevent.cpp +++ b/korganizer/koeditorgeneralevent.cpp | |||
@@ -48,385 +48,385 @@ | |||
48 | 48 | ||
49 | KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent, | 49 | KOEditorGeneralEvent::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 | ||
60 | KOEditorGeneralEvent::~KOEditorGeneralEvent() | 60 | KOEditorGeneralEvent::~KOEditorGeneralEvent() |
61 | { | 61 | { |
62 | } | 62 | } |
63 | 63 | ||
64 | void KOEditorGeneralEvent::finishSetup() | 64 | void 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 | ||
86 | void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) | 86 | void 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("All day event"),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 | connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime))); | 145 | connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime))); |
146 | connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime))); | 146 | connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime))); |
147 | } | 147 | } |
148 | 148 | ||
149 | void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) | 149 | void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) |
150 | { | 150 | { |
151 | QBoxLayout *classLayout = new QHBoxLayout(topLayout); | 151 | QBoxLayout *classLayout = new QHBoxLayout(topLayout); |
152 | 152 | ||
153 | QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); | 153 | QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); |
154 | classLayout->addWidget(freeTimeLabel); | 154 | classLayout->addWidget(freeTimeLabel); |
155 | 155 | ||
156 | mFreeTimeCombo = new QComboBox(false, parent); | 156 | mFreeTimeCombo = new QComboBox(false, parent); |
157 | mFreeTimeCombo->insertItem(i18n("Busy")); | 157 | mFreeTimeCombo->insertItem(i18n("Busy")); |
158 | mFreeTimeCombo->insertItem(i18n("Free")); | 158 | mFreeTimeCombo->insertItem(i18n("Free")); |
159 | classLayout->addWidget(mFreeTimeCombo); | 159 | classLayout->addWidget(mFreeTimeCombo); |
160 | } | 160 | } |
161 | 161 | ||
162 | void KOEditorGeneralEvent::timeStuffDisable(bool disable) | 162 | void KOEditorGeneralEvent::timeStuffDisable(bool disable) |
163 | { | 163 | { |
164 | mStartTimeEdit->setEnabled( !disable ); | 164 | mStartTimeEdit->setEnabled( !disable ); |
165 | mEndTimeEdit->setEnabled( !disable ); | 165 | mEndTimeEdit->setEnabled( !disable ); |
166 | 166 | ||
167 | setDuration(); | 167 | setDuration(); |
168 | emitDateTimeStr(); | 168 | emitDateTimeStr(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void KOEditorGeneralEvent::dontAssociateTime(bool noTime) | 171 | void KOEditorGeneralEvent::dontAssociateTime(bool noTime) |
172 | { | 172 | { |
173 | timeStuffDisable(noTime); | 173 | timeStuffDisable(noTime); |
174 | //if(alarmButton->isChecked()) alarmStuffDisable(noTime); | 174 | //if(alarmButton->isChecked()) alarmStuffDisable(noTime); |
175 | allDayChanged(noTime); | 175 | allDayChanged(noTime); |
176 | } | 176 | } |
177 | 177 | ||
178 | void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) | 178 | void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) |
179 | { | 179 | { |
180 | // kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; | 180 | // kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; |
181 | if ( !mTemplate ) | 181 | if ( !mTemplate ) |
182 | mStartDateEdit->setDate(start.date()); | 182 | mStartDateEdit->setDate(start.date()); |
183 | // KTimeEdit seems to emit some signals when setTime() is called. | 183 | // KTimeEdit seems to emit some signals when setTime() is called. |
184 | mStartTimeEdit->blockSignals( true ); | 184 | mStartTimeEdit->blockSignals( true ); |
185 | mStartTimeEdit->setTime(start.time()); | 185 | mStartTimeEdit->setTime(start.time()); |
186 | mStartTimeEdit->blockSignals( false ); | 186 | mStartTimeEdit->blockSignals( false ); |
187 | if ( !mTemplate ) | 187 | if ( !mTemplate ) |
188 | mEndDateEdit->setDate(end.date()); | 188 | mEndDateEdit->setDate(end.date()); |
189 | mEndTimeEdit->setTime(end.time()); | 189 | mEndTimeEdit->setTime(end.time()); |
190 | 190 | ||
191 | mCurrStartDateTime = start; | 191 | mCurrStartDateTime = start; |
192 | mCurrEndDateTime = end; | 192 | mCurrEndDateTime = end; |
193 | 193 | ||
194 | setDuration(); | 194 | setDuration(); |
195 | emitDateTimeStr(); | 195 | emitDateTimeStr(); |
196 | } | 196 | } |
197 | 197 | ||
198 | void KOEditorGeneralEvent::sTimeChanged(QTime ti) | 198 | void KOEditorGeneralEvent::sTimeChanged(QTime ti) |
199 | { | 199 | { |
200 | mStartTimeEdit->setTime( ti ); | 200 | mStartTimeEdit->setTime( ti ); |
201 | startTimeChanged ( ti); | 201 | startTimeChanged ( ti); |
202 | } | 202 | } |
203 | void KOEditorGeneralEvent::eTimeChanged(QTime ti ) | 203 | void KOEditorGeneralEvent::eTimeChanged(QTime ti ) |
204 | { | 204 | { |
205 | mEndTimeEdit->setTime( ti ); | 205 | mEndTimeEdit->setTime( ti ); |
206 | endTimeChanged( ti ); | 206 | endTimeChanged( ti ); |
207 | } | 207 | } |
208 | void KOEditorGeneralEvent::startTimeChanged(QTime newtime) | 208 | void KOEditorGeneralEvent::startTimeChanged(QTime newtime) |
209 | { | 209 | { |
210 | 210 | ||
211 | int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); | 211 | int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); |
212 | 212 | ||
213 | mCurrStartDateTime = QDateTime( mStartDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0) ); | 213 | mCurrStartDateTime = QDateTime( mStartDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0) ); |
214 | // adjust end time so that the event has the same duration as before. | 214 | // adjust end time so that the event has the same duration as before. |
215 | if( secsep > 0 ) | 215 | if( secsep > 0 ) |
216 | mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); | 216 | mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); |
217 | mEndTimeEdit->setTime(mCurrEndDateTime.time()); | 217 | mEndTimeEdit->setTime(mCurrEndDateTime.time()); |
218 | mEndDateEdit->setDate(mCurrEndDateTime.date()); | 218 | mEndDateEdit->setDate(mCurrEndDateTime.date()); |
219 | 219 | ||
220 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 220 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
221 | } | 221 | } |
222 | 222 | ||
223 | void KOEditorGeneralEvent::endTimeChanged(QTime newtime) | 223 | void KOEditorGeneralEvent::endTimeChanged(QTime newtime) |
224 | { | 224 | { |
225 | 225 | ||
226 | mCurrEndDateTime = QDateTime ( mEndDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0)); | 226 | mCurrEndDateTime = QDateTime ( mEndDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0)); |
227 | 227 | ||
228 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 228 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
229 | } | 229 | } |
230 | 230 | ||
231 | void KOEditorGeneralEvent::startDateChanged(QDate newdate) | 231 | void KOEditorGeneralEvent::startDateChanged(QDate newdate) |
232 | { | 232 | { |
233 | int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); | 233 | int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); |
234 | 234 | ||
235 | mCurrStartDateTime.setDate(newdate); | 235 | mCurrStartDateTime.setDate(newdate); |
236 | 236 | ||
237 | // adjust end date so that the event has the same duration as before | 237 | // adjust end date so that the event has the same duration as before |
238 | mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); | 238 | mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); |
239 | mEndDateEdit->setDate(mCurrEndDateTime.date()); | 239 | mEndDateEdit->setDate(mCurrEndDateTime.date()); |
240 | 240 | qDebug("KOEditorGeneralEvent::startDateChanged "); | |
241 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 241 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
242 | } | 242 | } |
243 | 243 | ||
244 | void KOEditorGeneralEvent::endDateChanged(QDate newdate) | 244 | void KOEditorGeneralEvent::endDateChanged(QDate newdate) |
245 | { | 245 | { |
246 | QDateTime newdt(newdate, mCurrEndDateTime.time()); | 246 | QDateTime newdt(newdate, mCurrEndDateTime.time()); |
247 | 247 | ||
248 | if(newdt < mCurrStartDateTime) { | 248 | if(newdt < mCurrStartDateTime) { |
249 | // oops, we can't let that happen. | 249 | // oops, we can't let that happen. |
250 | newdt = mCurrStartDateTime; | 250 | newdt = mCurrStartDateTime; |
251 | mEndDateEdit->setDate(newdt.date()); | 251 | mEndDateEdit->setDate(newdt.date()); |
252 | mEndTimeEdit->setTime(newdt.time()); | 252 | mEndTimeEdit->setTime(newdt.time()); |
253 | } | 253 | } |
254 | mCurrEndDateTime = newdt; | 254 | mCurrEndDateTime = newdt; |
255 | 255 | ||
256 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 256 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
257 | } | 257 | } |
258 | 258 | ||
259 | void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay) | 259 | void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay) |
260 | { | 260 | { |
261 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); | 261 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); |
262 | mLocationEdit->load(KOLocationBox::LOCATION); | 262 | mLocationEdit->load(KOLocationBox::LOCATION); |
263 | KOEditorGeneral::setDefaults(allDay); | 263 | KOEditorGeneral::setDefaults(allDay); |
264 | 264 | ||
265 | mNoTimeButton->setChecked(allDay); | 265 | mNoTimeButton->setChecked(allDay); |
266 | timeStuffDisable(allDay); | 266 | timeStuffDisable(allDay); |
267 | mFreeTimeCombo->setCurrentItem( 0 ); | 267 | mFreeTimeCombo->setCurrentItem( 0 ); |
268 | setDateTimes(from,to); | 268 | setDateTimes(from,to); |
269 | } | 269 | } |
270 | 270 | ||
271 | void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl ) | 271 | void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl ) |
272 | { | 272 | { |
273 | QString tmpStr; | 273 | QString tmpStr; |
274 | 274 | ||
275 | mTemplate = tmpl; | 275 | mTemplate = tmpl; |
276 | // the rest is for the events only | 276 | // the rest is for the events only |
277 | mNoTimeButton->setChecked(event->doesFloat()); | 277 | mNoTimeButton->setChecked(event->doesFloat()); |
278 | timeStuffDisable(event->doesFloat()); | 278 | timeStuffDisable(event->doesFloat()); |
279 | 279 | ||
280 | setDateTimes(event->dtStart(),event->dtEnd()); | 280 | setDateTimes(event->dtStart(),event->dtEnd()); |
281 | 281 | ||
282 | mTemplate = false; | 282 | mTemplate = false; |
283 | switch( event->transparency() ) { | 283 | switch( event->transparency() ) { |
284 | case Event::Transparent: | 284 | case Event::Transparent: |
285 | mFreeTimeCombo->setCurrentItem(1); | 285 | mFreeTimeCombo->setCurrentItem(1); |
286 | break; | 286 | break; |
287 | case Event::Opaque: | 287 | case Event::Opaque: |
288 | mFreeTimeCombo->setCurrentItem(0); | 288 | mFreeTimeCombo->setCurrentItem(0); |
289 | break; | 289 | break; |
290 | } | 290 | } |
291 | 291 | ||
292 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); | 292 | mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); |
293 | mLocationEdit->load(KOLocationBox::LOCATION); | 293 | mLocationEdit->load(KOLocationBox::LOCATION); |
294 | readIncidence(event); | 294 | readIncidence(event); |
295 | } | 295 | } |
296 | 296 | ||
297 | void KOEditorGeneralEvent::writeEvent(Event *event) | 297 | void KOEditorGeneralEvent::writeEvent(Event *event) |
298 | { | 298 | { |
299 | // kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl; | 299 | // kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl; |
300 | 300 | ||
301 | writeIncidence(event); | 301 | writeIncidence(event); |
302 | 302 | ||
303 | QDate tmpDate; | 303 | QDate tmpDate; |
304 | QTime tmpTime; | 304 | QTime tmpTime; |
305 | QDateTime tmpDT; | 305 | QDateTime tmpDT; |
306 | 306 | ||
307 | // temp. until something better happens. | 307 | // temp. until something better happens. |
308 | QString tmpStr; | 308 | QString tmpStr; |
309 | 309 | ||
310 | if (mNoTimeButton->isChecked()) { | 310 | if (mNoTimeButton->isChecked()) { |
311 | event->setFloats(true); | 311 | event->setFloats(true); |
312 | // need to change this. | 312 | // need to change this. |
313 | tmpDate = mStartDateEdit->date(); | 313 | tmpDate = mStartDateEdit->date(); |
314 | tmpTime.setHMS(0,0,0); | 314 | tmpTime.setHMS(0,0,0); |
315 | tmpDT.setDate(tmpDate); | 315 | tmpDT.setDate(tmpDate); |
316 | tmpDT.setTime(tmpTime); | 316 | tmpDT.setTime(tmpTime); |
317 | event->setDtStart(tmpDT); | 317 | event->setDtStart(tmpDT); |
318 | 318 | ||
319 | tmpDate = mEndDateEdit->date(); | 319 | tmpDate = mEndDateEdit->date(); |
320 | tmpTime.setHMS(0,0,0); | 320 | tmpTime.setHMS(0,0,0); |
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 | } else { | 324 | } else { |
325 | event->setFloats(false); | 325 | event->setFloats(false); |
326 | 326 | ||
327 | // set date/time end | 327 | // set date/time end |
328 | tmpDate = mEndDateEdit->date(); | 328 | tmpDate = mEndDateEdit->date(); |
329 | tmpTime = mEndTimeEdit->getTime(); | 329 | tmpTime = mEndTimeEdit->getTime(); |
330 | tmpDT.setDate(tmpDate); | 330 | tmpDT.setDate(tmpDate); |
331 | tmpDT.setTime(tmpTime); | 331 | tmpDT.setTime(tmpTime); |
332 | event->setDtEnd(tmpDT); | 332 | event->setDtEnd(tmpDT); |
333 | 333 | ||
334 | // set date/time start | 334 | // set date/time start |
335 | tmpDate = mStartDateEdit->date(); | 335 | tmpDate = mStartDateEdit->date(); |
336 | tmpTime = mStartTimeEdit->getTime(); | 336 | tmpTime = mStartTimeEdit->getTime(); |
337 | tmpDT.setDate(tmpDate); | 337 | tmpDT.setDate(tmpDate); |
338 | tmpDT.setTime(tmpTime); | 338 | tmpDT.setTime(tmpTime); |
339 | event->setDtStart(tmpDT); | 339 | event->setDtStart(tmpDT); |
340 | } // check for float | 340 | } // check for float |
341 | mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); | 341 | mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); |
342 | 342 | ||
343 | event->setTransparency(mFreeTimeCombo->currentItem() > 0 | 343 | event->setTransparency(mFreeTimeCombo->currentItem() > 0 |
344 | ? KCal::Event::Transparent | 344 | ? KCal::Event::Transparent |
345 | : KCal::Event::Opaque); | 345 | : KCal::Event::Opaque); |
346 | 346 | ||
347 | // kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; | 347 | // kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; |
348 | } | 348 | } |
349 | 349 | ||
350 | void KOEditorGeneralEvent::setDuration() | 350 | void KOEditorGeneralEvent::setDuration() |
351 | { | 351 | { |
352 | QString tmpStr = "", catStr; | 352 | QString tmpStr = "", catStr; |
353 | int hourdiff, minutediff; | 353 | int hourdiff, minutediff; |
354 | // end<date is an accepted temporary state while typing, but don't show | 354 | // end<date is an accepted temporary state while typing, but don't show |
355 | // any duration if this happens | 355 | // any duration if this happens |
356 | if(mCurrEndDateTime >= mCurrStartDateTime) { | 356 | if(mCurrEndDateTime >= mCurrStartDateTime) { |
357 | 357 | ||
358 | if (mNoTimeButton->isChecked()) { | 358 | if (mNoTimeButton->isChecked()) { |
359 | int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; | 359 | int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; |
360 | tmpStr = i18n("Duration: "); | 360 | tmpStr = i18n("Duration: "); |
361 | tmpStr.append(i18n("1 Day","%n Days",daydiff)); | 361 | tmpStr.append(i18n("1 Day","%n Days",daydiff)); |
362 | } else { | 362 | } else { |
363 | int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); | 363 | int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); |
364 | hourdiff = secto / 3600; | 364 | hourdiff = secto / 3600; |
365 | minutediff = (secto/60 ) % 60; | 365 | minutediff = (secto/60 ) % 60; |
366 | if (hourdiff || minutediff){ | 366 | if (hourdiff || minutediff){ |
367 | tmpStr = i18n("Duration: "); | 367 | tmpStr = i18n("Duration: "); |
368 | if (hourdiff){ | 368 | if (hourdiff){ |
369 | catStr = i18n("1 h","%n h",hourdiff); | 369 | catStr = i18n("1 h","%n h",hourdiff); |
370 | tmpStr.append(catStr); | 370 | tmpStr.append(catStr); |
371 | } | 371 | } |
372 | if (hourdiff && minutediff){ | 372 | if (hourdiff && minutediff){ |
373 | tmpStr += i18n(", "); | 373 | tmpStr += i18n(", "); |
374 | } | 374 | } |
375 | if (minutediff){ | 375 | if (minutediff){ |
376 | catStr = i18n("1 min","%n min",minutediff); | 376 | catStr = i18n("1 min","%n min",minutediff); |
377 | tmpStr += catStr; | 377 | tmpStr += catStr; |
378 | } | 378 | } |
379 | } else tmpStr = ""; | 379 | } else tmpStr = ""; |
380 | } | 380 | } |
381 | } | 381 | } |
382 | mDurationLabel->setText(tmpStr); | 382 | mDurationLabel->setText(tmpStr); |
383 | } | 383 | } |
384 | 384 | ||
385 | void KOEditorGeneralEvent::emitDateTimeStr() | 385 | void KOEditorGeneralEvent::emitDateTimeStr() |
386 | { | 386 | { |
387 | KLocale *l = KGlobal::locale(); | 387 | KLocale *l = KGlobal::locale(); |
388 | QString startString = ""; | 388 | QString startString = ""; |
389 | if ( mCurrStartDateTime.date() < mCurrEndDateTime.date() ) { | 389 | if ( mCurrStartDateTime.date() < mCurrEndDateTime.date() ) { |
390 | if ( mNoTimeButton->isChecked() ) { | 390 | if ( mNoTimeButton->isChecked() ) { |
391 | startString = i18n("From: ") + l->formatDate(mCurrStartDateTime.date() ); | 391 | startString = i18n("From: ") + l->formatDate(mCurrStartDateTime.date() ); |
392 | startString += "\n"+i18n("To: ")+ l->formatDate(mCurrEndDateTime.date()); | 392 | startString += "\n"+i18n("To: ")+ l->formatDate(mCurrEndDateTime.date()); |
393 | 393 | ||
394 | } else { | 394 | } else { |
395 | startString = i18n("From: ") +l->formatDateTime(mCurrStartDateTime, false); | 395 | startString = i18n("From: ") +l->formatDateTime(mCurrStartDateTime, false); |
396 | startString += "\n"+i18n("To: ")+l->formatDateTime(mCurrEndDateTime, false); | 396 | startString += "\n"+i18n("To: ")+l->formatDateTime(mCurrEndDateTime, false); |
397 | } | 397 | } |
398 | } else { | 398 | } else { |
399 | if ( mNoTimeButton->isChecked() ) { | 399 | if ( mNoTimeButton->isChecked() ) { |
400 | startString = i18n("On: ") + l->formatDate(mCurrStartDateTime.date() ); | 400 | startString = i18n("On: ") + l->formatDate(mCurrStartDateTime.date() ); |
401 | } else { | 401 | } else { |
402 | startString = i18n("From: ") + KGlobal::locale()->formatTime(mCurrStartDateTime.time())+ | 402 | startString = i18n("From: ") + KGlobal::locale()->formatTime(mCurrStartDateTime.time())+ |
403 | "-"+KGlobal::locale()->formatTime(mCurrEndDateTime.time()); | 403 | "-"+KGlobal::locale()->formatTime(mCurrEndDateTime.time()); |
404 | startString += i18n(" on ")+KGlobal::locale()->formatDate( mCurrStartDateTime.date(), true); | 404 | startString += i18n(" on ")+KGlobal::locale()->formatDate( mCurrStartDateTime.date(), true); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | startString +="\n"+mDurationLabel->text(); | 407 | startString +="\n"+mDurationLabel->text(); |
408 | emit dateTimeStrChanged(startString); | 408 | emit dateTimeStrChanged(startString); |
409 | } | 409 | } |
410 | 410 | ||
411 | bool KOEditorGeneralEvent::validateInput() | 411 | bool KOEditorGeneralEvent::validateInput() |
412 | { | 412 | { |
413 | 413 | ||
414 | if (!mStartDateEdit->inputIsValid()) { | 414 | if (!mStartDateEdit->inputIsValid()) { |
415 | KMessageBox::sorry( 0, | 415 | KMessageBox::sorry( 0, |
416 | i18n("Please specify a valid start date,\nfor example '%1'.") | 416 | i18n("Please specify a valid start date,\nfor example '%1'.") |
417 | .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); | 417 | .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); |
418 | return false; | 418 | return false; |
419 | } | 419 | } |
420 | 420 | ||
421 | if (!mEndDateEdit->inputIsValid()) { | 421 | if (!mEndDateEdit->inputIsValid()) { |
422 | KMessageBox::sorry( 0, | 422 | KMessageBox::sorry( 0, |
423 | i18n("Please specify a valid end date,\nfor example '%1'.") | 423 | i18n("Please specify a valid end date,\nfor example '%1'.") |
424 | .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); | 424 | .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); |
425 | return false; | 425 | return false; |
426 | } | 426 | } |
427 | 427 | ||
428 | QDateTime startDt,endDt; | 428 | QDateTime startDt,endDt; |
429 | startDt.setDate(mStartDateEdit->date()); | 429 | startDt.setDate(mStartDateEdit->date()); |
430 | endDt.setDate(mEndDateEdit->date()); | 430 | endDt.setDate(mEndDateEdit->date()); |
431 | if (!mNoTimeButton->isChecked()) { | 431 | if (!mNoTimeButton->isChecked()) { |
432 | startDt.setTime(mStartTimeEdit->getTime()); | 432 | startDt.setTime(mStartTimeEdit->getTime()); |