-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 24 | ||||
-rw-r--r-- | korganizer/koeditorgeneralevent.h | 1 |
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 | |||
@@ -21,64 +21,65 @@ | |||
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 | ||
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 | 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 | ||
59 | KOEditorGeneralEvent::~KOEditorGeneralEvent() | 60 | KOEditorGeneralEvent::~KOEditorGeneralEvent() |
60 | { | 61 | { |
61 | } | 62 | } |
62 | 63 | ||
63 | void KOEditorGeneralEvent::finishSetup() | 64 | void 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 | ||
@@ -146,71 +147,72 @@ void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) | |||
146 | void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) | 147 | void 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 | ||
159 | void KOEditorGeneralEvent::timeStuffDisable(bool disable) | 160 | void 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 | ||
168 | void KOEditorGeneralEvent::dontAssociateTime(bool noTime) | 169 | void 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 | ||
175 | void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) | 176 | void 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 | ||
194 | void KOEditorGeneralEvent::startTimeChanged(QTime newtime) | 196 | void 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 | ||
210 | void KOEditorGeneralEvent::endTimeChanged(QTime newtime) | 212 | void 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 | ||
@@ -232,72 +234,72 @@ void KOEditorGeneralEvent::startDateChanged(QDate newdate) | |||
232 | 234 | ||
233 | void KOEditorGeneralEvent::endDateChanged(QDate newdate) | 235 | void 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 | ||
248 | void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay) | 250 | void 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 | ||
260 | void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl ) | 262 | void 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 | ||
286 | void KOEditorGeneralEvent::writeEvent(Event *event) | 288 | void 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); |
diff --git a/korganizer/koeditorgeneralevent.h b/korganizer/koeditorgeneralevent.h index 188dc93..0174788 100644 --- a/korganizer/koeditorgeneralevent.h +++ b/korganizer/koeditorgeneralevent.h | |||
@@ -61,48 +61,49 @@ class KOEditorGeneralEvent : public KOEditorGeneral | |||
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 |