summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoeditor.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoeditor.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kotodoeditor.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 20a35d2..aeab92a 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -2,57 +2,62 @@
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 <q3frame.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qhbox.h> 29#include <q3hbox.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qapplication.h> 33#include <qapplication.h>
34#include <QDesktopWidget>
34#include <qtabwidget.h> 35#include <qtabwidget.h>
36//Added by qt3to4:
37#include <Q3HBoxLayout>
38#include <Q3PtrList>
39#include <Q3VBoxLayout>
35 40
36#include <kiconloader.h> 41#include <kiconloader.h>
37#include <klocale.h> 42#include <klocale.h>
38#include <kfiledialog.h> 43#include <kfiledialog.h>
39#include <kstandarddirs.h> 44#include <kstandarddirs.h>
40#include <kmessagebox.h> 45#include <kmessagebox.h>
41 46
42#include <libkdepim/categoryselectdialog.h> 47#include <libkdepim/categoryselectdialog.h>
43#include <libkcal/calendarlocal.h> 48#include <libkcal/calendarlocal.h>
44#include <libkcal/calendarresources.h> 49#include <libkcal/calendarresources.h>
45#include <libkcal/resourcecalendar.h> 50#include <libkcal/resourcecalendar.h>
46#include <libkcal/icalformat.h> 51#include <libkcal/icalformat.h>
47#include <kresources/resourceselectdialog.h> 52#include <kresources/resourceselectdialog.h>
48#include <libkdepim/kdateedit.h> 53#include <libkdepim/kdateedit.h>
49 54
50#include "koprefs.h" 55#include "koprefs.h"
51#include "kolocationbox.h" 56#include "kolocationbox.h"
52 57
53#include "kotodoeditor.h" 58#include "kotodoeditor.h"
54extern int globalFlagBlockAgenda; 59extern int globalFlagBlockAgenda;
55 60
56KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : 61KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) :
57 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) 62 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent )
58{ 63{
@@ -60,164 +65,164 @@ KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) :
60 mRelatedTodo = 0; 65 mRelatedTodo = 0;
61 findButton(User1)->hide(); 66 findButton(User1)->hide();
62 init(); 67 init();
63 if ( QApplication::desktop()->height() <= 240 ) 68 if ( QApplication::desktop()->height() <= 240 )
64 hideButtons(); 69 hideButtons();
65} 70}
66 71
67KOTodoEditor::~KOTodoEditor() 72KOTodoEditor::~KOTodoEditor()
68{ 73{
69 emit dialogClose( mTodo ); 74 emit dialogClose( mTodo );
70} 75}
71 76
72void KOTodoEditor::init() 77void KOTodoEditor::init()
73{ 78{
74 setupGeneral(); 79 setupGeneral();
75 setupAttendeesTab(); 80 setupAttendeesTab();
76 setupRecurrence(); 81 setupRecurrence();
77 connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); 82 connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence()));
78 mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); 83 mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") );
79 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 84 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
80 mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); 85 mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime)));
81} 86}
82void KOTodoEditor::setupRecurrence() 87void KOTodoEditor::setupRecurrence()
83{ 88{
84 QFrame *topFrame = addPage( i18n("Recurrence") ); 89 Q3Frame *topFrame = addPage( i18n("Recurrence") );
85 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 90 Q3BoxLayout *topLayout = new Q3VBoxLayout( topFrame );
86 91
87 mRecurrence = new KOEditorRecurrence( topFrame ); 92 mRecurrence = new KOEditorRecurrence( topFrame );
88 topLayout->addWidget( mRecurrence ); 93 topLayout->addWidget( mRecurrence );
89} 94}
90 95
91void KOTodoEditor::setCategories( QString s ) 96void KOTodoEditor::setCategories( QString s )
92{ 97{
93 mGeneral->setCategories(s); 98 mGeneral->setCategories(s);
94} 99}
95void KOTodoEditor::setSecrecy( int sec ) 100void KOTodoEditor::setSecrecy( int sec )
96{ 101{
97 mGeneral->setSecrecy( sec ); 102 mGeneral->setSecrecy( sec );
98} 103}
99void KOTodoEditor::reload() 104void KOTodoEditor::reload()
100{ 105{
101 if ( mTodo ) readTodo( mTodo ); 106 if ( mTodo ) readTodo( mTodo );
102} 107}
103 108
104void KOTodoEditor::setupGeneral() 109void KOTodoEditor::setupGeneral()
105{ 110{
106 mGeneral = new KOEditorGeneralTodo(this); 111 mGeneral = new KOEditorGeneralTodo(this);
107 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 112 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
108 113
109 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 114 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
110 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), 115 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
111 // mGeneral,SLOT(setCategories(const QString &))); 116 // mGeneral,SLOT(setCategories(const QString &)));
112 117
113 if (KOPrefs::instance()->mCompactDialogs) { 118 if (KOPrefs::instance()->mCompactDialogs) {
114 QFrame *topFrame = addPage(i18n("General")); 119 Q3Frame *topFrame = addPage(i18n("General"));
115 120
116 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 121 Q3BoxLayout *topLayout = new Q3VBoxLayout(topFrame);
117 if ( QApplication::desktop()->width() < 480 ) { 122 if ( QApplication::desktop()->width() < 480 ) {
118 topLayout->setMargin(marginHintSmall()); 123 topLayout->setMargin(marginHintSmall());
119 topLayout->setSpacing(spacingHintSmall()); 124 topLayout->setSpacing(spacingHintSmall());
120 } else { 125 } else {
121 topLayout->setMargin(marginHint()); 126 topLayout->setMargin(marginHint());
122 topLayout->setSpacing(spacingHint()); 127 topLayout->setSpacing(spacingHint());
123 } 128 }
124 topLayout->addStretch( 1 ); 129 topLayout->addStretch( 1 );
125 mGeneral->initHeader(topFrame,topLayout); 130 mGeneral->initHeader(topFrame,topLayout);
126 topLayout->addStretch( 1 ); 131 topLayout->addStretch( 1 );
127 mGeneral->initTime(topFrame,topLayout); 132 mGeneral->initTime(topFrame,topLayout);
128 topLayout->addStretch( 1 ); 133 topLayout->addStretch( 1 );
129 mGeneral->initAlarm(topFrame,topLayout); 134 mGeneral->initAlarm(topFrame,topLayout);
130 topLayout->addStretch( 1 ); 135 topLayout->addStretch( 1 );
131 mGeneral->enableAlarm( false ); 136 mGeneral->enableAlarm( false );
132 137
133 138
134 QBoxLayout *priorityLayout; 139 Q3BoxLayout *priorityLayout;
135 if ( QApplication::desktop()->width() < 500 ) 140 if ( QApplication::desktop()->width() < 500 )
136 priorityLayout = new QVBoxLayout( topLayout ); 141 priorityLayout = new Q3VBoxLayout( topLayout );
137 else 142 else
138 priorityLayout = new QHBoxLayout( topLayout ); 143 priorityLayout = new Q3HBoxLayout( topLayout );
139 QWidget* prioWidget = new QWidget (topFrame); 144 QWidget* prioWidget = new QWidget (topFrame);
140 priorityLayout->addWidget( prioWidget ); 145 priorityLayout->addWidget( prioWidget );
141 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); 146 Q3HBoxLayout* priorityLayout2 = new Q3HBoxLayout( prioWidget);
142 147
143 148
144 QIconSet icon; 149 QIcon icon;
145 if ( QApplication::desktop()->width() < 321 ) 150 if ( QApplication::desktop()->width() < 321 )
146 icon = SmallIcon("fileimport16"); 151 icon = SmallIcon("fileimport16");
147 else 152 else
148 icon = SmallIcon("fileimport"); 153 icon = SmallIcon("fileimport");
149 QPushButton * loadTemplate = new QPushButton( prioWidget); 154 QPushButton * loadTemplate = new QPushButton( prioWidget);
150 loadTemplate->setIconSet (icon ) ; 155 loadTemplate->setIconSet (icon ) ;
151 int size = loadTemplate->sizeHint().height(); 156 int size = loadTemplate->sizeHint().height();
152 loadTemplate->setFixedSize( size, size ); 157 loadTemplate->setFixedSize( size, size );
153 if ( QApplication::desktop()->width() < 321 ) 158 if ( QApplication::desktop()->width() < 321 )
154 icon = SmallIcon("fileexport16"); 159 icon = SmallIcon("fileexport16");
155 else 160 else
156 icon = SmallIcon("fileexport"); 161 icon = SmallIcon("fileexport");
157 QPushButton * saveTemplate = new QPushButton( prioWidget); 162 QPushButton * saveTemplate = new QPushButton( prioWidget);
158 saveTemplate->setIconSet (icon ) ; 163 saveTemplate->setIconSet (icon ) ;
159 saveTemplate->setFixedSize( size, size ); 164 saveTemplate->setFixedSize( size, size );
160 165
161 priorityLayout2->addWidget(loadTemplate); 166 priorityLayout2->addWidget(loadTemplate);
162 priorityLayout2->addWidget(saveTemplate); 167 priorityLayout2->addWidget(saveTemplate);
163 mGeneral->initPriority(prioWidget,priorityLayout2); 168 mGeneral->initPriority(prioWidget,priorityLayout2);
164 mGeneral->initCategories( topFrame, priorityLayout ); 169 mGeneral->initCategories( topFrame, priorityLayout );
165 topLayout->addStretch(1); 170 topLayout->addStretch(1);
166 171
167 QFrame *topFrame2 = addPage(i18n("Details")); 172 Q3Frame *topFrame2 = addPage(i18n("Details"));
168 173
169 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 174 Q3BoxLayout *topLayout2 = new Q3VBoxLayout(topFrame2);
170 topLayout2->setMargin(marginHint()); 175 topLayout2->setMargin(marginHint());
171 topLayout2->setSpacing(spacingHint()); 176 topLayout2->setSpacing(spacingHint());
172 177
173 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); 178 Q3HBoxLayout *completionLayout = new Q3HBoxLayout( topLayout2 );
174 mGeneral->initCompletion(topFrame2,completionLayout); 179 mGeneral->initCompletion(topFrame2,completionLayout);
175 180
176 181
177 mGeneral->initSecrecy( topFrame2, topLayout2 ); 182 mGeneral->initSecrecy( topFrame2, topLayout2 );
178 mGeneral->initDescription(topFrame2,topLayout2); 183 mGeneral->initDescription(topFrame2,topLayout2);
179 184
180 // QHBox * hb = new QHBox ( topFrame2 ); 185 // QHBox * hb = new QHBox ( topFrame2 );
181 // topLayout2->addWidget(hb); 186 // topLayout2->addWidget(hb);
182 // hb->setSpacing( 3 ); 187 // hb->setSpacing( 3 );
183 188
184 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 189 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
185 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 190 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
186 191
187 } else { 192 } else {
188 QFrame *topFrame = addPage(i18n("General")); 193 Q3Frame *topFrame = addPage(i18n("General"));
189 194
190 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 195 Q3BoxLayout *topLayout = new Q3VBoxLayout(topFrame);
191 topLayout->setSpacing(spacingHint()); 196 topLayout->setSpacing(spacingHint());
192 197
193 mGeneral->initHeader(topFrame,topLayout); 198 mGeneral->initHeader(topFrame,topLayout);
194 mGeneral->initTime(topFrame,topLayout); 199 mGeneral->initTime(topFrame,topLayout);
195 mGeneral->initStatus(topFrame,topLayout); 200 mGeneral->initStatus(topFrame,topLayout);
196 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 201 Q3BoxLayout *alarmLineLayout = new Q3HBoxLayout(topLayout);
197 mGeneral->initAlarm(topFrame,alarmLineLayout); 202 mGeneral->initAlarm(topFrame,alarmLineLayout);
198 mGeneral->initDescription(topFrame,topLayout); 203 mGeneral->initDescription(topFrame,topLayout);
199 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 204 Q3BoxLayout *detailsLayout = new Q3HBoxLayout(topLayout);
200 mGeneral->initCategories( topFrame, detailsLayout ); 205 mGeneral->initCategories( topFrame, detailsLayout );
201 mGeneral->initSecrecy( topFrame, detailsLayout ); 206 mGeneral->initSecrecy( topFrame, detailsLayout );
202 } 207 }
203 mGeneral->finishSetup(); 208 mGeneral->finishSetup();
204 209
205} 210}
206 211
207void KOTodoEditor::editTodo(Todo *todo, bool editDescription) 212void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
208{ 213{
209 //init(); 214 //init();
210 215
211 mTodo = todo; 216 mTodo = todo;
212 readTodo(mTodo); 217 readTodo(mTodo);
213 if ( editDescription ) { 218 if ( editDescription ) {
214 showPage( 1 ); 219 showPage( 1 );
215 mGeneral->setFocusOn( 1 ); 220 mGeneral->setFocusOn( 1 );
216 } else { 221 } else {
217 showPage( 0 ); 222 showPage( 0 );
218 mGeneral->setFocusOn( 2 ); 223 mGeneral->setFocusOn( 2 );
219 } 224 }
220 checkRecurrence(); 225 checkRecurrence();
221} 226}
222 227
223void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) 228void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay)
@@ -406,49 +411,49 @@ void KOTodoEditor::modified (int modification)
406 KOGlobals::UNKNOWN_MODIFIED == modification ) 411 KOGlobals::UNKNOWN_MODIFIED == modification )
407 // mCategoryDialog->setSelected (mTodo->categories ()); 412 // mCategoryDialog->setSelected (mTodo->categories ());
408 mGeneral->modified (mTodo, modification); 413 mGeneral->modified (mTodo, modification);
409 414
410} 415}
411 416
412void KOTodoEditor::slotLoadTemplate() 417void KOTodoEditor::slotLoadTemplate()
413{ 418{
414 419
415 QString fileName =locateLocal( "templates", "todos" ); 420 QString fileName =locateLocal( "templates", "todos" );
416 QDir t_dir; 421 QDir t_dir;
417 if ( !t_dir.exists(fileName) ) 422 if ( !t_dir.exists(fileName) )
418 t_dir.mkdir ( fileName ); 423 t_dir.mkdir ( fileName );
419 fileName += "/todo"; 424 fileName += "/todo";
420 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); 425 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
421 if ( fileName.length() == 0 ) 426 if ( fileName.length() == 0 )
422 return; 427 return;
423 CalendarLocal cal; 428 CalendarLocal cal;
424 ICalFormat format; 429 ICalFormat format;
425 if ( !format.load( &cal, fileName ) ) { 430 if ( !format.load( &cal, fileName ) ) {
426 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 431 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
427 .arg( fileName ) ); 432 .arg( fileName ) );
428 return ; 433 return ;
429 } 434 }
430 QPtrList<Todo> todos = cal.todos(); 435 Q3PtrList<Todo> todos = cal.todos();
431 Todo * todo = todos.first(); 436 Todo * todo = todos.first();
432 if ( !todo ) { 437 if ( !todo ) {
433 KMessageBox::error( this, 438 KMessageBox::error( this,
434 i18n("Template does not\ncontain a valid Todo.")); 439 i18n("Template does not\ncontain a valid Todo."));
435 } else { 440 } else {
436 readTodo( todo ); 441 readTodo( todo );
437 } 442 }
438 443
439} 444}
440 445
441void KOTodoEditor::slotSaveTemplate() 446void KOTodoEditor::slotSaveTemplate()
442{ 447{
443 QString fileName =locateLocal( "templates", "todos" ); 448 QString fileName =locateLocal( "templates", "todos" );
444 QDir t_dir; 449 QDir t_dir;
445 if ( !t_dir.exists(fileName) ) 450 if ( !t_dir.exists(fileName) )
446 t_dir.mkdir ( fileName ); 451 t_dir.mkdir ( fileName );
447 fileName += "/todo"; 452 fileName += "/todo";
448 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); 453 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this );
449 if ( fileName.length() > 0 ) 454 if ( fileName.length() > 0 )
450 saveTemplate( fileName ); 455 saveTemplate( fileName );
451} 456}
452 457
453void KOTodoEditor::saveTemplate( const QString &templateName ) 458void KOTodoEditor::saveTemplate( const QString &templateName )
454{ 459{