Diffstat (limited to 'korganizer/koeventeditor.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeventeditor.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp index 3e87197..62ad250 100644 --- a/korganizer/koeventeditor.cpp +++ b/korganizer/koeventeditor.cpp | |||
@@ -1,64 +1,69 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 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 <qframe.h> | 25 | #include <q3frame.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qhbox.h> | 27 | #include <q3hbox.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qwidgetstack.h> | 31 | #include <q3widgetstack.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <QDesktopWidget> | ||
34 | //Added by qt3to4: | ||
35 | #include <Q3HBoxLayout> | ||
36 | #include <Q3PtrList> | ||
37 | #include <Q3VBoxLayout> | ||
33 | 38 | ||
34 | #include <kiconloader.h> | 39 | #include <kiconloader.h> |
35 | #include <kstandarddirs.h> | 40 | #include <kstandarddirs.h> |
36 | #include <kdebug.h> | 41 | #include <kdebug.h> |
37 | #include <klocale.h> | 42 | #include <klocale.h> |
38 | #include <kfiledialog.h> | 43 | #include <kfiledialog.h> |
39 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
40 | #include <libkcal/calendarresources.h> | 45 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 46 | #include <libkcal/resourcecalendar.h> |
42 | #include <kresources/resourceselectdialog.h> | 47 | #include <kresources/resourceselectdialog.h> |
43 | 48 | ||
44 | #include <libkdepim/categoryselectdialog.h> | 49 | #include <libkdepim/categoryselectdialog.h> |
45 | #include <libkcal/calendarlocal.h> | 50 | #include <libkcal/calendarlocal.h> |
46 | #include <libkcal/icalformat.h> | 51 | #include <libkcal/icalformat.h> |
47 | 52 | ||
48 | #include "koprefs.h" | 53 | #include "koprefs.h" |
49 | 54 | ||
50 | #include "koeventeditor.h" | 55 | #include "koeventeditor.h" |
51 | extern int globalFlagBlockAgenda; | 56 | extern int globalFlagBlockAgenda; |
52 | 57 | ||
53 | KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : | 58 | KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : |
54 | KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) | 59 | KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) |
55 | { | 60 | { |
56 | mEvent = 0; | 61 | mEvent = 0; |
57 | init(); | 62 | init(); |
58 | if ( QApplication::desktop()->height() <= 240 ) | 63 | if ( QApplication::desktop()->height() <= 240 ) |
59 | hideButtons(); | 64 | hideButtons(); |
60 | } | 65 | } |
61 | 66 | ||
62 | KOEventEditor::~KOEventEditor() | 67 | KOEventEditor::~KOEventEditor() |
63 | { | 68 | { |
64 | //emit dialogClose( mEvent ); | 69 | //emit dialogClose( mEvent ); |
@@ -76,143 +81,143 @@ void KOEventEditor::init() | |||
76 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); | 81 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); |
77 | connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), | 82 | connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), |
78 | mRecurrence,SLOT(setDateTimeStr(const QString &))); | 83 | mRecurrence,SLOT(setDateTimeStr(const QString &))); |
79 | 84 | ||
80 | // Category dialog | 85 | // Category dialog |
81 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 86 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
82 | //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), | 87 | //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), |
83 | // mGeneral,SLOT(setCategories(const QString &))); | 88 | // mGeneral,SLOT(setCategories(const QString &))); |
84 | 89 | ||
85 | 90 | ||
86 | } | 91 | } |
87 | 92 | ||
88 | void KOEventEditor::reload() | 93 | void KOEventEditor::reload() |
89 | { | 94 | { |
90 | if ( mEvent ) readEvent( mEvent ); | 95 | if ( mEvent ) readEvent( mEvent ); |
91 | } | 96 | } |
92 | 97 | ||
93 | void KOEventEditor::setSecrecy( int sec ) | 98 | void KOEventEditor::setSecrecy( int sec ) |
94 | { | 99 | { |
95 | mGeneral->setSecrecy( sec ); | 100 | mGeneral->setSecrecy( sec ); |
96 | } | 101 | } |
97 | void KOEventEditor::setCategories( QString s ) | 102 | void KOEventEditor::setCategories( QString s ) |
98 | { | 103 | { |
99 | mGeneral->setCategories(s); | 104 | mGeneral->setCategories(s); |
100 | 105 | ||
101 | } | 106 | } |
102 | void KOEventEditor::setupGeneral() | 107 | void KOEventEditor::setupGeneral() |
103 | { | 108 | { |
104 | mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); | 109 | mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); |
105 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 110 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
106 | 111 | ||
107 | if( KOPrefs::instance()->mCompactDialogs ) { | 112 | if( KOPrefs::instance()->mCompactDialogs ) { |
108 | QFrame *topFrame = addPage(i18n("General")); | 113 | Q3Frame *topFrame = addPage(i18n("General")); |
109 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 114 | Q3BoxLayout *topLayout = new Q3VBoxLayout(topFrame); |
110 | topLayout->setSpacing(spacingHint()-1); | 115 | topLayout->setSpacing(spacingHint()-1); |
111 | topLayout->setMargin(marginHint()-1); | 116 | topLayout->setMargin(marginHint()-1); |
112 | topLayout->addStretch ( 1 ); | 117 | topLayout->addStretch ( 1 ); |
113 | mGeneral->initHeader(topFrame,topLayout); | 118 | mGeneral->initHeader(topFrame,topLayout); |
114 | topLayout->addStretch ( 1 ); | 119 | topLayout->addStretch ( 1 ); |
115 | mGeneral->initTime(topFrame,topLayout); | 120 | mGeneral->initTime(topFrame,topLayout); |
116 | topLayout->addStretch ( 1 ); | 121 | topLayout->addStretch ( 1 ); |
117 | // QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 122 | // QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
118 | mGeneral->initAlarm(topFrame,topLayout); | 123 | mGeneral->initAlarm(topFrame,topLayout); |
119 | topLayout->addStretch ( 1 ); | 124 | topLayout->addStretch ( 1 ); |
120 | mGeneral->enableAlarm( false ); | 125 | mGeneral->enableAlarm( false ); |
121 | 126 | ||
122 | QBoxLayout *buttonLayout; | 127 | Q3BoxLayout *buttonLayout; |
123 | if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 ) | 128 | if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 ) |
124 | buttonLayout = new QVBoxLayout( topLayout ); | 129 | buttonLayout = new Q3VBoxLayout( topLayout ); |
125 | else | 130 | else |
126 | buttonLayout = new QHBoxLayout( topLayout ); | 131 | buttonLayout = new Q3HBoxLayout( topLayout ); |
127 | QHBox* buttonWidget = new QHBox (topFrame); | 132 | Q3HBox* buttonWidget = new Q3HBox (topFrame); |
128 | QIconSet icon; | 133 | QIcon icon; |
129 | if ( QApplication::desktop()->width() < 321 ) | 134 | if ( QApplication::desktop()->width() < 321 ) |
130 | icon = SmallIcon("fileexport16"); | 135 | icon = SmallIcon("fileexport16"); |
131 | else | 136 | else |
132 | icon = SmallIcon("fileexport"); | 137 | icon = SmallIcon("fileexport"); |
133 | QPushButton * loadTemplate = new QPushButton( buttonWidget); | 138 | QPushButton * loadTemplate = new QPushButton( buttonWidget); |
134 | QPushButton * saveTemplate = new QPushButton( buttonWidget); | 139 | QPushButton * saveTemplate = new QPushButton( buttonWidget); |
135 | saveTemplate->setIconSet (icon ) ; | 140 | saveTemplate->setIconSet (icon ) ; |
136 | int size = saveTemplate->sizeHint().height(); | 141 | int size = saveTemplate->sizeHint().height(); |
137 | saveTemplate->setFixedSize( size, size ); | 142 | saveTemplate->setFixedSize( size, size ); |
138 | if ( QApplication::desktop()->width() < 321 ) | 143 | if ( QApplication::desktop()->width() < 321 ) |
139 | icon = SmallIcon("fileimport16"); | 144 | icon = SmallIcon("fileimport16"); |
140 | else | 145 | else |
141 | icon = SmallIcon("fileimport"); | 146 | icon = SmallIcon("fileimport"); |
142 | loadTemplate->setIconSet (icon ) ; | 147 | loadTemplate->setIconSet (icon ) ; |
143 | loadTemplate->setFixedSize( size, size ); | 148 | loadTemplate->setFixedSize( size, size ); |
144 | buttonLayout->addWidget( buttonWidget ); | 149 | buttonLayout->addWidget( buttonWidget ); |
145 | mGeneral->initCategories( topFrame, buttonLayout ); | 150 | mGeneral->initCategories( topFrame, buttonLayout ); |
146 | 151 | ||
147 | topLayout->addStretch( 1 ); | 152 | topLayout->addStretch( 1 ); |
148 | 153 | ||
149 | QFrame *topFrame2 = addPage(i18n("Details")); | 154 | Q3Frame *topFrame2 = addPage(i18n("Details")); |
150 | 155 | ||
151 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 156 | Q3BoxLayout *topLayout2 = new Q3VBoxLayout(topFrame2); |
152 | topLayout2->setSpacing(spacingHint()-1); | 157 | topLayout2->setSpacing(spacingHint()-1); |
153 | topLayout2->setMargin(marginHint()-1); | 158 | topLayout2->setMargin(marginHint()-1); |
154 | topLayout2->setSpacing(spacingHint()); | 159 | topLayout2->setSpacing(spacingHint()); |
155 | 160 | ||
156 | mGeneral->initClass(topFrame2,topLayout2); | 161 | mGeneral->initClass(topFrame2,topLayout2); |
157 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 162 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
158 | mGeneral->initDescription(topFrame2,topLayout2); | 163 | mGeneral->initDescription(topFrame2,topLayout2); |
159 | 164 | ||
160 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 165 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
161 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 166 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
162 | } else { | 167 | } else { |
163 | QFrame *topFrame = addPage(i18n("General")); | 168 | Q3Frame *topFrame = addPage(i18n("General")); |
164 | 169 | ||
165 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 170 | Q3BoxLayout *topLayout = new Q3VBoxLayout(topFrame); |
166 | topLayout->setSpacing(spacingHint()); | 171 | topLayout->setSpacing(spacingHint()); |
167 | 172 | ||
168 | mGeneral->initHeader(topFrame,topLayout); | 173 | mGeneral->initHeader(topFrame,topLayout); |
169 | mGeneral->initTime(topFrame,topLayout); | 174 | mGeneral->initTime(topFrame,topLayout); |
170 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 175 | Q3BoxLayout *alarmLineLayout = new Q3HBoxLayout(topLayout); |
171 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 176 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
172 | mGeneral->initClass(topFrame,alarmLineLayout); | 177 | mGeneral->initClass(topFrame,alarmLineLayout); |
173 | mGeneral->initDescription(topFrame,topLayout); | 178 | mGeneral->initDescription(topFrame,topLayout); |
174 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 179 | Q3BoxLayout *detailsLayout = new Q3HBoxLayout(topLayout); |
175 | mGeneral->initCategories( topFrame, detailsLayout ); | 180 | mGeneral->initCategories( topFrame, detailsLayout ); |
176 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 181 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
177 | } | 182 | } |
178 | 183 | ||
179 | mGeneral->finishSetup(); | 184 | mGeneral->finishSetup(); |
180 | 185 | ||
181 | } | 186 | } |
182 | 187 | ||
183 | void KOEventEditor::setupRecurrence() | 188 | void KOEventEditor::setupRecurrence() |
184 | { | 189 | { |
185 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 190 | Q3Frame *topFrame = addPage( i18n("Recurrence") ); |
186 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 191 | Q3BoxLayout *topLayout = new Q3VBoxLayout( topFrame ); |
187 | 192 | ||
188 | mRecurrence = new KOEditorRecurrence( topFrame ); | 193 | mRecurrence = new KOEditorRecurrence( topFrame ); |
189 | topLayout->addWidget( mRecurrence ); | 194 | topLayout->addWidget( mRecurrence ); |
190 | } | 195 | } |
191 | 196 | ||
192 | void KOEventEditor::editEvent(Event *event, bool showDescription) | 197 | void KOEventEditor::editEvent(Event *event, bool showDescription) |
193 | { | 198 | { |
194 | // init(); | 199 | // init(); |
195 | 200 | ||
196 | mEvent = event; | 201 | mEvent = event; |
197 | readEvent(mEvent); | 202 | readEvent(mEvent); |
198 | if ( showDescription ) { | 203 | if ( showDescription ) { |
199 | showPage( 1 ); | 204 | showPage( 1 ); |
200 | mGeneral->setFocusOn( 1 ); | 205 | mGeneral->setFocusOn( 1 ); |
201 | } else { | 206 | } else { |
202 | showPage( 0 ); | 207 | showPage( 0 ); |
203 | mGeneral->setFocusOn( 2 ); | 208 | mGeneral->setFocusOn( 2 ); |
204 | } | 209 | } |
205 | } | 210 | } |
206 | 211 | ||
207 | void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) | 212 | void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) |
208 | { | 213 | { |
209 | // init(); | 214 | // init(); |
210 | 215 | ||
211 | mEvent = 0; | 216 | mEvent = 0; |
212 | setDefaults(from,to,allDay); | 217 | setDefaults(from,to,allDay); |
213 | } | 218 | } |
214 | 219 | ||
215 | void KOEventEditor::loadDefaults() | 220 | void KOEventEditor::loadDefaults() |
216 | { | 221 | { |
217 | int fmt = KOPrefs::instance()->mStartTime; | 222 | int fmt = KOPrefs::instance()->mStartTime; |
218 | 223 | ||
@@ -327,62 +332,62 @@ bool KOEventEditor::validateInput() | |||
327 | { | 332 | { |
328 | if (!mGeneral->validateInput()) return false; | 333 | if (!mGeneral->validateInput()) return false; |
329 | if (!mDetails->validateInput()) return false; | 334 | if (!mDetails->validateInput()) return false; |
330 | if (!mRecurrence->validateInput()) return false; | 335 | if (!mRecurrence->validateInput()) return false; |
331 | return true; | 336 | return true; |
332 | } | 337 | } |
333 | 338 | ||
334 | int KOEventEditor::msgItemDelete() | 339 | int KOEventEditor::msgItemDelete() |
335 | { | 340 | { |
336 | return KMessageBox::warningContinueCancel(this, | 341 | return KMessageBox::warningContinueCancel(this, |
337 | i18n("This item will be permanently deleted."), | 342 | i18n("This item will be permanently deleted."), |
338 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 343 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
339 | } | 344 | } |
340 | 345 | ||
341 | void KOEventEditor::slotLoadTemplate() | 346 | void KOEventEditor::slotLoadTemplate() |
342 | { | 347 | { |
343 | 348 | ||
344 | QString fileName =locateLocal( "templates", "events" ); | 349 | QString fileName =locateLocal( "templates", "events" ); |
345 | QDir t_dir; | 350 | QDir t_dir; |
346 | if ( !t_dir.exists(fileName) ) | 351 | if ( !t_dir.exists(fileName) ) |
347 | t_dir.mkdir ( fileName ); | 352 | t_dir.mkdir ( fileName ); |
348 | fileName += "/event"; | 353 | fileName += "/event"; |
349 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); | 354 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); |
350 | if ( fileName.length() == 0 ) | 355 | if ( fileName.length() == 0 ) |
351 | return; | 356 | return; |
352 | CalendarLocal cal; | 357 | CalendarLocal cal; |
353 | ICalFormat format; | 358 | ICalFormat format; |
354 | if ( !format.load( &cal, fileName ) ) { | 359 | if ( !format.load( &cal, fileName ) ) { |
355 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 360 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
356 | .arg( fileName ) ); | 361 | .arg( fileName ) ); |
357 | return ; | 362 | return ; |
358 | } | 363 | } |
359 | QPtrList<Event> events = cal.events(); | 364 | Q3PtrList<Event> events = cal.events(); |
360 | Event* event = events.first(); | 365 | Event* event = events.first(); |
361 | if ( !event ) { | 366 | if ( !event ) { |
362 | KMessageBox::error( this, | 367 | KMessageBox::error( this, |
363 | i18n("Template does not contain\na valid Event.")); | 368 | i18n("Template does not contain\na valid Event.")); |
364 | } else { | 369 | } else { |
365 | kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; | 370 | kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; |
366 | readEvent( event, true ); | 371 | readEvent( event, true ); |
367 | } | 372 | } |
368 | } | 373 | } |
369 | 374 | ||
370 | 375 | ||
371 | void KOEventEditor::slotSaveTemplate() | 376 | void KOEventEditor::slotSaveTemplate() |
372 | { | 377 | { |
373 | QString fileName =locateLocal( "templates", "events" ); | 378 | QString fileName =locateLocal( "templates", "events" ); |
374 | QDir t_dir; | 379 | QDir t_dir; |
375 | if ( !t_dir.exists(fileName) ) | 380 | if ( !t_dir.exists(fileName) ) |
376 | t_dir.mkdir ( fileName ); | 381 | t_dir.mkdir ( fileName ); |
377 | fileName += "/event"; | 382 | fileName += "/event"; |
378 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); | 383 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); |
379 | if ( fileName.length() > 0 ) | 384 | if ( fileName.length() > 0 ) |
380 | saveTemplate( fileName ); | 385 | saveTemplate( fileName ); |
381 | } | 386 | } |
382 | 387 | ||
383 | void KOEventEditor::saveTemplate( const QString &templateName ) | 388 | void KOEventEditor::saveTemplate( const QString &templateName ) |
384 | { | 389 | { |
385 | Event *event = new Event; | 390 | Event *event = new Event; |
386 | writeEvent( event ); | 391 | writeEvent( event ); |
387 | saveAsTemplate( event, templateName ); | 392 | saveAsTemplate( event, templateName ); |
388 | } | 393 | } |