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