author | zautrix <zautrix> | 2005-04-06 09:41:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-06 09:41:54 (UTC) |
commit | 03c5656deeec67eefcefb4faa1bfc9a9bc3254ef (patch) (unidiff) | |
tree | b514080a9b5256373967602d3a0ec41c68a70126 /korganizer | |
parent | cf4848d972efe96640f2d5f5d52704306d0cbe4c (diff) | |
download | kdepimpi-03c5656deeec67eefcefb4faa1bfc9a9bc3254ef.zip kdepimpi-03c5656deeec67eefcefb4faa1bfc9a9bc3254ef.tar.gz kdepimpi-03c5656deeec67eefcefb4faa1bfc9a9bc3254ef.tar.bz2 |
focus fix
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 13 | ||||
-rw-r--r-- | korganizer/koeditorgeneral.h | 3 | ||||
-rw-r--r-- | korganizer/koeventeditor.cpp | 1 |
3 files changed, 11 insertions, 6 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index abc80d4..f54660f 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -1,372 +1,377 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | 33 | ||
34 | 34 | ||
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <kdebug.h> | 36 | #include <kdebug.h> |
37 | #include <klocale.h> | 37 | #include <klocale.h> |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | #include <kfiledialog.h> | 40 | #include <kfiledialog.h> |
41 | #include <kstandarddirs.h> | 41 | #include <kstandarddirs.h> |
42 | 42 | ||
43 | #include <libkcal/todo.h> | 43 | #include <libkcal/todo.h> |
44 | #include <libkcal/event.h> | 44 | #include <libkcal/event.h> |
45 | #include <libkdepim/categoryselectdialog.h> | 45 | #include <libkdepim/categoryselectdialog.h> |
46 | #include <libkdepim/kdateedit.h> | 46 | #include <libkdepim/kdateedit.h> |
47 | 47 | ||
48 | #include "koprefs.h" | 48 | #include "koprefs.h" |
49 | #include "koglobals.h" | 49 | #include "koglobals.h" |
50 | 50 | ||
51 | #include "koeditorgeneral.h" | 51 | #include "koeditorgeneral.h" |
52 | #include "kolocationbox.h" | 52 | #include "kolocationbox.h" |
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #else | 55 | #else |
56 | #include <qapplication.h> | 56 | #include <qapplication.h> |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : | 59 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : |
60 | QObject( parent, name) | 60 | QObject( parent, name) |
61 | { | 61 | { |
62 | mNextFocus = 0; | ||
62 | } | 63 | } |
63 | 64 | ||
64 | KOEditorGeneral::~KOEditorGeneral() | 65 | KOEditorGeneral::~KOEditorGeneral() |
65 | { | 66 | { |
66 | } | 67 | } |
67 | 68 | ||
68 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 69 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
69 | { | 70 | { |
70 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 71 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
71 | 72 | ||
72 | #if 0 | 73 | #if 0 |
73 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 74 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
74 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 75 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
75 | #endif | 76 | #endif |
76 | 77 | ||
77 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 78 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
78 | headerLayout->addWidget(summaryLabel,1,0); | 79 | headerLayout->addWidget(summaryLabel,1,0); |
79 | 80 | ||
80 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); | 81 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); |
81 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 82 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
82 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 83 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
83 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 84 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
84 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 85 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
85 | if ( QApplication::desktop()->width() > 320 ) | 86 | if ( QApplication::desktop()->width() > 320 ) |
86 | mSummaryEdit->setMaximumHeight( hei +6 ); | 87 | mSummaryEdit->setMaximumHeight( hei +6 ); |
87 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 88 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); |
88 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } | 89 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
89 | // mSummaryEdit = new QLineEdit(parent); | 90 | // mSummaryEdit = new QLineEdit(parent); |
90 | headerLayout->addWidget(mSummaryEdit,1,1); | 91 | headerLayout->addWidget(mSummaryEdit,1,1); |
91 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 92 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
92 | 93 | ||
93 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 94 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
94 | headerLayout->addWidget(locationLabel,2,0); | 95 | headerLayout->addWidget(locationLabel,2,0); |
95 | 96 | ||
96 | mLocationEdit = new KOLocationBox(TRUE,parent,10); | 97 | mLocationEdit = new KOLocationBox(TRUE,parent,10); |
97 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 98 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
98 | if ( QApplication::desktop()->width() > 320 ) | 99 | if ( QApplication::desktop()->width() > 320 ) |
99 | mLocationEdit->setMaximumHeight( hei + 6); | 100 | mLocationEdit->setMaximumHeight( hei + 6); |
100 | 101 | ||
101 | // mLocationEdit = new QLineEdit(parent); | 102 | // mLocationEdit = new QLineEdit(parent); |
102 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 103 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
103 | headerLayout->addWidget(mLocationEdit,2,1); | 104 | headerLayout->addWidget(mLocationEdit,2,1); |
104 | headerLayout->setColStretch( 1, 10); | 105 | headerLayout->setColStretch( 1, 10); |
105 | } | 106 | } |
106 | void KOEditorGeneral::setFocusOn( int i ) | 107 | void KOEditorGeneral::setFocusOn( int i ) |
107 | { | 108 | { |
108 | qApp->processEvents(); | 109 | mNextFocus = i; |
109 | if ( i == 1 ) { | 110 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); |
111 | } | ||
112 | void KOEditorGeneral::slotSetFocusOn() | ||
113 | { | ||
114 | mNextFocus; | ||
115 | if ( mNextFocus == 1 ) { | ||
110 | mDescriptionEdit->setFocus(); | 116 | mDescriptionEdit->setFocus(); |
111 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 117 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
112 | } | 118 | } |
113 | if ( i == 2 ) { | 119 | if ( mNextFocus == 2 ) { |
114 | mSummaryEdit->setFocus(); | 120 | mSummaryEdit->setFocus(); |
115 | } | 121 | } |
116 | |||
117 | } | 122 | } |
118 | void KOEditorGeneral::editCategories() | 123 | void KOEditorGeneral::editCategories() |
119 | { | 124 | { |
120 | // qDebug("KOEditorGeneral::editCategories() "); | 125 | // qDebug("KOEditorGeneral::editCategories() "); |
121 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 126 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
122 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 127 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
123 | //KOGlobals::fitDialogToScreen( csd ); | 128 | //KOGlobals::fitDialogToScreen( csd ); |
124 | csd->setColorEnabled(); | 129 | csd->setColorEnabled(); |
125 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 130 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
126 | csd->exec(); | 131 | csd->exec(); |
127 | delete csd; | 132 | delete csd; |
128 | } | 133 | } |
129 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 134 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
130 | { | 135 | { |
131 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 136 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
132 | 137 | ||
133 | mCategoriesButton = new QPushButton(parent); | 138 | mCategoriesButton = new QPushButton(parent); |
134 | mCategoriesButton->setText(i18n("Categories...")); | 139 | mCategoriesButton->setText(i18n("Categories...")); |
135 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 140 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
136 | categoriesLayout->addWidget(mCategoriesButton); | 141 | categoriesLayout->addWidget(mCategoriesButton); |
137 | 142 | ||
138 | mCategoriesLabel = new QLabel(parent); | 143 | mCategoriesLabel = new QLabel(parent); |
139 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 144 | mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
140 | categoriesLayout->addWidget(mCategoriesLabel,1); | 145 | categoriesLayout->addWidget(mCategoriesLabel,1); |
141 | } | 146 | } |
142 | 147 | ||
143 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 148 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
144 | { | 149 | { |
145 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 150 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
146 | 151 | ||
147 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 152 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
148 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 153 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
149 | secrecyLayout->addWidget(mCancelBox); | 154 | secrecyLayout->addWidget(mCancelBox); |
150 | secrecyLayout->addWidget(secrecyLabel); | 155 | secrecyLayout->addWidget(secrecyLabel); |
151 | 156 | ||
152 | mSecrecyCombo = new QComboBox(parent); | 157 | mSecrecyCombo = new QComboBox(parent); |
153 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 158 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
154 | secrecyLayout->addWidget(mSecrecyCombo); | 159 | secrecyLayout->addWidget(mSecrecyCombo); |
155 | } | 160 | } |
156 | 161 | ||
157 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 162 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
158 | { | 163 | { |
159 | mDescriptionEdit = new KTextEdit(parent); | 164 | mDescriptionEdit = new KTextEdit(parent); |
160 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 165 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
161 | mDescriptionEdit->append(""); | 166 | mDescriptionEdit->append(""); |
162 | mDescriptionEdit->setReadOnly(false); | 167 | mDescriptionEdit->setReadOnly(false); |
163 | mDescriptionEdit->setOverwriteMode(false); | 168 | mDescriptionEdit->setOverwriteMode(false); |
164 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 169 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
165 | topLayout->addWidget(mDescriptionEdit); | 170 | topLayout->addWidget(mDescriptionEdit); |
166 | #ifndef DESKTOP_VERSION | 171 | #ifndef DESKTOP_VERSION |
167 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 172 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
168 | #endif | 173 | #endif |
169 | 174 | ||
170 | } | 175 | } |
171 | 176 | ||
172 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 177 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
173 | { | 178 | { |
174 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 179 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
175 | 180 | ||
176 | //mAlarmBell = new QLabel(parent); | 181 | //mAlarmBell = new QLabel(parent); |
177 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 182 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
178 | //alarmLayout->addWidget(mAlarmBell); | 183 | //alarmLayout->addWidget(mAlarmBell); |
179 | if ( QApplication::desktop()->width() < 320 ) | 184 | if ( QApplication::desktop()->width() < 320 ) |
180 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 185 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
181 | else | 186 | else |
182 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 187 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
183 | 188 | ||
184 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 189 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
185 | alarmLayout->addWidget(mAlarmButton); | 190 | alarmLayout->addWidget(mAlarmButton); |
186 | 191 | ||
187 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 192 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
188 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); | 193 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); |
189 | alarmLayout->addWidget(mAlarmTimeEdit); | 194 | alarmLayout->addWidget(mAlarmTimeEdit); |
190 | mAlarmIncrCombo = new QComboBox(false, parent); | 195 | mAlarmIncrCombo = new QComboBox(false, parent); |
191 | if ( QApplication::desktop()->width() < 320 ) { | 196 | if ( QApplication::desktop()->width() < 320 ) { |
192 | mAlarmIncrCombo->insertItem(i18n("min")); | 197 | mAlarmIncrCombo->insertItem(i18n("min")); |
193 | mAlarmIncrCombo->insertItem(i18n("hou")); | 198 | mAlarmIncrCombo->insertItem(i18n("hou")); |
194 | mAlarmIncrCombo->insertItem(i18n("day")); | 199 | mAlarmIncrCombo->insertItem(i18n("day")); |
195 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 200 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
196 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 201 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
197 | } else { | 202 | } else { |
198 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 203 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
199 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 204 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
200 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 205 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
201 | } | 206 | } |
202 | 207 | ||
203 | // mAlarmIncrCombo->setMinimumHeight(20); | 208 | // mAlarmIncrCombo->setMinimumHeight(20); |
204 | alarmLayout->addWidget(mAlarmIncrCombo); | 209 | alarmLayout->addWidget(mAlarmIncrCombo); |
205 | mAlarmSoundButton = new QPushButton(parent); | 210 | mAlarmSoundButton = new QPushButton(parent); |
206 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 211 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
207 | mAlarmSoundButton->setToggleButton(true); | 212 | mAlarmSoundButton->setToggleButton(true); |
208 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 213 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
209 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 214 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
210 | alarmLayout->addWidget(mAlarmSoundButton); | 215 | alarmLayout->addWidget(mAlarmSoundButton); |
211 | 216 | ||
212 | mAlarmProgramButton = new QPushButton(parent); | 217 | mAlarmProgramButton = new QPushButton(parent); |
213 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 218 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
214 | mAlarmProgramButton->setToggleButton(true); | 219 | mAlarmProgramButton->setToggleButton(true); |
215 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 220 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
216 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 221 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
217 | alarmLayout->addWidget(mAlarmProgramButton); | 222 | alarmLayout->addWidget(mAlarmProgramButton); |
218 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 223 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
219 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 224 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
220 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 225 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
221 | // mAlarmSoundButton->hide(); | 226 | // mAlarmSoundButton->hide(); |
222 | // mAlarmProgramButton->hide(); | 227 | // mAlarmProgramButton->hide(); |
223 | // } | 228 | // } |
224 | } | 229 | } |
225 | 230 | ||
226 | void KOEditorGeneral::pickAlarmSound() | 231 | void KOEditorGeneral::pickAlarmSound() |
227 | { | 232 | { |
228 | 233 | ||
229 | qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); | 234 | qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); |
230 | 235 | ||
231 | bool oldState = mAlarmSoundButton->isOn(); | 236 | bool oldState = mAlarmSoundButton->isOn(); |
232 | 237 | ||
233 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 238 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
234 | i18n("*.wav|Wav Files"), 0)); | 239 | i18n("*.wav|Wav Files"), 0)); |
235 | if (!fileName.isEmpty()) { | 240 | if (!fileName.isEmpty()) { |
236 | mAlarmSound = fileName; | 241 | mAlarmSound = fileName; |
237 | QToolTip::remove(mAlarmSoundButton); | 242 | QToolTip::remove(mAlarmSoundButton); |
238 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 243 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
239 | QToolTip::add(mAlarmSoundButton, dispStr); | 244 | QToolTip::add(mAlarmSoundButton, dispStr); |
240 | mAlarmProgramButton->setOn(false); | 245 | mAlarmProgramButton->setOn(false); |
241 | mAlarmSoundButton->setOn(true); | 246 | mAlarmSoundButton->setOn(true); |
242 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 247 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
243 | } else { | 248 | } else { |
244 | mAlarmProgramButton->setOn(oldState); | 249 | mAlarmProgramButton->setOn(oldState); |
245 | mAlarmSoundButton->setOn(!oldState); | 250 | mAlarmSoundButton->setOn(!oldState); |
246 | 251 | ||
247 | 252 | ||
248 | } | 253 | } |
249 | 254 | ||
250 | if (mAlarmProgramButton->isOn()) | 255 | if (mAlarmProgramButton->isOn()) |
251 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 256 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
252 | if ( mAlarmSoundButton->isOn()) | 257 | if ( mAlarmSoundButton->isOn()) |
253 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 258 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
254 | 259 | ||
255 | } | 260 | } |
256 | 261 | ||
257 | void KOEditorGeneral::pickAlarmProgram() | 262 | void KOEditorGeneral::pickAlarmProgram() |
258 | { | 263 | { |
259 | bool oldState = mAlarmProgramButton->isOn(); | 264 | bool oldState = mAlarmProgramButton->isOn(); |
260 | 265 | ||
261 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); | 266 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); |
262 | if (!fileName.isEmpty()) { | 267 | if (!fileName.isEmpty()) { |
263 | mAlarmProgram = fileName; | 268 | mAlarmProgram = fileName; |
264 | QToolTip::remove(mAlarmProgramButton); | 269 | QToolTip::remove(mAlarmProgramButton); |
265 | QString dispStr = i18n("Running '%1'").arg(fileName); | 270 | QString dispStr = i18n("Running '%1'").arg(fileName); |
266 | QToolTip::add(mAlarmProgramButton, dispStr); | 271 | QToolTip::add(mAlarmProgramButton, dispStr); |
267 | mAlarmSoundButton->setOn(false); | 272 | mAlarmSoundButton->setOn(false); |
268 | mAlarmProgramButton->setOn(true); | 273 | mAlarmProgramButton->setOn(true); |
269 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 274 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
270 | } else { | 275 | } else { |
271 | mAlarmProgramButton->setOn(!oldState); | 276 | mAlarmProgramButton->setOn(!oldState); |
272 | mAlarmSoundButton->setOn(oldState); | 277 | mAlarmSoundButton->setOn(oldState); |
273 | } | 278 | } |
274 | 279 | ||
275 | if (mAlarmProgramButton->isOn()) | 280 | if (mAlarmProgramButton->isOn()) |
276 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 281 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
277 | if ( mAlarmSoundButton->isOn()) | 282 | if ( mAlarmSoundButton->isOn()) |
278 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 283 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
279 | 284 | ||
280 | } | 285 | } |
281 | 286 | ||
282 | 287 | ||
283 | QString KOEditorGeneral::getFittingPath( const QString s ) | 288 | QString KOEditorGeneral::getFittingPath( const QString s ) |
284 | { | 289 | { |
285 | int maxlen = 50; | 290 | int maxlen = 50; |
286 | if ( QApplication::desktop()->width() < 640 ) { | 291 | if ( QApplication::desktop()->width() < 640 ) { |
287 | if ( QApplication::desktop()->width() < 320 ) | 292 | if ( QApplication::desktop()->width() < 320 ) |
288 | maxlen = 22; | 293 | maxlen = 22; |
289 | else | 294 | else |
290 | maxlen = 35; | 295 | maxlen = 35; |
291 | } | 296 | } |
292 | if ( s.length() > maxlen ) { | 297 | if ( s.length() > maxlen ) { |
293 | return "..."+s.right(maxlen -3); | 298 | return "..."+s.right(maxlen -3); |
294 | } | 299 | } |
295 | return s; | 300 | return s; |
296 | } | 301 | } |
297 | 302 | ||
298 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 303 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
299 | { | 304 | { |
300 | if ( enable ) { | 305 | if ( enable ) { |
301 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 306 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
302 | mAlarmSoundButton->setOn( true ); | 307 | mAlarmSoundButton->setOn( true ); |
303 | if ( mAlarmSound.isEmpty() ) | 308 | if ( mAlarmSound.isEmpty() ) |
304 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 309 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
305 | else { | 310 | else { |
306 | if ( ! QFile::exists( mAlarmSound ) ) | 311 | if ( ! QFile::exists( mAlarmSound ) ) |
307 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 312 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
308 | } | 313 | } |
309 | } | 314 | } |
310 | } | 315 | } |
311 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); | 316 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); |
312 | mAlarmTimeEdit->setEnabled(enable); | 317 | mAlarmTimeEdit->setEnabled(enable); |
313 | mAlarmSoundButton->setEnabled(enable); | 318 | mAlarmSoundButton->setEnabled(enable); |
314 | mAlarmProgramButton->setEnabled(enable); | 319 | mAlarmProgramButton->setEnabled(enable); |
315 | mAlarmIncrCombo->setEnabled(enable); | 320 | mAlarmIncrCombo->setEnabled(enable); |
316 | } | 321 | } |
317 | 322 | ||
318 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 323 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
319 | { | 324 | { |
320 | enableAlarmEdit( !disable ); | 325 | enableAlarmEdit( !disable ); |
321 | } | 326 | } |
322 | 327 | ||
323 | void KOEditorGeneral::enableAlarm( bool enable ) | 328 | void KOEditorGeneral::enableAlarm( bool enable ) |
324 | { | 329 | { |
325 | enableAlarmEdit( enable ); | 330 | enableAlarmEdit( enable ); |
326 | } | 331 | } |
327 | 332 | ||
328 | void KOEditorGeneral::alarmDisable(bool disable) | 333 | void KOEditorGeneral::alarmDisable(bool disable) |
329 | { | 334 | { |
330 | if (!disable) { | 335 | if (!disable) { |
331 | //mAlarmBell->setEnabled(true); | 336 | //mAlarmBell->setEnabled(true); |
332 | mAlarmButton->setEnabled(true); | 337 | mAlarmButton->setEnabled(true); |
333 | } else { | 338 | } else { |
334 | //mAlarmBell->setEnabled(false); | 339 | //mAlarmBell->setEnabled(false); |
335 | mAlarmButton->setEnabled(false); | 340 | mAlarmButton->setEnabled(false); |
336 | mAlarmButton->setChecked(false); | 341 | mAlarmButton->setChecked(false); |
337 | mAlarmTimeEdit->setEnabled(false); | 342 | mAlarmTimeEdit->setEnabled(false); |
338 | mAlarmSoundButton->setEnabled(false); | 343 | mAlarmSoundButton->setEnabled(false); |
339 | mAlarmProgramButton->setEnabled(false); | 344 | mAlarmProgramButton->setEnabled(false); |
340 | mAlarmIncrCombo->setEnabled(false); | 345 | mAlarmIncrCombo->setEnabled(false); |
341 | } | 346 | } |
342 | } | 347 | } |
343 | 348 | ||
344 | void KOEditorGeneral::setCategories(const QString &str) | 349 | void KOEditorGeneral::setCategories(const QString &str) |
345 | { | 350 | { |
346 | mCategoriesLabel->setText(str); | 351 | mCategoriesLabel->setText(str); |
347 | } | 352 | } |
348 | 353 | ||
349 | void KOEditorGeneral::setDefaults(bool allDay) | 354 | void KOEditorGeneral::setDefaults(bool allDay) |
350 | { | 355 | { |
351 | #if 0 | 356 | #if 0 |
352 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 357 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
353 | #endif | 358 | #endif |
354 | 359 | ||
355 | mAlarmMessage = i18n("Edit new item"); | 360 | mAlarmMessage = i18n("Edit new item"); |
356 | enableAlarmEdit( !allDay ); | 361 | enableAlarmEdit( !allDay ); |
357 | 362 | ||
358 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 363 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
359 | int alarmTime; | 364 | int alarmTime; |
360 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 365 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
361 | int index = KOPrefs::instance()->mAlarmTime; | 366 | int index = KOPrefs::instance()->mAlarmTime; |
362 | if (index < 0 || index > 7) { | 367 | if (index < 0 || index > 7) { |
363 | alarmTime = 15; | 368 | alarmTime = 15; |
364 | } else { | 369 | } else { |
365 | alarmTime = a[index]; | 370 | alarmTime = a[index]; |
366 | } | 371 | } |
367 | mAlarmButton ->setChecked( false ); | 372 | mAlarmButton ->setChecked( false ); |
368 | mAlarmTimeEdit->setValue(alarmTime); | 373 | mAlarmTimeEdit->setValue(alarmTime); |
369 | mAlarmIncrCombo->setCurrentItem(0); | 374 | mAlarmIncrCombo->setCurrentItem(0); |
370 | enableAlarmEdit( false ); | 375 | enableAlarmEdit( false ); |
371 | //alarmDisable (false); | 376 | //alarmDisable (false); |
372 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 377 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
diff --git a/korganizer/koeditorgeneral.h b/korganizer/koeditorgeneral.h index f4728c7..2069e9c 100644 --- a/korganizer/koeditorgeneral.h +++ b/korganizer/koeditorgeneral.h | |||
@@ -1,114 +1,115 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 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 | #ifndef KOEDITORGENERAL_H | 23 | #ifndef KOEDITORGENERAL_H |
24 | #define KOEDITORGENERAL_H | 24 | #define KOEDITORGENERAL_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qcheckbox.h> | 28 | #include <qcheckbox.h> |
29 | #include <qpushbutton.h> | 29 | #include <qpushbutton.h> |
30 | #include <qgroupbox.h> | 30 | #include <qgroupbox.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qlistview.h> | 33 | #include <qlistview.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | 37 | ||
38 | #include <ktextedit.h> | 38 | #include <ktextedit.h> |
39 | #include <krestrictedline.h> | 39 | #include <krestrictedline.h> |
40 | 40 | ||
41 | #include <libkcal/incidence.h> | 41 | #include <libkcal/incidence.h> |
42 | 42 | ||
43 | #include "ktimeedit.h" | 43 | #include "ktimeedit.h" |
44 | 44 | ||
45 | class KDateEdit; | 45 | class KDateEdit; |
46 | class KOLocationBox; | 46 | class KOLocationBox; |
47 | using namespace KCal; | 47 | using namespace KCal; |
48 | 48 | ||
49 | class KOEditorGeneral : public QObject | 49 | class KOEditorGeneral : public QObject |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | KOEditorGeneral (QObject* parent=0,const char* name=0); | 53 | KOEditorGeneral (QObject* parent=0,const char* name=0); |
54 | virtual ~KOEditorGeneral(); | 54 | virtual ~KOEditorGeneral(); |
55 | void setFocusOn( int i ); | 55 | void setFocusOn( int i ); |
56 | void initHeader(QWidget *,QBoxLayout *); | 56 | void initHeader(QWidget *,QBoxLayout *); |
57 | void initDescription(QWidget *,QBoxLayout *); | 57 | void initDescription(QWidget *,QBoxLayout *); |
58 | void initSecrecy(QWidget *,QBoxLayout *); | 58 | void initSecrecy(QWidget *,QBoxLayout *); |
59 | void initCategories(QWidget *,QBoxLayout *); | 59 | void initCategories(QWidget *,QBoxLayout *); |
60 | void initAlarm(QWidget *,QBoxLayout *); | 60 | void initAlarm(QWidget *,QBoxLayout *); |
61 | 61 | ||
62 | /** Set widgets to default values */ | 62 | /** Set widgets to default values */ |
63 | void setDefaults(bool allDay); | 63 | void setDefaults(bool allDay); |
64 | /** Read event object and setup widgets accordingly */ | 64 | /** Read event object and setup widgets accordingly */ |
65 | void readIncidence(Incidence *); | 65 | void readIncidence(Incidence *); |
66 | /** Write event settings to event object */ | 66 | /** Write event settings to event object */ |
67 | void writeIncidence(Incidence *); | 67 | void writeIncidence(Incidence *); |
68 | 68 | ||
69 | /** Check if the input is valid. */ | 69 | /** Check if the input is valid. */ |
70 | bool validateInput() { return true; } | 70 | bool validateInput() { return true; } |
71 | 71 | ||
72 | void enableAlarm( bool enable ); | 72 | void enableAlarm( bool enable ); |
73 | void setSecrecy( int num ); | 73 | void setSecrecy( int num ); |
74 | public slots: | 74 | public slots: |
75 | void setCategories(const QString &); | 75 | void setCategories(const QString &); |
76 | void editCategories(); | 76 | void editCategories(); |
77 | 77 | ||
78 | protected slots: | 78 | protected slots: |
79 | void enableAlarmEdit( bool enable ); | 79 | void enableAlarmEdit( bool enable ); |
80 | void disableAlarmEdit( bool disable ); | 80 | void disableAlarmEdit( bool disable ); |
81 | void alarmDisable( bool disable ); | 81 | void alarmDisable( bool disable ); |
82 | void pickAlarmSound(); | 82 | void pickAlarmSound(); |
83 | void pickAlarmProgram(); | 83 | void pickAlarmProgram(); |
84 | 84 | void slotSetFocusOn(); | |
85 | signals: | 85 | signals: |
86 | void openCategoryDialog(); | 86 | void openCategoryDialog(); |
87 | void allAccepted(); | 87 | void allAccepted(); |
88 | 88 | ||
89 | protected: | 89 | protected: |
90 | int mNextFocus; | ||
90 | //QLineEdit *mSummaryEdit; | 91 | //QLineEdit *mSummaryEdit; |
91 | //QLineEdit *mLocationEdit; | 92 | //QLineEdit *mLocationEdit; |
92 | KOLocationBox *mSummaryEdit; | 93 | KOLocationBox *mSummaryEdit; |
93 | KOLocationBox *mLocationEdit; | 94 | KOLocationBox *mLocationEdit; |
94 | QLabel *mAlarmBell; | 95 | QLabel *mAlarmBell; |
95 | QCheckBox *mAlarmButton; | 96 | QCheckBox *mAlarmButton; |
96 | QSpinBox *mAlarmTimeEdit; | 97 | QSpinBox *mAlarmTimeEdit; |
97 | QPushButton *mAlarmSoundButton; | 98 | QPushButton *mAlarmSoundButton; |
98 | QPushButton *mAlarmProgramButton; | 99 | QPushButton *mAlarmProgramButton; |
99 | QComboBox *mAlarmIncrCombo; | 100 | QComboBox *mAlarmIncrCombo; |
100 | KTextEdit *mDescriptionEdit; | 101 | KTextEdit *mDescriptionEdit; |
101 | QLabel *mOwnerLabel; | 102 | QLabel *mOwnerLabel; |
102 | QComboBox *mSecrecyCombo; | 103 | QComboBox *mSecrecyCombo; |
103 | QCheckBox *mCancelBox; | 104 | QCheckBox *mCancelBox; |
104 | QPushButton *mCategoriesButton; | 105 | QPushButton *mCategoriesButton; |
105 | QLabel *mCategoriesLabel; | 106 | QLabel *mCategoriesLabel; |
106 | 107 | ||
107 | private: | 108 | private: |
108 | QString getFittingPath( const QString ) ; | 109 | QString getFittingPath( const QString ) ; |
109 | QString mAlarmSound; | 110 | QString mAlarmSound; |
110 | QString mAlarmProgram; | 111 | QString mAlarmProgram; |
111 | QString mAlarmMessage; | 112 | QString mAlarmMessage; |
112 | }; | 113 | }; |
113 | 114 | ||
114 | #endif | 115 | #endif |
diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp index 337db9b..e23e680 100644 --- a/korganizer/koeventeditor.cpp +++ b/korganizer/koeventeditor.cpp | |||
@@ -1,377 +1,376 @@ | |||
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 <qframe.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qhbox.h> | 27 | #include <qhbox.h> |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | 32 | ||
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kstandarddirs.h> | 34 | #include <kstandarddirs.h> |
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kfiledialog.h> | 37 | #include <kfiledialog.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | #include <libkcal/calendarresources.h> | 39 | #include <libkcal/calendarresources.h> |
40 | #include <libkcal/resourcecalendar.h> | 40 | #include <libkcal/resourcecalendar.h> |
41 | #include <kresources/resourceselectdialog.h> | 41 | #include <kresources/resourceselectdialog.h> |
42 | 42 | ||
43 | #include <libkdepim/categoryselectdialog.h> | 43 | #include <libkdepim/categoryselectdialog.h> |
44 | #include <libkcal/calendarlocal.h> | 44 | #include <libkcal/calendarlocal.h> |
45 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koeventeditor.h" | 49 | #include "koeventeditor.h" |
50 | extern int globalFlagBlockAgenda; | 50 | extern int globalFlagBlockAgenda; |
51 | 51 | ||
52 | KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : | 52 | KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : |
53 | KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) | 53 | KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) |
54 | { | 54 | { |
55 | mEvent = 0; | 55 | mEvent = 0; |
56 | init(); | 56 | init(); |
57 | } | 57 | } |
58 | 58 | ||
59 | KOEventEditor::~KOEventEditor() | 59 | KOEventEditor::~KOEventEditor() |
60 | { | 60 | { |
61 | //emit dialogClose( mEvent ); | 61 | //emit dialogClose( mEvent ); |
62 | } | 62 | } |
63 | 63 | ||
64 | void KOEventEditor::init() | 64 | void KOEventEditor::init() |
65 | { | 65 | { |
66 | 66 | ||
67 | setupGeneral(); | 67 | setupGeneral(); |
68 | setupAttendeesTab(); | 68 | setupAttendeesTab(); |
69 | setupRecurrence(); | 69 | setupRecurrence(); |
70 | 70 | ||
71 | // Propagate date time settings to recurrence tab | 71 | // Propagate date time settings to recurrence tab |
72 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), | 72 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), |
73 | mRecurrence,SLOT(setDateTimes(QDateTime,QDateTime))); | 73 | mRecurrence,SLOT(setDateTimes(QDateTime,QDateTime))); |
74 | connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), | 74 | connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), |
75 | mRecurrence,SLOT(setDateTimeStr(const QString &))); | 75 | mRecurrence,SLOT(setDateTimeStr(const QString &))); |
76 | 76 | ||
77 | // Category dialog | 77 | // Category dialog |
78 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 78 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
79 | //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), | 79 | //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), |
80 | // mGeneral,SLOT(setCategories(const QString &))); | 80 | // mGeneral,SLOT(setCategories(const QString &))); |
81 | 81 | ||
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | void KOEventEditor::reload() | 85 | void KOEventEditor::reload() |
86 | { | 86 | { |
87 | if ( mEvent ) readEvent( mEvent ); | 87 | if ( mEvent ) readEvent( mEvent ); |
88 | } | 88 | } |
89 | 89 | ||
90 | void KOEventEditor::setSecrecy( int sec ) | 90 | void KOEventEditor::setSecrecy( int sec ) |
91 | { | 91 | { |
92 | mGeneral->setSecrecy( sec ); | 92 | mGeneral->setSecrecy( sec ); |
93 | } | 93 | } |
94 | void KOEventEditor::setCategories( QString s ) | 94 | void KOEventEditor::setCategories( QString s ) |
95 | { | 95 | { |
96 | mGeneral->setCategories(s); | 96 | mGeneral->setCategories(s); |
97 | 97 | ||
98 | } | 98 | } |
99 | void KOEventEditor::setupGeneral() | 99 | void KOEventEditor::setupGeneral() |
100 | { | 100 | { |
101 | mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); | 101 | mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); |
102 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 102 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
103 | 103 | ||
104 | if( KOPrefs::instance()->mCompactDialogs ) { | 104 | if( KOPrefs::instance()->mCompactDialogs ) { |
105 | QFrame *topFrame = addPage(i18n("General")); | 105 | QFrame *topFrame = addPage(i18n("General")); |
106 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 106 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
107 | topLayout->setSpacing(spacingHint()-1); | 107 | topLayout->setSpacing(spacingHint()-1); |
108 | topLayout->setMargin(marginHint()-1); | 108 | topLayout->setMargin(marginHint()-1); |
109 | mGeneral->initHeader(topFrame,topLayout); | 109 | mGeneral->initHeader(topFrame,topLayout); |
110 | mGeneral->initTime(topFrame,topLayout); | 110 | mGeneral->initTime(topFrame,topLayout); |
111 | // QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 111 | // QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
112 | mGeneral->initAlarm(topFrame,topLayout); | 112 | mGeneral->initAlarm(topFrame,topLayout); |
113 | mGeneral->enableAlarm( false ); | 113 | mGeneral->enableAlarm( false ); |
114 | 114 | ||
115 | QBoxLayout *buttonLayout; | 115 | QBoxLayout *buttonLayout; |
116 | if ( QApplication::desktop()->width() < 500 ) | 116 | if ( QApplication::desktop()->width() < 500 ) |
117 | buttonLayout = new QVBoxLayout( topLayout ); | 117 | buttonLayout = new QVBoxLayout( topLayout ); |
118 | else | 118 | else |
119 | buttonLayout = new QHBoxLayout( topLayout ); | 119 | buttonLayout = new QHBoxLayout( topLayout ); |
120 | QHBox* buttonWidget = new QHBox (topFrame); | 120 | QHBox* buttonWidget = new QHBox (topFrame); |
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 * loadTemplate = new QPushButton( buttonWidget); | 126 | QPushButton * loadTemplate = new QPushButton( buttonWidget); |
127 | QPushButton * saveTemplate = new QPushButton( buttonWidget); | 127 | QPushButton * saveTemplate = new QPushButton( buttonWidget); |
128 | saveTemplate->setIconSet (icon ) ; | 128 | saveTemplate->setIconSet (icon ) ; |
129 | int size = saveTemplate->sizeHint().height(); | 129 | int size = saveTemplate->sizeHint().height(); |
130 | saveTemplate->setFixedSize( size, size ); | 130 | saveTemplate->setFixedSize( size, size ); |
131 | if ( QApplication::desktop()->width() < 321 ) | 131 | if ( QApplication::desktop()->width() < 321 ) |
132 | icon = SmallIcon("fileimport16"); | 132 | icon = SmallIcon("fileimport16"); |
133 | else | 133 | else |
134 | icon = SmallIcon("fileimport"); | 134 | icon = SmallIcon("fileimport"); |
135 | loadTemplate->setIconSet (icon ) ; | 135 | loadTemplate->setIconSet (icon ) ; |
136 | loadTemplate->setFixedSize( size, size ); | 136 | loadTemplate->setFixedSize( size, size ); |
137 | buttonLayout->addWidget( buttonWidget ); | 137 | buttonLayout->addWidget( buttonWidget ); |
138 | mGeneral->initCategories( topFrame, buttonLayout ); | 138 | mGeneral->initCategories( topFrame, buttonLayout ); |
139 | 139 | ||
140 | topLayout->addStretch( 1 ); | 140 | topLayout->addStretch( 1 ); |
141 | 141 | ||
142 | QFrame *topFrame2 = addPage(i18n("Details")); | 142 | QFrame *topFrame2 = addPage(i18n("Details")); |
143 | 143 | ||
144 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 144 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
145 | topLayout2->setSpacing(spacingHint()); | 145 | topLayout2->setSpacing(spacingHint()); |
146 | 146 | ||
147 | mGeneral->initClass(topFrame2,topLayout2); | 147 | mGeneral->initClass(topFrame2,topLayout2); |
148 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 148 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
149 | mGeneral->initDescription(topFrame2,topLayout2); | 149 | mGeneral->initDescription(topFrame2,topLayout2); |
150 | 150 | ||
151 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 151 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
152 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 152 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
153 | } else { | 153 | } else { |
154 | QFrame *topFrame = addPage(i18n("General")); | 154 | QFrame *topFrame = addPage(i18n("General")); |
155 | 155 | ||
156 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 156 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
157 | topLayout->setSpacing(spacingHint()); | 157 | topLayout->setSpacing(spacingHint()); |
158 | 158 | ||
159 | mGeneral->initHeader(topFrame,topLayout); | 159 | mGeneral->initHeader(topFrame,topLayout); |
160 | mGeneral->initTime(topFrame,topLayout); | 160 | mGeneral->initTime(topFrame,topLayout); |
161 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 161 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
162 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 162 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
163 | mGeneral->initClass(topFrame,alarmLineLayout); | 163 | mGeneral->initClass(topFrame,alarmLineLayout); |
164 | mGeneral->initDescription(topFrame,topLayout); | 164 | mGeneral->initDescription(topFrame,topLayout); |
165 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 165 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
166 | mGeneral->initCategories( topFrame, detailsLayout ); | 166 | mGeneral->initCategories( topFrame, detailsLayout ); |
167 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 167 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
168 | } | 168 | } |
169 | 169 | ||
170 | mGeneral->finishSetup(); | 170 | mGeneral->finishSetup(); |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | void KOEventEditor::setupRecurrence() | 174 | void KOEventEditor::setupRecurrence() |
175 | { | 175 | { |
176 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 176 | QFrame *topFrame = addPage( i18n("Recurrence") ); |
177 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 177 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
178 | 178 | ||
179 | mRecurrence = new KOEditorRecurrence( topFrame ); | 179 | mRecurrence = new KOEditorRecurrence( topFrame ); |
180 | topLayout->addWidget( mRecurrence ); | 180 | topLayout->addWidget( mRecurrence ); |
181 | } | 181 | } |
182 | 182 | ||
183 | void KOEventEditor::editEvent(Event *event, bool showDescription) | 183 | void KOEventEditor::editEvent(Event *event, bool showDescription) |
184 | { | 184 | { |
185 | // init(); | 185 | // init(); |
186 | 186 | ||
187 | mEvent = event; | 187 | mEvent = event; |
188 | readEvent(mEvent); | 188 | readEvent(mEvent); |
189 | qApp->processEvents(); | ||
190 | if ( showDescription ) { | 189 | if ( showDescription ) { |
191 | showPage( 1 ); | 190 | showPage( 1 ); |
192 | mGeneral->setFocusOn( 1 ); | 191 | mGeneral->setFocusOn( 1 ); |
193 | } else { | 192 | } else { |
194 | showPage( 0 ); | 193 | showPage( 0 ); |
195 | mGeneral->setFocusOn( 2 ); | 194 | mGeneral->setFocusOn( 2 ); |
196 | } | 195 | } |
197 | } | 196 | } |
198 | 197 | ||
199 | void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) | 198 | void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) |
200 | { | 199 | { |
201 | // init(); | 200 | // init(); |
202 | 201 | ||
203 | mEvent = 0; | 202 | mEvent = 0; |
204 | setDefaults(from,to,allDay); | 203 | setDefaults(from,to,allDay); |
205 | } | 204 | } |
206 | 205 | ||
207 | void KOEventEditor::loadDefaults() | 206 | void KOEventEditor::loadDefaults() |
208 | { | 207 | { |
209 | int fmt = KOPrefs::instance()->mStartTime; | 208 | int fmt = KOPrefs::instance()->mStartTime; |
210 | 209 | ||
211 | QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); | 210 | QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); |
212 | QDateTime to(QDate::currentDate(), | 211 | QDateTime to(QDate::currentDate(), |
213 | QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); | 212 | QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); |
214 | 213 | ||
215 | setDefaults(from,to,false); | 214 | setDefaults(from,to,false); |
216 | } | 215 | } |
217 | 216 | ||
218 | bool KOEventEditor::processInput( bool emitTime ) | 217 | bool KOEventEditor::processInput( bool emitTime ) |
219 | { | 218 | { |
220 | if (!validateInput()) return false; | 219 | if (!validateInput()) return false; |
221 | 220 | ||
222 | Event *event = 0; | 221 | Event *event = 0; |
223 | 222 | ||
224 | if (mEvent) event = mEvent; | 223 | if (mEvent) event = mEvent; |
225 | else { | 224 | else { |
226 | event = new Event; | 225 | event = new Event; |
227 | event->setOrganizer(KOPrefs::instance()->email()); | 226 | event->setOrganizer(KOPrefs::instance()->email()); |
228 | } | 227 | } |
229 | 228 | ||
230 | writeEvent(event); | 229 | writeEvent(event); |
231 | if ( emitTime ) { | 230 | if ( emitTime ) { |
232 | globalFlagBlockAgenda = 1; | 231 | globalFlagBlockAgenda = 1; |
233 | emit showAgendaView( false ); | 232 | emit showAgendaView( false ); |
234 | emit jumpToTime( event->dtStart().date() ); | 233 | emit jumpToTime( event->dtStart().date() ); |
235 | globalFlagBlockAgenda = 2; | 234 | globalFlagBlockAgenda = 2; |
236 | 235 | ||
237 | } | 236 | } |
238 | if (mEvent) { | 237 | if (mEvent) { |
239 | event->setRevision(event->revision()+1); | 238 | event->setRevision(event->revision()+1); |
240 | emit eventChanged(event); | 239 | emit eventChanged(event); |
241 | } else { | 240 | } else { |
242 | mCalendar->addEvent(event); | 241 | mCalendar->addEvent(event); |
243 | mEvent = event; | 242 | mEvent = event; |
244 | emit eventAdded(event); | 243 | emit eventAdded(event); |
245 | } | 244 | } |
246 | 245 | ||
247 | return true; | 246 | return true; |
248 | } | 247 | } |
249 | 248 | ||
250 | void KOEventEditor::deleteEvent() | 249 | void KOEventEditor::deleteEvent() |
251 | { | 250 | { |
252 | kdDebug() << "Delete event" << endl; | 251 | kdDebug() << "Delete event" << endl; |
253 | 252 | ||
254 | if (mEvent) { | 253 | if (mEvent) { |
255 | if (KOPrefs::instance()->mConfirm) { | 254 | if (KOPrefs::instance()->mConfirm) { |
256 | switch (msgItemDelete()) { | 255 | switch (msgItemDelete()) { |
257 | case KMessageBox::Continue: // OK | 256 | case KMessageBox::Continue: // OK |
258 | emit eventToBeDeleted(mEvent); | 257 | emit eventToBeDeleted(mEvent); |
259 | emit dialogClose(mEvent); | 258 | emit dialogClose(mEvent); |
260 | mCalendar->deleteEvent(mEvent); | 259 | mCalendar->deleteEvent(mEvent); |
261 | emit eventDeleted(); | 260 | emit eventDeleted(); |
262 | reject(); | 261 | reject(); |
263 | break; | 262 | break; |
264 | } | 263 | } |
265 | } | 264 | } |
266 | else { | 265 | else { |
267 | emit eventToBeDeleted(mEvent); | 266 | emit eventToBeDeleted(mEvent); |
268 | emit dialogClose(mEvent); | 267 | emit dialogClose(mEvent); |
269 | mCalendar->deleteEvent(mEvent); | 268 | mCalendar->deleteEvent(mEvent); |
270 | emit eventDeleted(); | 269 | emit eventDeleted(); |
271 | reject(); | 270 | reject(); |
272 | } | 271 | } |
273 | } else { | 272 | } else { |
274 | reject(); | 273 | reject(); |
275 | } | 274 | } |
276 | } | 275 | } |
277 | 276 | ||
278 | void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) | 277 | void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) |
279 | { | 278 | { |
280 | mGeneral->setDefaults(from,to,allDay); | 279 | mGeneral->setDefaults(from,to,allDay); |
281 | mDetails->setDefaults(); | 280 | mDetails->setDefaults(); |
282 | mRecurrence->setDefaults(from,to,allDay); | 281 | mRecurrence->setDefaults(from,to,allDay); |
283 | showPage( 0 ); | 282 | showPage( 0 ); |
284 | mGeneral->setFocusOn( 2 ); | 283 | mGeneral->setFocusOn( 2 ); |
285 | } | 284 | } |
286 | 285 | ||
287 | void KOEventEditor::readEvent( Event *event, bool tmpl ) | 286 | void KOEventEditor::readEvent( Event *event, bool tmpl ) |
288 | { | 287 | { |
289 | mGeneral->readEvent( event, tmpl ); | 288 | mGeneral->readEvent( event, tmpl ); |
290 | mDetails->readEvent( event ); | 289 | mDetails->readEvent( event ); |
291 | mRecurrence->readEvent( event ); | 290 | mRecurrence->readEvent( event ); |
292 | 291 | ||
293 | // categories | 292 | // categories |
294 | //mCategoryDialog->setSelected( event->categories() ); | 293 | //mCategoryDialog->setSelected( event->categories() ); |
295 | } | 294 | } |
296 | 295 | ||
297 | void KOEventEditor::writeEvent(Event *event) | 296 | void KOEventEditor::writeEvent(Event *event) |
298 | { | 297 | { |
299 | mGeneral->writeEvent( event ); | 298 | mGeneral->writeEvent( event ); |
300 | mDetails->writeEvent( event ); | 299 | mDetails->writeEvent( event ); |
301 | 300 | ||
302 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 301 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
303 | Event *ev = new Event( *event ); | 302 | Event *ev = new Event( *event ); |
304 | ev->registerObserver(0); | 303 | ev->registerObserver(0); |
305 | mDetails->cancelAttendeeEvent( ev ); | 304 | mDetails->cancelAttendeeEvent( ev ); |
306 | if ( ev->attendeeCount() > 0 ) { | 305 | if ( ev->attendeeCount() > 0 ) { |
307 | emit deleteAttendee( ev ); | 306 | emit deleteAttendee( ev ); |
308 | } | 307 | } |
309 | delete(ev); | 308 | delete(ev); |
310 | } | 309 | } |
311 | 310 | ||
312 | mRecurrence->writeEvent(event); | 311 | mRecurrence->writeEvent(event); |
313 | } | 312 | } |
314 | 313 | ||
315 | bool KOEventEditor::validateInput() | 314 | bool KOEventEditor::validateInput() |
316 | { | 315 | { |
317 | if (!mGeneral->validateInput()) return false; | 316 | if (!mGeneral->validateInput()) return false; |
318 | if (!mDetails->validateInput()) return false; | 317 | if (!mDetails->validateInput()) return false; |
319 | if (!mRecurrence->validateInput()) return false; | 318 | if (!mRecurrence->validateInput()) return false; |
320 | return true; | 319 | return true; |
321 | } | 320 | } |
322 | 321 | ||
323 | int KOEventEditor::msgItemDelete() | 322 | int KOEventEditor::msgItemDelete() |
324 | { | 323 | { |
325 | return KMessageBox::warningContinueCancel(this, | 324 | return KMessageBox::warningContinueCancel(this, |
326 | i18n("This item will be permanently deleted."), | 325 | i18n("This item will be permanently deleted."), |
327 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 326 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
328 | } | 327 | } |
329 | 328 | ||
330 | void KOEventEditor::slotLoadTemplate() | 329 | void KOEventEditor::slotLoadTemplate() |
331 | { | 330 | { |
332 | 331 | ||
333 | QString fileName =locateLocal( "templates", "events" ); | 332 | QString fileName =locateLocal( "templates", "events" ); |
334 | QDir t_dir; | 333 | QDir t_dir; |
335 | if ( !t_dir.exists(fileName) ) | 334 | if ( !t_dir.exists(fileName) ) |
336 | t_dir.mkdir ( fileName ); | 335 | t_dir.mkdir ( fileName ); |
337 | fileName += "/event"; | 336 | fileName += "/event"; |
338 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); | 337 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); |
339 | if ( fileName.length() == 0 ) | 338 | if ( fileName.length() == 0 ) |
340 | return; | 339 | return; |
341 | CalendarLocal cal; | 340 | CalendarLocal cal; |
342 | ICalFormat format; | 341 | ICalFormat format; |
343 | if ( !format.load( &cal, fileName ) ) { | 342 | if ( !format.load( &cal, fileName ) ) { |
344 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 343 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
345 | .arg( fileName ) ); | 344 | .arg( fileName ) ); |
346 | return ; | 345 | return ; |
347 | } | 346 | } |
348 | QPtrList<Event> events = cal.events(); | 347 | QPtrList<Event> events = cal.events(); |
349 | Event* event = events.first(); | 348 | Event* event = events.first(); |
350 | if ( !event ) { | 349 | if ( !event ) { |
351 | KMessageBox::error( this, | 350 | KMessageBox::error( this, |
352 | i18n("Template does not contain\na valid Event.")); | 351 | i18n("Template does not contain\na valid Event.")); |
353 | } else { | 352 | } else { |
354 | kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; | 353 | kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; |
355 | readEvent( event, true ); | 354 | readEvent( event, true ); |
356 | } | 355 | } |
357 | } | 356 | } |
358 | 357 | ||
359 | 358 | ||
360 | void KOEventEditor::slotSaveTemplate() | 359 | void KOEventEditor::slotSaveTemplate() |
361 | { | 360 | { |
362 | QString fileName =locateLocal( "templates", "events" ); | 361 | QString fileName =locateLocal( "templates", "events" ); |
363 | QDir t_dir; | 362 | QDir t_dir; |
364 | if ( !t_dir.exists(fileName) ) | 363 | if ( !t_dir.exists(fileName) ) |
365 | t_dir.mkdir ( fileName ); | 364 | t_dir.mkdir ( fileName ); |
366 | fileName += "/event"; | 365 | fileName += "/event"; |
367 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); | 366 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); |
368 | if ( fileName.length() > 0 ) | 367 | if ( fileName.length() > 0 ) |
369 | saveTemplate( fileName ); | 368 | saveTemplate( fileName ); |
370 | } | 369 | } |
371 | 370 | ||
372 | void KOEventEditor::saveTemplate( const QString &templateName ) | 371 | void KOEventEditor::saveTemplate( const QString &templateName ) |
373 | { | 372 | { |
374 | Event *event = new Event; | 373 | Event *event = new Event; |
375 | writeEvent( event ); | 374 | writeEvent( event ); |
376 | saveAsTemplate( event, templateName ); | 375 | saveAsTemplate( event, templateName ); |
377 | } | 376 | } |