summaryrefslogtreecommitdiffabout
path: root/korganizer/koeditorgeneral.cpp
Unidiff
Diffstat (limited to 'korganizer/koeditorgeneral.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koeditorgeneral.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 21f220c..8105432 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,122 +1,129 @@
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 <q3vbox.h>
28#include <qbuttongroup.h> 28#include <q3buttongroup.h>
29#include <qvgroupbox.h> 29#include <q3vgroupbox.h>
30#include <qwidgetstack.h> 30#include <q3widgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qregexp.h> 34#include <qregexp.h>
35//Added by qt3to4:
36#include <Q3HBoxLayout>
37#include <QLabel>
38#include <Q3GridLayout>
39#include <Q3PtrList>
40#include <Q3PopupMenu>
35 41
42#include <QDesktopWidget>
36 43
37#include <kglobal.h> 44#include <kglobal.h>
38#include <kdialog.h> 45#include <kdialog.h>
39#include <kdebug.h> 46#include <kdebug.h>
40#include <klocale.h> 47#include <klocale.h>
41#include <kiconloader.h> 48#include <kiconloader.h>
42#include <kmessagebox.h> 49#include <kmessagebox.h>
43#include <kfiledialog.h> 50#include <kfiledialog.h>
44#include <kstandarddirs.h> 51#include <kstandarddirs.h>
45 52
46#include <libkcal/todo.h> 53#include <libkcal/todo.h>
47#include <libkcal/event.h> 54#include <libkcal/event.h>
48#include <libkdepim/categoryselectdialog.h> 55#include <libkdepim/categoryselectdialog.h>
49#include <libkdepim/kdateedit.h> 56#include <libkdepim/kdateedit.h>
50 57
51#include "koprefs.h" 58#include "koprefs.h"
52#include "koglobals.h" 59#include "koglobals.h"
53 60
54#include "koeditorgeneral.h" 61#include "koeditorgeneral.h"
55#include "kolocationbox.h" 62#include "kolocationbox.h"
56#ifndef DESKTOP_VERSION 63#ifndef DESKTOP_VERSION
57#include <qpe/qpeapplication.h> 64#include <qpe/qpeapplication.h>
58#else 65#else
59#include <qapplication.h> 66#include <qapplication.h>
60#endif 67#endif
61 68
62KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 69KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
63 QObject( parent, name) 70 QObject( parent, name)
64{ 71{
65 mNextFocus = 0; 72 mNextFocus = 0;
66} 73}
67 74
68KOEditorGeneral::~KOEditorGeneral() 75KOEditorGeneral::~KOEditorGeneral()
69{ 76{
70} 77}
71 78
72void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 79void KOEditorGeneral::initHeader(QWidget *parent,Q3BoxLayout *topLayout)
73{ 80{
74 QGridLayout *headerLayout = new QGridLayout(topLayout); 81 Q3GridLayout *headerLayout = new Q3GridLayout(topLayout);
75 82
76#if 0 83#if 0
77 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 84 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
78 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 85 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
79#endif 86#endif
80 // 1 on pda 87 // 1 on pda
81 // 11 on desktop 88 // 11 on desktop
82 headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 ); 89 headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 );
83 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 90 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
84 headerLayout->addWidget(summaryLabel,0,0); 91 headerLayout->addWidget(summaryLabel,0,0);
85 92
86 mSummaryEdit = new KOLocationBox(TRUE,parent, 50); 93 mSummaryEdit = new KOLocationBox(TRUE,parent, 50);
87 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 94 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
88 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 95 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
89 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 96 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
90 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 97 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
91 if ( QApplication::desktop()->width() > 320 ) 98 if ( QApplication::desktop()->width() > 320 )
92 mSummaryEdit->setMaximumHeight( hei +6 ); 99 mSummaryEdit->setMaximumHeight( hei +6 );
93 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 100 //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 } 101 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
95 // mSummaryEdit = new QLineEdit(parent); 102 // mSummaryEdit = new QLineEdit(parent);
96 if ( QApplication::desktop()->height() < 320 ) 103 if ( QApplication::desktop()->height() < 320 )
97 headerLayout->addWidget(mSummaryEdit,0,1); 104 headerLayout->addWidget(mSummaryEdit,0,1);
98 else 105 else
99 headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2); 106 headerLayout->addMultiCellWidget(mSummaryEdit,0,0,1,2);
100 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 107 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
101 108
102 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 109 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
103 if ( QApplication::desktop()->height() < 320 ) 110 if ( QApplication::desktop()->height() < 320 )
104 headerLayout->addWidget(locationLabel,0,2); 111 headerLayout->addWidget(locationLabel,0,2);
105 else 112 else
106 headerLayout->addWidget(locationLabel,1,0); 113 headerLayout->addWidget(locationLabel,1,0);
107 114
108 mLocationEdit = new KOLocationBox(TRUE,parent,30); 115 mLocationEdit = new KOLocationBox(TRUE,parent,30);
109 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 116 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
110 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) 117 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 )
111 mLocationEdit->setMaximumHeight( hei + 6); 118 mLocationEdit->setMaximumHeight( hei + 6);
112 119
113 // mLocationEdit = new QLineEdit(parent); 120 // mLocationEdit = new QLineEdit(parent);
114 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 121 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
115 122
116 mCalendarBox = new QComboBox ( parent ); 123 mCalendarBox = new QComboBox ( parent );
117 mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 124 mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
118 if ( QApplication::desktop()->height() < 320 ) { 125 if ( QApplication::desktop()->height() < 320 ) {
119 headerLayout->addWidget(mLocationEdit,0,3); 126 headerLayout->addWidget(mLocationEdit,0,3);
120 headerLayout->addWidget(mCalendarBox,0,4); 127 headerLayout->addWidget(mCalendarBox,0,4);
121 headerLayout->setColStretch( 1, 10); 128 headerLayout->setColStretch( 1, 10);
122 headerLayout->setColStretch( 3, 10); 129 headerLayout->setColStretch( 3, 10);
@@ -150,147 +157,147 @@ void KOEditorGeneral::slotSetFocusOn()
150 if ( mNextFocus == 2 ) { 157 if ( mNextFocus == 2 ) {
151 mSummaryEdit->setFocus(); 158 mSummaryEdit->setFocus();
152 } 159 }
153} 160}
154void KOEditorGeneral::editCategories() 161void KOEditorGeneral::editCategories()
155{ 162{
156 // qDebug("KOEditorGeneral::editCategories() "); 163 // qDebug("KOEditorGeneral::editCategories() ");
157 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 164 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
158 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 165 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
159 //KOGlobals::fitDialogToScreen( csd ); 166 //KOGlobals::fitDialogToScreen( csd );
160 csd->setColorEnabled(); 167 csd->setColorEnabled();
161 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 168 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
162 csd->exec(); 169 csd->exec();
163 delete csd; 170 delete csd;
164} 171}
165 172
166void KOEditorGeneral::showCatPopup() 173void KOEditorGeneral::showCatPopup()
167{ 174{
168 mCatPopup->clear(); 175 mCatPopup->clear();
169 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); 176 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text());
170 int index = 0; 177 int index = 0;
171 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 178 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
172 it != KOPrefs::instance()->mCustomCategories.end (); 179 it != KOPrefs::instance()->mCustomCategories.end ();
173 ++it) { 180 ++it) {
174 mCatPopup->insertItem (*it, index ); 181 mCatPopup->insertItem (*it, index );
175 //mCategory[index] = *it; 182 //mCategory[index] = *it;
176 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); 183 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
177 ++index; 184 ++index;
178 } 185 }
179} 186}
180void KOEditorGeneral::selectedCatPopup( int index ) 187void KOEditorGeneral::selectedCatPopup( int index )
181{ 188{
182 QStringList categories = QStringList::split (",", mCategoriesLabel->text()); 189 QStringList categories = QStringList::split (",", mCategoriesLabel->text());
183 QString colcat = categories.first(); 190 QString colcat = categories.first();
184 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 191 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
185 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 192 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
186 else 193 else
187 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 194 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
188 categories.sort (); 195 categories.sort ();
189 if ( !colcat.isEmpty() ) { 196 if ( !colcat.isEmpty() ) {
190 if ( categories.find ( colcat ) != categories.end () ) { 197 if ( categories.find ( colcat ) != categories.end () ) {
191 categories.remove( colcat ); 198 categories.remove( colcat );
192 categories.prepend( colcat ); 199 categories.prepend( colcat );
193 } 200 }
194 } 201 }
195 setCategories( categories.join(",") ); 202 setCategories( categories.join(",") );
196} 203}
197 204
198void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 205void KOEditorGeneral::initCategories(QWidget *parent, Q3BoxLayout *topLayout)
199{ 206{
200 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 207 Q3BoxLayout *categoriesLayout = new Q3HBoxLayout( topLayout );
201 mCatPopup = new QPopupMenu ( parent ); 208 mCatPopup = new Q3PopupMenu ( parent );
202 mCatPopup->setCheckable (true); 209 mCatPopup->setCheckable (true);
203 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); 210 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
204 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); 211 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
205 mCategoriesButton = new QPushButton(parent); 212 mCategoriesButton = new QPushButton(parent);
206 mCategoriesButton->setText(i18n("Categories...")); 213 mCategoriesButton->setText(i18n("Categories..."));
207 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 214 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
208 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 215 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
209 categoriesLayout->addWidget(mCategoriesButton); 216 categoriesLayout->addWidget(mCategoriesButton);
210 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); 217 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent);
211 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); 218 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) );
212 mCategoriesLabel->setPopup( mCatPopup ); 219 mCategoriesLabel->setPopup( mCatPopup );
213 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 220 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
214 categoriesLayout->addWidget(mCategoriesLabel,1); 221 categoriesLayout->addWidget(mCategoriesLabel,1);
215} 222}
216 223
217void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 224void KOEditorGeneral::initSecrecy(QWidget *parent, Q3BoxLayout *topLayout)
218{ 225{
219 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 226 Q3BoxLayout *secrecyLayout = new Q3HBoxLayout( topLayout );
220 227
221 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 228 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
222 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 229 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
223 secrecyLayout->addWidget(mCancelBox); 230 secrecyLayout->addWidget(mCancelBox);
224 secrecyLayout->addWidget(secrecyLabel); 231 secrecyLayout->addWidget(secrecyLabel);
225 232
226 mSecrecyCombo = new QComboBox(parent); 233 mSecrecyCombo = new QComboBox(parent);
227 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 234 mSecrecyCombo->insertStringList(Incidence::secrecyList());
228 secrecyLayout->addWidget(mSecrecyCombo); 235 secrecyLayout->addWidget(mSecrecyCombo);
229} 236}
230 237
231void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 238void KOEditorGeneral::initDescription(QWidget *parent,Q3BoxLayout *topLayout)
232{ 239{
233 mDescriptionEdit = new KTextEdit(parent); 240 mDescriptionEdit = new KTextEdit(parent);
234 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 241 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
235 mDescriptionEdit->append(""); 242 mDescriptionEdit->append("");
236 mDescriptionEdit->setReadOnly(false); 243 mDescriptionEdit->setReadOnly(false);
237 mDescriptionEdit->setOverwriteMode(false); 244 mDescriptionEdit->setOverwriteMode(false);
238 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 245 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
239 topLayout->addWidget(mDescriptionEdit); 246 topLayout->addWidget(mDescriptionEdit);
240#ifndef DESKTOP_VERSION 247#ifndef DESKTOP_VERSION
241 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 248 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
242#endif 249#endif
243 250
244} 251}
245 252
246void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 253void KOEditorGeneral::initAlarm(QWidget *parent,Q3BoxLayout *topLayout)
247{ 254{
248 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 255 Q3BoxLayout *alarmLayout = new Q3HBoxLayout(topLayout);
249 256
250 //mAlarmBell = new QLabel(parent); 257 //mAlarmBell = new QLabel(parent);
251 //mAlarmBell->setPixmap(SmallIcon("bell")); 258 //mAlarmBell->setPixmap(SmallIcon("bell"));
252 //alarmLayout->addWidget(mAlarmBell); 259 //alarmLayout->addWidget(mAlarmBell);
253 if ( QApplication::desktop()->width() < 320 ) 260 if ( QApplication::desktop()->width() < 320 )
254 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 261 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
255 else 262 else
256 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 263 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
257 264
258 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 265 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
259 alarmLayout->addWidget(mAlarmButton); 266 alarmLayout->addWidget(mAlarmButton);
260 267
261 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 268 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
262 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 269 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
263 alarmLayout->addWidget(mAlarmTimeEdit); 270 alarmLayout->addWidget(mAlarmTimeEdit);
264 mAlarmIncrCombo = new QComboBox(false, parent); 271 mAlarmIncrCombo = new QComboBox(false, parent);
265 if ( QApplication::desktop()->width() < 320 ) { 272 if ( QApplication::desktop()->width() < 320 ) {
266 mAlarmIncrCombo->insertItem(i18n("min")); 273 mAlarmIncrCombo->insertItem(i18n("min"));
267 mAlarmIncrCombo->insertItem(i18n("hou")); 274 mAlarmIncrCombo->insertItem(i18n("hou"));
268 mAlarmIncrCombo->insertItem(i18n("day")); 275 mAlarmIncrCombo->insertItem(i18n("day"));
269 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 276 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
270 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 277 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
271 } else { 278 } else {
272 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 279 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
273 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 280 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
274 mAlarmIncrCombo->insertItem(i18n("day(s)")); 281 mAlarmIncrCombo->insertItem(i18n("day(s)"));
275 } 282 }
276 283
277 // mAlarmIncrCombo->setMinimumHeight(20); 284 // mAlarmIncrCombo->setMinimumHeight(20);
278 alarmLayout->addWidget(mAlarmIncrCombo); 285 alarmLayout->addWidget(mAlarmIncrCombo);
279 mAlarmSoundButton = new QPushButton(parent); 286 mAlarmSoundButton = new QPushButton(parent);
280 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 287 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
281 mAlarmSoundButton->setToggleButton(true); 288 mAlarmSoundButton->setToggleButton(true);
282 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 289 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
283 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 290 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
284 alarmLayout->addWidget(mAlarmSoundButton); 291 alarmLayout->addWidget(mAlarmSoundButton);
285 292
286 mAlarmProgramButton = new QPushButton(parent); 293 mAlarmProgramButton = new QPushButton(parent);
287 mAlarmProgramButton->setPixmap(SmallIcon("run")); 294 mAlarmProgramButton->setPixmap(SmallIcon("run"));
288 mAlarmProgramButton->setToggleButton(true); 295 mAlarmProgramButton->setToggleButton(true);
289 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 296 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
290 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 297 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
291 alarmLayout->addWidget(mAlarmProgramButton); 298 alarmLayout->addWidget(mAlarmProgramButton);
292 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 299 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
293 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 300 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
294 // if ( KOPrefs::instance()->mCompactDialogs ) { 301 // if ( KOPrefs::instance()->mCompactDialogs ) {
295 // mAlarmSoundButton->hide(); 302 // mAlarmSoundButton->hide();
296 // mAlarmProgramButton->hide(); 303 // mAlarmProgramButton->hide();
@@ -483,143 +490,143 @@ void KOEditorGeneral::fillCalCombo( int setToID )
483 if ( KOPrefs::instance()->mCalendars.count() == 1 ) 490 if ( KOPrefs::instance()->mCalendars.count() == 1 )
484 mCalendarBox->hide(); 491 mCalendarBox->hide();
485 else 492 else
486 mCalendarBox->show(); 493 mCalendarBox->show();
487 494
488} 495}
489int KOEditorGeneral::getCalendarID() 496int KOEditorGeneral::getCalendarID()
490{ 497{
491 return KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); 498 return KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() );
492} 499}
493 500
494void KOEditorGeneral::readIncidence(Incidence *event) 501void KOEditorGeneral::readIncidence(Incidence *event)
495{ 502{
496 fillCalCombo( event->calID() ); 503 fillCalCombo( event->calID() );
497 mAlarmMessage = event->summary(); 504 mAlarmMessage = event->summary();
498 if ( ! event->location().isEmpty() ) 505 if ( ! event->location().isEmpty() )
499 mAlarmMessage += " ("+event->location()+")"; 506 mAlarmMessage += " ("+event->location()+")";
500 mAlarmIncrCombo->setCurrentItem(0); 507 mAlarmIncrCombo->setCurrentItem(0);
501 mSummaryEdit->setEditText(event->summary()); 508 mSummaryEdit->setEditText(event->summary());
502 mLocationEdit->setEditText(event->location()); 509 mLocationEdit->setEditText(event->location());
503 mDescriptionEdit->setText(event->description()); 510 mDescriptionEdit->setText(event->description());
504 511
505#if 0 512#if 0
506 // organizer information 513 // organizer information
507 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 514 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
508#endif 515#endif
509 516
510 enableAlarmEdit( event->isAlarmEnabled() ); 517 enableAlarmEdit( event->isAlarmEnabled() );
511 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 518 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
512 if(!event->isAlarmEnabled()) { 519 if(!event->isAlarmEnabled()) {
513 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 520 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
514 int alarmTime; 521 int alarmTime;
515 int a[] = { 1,5,10,15,30,60,180, 1440 }; 522 int a[] = { 1,5,10,15,30,60,180, 1440 };
516 int index = KOPrefs::instance()->mAlarmTime; 523 int index = KOPrefs::instance()->mAlarmTime;
517 if (index < 0 || index > 7) { 524 if (index < 0 || index > 7) {
518 alarmTime = 15; 525 alarmTime = 15;
519 } else { 526 } else {
520 alarmTime = a[index]; 527 alarmTime = a[index];
521 } 528 }
522 mAlarmTimeEdit->setValue(alarmTime); 529 mAlarmTimeEdit->setValue(alarmTime);
523 } 530 }
524 mAlarmButton->setChecked( event->isAlarmEnabled() ); 531 mAlarmButton->setChecked( event->isAlarmEnabled() );
525 mSecrecyCombo->setCurrentItem(event->secrecy()); 532 mSecrecyCombo->setCurrentItem(event->secrecy());
526 mCancelBox->setChecked( event->cancelled() ); 533 mCancelBox->setChecked( event->cancelled() );
527 mAlarmProgramButton->setOn(false); 534 mAlarmProgramButton->setOn(false);
528 mAlarmSoundButton->setOn(false); 535 mAlarmSoundButton->setOn(false);
529 536
530 // set up alarm stuff 537 // set up alarm stuff
531 QPtrList<Alarm> alarms = event->alarms(); 538 Q3PtrList<Alarm> alarms = event->alarms();
532 Alarm* alarm; 539 Alarm* alarm;
533 mAlarmIncrCombo->setCurrentItem(0); 540 mAlarmIncrCombo->setCurrentItem(0);
534 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 541 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
535 int offset; 542 int offset;
536 if ( alarm->hasTime() ) { 543 if ( alarm->hasTime() ) {
537 QDateTime t = alarm->time(); 544 QDateTime t = alarm->time();
538 offset = event->dtStart().secsTo( t ); 545 offset = event->dtStart().secsTo( t );
539 } else { 546 } else {
540 offset = alarm->startOffset().asSeconds(); 547 offset = alarm->startOffset().asSeconds();
541 } 548 }
542 if ( offset != 0 ) { 549 if ( offset != 0 ) {
543 offset = offset / -60; // make minutes 550 offset = offset / -60; // make minutes
544 if (offset % 60 == 0) { // divides evenly into hours? 551 if (offset % 60 == 0) { // divides evenly into hours?
545 offset = offset / 60; 552 offset = offset / 60;
546 mAlarmIncrCombo->setCurrentItem(1); 553 mAlarmIncrCombo->setCurrentItem(1);
547 if (offset % 24 == 0) { // divides evenly into days? 554 if (offset % 24 == 0) { // divides evenly into days?
548 offset = offset / 24; 555 offset = offset / 24;
549 mAlarmIncrCombo->setCurrentItem(2); 556 mAlarmIncrCombo->setCurrentItem(2);
550 } 557 }
551 } 558 }
552 } 559 }
553 mAlarmTimeEdit->setValue( offset ); 560 mAlarmTimeEdit->setValue( offset );
554 if (alarm->type() == Alarm::Procedure) { 561 if (alarm->type() == Alarm::Procedure) {
555 562
556 mAlarmProgram = alarm->programFile(); 563 mAlarmProgram = alarm->programFile();
557 mAlarmProgramButton->setOn(true); 564 mAlarmProgramButton->setOn(true);
558 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 565 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
559 QToolTip::add(mAlarmProgramButton, dispStr); 566 QToolTip::add(mAlarmProgramButton, dispStr);
560 } 567 }
561 else if (alarm->type() == Alarm::Audio) { 568 else if (alarm->type() == Alarm::Audio) {
562 mAlarmSound = alarm->audioFile(); 569 mAlarmSound = alarm->audioFile();
563 if ( ! QFile::exists( mAlarmSound ) ) 570 if ( ! QFile::exists( mAlarmSound ) )
564 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 571 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
565 mAlarmSoundButton->setOn(true); 572 mAlarmSoundButton->setOn(true);
566 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 573 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
567 QToolTip::add(mAlarmSoundButton, dispStr); 574 QToolTip::add(mAlarmSoundButton, dispStr);
568 } 575 }
569 mAlarmButton->setChecked(alarm->enabled()); 576 mAlarmButton->setChecked(alarm->enabled());
570 enableAlarmEdit( alarm->enabled() ); 577 enableAlarmEdit( alarm->enabled() );
571 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 578 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
572 // TODO: Deal with multiple alarms 579 // TODO: Deal with multiple alarms
573 break; // For now, stop after the first alarm 580 break; // For now, stop after the first alarm
574 } 581 }
575 582
576 setCategories(event->categoriesStr()); 583 setCategories(event->categoriesStr());
577} 584}
578 585
579void KOEditorGeneral::writeIncidence(Incidence *event) 586void KOEditorGeneral::writeIncidence(Incidence *event)
580{ 587{
581 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 588 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
582 mLocationEdit->save(KOLocationBox::LOCATION); 589 mLocationEdit->save(KOLocationBox::LOCATION);
583 event->setSummary(mSummaryEdit->currentText()); 590 event->setSummary(mSummaryEdit->currentText());
584 event->setLocation(mLocationEdit->currentText()); 591 event->setLocation(mLocationEdit->currentText());
585 event->setDescription(mDescriptionEdit->text()); 592 event->setDescription(mDescriptionEdit->text());
586 event->setCategories(mCategoriesLabel->text()); 593 event->setCategories(mCategoriesLabel->text());
587 event->setSecrecy(mSecrecyCombo->currentItem()); 594 event->setSecrecy(mSecrecyCombo->currentItem());
588 event->setCancelled(mCancelBox->isChecked() );; 595 event->setCancelled(mCancelBox->isChecked() );;
589 // alarm stuff 596 // alarm stuff
590 if (mAlarmButton->isChecked()) { 597 if (mAlarmButton->isChecked()) {
591 if (event->alarms().count() == 0) 598 if (event->alarms().count() == 0)
592 event->newAlarm(); 599 event->newAlarm();
593 QPtrList<Alarm> alarms = event->alarms(); 600 Q3PtrList<Alarm> alarms = event->alarms();
594 Alarm *alarm; 601 Alarm *alarm;
595 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 602 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
596 alarm->setEnabled(true); 603 alarm->setEnabled(true);
597 int j = mAlarmTimeEdit->value()* -60; 604 int j = mAlarmTimeEdit->value()* -60;
598 if (mAlarmIncrCombo->currentItem() == 1) 605 if (mAlarmIncrCombo->currentItem() == 1)
599 j = j * 60; 606 j = j * 60;
600 else if (mAlarmIncrCombo->currentItem() == 2) 607 else if (mAlarmIncrCombo->currentItem() == 2)
601 j = j * (60 * 24); 608 j = j * (60 * 24);
602 alarm->setStartOffset( j ); 609 alarm->setStartOffset( j );
603 610
604 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 611 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
605 alarm->setProcedureAlarm(mAlarmProgram); 612 alarm->setProcedureAlarm(mAlarmProgram);
606 } 613 }
607 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 614 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
608 alarm->setAudioAlarm(mAlarmSound); 615 alarm->setAudioAlarm(mAlarmSound);
609 else 616 else
610 alarm->setType(Alarm::Invalid); 617 alarm->setType(Alarm::Invalid);
611 //alarm->setAudioAlarm("default"); 618 //alarm->setAudioAlarm("default");
612 // TODO: Deal with multiple alarms 619 // TODO: Deal with multiple alarms
613 break; // For now, stop after the first alarm 620 break; // For now, stop after the first alarm
614 } 621 }
615 } else { 622 } else {
616 Alarm* alarm = event->alarms().first(); 623 Alarm* alarm = event->alarms().first();
617 if ( alarm ) { 624 if ( alarm ) {
618 alarm->setEnabled(false); 625 alarm->setEnabled(false);
619 alarm->setType(Alarm::Invalid); 626 alarm->setType(Alarm::Invalid);
620 } 627 }
621 } 628 }
622 int id = getCalendarID(); 629 int id = getCalendarID();
623 event->setCalID( id ); 630 event->setCalID( id );
624 event->setAlarmEnabled( KOPrefs::instance()->getCalendar( id )->isAlarmEnabled ); 631 event->setAlarmEnabled( KOPrefs::instance()->getCalendar( id )->isAlarmEnabled );
625} 632}