author | zautrix <zautrix> | 2005-07-04 11:32:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-04 11:32:53 (UTC) |
commit | 172078c08cd183e9f7ec913a9bf42426e3585b78 (patch) (unidiff) | |
tree | d0f82f7495287ca23db2faf0ed541dc42b087464 | |
parent | e19b410f43c4fcf35d3d62fc312d1b5251068691 (diff) | |
download | kdepimpi-172078c08cd183e9f7ec913a9bf42426e3585b78.zip kdepimpi-172078c08cd183e9f7ec913a9bf42426e3585b78.tar.gz kdepimpi-172078c08cd183e9f7ec913a9bf42426e3585b78.tar.bz2 |
layout fix
-rw-r--r-- | korganizer/koeditorgeneral.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp index 753630b..407a5d5 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, 10); | 86 | mSummaryEdit = new KOLocationBox(TRUE,parent, 10); |
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,10); | 108 | mLocationEdit = new KOLocationBox(TRUE,parent,10); |
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 | headerLayout->setColStretch( 1, 10); | 128 | headerLayout->setColStretch( 1, 3); |
129 | headerLayout->setColStretch( 2, 1); | ||
129 | } | 130 | } |
130 | 131 | ||
131 | } | 132 | } |
132 | void KOEditorGeneral::setFocusOn( int i ) | 133 | void KOEditorGeneral::setFocusOn( int i ) |
133 | { | 134 | { |
134 | mNextFocus = i; | 135 | mNextFocus = i; |
135 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); | 136 | QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); |
136 | } | 137 | } |
137 | void KOEditorGeneral::slotSetFocusOn() | 138 | void KOEditorGeneral::slotSetFocusOn() |
138 | { | 139 | { |
139 | mNextFocus; | 140 | mNextFocus; |
140 | if ( mNextFocus == 1 ) { | 141 | if ( mNextFocus == 1 ) { |
141 | mDescriptionEdit->setFocus(); | 142 | mDescriptionEdit->setFocus(); |
142 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); | 143 | mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); |
143 | } | 144 | } |
144 | if ( mNextFocus == 2 ) { | 145 | if ( mNextFocus == 2 ) { |
145 | mSummaryEdit->setFocus(); | 146 | mSummaryEdit->setFocus(); |
146 | } | 147 | } |
147 | } | 148 | } |
148 | void KOEditorGeneral::editCategories() | 149 | void KOEditorGeneral::editCategories() |
149 | { | 150 | { |
150 | // qDebug("KOEditorGeneral::editCategories() "); | 151 | // qDebug("KOEditorGeneral::editCategories() "); |
151 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 152 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
152 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); | 153 | connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); |
153 | //KOGlobals::fitDialogToScreen( csd ); | 154 | //KOGlobals::fitDialogToScreen( csd ); |
154 | csd->setColorEnabled(); | 155 | csd->setColorEnabled(); |
155 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); | 156 | csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); |
156 | csd->exec(); | 157 | csd->exec(); |
157 | delete csd; | 158 | delete csd; |
158 | } | 159 | } |
159 | 160 | ||
160 | void KOEditorGeneral::showCatPopup() | 161 | void KOEditorGeneral::showCatPopup() |
161 | { | 162 | { |
162 | mCatPopup->clear(); | 163 | mCatPopup->clear(); |
163 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); | 164 | QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); |
164 | int index = 0; | 165 | int index = 0; |
165 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 166 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
166 | it != KOPrefs::instance()->mCustomCategories.end (); | 167 | it != KOPrefs::instance()->mCustomCategories.end (); |
167 | ++it) { | 168 | ++it) { |
168 | mCatPopup->insertItem (*it, index ); | 169 | mCatPopup->insertItem (*it, index ); |
169 | //mCategory[index] = *it; | 170 | //mCategory[index] = *it; |
170 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); | 171 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); |
171 | ++index; | 172 | ++index; |
172 | } | 173 | } |
173 | } | 174 | } |
174 | void KOEditorGeneral::selectedCatPopup( int index ) | 175 | void KOEditorGeneral::selectedCatPopup( int index ) |
175 | { | 176 | { |
176 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); | 177 | QStringList categories = QStringList::split (",", mCategoriesLabel->text()); |
177 | QString colcat = categories.first(); | 178 | QString colcat = categories.first(); |
178 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) | 179 | if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) |
179 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); | 180 | categories.remove (KOPrefs::instance()->mCustomCategories[index]); |
180 | else | 181 | else |
181 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); | 182 | categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); |
182 | categories.sort (); | 183 | categories.sort (); |
183 | if ( !colcat.isEmpty() ) { | 184 | if ( !colcat.isEmpty() ) { |
184 | if ( categories.find ( colcat ) != categories.end () ) { | 185 | if ( categories.find ( colcat ) != categories.end () ) { |
185 | categories.remove( colcat ); | 186 | categories.remove( colcat ); |
186 | categories.prepend( colcat ); | 187 | categories.prepend( colcat ); |
187 | } | 188 | } |
188 | } | 189 | } |
189 | setCategories( categories.join(",") ); | 190 | setCategories( categories.join(",") ); |
190 | } | 191 | } |
191 | 192 | ||
192 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) | 193 | void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) |
193 | { | 194 | { |
194 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); | 195 | QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); |
195 | mCatPopup = new QPopupMenu ( parent ); | 196 | mCatPopup = new QPopupMenu ( parent ); |
196 | mCatPopup->setCheckable (true); | 197 | mCatPopup->setCheckable (true); |
197 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); | 198 | connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); |
198 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); | 199 | connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); |
199 | mCategoriesButton = new QPushButton(parent); | 200 | mCategoriesButton = new QPushButton(parent); |
200 | mCategoriesButton->setText(i18n("Categories...")); | 201 | mCategoriesButton->setText(i18n("Categories...")); |
201 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 202 | connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
202 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); | 203 | //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); |
203 | categoriesLayout->addWidget(mCategoriesButton); | 204 | categoriesLayout->addWidget(mCategoriesButton); |
204 | mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); | 205 | mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); |
205 | mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 206 | mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
206 | mCategoriesLabel->setPopup( mCatPopup ); | 207 | mCategoriesLabel->setPopup( mCatPopup ); |
207 | //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 208 | //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
208 | categoriesLayout->addWidget(mCategoriesLabel,1); | 209 | categoriesLayout->addWidget(mCategoriesLabel,1); |
209 | } | 210 | } |
210 | 211 | ||
211 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) | 212 | void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) |
212 | { | 213 | { |
213 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); | 214 | QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); |
214 | 215 | ||
215 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); | 216 | QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); |
216 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); | 217 | mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); |
217 | secrecyLayout->addWidget(mCancelBox); | 218 | secrecyLayout->addWidget(mCancelBox); |
218 | secrecyLayout->addWidget(secrecyLabel); | 219 | secrecyLayout->addWidget(secrecyLabel); |
219 | 220 | ||
220 | mSecrecyCombo = new QComboBox(parent); | 221 | mSecrecyCombo = new QComboBox(parent); |
221 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); | 222 | mSecrecyCombo->insertStringList(Incidence::secrecyList()); |
222 | secrecyLayout->addWidget(mSecrecyCombo); | 223 | secrecyLayout->addWidget(mSecrecyCombo); |
223 | } | 224 | } |
224 | 225 | ||
225 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) | 226 | void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) |
226 | { | 227 | { |
227 | mDescriptionEdit = new KTextEdit(parent); | 228 | mDescriptionEdit = new KTextEdit(parent); |
228 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); | 229 | mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); |
229 | mDescriptionEdit->append(""); | 230 | mDescriptionEdit->append(""); |
230 | mDescriptionEdit->setReadOnly(false); | 231 | mDescriptionEdit->setReadOnly(false); |
231 | mDescriptionEdit->setOverwriteMode(false); | 232 | mDescriptionEdit->setOverwriteMode(false); |
232 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); | 233 | mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); |
233 | topLayout->addWidget(mDescriptionEdit); | 234 | topLayout->addWidget(mDescriptionEdit); |
234 | #ifndef DESKTOP_VERSION | 235 | #ifndef DESKTOP_VERSION |
235 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); | 236 | QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); |
236 | #endif | 237 | #endif |
237 | 238 | ||
238 | } | 239 | } |
239 | 240 | ||
240 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) | 241 | void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) |
241 | { | 242 | { |
242 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); | 243 | QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); |
243 | 244 | ||
244 | //mAlarmBell = new QLabel(parent); | 245 | //mAlarmBell = new QLabel(parent); |
245 | //mAlarmBell->setPixmap(SmallIcon("bell")); | 246 | //mAlarmBell->setPixmap(SmallIcon("bell")); |
246 | //alarmLayout->addWidget(mAlarmBell); | 247 | //alarmLayout->addWidget(mAlarmBell); |
247 | if ( QApplication::desktop()->width() < 320 ) | 248 | if ( QApplication::desktop()->width() < 320 ) |
248 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); | 249 | mAlarmButton = new QCheckBox(i18n("Rem."),parent); |
249 | else | 250 | else |
250 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); | 251 | mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); |
251 | 252 | ||
252 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); | 253 | connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); |
253 | alarmLayout->addWidget(mAlarmButton); | 254 | alarmLayout->addWidget(mAlarmButton); |
254 | 255 | ||
255 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; | 256 | mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; |
256 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); | 257 | mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); |
257 | alarmLayout->addWidget(mAlarmTimeEdit); | 258 | alarmLayout->addWidget(mAlarmTimeEdit); |
258 | mAlarmIncrCombo = new QComboBox(false, parent); | 259 | mAlarmIncrCombo = new QComboBox(false, parent); |
259 | if ( QApplication::desktop()->width() < 320 ) { | 260 | if ( QApplication::desktop()->width() < 320 ) { |
260 | mAlarmIncrCombo->insertItem(i18n("min")); | 261 | mAlarmIncrCombo->insertItem(i18n("min")); |
261 | mAlarmIncrCombo->insertItem(i18n("hou")); | 262 | mAlarmIncrCombo->insertItem(i18n("hou")); |
262 | mAlarmIncrCombo->insertItem(i18n("day")); | 263 | mAlarmIncrCombo->insertItem(i18n("day")); |
263 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); | 264 | mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); |
264 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); | 265 | mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); |
265 | } else { | 266 | } else { |
266 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); | 267 | mAlarmIncrCombo->insertItem(i18n("minute(s)")); |
267 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); | 268 | mAlarmIncrCombo->insertItem(i18n("hour(s)")); |
268 | mAlarmIncrCombo->insertItem(i18n("day(s)")); | 269 | mAlarmIncrCombo->insertItem(i18n("day(s)")); |
269 | } | 270 | } |
270 | 271 | ||
271 | // mAlarmIncrCombo->setMinimumHeight(20); | 272 | // mAlarmIncrCombo->setMinimumHeight(20); |
272 | alarmLayout->addWidget(mAlarmIncrCombo); | 273 | alarmLayout->addWidget(mAlarmIncrCombo); |
273 | mAlarmSoundButton = new QPushButton(parent); | 274 | mAlarmSoundButton = new QPushButton(parent); |
274 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); | 275 | mAlarmSoundButton->setPixmap(SmallIcon("playsound")); |
275 | mAlarmSoundButton->setToggleButton(true); | 276 | mAlarmSoundButton->setToggleButton(true); |
276 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 277 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
277 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); | 278 | connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); |
278 | alarmLayout->addWidget(mAlarmSoundButton); | 279 | alarmLayout->addWidget(mAlarmSoundButton); |
279 | 280 | ||
280 | mAlarmProgramButton = new QPushButton(parent); | 281 | mAlarmProgramButton = new QPushButton(parent); |
281 | mAlarmProgramButton->setPixmap(SmallIcon("run")); | 282 | mAlarmProgramButton->setPixmap(SmallIcon("run")); |
282 | mAlarmProgramButton->setToggleButton(true); | 283 | mAlarmProgramButton->setToggleButton(true); |
283 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 284 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
284 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); | 285 | connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); |
285 | alarmLayout->addWidget(mAlarmProgramButton); | 286 | alarmLayout->addWidget(mAlarmProgramButton); |
286 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); | 287 | mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); |
287 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); | 288 | mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); |
288 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 289 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
289 | // mAlarmSoundButton->hide(); | 290 | // mAlarmSoundButton->hide(); |
290 | // mAlarmProgramButton->hide(); | 291 | // mAlarmProgramButton->hide(); |
291 | // } | 292 | // } |
292 | } | 293 | } |
293 | 294 | ||
294 | void KOEditorGeneral::pickAlarmSound() | 295 | void KOEditorGeneral::pickAlarmSound() |
295 | { | 296 | { |
296 | 297 | ||
297 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); | 298 | //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); |
298 | 299 | ||
299 | bool oldState = mAlarmSoundButton->isOn(); | 300 | bool oldState = mAlarmSoundButton->isOn(); |
300 | 301 | ||
301 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, | 302 | QString fileName(KFileDialog::getOpenFileName(mAlarmSound, |
302 | i18n("*.wav|Wav Files"), 0)); | 303 | i18n("*.wav|Wav Files"), 0)); |
303 | if (!fileName.isEmpty()) { | 304 | if (!fileName.isEmpty()) { |
304 | mAlarmSound = fileName; | 305 | mAlarmSound = fileName; |
305 | QToolTip::remove(mAlarmSoundButton); | 306 | QToolTip::remove(mAlarmSoundButton); |
306 | QString dispStr = i18n("Playing '%1'").arg(fileName); | 307 | QString dispStr = i18n("Playing '%1'").arg(fileName); |
307 | QToolTip::add(mAlarmSoundButton, dispStr); | 308 | QToolTip::add(mAlarmSoundButton, dispStr); |
308 | mAlarmProgramButton->setOn(false); | 309 | mAlarmProgramButton->setOn(false); |
309 | mAlarmSoundButton->setOn(true); | 310 | mAlarmSoundButton->setOn(true); |
310 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); | 311 | QToolTip::add(mAlarmProgramButton, i18n("No program set")); |
311 | } else { | 312 | } else { |
312 | mAlarmProgramButton->setOn(oldState); | 313 | mAlarmProgramButton->setOn(oldState); |
313 | mAlarmSoundButton->setOn(!oldState); | 314 | mAlarmSoundButton->setOn(!oldState); |
314 | 315 | ||
315 | 316 | ||
316 | } | 317 | } |
317 | 318 | ||
318 | if (mAlarmProgramButton->isOn()) | 319 | if (mAlarmProgramButton->isOn()) |
319 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 320 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
320 | if ( mAlarmSoundButton->isOn()) | 321 | if ( mAlarmSoundButton->isOn()) |
321 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 322 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
322 | 323 | ||
323 | } | 324 | } |
324 | 325 | ||
325 | void KOEditorGeneral::pickAlarmProgram() | 326 | void KOEditorGeneral::pickAlarmProgram() |
326 | { | 327 | { |
327 | bool oldState = mAlarmProgramButton->isOn(); | 328 | bool oldState = mAlarmProgramButton->isOn(); |
328 | 329 | ||
329 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); | 330 | QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); |
330 | if (!fileName.isEmpty()) { | 331 | if (!fileName.isEmpty()) { |
331 | mAlarmProgram = fileName; | 332 | mAlarmProgram = fileName; |
332 | QToolTip::remove(mAlarmProgramButton); | 333 | QToolTip::remove(mAlarmProgramButton); |
333 | QString dispStr = i18n("Running '%1'").arg(fileName); | 334 | QString dispStr = i18n("Running '%1'").arg(fileName); |
334 | QToolTip::add(mAlarmProgramButton, dispStr); | 335 | QToolTip::add(mAlarmProgramButton, dispStr); |
335 | mAlarmSoundButton->setOn(false); | 336 | mAlarmSoundButton->setOn(false); |
336 | mAlarmProgramButton->setOn(true); | 337 | mAlarmProgramButton->setOn(true); |
337 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); | 338 | QToolTip::add(mAlarmSoundButton, i18n("No sound set")); |
338 | } else { | 339 | } else { |
339 | mAlarmProgramButton->setOn(!oldState); | 340 | mAlarmProgramButton->setOn(!oldState); |
340 | mAlarmSoundButton->setOn(oldState); | 341 | mAlarmSoundButton->setOn(oldState); |
341 | } | 342 | } |
342 | 343 | ||
343 | if (mAlarmProgramButton->isOn()) | 344 | if (mAlarmProgramButton->isOn()) |
344 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); | 345 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); |
345 | if ( mAlarmSoundButton->isOn()) | 346 | if ( mAlarmSoundButton->isOn()) |
346 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); | 347 | ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); |
347 | 348 | ||
348 | } | 349 | } |
349 | 350 | ||
350 | 351 | ||
351 | QString KOEditorGeneral::getFittingPath( const QString s ) | 352 | QString KOEditorGeneral::getFittingPath( const QString s ) |
352 | { | 353 | { |
353 | int maxlen = 50; | 354 | int maxlen = 50; |
354 | if ( QApplication::desktop()->width() < 640 ) { | 355 | if ( QApplication::desktop()->width() < 640 ) { |
355 | if ( QApplication::desktop()->width() < 320 ) | 356 | if ( QApplication::desktop()->width() < 320 ) |
356 | maxlen = 22; | 357 | maxlen = 22; |
357 | else | 358 | else |
358 | maxlen = 35; | 359 | maxlen = 35; |
359 | } | 360 | } |
360 | if ( s.length() > maxlen ) { | 361 | if ( s.length() > maxlen ) { |
361 | return "..."+s.right(maxlen -3); | 362 | return "..."+s.right(maxlen -3); |
362 | } | 363 | } |
363 | return s; | 364 | return s; |
364 | } | 365 | } |
365 | 366 | ||
366 | void KOEditorGeneral::enableAlarmEdit(bool enable) | 367 | void KOEditorGeneral::enableAlarmEdit(bool enable) |
367 | { | 368 | { |
368 | if ( enable ) { | 369 | if ( enable ) { |
369 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { | 370 | if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { |
370 | mAlarmSoundButton->setOn( true ); | 371 | mAlarmSoundButton->setOn( true ); |
371 | if ( mAlarmSound.isEmpty() ) | 372 | if ( mAlarmSound.isEmpty() ) |
372 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 373 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
373 | else { | 374 | else { |
374 | if ( ! QFile::exists( mAlarmSound ) ) | 375 | if ( ! QFile::exists( mAlarmSound ) ) |
375 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 376 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
376 | } | 377 | } |
377 | } | 378 | } |
378 | } | 379 | } |
379 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); | 380 | ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); |
380 | mAlarmTimeEdit->setEnabled(enable); | 381 | mAlarmTimeEdit->setEnabled(enable); |
381 | mAlarmSoundButton->setEnabled(enable); | 382 | mAlarmSoundButton->setEnabled(enable); |
382 | mAlarmProgramButton->setEnabled(enable); | 383 | mAlarmProgramButton->setEnabled(enable); |
383 | mAlarmIncrCombo->setEnabled(enable); | 384 | mAlarmIncrCombo->setEnabled(enable); |
384 | } | 385 | } |
385 | 386 | ||
386 | void KOEditorGeneral::disableAlarmEdit(bool disable) | 387 | void KOEditorGeneral::disableAlarmEdit(bool disable) |
387 | { | 388 | { |
388 | enableAlarmEdit( !disable ); | 389 | enableAlarmEdit( !disable ); |
389 | } | 390 | } |
390 | 391 | ||
391 | void KOEditorGeneral::enableAlarm( bool enable ) | 392 | void KOEditorGeneral::enableAlarm( bool enable ) |
392 | { | 393 | { |
393 | enableAlarmEdit( enable ); | 394 | enableAlarmEdit( enable ); |
394 | } | 395 | } |
395 | 396 | ||
396 | void KOEditorGeneral::alarmDisable(bool disable) | 397 | void KOEditorGeneral::alarmDisable(bool disable) |
397 | { | 398 | { |
398 | if (!disable) { | 399 | if (!disable) { |
399 | //mAlarmBell->setEnabled(true); | 400 | //mAlarmBell->setEnabled(true); |
400 | mAlarmButton->setEnabled(true); | 401 | mAlarmButton->setEnabled(true); |
401 | } else { | 402 | } else { |
402 | //mAlarmBell->setEnabled(false); | 403 | //mAlarmBell->setEnabled(false); |
403 | mAlarmButton->setEnabled(false); | 404 | mAlarmButton->setEnabled(false); |
404 | mAlarmButton->setChecked(false); | 405 | mAlarmButton->setChecked(false); |
405 | mAlarmTimeEdit->setEnabled(false); | 406 | mAlarmTimeEdit->setEnabled(false); |
406 | mAlarmSoundButton->setEnabled(false); | 407 | mAlarmSoundButton->setEnabled(false); |
407 | mAlarmProgramButton->setEnabled(false); | 408 | mAlarmProgramButton->setEnabled(false); |
408 | mAlarmIncrCombo->setEnabled(false); | 409 | mAlarmIncrCombo->setEnabled(false); |
409 | } | 410 | } |
410 | } | 411 | } |
411 | 412 | ||
412 | void KOEditorGeneral::setCategories(const QString &str) | 413 | void KOEditorGeneral::setCategories(const QString &str) |
413 | { | 414 | { |
414 | QString tt = str; | 415 | QString tt = str; |
415 | QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); | 416 | QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); |
416 | mCategoriesLabel->setText(str); | 417 | mCategoriesLabel->setText(str); |
417 | } | 418 | } |
418 | 419 | ||
419 | void KOEditorGeneral::setDefaults(bool allDay) | 420 | void KOEditorGeneral::setDefaults(bool allDay) |
420 | { | 421 | { |
421 | #if 0 | 422 | #if 0 |
422 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); | 423 | mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); |
423 | #endif | 424 | #endif |
424 | 425 | ||
425 | mAlarmMessage = i18n("Edit new item"); | 426 | mAlarmMessage = i18n("Edit new item"); |
426 | enableAlarmEdit( !allDay ); | 427 | enableAlarmEdit( !allDay ); |
427 | 428 | ||
428 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. | 429 | // TODO: Implement a KPrefsComboItem to solve this in a clean way. |
429 | int alarmTime; | 430 | int alarmTime; |
430 | int a[] = { 1,5,10,15,30,60,180, 1440 }; | 431 | int a[] = { 1,5,10,15,30,60,180, 1440 }; |
431 | int index = KOPrefs::instance()->mAlarmTime; | 432 | int index = KOPrefs::instance()->mAlarmTime; |
432 | if (index < 0 || index > 7) { | 433 | if (index < 0 || index > 7) { |
433 | alarmTime = 15; | 434 | alarmTime = 15; |
434 | } else { | 435 | } else { |
435 | alarmTime = a[index]; | 436 | alarmTime = a[index]; |
436 | } | 437 | } |
437 | mAlarmButton ->setChecked( false ); | 438 | mAlarmButton ->setChecked( false ); |
438 | mAlarmTimeEdit->setValue(alarmTime); | 439 | mAlarmTimeEdit->setValue(alarmTime); |
439 | mAlarmIncrCombo->setCurrentItem(0); | 440 | mAlarmIncrCombo->setCurrentItem(0); |
440 | enableAlarmEdit( false ); | 441 | enableAlarmEdit( false ); |
441 | //alarmDisable (false); | 442 | //alarmDisable (false); |
442 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); | 443 | mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); |
443 | mCancelBox->setChecked( false ); | 444 | mCancelBox->setChecked( false ); |
444 | mSummaryEdit->setEditText(""); | 445 | mSummaryEdit->setEditText(""); |
445 | mLocationEdit->setEditText(""); | 446 | mLocationEdit->setEditText(""); |
446 | mDescriptionEdit->setText(""); | 447 | mDescriptionEdit->setText(""); |
447 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; | 448 | mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; |
448 | setCategories(""); | 449 | setCategories(""); |
449 | fillCalCombo(); | 450 | fillCalCombo(); |
450 | } | 451 | } |
451 | void KOEditorGeneral::setSecrecy( int num ) | 452 | void KOEditorGeneral::setSecrecy( int num ) |
452 | { | 453 | { |
453 | mSecrecyCombo->setCurrentItem(num); | 454 | mSecrecyCombo->setCurrentItem(num); |
454 | } | 455 | } |
455 | void KOEditorGeneral::fillCalCombo( int setToID ) | 456 | void KOEditorGeneral::fillCalCombo( int setToID ) |
456 | { | 457 | { |
457 | mCalendarBox->clear(); | 458 | mCalendarBox->clear(); |
458 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 459 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
459 | int std = 0; | 460 | int std = 0; |
460 | int count = 0; | 461 | int count = 0; |
461 | while ( kkf ) { | 462 | while ( kkf ) { |
462 | if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) { | 463 | if ( !kkf->mErrorOnLoad &&! kkf->isReadOnly ) { |
463 | if ( setToID ) { | 464 | if ( setToID ) { |
464 | if ( kkf->mCalNumber == setToID ) | 465 | if ( kkf->mCalNumber == setToID ) |
465 | std = count; | 466 | std = count; |
466 | } else { | 467 | } else { |
467 | if ( kkf->isStandard ) { | 468 | if ( kkf->isStandard ) { |
468 | std = count; | 469 | std = count; |
469 | } | 470 | } |
470 | } | 471 | } |
471 | ++count; | 472 | ++count; |
472 | mCalendarBox->insertItem( kkf->mName ); | 473 | mCalendarBox->insertItem( kkf->mName ); |
473 | } | 474 | } |
474 | kkf = KOPrefs::instance()->mCalendars.next(); | 475 | kkf = KOPrefs::instance()->mCalendars.next(); |
475 | } | 476 | } |
476 | mCalendarBox->setCurrentItem( std ); | 477 | mCalendarBox->setCurrentItem( std ); |
477 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) | 478 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) |
478 | mCalendarBox->hide(); | 479 | mCalendarBox->hide(); |
479 | else | 480 | else |
480 | mCalendarBox->show(); | 481 | mCalendarBox->show(); |
481 | 482 | ||
482 | } | 483 | } |
483 | int KOEditorGeneral::getCalendarID() | 484 | int KOEditorGeneral::getCalendarID() |
484 | { | 485 | { |
485 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 486 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
486 | while ( kkf ) { | 487 | while ( kkf ) { |
487 | if ( mCalendarBox->currentText() == kkf->mName) | 488 | if ( mCalendarBox->currentText() == kkf->mName) |
488 | return kkf->mCalNumber; | 489 | return kkf->mCalNumber; |
489 | kkf = KOPrefs::instance()->mCalendars.next(); | 490 | kkf = KOPrefs::instance()->mCalendars.next(); |
490 | } | 491 | } |
491 | return 1; | 492 | return 1; |
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 | } |