author | zautrix <zautrix> | 2005-02-03 19:12:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-03 19:12:28 (UTC) |
commit | 48c87f3c5dcb1c373c812ca6068cfa1417802f27 (patch) (unidiff) | |
tree | a96b3e173a828b2be1d3db1ad528567218518457 | |
parent | fb6753570dc90e936b4e89092554ab012e946a56 (diff) | |
download | kdepimpi-48c87f3c5dcb1c373c812ca6068cfa1417802f27.zip kdepimpi-48c87f3c5dcb1c373c812ca6068cfa1417802f27.tar.gz kdepimpi-48c87f3c5dcb1c373c812ca6068cfa1417802f27.tar.bz2 |
fiihiix
-rw-r--r-- | korganizer/kotodoeditor.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index ec5c2d1..70dfbd1 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,383 +1,383 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1997, 1998 Preston Brown | 3 | Copyright (c) 1997, 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qhbox.h> | 29 | #include <qhbox.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kfiledialog.h> | 36 | #include <kfiledialog.h> |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | 39 | ||
40 | #include <libkdepim/categoryselectdialog.h> | 40 | #include <libkdepim/categoryselectdialog.h> |
41 | #include <libkcal/calendarlocal.h> | 41 | #include <libkcal/calendarlocal.h> |
42 | #include <libkcal/calendarresources.h> | 42 | #include <libkcal/calendarresources.h> |
43 | #include <libkcal/resourcecalendar.h> | 43 | #include <libkcal/resourcecalendar.h> |
44 | #include <libkcal/icalformat.h> | 44 | #include <libkcal/icalformat.h> |
45 | #include <kresources/resourceselectdialog.h> | 45 | #include <kresources/resourceselectdialog.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "kolocationbox.h" | 48 | #include "kolocationbox.h" |
49 | 49 | ||
50 | #include "kotodoeditor.h" | 50 | #include "kotodoeditor.h" |
51 | extern int globalFlagBlockAgenda; | 51 | extern int globalFlagBlockAgenda; |
52 | 52 | ||
53 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 53 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
54 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 54 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
55 | { | 55 | { |
56 | mTodo = 0; | 56 | mTodo = 0; |
57 | mRelatedTodo = 0; | 57 | mRelatedTodo = 0; |
58 | findButton(User1)->hide(); | 58 | findButton(User1)->hide(); |
59 | init(); | 59 | init(); |
60 | } | 60 | } |
61 | 61 | ||
62 | KOTodoEditor::~KOTodoEditor() | 62 | KOTodoEditor::~KOTodoEditor() |
63 | { | 63 | { |
64 | emit dialogClose( mTodo ); | 64 | emit dialogClose( mTodo ); |
65 | } | 65 | } |
66 | 66 | ||
67 | void KOTodoEditor::init() | 67 | void KOTodoEditor::init() |
68 | { | 68 | { |
69 | setupGeneral(); | 69 | setupGeneral(); |
70 | setupAttendeesTab(); | 70 | setupAttendeesTab(); |
71 | } | 71 | } |
72 | void KOTodoEditor::setCategories( QString s ) | 72 | void KOTodoEditor::setCategories( QString s ) |
73 | { | 73 | { |
74 | mGeneral->setCategories(s); | 74 | mGeneral->setCategories(s); |
75 | } | 75 | } |
76 | void KOTodoEditor::setSecrecy( int sec ) | 76 | void KOTodoEditor::setSecrecy( int sec ) |
77 | { | 77 | { |
78 | mGeneral->setSecrecy( sec ); | 78 | mGeneral->setSecrecy( sec ); |
79 | } | 79 | } |
80 | void KOTodoEditor::reload() | 80 | void KOTodoEditor::reload() |
81 | { | 81 | { |
82 | if ( mTodo ) readTodo( mTodo ); | 82 | if ( mTodo ) readTodo( mTodo ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void KOTodoEditor::setupGeneral() | 85 | void KOTodoEditor::setupGeneral() |
86 | { | 86 | { |
87 | mGeneral = new KOEditorGeneralTodo(this); | 87 | mGeneral = new KOEditorGeneralTodo(this); |
88 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 88 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
89 | 89 | ||
90 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 90 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
91 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 91 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
92 | // mGeneral,SLOT(setCategories(const QString &))); | 92 | // mGeneral,SLOT(setCategories(const QString &))); |
93 | 93 | ||
94 | if (KOPrefs::instance()->mCompactDialogs) { | 94 | if (KOPrefs::instance()->mCompactDialogs) { |
95 | QFrame *topFrame = addPage(i18n("General")); | 95 | QFrame *topFrame = addPage(i18n("General")); |
96 | 96 | ||
97 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 97 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
98 | if ( QApplication::desktop()->width() < 480 ) { | 98 | if ( QApplication::desktop()->width() < 480 ) { |
99 | topLayout->setMargin(1); | 99 | topLayout->setMargin(1); |
100 | topLayout->setSpacing(1); | 100 | topLayout->setSpacing(1); |
101 | } else { | 101 | } else { |
102 | topLayout->setMargin(marginHint()-1); | 102 | topLayout->setMargin(marginHint()-1); |
103 | topLayout->setSpacing(spacingHint()-1); | 103 | topLayout->setSpacing(spacingHint()-1); |
104 | } | 104 | } |
105 | mGeneral->initHeader(topFrame,topLayout); | 105 | mGeneral->initHeader(topFrame,topLayout); |
106 | mGeneral->initTime(topFrame,topLayout); | 106 | mGeneral->initTime(topFrame,topLayout); |
107 | mGeneral->initAlarm(topFrame,topLayout); | 107 | mGeneral->initAlarm(topFrame,topLayout); |
108 | mGeneral->enableAlarm( false ); | 108 | mGeneral->enableAlarm( false ); |
109 | 109 | ||
110 | 110 | ||
111 | QBoxLayout *priorityLayout; | 111 | QBoxLayout *priorityLayout; |
112 | if ( QApplication::desktop()->width() < 500 ) | 112 | if ( QApplication::desktop()->width() < 500 ) |
113 | priorityLayout = new QVBoxLayout( topLayout ); | 113 | priorityLayout = new QVBoxLayout( topLayout ); |
114 | else | 114 | else |
115 | priorityLayout = new QHBoxLayout( topLayout ); | 115 | priorityLayout = new QHBoxLayout( topLayout ); |
116 | QWidget* prioWidget = new QWidget (topFrame); | 116 | QWidget* prioWidget = new QWidget (topFrame); |
117 | priorityLayout->addWidget( prioWidget ); | 117 | priorityLayout->addWidget( prioWidget ); |
118 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); | 118 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); |
119 | 119 | ||
120 | 120 | ||
121 | QIconSet icon; | 121 | QIconSet icon; |
122 | if ( QApplication::desktop()->width() < 321 ) | 122 | if ( QApplication::desktop()->width() < 321 ) |
123 | icon = SmallIcon("fileexport16"); | 123 | icon = SmallIcon("fileexport16"); |
124 | else | 124 | else |
125 | icon = SmallIcon("fileexport"); | 125 | icon = SmallIcon("fileexport"); |
126 | QPushButton * saveTemplate = new QPushButton( prioWidget); | 126 | QPushButton * saveTemplate = new QPushButton( prioWidget); |
127 | saveTemplate->setIconSet (icon ) ; | 127 | saveTemplate->setIconSet (icon ) ; |
128 | int size = saveTemplate->sizeHint().height(); | 128 | int size = saveTemplate->sizeHint().height(); |
129 | saveTemplate->setFixedSize( size, size ); | 129 | saveTemplate->setFixedSize( size, size ); |
130 | if ( QApplication::desktop()->width() < 321 ) | 130 | if ( QApplication::desktop()->width() < 321 ) |
131 | icon = SmallIcon("fileimport16"); | 131 | icon = SmallIcon("fileimport16"); |
132 | else | 132 | else |
133 | icon = SmallIcon("fileimport"); | 133 | icon = SmallIcon("fileimport"); |
134 | QPushButton * loadTemplate = new QPushButton( prioWidget); | 134 | QPushButton * loadTemplate = new QPushButton( prioWidget); |
135 | loadTemplate->setIconSet (icon ) ; | 135 | loadTemplate->setIconSet (icon ) ; |
136 | loadTemplate->setFixedSize( size, size ); | 136 | loadTemplate->setFixedSize( size, size ); |
137 | 137 | ||
138 | priorityLayout2->addWidget(loadTemplate); | 138 | priorityLayout2->addWidget(loadTemplate); |
139 | priorityLayout2->addWidget(saveTemplate); | 139 | priorityLayout2->addWidget(saveTemplate); |
140 | mGeneral->initPriority(prioWidget,priorityLayout2); | 140 | mGeneral->initPriority(prioWidget,priorityLayout2); |
141 | mGeneral->initCategories( topFrame, priorityLayout ); | 141 | mGeneral->initCategories( topFrame, priorityLayout ); |
142 | topLayout->addStretch(1); | 142 | topLayout->addStretch(1); |
143 | 143 | ||
144 | QFrame *topFrame2 = addPage(i18n("Details")); | 144 | QFrame *topFrame2 = addPage(i18n("Details")); |
145 | 145 | ||
146 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 146 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
147 | topLayout2->setMargin(marginHint()); | 147 | topLayout2->setMargin(marginHint()); |
148 | topLayout2->setSpacing(spacingHint()); | 148 | topLayout2->setSpacing(spacingHint()); |
149 | 149 | ||
150 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); | 150 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); |
151 | mGeneral->initCompletion(topFrame2,completionLayout); | 151 | mGeneral->initCompletion(topFrame2,completionLayout); |
152 | 152 | ||
153 | 153 | ||
154 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 154 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
155 | mGeneral->initDescription(topFrame2,topLayout2); | 155 | mGeneral->initDescription(topFrame2,topLayout2); |
156 | 156 | ||
157 | // QHBox * hb = new QHBox ( topFrame2 ); | 157 | // QHBox * hb = new QHBox ( topFrame2 ); |
158 | // topLayout2->addWidget(hb); | 158 | // topLayout2->addWidget(hb); |
159 | // hb->setSpacing( 3 ); | 159 | // hb->setSpacing( 3 ); |
160 | 160 | ||
161 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 161 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
162 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 162 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
163 | 163 | ||
164 | } else { | 164 | } else { |
165 | QFrame *topFrame = addPage(i18n("General")); | 165 | QFrame *topFrame = addPage(i18n("General")); |
166 | 166 | ||
167 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 167 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
168 | topLayout->setSpacing(spacingHint()); | 168 | topLayout->setSpacing(spacingHint()); |
169 | 169 | ||
170 | mGeneral->initHeader(topFrame,topLayout); | 170 | mGeneral->initHeader(topFrame,topLayout); |
171 | mGeneral->initTime(topFrame,topLayout); | 171 | mGeneral->initTime(topFrame,topLayout); |
172 | mGeneral->initStatus(topFrame,topLayout); | 172 | mGeneral->initStatus(topFrame,topLayout); |
173 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 173 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
174 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 174 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
175 | mGeneral->initDescription(topFrame,topLayout); | 175 | mGeneral->initDescription(topFrame,topLayout); |
176 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 176 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
177 | mGeneral->initCategories( topFrame, detailsLayout ); | 177 | mGeneral->initCategories( topFrame, detailsLayout ); |
178 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 178 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
179 | } | 179 | } |
180 | mGeneral->finishSetup(); | 180 | mGeneral->finishSetup(); |
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | 184 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) |
185 | { | 185 | { |
186 | //init(); | 186 | //init(); |
187 | 187 | ||
188 | mTodo = todo; | 188 | mTodo = todo; |
189 | readTodo(mTodo); | 189 | readTodo(mTodo); |
190 | if ( editDescription ) { | 190 | if ( editDescription ) { |
191 | showPage( 1 ); | 191 | showPage( 1 ); |
192 | mGeneral->setFocusOn( 1 ); | 192 | mGeneral->setFocusOn( 1 ); |
193 | } else { | 193 | } else { |
194 | showPage( 0 ); | 194 | showPage( 0 ); |
195 | mGeneral->setFocusOn( 2 ); | 195 | mGeneral->setFocusOn( 2 ); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | 198 | ||
199 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 199 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
200 | { | 200 | { |
201 | //init(); | 201 | //init(); |
202 | 202 | ||
203 | mTodo = 0; | 203 | mTodo = 0; |
204 | setDefaults(due,relatedTodo,allDay); | 204 | setDefaults(due,relatedTodo,allDay); |
205 | } | 205 | } |
206 | 206 | ||
207 | void KOTodoEditor::loadDefaults() | 207 | void KOTodoEditor::loadDefaults() |
208 | { | 208 | { |
209 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 209 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
210 | } | 210 | } |
211 | 211 | ||
212 | bool KOTodoEditor::processInput( bool emitTime ) | 212 | bool KOTodoEditor::processInput( bool emitTime ) |
213 | { | 213 | { |
214 | if (!validateInput()) return false; | 214 | if (!validateInput()) return false; |
215 | 215 | ||
216 | Todo *todo = 0; | 216 | Todo *todo = 0; |
217 | 217 | ||
218 | if (mTodo) todo = mTodo; | 218 | if (mTodo) todo = mTodo; |
219 | else { | 219 | else { |
220 | todo = new Todo; | 220 | todo = new Todo; |
221 | todo->setOrganizer(KOPrefs::instance()->email()); | 221 | todo->setOrganizer(KOPrefs::instance()->email()); |
222 | } | 222 | } |
223 | 223 | ||
224 | writeTodo(todo); | 224 | writeTodo(todo); |
225 | if ( emitTime ) { | 225 | if ( emitTime ) { |
226 | globalFlagBlockAgenda = 1; | 226 | globalFlagBlockAgenda = 1; |
227 | emit showAgendaView( false ); | 227 | emit showAgendaView( false ); |
228 | if ( todo->hasDueDate() ) | 228 | if ( todo->hasDueDate() ) |
229 | emit jumpToTime( todo->dtDue().date() ); | 229 | emit jumpToTime( todo->dtDue().date() ); |
230 | globalFlagBlockAgenda = 2; | 230 | globalFlagBlockAgenda = 2; |
231 | } | 231 | } |
232 | if (mTodo) { | 232 | if (mTodo) { |
233 | todo->setRevision(todo->revision()+1); | 233 | todo->setRevision(todo->revision()+1); |
234 | emit todoChanged(todo); | 234 | emit todoChanged(todo); |
235 | } else { | 235 | } else { |
236 | mCalendar->addTodo(todo); | 236 | mCalendar->addTodo(todo); |
237 | mTodo = todo; | 237 | mTodo = todo; |
238 | emit todoAdded(todo); | 238 | emit todoAdded(todo); |
239 | } | 239 | } |
240 | 240 | ||
241 | return true; | 241 | return true; |
242 | } | 242 | } |
243 | 243 | ||
244 | void KOTodoEditor::deleteTodo() | 244 | void KOTodoEditor::deleteTodo() |
245 | { | 245 | { |
246 | if (mTodo) { | 246 | if (mTodo) { |
247 | if (KOPrefs::instance()->mConfirm) { | 247 | if (KOPrefs::instance()->mConfirm) { |
248 | switch (msgItemDelete()) { | 248 | switch (msgItemDelete()) { |
249 | case KMessageBox::Continue: // OK | 249 | case KMessageBox::Continue: // OK |
250 | emit todoToBeDeleted(mTodo); | 250 | emit todoToBeDeleted(mTodo); |
251 | emit dialogClose(mTodo); | 251 | emit dialogClose(mTodo); |
252 | mCalendar->deleteTodo(mTodo); | 252 | mCalendar->deleteTodo(mTodo); |
253 | emit todoDeleted(); | 253 | emit todoDeleted(); |
254 | reject(); | 254 | reject(); |
255 | break; | 255 | break; |
256 | } | 256 | } |
257 | } | 257 | } |
258 | else { | 258 | else { |
259 | emit todoToBeDeleted(mTodo); | 259 | emit todoToBeDeleted(mTodo); |
260 | emit dialogClose(mTodo); | 260 | emit dialogClose(mTodo); |
261 | mCalendar->deleteTodo(mTodo); | 261 | mCalendar->deleteTodo(mTodo); |
262 | emit todoDeleted(); | 262 | emit todoDeleted(); |
263 | reject(); | 263 | reject(); |
264 | } | 264 | } |
265 | } else { | 265 | } else { |
266 | reject(); | 266 | reject(); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 270 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
271 | { | 271 | { |
272 | mRelatedTodo = relatedEvent; | 272 | mRelatedTodo = relatedEvent; |
273 | 273 | ||
274 | mGeneral->setDefaults(due,allDay); | 274 | mGeneral->setDefaults(due,allDay); |
275 | mDetails->setDefaults(); | 275 | mDetails->setDefaults(); |
276 | showPage( 0 ); | 276 | showPage( 0 ); |
277 | if ( mRelatedTodo ) { | 277 | if ( mRelatedTodo ) { |
278 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 278 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
279 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 279 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
280 | if ( mRelatedTodo->priority() < 3 ) | 280 | if ( mRelatedTodo->priority() < 3 ) |
281 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 281 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
282 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 282 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
283 | int len = mRelatedTodo->summary().length(); | 283 | int len = mRelatedTodo->summary().length(); |
284 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | ||
285 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | ||
286 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 284 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
285 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | ||
286 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | ||
287 | 287 | ||
288 | } else | 288 | } else |
289 | mGeneral->setFocusOn( 2 ); | 289 | mGeneral->setFocusOn( 2 ); |
290 | } | 290 | } |
291 | 291 | ||
292 | void KOTodoEditor::readTodo(Todo *todo) | 292 | void KOTodoEditor::readTodo(Todo *todo) |
293 | { | 293 | { |
294 | mGeneral->readTodo(todo); | 294 | mGeneral->readTodo(todo); |
295 | mDetails->readEvent(todo); | 295 | mDetails->readEvent(todo); |
296 | mRelatedTodo = 0;//todo->relatedTo(); | 296 | mRelatedTodo = 0;//todo->relatedTo(); |
297 | // categories | 297 | // categories |
298 | // mCategoryDialog->setSelected(todo->categories()); | 298 | // mCategoryDialog->setSelected(todo->categories()); |
299 | 299 | ||
300 | // We should handle read-only events here. | 300 | // We should handle read-only events here. |
301 | } | 301 | } |
302 | 302 | ||
303 | void KOTodoEditor::writeTodo(Todo *event) | 303 | void KOTodoEditor::writeTodo(Todo *event) |
304 | { | 304 | { |
305 | mGeneral->writeTodo(event); | 305 | mGeneral->writeTodo(event); |
306 | mDetails->writeEvent(event); | 306 | mDetails->writeEvent(event); |
307 | 307 | ||
308 | // set related event, i.e. parent to-do in this case. | 308 | // set related event, i.e. parent to-do in this case. |
309 | if (mRelatedTodo) { | 309 | if (mRelatedTodo) { |
310 | event->setRelatedTo(mRelatedTodo); | 310 | event->setRelatedTo(mRelatedTodo); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | bool KOTodoEditor::validateInput() | 314 | bool KOTodoEditor::validateInput() |
315 | { | 315 | { |
316 | if (!mGeneral->validateInput()) return false; | 316 | if (!mGeneral->validateInput()) return false; |
317 | if (!mDetails->validateInput()) return false; | 317 | if (!mDetails->validateInput()) return false; |
318 | return true; | 318 | return true; |
319 | } | 319 | } |
320 | 320 | ||
321 | int KOTodoEditor::msgItemDelete() | 321 | int KOTodoEditor::msgItemDelete() |
322 | { | 322 | { |
323 | return KMessageBox::warningContinueCancel(this, | 323 | return KMessageBox::warningContinueCancel(this, |
324 | i18n("This item will be permanently deleted."), | 324 | i18n("This item will be permanently deleted."), |
325 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 325 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
326 | } | 326 | } |
327 | 327 | ||
328 | void KOTodoEditor::modified (int modification) | 328 | void KOTodoEditor::modified (int modification) |
329 | { | 329 | { |
330 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 330 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
331 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 331 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
332 | // mCategoryDialog->setSelected (mTodo->categories ()); | 332 | // mCategoryDialog->setSelected (mTodo->categories ()); |
333 | mGeneral->modified (mTodo, modification); | 333 | mGeneral->modified (mTodo, modification); |
334 | 334 | ||
335 | } | 335 | } |
336 | 336 | ||
337 | void KOTodoEditor::slotLoadTemplate() | 337 | void KOTodoEditor::slotLoadTemplate() |
338 | { | 338 | { |
339 | 339 | ||
340 | QString fileName =locateLocal( "templates", "todos" ); | 340 | QString fileName =locateLocal( "templates", "todos" ); |
341 | QDir t_dir; | 341 | QDir t_dir; |
342 | if ( !t_dir.exists(fileName) ) | 342 | if ( !t_dir.exists(fileName) ) |
343 | t_dir.mkdir ( fileName ); | 343 | t_dir.mkdir ( fileName ); |
344 | fileName += "/todo"; | 344 | fileName += "/todo"; |
345 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); | 345 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); |
346 | if ( fileName.length() == 0 ) | 346 | if ( fileName.length() == 0 ) |
347 | return; | 347 | return; |
348 | CalendarLocal cal; | 348 | CalendarLocal cal; |
349 | ICalFormat format; | 349 | ICalFormat format; |
350 | if ( !format.load( &cal, fileName ) ) { | 350 | if ( !format.load( &cal, fileName ) ) { |
351 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 351 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
352 | .arg( fileName ) ); | 352 | .arg( fileName ) ); |
353 | return ; | 353 | return ; |
354 | } | 354 | } |
355 | QPtrList<Todo> todos = cal.todos(); | 355 | QPtrList<Todo> todos = cal.todos(); |
356 | Todo * todo = todos.first(); | 356 | Todo * todo = todos.first(); |
357 | if ( !todo ) { | 357 | if ( !todo ) { |
358 | KMessageBox::error( this, | 358 | KMessageBox::error( this, |
359 | i18n("Template does not\ncontain a valid Todo.")); | 359 | i18n("Template does not\ncontain a valid Todo.")); |
360 | } else { | 360 | } else { |
361 | readTodo( todo ); | 361 | readTodo( todo ); |
362 | } | 362 | } |
363 | 363 | ||
364 | } | 364 | } |
365 | 365 | ||
366 | void KOTodoEditor::slotSaveTemplate() | 366 | void KOTodoEditor::slotSaveTemplate() |
367 | { | 367 | { |
368 | QString fileName =locateLocal( "templates", "todos" ); | 368 | QString fileName =locateLocal( "templates", "todos" ); |
369 | QDir t_dir; | 369 | QDir t_dir; |
370 | if ( !t_dir.exists(fileName) ) | 370 | if ( !t_dir.exists(fileName) ) |
371 | t_dir.mkdir ( fileName ); | 371 | t_dir.mkdir ( fileName ); |
372 | fileName += "/todo"; | 372 | fileName += "/todo"; |
373 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); | 373 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); |
374 | if ( fileName.length() > 0 ) | 374 | if ( fileName.length() > 0 ) |
375 | saveTemplate( fileName ); | 375 | saveTemplate( fileName ); |
376 | } | 376 | } |
377 | 377 | ||
378 | void KOTodoEditor::saveTemplate( const QString &templateName ) | 378 | void KOTodoEditor::saveTemplate( const QString &templateName ) |
379 | { | 379 | { |
380 | Todo *todo = new Todo; | 380 | Todo *todo = new Todo; |
381 | writeTodo( todo ); | 381 | writeTodo( todo ); |
382 | saveAsTemplate( todo, templateName ); | 382 | saveAsTemplate( todo, templateName ); |
383 | } | 383 | } |