summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-06-30 11:05:14 (UTC)
committer zautrix <zautrix>2005-06-30 11:05:14 (UTC)
commitb03b54ce54c1391db8979db0df1369e1c68656fa (patch) (unidiff)
treeadf1bb74f5f56cb54a18a2bbfa3bc327e2e32217 /korganizer
parent00e631189f1dca0d596b6ce5816f2fcde9124bd7 (diff)
downloadkdepimpi-b03b54ce54c1391db8979db0df1369e1c68656fa.zip
kdepimpi-b03b54ce54c1391db8979db0df1369e1c68656fa.tar.gz
kdepimpi-b03b54ce54c1391db8979db0df1369e1c68656fa.tar.bz2
fixxx
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditorgeneral.cpp51
-rw-r--r--korganizer/koeditorgeneral.h7
-rw-r--r--korganizer/koprefs.cpp16
-rw-r--r--korganizer/kotodoview.cpp33
4 files changed, 76 insertions, 31 deletions
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 915c7ec..50a04ea 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -49,203 +49,242 @@
49#include "koprefs.h" 49#include "koprefs.h"
50#include "koglobals.h" 50#include "koglobals.h"
51 51
52#include "koeditorgeneral.h" 52#include "koeditorgeneral.h"
53#include "kolocationbox.h" 53#include "kolocationbox.h"
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
61 QObject( parent, name) 61 QObject( parent, name)
62{ 62{
63 mNextFocus = 0; 63 mNextFocus = 0;
64} 64}
65 65
66KOEditorGeneral::~KOEditorGeneral() 66KOEditorGeneral::~KOEditorGeneral()
67{ 67{
68} 68}
69 69
70void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 70void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
71{ 71{
72 QGridLayout *headerLayout = new QGridLayout(topLayout); 72 QGridLayout *headerLayout = new QGridLayout(topLayout);
73 73
74#if 0 74#if 0
75 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 75 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
76 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 76 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
77#endif 77#endif
78 78
79 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 79 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
80 headerLayout->addWidget(summaryLabel,1,0); 80 headerLayout->addWidget(summaryLabel,1,0);
81 81
82 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 82 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
83 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 83 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
84 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 84 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
85 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 85 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
86 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 86 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
87 if ( QApplication::desktop()->width() > 320 ) 87 if ( QApplication::desktop()->width() > 320 )
88 mSummaryEdit->setMaximumHeight( hei +6 ); 88 mSummaryEdit->setMaximumHeight( hei +6 );
89 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 89 //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 } 90 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
91 // mSummaryEdit = new QLineEdit(parent); 91 // mSummaryEdit = new QLineEdit(parent);
92 headerLayout->addWidget(mSummaryEdit,1,1); 92 headerLayout->addWidget(mSummaryEdit,1,1);
93 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 93 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
94 94
95 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 95 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
96 if ( QApplication::desktop()->height() < 320 ) 96 if ( QApplication::desktop()->height() < 320 )
97 headerLayout->addWidget(locationLabel,1,2); 97 headerLayout->addWidget(locationLabel,1,2);
98 else 98 else
99 headerLayout->addWidget(locationLabel,2,0); 99 headerLayout->addWidget(locationLabel,2,0);
100 100
101 mLocationEdit = new KOLocationBox(TRUE,parent,10); 101 mLocationEdit = new KOLocationBox(TRUE,parent,10);
102 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 102 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
103 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) 103 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 )
104 mLocationEdit->setMaximumHeight( hei + 6); 104 mLocationEdit->setMaximumHeight( hei + 6);
105 105
106 // mLocationEdit = new QLineEdit(parent); 106 // mLocationEdit = new QLineEdit(parent);
107 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 107 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
108 if ( QApplication::desktop()->height() < 320 ) { 108 if ( QApplication::desktop()->height() < 320 ) {
109 headerLayout->addWidget(mLocationEdit,1,3); 109 headerLayout->addWidget(mLocationEdit,1,3);
110 headerLayout->setColStretch( 1, 10); 110 headerLayout->setColStretch( 1, 10);
111 headerLayout->setColStretch( 3, 10); 111 headerLayout->setColStretch( 3, 10);
112 } 112 }
113 else { 113 else {
114 headerLayout->addWidget(mLocationEdit,2,1); 114 headerLayout->addWidget(mLocationEdit,2,1);
115 headerLayout->setColStretch( 1, 10); 115 headerLayout->setColStretch( 1, 10);
116 } 116 }
117} 117}
118void KOEditorGeneral::setFocusOn( int i ) 118void KOEditorGeneral::setFocusOn( int i )
119{ 119{
120 mNextFocus = i; 120 mNextFocus = i;
121 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); 121 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
122} 122}
123void KOEditorGeneral::slotSetFocusOn() 123void KOEditorGeneral::slotSetFocusOn()
124{ 124{
125 mNextFocus; 125 mNextFocus;
126 if ( mNextFocus == 1 ) { 126 if ( mNextFocus == 1 ) {
127 mDescriptionEdit->setFocus(); 127 mDescriptionEdit->setFocus();
128 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 128 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
129 } 129 }
130 if ( mNextFocus == 2 ) { 130 if ( mNextFocus == 2 ) {
131 mSummaryEdit->setFocus(); 131 mSummaryEdit->setFocus();
132 } 132 }
133} 133}
134void KOEditorGeneral::editCategories() 134void KOEditorGeneral::editCategories()
135{ 135{
136 // qDebug("KOEditorGeneral::editCategories() "); 136 // qDebug("KOEditorGeneral::editCategories() ");
137 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 137 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
138 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 138 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
139 //KOGlobals::fitDialogToScreen( csd ); 139 //KOGlobals::fitDialogToScreen( csd );
140 csd->setColorEnabled(); 140 csd->setColorEnabled();
141 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 141 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
142 csd->exec(); 142 csd->exec();
143 delete csd; 143 delete csd;
144} 144}
145
146void KOEditorGeneral::showCatPopup()
147{
148 mCatPopup->clear();
149 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text());
150 int index = 0;
151 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
152 it != KOPrefs::instance()->mCustomCategories.end ();
153 ++it) {
154 mCatPopup->insertItem (*it, index );
155 //mCategory[index] = *it;
156 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
157 ++index;
158 }
159}
160void KOEditorGeneral::selectedCatPopup( int index )
161{
162 qDebug("i %d c %d ", index, KOPrefs::instance()->mCustomCategories.count());
163 QStringList categories = QStringList::split (",", mCategoriesLabel->text());
164 QString colcat = categories.first();
165 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
166 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
167 else
168 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
169 categories.sort ();
170 if ( !colcat.isEmpty() ) {
171 if ( categories.find ( colcat ) != categories.end () ) {
172 categories.remove( colcat );
173 categories.prepend( colcat );
174 }
175 }
176 mCategoriesLabel->setText( categories.join(",") );
177}
178
145void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 179void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
146{ 180{
147 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 181 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
148 182 mCatPopup = new QPopupMenu ( parent );
183 mCatPopup->setCheckable (true);
184 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
185 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
149 mCategoriesButton = new QPushButton(parent); 186 mCategoriesButton = new QPushButton(parent);
150 mCategoriesButton->setText(i18n("Categories...")); 187 mCategoriesButton->setText(i18n("Categories"));
151 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 188 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
152 categoriesLayout->addWidget(mCategoriesButton); 189 categoriesLayout->addWidget(mCategoriesButton);
153 190 mCategoriesButton->setPopup( mCatPopup );
154 mCategoriesLabel = new QLabel(parent); 191 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent);
155 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 192 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
193 connect(mCategoriesLabel,SIGNAL(clicked()),this, SLOT(editCategories() ));
194 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
156 categoriesLayout->addWidget(mCategoriesLabel,1); 195 categoriesLayout->addWidget(mCategoriesLabel,1);
157} 196}
158 197
159void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 198void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
160{ 199{
161 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 200 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
162 201
163 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 202 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
164 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 203 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
165 secrecyLayout->addWidget(mCancelBox); 204 secrecyLayout->addWidget(mCancelBox);
166 secrecyLayout->addWidget(secrecyLabel); 205 secrecyLayout->addWidget(secrecyLabel);
167 206
168 mSecrecyCombo = new QComboBox(parent); 207 mSecrecyCombo = new QComboBox(parent);
169 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 208 mSecrecyCombo->insertStringList(Incidence::secrecyList());
170 secrecyLayout->addWidget(mSecrecyCombo); 209 secrecyLayout->addWidget(mSecrecyCombo);
171} 210}
172 211
173void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 212void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
174{ 213{
175 mDescriptionEdit = new KTextEdit(parent); 214 mDescriptionEdit = new KTextEdit(parent);
176 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 215 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
177 mDescriptionEdit->append(""); 216 mDescriptionEdit->append("");
178 mDescriptionEdit->setReadOnly(false); 217 mDescriptionEdit->setReadOnly(false);
179 mDescriptionEdit->setOverwriteMode(false); 218 mDescriptionEdit->setOverwriteMode(false);
180 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 219 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
181 topLayout->addWidget(mDescriptionEdit); 220 topLayout->addWidget(mDescriptionEdit);
182#ifndef DESKTOP_VERSION 221#ifndef DESKTOP_VERSION
183 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 222 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
184#endif 223#endif
185 224
186} 225}
187 226
188void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 227void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
189{ 228{
190 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 229 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
191 230
192 //mAlarmBell = new QLabel(parent); 231 //mAlarmBell = new QLabel(parent);
193 //mAlarmBell->setPixmap(SmallIcon("bell")); 232 //mAlarmBell->setPixmap(SmallIcon("bell"));
194 //alarmLayout->addWidget(mAlarmBell); 233 //alarmLayout->addWidget(mAlarmBell);
195 if ( QApplication::desktop()->width() < 320 ) 234 if ( QApplication::desktop()->width() < 320 )
196 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 235 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
197 else 236 else
198 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 237 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
199 238
200 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 239 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
201 alarmLayout->addWidget(mAlarmButton); 240 alarmLayout->addWidget(mAlarmButton);
202 241
203 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 242 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
204 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 243 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
205 alarmLayout->addWidget(mAlarmTimeEdit); 244 alarmLayout->addWidget(mAlarmTimeEdit);
206 mAlarmIncrCombo = new QComboBox(false, parent); 245 mAlarmIncrCombo = new QComboBox(false, parent);
207 if ( QApplication::desktop()->width() < 320 ) { 246 if ( QApplication::desktop()->width() < 320 ) {
208 mAlarmIncrCombo->insertItem(i18n("min")); 247 mAlarmIncrCombo->insertItem(i18n("min"));
209 mAlarmIncrCombo->insertItem(i18n("hou")); 248 mAlarmIncrCombo->insertItem(i18n("hou"));
210 mAlarmIncrCombo->insertItem(i18n("day")); 249 mAlarmIncrCombo->insertItem(i18n("day"));
211 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 250 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
212 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 251 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
213 } else { 252 } else {
214 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 253 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
215 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 254 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
216 mAlarmIncrCombo->insertItem(i18n("day(s)")); 255 mAlarmIncrCombo->insertItem(i18n("day(s)"));
217 } 256 }
218 257
219 // mAlarmIncrCombo->setMinimumHeight(20); 258 // mAlarmIncrCombo->setMinimumHeight(20);
220 alarmLayout->addWidget(mAlarmIncrCombo); 259 alarmLayout->addWidget(mAlarmIncrCombo);
221 mAlarmSoundButton = new QPushButton(parent); 260 mAlarmSoundButton = new QPushButton(parent);
222 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 261 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
223 mAlarmSoundButton->setToggleButton(true); 262 mAlarmSoundButton->setToggleButton(true);
224 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 263 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
225 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 264 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
226 alarmLayout->addWidget(mAlarmSoundButton); 265 alarmLayout->addWidget(mAlarmSoundButton);
227 266
228 mAlarmProgramButton = new QPushButton(parent); 267 mAlarmProgramButton = new QPushButton(parent);
229 mAlarmProgramButton->setPixmap(SmallIcon("run")); 268 mAlarmProgramButton->setPixmap(SmallIcon("run"));
230 mAlarmProgramButton->setToggleButton(true); 269 mAlarmProgramButton->setToggleButton(true);
231 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 270 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
232 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 271 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
233 alarmLayout->addWidget(mAlarmProgramButton); 272 alarmLayout->addWidget(mAlarmProgramButton);
234 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 273 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
235 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 274 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
236 // if ( KOPrefs::instance()->mCompactDialogs ) { 275 // if ( KOPrefs::instance()->mCompactDialogs ) {
237 // mAlarmSoundButton->hide(); 276 // mAlarmSoundButton->hide();
238 // mAlarmProgramButton->hide(); 277 // mAlarmProgramButton->hide();
239 // } 278 // }
240} 279}
241 280
242void KOEditorGeneral::pickAlarmSound() 281void KOEditorGeneral::pickAlarmSound()
243{ 282{
244 283
245 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); 284 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
246 285
247 bool oldState = mAlarmSoundButton->isOn(); 286 bool oldState = mAlarmSoundButton->isOn();
248 287
249 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 288 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
250 i18n("*.wav|Wav Files"), 0)); 289 i18n("*.wav|Wav Files"), 0));
251 if (!fileName.isEmpty()) { 290 if (!fileName.isEmpty()) {
diff --git a/korganizer/koeditorgeneral.h b/korganizer/koeditorgeneral.h
index a8f6443..c463403 100644
--- a/korganizer/koeditorgeneral.h
+++ b/korganizer/koeditorgeneral.h
@@ -1,116 +1,121 @@
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#ifndef KOEDITORGENERAL_H 23#ifndef KOEDITORGENERAL_H
24#define KOEDITORGENERAL_H 24#define KOEDITORGENERAL_H
25 25
26#include <qframe.h> 26#include <qframe.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qpopupmenu.h>
30#include <qgroupbox.h> 31#include <qgroupbox.h>
31#include <qlineedit.h> 32#include <qlineedit.h>
32#include <qcombobox.h> 33#include <qcombobox.h>
33#include <qlistview.h> 34#include <qlistview.h>
34#include <qradiobutton.h> 35#include <qradiobutton.h>
35#include <qlayout.h> 36#include <qlayout.h>
36#include <qspinbox.h> 37#include <qspinbox.h>
37 38
38#include <ktextedit.h> 39#include <ktextedit.h>
39#include <krestrictedline.h> 40#include <krestrictedline.h>
40 41
41#include <libkcal/incidence.h> 42#include <libkcal/incidence.h>
42 43
43#include "ktimeedit.h" 44#include "ktimeedit.h"
44 45
45class KDateEdit; 46class KDateEdit;
46class KOLocationBox; 47class KOLocationBox;
47using namespace KCal; 48using namespace KCal;
48 49
49class KOEditorGeneral : public QObject 50class KOEditorGeneral : public QObject
50{ 51{
51 Q_OBJECT 52 Q_OBJECT
52 public: 53 public:
53 KOEditorGeneral (QObject* parent=0,const char* name=0); 54 KOEditorGeneral (QObject* parent=0,const char* name=0);
54 virtual ~KOEditorGeneral(); 55 virtual ~KOEditorGeneral();
55 void setFocusOn( int i ); 56 void setFocusOn( int i );
56 void initHeader(QWidget *,QBoxLayout *); 57 void initHeader(QWidget *,QBoxLayout *);
57 void initDescription(QWidget *,QBoxLayout *); 58 void initDescription(QWidget *,QBoxLayout *);
58 void initSecrecy(QWidget *,QBoxLayout *); 59 void initSecrecy(QWidget *,QBoxLayout *);
59 void initCategories(QWidget *,QBoxLayout *); 60 void initCategories(QWidget *,QBoxLayout *);
60 void initAlarm(QWidget *,QBoxLayout *); 61 void initAlarm(QWidget *,QBoxLayout *);
61 62
62 /** Set widgets to default values */ 63 /** Set widgets to default values */
63 void setDefaults(bool allDay); 64 void setDefaults(bool allDay);
64 /** Read event object and setup widgets accordingly */ 65 /** Read event object and setup widgets accordingly */
65 void readIncidence(Incidence *); 66 void readIncidence(Incidence *);
66 /** Write event settings to event object */ 67 /** Write event settings to event object */
67 void writeIncidence(Incidence *); 68 void writeIncidence(Incidence *);
68 69
69 /** Check if the input is valid. */ 70 /** Check if the input is valid. */
70 bool validateInput() { return true; } 71 bool validateInput() { return true; }
71 72
72 void enableAlarm( bool enable ); 73 void enableAlarm( bool enable );
73 void setSecrecy( int num ); 74 void setSecrecy( int num );
74 public slots: 75 public slots:
75 void setCategories(const QString &); 76 void setCategories(const QString &);
76 void editCategories(); 77 void editCategories();
77 78
78 protected slots: 79 protected slots:
79 void enableAlarmEdit( bool enable ); 80 void enableAlarmEdit( bool enable );
80 void disableAlarmEdit( bool disable ); 81 void disableAlarmEdit( bool disable );
81 void alarmDisable( bool disable ); 82 void alarmDisable( bool disable );
82 void pickAlarmSound(); 83 void pickAlarmSound();
83 void pickAlarmProgram(); 84 void pickAlarmProgram();
84 void slotSetFocusOn(); 85 void slotSetFocusOn();
86 void showCatPopup();
87 void selectedCatPopup( int );
88
85 signals: 89 signals:
86 void openCategoryDialog(); 90 void openCategoryDialog();
87 void allAccepted(); 91 void allAccepted();
88 void dateTimesChanged(QDateTime,QDateTime); 92 void dateTimesChanged(QDateTime,QDateTime);
89 93
90 protected: 94 protected:
91 int mNextFocus; 95 int mNextFocus;
92 //QLineEdit *mSummaryEdit; 96 //QLineEdit *mSummaryEdit;
93 //QLineEdit *mLocationEdit; 97 //QLineEdit *mLocationEdit;
94 KOLocationBox *mSummaryEdit; 98 KOLocationBox *mSummaryEdit;
95 KOLocationBox *mLocationEdit; 99 KOLocationBox *mLocationEdit;
96 QLabel *mAlarmBell; 100 QLabel *mAlarmBell;
97 QCheckBox *mAlarmButton; 101 QCheckBox *mAlarmButton;
98 QSpinBox *mAlarmTimeEdit; 102 QSpinBox *mAlarmTimeEdit;
99 QPushButton *mAlarmSoundButton; 103 QPushButton *mAlarmSoundButton;
100 QPushButton *mAlarmProgramButton; 104 QPushButton *mAlarmProgramButton;
101 QComboBox *mAlarmIncrCombo; 105 QComboBox *mAlarmIncrCombo;
102 KTextEdit *mDescriptionEdit; 106 KTextEdit *mDescriptionEdit;
103 QLabel *mOwnerLabel; 107 QLabel *mOwnerLabel;
104 QComboBox *mSecrecyCombo; 108 QComboBox *mSecrecyCombo;
105 QCheckBox *mCancelBox; 109 QCheckBox *mCancelBox;
106 QPushButton *mCategoriesButton; 110 QPushButton *mCategoriesButton;
107 QLabel *mCategoriesLabel; 111 QPushButton *mCategoriesLabel;
108 112
109 private: 113 private:
114 QPopupMenu * mCatPopup;
110 QString getFittingPath( const QString ) ; 115 QString getFittingPath( const QString ) ;
111 QString mAlarmSound; 116 QString mAlarmSound;
112 QString mAlarmProgram; 117 QString mAlarmProgram;
113 QString mAlarmMessage; 118 QString mAlarmMessage;
114}; 119};
115 120
116#endif 121#endif
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 7ba7269..9db2040 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -298,205 +298,205 @@ KOPrefs::KOPrefs() :
298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
300 addItemStringList("AdditionalMails",&mAdditionalMails,""); 300 addItemStringList("AdditionalMails",&mAdditionalMails,"");
301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
306 306
307 KPrefs::setCurrentGroup( "Editors" ); 307 KPrefs::setCurrentGroup( "Editors" );
308 308
309 addItemStringList( "EventTemplates", &mEventTemplates ); 309 addItemStringList( "EventTemplates", &mEventTemplates );
310 addItemStringList( "TodoTemplates", &mTodoTemplates ); 310 addItemStringList( "TodoTemplates", &mTodoTemplates );
311 311
312 addItemInt("DestinationPolicy",&mDestination,standardDestination); 312 addItemInt("DestinationPolicy",&mDestination,standardDestination);
313 313
314 KPrefs::setCurrentGroup( "ViewOptions" ); 314 KPrefs::setCurrentGroup( "ViewOptions" );
315 addItemBool("EVshowDetails",&mEVshowDetails,true); 315 addItemBool("EVshowDetails",&mEVshowDetails,true);
316 addItemBool("EVshowCreated",&mEVshowCreated,true); 316 addItemBool("EVshowCreated",&mEVshowCreated,true);
317 addItemBool("EVshowChanged",&mEVshowChanged,true); 317 addItemBool("EVshowChanged",&mEVshowChanged,true);
318 addItemBool("WTshowDetails",&mWTshowDetails,false); 318 addItemBool("WTshowDetails",&mWTshowDetails,false);
319 addItemBool("WTshowCreated",&mWTshowCreated,false); 319 addItemBool("WTshowCreated",&mWTshowCreated,false);
320 addItemBool("WTshowChanged",&mWTshowChanged,false); 320 addItemBool("WTshowChanged",&mWTshowChanged,false);
321 mCalendars.setAutoDelete( true ); 321 mCalendars.setAutoDelete( true );
322} 322}
323 323
324 324
325KOPrefs::~KOPrefs() 325KOPrefs::~KOPrefs()
326{ 326{
327 if (mInstance == this) 327 if (mInstance == this)
328 mInstance = insd.setObject(0); 328 mInstance = insd.setObject(0);
329 mCalendars.setAutoDelete( true ); 329 mCalendars.setAutoDelete( true );
330 mCalendars.clear(); 330 mCalendars.clear();
331 //qDebug("KOPrefs::~KOPrefs() "); 331 //qDebug("KOPrefs::~KOPrefs() ");
332} 332}
333 333
334 334
335KOPrefs *KOPrefs::instance() 335KOPrefs *KOPrefs::instance()
336{ 336{
337 if (!mInstance) { 337 if (!mInstance) {
338 mInstance = insd.setObject(new KOPrefs()); 338 mInstance = insd.setObject(new KOPrefs());
339 mInstance->readConfig(); 339 mInstance->readConfig();
340 } 340 }
341 341
342 return mInstance; 342 return mInstance;
343} 343}
344 344
345void KOPrefs::usrSetDefaults() 345void KOPrefs::usrSetDefaults()
346{ 346{
347 347
348} 348}
349 349
350void KOPrefs::fillMailDefaults() 350void KOPrefs::fillMailDefaults()
351{ 351{
352 if (mName.isEmpty()) mName = i18n("Anonymous"); 352 if (mName.isEmpty()) mName = i18n("Anonymous");
353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
354} 354}
355 355
356void KOPrefs::setTimeZoneIdDefault() 356void KOPrefs::setTimeZoneIdDefault()
357{ 357{
358 ; 358 ;
359} 359}
360 360
361void KOPrefs::setAllDefaults() 361void KOPrefs::setAllDefaults()
362{ 362{
363 setCategoryDefaults(); 363 setCategoryDefaults();
364 mEventSummaryUser = getDefaultList() ; 364 mEventSummaryUser = getDefaultList() ;
365 mTodoSummaryUser = getDefaultList() ; 365 mTodoSummaryUser = getDefaultList() ;
366 mLocationDefaults = getLocationDefaultList(); 366 mLocationDefaults = getLocationDefaultList();
367} 367}
368 368
369void KOPrefs::setCategoryDefaults() 369void KOPrefs::setCategoryDefaults()
370{ 370{
371 mCustomCategories.clear(); 371 mCustomCategories.clear();
372 mCustomCategories = getDefaultList(); 372 mCustomCategories = getDefaultList();
373 373
374 QStringList::Iterator it; 374 QStringList::Iterator it;
375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
376 setCategoryColor(*it,mDefaultCategoryColor); 376 setCategoryColor(*it,mDefaultCategoryColor);
377 } 377 }
378} 378}
379QStringList KOPrefs::getLocationDefaultList() 379QStringList KOPrefs::getLocationDefaultList()
380{ 380{
381 QStringList retval ; 381 QStringList retval ;
382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
387 387
388 retval.sort(); 388 retval.sort();
389 return retval; 389 return retval;
390} 390}
391QStringList KOPrefs::getDefaultList() 391QStringList KOPrefs::getDefaultList()
392{ 392{
393 QStringList retval ; 393 QStringList retval ;
394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Cinema") << i18n("Customer")
395 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 395 << i18n("Break")
396 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 396 << i18n("Family") << i18n("Favorites") << i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Key Customer")
398 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 398 << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal")
399 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 399 << i18n("PHB") << i18n("Phone Calls") << i18n("School") << i18n("Shopping")
400 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 400 << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
402 retval.sort(); 402 retval.sort();
403 //qDebug("cat %s ", retval.join("-").latin1()); 403 //qDebug("cat %s ", retval.join("-").latin1());
404 return retval; 404 return retval;
405} 405}
406 406// << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")
407void KOPrefs::usrReadConfig() 407void KOPrefs::usrReadConfig()
408{ 408{
409 config()->setGroup("General"); 409 config()->setGroup("General");
410 410
411 //qDebug("KOPrefs::usrReadConfig() "); 411 //qDebug("KOPrefs::usrReadConfig() ");
412 mCustomCategories = config()->readListEntry("Custom Categories"); 412 mCustomCategories = config()->readListEntry("Custom Categories");
413 mOldLoadedLanguage = mOldLanguage ; 413 mOldLoadedLanguage = mOldLanguage ;
414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
415 if (mLocationDefaults.isEmpty()) { 415 if (mLocationDefaults.isEmpty()) {
416 mLocationDefaults = getLocationDefaultList(); 416 mLocationDefaults = getLocationDefaultList();
417 } 417 }
418 418
419 if (mEventSummaryUser.isEmpty()) { 419 if (mEventSummaryUser.isEmpty()) {
420 mEventSummaryUser = getDefaultList() ; 420 mEventSummaryUser = getDefaultList() ;
421 } 421 }
422 if (mTodoSummaryUser.isEmpty()) { 422 if (mTodoSummaryUser.isEmpty()) {
423 mTodoSummaryUser = getDefaultList() ; 423 mTodoSummaryUser = getDefaultList() ;
424 } 424 }
425 425
426 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 426 if (mCustomCategories.isEmpty()) setCategoryDefaults();
427 427
428 config()->setGroup("Personal Settings"); 428 config()->setGroup("Personal Settings");
429 mName = config()->readEntry("user_name",""); 429 mName = config()->readEntry("user_name","");
430 mEmail = config()->readEntry("user_email",""); 430 mEmail = config()->readEntry("user_email","");
431 fillMailDefaults(); 431 fillMailDefaults();
432 432
433 config()->setGroup("Category Colors"); 433 config()->setGroup("Category Colors");
434 QStringList::Iterator it; 434 QStringList::Iterator it;
435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
437 437
438 } 438 }
439 KConfig fc (locateLocal("config","kopicalendarrc")); 439 KConfig fc (locateLocal("config","kopicalendarrc"));
440 fc.setGroup("CC"); 440 fc.setGroup("CC");
441 int numCals = fc.readNumEntry("NumberCalendars",0 ); 441 int numCals = fc.readNumEntry("NumberCalendars",0 );
442 mNextAvailableCalendar = 1; 442 mNextAvailableCalendar = 1;
443 if ( numCals == 0 ) { 443 if ( numCals == 0 ) {
444 KopiCalendarFile *kkf = getNewCalendar(); 444 KopiCalendarFile *kkf = getNewCalendar();
445 kkf->isStandard = true; 445 kkf->isStandard = true;
446 kkf->mName = i18n("Standard"); 446 kkf->mName = i18n("Standard");
447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
448 } 448 }
449 while ( mNextAvailableCalendar <= numCals ) { 449 while ( mNextAvailableCalendar <= numCals ) {
450 //qDebug("Read cal #%d ", mNextAvailableCalendar ); 450 //qDebug("Read cal #%d ", mNextAvailableCalendar );
451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); 451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
452 KopiCalendarFile *kkf = getNewCalendar(); 452 KopiCalendarFile *kkf = getNewCalendar();
453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); 453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false );
454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); 454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true);
455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); 455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true);
456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); 456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false);
457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); 457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar");
458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); 458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName);
459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); 459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor);
460 if ( kkf->mCalNumber == 1 ) { 460 if ( kkf->mCalNumber == 1 ) {
461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
462 } 462 }
463 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); 463 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() );
464 if ( kkf->mName == i18n("Birthdays") ) { 464 if ( kkf->mName == i18n("Birthdays") ) {
465 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); 465 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" );
466 } 466 }
467 } 467 }
468 468
469 KPimPrefs::usrReadConfig(); 469 KPimPrefs::usrReadConfig();
470} 470}
471 471
472KopiCalendarFile * KOPrefs::getCalendar( int num ) 472KopiCalendarFile * KOPrefs::getCalendar( int num )
473{ 473{
474 return mDefCalColors[num-1]; 474 return mDefCalColors[num-1];
475} 475}
476 476
477KopiCalendarFile * KOPrefs::getNewCalendar() 477KopiCalendarFile * KOPrefs::getNewCalendar()
478{ 478{
479 KopiCalendarFile * kkf = new KopiCalendarFile(); 479 KopiCalendarFile * kkf = new KopiCalendarFile();
480 kkf->mCalNumber = mNextAvailableCalendar; 480 kkf->mCalNumber = mNextAvailableCalendar;
481 mDefCalColors.resize( mNextAvailableCalendar ); 481 mDefCalColors.resize( mNextAvailableCalendar );
482 mDefCalColors[mNextAvailableCalendar-1] = kkf; 482 mDefCalColors[mNextAvailableCalendar-1] = kkf;
483 ++mNextAvailableCalendar; 483 ++mNextAvailableCalendar;
484 kkf->mDefaultColor = mEventColor; 484 kkf->mDefaultColor = mEventColor;
485 kkf->mName = i18n("New Calendar"); 485 kkf->mName = i18n("New Calendar");
486 mCalendars.append( kkf ); 486 mCalendars.append( kkf );
487 return kkf; 487 return kkf;
488} 488}
489void KOPrefs::deleteCalendar( int num ) 489void KOPrefs::deleteCalendar( int num )
490{ 490{
491 KopiCalendarFile * kkf = mCalendars.first(); 491 KopiCalendarFile * kkf = mCalendars.first();
492 while ( kkf ) { 492 while ( kkf ) {
493 if ( kkf->mCalNumber == num ) { 493 if ( kkf->mCalNumber == num ) {
494 qDebug("KOPrefs::deleteCalendar %d ", num ); 494 qDebug("KOPrefs::deleteCalendar %d ", num );
495 mCalendars.remove( kkf ); 495 mCalendars.remove( kkf );
496 delete kkf; 496 delete kkf;
497 return; 497 return;
498 } 498 }
499 kkf = mCalendars.next(); 499 kkf = mCalendars.next();
500 } 500 }
501} 501}
502QString KOPrefs::calName( int calNum) const 502QString KOPrefs::calName( int calNum) const
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 1bfdef9..873a776 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -404,192 +404,193 @@ void KOTodoListView::keyPressEvent ( QKeyEvent * e )
404 qApp->processEvents(); 404 qApp->processEvents();
405 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 405 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
406 e->ignore(); 406 e->ignore();
407 // qDebug(" ignore %d",e->isAutoRepeat() ); 407 // qDebug(" ignore %d",e->isAutoRepeat() );
408 return; 408 return;
409 } 409 }
410 if (! e->isAutoRepeat() ) 410 if (! e->isAutoRepeat() )
411 mFlagKeyPressed = true; 411 mFlagKeyPressed = true;
412 QListViewItem* cn; 412 QListViewItem* cn;
413 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 413 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
414 cn = currentItem(); 414 cn = currentItem();
415 if ( cn ) { 415 if ( cn ) {
416 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 416 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
417 if ( ci ){ 417 if ( ci ){
418 if ( e->state() == ShiftButton ) 418 if ( e->state() == ShiftButton )
419 ci->setOn( false ); 419 ci->setOn( false );
420 else 420 else
421 ci->setOn( true ); 421 ci->setOn( true );
422 cn = cn->itemBelow(); 422 cn = cn->itemBelow();
423 if ( cn ) { 423 if ( cn ) {
424 setCurrentItem ( cn ); 424 setCurrentItem ( cn );
425 ensureItemVisible ( cn ); 425 ensureItemVisible ( cn );
426 } 426 }
427 427
428 } 428 }
429 } 429 }
430 430
431 return; 431 return;
432 } 432 }
433 433
434 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 434 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
435 switch ( e->key() ) { 435 switch ( e->key() ) {
436 case Qt::Key_Down: 436 case Qt::Key_Down:
437 case Qt::Key_Up: 437 case Qt::Key_Up:
438 QListView::keyPressEvent ( e ); 438 QListView::keyPressEvent ( e );
439 break; 439 break;
440 case Qt::Key_Left: 440 case Qt::Key_Left:
441 case Qt::Key_Right: 441 case Qt::Key_Right:
442 QListView::keyPressEvent ( e ); 442 QListView::keyPressEvent ( e );
443 e->accept(); 443 e->accept();
444 return; 444 return;
445 break; 445 break;
446 default: 446 default:
447 e->ignore(); 447 e->ignore();
448 break; 448 break;
449 } 449 }
450 return; 450 return;
451 } 451 }
452 e->ignore(); 452 e->ignore();
453} 453}
454void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 454void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
455{ 455{
456 QListView::contentsMouseReleaseEvent(e); 456 QListView::contentsMouseReleaseEvent(e);
457 mMousePressed = false; 457 mMousePressed = false;
458} 458}
459 459
460void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 460void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
461{ 461{
462 if (!e) return; 462 if (!e) return;
463 463
464 QPoint vp = contentsToViewport(e->pos()); 464 QPoint vp = contentsToViewport(e->pos());
465 465
466 QListViewItem *item = itemAt(vp); 466 QListViewItem *item = itemAt(vp);
467 467
468 emit double_Clicked(item); 468 emit double_Clicked(item);
469 if (!item) return; 469 if (!item) return;
470 470
471 emit doubleClicked(item,vp,0); 471 emit doubleClicked(item,vp,0);
472} 472}
473 473
474///////////////////////////////////////////////////////////////////////////// 474/////////////////////////////////////////////////////////////////////////////
475 475
476KOQuickTodo::KOQuickTodo(QWidget *parent) : 476KOQuickTodo::KOQuickTodo(QWidget *parent) :
477 QLineEdit(parent) 477 QLineEdit(parent)
478{ 478{
479 setText(i18n("Click to add a new Todo")); 479 setText(i18n("Click to add a new Todo"));
480} 480}
481 481
482void KOQuickTodo::focusInEvent(QFocusEvent *ev) 482void KOQuickTodo::focusInEvent(QFocusEvent *ev)
483{ 483{
484 if ( text()==i18n("Click to add a new Todo") ) 484 if ( text()==i18n("Click to add a new Todo") )
485 setText(""); 485 setText("");
486 QLineEdit::focusInEvent(ev); 486 QLineEdit::focusInEvent(ev);
487} 487}
488 488
489void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 489void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
490{ 490{
491 setText(i18n("Click to add a new Todo")); 491 setText(i18n("Click to add a new Todo"));
492 QLineEdit::focusOutEvent(ev); 492 QLineEdit::focusOutEvent(ev);
493} 493}
494 494
495///////////////////////////////////////////////////////////////////////////// 495/////////////////////////////////////////////////////////////////////////////
496 496
497KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 497KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
498 KOrg::BaseView(calendar,parent,name) 498 KOrg::BaseView(calendar,parent,name)
499{ 499{
500 mCategoryPopupMenu = 0;
500 mPendingUpdateBeforeRepaint = false; 501 mPendingUpdateBeforeRepaint = false;
501 isFlatDisplay = false; 502 isFlatDisplay = false;
502 mNavigator = 0; 503 mNavigator = 0;
503 QBoxLayout *topLayout = new QVBoxLayout(this); 504 QBoxLayout *topLayout = new QVBoxLayout(this);
504 mName = QString ( name ); 505 mName = QString ( name );
505 mBlockUpdate = false; 506 mBlockUpdate = false;
506 mQuickAdd = new KOQuickTodo(this); 507 mQuickAdd = new KOQuickTodo(this);
507 topLayout->addWidget(mQuickAdd); 508 topLayout->addWidget(mQuickAdd);
508 509
509 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 510 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
510 511
511 mTodoListView = new KOTodoListView(calendar,this, name ); 512 mTodoListView = new KOTodoListView(calendar,this, name );
512 topLayout->addWidget(mTodoListView); 513 topLayout->addWidget(mTodoListView);
513 //mTodoListView->header()->setMaximumHeight(30); 514 //mTodoListView->header()->setMaximumHeight(30);
514 mTodoListView->setRootIsDecorated(true); 515 mTodoListView->setRootIsDecorated(true);
515 mTodoListView->setAllColumnsShowFocus(true); 516 mTodoListView->setAllColumnsShowFocus(true);
516 517
517 mTodoListView->setShowSortIndicator(true); 518 mTodoListView->setShowSortIndicator(true);
518 519
519 mTodoListView->addColumn(i18n("Todo")); 520 mTodoListView->addColumn(i18n("Todo"));
520 mTodoListView->addColumn(i18n("Prio")); 521 mTodoListView->addColumn(i18n("Prio"));
521 mTodoListView->setColumnAlignment(1,AlignHCenter); 522 mTodoListView->setColumnAlignment(1,AlignHCenter);
522 mTodoListView->addColumn(i18n("Complete")); 523 mTodoListView->addColumn(i18n("Complete"));
523 mTodoListView->setColumnAlignment(2,AlignCenter); 524 mTodoListView->setColumnAlignment(2,AlignCenter);
524 525
525 mTodoListView->addColumn(i18n("Due Date")); 526 mTodoListView->addColumn(i18n("Due Date"));
526 mTodoListView->setColumnAlignment(3,AlignLeft); 527 mTodoListView->setColumnAlignment(3,AlignLeft);
527 mTodoListView->addColumn(i18n("Due Time")); 528 mTodoListView->addColumn(i18n("Due Time"));
528 mTodoListView->setColumnAlignment(4,AlignHCenter); 529 mTodoListView->setColumnAlignment(4,AlignHCenter);
529 530
530 mTodoListView->addColumn(i18n("Start Date")); 531 mTodoListView->addColumn(i18n("Start Date"));
531 mTodoListView->setColumnAlignment(5,AlignLeft); 532 mTodoListView->setColumnAlignment(5,AlignLeft);
532 mTodoListView->addColumn(i18n("Start Time")); 533 mTodoListView->addColumn(i18n("Start Time"));
533 mTodoListView->setColumnAlignment(6,AlignHCenter); 534 mTodoListView->setColumnAlignment(6,AlignHCenter);
534 535
535 mTodoListView->addColumn(i18n("Cancelled")); 536 mTodoListView->addColumn(i18n("Cancelled"));
536 mTodoListView->addColumn(i18n("Categories")); 537 mTodoListView->addColumn(i18n("Categories"));
537 mTodoListView->addColumn(i18n("Calendar")); 538 mTodoListView->addColumn(i18n("Calendar"));
538#if 0 539#if 0
539 mTodoListView->addColumn(i18n("Sort Id")); 540 mTodoListView->addColumn(i18n("Sort Id"));
540 mTodoListView->setColumnAlignment(4,AlignHCenter); 541 mTodoListView->setColumnAlignment(4,AlignHCenter);
541#endif 542#endif
542 543
543 mTodoListView->setMinimumHeight( 60 ); 544 mTodoListView->setMinimumHeight( 60 );
544 mTodoListView->setItemsRenameable( true ); 545 mTodoListView->setItemsRenameable( true );
545 mTodoListView->setRenameable( 0 ); 546 mTodoListView->setRenameable( 0 );
546 mTodoListView->setColumnWidth( 0, 120 ); 547 mTodoListView->setColumnWidth( 0, 120 );
547 int iii = 0; 548 int iii = 0;
548 for ( iii = 0; iii< 10 ; ++iii ) 549 for ( iii = 0; iii< 10 ; ++iii )
549 mTodoListView->setColumnWidthMode( iii, QListView::Manual ); 550 mTodoListView->setColumnWidthMode( iii, QListView::Manual );
550 551
551 552
552 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 553 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
553 554
554 mPriorityPopupMenu = new QPopupMenu(this); 555 mPriorityPopupMenu = new QPopupMenu(this);
555 for (int i = 1; i <= 5; i++) { 556 for (int i = 1; i <= 5; i++) {
556 QString label = QString ("%1").arg (i); 557 QString label = QString ("%1").arg (i);
557 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 558 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
558 } 559 }
559 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 560 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
560 561
561 mPercentageCompletedPopupMenu = new QPopupMenu(this); 562 mPercentageCompletedPopupMenu = new QPopupMenu(this);
562 for (int i = 0; i <= 100; i+=20) { 563 for (int i = 0; i <= 100; i+=20) {
563 QString label = QString ("%1 %").arg (i); 564 QString label = QString ("%1 %").arg (i);
564 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 565 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
565 } 566 }
566 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 567 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
567 568
568 569
569 570
570 mItemPopupMenu = new QPopupMenu(this); 571 mItemPopupMenu = new QPopupMenu(this);
571 mItemPopupMenu->insertItem(i18n("Show..."), this, 572 mItemPopupMenu->insertItem(i18n("Show..."), this,
572 SLOT (showTodo())); 573 SLOT (showTodo()));
573 mItemPopupMenu->insertItem(i18n("Edit..."), this, 574 mItemPopupMenu->insertItem(i18n("Edit..."), this,
574 SLOT (editTodo())); 575 SLOT (editTodo()));
575 mItemPopupMenu->insertItem( i18n("Delete"), this, 576 mItemPopupMenu->insertItem( i18n("Delete"), this,
576 SLOT (deleteTodo())); 577 SLOT (deleteTodo()));
577 mItemPopupMenu->insertItem( i18n("Clone..."), this, 578 mItemPopupMenu->insertItem( i18n("Clone..."), this,
578 SLOT (cloneTodo())); 579 SLOT (cloneTodo()));
579 mItemPopupMenu->insertItem( i18n("Move..."), this, 580 mItemPopupMenu->insertItem( i18n("Move..."), this,
580 SLOT (moveTodo())); 581 SLOT (moveTodo()));
581#ifndef DESKTOP_VERSION 582#ifndef DESKTOP_VERSION
582 mItemPopupMenu->insertItem( i18n("Beam..."), this, 583 mItemPopupMenu->insertItem( i18n("Beam..."), this,
583 SLOT (beamTodo())); 584 SLOT (beamTodo()));
584#endif 585#endif
585 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 586 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
586 SLOT (cancelTodo())); 587 SLOT (cancelTodo()));
587 mItemPopupMenu->insertSeparator(); 588 mItemPopupMenu->insertSeparator();
588 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 589 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
589 SLOT (toggleRunningItem())); 590 SLOT (toggleRunningItem()));
590 mItemPopupMenu->insertSeparator(); 591 mItemPopupMenu->insertSeparator();
591 /* 592 /*
592 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 593 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
593 SLOT (newTodo())); 594 SLOT (newTodo()));
594 */ 595 */
595 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 596 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
@@ -1065,208 +1066,208 @@ void KOTodoView::unparentTodo()
1065{ 1066{
1066 if (mActiveItem) { 1067 if (mActiveItem) {
1067 emit unparentTodoSignal(mActiveItem->todo()); 1068 emit unparentTodoSignal(mActiveItem->todo());
1068 } 1069 }
1069} 1070}
1070 1071
1071void KOTodoView::reparentTodo() 1072void KOTodoView::reparentTodo()
1072{ 1073{
1073 if (mActiveItem) { 1074 if (mActiveItem) {
1074 topLevelWidget()->setCaption(i18n("Click on new parent item")); 1075 topLevelWidget()->setCaption(i18n("Click on new parent item"));
1075 pendingSubtodo = mActiveItem; 1076 pendingSubtodo = mActiveItem;
1076 } 1077 }
1077} 1078}
1078void KOTodoView::editTodo() 1079void KOTodoView::editTodo()
1079{ 1080{
1080 if (mActiveItem) { 1081 if (mActiveItem) {
1081 emit editTodoSignal(mActiveItem->todo()); 1082 emit editTodoSignal(mActiveItem->todo());
1082 } 1083 }
1083} 1084}
1084void KOTodoView::cloneTodo() 1085void KOTodoView::cloneTodo()
1085{ 1086{
1086 if (mActiveItem) { 1087 if (mActiveItem) {
1087 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 1088 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
1088 } 1089 }
1089} 1090}
1090void KOTodoView::cancelTodo() 1091void KOTodoView::cancelTodo()
1091{ 1092{
1092 if (mActiveItem) { 1093 if (mActiveItem) {
1093 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 1094 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
1094 } 1095 }
1095} 1096}
1096void KOTodoView::moveTodo() 1097void KOTodoView::moveTodo()
1097{ 1098{
1098 if (mActiveItem) { 1099 if (mActiveItem) {
1099 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 1100 emit moveTodoSignal((Incidence*)mActiveItem->todo());
1100 } 1101 }
1101} 1102}
1102void KOTodoView::beamTodo() 1103void KOTodoView::beamTodo()
1103{ 1104{
1104 if (mActiveItem) { 1105 if (mActiveItem) {
1105 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 1106 emit beamTodoSignal((Incidence*)mActiveItem->todo());
1106 } 1107 }
1107} 1108}
1108 1109
1109 1110
1110void KOTodoView::showTodo() 1111void KOTodoView::showTodo()
1111{ 1112{
1112 if (mActiveItem) { 1113 if (mActiveItem) {
1113 emit showTodoSignal(mActiveItem->todo()); 1114 emit showTodoSignal(mActiveItem->todo());
1114 } 1115 }
1115} 1116}
1116 1117
1117void KOTodoView::deleteTodo() 1118void KOTodoView::deleteTodo()
1118{ 1119{
1119 if (mActiveItem) { 1120 if (mActiveItem) {
1120 emit deleteTodoSignal(mActiveItem->todo()); 1121 emit deleteTodoSignal(mActiveItem->todo());
1121 } 1122 }
1122} 1123}
1123 1124
1124void KOTodoView::setNewPriority(int index) 1125void KOTodoView::setNewPriority(int index)
1125{ 1126{
1126 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1127 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1127 mActiveItem->todo()->setPriority(mPriority[index]); 1128 mActiveItem->todo()->setPriority(mPriority[index]);
1128 mActiveItem->construct(); 1129 mActiveItem->construct();
1129 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1130 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1130 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1131 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1131 } 1132 }
1132} 1133}
1133 1134
1134void KOTodoView::setNewPercentage(int index) 1135void KOTodoView::setNewPercentage(int index)
1135{ 1136{
1136 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1137 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1137 1138
1138 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1139 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1139 mActiveItem->setOn( true ); 1140 mActiveItem->setOn( true );
1140 return; 1141 return;
1141 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1142 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1142 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1143 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1143 if ( par && par->isOn() ) 1144 if ( par && par->isOn() )
1144 par->setOn( false ); 1145 par->setOn( false );
1145 } 1146 }
1146 if (mPercentage[index] == 100) { 1147 if (mPercentage[index] == 100) {
1147 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1148 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1148 } else { 1149 } else {
1149 mActiveItem->todo()->setCompleted(false); 1150 mActiveItem->todo()->setCompleted(false);
1150 } 1151 }
1151 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1152 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1152 mActiveItem->construct(); 1153 mActiveItem->construct();
1153 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1154 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1154 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1155 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1155 } 1156 }
1156} 1157}
1157 1158
1158 1159
1159QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1160QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1160{ 1161{
1161 QPopupMenu* tempMenu = new QPopupMenu (this); 1162 if ( !mCategoryPopupMenu ) {
1162 QStringList checkedCategories = todoItem->todo()->categories (); 1163 mCategoryPopupMenu = new QPopupMenu (this);
1163 1164 mCategoryPopupMenu->setCheckable (true);
1164 tempMenu->setCheckable (true); 1165 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1165 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1166 }
1166 it != KOPrefs::instance()->mCustomCategories.end (); 1167 mCategoryPopupMenu->clear();
1167 ++it) { 1168 QStringList checkedCategories = todoItem->todo()->categories ();
1168 int index = tempMenu->insertItem (*it); 1169
1169 mCategory[index] = *it; 1170 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1170 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1171 it != KOPrefs::instance()->mCustomCategories.end ();
1171 } 1172 ++it) {
1172 1173 int index = mCategoryPopupMenu->insertItem (*it);
1173 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1174 mCategory[index] = *it;
1174 return tempMenu; 1175 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true);
1175 1176 }
1176 1177 return mCategoryPopupMenu;
1177} 1178}
1178void KOTodoView::changedCategories(int index) 1179void KOTodoView::changedCategories(int index)
1179{ 1180{
1180 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1181 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1181 QStringList categories = mActiveItem->todo()->categories (); 1182 QStringList categories = mActiveItem->todo()->categories ();
1182 QString colcat = categories.first(); 1183 QString colcat = categories.first();
1183 if (categories.find (mCategory[index]) != categories.end ()) 1184 if (categories.find (mCategory[index]) != categories.end ())
1184 categories.remove (mCategory[index]); 1185 categories.remove (mCategory[index]);
1185 else 1186 else
1186 categories.insert (categories.end(), mCategory[index]); 1187 categories.insert (categories.end(), mCategory[index]);
1187 categories.sort (); 1188 categories.sort ();
1188 if ( !colcat.isEmpty() ) { 1189 if ( !colcat.isEmpty() ) {
1189 if ( categories.find ( colcat ) != categories.end () ) { 1190 if ( categories.find ( colcat ) != categories.end () ) {
1190 categories.remove( colcat ); 1191 categories.remove( colcat );
1191 categories.prepend( colcat ); 1192 categories.prepend( colcat );
1192 } 1193 }
1193 } 1194 }
1194 mActiveItem->todo()->setCategories (categories); 1195 mActiveItem->todo()->setCategories (categories);
1195 mActiveItem->construct(); 1196 mActiveItem->construct();
1196 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1197 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1197 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1198 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1198 } 1199 }
1199} 1200}
1200void KOTodoView::itemDoubleClicked(QListViewItem *item) 1201void KOTodoView::itemDoubleClicked(QListViewItem *item)
1201{ 1202{
1202 if ( pendingSubtodo != 0 ) { 1203 if ( pendingSubtodo != 0 ) {
1203 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1204 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1204 } 1205 }
1205 pendingSubtodo = 0; 1206 pendingSubtodo = 0;
1206 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1207 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1207 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1208 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1208 //qDebug("ROW %d ", row); 1209 //qDebug("ROW %d ", row);
1209 if (!item) { 1210 if (!item) {
1210 newTodo(); 1211 newTodo();
1211 return; 1212 return;
1212 } else { 1213 } else {
1213 if ( row == 1 ) { 1214 if ( row == 1 ) {
1214 mActiveItem = (KOTodoViewItem *) item; 1215 mActiveItem = (KOTodoViewItem *) item;
1215 newSubTodo(); 1216 newSubTodo();
1216 return; 1217 return;
1217 } 1218 }
1218 if ( row == 5 || row == 6 || row == 2) { 1219 if ( row == 5 || row == 6 || row == 2) {
1219 mActiveItem = (KOTodoViewItem *) item; 1220 mActiveItem = (KOTodoViewItem *) item;
1220 Todo * t = mActiveItem->todo(); 1221 Todo * t = mActiveItem->todo();
1221 if ( t->isRunning() ) { 1222 if ( t->isRunning() ) {
1222 if ( t->runTime() < 15) { 1223 if ( t->runTime() < 15) {
1223 t->stopRunning(); 1224 t->stopRunning();
1224 mActiveItem->construct(); 1225 mActiveItem->construct();
1225 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); 1226 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!"));
1226 return; 1227 return;
1227 } 1228 }
1228 else 1229 else
1229 toggleRunningItem(); 1230 toggleRunningItem();
1230 return; 1231 return;
1231 } else { 1232 } else {
1232 t->setRunning( true ); 1233 t->setRunning( true );
1233 mActiveItem->construct(); 1234 mActiveItem->construct();
1234 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); 1235 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!"));
1235 return; 1236 return;
1236 } 1237 }
1237 } 1238 }
1238 } 1239 }
1239 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1240 if ( KOPrefs::instance()->mEditOnDoubleClick )
1240 editItem( item ); 1241 editItem( item );
1241 else 1242 else
1242 showItem( item , QPoint(), 0 ); 1243 showItem( item , QPoint(), 0 );
1243} 1244}
1244void KOTodoView::toggleRunningItem() 1245void KOTodoView::toggleRunningItem()
1245{ 1246{
1246 // qDebug("KOTodoView::toggleRunning() "); 1247 // qDebug("KOTodoView::toggleRunning() ");
1247 if ( ! mActiveItem ) 1248 if ( ! mActiveItem )
1248 return; 1249 return;
1249 Todo * t = mActiveItem->todo(); 1250 Todo * t = mActiveItem->todo();
1250 if ( t->isRunning() ) { 1251 if ( t->isRunning() ) {
1251 KOStopTodoPrefs tp ( t, this ); 1252 KOStopTodoPrefs tp ( t, this );
1252 if (QApplication::desktop()->width() <= 800 ){ 1253 if (QApplication::desktop()->width() <= 800 ){
1253 int wid = tp.width(); 1254 int wid = tp.width();
1254 int hei = tp.height(); 1255 int hei = tp.height();
1255 int xx = (QApplication::desktop()->width()-wid)/2; 1256 int xx = (QApplication::desktop()->width()-wid)/2;
1256 int yy = (QApplication::desktop()->height()-hei)/2; 1257 int yy = (QApplication::desktop()->height()-hei)/2;
1257 tp.setGeometry( xx,yy,wid,hei ); 1258 tp.setGeometry( xx,yy,wid,hei );
1258 } 1259 }
1259 tp.exec(); 1260 tp.exec();
1260 mActiveItem->construct(); 1261 mActiveItem->construct();
1261 } else { 1262 } else {
1262 KOStartTodoPrefs tp ( t->summary(), this ); 1263 KOStartTodoPrefs tp ( t->summary(), this );
1263 if (QApplication::desktop()->width() <= 800 ){ 1264 if (QApplication::desktop()->width() <= 800 ){
1264 int wid = tp.width(); 1265 int wid = tp.width();
1265 int hei = tp.height(); 1266 int hei = tp.height();
1266 int xx = (QApplication::desktop()->width()-wid)/2; 1267 int xx = (QApplication::desktop()->width()-wid)/2;
1267 int yy = (QApplication::desktop()->height()-hei)/2; 1268 int yy = (QApplication::desktop()->height()-hei)/2;
1268 tp.setGeometry( xx,yy,wid,hei ); 1269 tp.setGeometry( xx,yy,wid,hei );
1269 } 1270 }
1270 if ( !tp.exec() ) return; 1271 if ( !tp.exec() ) return;
1271 if ( tp.stopAll() ) { 1272 if ( tp.stopAll() ) {
1272 mCalendar->stopAllTodos(); 1273 mCalendar->stopAllTodos();