Diffstat (limited to 'korganizer/koeditorgeneralevent.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp index 3b2a276..af97ee9 100644 --- a/korganizer/koeditorgeneralevent.cpp +++ b/korganizer/koeditorgeneralevent.cpp | |||
@@ -133,27 +133,26 @@ void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) | |||
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)),mStartTimeEdit,SLOT(setTime(QTime))); | 145 | connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime))); |
146 | connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),mEndTimeEdit,SLOT(setTime(QTime))); | 146 | connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime))); |
147 | |||
148 | } | 147 | } |
149 | 148 | ||
150 | void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) | 149 | void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) |
151 | { | 150 | { |
152 | QBoxLayout *classLayout = new QHBoxLayout(topLayout); | 151 | QBoxLayout *classLayout = new QHBoxLayout(topLayout); |
153 | 152 | ||
154 | QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); | 153 | QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); |
155 | classLayout->addWidget(freeTimeLabel); | 154 | classLayout->addWidget(freeTimeLabel); |
156 | 155 | ||
157 | mFreeTimeCombo = new QComboBox(false, parent); | 156 | mFreeTimeCombo = new QComboBox(false, parent); |
158 | mFreeTimeCombo->insertItem(i18n("Busy")); | 157 | mFreeTimeCombo->insertItem(i18n("Busy")); |
159 | mFreeTimeCombo->insertItem(i18n("Free")); | 158 | mFreeTimeCombo->insertItem(i18n("Free")); |
@@ -187,46 +186,53 @@ void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) | |||
187 | mStartTimeEdit->blockSignals( false ); | 186 | mStartTimeEdit->blockSignals( false ); |
188 | if ( !mTemplate ) | 187 | if ( !mTemplate ) |
189 | mEndDateEdit->setDate(end.date()); | 188 | mEndDateEdit->setDate(end.date()); |
190 | mEndTimeEdit->setTime(end.time()); | 189 | mEndTimeEdit->setTime(end.time()); |
191 | 190 | ||
192 | mCurrStartDateTime = start; | 191 | mCurrStartDateTime = start; |
193 | mCurrEndDateTime = end; | 192 | mCurrEndDateTime = end; |
194 | 193 | ||
195 | setDuration(); | 194 | setDuration(); |
196 | emitDateTimeStr(); | 195 | emitDateTimeStr(); |
197 | } | 196 | } |
198 | 197 | ||
198 | void KOEditorGeneralEvent::sTimeChanged(QTime ti) | ||
199 | { | ||
200 | mStartTimeEdit->setTime( ti ); | ||
201 | startTimeChanged ( ti); | ||
202 | } | ||
203 | void KOEditorGeneralEvent::eTimeChanged(QTime ti ) | ||
204 | { | ||
205 | mEndTimeEdit->setTime( ti ); | ||
206 | endTimeChanged( ti ); | ||
207 | } | ||
199 | void KOEditorGeneralEvent::startTimeChanged(QTime newtime) | 208 | void KOEditorGeneralEvent::startTimeChanged(QTime newtime) |
200 | { | 209 | { |
201 | kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl; | ||
202 | 210 | ||
203 | int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); | 211 | int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); |
204 | 212 | ||
205 | mCurrStartDateTime.setTime(newtime); | 213 | mCurrStartDateTime = QDateTime( mStartDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0) ); |
206 | |||
207 | // 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. |
208 | mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); | 215 | if( secsep > 0 ) |
216 | mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); | ||
209 | mEndTimeEdit->setTime(mCurrEndDateTime.time()); | 217 | mEndTimeEdit->setTime(mCurrEndDateTime.time()); |
210 | mEndDateEdit->setDate(mCurrEndDateTime.date()); | 218 | mEndDateEdit->setDate(mCurrEndDateTime.date()); |
211 | 219 | ||
212 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 220 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
213 | } | 221 | } |
214 | 222 | ||
215 | void KOEditorGeneralEvent::endTimeChanged(QTime newtime) | 223 | void KOEditorGeneralEvent::endTimeChanged(QTime newtime) |
216 | { | 224 | { |
217 | // kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl; | ||
218 | 225 | ||
219 | QDateTime newdt(mCurrEndDateTime.date(), newtime); | 226 | mCurrEndDateTime = QDateTime ( mEndDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0)); |
220 | mCurrEndDateTime = newdt; | ||
221 | 227 | ||
222 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 228 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
223 | } | 229 | } |
224 | 230 | ||
225 | void KOEditorGeneralEvent::startDateChanged(QDate newdate) | 231 | void KOEditorGeneralEvent::startDateChanged(QDate newdate) |
226 | { | 232 | { |
227 | int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); | 233 | int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); |
228 | 234 | ||
229 | mCurrStartDateTime.setDate(newdate); | 235 | mCurrStartDateTime.setDate(newdate); |
230 | 236 | ||
231 | // 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 |
232 | mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); | 238 | mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); |