author | zautrix <zautrix> | 2005-07-29 14:41:38 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-29 14:41:38 (UTC) |
commit | 84ddce3290c2e44cf351888ce10e1d25e2268fc0 (patch) (unidiff) | |
tree | 09cb007463d7fa49b86a89d7c7710abd1176db3b | |
parent | 50b0d4463cf13ae27e45e54b48b2911a3ceb5f9f (diff) | |
download | kdepimpi-84ddce3290c2e44cf351888ce10e1d25e2268fc0.zip kdepimpi-84ddce3290c2e44cf351888ce10e1d25e2268fc0.tar.gz kdepimpi-84ddce3290c2e44cf351888ce10e1d25e2268fc0.tar.bz2 |
fix
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index e601eef..92e5a0f 100644 --- a/korganizer/koeditorgeneral.cpp +++ b/korganizer/koeditorgeneral.cpp | |||
@@ -1,623 +1,624 @@ | |||
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 <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | 36 | ||
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | #include <kdialog.h> | 38 | #include <kdialog.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | #include <kfiledialog.h> | 43 | #include <kfiledialog.h> |
44 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
45 | 45 | ||
46 | #include <libkcal/todo.h> | 46 | #include <libkcal/todo.h> |
47 | #include <libkcal/event.h> | 47 | #include <libkcal/event.h> |
48 | #include <libkdepim/categoryselectdialog.h> | 48 | #include <libkdepim/categoryselectdialog.h> |
49 | #include <libkdepim/kdateedit.h> | 49 | #include <libkdepim/kdateedit.h> |
50 | 50 | ||
51 | #include "koprefs.h" | 51 | #include "koprefs.h" |
52 | #include "koglobals.h" | 52 | #include "koglobals.h" |
53 | 53 | ||
54 | #include "koeditorgeneral.h" | 54 | #include "koeditorgeneral.h" |
55 | #include "kolocationbox.h" | 55 | #include "kolocationbox.h" |
56 | #ifndef DESKTOP_VERSION | 56 | #ifndef DESKTOP_VERSION |
57 | #include <qpe/qpeapplication.h> | 57 | #include <qpe/qpeapplication.h> |
58 | #else | 58 | #else |
59 | #include <qapplication.h> | 59 | #include <qapplication.h> |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : | 62 | KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : |
63 | QObject( parent, name) | 63 | QObject( parent, name) |
64 | { | 64 | { |
65 | mNextFocus = 0; | 65 | mNextFocus = 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | KOEditorGeneral::~KOEditorGeneral() | 68 | KOEditorGeneral::~KOEditorGeneral() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) | 72 | void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) |
73 | { | 73 | { |
74 | QGridLayout *headerLayout = new QGridLayout(topLayout); | 74 | QGridLayout *headerLayout = new QGridLayout(topLayout); |
75 | 75 | ||
76 | #if 0 | 76 | #if 0 |
77 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); | 77 | mOwnerLabel = new QLabel(i18n("Owner:"),parent); |
78 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); | 78 | headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); |
79 | #endif | 79 | #endif |
80 | // 1 on pda | 80 | // 1 on pda |
81 | // 11 on desktop | 81 | // 11 on desktop |
82 | headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 ); | 82 | headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 ); |
83 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); | 83 | QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); |
84 | headerLayout->addWidget(summaryLabel,0,0); | 84 | headerLayout->addWidget(summaryLabel,0,0); |
85 | 85 | ||
86 | mSummaryEdit = new KOLocationBox(TRUE,parent, 50); | 86 | mSummaryEdit = new KOLocationBox(TRUE,parent, 50); |
87 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 87 | mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
88 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); | 88 | //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); |
89 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); | 89 | //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); |
90 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; | 90 | int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; |
91 | if ( QApplication::desktop()->width() > 320 ) | 91 | if ( QApplication::desktop()->width() > 320 ) |
92 | mSummaryEdit->setMaximumHeight( hei +6 ); | 92 | mSummaryEdit->setMaximumHeight( hei +6 ); |
93 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); | 93 | //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); |
94 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } | 94 | // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } |
95 | // mSummaryEdit = new QLineEdit(parent); | 95 | // mSummaryEdit = new QLineEdit(parent); |
96 | if ( QApplication::desktop()->height() < 320 ) | 96 | if ( QApplication::desktop()->height() < 320 ) |
97 | headerLayout->addWidget(mSummaryEdit,0,1); | 97 | headerLayout->addWidget(mSummaryEdit,0,1); |
98 | else | 98 | else |
99 | headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2); | 99 | headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2); |
100 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 100 | connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
101 | 101 | ||
102 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); | 102 | QLabel *locationLabel = new QLabel(i18n("Location:"),parent); |
103 | if ( QApplication::desktop()->height() < 320 ) | 103 | if ( QApplication::desktop()->height() < 320 ) |
104 | headerLayout->addWidget(locationLabel,0,2); | 104 | headerLayout->addWidget(locationLabel,0,2); |
105 | else | 105 | else |
106 | headerLayout->addWidget(locationLabel,1,0); | 106 | headerLayout->addWidget(locationLabel,1,0); |
107 | 107 | ||
108 | mLocationEdit = new KOLocationBox(TRUE,parent,30); | 108 | mLocationEdit = new KOLocationBox(TRUE,parent,30); |
109 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 109 | mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
110 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) | 110 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) |
111 | mLocationEdit->setMaximumHeight( hei + 6); | 111 | mLocationEdit->setMaximumHeight( hei + 6); |
112 | 112 | ||
113 | // mLocationEdit = new QLineEdit(parent); | 113 | // mLocationEdit = new QLineEdit(parent); |
114 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); | 114 | connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); |
115 | 115 | ||
116 | mCalendarBox = new QComboBox ( parent ); | 116 | mCalendarBox = new QComboBox ( parent ); |
117 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); | 117 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); |
118 | if ( QApplication::desktop()->height() < 320 ) { | 118 | if ( QApplication::desktop()->height() < 320 ) { |
119 | headerLayout->addWidget(mLocationEdit,0,3); | 119 | headerLayout->addWidget(mLocationEdit,0,3); |
120 | headerLayout->addWidget(mCalendarBox,0,4); | 120 | headerLayout->addWidget(mCalendarBox,0,4); |
121 | headerLayout->setColStretch( 1, 10); | 121 | headerLayout->setColStretch( 1, 10); |
122 | headerLayout->setColStretch( 3, 10); | 122 | headerLayout->setColStretch( 3, 10); |
123 | mCalendarBox->setMaximumWidth( 64 ); | 123 | mCalendarBox->setMaximumWidth( 64 ); |
124 | } | 124 | } |
125 | else { | 125 | else { |
126 | headerLayout->addWidget(mLocationEdit,1,1); | 126 | headerLayout->addWidget(mLocationEdit,1,1); |
127 | headerLayout->addWidget(mCalendarBox,1,2); | 127 | headerLayout->addWidget(mCalendarBox,1,2); |
128 | int str = 3; | 128 | int str = 3; |
129 | if ( QApplication::desktop()->width() < 320 ) { | 129 | if ( QApplication::desktop()->width() < 640 ) { |
130 | --str; | ||
131 | --str; | 130 | --str; |
131 | if ( QApplication::desktop()->width() < 320 ) | ||
132 | --str; | ||
132 | } | 133 | } |
133 | headerLayout->setColStretch( 1, str); | 134 | headerLayout->setColStretch( 1, str); |
134 | headerLayout->setColStretch( 2, 1); | 135 | headerLayout->setColStretch( 2, 1); |
135 | } | 136 | } |
136 | 137 | ||
137 | } | 138 | } |
138 | void KOEditorGeneral::setFocusOn( int i ) | 139 | void KOEditorGeneral::setFocusOn( int i ) |
139 | { | 140 | { |
140 | mNextFocus = i; | 141 | mNextFocus = i; |
141 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); | 142 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); |
142 | } | 143 | } |
143 | void KOEditorGeneral::slotSetFocusOn() | 144 | void KOEditorGeneral::slotSetFocusOn() |
144 | { | 145 | { |
145 | mNextFocus; | 146 | mNextFocus; |
146 | if ( mNextFocus == 1 ) { | 147 | if ( mNextFocus == 1 ) { |
147 | mDescriptionEdit->setFocus(); | 148 | mDescriptionEdit->setFocus(); |
148 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 149 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
149 | } | 150 | } |
150 | if ( mNextFocus == 2 ) { | 151 | if ( mNextFocus == 2 ) { |
151 | mSummaryEdit->setFocus(); | 152 | mSummaryEdit->setFocus(); |
152 | } | 153 | } |
153 | } | 154 | } |
154 | void KOEditorGeneral::editCategories() | 155 | void KOEditorGeneral::editCategories() |
155 | { | 156 | { |
156 | // qDebug("KOEditorGeneral::editCategories() "); | 157 | // qDebug("KOEditorGeneral::editCategories() "); |
157 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 158 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
158 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 159 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
159 | //KOGlobals::fitDialogToScreen( csd ); | 160 | //KOGlobals::fitDialogToScreen( csd ); |
160 | csd->setColorEnabled(); | 161 | csd->setColorEnabled(); |
161 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 162 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
162 | csd->exec(); | 163 | csd->exec(); |
163 | delete csd; | 164 | delete csd; |
164 | } | 165 | } |
165 | 166 | ||
166 | void KOEditorGeneral::showCatPopup() | 167 | void KOEditorGeneral::showCatPopup() |
167 | { | 168 | { |
168 | mCatPopup->clear(); | 169 | mCatPopup->clear(); |
169 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); | 170 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); |
170 | int index = 0; | 171 | int index = 0; |
171 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 172 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
172 | it != KOPrefs::instance()->mCustomCategories.end (); | 173 | it != KOPrefs::instance()->mCustomCategories.end (); |
173 | ++it) { | 174 | ++it) { |
174 | mCatPopup->insertItem (*it, index ); | 175 | mCatPopup->insertItem (*it, index ); |
175 | //mCategory[index] = *it; | 176 | //mCategory[index] = *it; |
176 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); | 177 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); |
177 | ++index; | 178 | ++index; |
178 | } | 179 | } |
179 | } | 180 | } |
180 | void KOEditorGeneral::selectedCatPopup( int index ) | 181 | void KOEditorGeneral::selectedCatPopup( int index ) |
181 | { | 182 | { |
182 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); | 183 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); |
183 | QString colcat = categories.first(); | 184 | QString colcat = categories.first(); |
184 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) | 185 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) |
185 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); | 186 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); |
186 | else | 187 | else |
187 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); | 188 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); |
188 | categories.sort (); | 189 | categories.sort (); |
189 | if ( !colcat.isEmpty() ) { | 190 | if ( !colcat.isEmpty() ) { |
190 | if ( categories.find ( colcat ) != categories.end () ) { | 191 | if ( categories.find ( colcat ) != categories.end () ) { |
191 | categories.remove( colcat ); | 192 | categories.remove( colcat ); |
192 | categories.prepend( colcat ); | 193 | categories.prepend( colcat ); |
193 | } | 194 | } |
194 | } | 195 | } |
195 | setCategories( categories.join(",") ); | 196 | setCategories( categories.join(",") ); |
196 | } | 197 | } |
197 | 198 | ||
198 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 199 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
199 | { | 200 | { |
200 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 201 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
201 | mCatPopup = new QPopupMenu ( parent ); | 202 | mCatPopup = new QPopupMenu ( parent ); |
202 | mCatPopup->setCheckable (true); | 203 | mCatPopup->setCheckable (true); |
203 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); | 204 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); |
204 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); | 205 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); |
205 | mCategoriesButton = new QPushButton(parent); | 206 | mCategoriesButton = new QPushButton(parent); |
206 | mCategoriesButton->setText(i18n("Categories...")); | 207 | mCategoriesButton->setText(i18n("Categories...")); |
207 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 208 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
208 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 209 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
209 | categoriesLayout->addWidget(mCategoriesButton); | 210 | categoriesLayout->addWidget(mCategoriesButton); |
210 | mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); | 211 | mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); |
211 | mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 212 | mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
212 | mCategoriesLabel->setPopup( mCatPopup ); | 213 | mCategoriesLabel->setPopup( mCatPopup ); |
213 | //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 214 | //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
214 | categoriesLayout->addWidget(mCategoriesLabel,1); | 215 | categoriesLayout->addWidget(mCategoriesLabel,1); |
215 | } | 216 | } |
216 | 217 | ||
217 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 218 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
218 | { | 219 | { |
219 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 220 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
220 | 221 | ||
221 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 222 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
222 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 223 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
223 | secrecyLayout->addWidget(mCancelBox); | 224 | secrecyLayout->addWidget(mCancelBox); |
224 | secrecyLayout->addWidget(secrecyLabel); | 225 | secrecyLayout->addWidget(secrecyLabel); |
225 | 226 | ||
226 | mSecrecyCombo = new QComboBox(parent); | 227 | mSecrecyCombo = new QComboBox(parent); |
227 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 228 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
228 | secrecyLayout->addWidget(mSecrecyCombo); | 229 | secrecyLayout->addWidget(mSecrecyCombo); |
229 | } | 230 | } |
230 | 231 | ||
231 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 232 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
232 | { | 233 | { |
233 | mDescriptionEdit = new KTextEdit(parent); | 234 | mDescriptionEdit = new KTextEdit(parent); |
234 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 235 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
235 | mDescriptionEdit->append(""); | 236 | mDescriptionEdit->append(""); |
236 | mDescriptionEdit->setReadOnly(false); | 237 | mDescriptionEdit->setReadOnly(false); |
237 | mDescriptionEdit->setOverwriteMode(false); | 238 | mDescriptionEdit->setOverwriteMode(false); |
238 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 239 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
239 | topLayout->addWidget(mDescriptionEdit); | 240 | topLayout->addWidget(mDescriptionEdit); |
240 | #ifndef DESKTOP_VERSION | 241 | #ifndef DESKTOP_VERSION |
241 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 242 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
242 | #endif | 243 | #endif |
243 | 244 | ||
244 | } | 245 | } |
245 | 246 | ||
246 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 247 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
247 | { | 248 | { |
248 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 249 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
249 | 250 | ||
250 | //mAlarmBell = new QLabel(parent); | 251 | //mAlarmBell = new QLabel(parent); |
251 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 252 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
252 | //alarmLayout->addWidget(mAlarmBell); | 253 | //alarmLayout->addWidget(mAlarmBell); |
253 | if ( QApplication::desktop()->width() < 320 ) | 254 | if ( QApplication::desktop()->width() < 320 ) |
254 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 255 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
255 | else | 256 | else |
256 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 257 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
257 | 258 | ||
258 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 259 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
259 | alarmLayout->addWidget(mAlarmButton); | 260 | alarmLayout->addWidget(mAlarmButton); |
260 | 261 | ||
261 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 262 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
262 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); | 263 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); |
263 | alarmLayout->addWidget(mAlarmTimeEdit); | 264 | alarmLayout->addWidget(mAlarmTimeEdit); |
264 | mAlarmIncrCombo = new QComboBox(false, parent); | 265 | mAlarmIncrCombo = new QComboBox(false, parent); |
265 | if ( QApplication::desktop()->width() < 320 ) { | 266 | if ( QApplication::desktop()->width() < 320 ) { |
266 | mAlarmIncrCombo->insertItem(i18n("min")); | 267 | mAlarmIncrCombo->insertItem(i18n("min")); |
267 | mAlarmIncrCombo->insertItem(i18n("hou")); | 268 | mAlarmIncrCombo->insertItem(i18n("hou")); |
268 | mAlarmIncrCombo->insertItem(i18n("day")); | 269 | mAlarmIncrCombo->insertItem(i18n("day")); |
269 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 270 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
270 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 271 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
271 | } else { | 272 | } else { |
272 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 273 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
273 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 274 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
274 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 275 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
275 | } | 276 | } |
276 | 277 | ||
277 | // mAlarmIncrCombo->setMinimumHeight(20); | 278 | // mAlarmIncrCombo->setMinimumHeight(20); |
278 | alarmLayout->addWidget(mAlarmIncrCombo); | 279 | alarmLayout->addWidget(mAlarmIncrCombo); |
279 | mAlarmSoundButton = new QPushButton(parent); | 280 | mAlarmSoundButton = new QPushButton(parent); |
280 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 281 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
281 | mAlarmSoundButton->setToggleButton(true); | 282 | mAlarmSoundButton->setToggleButton(true); |
282 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 283 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
283 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 284 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
284 | alarmLayout->addWidget(mAlarmSoundButton); | 285 | alarmLayout->addWidget(mAlarmSoundButton); |
285 | 286 | ||
286 | mAlarmProgramButton = new QPushButton(parent); | 287 | mAlarmProgramButton = new QPushButton(parent); |
287 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 288 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
288 | mAlarmProgramButton->setToggleButton(true); | 289 | mAlarmProgramButton->setToggleButton(true); |
289 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 290 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
290 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 291 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
291 | alarmLayout->addWidget(mAlarmProgramButton); | 292 | alarmLayout->addWidget(mAlarmProgramButton); |
292 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 293 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
293 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 294 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
294 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 295 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
295 | // mAlarmSoundButton->hide(); | 296 | // mAlarmSoundButton->hide(); |
296 | // mAlarmProgramButton->hide(); | 297 | // mAlarmProgramButton->hide(); |
297 | // } | 298 | // } |
298 | } | 299 | } |
299 | 300 | ||
300 | void KOEditorGeneral::pickAlarmSound() | 301 | void KOEditorGeneral::pickAlarmSound() |
301 | { | 302 | { |
302 | 303 | ||
303 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); | 304 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); |
304 | 305 | ||
305 | bool oldState = mAlarmSoundButton->isOn(); | 306 | bool oldState = mAlarmSoundButton->isOn(); |
306 | 307 | ||
307 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 308 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
308 | i18n("*.wav|Wav Files"), 0)); | 309 | i18n("*.wav|Wav Files"), 0)); |
309 | if (!fileName.isEmpty()) { | 310 | if (!fileName.isEmpty()) { |
310 | mAlarmSound = fileName; | 311 | mAlarmSound = fileName; |
311 | QToolTip::remove(mAlarmSoundButton); | 312 | QToolTip::remove(mAlarmSoundButton); |
312 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 313 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
313 | QToolTip::add(mAlarmSoundButton, dispStr); | 314 | QToolTip::add(mAlarmSoundButton, dispStr); |
314 | mAlarmProgramButton->setOn(false); | 315 | mAlarmProgramButton->setOn(false); |
315 | mAlarmSoundButton->setOn(true); | 316 | mAlarmSoundButton->setOn(true); |
316 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 317 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
317 | } else { | 318 | } else { |
318 | mAlarmProgramButton->setOn(oldState); | 319 | mAlarmProgramButton->setOn(oldState); |
319 | mAlarmSoundButton->setOn(!oldState); | 320 | mAlarmSoundButton->setOn(!oldState); |
320 | 321 | ||
321 | 322 | ||
322 | } | 323 | } |
323 | 324 | ||
324 | if (mAlarmProgramButton->isOn()) | 325 | if (mAlarmProgramButton->isOn()) |
325 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 326 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
326 | if ( mAlarmSoundButton->isOn()) | 327 | if ( mAlarmSoundButton->isOn()) |
327 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 328 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
328 | 329 | ||
329 | } | 330 | } |
330 | 331 | ||
331 | void KOEditorGeneral::pickAlarmProgram() | 332 | void KOEditorGeneral::pickAlarmProgram() |
332 | { | 333 | { |
333 | bool oldState = mAlarmProgramButton->isOn(); | 334 | bool oldState = mAlarmProgramButton->isOn(); |
334 | 335 | ||
335 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); | 336 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); |
336 | if (!fileName.isEmpty()) { | 337 | if (!fileName.isEmpty()) { |
337 | mAlarmProgram = fileName; | 338 | mAlarmProgram = fileName; |
338 | QToolTip::remove(mAlarmProgramButton); | 339 | QToolTip::remove(mAlarmProgramButton); |
339 | QString dispStr = i18n("Running '%1'").arg(fileName); | 340 | QString dispStr = i18n("Running '%1'").arg(fileName); |
340 | QToolTip::add(mAlarmProgramButton, dispStr); | 341 | QToolTip::add(mAlarmProgramButton, dispStr); |
341 | mAlarmSoundButton->setOn(false); | 342 | mAlarmSoundButton->setOn(false); |
342 | mAlarmProgramButton->setOn(true); | 343 | mAlarmProgramButton->setOn(true); |
343 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 344 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
344 | } else { | 345 | } else { |
345 | mAlarmProgramButton->setOn(!oldState); | 346 | mAlarmProgramButton->setOn(!oldState); |
346 | mAlarmSoundButton->setOn(oldState); | 347 | mAlarmSoundButton->setOn(oldState); |
347 | } | 348 | } |
348 | 349 | ||
349 | if (mAlarmProgramButton->isOn()) | 350 | if (mAlarmProgramButton->isOn()) |
350 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 351 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
351 | if ( mAlarmSoundButton->isOn()) | 352 | if ( mAlarmSoundButton->isOn()) |
352 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 353 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
353 | 354 | ||
354 | } | 355 | } |
355 | 356 | ||
356 | 357 | ||
357 | QString KOEditorGeneral::getFittingPath( const QString s ) | 358 | QString KOEditorGeneral::getFittingPath( const QString s ) |
358 | { | 359 | { |
359 | int maxlen = 50; | 360 | int maxlen = 50; |
360 | if ( QApplication::desktop()->width() < 640 ) { | 361 | if ( QApplication::desktop()->width() < 640 ) { |
361 | if ( QApplication::desktop()->width() < 320 ) | 362 | if ( QApplication::desktop()->width() < 320 ) |
362 | maxlen = 22; | 363 | maxlen = 22; |
363 | else | 364 | else |
364 | maxlen = 35; | 365 | maxlen = 35; |
365 | } | 366 | } |
366 | if ( s.length() > maxlen ) { | 367 | if ( s.length() > maxlen ) { |
367 | return "..."+s.right(maxlen -3); | 368 | return "..."+s.right(maxlen -3); |
368 | } | 369 | } |
369 | return s; | 370 | return s; |
370 | } | 371 | } |
371 | 372 | ||
372 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 373 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
373 | { | 374 | { |
374 | if ( enable ) { | 375 | if ( enable ) { |
375 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 376 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
376 | mAlarmSoundButton->setOn( true ); | 377 | mAlarmSoundButton->setOn( true ); |
377 | if ( mAlarmSound.isEmpty() ) | 378 | if ( mAlarmSound.isEmpty() ) |
378 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 379 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
379 | else { | 380 | else { |
380 | if ( ! QFile::exists( mAlarmSound ) ) | 381 | if ( ! QFile::exists( mAlarmSound ) ) |
381 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 382 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
382 | } | 383 | } |
383 | } | 384 | } |
384 | } | 385 | } |
385 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); | 386 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); |
386 | mAlarmTimeEdit->setEnabled(enable); | 387 | mAlarmTimeEdit->setEnabled(enable); |
387 | mAlarmSoundButton->setEnabled(enable); | 388 | mAlarmSoundButton->setEnabled(enable); |
388 | mAlarmProgramButton->setEnabled(enable); | 389 | mAlarmProgramButton->setEnabled(enable); |
389 | mAlarmIncrCombo->setEnabled(enable); | 390 | mAlarmIncrCombo->setEnabled(enable); |
390 | } | 391 | } |
391 | 392 | ||
392 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 393 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
393 | { | 394 | { |
394 | enableAlarmEdit( !disable ); | 395 | enableAlarmEdit( !disable ); |
395 | } | 396 | } |
396 | 397 | ||
397 | void KOEditorGeneral::enableAlarm( bool enable ) | 398 | void KOEditorGeneral::enableAlarm( bool enable ) |
398 | { | 399 | { |
399 | enableAlarmEdit( enable ); | 400 | enableAlarmEdit( enable ); |
400 | } | 401 | } |
401 | 402 | ||
402 | void KOEditorGeneral::alarmDisable(bool disable) | 403 | void KOEditorGeneral::alarmDisable(bool disable) |
403 | { | 404 | { |
404 | if (!disable) { | 405 | if (!disable) { |
405 | //mAlarmBell->setEnabled(true); | 406 | //mAlarmBell->setEnabled(true); |
406 | mAlarmButton->setEnabled(true); | 407 | mAlarmButton->setEnabled(true); |
407 | } else { | 408 | } else { |
408 | //mAlarmBell->setEnabled(false); | 409 | //mAlarmBell->setEnabled(false); |
409 | mAlarmButton->setEnabled(false); | 410 | mAlarmButton->setEnabled(false); |
410 | mAlarmButton->setChecked(false); | 411 | mAlarmButton->setChecked(false); |
411 | mAlarmTimeEdit->setEnabled(false); | 412 | mAlarmTimeEdit->setEnabled(false); |
412 | mAlarmSoundButton->setEnabled(false); | 413 | mAlarmSoundButton->setEnabled(false); |
413 | mAlarmProgramButton->setEnabled(false); | 414 | mAlarmProgramButton->setEnabled(false); |
414 | mAlarmIncrCombo->setEnabled(false); | 415 | mAlarmIncrCombo->setEnabled(false); |
415 | } | 416 | } |
416 | } | 417 | } |
417 | 418 | ||
418 | void KOEditorGeneral::setCategories(const QString &str) | 419 | void KOEditorGeneral::setCategories(const QString &str) |
419 | { | 420 | { |
420 | QString tt = str; | 421 | QString tt = str; |
421 | QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); | 422 | QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); |
422 | mCategoriesLabel->setText(str); | 423 | mCategoriesLabel->setText(str); |
423 | } | 424 | } |
424 | 425 | ||
425 | void KOEditorGeneral::setDefaults(bool allDay) | 426 | void KOEditorGeneral::setDefaults(bool allDay) |
426 | { | 427 | { |
427 | #if 0 | 428 | #if 0 |
428 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 429 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
429 | #endif | 430 | #endif |
430 | 431 | ||
431 | mAlarmMessage = i18n("Edit new item"); | 432 | mAlarmMessage = i18n("Edit new item"); |
432 | enableAlarmEdit( !allDay ); | 433 | enableAlarmEdit( !allDay ); |
433 | 434 | ||
434 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 435 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
435 | int alarmTime; | 436 | int alarmTime; |
436 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 437 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
437 | int index = KOPrefs::instance()->mAlarmTime; | 438 | int index = KOPrefs::instance()->mAlarmTime; |
438 | if (index < 0 || index > 7) { | 439 | if (index < 0 || index > 7) { |
439 | alarmTime = 15; | 440 | alarmTime = 15; |
440 | } else { | 441 | } else { |
441 | alarmTime = a[index]; | 442 | alarmTime = a[index]; |
442 | } | 443 | } |
443 | mAlarmButton ->setChecked( false ); | 444 | mAlarmButton ->setChecked( false ); |
444 | mAlarmTimeEdit->setValue(alarmTime); | 445 | mAlarmTimeEdit->setValue(alarmTime); |
445 | mAlarmIncrCombo->setCurrentItem(0); | 446 | mAlarmIncrCombo->setCurrentItem(0); |
446 | enableAlarmEdit( false ); | 447 | enableAlarmEdit( false ); |
447 | //alarmDisable (false); | 448 | //alarmDisable (false); |
448 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 449 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
449 | mCancelBox->setChecked( false ); | 450 | mCancelBox->setChecked( false ); |
450 | mSummaryEdit->setEditText(""); | 451 | mSummaryEdit->setEditText(""); |
451 | mLocationEdit->setEditText(""); | 452 | mLocationEdit->setEditText(""); |
452 | mDescriptionEdit->setText(""); | 453 | mDescriptionEdit->setText(""); |
453 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 454 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
454 | setCategories(""); | 455 | setCategories(""); |
455 | fillCalCombo(); | 456 | fillCalCombo(); |
456 | } | 457 | } |
457 | void KOEditorGeneral::setSecrecy( int num ) | 458 | void KOEditorGeneral::setSecrecy( int num ) |
458 | { | 459 | { |
459 | mSecrecyCombo->setCurrentItem(num); | 460 | mSecrecyCombo->setCurrentItem(num); |
460 | } | 461 | } |
461 | void KOEditorGeneral::fillCalCombo( int setToID ) | 462 | void KOEditorGeneral::fillCalCombo( int setToID ) |
462 | { | 463 | { |
463 | mCalendarBox->clear(); | 464 | mCalendarBox->clear(); |
464 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 465 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
465 | int std = 0; | 466 | int std = 0; |
466 | int count = 0; | 467 | int count = 0; |
467 | while ( kkf ) { | 468 | while ( kkf ) { |
468 | if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) { | 469 | if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) { |
469 | if ( setToID ) { | 470 | if ( setToID ) { |
470 | if ( kkf->mCalNumber == setToID ) | 471 | if ( kkf->mCalNumber == setToID ) |
471 | std = count; | 472 | std = count; |
472 | } else { | 473 | } else { |
473 | if ( kkf->isStandard ) { | 474 | if ( kkf->isStandard ) { |
474 | std = count; | 475 | std = count; |
475 | } | 476 | } |
476 | } | 477 | } |
477 | ++count; | 478 | ++count; |
478 | mCalendarBox->insertItem( kkf->mName ); | 479 | mCalendarBox->insertItem( kkf->mName ); |
479 | } | 480 | } |
480 | kkf = KOPrefs::instance()->mCalendars.next(); | 481 | kkf = KOPrefs::instance()->mCalendars.next(); |
481 | } | 482 | } |
482 | mCalendarBox->setCurrentItem( std ); | 483 | mCalendarBox->setCurrentItem( std ); |
483 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) | 484 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) |
484 | mCalendarBox->hide(); | 485 | mCalendarBox->hide(); |
485 | else | 486 | else |
486 | mCalendarBox->show(); | 487 | mCalendarBox->show(); |
487 | 488 | ||
488 | } | 489 | } |
489 | int KOEditorGeneral::getCalendarID() | 490 | int KOEditorGeneral::getCalendarID() |
490 | { | 491 | { |
491 | return KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); | 492 | return KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); |
492 | } | 493 | } |
493 | 494 | ||
494 | void KOEditorGeneral::readIncidence(Incidence *event) | 495 | void KOEditorGeneral::readIncidence(Incidence *event) |
495 | { | 496 | { |
496 | fillCalCombo( event->calID() ); | 497 | fillCalCombo( event->calID() ); |
497 | mAlarmMessage = event->summary(); | 498 | mAlarmMessage = event->summary(); |
498 | if ( ! event->location().isEmpty() ) | 499 | if ( ! event->location().isEmpty() ) |
499 | mAlarmMessage += " ("+event->location()+")"; | 500 | mAlarmMessage += " ("+event->location()+")"; |
500 | mAlarmIncrCombo->setCurrentItem(0); | 501 | mAlarmIncrCombo->setCurrentItem(0); |
501 | mSummaryEdit->setEditText(event->summary()); | 502 | mSummaryEdit->setEditText(event->summary()); |
502 | mLocationEdit->setEditText(event->location()); | 503 | mLocationEdit->setEditText(event->location()); |
503 | mDescriptionEdit->setText(event->description()); | 504 | mDescriptionEdit->setText(event->description()); |
504 | 505 | ||
505 | #if 0 | 506 | #if 0 |
506 | // organizer information | 507 | // organizer information |
507 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); | 508 | mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); |
508 | #endif | 509 | #endif |
509 | 510 | ||
510 | enableAlarmEdit( event->isAlarmEnabled() ); | 511 | enableAlarmEdit( event->isAlarmEnabled() ); |
511 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); | 512 | //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); |
512 | if(!event->isAlarmEnabled()) { | 513 | if(!event->isAlarmEnabled()) { |
513 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 514 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
514 | int alarmTime; | 515 | int alarmTime; |
515 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 516 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
516 | int index = KOPrefs::instance()->mAlarmTime; | 517 | int index = KOPrefs::instance()->mAlarmTime; |
517 | if (index < 0 || index > 7) { | 518 | if (index < 0 || index > 7) { |
518 | alarmTime = 15; | 519 | alarmTime = 15; |
519 | } else { | 520 | } else { |
520 | alarmTime = a[index]; | 521 | alarmTime = a[index]; |
521 | } | 522 | } |
522 | mAlarmTimeEdit->setValue(alarmTime); | 523 | mAlarmTimeEdit->setValue(alarmTime); |
523 | } | 524 | } |
524 | mAlarmButton->setChecked( event->isAlarmEnabled() ); | 525 | mAlarmButton->setChecked( event->isAlarmEnabled() ); |
525 | mSecrecyCombo->setCurrentItem(event->secrecy()); | 526 | mSecrecyCombo->setCurrentItem(event->secrecy()); |
526 | mCancelBox->setChecked( event->cancelled() ); | 527 | mCancelBox->setChecked( event->cancelled() ); |
527 | mAlarmProgramButton->setOn(false); | 528 | mAlarmProgramButton->setOn(false); |
528 | mAlarmSoundButton->setOn(false); | 529 | mAlarmSoundButton->setOn(false); |
529 | 530 | ||
530 | // set up alarm stuff | 531 | // set up alarm stuff |
531 | QPtrList<Alarm> alarms = event->alarms(); | 532 | QPtrList<Alarm> alarms = event->alarms(); |
532 | Alarm* alarm; | 533 | Alarm* alarm; |
533 | mAlarmIncrCombo->setCurrentItem(0); | 534 | mAlarmIncrCombo->setCurrentItem(0); |
534 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 535 | for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
535 | int offset; | 536 | int offset; |
536 | if ( alarm->hasTime() ) { | 537 | if ( alarm->hasTime() ) { |
537 | QDateTime t = alarm->time(); | 538 | QDateTime t = alarm->time(); |
538 | offset = event->dtStart().secsTo( t ); | 539 | offset = event->dtStart().secsTo( t ); |
539 | } else { | 540 | } else { |
540 | offset = alarm->startOffset().asSeconds(); | 541 | offset = alarm->startOffset().asSeconds(); |
541 | } | 542 | } |
542 | if ( offset != 0 ) { | 543 | if ( offset != 0 ) { |
543 | offset = offset / -60; // make minutes | 544 | offset = offset / -60; // make minutes |
544 | if (offset % 60 == 0) { // divides evenly into hours? | 545 | if (offset % 60 == 0) { // divides evenly into hours? |
545 | offset = offset / 60; | 546 | offset = offset / 60; |
546 | mAlarmIncrCombo->setCurrentItem(1); | 547 | mAlarmIncrCombo->setCurrentItem(1); |
547 | if (offset % 24 == 0) { // divides evenly into days? | 548 | if (offset % 24 == 0) { // divides evenly into days? |
548 | offset = offset / 24; | 549 | offset = offset / 24; |
549 | mAlarmIncrCombo->setCurrentItem(2); | 550 | mAlarmIncrCombo->setCurrentItem(2); |
550 | } | 551 | } |
551 | } | 552 | } |
552 | } | 553 | } |
553 | mAlarmTimeEdit->setValue( offset ); | 554 | mAlarmTimeEdit->setValue( offset ); |
554 | if (alarm->type() == Alarm::Procedure) { | 555 | if (alarm->type() == Alarm::Procedure) { |
555 | 556 | ||
556 | mAlarmProgram = alarm->programFile(); | 557 | mAlarmProgram = alarm->programFile(); |
557 | mAlarmProgramButton->setOn(true); | 558 | mAlarmProgramButton->setOn(true); |
558 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); | 559 | QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); |
559 | QToolTip::add(mAlarmProgramButton, dispStr); | 560 | QToolTip::add(mAlarmProgramButton, dispStr); |
560 | } | 561 | } |
561 | else if (alarm->type() == Alarm::Audio) { | 562 | else if (alarm->type() == Alarm::Audio) { |
562 | mAlarmSound = alarm->audioFile(); | 563 | mAlarmSound = alarm->audioFile(); |
563 | if ( ! QFile::exists( mAlarmSound ) ) | 564 | if ( ! QFile::exists( mAlarmSound ) ) |
564 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 565 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
565 | mAlarmSoundButton->setOn(true); | 566 | mAlarmSoundButton->setOn(true); |
566 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); | 567 | QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); |
567 | QToolTip::add(mAlarmSoundButton, dispStr); | 568 | QToolTip::add(mAlarmSoundButton, dispStr); |
568 | } | 569 | } |
569 | mAlarmButton->setChecked(alarm->enabled()); | 570 | mAlarmButton->setChecked(alarm->enabled()); |
570 | enableAlarmEdit( alarm->enabled() ); | 571 | enableAlarmEdit( alarm->enabled() ); |
571 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); | 572 | //qDebug("nableAlarmEdit( alarm->enabled() )********* "); |
572 | // TODO: Deal with multiple alarms | 573 | // TODO: Deal with multiple alarms |
573 | break; // For now, stop after the first alarm | 574 | break; // For now, stop after the first alarm |
574 | } | 575 | } |
575 | 576 | ||
576 | setCategories(event->categoriesStr()); | 577 | setCategories(event->categoriesStr()); |
577 | } | 578 | } |
578 | 579 | ||
579 | void KOEditorGeneral::writeIncidence(Incidence *event) | 580 | void KOEditorGeneral::writeIncidence(Incidence *event) |
580 | { | 581 | { |
581 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; | 582 | // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; |
582 | mLocationEdit->save(KOLocationBox::LOCATION); | 583 | mLocationEdit->save(KOLocationBox::LOCATION); |
583 | event->setSummary(mSummaryEdit->currentText()); | 584 | event->setSummary(mSummaryEdit->currentText()); |
584 | event->setLocation(mLocationEdit->currentText()); | 585 | event->setLocation(mLocationEdit->currentText()); |
585 | event->setDescription(mDescriptionEdit->text()); | 586 | event->setDescription(mDescriptionEdit->text()); |
586 | event->setCategories(mCategoriesLabel->text()); | 587 | event->setCategories(mCategoriesLabel->text()); |
587 | event->setSecrecy(mSecrecyCombo->currentItem()); | 588 | event->setSecrecy(mSecrecyCombo->currentItem()); |
588 | event->setCancelled(mCancelBox->isChecked() );; | 589 | event->setCancelled(mCancelBox->isChecked() );; |
589 | // alarm stuff | 590 | // alarm stuff |
590 | if (mAlarmButton->isChecked()) { | 591 | if (mAlarmButton->isChecked()) { |
591 | if (event->alarms().count() == 0) | 592 | if (event->alarms().count() == 0) |
592 | event->newAlarm(); | 593 | event->newAlarm(); |
593 | QPtrList<Alarm> alarms = event->alarms(); | 594 | QPtrList<Alarm> alarms = event->alarms(); |
594 | Alarm *alarm; | 595 | Alarm *alarm; |
595 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 596 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
596 | alarm->setEnabled(true); | 597 | alarm->setEnabled(true); |
597 | int j = mAlarmTimeEdit->value()* -60; | 598 | int j = mAlarmTimeEdit->value()* -60; |
598 | if (mAlarmIncrCombo->currentItem() == 1) | 599 | if (mAlarmIncrCombo->currentItem() == 1) |
599 | j = j * 60; | 600 | j = j * 60; |
600 | else if (mAlarmIncrCombo->currentItem() == 2) | 601 | else if (mAlarmIncrCombo->currentItem() == 2) |
601 | j = j * (60 * 24); | 602 | j = j * (60 * 24); |
602 | alarm->setStartOffset( j ); | 603 | alarm->setStartOffset( j ); |
603 | 604 | ||
604 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { | 605 | if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { |
605 | alarm->setProcedureAlarm(mAlarmProgram); | 606 | alarm->setProcedureAlarm(mAlarmProgram); |
606 | } | 607 | } |
607 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) | 608 | else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) |
608 | alarm->setAudioAlarm(mAlarmSound); | 609 | alarm->setAudioAlarm(mAlarmSound); |
609 | else | 610 | else |
610 | alarm->setType(Alarm::Invalid); | 611 | alarm->setType(Alarm::Invalid); |
611 | //alarm->setAudioAlarm("default"); | 612 | //alarm->setAudioAlarm("default"); |
612 | // TODO: Deal with multiple alarms | 613 | // TODO: Deal with multiple alarms |
613 | break; // For now, stop after the first alarm | 614 | break; // For now, stop after the first alarm |
614 | } | 615 | } |
615 | } else { | 616 | } else { |
616 | Alarm* alarm = event->alarms().first(); | 617 | Alarm* alarm = event->alarms().first(); |
617 | if ( alarm ) { | 618 | if ( alarm ) { |
618 | alarm->setEnabled(false); | 619 | alarm->setEnabled(false); |
619 | alarm->setType(Alarm::Invalid); | 620 | alarm->setType(Alarm::Invalid); |
620 | } | 621 | } |
621 | } | 622 | } |
622 | event->setCalID( getCalendarID() ); | 623 | event->setCalID( getCalendarID() ); |
623 | } | 624 | } |