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