summaryrefslogtreecommitdiffabout
path: root/korganizer/koeditorgeneraltodo.cpp
Unidiff
Diffstat (limited to 'korganizer/koeditorgeneraltodo.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeditorgeneraltodo.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
index d32d5a5..baee9fc 100644
--- a/korganizer/koeditorgeneraltodo.cpp
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -1,56 +1,63 @@
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 <q3filedialog.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <q3vbox.h>
28#include <qbuttongroup.h> 28#include <q3buttongroup.h>
29#include <qvgroupbox.h> 29#include <q3vgroupbox.h>
30#include <qwidgetstack.h> 30#include <q3widgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qapplication.h> 32#include <qapplication.h>
33#include <QDesktopWidget>
34//Added by qt3to4:
35#include <Q3HBoxLayout>
36#include <Q3GridLayout>
37#include <Q3Frame>
38#include <QLabel>
39#include <Q3VBoxLayout>
33 40
34#include <kglobal.h> 41#include <kglobal.h>
35#include <klocale.h> 42#include <klocale.h>
36#include <kiconloader.h> 43#include <kiconloader.h>
37#include <kmessagebox.h> 44#include <kmessagebox.h>
38#include <kdebug.h> 45#include <kdebug.h>
39#include <krestrictedline.h> 46#include <krestrictedline.h>
40#include <kstandarddirs.h> 47#include <kstandarddirs.h>
41#include <kfiledialog.h> 48#include <kfiledialog.h>
42#include <kdialog.h> 49#include <kdialog.h>
43 50
44#include <libkcal/todo.h> 51#include <libkcal/todo.h>
45 52
46#include <libkdepim/kdateedit.h> 53#include <libkdepim/kdateedit.h>
47 54
48#include "koprefs.h" 55#include "koprefs.h"
49#include "ktimeedit.h" 56#include "ktimeedit.h"
50 57
51#include "koeditorgeneraltodo.h" 58#include "koeditorgeneraltodo.h"
52#include "kolocationbox.h" 59#include "kolocationbox.h"
53 60
54KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, 61KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent,
55 const char* name) 62 const char* name)
56 : KOEditorGeneral( parent, name) 63 : KOEditorGeneral( parent, name)
@@ -61,158 +68,158 @@ KOEditorGeneralTodo::~KOEditorGeneralTodo()
61{ 68{
62} 69}
63 70
64void KOEditorGeneralTodo::finishSetup() 71void KOEditorGeneralTodo::finishSetup()
65{ 72{
66 73
67// QWidget::setTabOrder(mSummaryEdit, mLocationEdit); 74// QWidget::setTabOrder(mSummaryEdit, mLocationEdit);
68// QWidget::setTabOrder(mLocationEdit, mDueCheck); 75// QWidget::setTabOrder(mLocationEdit, mDueCheck);
69// QWidget::setTabOrder(mDueCheck, mDueDateEdit); 76// QWidget::setTabOrder(mDueCheck, mDueDateEdit);
70// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); 77// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit);
71// QWidget::setTabOrder(mDueTimeEdit, mStartCheck); 78// QWidget::setTabOrder(mDueTimeEdit, mStartCheck);
72// QWidget::setTabOrder(mStartCheck, mStartDateEdit); 79// QWidget::setTabOrder(mStartCheck, mStartDateEdit);
73// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); 80// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit);
74// QWidget::setTabOrder(mStartTimeEdit, mTimeButton); 81// QWidget::setTabOrder(mStartTimeEdit, mTimeButton);
75// QWidget::setTabOrder(mTimeButton, mCompletedCombo); 82// QWidget::setTabOrder(mTimeButton, mCompletedCombo);
76// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); 83// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo);
77// QWidget::setTabOrder(mPriorityCombo, mAlarmButton); 84// QWidget::setTabOrder(mPriorityCombo, mAlarmButton);
78// QWidget::setTabOrder(mAlarmButton, mCategoriesButton); 85// QWidget::setTabOrder(mAlarmButton, mCategoriesButton);
79// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); 86// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo);
80// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); 87// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit);
81 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 88 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
82 mSummaryEdit->setFocus(); 89 mSummaryEdit->setFocus();
83} 90}
84 91
85void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) 92void KOEditorGeneralTodo::initTime(QWidget *parent,Q3BoxLayout *topLayout)
86{ 93{
87 QBoxLayout *timeLayout = new QVBoxLayout(topLayout); 94 Q3BoxLayout *timeLayout = new Q3VBoxLayout(topLayout);
88 95
89 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, 96 Q3GroupBox *timeGroupBox = new Q3GroupBox(1,Qt::Horizontal,
90 i18n("Date && Time"),parent); 97 i18n("Date && Time"),parent);
91 timeLayout->addWidget(timeGroupBox); 98 timeLayout->addWidget(timeGroupBox);
92 timeGroupBox->layout()->setSpacing( KDialog::spacingHint()-2 ); 99 timeGroupBox->layout()->setSpacing( KDialog::spacingHint()-2 );
93 timeGroupBox->layout()->setMargin( KDialog::marginHint() ); 100 timeGroupBox->layout()->setMargin( KDialog::marginHint() );
94 QFrame *timeBoxFrame = new QFrame(timeGroupBox); 101 Q3Frame *timeBoxFrame = new Q3Frame(timeGroupBox);
95 102
96 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); 103 Q3GridLayout *layoutTimeBox = new Q3GridLayout(timeBoxFrame,3,3);
97 layoutTimeBox->setSpacing(KDialog::spacingHintSmall()); 104 layoutTimeBox->setSpacing(KDialog::spacingHintSmall());
98 layoutTimeBox->setColStretch( 1, 1 ); 105 layoutTimeBox->setColStretch( 1, 1 );
99 106
100 mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); 107 mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame);
101 layoutTimeBox->addWidget(mStartCheck,0,0); 108 layoutTimeBox->addWidget(mStartCheck,0,0);
102 connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); 109 connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool)));
103 110
104 mStartDateEdit = new KDateEdit(timeBoxFrame); 111 mStartDateEdit = new KDateEdit(timeBoxFrame);
105 layoutTimeBox->addWidget(mStartDateEdit,0,1); 112 layoutTimeBox->addWidget(mStartDateEdit,0,1);
106 113
107 mStartTimeEdit = new KOTimeEdit(timeBoxFrame); 114 mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
108 layoutTimeBox->addWidget(mStartTimeEdit,0,2); 115 layoutTimeBox->addWidget(mStartTimeEdit,0,2);
109 116
110 mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); 117 mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame);
111 layoutTimeBox->addWidget(mDueCheck,1,0); 118 layoutTimeBox->addWidget(mDueCheck,1,0);
112 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); 119 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool)));
113 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); 120 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm()));
114 121
115 122
116 mDueDateEdit = new KDateEdit(timeBoxFrame); 123 mDueDateEdit = new KDateEdit(timeBoxFrame);
117 layoutTimeBox->addWidget(mDueDateEdit,1,1); 124 layoutTimeBox->addWidget(mDueDateEdit,1,1);
118 125
119 mDueTimeEdit = new KOTimeEdit(timeBoxFrame); 126 mDueTimeEdit = new KOTimeEdit(timeBoxFrame);
120 layoutTimeBox->addWidget(mDueTimeEdit,1,2); 127 layoutTimeBox->addWidget(mDueTimeEdit,1,2);
121 128
122 129
123 mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); 130 mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame);
124 layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); 131 layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1);
125 132
126 connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); 133 connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool)));
127 connect(mDueDateEdit,SIGNAL(setTimeTo(QTime)),mDueTimeEdit,SLOT(setTime(QTime))); 134 connect(mDueDateEdit,SIGNAL(setTimeTo(QTime)),mDueTimeEdit,SLOT(setTime(QTime)));
128 connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime))); 135 connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime)));
129 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), 136 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)),
130 this, SLOT(startDateChanged(QDate))); 137 this, SLOT(startDateChanged(QDate)));
131 // some more layouting 138 // some more layouting
132 //layoutTimeBox->setColStretch(3,1); 139 //layoutTimeBox->setColStretch(3,1);
133} 140}
134 141
135 142
136void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) 143void KOEditorGeneralTodo::initCompletion(QWidget *parent, Q3BoxLayout *topLayout)
137{ 144{
138 mCompletedCombo = new QComboBox(parent); 145 mCompletedCombo = new QComboBox(parent);
139 // xgettext:no-c-format 146 // xgettext:no-c-format
140 mCompletedCombo->insertItem(i18n(" 0 %")); 147 mCompletedCombo->insertItem(i18n(" 0 %"));
141 // xgettext:no-c-format 148 // xgettext:no-c-format
142 mCompletedCombo->insertItem(i18n(" 20 %")); 149 mCompletedCombo->insertItem(i18n(" 20 %"));
143 // xgettext:no-c-format 150 // xgettext:no-c-format
144 mCompletedCombo->insertItem(i18n(" 40 %")); 151 mCompletedCombo->insertItem(i18n(" 40 %"));
145 // xgettext:no-c-format 152 // xgettext:no-c-format
146 mCompletedCombo->insertItem(i18n(" 60 %")); 153 mCompletedCombo->insertItem(i18n(" 60 %"));
147 // xgettext:no-c-format 154 // xgettext:no-c-format
148 mCompletedCombo->insertItem(i18n(" 80 %")); 155 mCompletedCombo->insertItem(i18n(" 80 %"));
149 // xgettext:no-c-format 156 // xgettext:no-c-format
150 mCompletedCombo->insertItem(i18n("100 %")); 157 mCompletedCombo->insertItem(i18n("100 %"));
151 connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); 158 connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int)));
152 topLayout->addWidget(mCompletedCombo); 159 topLayout->addWidget(mCompletedCombo);
153 160
154 mCompletedLabel = new QLabel(i18n("completed"),parent); 161 mCompletedLabel = new QLabel(i18n("completed"),parent);
155 topLayout->addWidget(mCompletedLabel); 162 topLayout->addWidget(mCompletedLabel);
156 163
157 mCompleteDateEdit = new KDateEdit(parent); 164 mCompleteDateEdit = new KDateEdit(parent);
158 topLayout->addWidget(mCompleteDateEdit ); 165 topLayout->addWidget(mCompleteDateEdit );
159 166
160 mCompleteTimeEdit = new KOTimeEdit(parent); 167 mCompleteTimeEdit = new KOTimeEdit(parent);
161 topLayout->addWidget( mCompleteTimeEdit); 168 topLayout->addWidget( mCompleteTimeEdit);
162 169
163 mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); 170 mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) );
164 mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); 171 mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) );
165 connect(mCompleteDateEdit,SIGNAL(setTimeTo(QTime)),mCompleteTimeEdit,SLOT(setTime(QTime))); 172 connect(mCompleteDateEdit,SIGNAL(setTimeTo(QTime)),mCompleteTimeEdit,SLOT(setTime(QTime)));
166 173
167 if ( QApplication::desktop()->width() <= 480 ) { 174 if ( QApplication::desktop()->width() <= 480 ) {
168 if ( QApplication::desktop()->width() < 320 ) 175 if ( QApplication::desktop()->width() < 320 )
169 mCompleteDateEdit->setMaximumWidth( 85 ); 176 mCompleteDateEdit->setMaximumWidth( 85 );
170 else 177 else
171 mCompleteDateEdit->setMaximumWidth( 140 ); 178 mCompleteDateEdit->setMaximumWidth( 140 );
172 topLayout->setSpacing( 0 ); 179 topLayout->setSpacing( 0 );
173 } 180 }
174} 181}
175 182
176void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) 183void KOEditorGeneralTodo::initPriority(QWidget *parent, Q3BoxLayout *topLayout)
177{ 184{
178 185
179 QHBox* h = new QHBox ( parent ); 186 Q3HBox* h = new Q3HBox ( parent );
180 topLayout->addWidget( h ); 187 topLayout->addWidget( h );
181 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); 188 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h);
182 // topLayout->addWidget(priorityLabel); 189 // topLayout->addWidget(priorityLabel);
183 mPriorityCombo = new QComboBox( h ); 190 mPriorityCombo = new QComboBox( h );
184 mPriorityCombo->insertItem(i18n("1 (high)")); 191 mPriorityCombo->insertItem(i18n("1 (high)"));
185 mPriorityCombo->insertItem(i18n("2")); 192 mPriorityCombo->insertItem(i18n("2"));
186 mPriorityCombo->insertItem(i18n("3")); 193 mPriorityCombo->insertItem(i18n("3"));
187 mPriorityCombo->insertItem(i18n("4")); 194 mPriorityCombo->insertItem(i18n("4"));
188 mPriorityCombo->insertItem(i18n("5 (low)")); 195 mPriorityCombo->insertItem(i18n("5 (low)"));
189 //topLayout->addWidget(mPriorityCombo); 196 //topLayout->addWidget(mPriorityCombo);
190} 197}
191 198
192void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) 199void KOEditorGeneralTodo::initStatus(QWidget *parent,Q3BoxLayout *topLayout)
193{ 200{
194 QBoxLayout *statusLayout = new QHBoxLayout(topLayout); 201 Q3BoxLayout *statusLayout = new Q3HBoxLayout(topLayout);
195 202
196 initCompletion( parent, statusLayout ); 203 initCompletion( parent, statusLayout );
197 204
198 statusLayout->addStretch( 1 ); 205 statusLayout->addStretch( 1 );
199 206
200 initPriority( parent, statusLayout ); 207 initPriority( parent, statusLayout );
201} 208}
202 209
203void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) 210void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay)
204{ 211{
205 212
206 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 213 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
207 mLocationEdit->load(KOLocationBox::LOCATION); 214 mLocationEdit->load(KOLocationBox::LOCATION);
208 KOEditorGeneral::setDefaults(allDay); 215 KOEditorGeneral::setDefaults(allDay);
209 216
210 mTimeButton->setChecked( !allDay ); 217 mTimeButton->setChecked( !allDay );
211 mTimeButton->setEnabled( !allDay ); 218 mTimeButton->setEnabled( !allDay );
212 219
213 enableTimeEdits( !allDay ); 220 enableTimeEdits( !allDay );
214 if ( due.isValid() ) { 221 if ( due.isValid() ) {
215 mDueCheck->setChecked(true); 222 mDueCheck->setChecked(true);
216 enableDueEdit(true); 223 enableDueEdit(true);
217 alarmDisable(false); 224 alarmDisable(false);
218 } else { 225 } else {
@@ -375,49 +382,49 @@ void KOEditorGeneralTodo::enableDueEdit(bool enable)
375} 382}
376 383
377void KOEditorGeneralTodo::enableStartEdit( bool enable ) 384void KOEditorGeneralTodo::enableStartEdit( bool enable )
378{ 385{
379 mStartDateEdit->setEnabled( enable ); 386 mStartDateEdit->setEnabled( enable );
380 387
381 if(mDueCheck->isChecked() || mStartCheck->isChecked()) { 388 if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
382 mTimeButton->setEnabled(true); 389 mTimeButton->setEnabled(true);
383 } 390 }
384 else { 391 else {
385 mTimeButton->setEnabled(false); 392 mTimeButton->setEnabled(false);
386 mTimeButton->setChecked(false); 393 mTimeButton->setChecked(false);
387 } 394 }
388 395
389 if (enable) { 396 if (enable) {
390 mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); 397 mStartTimeEdit->setEnabled( mTimeButton->isChecked() );
391 } else { 398 } else {
392 mStartTimeEdit->setEnabled( false ); 399 mStartTimeEdit->setEnabled( false );
393 } 400 }
394 emit datesChecked(); 401 emit datesChecked();
395} 402}
396void KOEditorGeneralTodo::startDateChanged(QDate newdate) 403void KOEditorGeneralTodo::startDateChanged(QDate newdate)
397{ 404{
398 if ( mDueCheck->isChecked() ) 405 if ( mDueCheck->isChecked() )
399 emit dateTimesChanged(newdate,mDueDateEdit->date()); 406 emit dateTimesChanged((QDateTime)newdate,(QDateTime)mDueDateEdit->date());
400} 407}
401void KOEditorGeneralTodo::enableTimeEdits(bool enable) 408void KOEditorGeneralTodo::enableTimeEdits(bool enable)
402{ 409{
403 if(mStartCheck->isChecked()) { 410 if(mStartCheck->isChecked()) {
404 mStartTimeEdit->setEnabled( enable ); 411 mStartTimeEdit->setEnabled( enable );
405 } 412 }
406 if(mDueCheck->isChecked()) { 413 if(mDueCheck->isChecked()) {
407 mDueTimeEdit->setEnabled( enable ); 414 mDueTimeEdit->setEnabled( enable );
408 } 415 }
409} 416}
410 417
411void KOEditorGeneralTodo::showAlarm() 418void KOEditorGeneralTodo::showAlarm()
412{ 419{
413 if ( mDueCheck->isChecked() ) { 420 if ( mDueCheck->isChecked() ) {
414 alarmDisable(false); 421 alarmDisable(false);
415 } 422 }
416 else { 423 else {
417 alarmDisable(true); 424 alarmDisable(true);
418 } 425 }
419} 426}
420 427
421bool KOEditorGeneralTodo::validateInput() 428bool KOEditorGeneralTodo::validateInput()
422{ 429{
423 if (mDueCheck->isChecked()) { 430 if (mDueCheck->isChecked()) {