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