summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorgeneral.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 5c94f62..2fbcd42 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,417 +1,418 @@
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 35
35 36
36#include <kglobal.h> 37#include <kglobal.h>
37#include <kdebug.h> 38#include <kdebug.h>
38#include <klocale.h> 39#include <klocale.h>
39#include <kiconloader.h> 40#include <kiconloader.h>
40#include <kmessagebox.h> 41#include <kmessagebox.h>
41#include <kfiledialog.h> 42#include <kfiledialog.h>
42#include <kstandarddirs.h> 43#include <kstandarddirs.h>
43 44
44#include <libkcal/todo.h> 45#include <libkcal/todo.h>
45#include <libkcal/event.h> 46#include <libkcal/event.h>
46#include <libkdepim/categoryselectdialog.h> 47#include <libkdepim/categoryselectdialog.h>
47#include <libkdepim/kdateedit.h> 48#include <libkdepim/kdateedit.h>
48 49
49#include "koprefs.h" 50#include "koprefs.h"
50#include "koglobals.h" 51#include "koglobals.h"
51 52
52#include "koeditorgeneral.h" 53#include "koeditorgeneral.h"
53#include "kolocationbox.h" 54#include "kolocationbox.h"
54#ifndef DESKTOP_VERSION 55#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 56#include <qpe/qpeapplication.h>
56#else 57#else
57#include <qapplication.h> 58#include <qapplication.h>
58#endif 59#endif
59 60
60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 61KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
61 QObject( parent, name) 62 QObject( parent, name)
62{ 63{
63 mNextFocus = 0; 64 mNextFocus = 0;
64} 65}
65 66
66KOEditorGeneral::~KOEditorGeneral() 67KOEditorGeneral::~KOEditorGeneral()
67{ 68{
68} 69}
69 70
70void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 71void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
71{ 72{
72 QGridLayout *headerLayout = new QGridLayout(topLayout); 73 QGridLayout *headerLayout = new QGridLayout(topLayout);
73 74
74#if 0 75#if 0
75 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 76 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
76 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 77 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
77#endif 78#endif
78 79
79 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 80 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
80 headerLayout->addWidget(summaryLabel,1,0); 81 headerLayout->addWidget(summaryLabel,1,0);
81 82
82 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 83 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
83 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 84 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
84 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 85 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
85 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 86 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
86 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 87 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
87 if ( QApplication::desktop()->width() > 320 ) 88 if ( QApplication::desktop()->width() > 320 )
88 mSummaryEdit->setMaximumHeight( hei +6 ); 89 mSummaryEdit->setMaximumHeight( hei +6 );
89 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 90 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
90 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } 91 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
91 // mSummaryEdit = new QLineEdit(parent); 92 // mSummaryEdit = new QLineEdit(parent);
92 headerLayout->addWidget(mSummaryEdit,1,1); 93 headerLayout->addWidget(mSummaryEdit,1,1);
93 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 94 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
94 95
95 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 96 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
96 if ( QApplication::desktop()->height() < 320 ) 97 if ( QApplication::desktop()->height() < 320 )
97 headerLayout->addWidget(locationLabel,1,2); 98 headerLayout->addWidget(locationLabel,1,2);
98 else 99 else
99 headerLayout->addWidget(locationLabel,2,0); 100 headerLayout->addWidget(locationLabel,2,0);
100 101
101 mLocationEdit = new KOLocationBox(TRUE,parent,10); 102 mLocationEdit = new KOLocationBox(TRUE,parent,10);
102 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 103 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
103 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) 104 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 )
104 mLocationEdit->setMaximumHeight( hei + 6); 105 mLocationEdit->setMaximumHeight( hei + 6);
105 106
106 // mLocationEdit = new QLineEdit(parent); 107 // mLocationEdit = new QLineEdit(parent);
107 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 108 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
108 if ( QApplication::desktop()->height() < 320 ) { 109 if ( QApplication::desktop()->height() < 320 ) {
109 headerLayout->addWidget(mLocationEdit,1,3); 110 headerLayout->addWidget(mLocationEdit,1,3);
110 headerLayout->setColStretch( 1, 10); 111 headerLayout->setColStretch( 1, 10);
111 headerLayout->setColStretch( 3, 10); 112 headerLayout->setColStretch( 3, 10);
112 } 113 }
113 else { 114 else {
114 headerLayout->addWidget(mLocationEdit,2,1); 115 headerLayout->addWidget(mLocationEdit,2,1);
115 headerLayout->setColStretch( 1, 10); 116 headerLayout->setColStretch( 1, 10);
116 } 117 }
117} 118}
118void KOEditorGeneral::setFocusOn( int i ) 119void KOEditorGeneral::setFocusOn( int i )
119{ 120{
120 mNextFocus = i; 121 mNextFocus = i;
121 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); 122 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
122} 123}
123void KOEditorGeneral::slotSetFocusOn() 124void KOEditorGeneral::slotSetFocusOn()
124{ 125{
125 mNextFocus; 126 mNextFocus;
126 if ( mNextFocus == 1 ) { 127 if ( mNextFocus == 1 ) {
127 mDescriptionEdit->setFocus(); 128 mDescriptionEdit->setFocus();
128 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 129 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
129 } 130 }
130 if ( mNextFocus == 2 ) { 131 if ( mNextFocus == 2 ) {
131 mSummaryEdit->setFocus(); 132 mSummaryEdit->setFocus();
132 } 133 }
133} 134}
134void KOEditorGeneral::editCategories() 135void KOEditorGeneral::editCategories()
135{ 136{
136 // qDebug("KOEditorGeneral::editCategories() "); 137 // qDebug("KOEditorGeneral::editCategories() ");
137 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 138 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
138 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 139 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
139 //KOGlobals::fitDialogToScreen( csd ); 140 //KOGlobals::fitDialogToScreen( csd );
140 csd->setColorEnabled(); 141 csd->setColorEnabled();
141 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 142 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
142 csd->exec(); 143 csd->exec();
143 delete csd; 144 delete csd;
144} 145}
145 146
146void KOEditorGeneral::showCatPopup() 147void KOEditorGeneral::showCatPopup()
147{ 148{
148 mCatPopup->clear(); 149 mCatPopup->clear();
149 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); 150 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text());
150 int index = 0; 151 int index = 0;
151 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 152 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
152 it != KOPrefs::instance()->mCustomCategories.end (); 153 it != KOPrefs::instance()->mCustomCategories.end ();
153 ++it) { 154 ++it) {
154 mCatPopup->insertItem (*it, index ); 155 mCatPopup->insertItem (*it, index );
155 //mCategory[index] = *it; 156 //mCategory[index] = *it;
156 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); 157 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
157 ++index; 158 ++index;
158 } 159 }
159} 160}
160void KOEditorGeneral::selectedCatPopup( int index ) 161void KOEditorGeneral::selectedCatPopup( int index )
161{ 162{
162 QStringList categories = QStringList::split (",", mCategoriesLabel->text()); 163 QStringList categories = QStringList::split (",", mCategoriesLabel->text());
163 QString colcat = categories.first(); 164 QString colcat = categories.first();
164 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 165 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
165 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 166 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
166 else 167 else
167 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 168 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
168 categories.sort (); 169 categories.sort ();
169 if ( !colcat.isEmpty() ) { 170 if ( !colcat.isEmpty() ) {
170 if ( categories.find ( colcat ) != categories.end () ) { 171 if ( categories.find ( colcat ) != categories.end () ) {
171 categories.remove( colcat ); 172 categories.remove( colcat );
172 categories.prepend( colcat ); 173 categories.prepend( colcat );
173 } 174 }
174 } 175 }
175 setCategories( categories.join(",") ); 176 setCategories( categories.join(",") );
176} 177}
177 178
178void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 179void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
179{ 180{
180 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 181 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
181 mCatPopup = new QPopupMenu ( parent ); 182 mCatPopup = new QPopupMenu ( parent );
182 mCatPopup->setCheckable (true); 183 mCatPopup->setCheckable (true);
183 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); 184 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
184 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); 185 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
185 mCategoriesButton = new QPushButton(parent); 186 mCategoriesButton = new QPushButton(parent);
186 mCategoriesButton->setText(i18n("Categories")); 187 mCategoriesButton->setText(i18n("Categories"));
187 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 188 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
188 categoriesLayout->addWidget(mCategoriesButton); 189 categoriesLayout->addWidget(mCategoriesButton);
189 mCategoriesButton->setPopup( mCatPopup ); 190 mCategoriesButton->setPopup( mCatPopup );
190 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); 191 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent);
191 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 192 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
192 connect(mCategoriesLabel,SIGNAL(clicked()),this, SLOT(editCategories() )); 193 connect(mCategoriesLabel,SIGNAL(clicked()),this, SLOT(editCategories() ));
193 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 194 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
194 categoriesLayout->addWidget(mCategoriesLabel,1); 195 categoriesLayout->addWidget(mCategoriesLabel,1);
195} 196}
196 197
197void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 198void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
198{ 199{
199 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 200 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
200 201
201 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 202 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
202 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 203 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
203 secrecyLayout->addWidget(mCancelBox); 204 secrecyLayout->addWidget(mCancelBox);
204 secrecyLayout->addWidget(secrecyLabel); 205 secrecyLayout->addWidget(secrecyLabel);
205 206
206 mSecrecyCombo = new QComboBox(parent); 207 mSecrecyCombo = new QComboBox(parent);
207 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 208 mSecrecyCombo->insertStringList(Incidence::secrecyList());
208 secrecyLayout->addWidget(mSecrecyCombo); 209 secrecyLayout->addWidget(mSecrecyCombo);
209} 210}
210 211
211void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 212void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
212{ 213{
213 mDescriptionEdit = new KTextEdit(parent); 214 mDescriptionEdit = new KTextEdit(parent);
214 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 215 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
215 mDescriptionEdit->append(""); 216 mDescriptionEdit->append("");
216 mDescriptionEdit->setReadOnly(false); 217 mDescriptionEdit->setReadOnly(false);
217 mDescriptionEdit->setOverwriteMode(false); 218 mDescriptionEdit->setOverwriteMode(false);
218 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 219 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
219 topLayout->addWidget(mDescriptionEdit); 220 topLayout->addWidget(mDescriptionEdit);
220#ifndef DESKTOP_VERSION 221#ifndef DESKTOP_VERSION
221 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 222 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
222#endif 223#endif
223 224
224} 225}
225 226
226void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 227void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
227{ 228{
228 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 229 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
229 230
230 //mAlarmBell = new QLabel(parent); 231 //mAlarmBell = new QLabel(parent);
231 //mAlarmBell->setPixmap(SmallIcon("bell")); 232 //mAlarmBell->setPixmap(SmallIcon("bell"));
232 //alarmLayout->addWidget(mAlarmBell); 233 //alarmLayout->addWidget(mAlarmBell);
233 if ( QApplication::desktop()->width() < 320 ) 234 if ( QApplication::desktop()->width() < 320 )
234 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 235 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
235 else 236 else
236 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 237 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
237 238
238 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 239 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
239 alarmLayout->addWidget(mAlarmButton); 240 alarmLayout->addWidget(mAlarmButton);
240 241
241 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 242 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
242 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 243 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
243 alarmLayout->addWidget(mAlarmTimeEdit); 244 alarmLayout->addWidget(mAlarmTimeEdit);
244 mAlarmIncrCombo = new QComboBox(false, parent); 245 mAlarmIncrCombo = new QComboBox(false, parent);
245 if ( QApplication::desktop()->width() < 320 ) { 246 if ( QApplication::desktop()->width() < 320 ) {
246 mAlarmIncrCombo->insertItem(i18n("min")); 247 mAlarmIncrCombo->insertItem(i18n("min"));
247 mAlarmIncrCombo->insertItem(i18n("hou")); 248 mAlarmIncrCombo->insertItem(i18n("hou"));
248 mAlarmIncrCombo->insertItem(i18n("day")); 249 mAlarmIncrCombo->insertItem(i18n("day"));
249 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 250 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
250 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 251 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
251 } else { 252 } else {
252 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 253 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
253 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 254 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
254 mAlarmIncrCombo->insertItem(i18n("day(s)")); 255 mAlarmIncrCombo->insertItem(i18n("day(s)"));
255 } 256 }
256 257
257 // mAlarmIncrCombo->setMinimumHeight(20); 258 // mAlarmIncrCombo->setMinimumHeight(20);
258 alarmLayout->addWidget(mAlarmIncrCombo); 259 alarmLayout->addWidget(mAlarmIncrCombo);
259 mAlarmSoundButton = new QPushButton(parent); 260 mAlarmSoundButton = new QPushButton(parent);
260 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 261 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
261 mAlarmSoundButton->setToggleButton(true); 262 mAlarmSoundButton->setToggleButton(true);
262 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 263 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
263 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 264 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
264 alarmLayout->addWidget(mAlarmSoundButton); 265 alarmLayout->addWidget(mAlarmSoundButton);
265 266
266 mAlarmProgramButton = new QPushButton(parent); 267 mAlarmProgramButton = new QPushButton(parent);
267 mAlarmProgramButton->setPixmap(SmallIcon("run")); 268 mAlarmProgramButton->setPixmap(SmallIcon("run"));
268 mAlarmProgramButton->setToggleButton(true); 269 mAlarmProgramButton->setToggleButton(true);
269 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 270 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
270 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 271 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
271 alarmLayout->addWidget(mAlarmProgramButton); 272 alarmLayout->addWidget(mAlarmProgramButton);
272 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 273 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
273 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 274 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
274 // if ( KOPrefs::instance()->mCompactDialogs ) { 275 // if ( KOPrefs::instance()->mCompactDialogs ) {
275 // mAlarmSoundButton->hide(); 276 // mAlarmSoundButton->hide();
276 // mAlarmProgramButton->hide(); 277 // mAlarmProgramButton->hide();
277 // } 278 // }
278} 279}
279 280
280void KOEditorGeneral::pickAlarmSound() 281void KOEditorGeneral::pickAlarmSound()
281{ 282{
282 283
283 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); 284 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
284 285
285 bool oldState = mAlarmSoundButton->isOn(); 286 bool oldState = mAlarmSoundButton->isOn();
286 287
287 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 288 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
288 i18n("*.wav|Wav Files"), 0)); 289 i18n("*.wav|Wav Files"), 0));
289 if (!fileName.isEmpty()) { 290 if (!fileName.isEmpty()) {
290 mAlarmSound = fileName; 291 mAlarmSound = fileName;
291 QToolTip::remove(mAlarmSoundButton); 292 QToolTip::remove(mAlarmSoundButton);
292 QString dispStr = i18n("Playing '%1'").arg(fileName); 293 QString dispStr = i18n("Playing '%1'").arg(fileName);
293 QToolTip::add(mAlarmSoundButton, dispStr); 294 QToolTip::add(mAlarmSoundButton, dispStr);
294 mAlarmProgramButton->setOn(false); 295 mAlarmProgramButton->setOn(false);
295 mAlarmSoundButton->setOn(true); 296 mAlarmSoundButton->setOn(true);
296 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 297 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
297 } else { 298 } else {
298 mAlarmProgramButton->setOn(oldState); 299 mAlarmProgramButton->setOn(oldState);
299 mAlarmSoundButton->setOn(!oldState); 300 mAlarmSoundButton->setOn(!oldState);
300 301
301 302
302 } 303 }
303 304
304 if (mAlarmProgramButton->isOn()) 305 if (mAlarmProgramButton->isOn())
305 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 306 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
306 if ( mAlarmSoundButton->isOn()) 307 if ( mAlarmSoundButton->isOn())
307 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 308 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
308 309
309} 310}
310 311
311void KOEditorGeneral::pickAlarmProgram() 312void KOEditorGeneral::pickAlarmProgram()
312{ 313{
313 bool oldState = mAlarmProgramButton->isOn(); 314 bool oldState = mAlarmProgramButton->isOn();
314 315
315 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 316 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
316 if (!fileName.isEmpty()) { 317 if (!fileName.isEmpty()) {
317 mAlarmProgram = fileName; 318 mAlarmProgram = fileName;
318 QToolTip::remove(mAlarmProgramButton); 319 QToolTip::remove(mAlarmProgramButton);
319 QString dispStr = i18n("Running '%1'").arg(fileName); 320 QString dispStr = i18n("Running '%1'").arg(fileName);
320 QToolTip::add(mAlarmProgramButton, dispStr); 321 QToolTip::add(mAlarmProgramButton, dispStr);
321 mAlarmSoundButton->setOn(false); 322 mAlarmSoundButton->setOn(false);
322 mAlarmProgramButton->setOn(true); 323 mAlarmProgramButton->setOn(true);
323 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 324 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
324 } else { 325 } else {
325 mAlarmProgramButton->setOn(!oldState); 326 mAlarmProgramButton->setOn(!oldState);
326 mAlarmSoundButton->setOn(oldState); 327 mAlarmSoundButton->setOn(oldState);
327 } 328 }
328 329
329 if (mAlarmProgramButton->isOn()) 330 if (mAlarmProgramButton->isOn())
330 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 331 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
331 if ( mAlarmSoundButton->isOn()) 332 if ( mAlarmSoundButton->isOn())
332 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 333 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
333 334
334} 335}
335 336
336 337
337QString KOEditorGeneral::getFittingPath( const QString s ) 338QString KOEditorGeneral::getFittingPath( const QString s )
338{ 339{
339 int maxlen = 50; 340 int maxlen = 50;
340 if ( QApplication::desktop()->width() < 640 ) { 341 if ( QApplication::desktop()->width() < 640 ) {
341 if ( QApplication::desktop()->width() < 320 ) 342 if ( QApplication::desktop()->width() < 320 )
342 maxlen = 22; 343 maxlen = 22;
343 else 344 else
344 maxlen = 35; 345 maxlen = 35;
345 } 346 }
346 if ( s.length() > maxlen ) { 347 if ( s.length() > maxlen ) {
347 return "..."+s.right(maxlen -3); 348 return "..."+s.right(maxlen -3);
348 } 349 }
349 return s; 350 return s;
350} 351}
351 352
352void KOEditorGeneral::enableAlarmEdit(bool enable) 353void KOEditorGeneral::enableAlarmEdit(bool enable)
353{ 354{
354 if ( enable ) { 355 if ( enable ) {
355 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 356 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
356 mAlarmSoundButton->setOn( true ); 357 mAlarmSoundButton->setOn( true );
357 if ( mAlarmSound.isEmpty() ) 358 if ( mAlarmSound.isEmpty() )
358 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 359 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
359 else { 360 else {
360 if ( ! QFile::exists( mAlarmSound ) ) 361 if ( ! QFile::exists( mAlarmSound ) )
361 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 362 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
362 } 363 }
363 } 364 }
364 } 365 }
365 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 366 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
366 mAlarmTimeEdit->setEnabled(enable); 367 mAlarmTimeEdit->setEnabled(enable);
367 mAlarmSoundButton->setEnabled(enable); 368 mAlarmSoundButton->setEnabled(enable);
368 mAlarmProgramButton->setEnabled(enable); 369 mAlarmProgramButton->setEnabled(enable);
369 mAlarmIncrCombo->setEnabled(enable); 370 mAlarmIncrCombo->setEnabled(enable);
370} 371}
371 372
372void KOEditorGeneral::disableAlarmEdit(bool disable) 373void KOEditorGeneral::disableAlarmEdit(bool disable)
373{ 374{
374 enableAlarmEdit( !disable ); 375 enableAlarmEdit( !disable );
375} 376}
376 377
377void KOEditorGeneral::enableAlarm( bool enable ) 378void KOEditorGeneral::enableAlarm( bool enable )
378{ 379{
379 enableAlarmEdit( enable ); 380 enableAlarmEdit( enable );
380} 381}
381 382
382void KOEditorGeneral::alarmDisable(bool disable) 383void KOEditorGeneral::alarmDisable(bool disable)
383{ 384{
384 if (!disable) { 385 if (!disable) {
385 //mAlarmBell->setEnabled(true); 386 //mAlarmBell->setEnabled(true);
386 mAlarmButton->setEnabled(true); 387 mAlarmButton->setEnabled(true);
387 } else { 388 } else {
388 //mAlarmBell->setEnabled(false); 389 //mAlarmBell->setEnabled(false);
389 mAlarmButton->setEnabled(false); 390 mAlarmButton->setEnabled(false);
390 mAlarmButton->setChecked(false); 391 mAlarmButton->setChecked(false);
391 mAlarmTimeEdit->setEnabled(false); 392 mAlarmTimeEdit->setEnabled(false);
392 mAlarmSoundButton->setEnabled(false); 393 mAlarmSoundButton->setEnabled(false);
393 mAlarmProgramButton->setEnabled(false); 394 mAlarmProgramButton->setEnabled(false);
394 mAlarmIncrCombo->setEnabled(false); 395 mAlarmIncrCombo->setEnabled(false);
395 } 396 }
396} 397}
397 398
398void KOEditorGeneral::setCategories(const QString &str) 399void KOEditorGeneral::setCategories(const QString &str)
399{ 400{
400 QString tt = str; 401 QString tt = str;
401 QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); 402 QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>");
402 mCategoriesLabel->setText(str); 403 mCategoriesLabel->setText(str);
403} 404}
404 405
405void KOEditorGeneral::setDefaults(bool allDay) 406void KOEditorGeneral::setDefaults(bool allDay)
406{ 407{
407#if 0 408#if 0
408 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 409 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
409#endif 410#endif
410 411
411 mAlarmMessage = i18n("Edit new item"); 412 mAlarmMessage = i18n("Edit new item");
412 enableAlarmEdit( !allDay ); 413 enableAlarmEdit( !allDay );
413 414
414 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 415 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
415 int alarmTime; 416 int alarmTime;
416 int a[] = { 1,5,10,15,30,60,180, 1440 }; 417 int a[] = { 1,5,10,15,30,60,180, 1440 };
417 int index = KOPrefs::instance()->mAlarmTime; 418 int index = KOPrefs::instance()->mAlarmTime;