summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-03 19:12:28 (UTC)
committer zautrix <zautrix>2005-02-03 19:12:28 (UTC)
commit48c87f3c5dcb1c373c812ca6068cfa1417802f27 (patch) (unidiff)
treea96b3e173a828b2be1d3db1ad528567218518457
parentfb6753570dc90e936b4e89092554ab012e946a56 (diff)
downloadkdepimpi-48c87f3c5dcb1c373c812ca6068cfa1417802f27.zip
kdepimpi-48c87f3c5dcb1c373c812ca6068cfa1417802f27.tar.gz
kdepimpi-48c87f3c5dcb1c373c812ca6068cfa1417802f27.tar.bz2
fiihiix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoeditor.cpp4
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
@@ -92,292 +92,292 @@ void KOTodoEditor::setupGeneral()
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
184void KOTodoEditor::editTodo(Todo *todo, bool editDescription) 184void 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
199void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) 199void 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
207void KOTodoEditor::loadDefaults() 207void KOTodoEditor::loadDefaults()
208{ 208{
209 setDefaults(QDateTime::currentDateTime().addDays(7),0,false); 209 setDefaults(QDateTime::currentDateTime().addDays(7),0,false);
210} 210}
211 211
212bool KOTodoEditor::processInput( bool emitTime ) 212bool 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
244void KOTodoEditor::deleteTodo() 244void 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
270void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) 270void 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
292void KOTodoEditor::readTodo(Todo *todo) 292void 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
303void KOTodoEditor::writeTodo(Todo *event) 303void 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
314bool KOTodoEditor::validateInput() 314bool 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
321int KOTodoEditor::msgItemDelete() 321int 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
328void KOTodoEditor::modified (int modification) 328void 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
337void KOTodoEditor::slotLoadTemplate() 337void 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
366void KOTodoEditor::slotSaveTemplate() 366void 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
378void KOTodoEditor::saveTemplate( const QString &templateName ) 378void 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}