-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 52 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.h | 2 |
2 files changed, 44 insertions, 10 deletions
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index b9a028b..ce0d7a9 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp | |||
@@ -23,437 +23,469 @@ | |||
23 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qfiledialog.h> | 25 | #include <qfiledialog.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | 32 | ||
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 <kdebug.h> | 37 | #include <kdebug.h> |
38 | #include <krestrictedline.h> | 38 | #include <krestrictedline.h> |
39 | #include <kstandarddirs.h> | 39 | #include <kstandarddirs.h> |
40 | #include <kfiledialog.h> | 40 | #include <kfiledialog.h> |
41 | 41 | ||
42 | #include <libkcal/todo.h> | 42 | #include <libkcal/todo.h> |
43 | 43 | ||
44 | #include <libkdepim/kdateedit.h> | 44 | #include <libkdepim/kdateedit.h> |
45 | 45 | ||
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "ktimeedit.h" | 47 | #include "ktimeedit.h" |
48 | 48 | ||
49 | #include "koeditorgeneraltodo.h" | 49 | #include "koeditorgeneraltodo.h" |
50 | #include "kolocationbox.h" | 50 | #include "kolocationbox.h" |
51 | 51 | ||
52 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, | 52 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, |
53 | const char* name) | 53 | const char* name) |
54 | : KOEditorGeneral( parent, name) | 54 | : KOEditorGeneral( parent, name) |
55 | { | 55 | { |
56 | } | 56 | } |
57 | 57 | ||
58 | KOEditorGeneralTodo::~KOEditorGeneralTodo() | 58 | KOEditorGeneralTodo::~KOEditorGeneralTodo() |
59 | { | 59 | { |
60 | } | 60 | } |
61 | 61 | ||
62 | void KOEditorGeneralTodo::finishSetup() | 62 | void KOEditorGeneralTodo::finishSetup() |
63 | { | 63 | { |
64 | 64 | ||
65 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); | 65 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); |
66 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); | 66 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); |
67 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); | 67 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); |
68 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); | 68 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); |
69 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); | 69 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); |
70 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); | 70 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); |
71 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); | 71 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); |
72 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); | 72 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); |
73 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); | 73 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); |
74 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); | 74 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); |
75 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); | 75 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); |
76 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); | 76 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); |
77 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); | 77 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); |
78 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); | 78 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); |
79 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 79 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
80 | mSummaryEdit->setFocus(); | 80 | mSummaryEdit->setFocus(); |
81 | } | 81 | } |
82 | 82 | ||
83 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) | 83 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) |
84 | { | 84 | { |
85 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); | 85 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); |
86 | 86 | ||
87 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, | 87 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, |
88 | i18n("Date && Time"),parent); | 88 | i18n("Date && Time"),parent); |
89 | timeLayout->addWidget(timeGroupBox); | 89 | timeLayout->addWidget(timeGroupBox); |
90 | timeGroupBox->layout()->setSpacing( 0 ); | 90 | timeGroupBox->layout()->setSpacing( 0 ); |
91 | timeGroupBox->layout()->setMargin( 5 ); | 91 | timeGroupBox->layout()->setMargin( 5 ); |
92 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); | 92 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); |
93 | 93 | ||
94 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); | 94 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); |
95 | layoutTimeBox->setSpacing(topLayout->spacing()); | 95 | layoutTimeBox->setSpacing(topLayout->spacing()); |
96 | layoutTimeBox->setColStretch( 1, 1 ); | 96 | layoutTimeBox->setColStretch( 1, 1 ); |
97 | 97 | ||
98 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); | 98 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); |
99 | layoutTimeBox->addWidget(mDueCheck,0,0); | 99 | layoutTimeBox->addWidget(mDueCheck,0,0); |
100 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); | 100 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); |
101 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); | 101 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); |
102 | 102 | ||
103 | 103 | ||
104 | mDueDateEdit = new KDateEdit(timeBoxFrame); | 104 | mDueDateEdit = new KDateEdit(timeBoxFrame); |
105 | layoutTimeBox->addWidget(mDueDateEdit,0,1); | 105 | layoutTimeBox->addWidget(mDueDateEdit,0,1); |
106 | 106 | ||
107 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); | 107 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); |
108 | layoutTimeBox->addWidget(mDueTimeEdit,0,2); | 108 | layoutTimeBox->addWidget(mDueTimeEdit,0,2); |
109 | 109 | ||
110 | 110 | ||
111 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); | 111 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); |
112 | layoutTimeBox->addWidget(mStartCheck,1,0); | 112 | layoutTimeBox->addWidget(mStartCheck,1,0); |
113 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); | 113 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); |
114 | 114 | ||
115 | mStartDateEdit = new KDateEdit(timeBoxFrame); | 115 | mStartDateEdit = new KDateEdit(timeBoxFrame); |
116 | layoutTimeBox->addWidget(mStartDateEdit,1,1); | 116 | layoutTimeBox->addWidget(mStartDateEdit,1,1); |
117 | 117 | ||
118 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); | 118 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); |
119 | layoutTimeBox->addWidget(mStartTimeEdit,1,2); | 119 | layoutTimeBox->addWidget(mStartTimeEdit,1,2); |
120 | 120 | ||
121 | 121 | ||
122 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); | 122 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); |
123 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); | 123 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); |
124 | 124 | ||
125 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); | 125 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); |
126 | 126 | ||
127 | // some more layouting | 127 | // some more layouting |
128 | //layoutTimeBox->setColStretch(3,1); | 128 | //layoutTimeBox->setColStretch(3,1); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) | 132 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) |
133 | { | 133 | { |
134 | mCompletedCombo = new QComboBox(parent); | 134 | mCompletedCombo = new QComboBox(parent); |
135 | // xgettext:no-c-format | 135 | // xgettext:no-c-format |
136 | mCompletedCombo->insertItem(i18n(" 0 %")); | 136 | mCompletedCombo->insertItem(i18n(" 0 %")); |
137 | // xgettext:no-c-format | 137 | // xgettext:no-c-format |
138 | mCompletedCombo->insertItem(i18n(" 20 %")); | 138 | mCompletedCombo->insertItem(i18n(" 20 %")); |
139 | // xgettext:no-c-format | 139 | // xgettext:no-c-format |
140 | mCompletedCombo->insertItem(i18n(" 40 %")); | 140 | mCompletedCombo->insertItem(i18n(" 40 %")); |
141 | // xgettext:no-c-format | 141 | // xgettext:no-c-format |
142 | mCompletedCombo->insertItem(i18n(" 60 %")); | 142 | mCompletedCombo->insertItem(i18n(" 60 %")); |
143 | // xgettext:no-c-format | 143 | // xgettext:no-c-format |
144 | mCompletedCombo->insertItem(i18n(" 80 %")); | 144 | mCompletedCombo->insertItem(i18n(" 80 %")); |
145 | // xgettext:no-c-format | 145 | // xgettext:no-c-format |
146 | mCompletedCombo->insertItem(i18n("100 %")); | 146 | mCompletedCombo->insertItem(i18n("100 %")); |
147 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); | 147 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); |
148 | topLayout->addWidget(mCompletedCombo); | 148 | topLayout->addWidget(mCompletedCombo); |
149 | 149 | ||
150 | mCompletedLabel = new QLabel(i18n("completed"),parent); | 150 | mCompletedLabel = new QLabel(i18n("completed"),parent); |
151 | topLayout->addWidget(mCompletedLabel); | 151 | topLayout->addWidget(mCompletedLabel); |
152 | |||
153 | mCompleteDateEdit = new KDateEdit(parent); | ||
154 | topLayout->addWidget(mCompleteDateEdit ); | ||
155 | |||
156 | mCompleteTimeEdit = new KOTimeEdit(parent); | ||
157 | topLayout->addWidget( mCompleteTimeEdit); | ||
158 | |||
159 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); | ||
160 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); | ||
161 | |||
162 | if ( QApplication::desktop()->width() < 320 ) { | ||
163 | mCompleteDateEdit->setMaximumWidth( 85 ); | ||
164 | topLayout->setSpacing( 0 ); | ||
165 | } | ||
152 | } | 166 | } |
153 | 167 | ||
154 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) | 168 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) |
155 | { | 169 | { |
156 | 170 | ||
157 | QHBox* h = new QHBox ( parent ); | 171 | QHBox* h = new QHBox ( parent ); |
158 | topLayout->addWidget( h ); | 172 | topLayout->addWidget( h ); |
159 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); | 173 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); |
160 | // topLayout->addWidget(priorityLabel); | 174 | // topLayout->addWidget(priorityLabel); |
161 | |||
162 | mPriorityCombo = new QComboBox( h ); | 175 | mPriorityCombo = new QComboBox( h ); |
163 | mPriorityCombo->insertItem(i18n("1 (high)")); | 176 | mPriorityCombo->insertItem(i18n("1 (high)")); |
164 | mPriorityCombo->insertItem(i18n("2")); | 177 | mPriorityCombo->insertItem(i18n("2")); |
165 | mPriorityCombo->insertItem(i18n("3")); | 178 | mPriorityCombo->insertItem(i18n("3")); |
166 | mPriorityCombo->insertItem(i18n("4")); | 179 | mPriorityCombo->insertItem(i18n("4")); |
167 | mPriorityCombo->insertItem(i18n("5 (low)")); | 180 | mPriorityCombo->insertItem(i18n("5 (low)")); |
168 | //topLayout->addWidget(mPriorityCombo); | 181 | //topLayout->addWidget(mPriorityCombo); |
169 | } | 182 | } |
170 | 183 | ||
171 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) | 184 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) |
172 | { | 185 | { |
173 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); | 186 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); |
174 | 187 | ||
175 | initCompletion( parent, statusLayout ); | 188 | initCompletion( parent, statusLayout ); |
176 | 189 | ||
177 | statusLayout->addStretch( 1 ); | 190 | statusLayout->addStretch( 1 ); |
178 | 191 | ||
179 | initPriority( parent, statusLayout ); | 192 | initPriority( parent, statusLayout ); |
180 | } | 193 | } |
181 | 194 | ||
182 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) | 195 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) |
183 | { | 196 | { |
184 | 197 | ||
185 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 198 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
186 | mLocationEdit->load(KOLocationBox::LOCATION); | 199 | mLocationEdit->load(KOLocationBox::LOCATION); |
187 | KOEditorGeneral::setDefaults(allDay); | 200 | KOEditorGeneral::setDefaults(allDay); |
188 | 201 | ||
189 | mTimeButton->setChecked( !allDay ); | 202 | mTimeButton->setChecked( !allDay ); |
190 | if(mTimeButton->isChecked()) { | 203 | if(mTimeButton->isChecked()) { |
191 | mTimeButton->setEnabled(true); | 204 | mTimeButton->setEnabled(true); |
192 | } | 205 | } |
193 | else { | 206 | else { |
194 | mTimeButton->setEnabled(false); | 207 | mTimeButton->setEnabled(false); |
195 | } | 208 | } |
196 | 209 | ||
197 | enableTimeEdits( !allDay ); | 210 | enableTimeEdits( !allDay ); |
198 | if ( due.isValid() ) { | 211 | if ( due.isValid() ) { |
199 | mDueCheck->setChecked(true); | 212 | mDueCheck->setChecked(true); |
200 | enableDueEdit(true); | 213 | enableDueEdit(true); |
201 | } else { | 214 | } else { |
202 | mDueCheck->setChecked(false); | 215 | mDueCheck->setChecked(false); |
203 | enableDueEdit(false); | 216 | enableDueEdit(false); |
204 | due = QDateTime::currentDateTime().addDays(7); | 217 | due = QDateTime::currentDateTime().addDays(7); |
205 | } | 218 | } |
206 | 219 | ||
207 | alarmDisable(true); | 220 | alarmDisable(true); |
208 | 221 | ||
209 | mStartCheck->setChecked(false); | 222 | mStartCheck->setChecked(false); |
210 | enableStartEdit(false); | 223 | enableStartEdit(false); |
211 | 224 | ||
212 | mDueDateEdit->setDate(due.date()); | 225 | mDueDateEdit->setDate(due.date()); |
213 | mDueTimeEdit->setTime(due.time()); | 226 | mDueTimeEdit->setTime(due.time()); |
214 | due = due.addDays(-7); | 227 | due = due.addDays(-7); |
215 | mStartDateEdit->setDate(due.date()); | 228 | mStartDateEdit->setDate(due.date()); |
216 | mStartTimeEdit->setTime(due.time()); | 229 | mStartTimeEdit->setTime(due.time()); |
217 | 230 | ||
218 | mPriorityCombo->setCurrentItem(2); | 231 | mPriorityCombo->setCurrentItem(2); |
219 | mCompletedLabel->setText(i18n("completed"));; | 232 | mCompletedLabel->setText(i18n("completed"));; |
220 | mCompletedCombo->setCurrentItem(0); | 233 | mCompletedCombo->setCurrentItem(0); |
221 | } | 234 | } |
222 | 235 | ||
223 | void KOEditorGeneralTodo::readTodo(Todo *todo) | 236 | void KOEditorGeneralTodo::readTodo(Todo *todo) |
224 | { | 237 | { |
225 | 238 | ||
226 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 239 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
227 | mLocationEdit->load(KOLocationBox::LOCATION); | 240 | mLocationEdit->load(KOLocationBox::LOCATION); |
228 | KOEditorGeneral::readIncidence(todo); | 241 | KOEditorGeneral::readIncidence(todo); |
229 | 242 | ||
230 | QDateTime dueDT; | 243 | QDateTime dueDT; |
231 | 244 | ||
232 | if (todo->hasDueDate()) { | 245 | if (todo->hasDueDate()) { |
233 | enableAlarmEdit(true); | 246 | enableAlarmEdit(true); |
234 | dueDT = todo->dtDue(); | 247 | dueDT = todo->dtDue(); |
235 | mDueDateEdit->setDate(todo->dtDue().date()); | 248 | mDueDateEdit->setDate(todo->dtDue().date()); |
236 | mDueTimeEdit->setTime(todo->dtDue().time()); | 249 | mDueTimeEdit->setTime(todo->dtDue().time()); |
237 | mDueCheck->setChecked(true); | 250 | mDueCheck->setChecked(true); |
238 | } else { | 251 | } else { |
239 | alarmDisable(true); | 252 | alarmDisable(true); |
240 | mDueDateEdit->setEnabled(false); | 253 | mDueDateEdit->setEnabled(false); |
241 | mDueTimeEdit->setEnabled(false); | 254 | mDueTimeEdit->setEnabled(false); |
242 | mDueDateEdit->setDate(QDate::currentDate()); | 255 | mDueDateEdit->setDate(QDate::currentDate()); |
243 | mDueTimeEdit->setTime(QTime::currentTime()); | 256 | mDueTimeEdit->setTime(QTime::currentTime()); |
244 | mDueCheck->setChecked(false); | 257 | mDueCheck->setChecked(false); |
245 | } | 258 | } |
246 | 259 | ||
247 | if (todo->hasStartDate()) { | 260 | if (todo->hasStartDate()) { |
248 | mStartDateEdit->setDate(todo->dtStart().date()); | 261 | mStartDateEdit->setDate(todo->dtStart().date()); |
249 | mStartTimeEdit->setTime(todo->dtStart().time()); | 262 | mStartTimeEdit->setTime(todo->dtStart().time()); |
250 | mStartCheck->setChecked(true); | 263 | mStartCheck->setChecked(true); |
251 | } else { | 264 | } else { |
252 | mStartDateEdit->setEnabled(false); | 265 | mStartDateEdit->setEnabled(false); |
253 | mStartTimeEdit->setEnabled(false); | 266 | mStartTimeEdit->setEnabled(false); |
254 | mStartDateEdit->setDate(QDate::currentDate()); | 267 | mStartDateEdit->setDate(QDate::currentDate()); |
255 | mStartTimeEdit->setTime(QTime::currentTime()); | 268 | mStartTimeEdit->setTime(QTime::currentTime()); |
256 | mStartCheck->setChecked(false); | 269 | mStartCheck->setChecked(false); |
257 | } | 270 | } |
258 | 271 | ||
259 | mTimeButton->setChecked( !todo->doesFloat() ); | 272 | mTimeButton->setChecked( !todo->doesFloat() ); |
260 | 273 | ||
261 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 274 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
262 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 275 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
263 | mCompleted = todo->completed(); | 276 | mCompleted = todo->completed(); |
264 | } | 277 | } |
265 | setCompletedDate(); | 278 | setCompletedDate(); |
266 | 279 | ||
267 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 280 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
268 | } | 281 | } |
269 | 282 | ||
270 | void KOEditorGeneralTodo::writeTodo(Todo *todo) | 283 | void KOEditorGeneralTodo::writeTodo(Todo *todo) |
271 | { | 284 | { |
272 | KOEditorGeneral::writeIncidence(todo); | 285 | KOEditorGeneral::writeIncidence(todo); |
273 | 286 | ||
274 | // temp. until something better happens. | 287 | // temp. until something better happens. |
275 | QString tmpStr; | 288 | QString tmpStr; |
276 | 289 | ||
277 | todo->setHasDueDate(mDueCheck->isChecked()); | 290 | todo->setHasDueDate(mDueCheck->isChecked()); |
278 | todo->setHasStartDate(mStartCheck->isChecked()); | 291 | todo->setHasStartDate(mStartCheck->isChecked()); |
279 | 292 | ||
280 | QDate tmpDate; | 293 | QDate tmpDate; |
281 | QTime tmpTime; | 294 | QTime tmpTime; |
282 | QDateTime tmpDT; | 295 | QDateTime tmpDT; |
283 | if ( mTimeButton->isChecked() ) { | 296 | if ( mTimeButton->isChecked() ) { |
284 | todo->setFloats(false); | 297 | todo->setFloats(false); |
285 | 298 | ||
286 | // set due date/time | 299 | // set due date/time |
287 | tmpDate = mDueDateEdit->date(); | 300 | tmpDate = mDueDateEdit->date(); |
288 | tmpTime = mDueTimeEdit->getTime(); | 301 | tmpTime = mDueTimeEdit->getTime(); |
289 | tmpDT.setDate(tmpDate); | 302 | tmpDT.setDate(tmpDate); |
290 | tmpDT.setTime(tmpTime); | 303 | tmpDT.setTime(tmpTime); |
291 | todo->setDtDue(tmpDT); | 304 | todo->setDtDue(tmpDT); |
292 | 305 | ||
293 | // set start date/time | 306 | // set start date/time |
294 | tmpDate = mStartDateEdit->date(); | 307 | tmpDate = mStartDateEdit->date(); |
295 | tmpTime = mStartTimeEdit->getTime(); | 308 | tmpTime = mStartTimeEdit->getTime(); |
296 | tmpDT.setDate(tmpDate); | 309 | tmpDT.setDate(tmpDate); |
297 | tmpDT.setTime(tmpTime); | 310 | tmpDT.setTime(tmpTime); |
298 | todo->setDtStart(tmpDT); | 311 | todo->setDtStart(tmpDT); |
299 | } else { | 312 | } else { |
300 | todo->setFloats(true); | 313 | todo->setFloats(true); |
301 | 314 | ||
302 | // need to change this. | 315 | // need to change this. |
303 | tmpDate = mDueDateEdit->date(); | 316 | tmpDate = mDueDateEdit->date(); |
304 | tmpTime.setHMS(0,0,0); | 317 | tmpTime.setHMS(0,0,0); |
305 | tmpDT.setDate(tmpDate); | 318 | tmpDT.setDate(tmpDate); |
306 | tmpDT.setTime(tmpTime); | 319 | tmpDT.setTime(tmpTime); |
307 | todo->setDtDue(tmpDT); | 320 | todo->setDtDue(tmpDT); |
308 | 321 | ||
309 | tmpDate = mStartDateEdit->date(); | 322 | tmpDate = mStartDateEdit->date(); |
310 | tmpTime.setHMS(0,0,0); | 323 | tmpTime.setHMS(0,0,0); |
311 | tmpDT.setDate(tmpDate); | 324 | tmpDT.setDate(tmpDate); |
312 | tmpDT.setTime(tmpTime); | 325 | tmpDT.setTime(tmpTime); |
313 | todo->setDtStart(tmpDT); | 326 | todo->setDtStart(tmpDT); |
314 | } | 327 | } |
315 | |||
316 | todo->setPriority(mPriorityCombo->currentItem()+1); | 328 | todo->setPriority(mPriorityCombo->currentItem()+1); |
317 | 329 | ||
318 | // set completion state | 330 | // set completion state |
319 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | 331 | if ( mCompletedCombo->currentItem() == 5 ) { |
320 | 332 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); | |
321 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { | 333 | if ( comp.isValid () ) { |
322 | todo->setCompleted(mCompleted); | 334 | todo->setPercentComplete(0); |
335 | todo->setPercentComplete(100); | ||
336 | todo->setCompleted(comp); | ||
337 | } else { | ||
338 | todo->setPercentComplete( 100 ); | ||
339 | if ( mCompleted.isValid() ) | ||
340 | todo->setCompleted(mCompleted); | ||
341 | } | ||
342 | } else { | ||
343 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | ||
323 | } | 344 | } |
345 | |||
324 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); | 346 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); |
325 | } | 347 | } |
326 | 348 | ||
327 | void KOEditorGeneralTodo::enableDueEdit(bool enable) | 349 | void KOEditorGeneralTodo::enableDueEdit(bool enable) |
328 | { | 350 | { |
329 | mDueDateEdit->setEnabled( enable ); | 351 | mDueDateEdit->setEnabled( enable ); |
330 | 352 | ||
331 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 353 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
332 | mTimeButton->setEnabled(true); | 354 | mTimeButton->setEnabled(true); |
333 | } | 355 | } |
334 | else { | 356 | else { |
335 | mTimeButton->setEnabled(false); | 357 | mTimeButton->setEnabled(false); |
336 | mTimeButton->setChecked(false); | 358 | mTimeButton->setChecked(false); |
337 | } | 359 | } |
338 | 360 | ||
339 | if (enable) { | 361 | if (enable) { |
340 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); | 362 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); |
341 | } else { | 363 | } else { |
342 | mDueTimeEdit->setEnabled( false ); | 364 | mDueTimeEdit->setEnabled( false ); |
343 | } | 365 | } |
344 | } | 366 | } |
345 | 367 | ||
346 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) | 368 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) |
347 | { | 369 | { |
348 | mStartDateEdit->setEnabled( enable ); | 370 | mStartDateEdit->setEnabled( enable ); |
349 | 371 | ||
350 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 372 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
351 | mTimeButton->setEnabled(true); | 373 | mTimeButton->setEnabled(true); |
352 | } | 374 | } |
353 | else { | 375 | else { |
354 | mTimeButton->setEnabled(false); | 376 | mTimeButton->setEnabled(false); |
355 | mTimeButton->setChecked(false); | 377 | mTimeButton->setChecked(false); |
356 | } | 378 | } |
357 | 379 | ||
358 | if (enable) { | 380 | if (enable) { |
359 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); | 381 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); |
360 | } else { | 382 | } else { |
361 | mStartTimeEdit->setEnabled( false ); | 383 | mStartTimeEdit->setEnabled( false ); |
362 | } | 384 | } |
363 | } | 385 | } |
364 | 386 | ||
365 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) | 387 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) |
366 | { | 388 | { |
367 | if(mStartCheck->isChecked()) { | 389 | if(mStartCheck->isChecked()) { |
368 | mStartTimeEdit->setEnabled( enable ); | 390 | mStartTimeEdit->setEnabled( enable ); |
369 | } | 391 | } |
370 | if(mDueCheck->isChecked()) { | 392 | if(mDueCheck->isChecked()) { |
371 | mDueTimeEdit->setEnabled( enable ); | 393 | mDueTimeEdit->setEnabled( enable ); |
372 | } | 394 | } |
373 | } | 395 | } |
374 | 396 | ||
375 | void KOEditorGeneralTodo::showAlarm() | 397 | void KOEditorGeneralTodo::showAlarm() |
376 | { | 398 | { |
377 | if ( mDueCheck->isChecked() ) { | 399 | if ( mDueCheck->isChecked() ) { |
378 | alarmDisable(false); | 400 | alarmDisable(false); |
379 | } | 401 | } |
380 | else { | 402 | else { |
381 | alarmDisable(true); | 403 | alarmDisable(true); |
382 | } | 404 | } |
383 | } | 405 | } |
384 | 406 | ||
385 | bool KOEditorGeneralTodo::validateInput() | 407 | bool KOEditorGeneralTodo::validateInput() |
386 | { | 408 | { |
387 | if (mDueCheck->isChecked()) { | 409 | if (mDueCheck->isChecked()) { |
388 | if (!mDueDateEdit->inputIsValid()) { | 410 | if (!mDueDateEdit->inputIsValid()) { |
389 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); | 411 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); |
390 | return false; | 412 | return false; |
391 | } | 413 | } |
392 | } | 414 | } |
393 | 415 | ||
394 | if (mStartCheck->isChecked()) { | 416 | if (mStartCheck->isChecked()) { |
395 | if (!mStartDateEdit->inputIsValid()) { | 417 | if (!mStartDateEdit->inputIsValid()) { |
396 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); | 418 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); |
397 | return false; | 419 | return false; |
398 | } | 420 | } |
399 | } | 421 | } |
400 | 422 | ||
401 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { | 423 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { |
402 | QDateTime startDate; | 424 | QDateTime startDate; |
403 | QDateTime dueDate; | 425 | QDateTime dueDate; |
404 | startDate.setDate(mStartDateEdit->date()); | 426 | startDate.setDate(mStartDateEdit->date()); |
405 | dueDate.setDate(mDueDateEdit->date()); | 427 | dueDate.setDate(mDueDateEdit->date()); |
406 | if (mTimeButton->isChecked()) { | 428 | if (mTimeButton->isChecked()) { |
407 | startDate.setTime(mStartTimeEdit->getTime()); | 429 | startDate.setTime(mStartTimeEdit->getTime()); |
408 | dueDate.setTime(mDueTimeEdit->getTime()); | 430 | dueDate.setTime(mDueTimeEdit->getTime()); |
409 | } | 431 | } |
410 | if (startDate > dueDate) { | 432 | if (startDate > dueDate) { |
411 | KMessageBox::sorry(0, | 433 | KMessageBox::sorry(0, |
412 | i18n("The start date cannot be after the due date.")); | 434 | i18n("The start date cannot be after the due date.")); |
413 | return false; | 435 | return false; |
414 | } | 436 | } |
415 | } | 437 | } |
416 | 438 | ||
417 | return KOEditorGeneral::validateInput(); | 439 | return KOEditorGeneral::validateInput(); |
418 | } | 440 | } |
419 | 441 | ||
420 | void KOEditorGeneralTodo::completedChanged(int index) | 442 | void KOEditorGeneralTodo::completedChanged(int index) |
421 | { | 443 | { |
422 | if (index == 5) { | 444 | if (index == 5) { |
423 | mCompleted = QDateTime::currentDateTime(); | 445 | //get rid of milli sec |
446 | mCompleted = QDateTime::currentDateTime(); | ||
424 | } | 447 | } |
425 | setCompletedDate(); | 448 | setCompletedDate(); |
426 | } | 449 | } |
427 | 450 | ||
428 | void KOEditorGeneralTodo::setCompletedDate() | 451 | void KOEditorGeneralTodo::setCompletedDate() |
429 | { | 452 | { |
430 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { | 453 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { |
431 | mCompletedLabel->setText(i18n("completed on %1") | 454 | if ( QApplication::desktop()->width() < 480 ) { |
432 | .arg(KGlobal::locale()->formatDateTime(mCompleted))); | 455 | mCompletedLabel->setText(i18n(" on")); |
456 | } | ||
457 | else | ||
458 | mCompletedLabel->setText(i18n(" completed on ")); | ||
459 | mCompleteDateEdit->show(); | ||
460 | mCompleteTimeEdit->show(); | ||
461 | mCompleteTimeEdit->setTime( mCompleted.time() ); | ||
462 | mCompleteDateEdit->setDate( mCompleted.date() ); | ||
433 | } else { | 463 | } else { |
434 | mCompletedLabel->setText(i18n("completed")); | 464 | mCompletedLabel->setText(i18n("completed")); |
465 | mCompleteDateEdit->hide(); | ||
466 | mCompleteTimeEdit->hide(); | ||
435 | } | 467 | } |
436 | } | 468 | } |
437 | 469 | ||
438 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) | 470 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) |
439 | { | 471 | { |
440 | switch (modification) { | 472 | switch (modification) { |
441 | case KOGlobals::PRIORITY_MODIFIED: | 473 | case KOGlobals::PRIORITY_MODIFIED: |
442 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 474 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
443 | break; | 475 | break; |
444 | case KOGlobals::COMPLETION_MODIFIED: | 476 | case KOGlobals::COMPLETION_MODIFIED: |
445 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 477 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
446 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 478 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
447 | mCompleted = todo->completed(); | 479 | mCompleted = todo->completed(); |
448 | } | 480 | } |
449 | setCompletedDate(); | 481 | setCompletedDate(); |
450 | break; | 482 | break; |
451 | case KOGlobals::CATEGORY_MODIFIED: | 483 | case KOGlobals::CATEGORY_MODIFIED: |
452 | setCategories (todo->categoriesStr ()); | 484 | setCategories (todo->categoriesStr ()); |
453 | break; | 485 | break; |
454 | case KOGlobals::UNKNOWN_MODIFIED: // fall through | 486 | case KOGlobals::UNKNOWN_MODIFIED: // fall through |
455 | default: | 487 | default: |
456 | readTodo( todo ); | 488 | readTodo( todo ); |
457 | break; | 489 | break; |
458 | } | 490 | } |
459 | } | 491 | } |
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h index 5f1c3cc..98f43dd 100644 --- a/korganizer/koeditorgeneraltodo.h +++ b/korganizer/koeditorgeneraltodo.h | |||
@@ -1,106 +1,108 @@ | |||
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 _KOEDITORGENERALTODO_H | 23 | #ifndef _KOEDITORGENERALTODO_H |
24 | #define _KOEDITORGENERALTODO_H | 24 | #define _KOEDITORGENERALTODO_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 "koeditorgeneral.h" | 37 | #include "koeditorgeneral.h" |
38 | #include "koglobals.h" | 38 | #include "koglobals.h" |
39 | 39 | ||
40 | class KRestrictedLine; | 40 | class KRestrictedLine; |
41 | 41 | ||
42 | class KDateEdit; | 42 | class KDateEdit; |
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | class KOEditorGeneralTodo : public KOEditorGeneral | 46 | class KOEditorGeneralTodo : public KOEditorGeneral |
47 | { | 47 | { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | KOEditorGeneralTodo (QObject* parent=0,const char* name=0); | 50 | KOEditorGeneralTodo (QObject* parent=0,const char* name=0); |
51 | virtual ~KOEditorGeneralTodo(); | 51 | virtual ~KOEditorGeneralTodo(); |
52 | 52 | ||
53 | void initTime(QWidget *, QBoxLayout *); | 53 | void initTime(QWidget *, QBoxLayout *); |
54 | void initStatus(QWidget *, QBoxLayout *); | 54 | void initStatus(QWidget *, QBoxLayout *); |
55 | void initCompletion(QWidget *, QBoxLayout *); | 55 | void initCompletion(QWidget *, QBoxLayout *); |
56 | void initPriority(QWidget *, QBoxLayout *); | 56 | void initPriority(QWidget *, QBoxLayout *); |
57 | 57 | ||
58 | void finishSetup(); | 58 | void finishSetup(); |
59 | 59 | ||
60 | /** Set widgets to default values */ | 60 | /** Set widgets to default values */ |
61 | void setDefaults(QDateTime due,bool allDay); | 61 | void setDefaults(QDateTime due,bool allDay); |
62 | /** Read todo object and setup widgets accordingly */ | 62 | /** Read todo object and setup widgets accordingly */ |
63 | void readTodo(Todo *); | 63 | void readTodo(Todo *); |
64 | /** Write todo settings to event object */ | 64 | /** Write todo settings to event object */ |
65 | void writeTodo(Todo *); | 65 | void writeTodo(Todo *); |
66 | 66 | ||
67 | /** Check if the input is valid. */ | 67 | /** Check if the input is valid. */ |
68 | bool validateInput(); | 68 | bool validateInput(); |
69 | 69 | ||
70 | /** The todo has been modified externally */ | 70 | /** The todo has been modified externally */ |
71 | void modified (Todo*, int); | 71 | void modified (Todo*, int); |
72 | 72 | ||
73 | signals: | 73 | signals: |
74 | void openCategoryDialog(); | 74 | void openCategoryDialog(); |
75 | 75 | ||
76 | protected slots: | 76 | protected slots: |
77 | void completedChanged(int); | 77 | void completedChanged(int); |
78 | 78 | ||
79 | void enableDueEdit( bool enable ); | 79 | void enableDueEdit( bool enable ); |
80 | void enableStartEdit( bool enable ); | 80 | void enableStartEdit( bool enable ); |
81 | void enableTimeEdits( bool enable ); | 81 | void enableTimeEdits( bool enable ); |
82 | void showAlarm(); | 82 | void showAlarm(); |
83 | 83 | ||
84 | protected: | 84 | protected: |
85 | void setCompletedDate(); | 85 | void setCompletedDate(); |
86 | 86 | ||
87 | private: | 87 | private: |
88 | friend class KOTodoEditor; | 88 | friend class KOTodoEditor; |
89 | KDateEdit *mStartDateEdit; | 89 | KDateEdit *mStartDateEdit; |
90 | KOTimeEdit *mStartTimeEdit; | 90 | KOTimeEdit *mStartTimeEdit; |
91 | KDateEdit *mCompleteDateEdit; | ||
92 | KOTimeEdit *mCompleteTimeEdit; | ||
91 | QCheckBox *mTimeButton; | 93 | QCheckBox *mTimeButton; |
92 | QCheckBox *mDueCheck; | 94 | QCheckBox *mDueCheck; |
93 | KDateEdit *mDueDateEdit; | 95 | KDateEdit *mDueDateEdit; |
94 | KOTimeEdit *mDueTimeEdit; | 96 | KOTimeEdit *mDueTimeEdit; |
95 | QComboBox *mCompletedCombo; | 97 | QComboBox *mCompletedCombo; |
96 | QLabel *mCompletedLabel; | 98 | QLabel *mCompletedLabel; |
97 | QLabel *mPriorityLabel; | 99 | QLabel *mPriorityLabel; |
98 | QComboBox *mPriorityCombo; | 100 | QComboBox *mPriorityCombo; |
99 | 101 | ||
100 | QCheckBox *mStartCheck; | 102 | QCheckBox *mStartCheck; |
101 | 103 | ||
102 | QDateTime mCompleted; | 104 | QDateTime mCompleted; |
103 | }; | 105 | }; |
104 | 106 | ||
105 | 107 | ||
106 | #endif | 108 | #endif |