Diffstat (limited to 'korganizer/koeditorgeneralevent.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | korganizer/koeditorgeneralevent.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp index d4aa78c..3b2a276 100644 --- a/korganizer/koeditorgeneralevent.cpp +++ b/korganizer/koeditorgeneralevent.cpp | |||
@@ -49,192 +49,195 @@ | |||
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)),mStartTimeEdit,SLOT(setTime(QTime))); | ||
146 | connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),mEndTimeEdit,SLOT(setTime(QTime))); | ||
147 | |||
145 | } | 148 | } |
146 | 149 | ||
147 | void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) | 150 | void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) |
148 | { | 151 | { |
149 | QBoxLayout *classLayout = new QHBoxLayout(topLayout); | 152 | QBoxLayout *classLayout = new QHBoxLayout(topLayout); |
150 | 153 | ||
151 | QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); | 154 | QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); |
152 | classLayout->addWidget(freeTimeLabel); | 155 | classLayout->addWidget(freeTimeLabel); |
153 | 156 | ||
154 | mFreeTimeCombo = new QComboBox(false, parent); | 157 | mFreeTimeCombo = new QComboBox(false, parent); |
155 | mFreeTimeCombo->insertItem(i18n("Busy")); | 158 | mFreeTimeCombo->insertItem(i18n("Busy")); |
156 | mFreeTimeCombo->insertItem(i18n("Free")); | 159 | mFreeTimeCombo->insertItem(i18n("Free")); |
157 | classLayout->addWidget(mFreeTimeCombo); | 160 | classLayout->addWidget(mFreeTimeCombo); |
158 | } | 161 | } |
159 | 162 | ||
160 | void KOEditorGeneralEvent::timeStuffDisable(bool disable) | 163 | void KOEditorGeneralEvent::timeStuffDisable(bool disable) |
161 | { | 164 | { |
162 | mStartTimeEdit->setEnabled( !disable ); | 165 | mStartTimeEdit->setEnabled( !disable ); |
163 | mEndTimeEdit->setEnabled( !disable ); | 166 | mEndTimeEdit->setEnabled( !disable ); |
164 | 167 | ||
165 | setDuration(); | 168 | setDuration(); |
166 | emitDateTimeStr(); | 169 | emitDateTimeStr(); |
167 | } | 170 | } |
168 | 171 | ||
169 | void KOEditorGeneralEvent::dontAssociateTime(bool noTime) | 172 | void KOEditorGeneralEvent::dontAssociateTime(bool noTime) |
170 | { | 173 | { |
171 | timeStuffDisable(noTime); | 174 | timeStuffDisable(noTime); |
172 | //if(alarmButton->isChecked()) alarmStuffDisable(noTime); | 175 | //if(alarmButton->isChecked()) alarmStuffDisable(noTime); |
173 | allDayChanged(noTime); | 176 | allDayChanged(noTime); |
174 | } | 177 | } |
175 | 178 | ||
176 | void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) | 179 | void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) |
177 | { | 180 | { |
178 | // kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; | 181 | // kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; |
179 | if ( !mTemplate ) | 182 | if ( !mTemplate ) |
180 | mStartDateEdit->setDate(start.date()); | 183 | mStartDateEdit->setDate(start.date()); |
181 | // KTimeEdit seems to emit some signals when setTime() is called. | 184 | // KTimeEdit seems to emit some signals when setTime() is called. |
182 | mStartTimeEdit->blockSignals( true ); | 185 | mStartTimeEdit->blockSignals( true ); |
183 | mStartTimeEdit->setTime(start.time()); | 186 | mStartTimeEdit->setTime(start.time()); |
184 | mStartTimeEdit->blockSignals( false ); | 187 | mStartTimeEdit->blockSignals( false ); |
185 | if ( !mTemplate ) | 188 | if ( !mTemplate ) |
186 | mEndDateEdit->setDate(end.date()); | 189 | mEndDateEdit->setDate(end.date()); |
187 | mEndTimeEdit->setTime(end.time()); | 190 | mEndTimeEdit->setTime(end.time()); |
188 | 191 | ||
189 | mCurrStartDateTime = start; | 192 | mCurrStartDateTime = start; |
190 | mCurrEndDateTime = end; | 193 | mCurrEndDateTime = end; |
191 | 194 | ||
192 | setDuration(); | 195 | setDuration(); |
193 | emitDateTimeStr(); | 196 | emitDateTimeStr(); |
194 | } | 197 | } |
195 | 198 | ||
196 | void KOEditorGeneralEvent::startTimeChanged(QTime newtime) | 199 | void KOEditorGeneralEvent::startTimeChanged(QTime newtime) |
197 | { | 200 | { |
198 | kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl; | 201 | kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl; |
199 | 202 | ||
200 | int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); | 203 | int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); |
201 | 204 | ||
202 | mCurrStartDateTime.setTime(newtime); | 205 | mCurrStartDateTime.setTime(newtime); |
203 | 206 | ||
204 | // adjust end time so that the event has the same duration as before. | 207 | // adjust end time so that the event has the same duration as before. |
205 | mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); | 208 | mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); |
206 | mEndTimeEdit->setTime(mCurrEndDateTime.time()); | 209 | mEndTimeEdit->setTime(mCurrEndDateTime.time()); |
207 | mEndDateEdit->setDate(mCurrEndDateTime.date()); | 210 | mEndDateEdit->setDate(mCurrEndDateTime.date()); |
208 | 211 | ||
209 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 212 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
210 | } | 213 | } |
211 | 214 | ||
212 | void KOEditorGeneralEvent::endTimeChanged(QTime newtime) | 215 | void KOEditorGeneralEvent::endTimeChanged(QTime newtime) |
213 | { | 216 | { |
214 | // kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl; | 217 | // kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl; |
215 | 218 | ||
216 | QDateTime newdt(mCurrEndDateTime.date(), newtime); | 219 | QDateTime newdt(mCurrEndDateTime.date(), newtime); |
217 | mCurrEndDateTime = newdt; | 220 | mCurrEndDateTime = newdt; |
218 | 221 | ||
219 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 222 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
220 | } | 223 | } |
221 | 224 | ||
222 | void KOEditorGeneralEvent::startDateChanged(QDate newdate) | 225 | void KOEditorGeneralEvent::startDateChanged(QDate newdate) |
223 | { | 226 | { |
224 | int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); | 227 | int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); |
225 | 228 | ||
226 | mCurrStartDateTime.setDate(newdate); | 229 | mCurrStartDateTime.setDate(newdate); |
227 | 230 | ||
228 | // adjust end date so that the event has the same duration as before | 231 | // adjust end date so that the event has the same duration as before |
229 | mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); | 232 | mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); |
230 | mEndDateEdit->setDate(mCurrEndDateTime.date()); | 233 | mEndDateEdit->setDate(mCurrEndDateTime.date()); |
231 | 234 | ||
232 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); | 235 | emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); |
233 | } | 236 | } |
234 | 237 | ||
235 | void KOEditorGeneralEvent::endDateChanged(QDate newdate) | 238 | void KOEditorGeneralEvent::endDateChanged(QDate newdate) |
236 | { | 239 | { |
237 | QDateTime newdt(newdate, mCurrEndDateTime.time()); | 240 | QDateTime newdt(newdate, mCurrEndDateTime.time()); |
238 | 241 | ||
239 | if(newdt < mCurrStartDateTime) { | 242 | if(newdt < mCurrStartDateTime) { |
240 | // oops, we can't let that happen. | 243 | // oops, we can't let that happen. |