summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (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
@@ -1,528 +1,567 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34 34
35 35
36#include <kglobal.h> 36#include <kglobal.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kiconloader.h> 39#include <kiconloader.h>
40#include <kmessagebox.h> 40#include <kmessagebox.h>
41#include <kfiledialog.h> 41#include <kfiledialog.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43 43
44#include <libkcal/todo.h> 44#include <libkcal/todo.h>
45#include <libkcal/event.h> 45#include <libkcal/event.h>
46#include <libkdepim/categoryselectdialog.h> 46#include <libkdepim/categoryselectdialog.h>
47#include <libkdepim/kdateedit.h> 47#include <libkdepim/kdateedit.h>
48 48
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()) {
252 mAlarmSound = fileName; 291 mAlarmSound = fileName;
253 QToolTip::remove(mAlarmSoundButton); 292 QToolTip::remove(mAlarmSoundButton);
254 QString dispStr = i18n("Playing '%1'").arg(fileName); 293 QString dispStr = i18n("Playing '%1'").arg(fileName);
255 QToolTip::add(mAlarmSoundButton, dispStr); 294 QToolTip::add(mAlarmSoundButton, dispStr);
256 mAlarmProgramButton->setOn(false); 295 mAlarmProgramButton->setOn(false);
257 mAlarmSoundButton->setOn(true); 296 mAlarmSoundButton->setOn(true);
258 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 297 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
259 } else { 298 } else {
260 mAlarmProgramButton->setOn(oldState); 299 mAlarmProgramButton->setOn(oldState);
261 mAlarmSoundButton->setOn(!oldState); 300 mAlarmSoundButton->setOn(!oldState);
262 301
263 302
264 } 303 }
265 304
266 if (mAlarmProgramButton->isOn()) 305 if (mAlarmProgramButton->isOn())
267 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 306 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
268 if ( mAlarmSoundButton->isOn()) 307 if ( mAlarmSoundButton->isOn())
269 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 308 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
270 309
271} 310}
272 311
273void KOEditorGeneral::pickAlarmProgram() 312void KOEditorGeneral::pickAlarmProgram()
274{ 313{
275 bool oldState = mAlarmProgramButton->isOn(); 314 bool oldState = mAlarmProgramButton->isOn();
276 315
277 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 316 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
278 if (!fileName.isEmpty()) { 317 if (!fileName.isEmpty()) {
279 mAlarmProgram = fileName; 318 mAlarmProgram = fileName;
280 QToolTip::remove(mAlarmProgramButton); 319 QToolTip::remove(mAlarmProgramButton);
281 QString dispStr = i18n("Running '%1'").arg(fileName); 320 QString dispStr = i18n("Running '%1'").arg(fileName);
282 QToolTip::add(mAlarmProgramButton, dispStr); 321 QToolTip::add(mAlarmProgramButton, dispStr);
283 mAlarmSoundButton->setOn(false); 322 mAlarmSoundButton->setOn(false);
284 mAlarmProgramButton->setOn(true); 323 mAlarmProgramButton->setOn(true);
285 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 324 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
286 } else { 325 } else {
287 mAlarmProgramButton->setOn(!oldState); 326 mAlarmProgramButton->setOn(!oldState);
288 mAlarmSoundButton->setOn(oldState); 327 mAlarmSoundButton->setOn(oldState);
289 } 328 }
290 329
291 if (mAlarmProgramButton->isOn()) 330 if (mAlarmProgramButton->isOn())
292 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 331 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
293 if ( mAlarmSoundButton->isOn()) 332 if ( mAlarmSoundButton->isOn())
294 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 333 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
295 334
296} 335}
297 336
298 337
299QString KOEditorGeneral::getFittingPath( const QString s ) 338QString KOEditorGeneral::getFittingPath( const QString s )
300{ 339{
301 int maxlen = 50; 340 int maxlen = 50;
302 if ( QApplication::desktop()->width() < 640 ) { 341 if ( QApplication::desktop()->width() < 640 ) {
303 if ( QApplication::desktop()->width() < 320 ) 342 if ( QApplication::desktop()->width() < 320 )
304 maxlen = 22; 343 maxlen = 22;
305 else 344 else
306 maxlen = 35; 345 maxlen = 35;
307 } 346 }
308 if ( s.length() > maxlen ) { 347 if ( s.length() > maxlen ) {
309 return "..."+s.right(maxlen -3); 348 return "..."+s.right(maxlen -3);
310 } 349 }
311 return s; 350 return s;
312} 351}
313 352
314void KOEditorGeneral::enableAlarmEdit(bool enable) 353void KOEditorGeneral::enableAlarmEdit(bool enable)
315{ 354{
316 if ( enable ) { 355 if ( enable ) {
317 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 356 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
318 mAlarmSoundButton->setOn( true ); 357 mAlarmSoundButton->setOn( true );
319 if ( mAlarmSound.isEmpty() ) 358 if ( mAlarmSound.isEmpty() )
320 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 359 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
321 else { 360 else {
322 if ( ! QFile::exists( mAlarmSound ) ) 361 if ( ! QFile::exists( mAlarmSound ) )
323 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 362 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
324 } 363 }
325 } 364 }
326 } 365 }
327 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 366 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
328 mAlarmTimeEdit->setEnabled(enable); 367 mAlarmTimeEdit->setEnabled(enable);
329 mAlarmSoundButton->setEnabled(enable); 368 mAlarmSoundButton->setEnabled(enable);
330 mAlarmProgramButton->setEnabled(enable); 369 mAlarmProgramButton->setEnabled(enable);
331 mAlarmIncrCombo->setEnabled(enable); 370 mAlarmIncrCombo->setEnabled(enable);
332} 371}
333 372
334void KOEditorGeneral::disableAlarmEdit(bool disable) 373void KOEditorGeneral::disableAlarmEdit(bool disable)
335{ 374{
336 enableAlarmEdit( !disable ); 375 enableAlarmEdit( !disable );
337} 376}
338 377
339void KOEditorGeneral::enableAlarm( bool enable ) 378void KOEditorGeneral::enableAlarm( bool enable )
340{ 379{
341 enableAlarmEdit( enable ); 380 enableAlarmEdit( enable );
342} 381}
343 382
344void KOEditorGeneral::alarmDisable(bool disable) 383void KOEditorGeneral::alarmDisable(bool disable)
345{ 384{
346 if (!disable) { 385 if (!disable) {
347 //mAlarmBell->setEnabled(true); 386 //mAlarmBell->setEnabled(true);
348 mAlarmButton->setEnabled(true); 387 mAlarmButton->setEnabled(true);
349 } else { 388 } else {
350 //mAlarmBell->setEnabled(false); 389 //mAlarmBell->setEnabled(false);
351 mAlarmButton->setEnabled(false); 390 mAlarmButton->setEnabled(false);
352 mAlarmButton->setChecked(false); 391 mAlarmButton->setChecked(false);
353 mAlarmTimeEdit->setEnabled(false); 392 mAlarmTimeEdit->setEnabled(false);
354 mAlarmSoundButton->setEnabled(false); 393 mAlarmSoundButton->setEnabled(false);
355 mAlarmProgramButton->setEnabled(false); 394 mAlarmProgramButton->setEnabled(false);
356 mAlarmIncrCombo->setEnabled(false); 395 mAlarmIncrCombo->setEnabled(false);
357 } 396 }
358} 397}
359 398
360void KOEditorGeneral::setCategories(const QString &str) 399void KOEditorGeneral::setCategories(const QString &str)
361{ 400{
362 mCategoriesLabel->setText(str); 401 mCategoriesLabel->setText(str);
363} 402}
364 403
365void KOEditorGeneral::setDefaults(bool allDay) 404void KOEditorGeneral::setDefaults(bool allDay)
366{ 405{
367#if 0 406#if 0
368 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 407 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
369#endif 408#endif
370 409
371 mAlarmMessage = i18n("Edit new item"); 410 mAlarmMessage = i18n("Edit new item");
372 enableAlarmEdit( !allDay ); 411 enableAlarmEdit( !allDay );
373 412
374 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 413 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
375 int alarmTime; 414 int alarmTime;
376 int a[] = { 1,5,10,15,30,60,180, 1440 }; 415 int a[] = { 1,5,10,15,30,60,180, 1440 };
377 int index = KOPrefs::instance()->mAlarmTime; 416 int index = KOPrefs::instance()->mAlarmTime;
378 if (index < 0 || index > 7) { 417 if (index < 0 || index > 7) {
379 alarmTime = 15; 418 alarmTime = 15;
380 } else { 419 } else {
381 alarmTime = a[index]; 420 alarmTime = a[index];
382 } 421 }
383 mAlarmButton ->setChecked( false ); 422 mAlarmButton ->setChecked( false );
384 mAlarmTimeEdit->setValue(alarmTime); 423 mAlarmTimeEdit->setValue(alarmTime);
385 mAlarmIncrCombo->setCurrentItem(0); 424 mAlarmIncrCombo->setCurrentItem(0);
386 enableAlarmEdit( false ); 425 enableAlarmEdit( false );
387 //alarmDisable (false); 426 //alarmDisable (false);
388 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 427 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
389 mCancelBox->setChecked( false ); 428 mCancelBox->setChecked( false );
390 mSummaryEdit->setEditText(""); 429 mSummaryEdit->setEditText("");
391 mLocationEdit->setEditText(""); 430 mLocationEdit->setEditText("");
392 mDescriptionEdit->setText(""); 431 mDescriptionEdit->setText("");
393 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 432 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
394 setCategories(""); 433 setCategories("");
395} 434}
396void KOEditorGeneral::setSecrecy( int num ) 435void KOEditorGeneral::setSecrecy( int num )
397{ 436{
398 mSecrecyCombo->setCurrentItem(num); 437 mSecrecyCombo->setCurrentItem(num);
399} 438}
400void KOEditorGeneral::readIncidence(Incidence *event) 439void KOEditorGeneral::readIncidence(Incidence *event)
401{ 440{
402 441
403 mAlarmMessage = event->summary(); 442 mAlarmMessage = event->summary();
404 if ( ! event->location().isEmpty() ) 443 if ( ! event->location().isEmpty() )
405 mAlarmMessage += " ("+event->location()+")"; 444 mAlarmMessage += " ("+event->location()+")";
406 mAlarmIncrCombo->setCurrentItem(0); 445 mAlarmIncrCombo->setCurrentItem(0);
407 mSummaryEdit->setEditText(event->summary()); 446 mSummaryEdit->setEditText(event->summary());
408 mLocationEdit->setEditText(event->location()); 447 mLocationEdit->setEditText(event->location());
409 mDescriptionEdit->setText(event->description()); 448 mDescriptionEdit->setText(event->description());
410 449
411#if 0 450#if 0
412 // organizer information 451 // organizer information
413 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 452 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
414#endif 453#endif
415 454
416 enableAlarmEdit( event->isAlarmEnabled() ); 455 enableAlarmEdit( event->isAlarmEnabled() );
417 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 456 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
418 if(!event->isAlarmEnabled()) { 457 if(!event->isAlarmEnabled()) {
419 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 458 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
420 int alarmTime; 459 int alarmTime;
421 int a[] = { 1,5,10,15,30,60,180, 1440 }; 460 int a[] = { 1,5,10,15,30,60,180, 1440 };
422 int index = KOPrefs::instance()->mAlarmTime; 461 int index = KOPrefs::instance()->mAlarmTime;
423 if (index < 0 || index > 7) { 462 if (index < 0 || index > 7) {
424 alarmTime = 15; 463 alarmTime = 15;
425 } else { 464 } else {
426 alarmTime = a[index]; 465 alarmTime = a[index];
427 } 466 }
428 mAlarmTimeEdit->setValue(alarmTime); 467 mAlarmTimeEdit->setValue(alarmTime);
429 } 468 }
430 mAlarmButton->setChecked( event->isAlarmEnabled() ); 469 mAlarmButton->setChecked( event->isAlarmEnabled() );
431 mSecrecyCombo->setCurrentItem(event->secrecy()); 470 mSecrecyCombo->setCurrentItem(event->secrecy());
432 mCancelBox->setChecked( event->cancelled() ); 471 mCancelBox->setChecked( event->cancelled() );
433 mAlarmProgramButton->setOn(false); 472 mAlarmProgramButton->setOn(false);
434 mAlarmSoundButton->setOn(false); 473 mAlarmSoundButton->setOn(false);
435 474
436 // set up alarm stuff 475 // set up alarm stuff
437 QPtrList<Alarm> alarms = event->alarms(); 476 QPtrList<Alarm> alarms = event->alarms();
438 Alarm* alarm; 477 Alarm* alarm;
439 mAlarmIncrCombo->setCurrentItem(0); 478 mAlarmIncrCombo->setCurrentItem(0);
440 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 479 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
441 int offset; 480 int offset;
442 if ( alarm->hasTime() ) { 481 if ( alarm->hasTime() ) {
443 QDateTime t = alarm->time(); 482 QDateTime t = alarm->time();
444 offset = event->dtStart().secsTo( t ); 483 offset = event->dtStart().secsTo( t );
445 } else { 484 } else {
446 offset = alarm->startOffset().asSeconds(); 485 offset = alarm->startOffset().asSeconds();
447 } 486 }
448 if ( offset != 0 ) { 487 if ( offset != 0 ) {
449 offset = offset / -60; // make minutes 488 offset = offset / -60; // make minutes
450 if (offset % 60 == 0) { // divides evenly into hours? 489 if (offset % 60 == 0) { // divides evenly into hours?
451 offset = offset / 60; 490 offset = offset / 60;
452 mAlarmIncrCombo->setCurrentItem(1); 491 mAlarmIncrCombo->setCurrentItem(1);
453 if (offset % 24 == 0) { // divides evenly into days? 492 if (offset % 24 == 0) { // divides evenly into days?
454 offset = offset / 24; 493 offset = offset / 24;
455 mAlarmIncrCombo->setCurrentItem(2); 494 mAlarmIncrCombo->setCurrentItem(2);
456 } 495 }
457 } 496 }
458 } 497 }
459 mAlarmTimeEdit->setValue( offset ); 498 mAlarmTimeEdit->setValue( offset );
460 if (alarm->type() == Alarm::Procedure) { 499 if (alarm->type() == Alarm::Procedure) {
461 500
462 mAlarmProgram = alarm->programFile(); 501 mAlarmProgram = alarm->programFile();
463 mAlarmProgramButton->setOn(true); 502 mAlarmProgramButton->setOn(true);
464 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 503 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
465 QToolTip::add(mAlarmProgramButton, dispStr); 504 QToolTip::add(mAlarmProgramButton, dispStr);
466 } 505 }
467 else if (alarm->type() == Alarm::Audio) { 506 else if (alarm->type() == Alarm::Audio) {
468 mAlarmSound = alarm->audioFile(); 507 mAlarmSound = alarm->audioFile();
469 if ( ! QFile::exists( mAlarmSound ) ) 508 if ( ! QFile::exists( mAlarmSound ) )
470 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 509 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
471 mAlarmSoundButton->setOn(true); 510 mAlarmSoundButton->setOn(true);
472 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 511 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
473 QToolTip::add(mAlarmSoundButton, dispStr); 512 QToolTip::add(mAlarmSoundButton, dispStr);
474 } 513 }
475 mAlarmButton->setChecked(alarm->enabled()); 514 mAlarmButton->setChecked(alarm->enabled());
476 enableAlarmEdit( alarm->enabled() ); 515 enableAlarmEdit( alarm->enabled() );
477 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 516 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
478 // TODO: Deal with multiple alarms 517 // TODO: Deal with multiple alarms
479 break; // For now, stop after the first alarm 518 break; // For now, stop after the first alarm
480 } 519 }
481 520
482 setCategories(event->categoriesStr()); 521 setCategories(event->categoriesStr());
483} 522}
484 523
485void KOEditorGeneral::writeIncidence(Incidence *event) 524void KOEditorGeneral::writeIncidence(Incidence *event)
486{ 525{
487 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 526 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
488 mLocationEdit->save(KOLocationBox::LOCATION); 527 mLocationEdit->save(KOLocationBox::LOCATION);
489 event->setSummary(mSummaryEdit->currentText()); 528 event->setSummary(mSummaryEdit->currentText());
490 event->setLocation(mLocationEdit->currentText()); 529 event->setLocation(mLocationEdit->currentText());
491 event->setDescription(mDescriptionEdit->text()); 530 event->setDescription(mDescriptionEdit->text());
492 event->setCategories(mCategoriesLabel->text()); 531 event->setCategories(mCategoriesLabel->text());
493 event->setSecrecy(mSecrecyCombo->currentItem()); 532 event->setSecrecy(mSecrecyCombo->currentItem());
494 event->setCancelled(mCancelBox->isChecked() );; 533 event->setCancelled(mCancelBox->isChecked() );;
495 // alarm stuff 534 // alarm stuff
496 if (mAlarmButton->isChecked()) { 535 if (mAlarmButton->isChecked()) {
497 if (event->alarms().count() == 0) 536 if (event->alarms().count() == 0)
498 event->newAlarm(); 537 event->newAlarm();
499 QPtrList<Alarm> alarms = event->alarms(); 538 QPtrList<Alarm> alarms = event->alarms();
500 Alarm *alarm; 539 Alarm *alarm;
501 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 540 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
502 alarm->setEnabled(true); 541 alarm->setEnabled(true);
503 int j = mAlarmTimeEdit->value()* -60; 542 int j = mAlarmTimeEdit->value()* -60;
504 if (mAlarmIncrCombo->currentItem() == 1) 543 if (mAlarmIncrCombo->currentItem() == 1)
505 j = j * 60; 544 j = j * 60;
506 else if (mAlarmIncrCombo->currentItem() == 2) 545 else if (mAlarmIncrCombo->currentItem() == 2)
507 j = j * (60 * 24); 546 j = j * (60 * 24);
508 alarm->setStartOffset( j ); 547 alarm->setStartOffset( j );
509 548
510 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 549 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
511 alarm->setProcedureAlarm(mAlarmProgram); 550 alarm->setProcedureAlarm(mAlarmProgram);
512 } 551 }
513 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 552 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
514 alarm->setAudioAlarm(mAlarmSound); 553 alarm->setAudioAlarm(mAlarmSound);
515 else 554 else
516 alarm->setType(Alarm::Invalid); 555 alarm->setType(Alarm::Invalid);
517 //alarm->setAudioAlarm("default"); 556 //alarm->setAudioAlarm("default");
518 // TODO: Deal with multiple alarms 557 // TODO: Deal with multiple alarms
519 break; // For now, stop after the first alarm 558 break; // For now, stop after the first alarm
520 } 559 }
521 } else { 560 } else {
522 Alarm* alarm = event->alarms().first(); 561 Alarm* alarm = event->alarms().first();
523 if ( alarm ) { 562 if ( alarm ) {
524 alarm->setEnabled(false); 563 alarm->setEnabled(false);
525 alarm->setType(Alarm::Invalid); 564 alarm->setType(Alarm::Invalid);
526 } 565 }
527 } 566 }
528} 567}
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
@@ -1,603 +1,603 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kglobalsettings.h> 39#include <kglobalsettings.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <klocale.h> 41#include <klocale.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kemailsettings.h> 43#include <kemailsettings.h>
44#include <kstaticdeleter.h> 44#include <kstaticdeleter.h>
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48#include "mainwindow.h" 48#include "mainwindow.h"
49 49
50KOPrefs *KOPrefs::mInstance = 0; 50KOPrefs *KOPrefs::mInstance = 0;
51static KStaticDeleter<KOPrefs> insd; 51static KStaticDeleter<KOPrefs> insd;
52 52
53KOPrefs::KOPrefs() : 53KOPrefs::KOPrefs() :
54 KPimPrefs("korganizerrc") 54 KPimPrefs("korganizerrc")
55{ 55{
56 mCategoryColors.setAutoDelete(true); 56 mCategoryColors.setAutoDelete(true);
57 fillMailDefaults(); 57 fillMailDefaults();
58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
59 QColor defaultHolidayColor = QColor(255,0,0); 59 QColor defaultHolidayColor = QColor(255,0,0);
60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
63 QColor defaultTodoDueTodayColor = QColor(255,220,100); 63 QColor defaultTodoDueTodayColor = QColor(255,220,100);
64 QColor defaultTodoOverdueColor = QColor(255,153,125); 64 QColor defaultTodoOverdueColor = QColor(255,153,125);
65 QColor defaultTodoRunColor = QColor(99,194,30); 65 QColor defaultTodoRunColor = QColor(99,194,30);
66 KPrefs::setCurrentGroup("General"); 66 KPrefs::setCurrentGroup("General");
67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
70 addItemBool("ShowIconSearch",&mShowIconSearch,true); 70 addItemBool("ShowIconSearch",&mShowIconSearch,true);
71 addItemBool("ShowIconList",&mShowIconList,true); 71 addItemBool("ShowIconList",&mShowIconList,true);
72 addItemBool("ShowIconDay1",&mShowIconDay1,true); 72 addItemBool("ShowIconDay1",&mShowIconDay1,true);
73 addItemBool("ShowIconDay5",&mShowIconDay5,true); 73 addItemBool("ShowIconDay5",&mShowIconDay5,true);
74 addItemBool("ShowIconDay6",&mShowIconDay6,true); 74 addItemBool("ShowIconDay6",&mShowIconDay6,true);
75 addItemBool("ShowIconDay7",&mShowIconDay7,true); 75 addItemBool("ShowIconDay7",&mShowIconDay7,true);
76 addItemBool("ShowIconMonth",&mShowIconMonth,true); 76 addItemBool("ShowIconMonth",&mShowIconMonth,true);
77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
79 addItemBool("ShowIconBack",&mShowIconBack,true); 79 addItemBool("ShowIconBack",&mShowIconBack,true);
80 addItemBool("ShowIconToday",&mShowIconToday,true); 80 addItemBool("ShowIconToday",&mShowIconToday,true);
81 addItemBool("ShowIconForward",&mShowIconForward,true); 81 addItemBool("ShowIconForward",&mShowIconForward,true);
82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); 84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true);
85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
86 addItemBool("ShowIconNext",&mShowIconNext,true); 86 addItemBool("ShowIconNext",&mShowIconNext,true);
87 addItemBool("ShowIconJournal",&mShowIconJournal,true); 87 addItemBool("ShowIconJournal",&mShowIconJournal,true);
88 addItemBool("ShowIconStretch",&mShowIconStretch,true); 88 addItemBool("ShowIconStretch",&mShowIconStretch,true);
89 addItemBool("ShowIconFilter",&mShowIconFilter,false); 89 addItemBool("ShowIconFilter",&mShowIconFilter,false);
90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); 90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true);
91 91
92 bool addIcons = false; 92 bool addIcons = false;
93#ifdef DESKTOP_VERSION 93#ifdef DESKTOP_VERSION
94 addIcons = true; 94 addIcons = true;
95#endif 95#endif
96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); 96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons);
97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); 97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons);
98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); 98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons);
99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); 99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons);
100 100
101 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 101 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
102 102
103 addItemBool("AskForQuit",&mAskForQuit,false); 103 addItemBool("AskForQuit",&mAskForQuit,false);
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 106 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 107#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 108 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 109#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 110 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 111 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarHorV",&mToolBarHorV, true ); 112 addItemBool("ToolBarHorV",&mToolBarHorV, true );
113 addItemBool("ToolBarUpV",&mToolBarUpV, false ); 113 addItemBool("ToolBarUpV",&mToolBarUpV, false );
114 addItemBool("ToolBarHorN",&mToolBarHorN, true ); 114 addItemBool("ToolBarHorN",&mToolBarHorN, true );
115 addItemBool("ToolBarUpN",&mToolBarUpN, false ); 115 addItemBool("ToolBarUpN",&mToolBarUpN, false );
116 addItemBool("ToolBarHorF",&mToolBarHorF, true ); 116 addItemBool("ToolBarHorF",&mToolBarHorF, true );
117 addItemBool("ToolBarUpF",&mToolBarUpF, false ); 117 addItemBool("ToolBarUpF",&mToolBarUpF, false );
118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
119 addItemInt("Whats Next Days",&mWhatsNextDays,3); 119 addItemInt("Whats Next Days",&mWhatsNextDays,3);
120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
121 121
122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); 123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true);
124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
127 addItemInt("AllDay Size",&mAllDaySize,28); 127 addItemInt("AllDay Size",&mAllDaySize,28);
128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
130 130
131 addItemStringList("LocationDefaults",&mLocationDefaults ); 131 addItemStringList("LocationDefaults",&mLocationDefaults );
132 addItemStringList("EventSummary User",&mEventSummaryUser); 132 addItemStringList("EventSummary User",&mEventSummaryUser);
133 addItemStringList("TodoSummary User",&mTodoSummaryUser); 133 addItemStringList("TodoSummary User",&mTodoSummaryUser);
134 134
135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
136 addItemBool("Enable Project View",&mEnableProjectView,false); 136 addItemBool("Enable Project View",&mEnableProjectView,false);
137 addItemBool("Auto Save",&mAutoSave,false); 137 addItemBool("Auto Save",&mAutoSave,false);
138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
139 addItemBool("Confirm Deletes",&mConfirm,true); 139 addItemBool("Confirm Deletes",&mConfirm,true);
140 addItemString("Archive File",&mArchiveFile); 140 addItemString("Archive File",&mArchiveFile);
141 addItemString("Html Export File",&mHtmlExportFile, 141 addItemString("Html Export File",&mHtmlExportFile,
142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
143 addItemBool("Html With Save",&mHtmlWithSave,false); 143 addItemBool("Html With Save",&mHtmlWithSave,false);
144 144
145 KPrefs::setCurrentGroup("Personal Settings"); 145 KPrefs::setCurrentGroup("Personal Settings");
146 146
147 addItemInt("Mail Client",&mMailClient,MailClientKMail); 147 addItemInt("Mail Client",&mMailClient,MailClientKMail);
148 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 148 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
149 addItemBool("Bcc",&mBcc,false); 149 addItemBool("Bcc",&mBcc,false);
150 150
151 KPrefs::setCurrentGroup("Time & Date"); 151 KPrefs::setCurrentGroup("Time & Date");
152 152
153 153
154 addItemInt("Default Start Time",&mStartTime,10); 154 addItemInt("Default Start Time",&mStartTime,10);
155 addItemInt("Default Duration",&mDefaultDuration,2); 155 addItemInt("Default Duration",&mDefaultDuration,2);
156 addItemInt("Default Alarm Time",&mAlarmTime,3); 156 addItemInt("Default Alarm Time",&mAlarmTime,3);
157 KPrefs::setCurrentGroup("AlarmSettings"); 157 KPrefs::setCurrentGroup("AlarmSettings");
158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
162 162
163 163
164 KPrefs::setCurrentGroup("Calendar"); 164 KPrefs::setCurrentGroup("Calendar");
165 165
166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
167 167
168 KPrefs::setCurrentGroup("Fonts"); 168 KPrefs::setCurrentGroup("Fonts");
169 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 169 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
170 QFont fon = KGlobalSettings::generalFont(); 170 QFont fon = KGlobalSettings::generalFont();
171 addItemFont("TimeBar Font",&mTimeBarFont,fon ); 171 addItemFont("TimeBar Font",&mTimeBarFont,fon );
172 addItemFont("MonthView Font",&mMonthViewFont,fon); 172 addItemFont("MonthView Font",&mMonthViewFont,fon);
173 addItemFont("AgendaView Font",&mAgendaViewFont,fon); 173 addItemFont("AgendaView Font",&mAgendaViewFont,fon);
174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); 174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon);
175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); 175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon);
176 addItemFont("TodoView Font",&mTodoViewFont,fon); 176 addItemFont("TodoView Font",&mTodoViewFont,fon);
177 addItemFont("ListView Font",&mListViewFont,fon); 177 addItemFont("ListView Font",&mListViewFont,fon);
178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); 178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon);
179 addItemFont("EditBox Font",&mEditBoxFont,fon); 179 addItemFont("EditBox Font",&mEditBoxFont,fon);
180 addItemFont("JournalView Font",&mJornalViewFont,fon); 180 addItemFont("JournalView Font",&mJornalViewFont,fon);
181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); 181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon);
182 addItemFont("EventView Font",&mEventViewFont,fon); 182 addItemFont("EventView Font",&mEventViewFont,fon);
183 183
184 KPrefs::setCurrentGroup("RemoteSyncing"); 184 KPrefs::setCurrentGroup("RemoteSyncing");
185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
188 addItemInt("LastSyncTime",&mLastSyncTime,0); 188 addItemInt("LastSyncTime",&mLastSyncTime,0);
189 189
190#ifdef _WIN32_ 190#ifdef _WIN32_
191 QString hdp= locateLocal("data","korganizer")+"\\\\"; 191 QString hdp= locateLocal("data","korganizer")+"\\\\";
192#else 192#else
193 QString hdp= locateLocal("data","korganizer")+"/"; 193 QString hdp= locateLocal("data","korganizer")+"/";
194#endif 194#endif
195 195
196 KPrefs::setCurrentGroup("LoadSaveFileNames"); 196 KPrefs::setCurrentGroup("LoadSaveFileNames");
197 197
198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
202 202
203 203
204 KPrefs::setCurrentGroup("Locale"); 204 KPrefs::setCurrentGroup("Locale");
205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
206 206
207 207
208 KPrefs::setCurrentGroup("Colors"); 208 KPrefs::setCurrentGroup("Colors");
209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); 212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); 217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor);
218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
223 addItemBool("MonthViewWeek",&mMonthViewWeek,false); 223 addItemBool("MonthViewWeek",&mMonthViewWeek,false);
224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
227 addItemBool("UseAppColors",&mUseAppColors,false); 227 addItemBool("UseAppColors",&mUseAppColors,false);
228 228
229 229
230 230
231 KPrefs::setCurrentGroup("Views"); 231 KPrefs::setCurrentGroup("Views");
232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true); 232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true);
233 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 233 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
234 addItemInt("Hour Size",&mHourSize,8); 234 addItemInt("Hour Size",&mHourSize,8);
235 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 235 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
239 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 239 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); 241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true);
242#ifdef DESKTOP_VERION 242#ifdef DESKTOP_VERION
243 addItemBool("Enable ToolTips",&mEnableToolTips,true); 243 addItemBool("Enable ToolTips",&mEnableToolTips,true);
244#else 244#else
245 addItemBool("Enable ToolTips",&mEnableToolTips,false); 245 addItemBool("Enable ToolTips",&mEnableToolTips,false);
246#endif 246#endif
247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); 263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true);
264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); 264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true);
265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
267#ifdef DESKTOP_VERSION 267#ifdef DESKTOP_VERSION
268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
269#else 269#else
270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
271#endif 271#endif
272 addItemInt("Day Begins",&mDayBegins,7); 272 addItemInt("Day Begins",&mDayBegins,7);
273 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 273 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
274 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 274 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
275 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 275 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
277 277
278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
279 addItemBool("Full View Month",&mFullViewMonth,true); 279 addItemBool("Full View Month",&mFullViewMonth,true);
280 addItemBool("Full View Todo",&mFullViewTodo,true); 280 addItemBool("Full View Todo",&mFullViewTodo,true);
281 addItemBool("Quick Todo",&mEnableQuickTodo,false); 281 addItemBool("Quick Todo",&mEnableQuickTodo,false);
282 282
283 addItemInt("Next X Days",&mNextXDays,3); 283 addItemInt("Next X Days",&mNextXDays,3);
284 284
285 KPrefs::setCurrentGroup("Printer"); 285 KPrefs::setCurrentGroup("Printer");
286 286
287 KPrefs::setCurrentGroup("Layout"); 287 KPrefs::setCurrentGroup("Layout");
288 288
289 addItemBool("CompactDialogs",&mCompactDialogs,false); 289 addItemBool("CompactDialogs",&mCompactDialogs,false);
290 addItemBool("VerticalScreen",&mVerticalScreen,true); 290 addItemBool("VerticalScreen",&mVerticalScreen,true);
291 291
292 KPrefs::setCurrentGroup("KOrganizer Plugins"); 292 KPrefs::setCurrentGroup("KOrganizer Plugins");
293 293
294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
295 295
296 KPrefs::setCurrentGroup("Group Scheduling"); 296 KPrefs::setCurrentGroup("Group Scheduling");
297 297
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
503{ 503{
504 return (mDefCalColors[calNum-1])->mName; 504 return (mDefCalColors[calNum-1])->mName;
505} 505}
506QColor KOPrefs::defaultColor( int calNum ) const 506QColor KOPrefs::defaultColor( int calNum ) const
507{ 507{
508 if ( calNum == 1 ) return mEventColor; 508 if ( calNum == 1 ) return mEventColor;
509 return (mDefCalColors[calNum-1])->mDefaultColor; 509 return (mDefCalColors[calNum-1])->mDefaultColor;
510} 510}
511void KOPrefs::usrWriteConfig() 511void KOPrefs::usrWriteConfig()
512{ 512{
513 config()->setGroup("General"); 513 config()->setGroup("General");
514 config()->writeEntry("Custom Categories",mCustomCategories); 514 config()->writeEntry("Custom Categories",mCustomCategories);
515 515
516 config()->setGroup("Personal Settings"); 516 config()->setGroup("Personal Settings");
517 config()->writeEntry("user_name",mName); 517 config()->writeEntry("user_name",mName);
518 config()->writeEntry("user_email",mEmail); 518 config()->writeEntry("user_email",mEmail);
519 519
520 config()->setGroup("Category Colors"); 520 config()->setGroup("Category Colors");
521 QDictIterator<QColor> it(mCategoryColors); 521 QDictIterator<QColor> it(mCategoryColors);
522 while (it.current()) { 522 while (it.current()) {
523 config()->writeEntry(it.currentKey(),*(it.current())); 523 config()->writeEntry(it.currentKey(),*(it.current()));
524 ++it; 524 ++it;
525 } 525 }
526 KConfig fc (locateLocal("config","kopicalendarrc")); 526 KConfig fc (locateLocal("config","kopicalendarrc"));
527 fc.setGroup("CC"); 527 fc.setGroup("CC");
528 fc.writeEntry("NumberCalendars",mCalendars.count()); 528 fc.writeEntry("NumberCalendars",mCalendars.count());
529 int numCal = 1; 529 int numCal = 1;
530 int writeCal = 0; 530 int writeCal = 0;
531 while ( numCal < mNextAvailableCalendar ) { 531 while ( numCal < mNextAvailableCalendar ) {
532 KopiCalendarFile * kkf = mCalendars.first(); 532 KopiCalendarFile * kkf = mCalendars.first();
533 while ( kkf ) { 533 while ( kkf ) {
534 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); 534 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
535 if ( kkf->mCalNumber == numCal ) { 535 if ( kkf->mCalNumber == numCal ) {
536 ++writeCal; 536 ++writeCal;
537 //qDebug("Write calendar %d %d ", numCal , writeCal); 537 //qDebug("Write calendar %d %d ", numCal , writeCal);
538 QString prefix = "Cal_" + QString::number( writeCal ); 538 QString prefix = "Cal_" + QString::number( writeCal );
539 fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); 539 fc.writeEntry( prefix+"_isStandard", kkf->isStandard );
540 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); 540 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled );
541 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); 541 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
542 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); 542 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
543 fc.writeEntry( prefix+"_Name", kkf->mName); 543 fc.writeEntry( prefix+"_Name", kkf->mName);
544 fc.writeEntry( prefix+"_FileName", kkf->mFileName); 544 fc.writeEntry( prefix+"_FileName", kkf->mFileName);
545 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); 545 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor);
546 } 546 }
547 kkf = mCalendars.next(); 547 kkf = mCalendars.next();
548 } 548 }
549 ++numCal; 549 ++numCal;
550 } 550 }
551 fc.sync(); 551 fc.sync();
552 KPimPrefs::usrWriteConfig(); 552 KPimPrefs::usrWriteConfig();
553} 553}
554 554
555void KOPrefs::setCategoryColor(QString cat,const QColor & color) 555void KOPrefs::setCategoryColor(QString cat,const QColor & color)
556{ 556{
557 mCategoryColors.replace(cat,new QColor(color)); 557 mCategoryColors.replace(cat,new QColor(color));
558} 558}
559 559
560QColor *KOPrefs::categoryColor(QString cat) 560QColor *KOPrefs::categoryColor(QString cat)
561{ 561{
562 QColor *color = 0; 562 QColor *color = 0;
563 563
564 if (!cat.isEmpty()) color = mCategoryColors[cat]; 564 if (!cat.isEmpty()) color = mCategoryColors[cat];
565 565
566 if (color) return color; 566 if (color) return color;
567 else return &mDefaultCategoryColor; 567 else return &mDefaultCategoryColor;
568} 568}
569 569
570void KOPrefs::setFullName(const QString &name) 570void KOPrefs::setFullName(const QString &name)
571{ 571{
572 mName = name; 572 mName = name;
573} 573}
574 574
575void KOPrefs::setEmail(const QString &email) 575void KOPrefs::setEmail(const QString &email)
576{ 576{
577 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 577 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
578 mEmail = email; 578 mEmail = email;
579} 579}
580 580
581QString KOPrefs::fullName() 581QString KOPrefs::fullName()
582{ 582{
583 if (mEmailControlCenter) { 583 if (mEmailControlCenter) {
584 KEMailSettings settings; 584 KEMailSettings settings;
585 return settings.getSetting(KEMailSettings::RealName); 585 return settings.getSetting(KEMailSettings::RealName);
586 } else { 586 } else {
587 return mName; 587 return mName;
588 } 588 }
589} 589}
590 590
591QString KOPrefs::email() 591QString KOPrefs::email()
592{ 592{
593 if (mEmailControlCenter) { 593 if (mEmailControlCenter) {
594 KEMailSettings settings; 594 KEMailSettings settings;
595 return settings.getSetting(KEMailSettings::EmailAddress); 595 return settings.getSetting(KEMailSettings::EmailAddress);
596 } else { 596 } else {
597 return mEmail; 597 return mEmail;
598 } 598 }
599} 599}
600KConfig* KOPrefs::getConfig() 600KConfig* KOPrefs::getConfig()
601{ 601{
602 return config(); 602 return config();
603} 603}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 1bfdef9..873a776 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1590 +1,1591 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <qinputdialog.h> 32#include <qinputdialog.h>
33 33
34#include <qvbox.h> 34#include <qvbox.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include "koprefs.h" 36#include "koprefs.h"
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kdateedit.h> 39#include <kdateedit.h>
40#include "ktimeedit.h" 40#include "ktimeedit.h"
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43 43
44#include <libkcal/icaldrag.h> 44#include <libkcal/icaldrag.h>
45#include <libkcal/vcaldrag.h> 45#include <libkcal/vcaldrag.h>
46#include <libkcal/calfilter.h> 46#include <libkcal/calfilter.h>
47#include <libkcal/dndfactory.h> 47#include <libkcal/dndfactory.h>
48#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
49#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
50#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57#ifndef KORG_NOPRINTER 57#ifndef KORG_NOPRINTER
58#include "calprinter.h" 58#include "calprinter.h"
59#endif 59#endif
60#include "docprefs.h" 60#include "docprefs.h"
61 61
62#include "kotodoview.h" 62#include "kotodoview.h"
63using namespace KOrg; 63using namespace KOrg;
64 64
65 65
66KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : 66KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) :
67 QDialog( parent, name, true ) 67 QDialog( parent, name, true )
68{ 68{
69 mStopAll = true; 69 mStopAll = true;
70 setCaption( i18n("Start todo") ); 70 setCaption( i18n("Start todo") );
71 QVBoxLayout* lay = new QVBoxLayout( this ); 71 QVBoxLayout* lay = new QVBoxLayout( this );
72 lay->setSpacing( 3 ); 72 lay->setSpacing( 3 );
73 lay->setMargin( 3 ); 73 lay->setMargin( 3 );
74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); 74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this );
75 lay->addWidget( lab ); 75 lay->addWidget( lab );
76 lab->setAlignment( AlignCenter ); 76 lab->setAlignment( AlignCenter );
77 77
78 QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); 78 QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this );
79 lay->addWidget( ok ); 79 lay->addWidget( ok );
80 ok->setDefault( true ); 80 ok->setDefault( true );
81 QPushButton * start = new QPushButton( i18n("Start todo"), this ); 81 QPushButton * start = new QPushButton( i18n("Start todo"), this );
82 lay->addWidget( start ); 82 lay->addWidget( start );
83 QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); 83 QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this );
84 lay->addWidget( cancel ); 84 lay->addWidget( cancel );
85 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 85 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
86 connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); 86 connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) );
87 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 87 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
88 resize( sizeHint() ); 88 resize( sizeHint() );
89 89
90} 90}
91void KOStartTodoPrefs::doStop() 91void KOStartTodoPrefs::doStop()
92{ 92{
93 mStopAll = false; 93 mStopAll = false;
94 accept(); 94 accept();
95} 95}
96KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 96KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
97 QDialog( parent, name, true ) 97 QDialog( parent, name, true )
98{ 98{
99 mTodo = todo; 99 mTodo = todo;
100 setCaption( i18n("Stop todo") ); 100 setCaption( i18n("Stop todo") );
101 QVBoxLayout* lay = new QVBoxLayout( this ); 101 QVBoxLayout* lay = new QVBoxLayout( this );
102 lay->setSpacing( 3 ); 102 lay->setSpacing( 3 );
103 lay->setMargin( 3 ); 103 lay->setMargin( 3 );
104 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); 104 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this );
105 lay->addWidget( lab ); 105 lay->addWidget( lab );
106 lab->setAlignment( AlignHCenter ); 106 lab->setAlignment( AlignHCenter );
107 lab = new QLabel( i18n("Additional Comment:"), this ); 107 lab = new QLabel( i18n("Additional Comment:"), this );
108 lay->addWidget( lab ); 108 lay->addWidget( lab );
109 mComment = new QLineEdit( this ); 109 mComment = new QLineEdit( this );
110 lay->addWidget( mComment ); 110 lay->addWidget( mComment );
111 QHBox * start = new QHBox ( this ); 111 QHBox * start = new QHBox ( this );
112 lay->addWidget( start ); 112 lay->addWidget( start );
113 lab = new QLabel( i18n("Start:"), start ); 113 lab = new QLabel( i18n("Start:"), start );
114 QHBox * end = new QHBox ( this ); 114 QHBox * end = new QHBox ( this );
115 lay->addWidget( end ); 115 lay->addWidget( end );
116 lab = new QLabel( i18n("End:"), end ); 116 lab = new QLabel( i18n("End:"), end );
117 sde = new KDateEdit( start ); 117 sde = new KDateEdit( start );
118 ste = new KOTimeEdit( start ); 118 ste = new KOTimeEdit( start );
119 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); 119 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
120 ede = new KDateEdit( end ); 120 ede = new KDateEdit( end );
121 ete = new KOTimeEdit(end ); 121 ete = new KOTimeEdit(end );
122 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); 122 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
123 sde->setDate( mTodo->runStart().date() ); 123 sde->setDate( mTodo->runStart().date() );
124 ste->setTime( mTodo->runStart().time() ); 124 ste->setTime( mTodo->runStart().time() );
125 ede->setDate( QDate::currentDate()); 125 ede->setDate( QDate::currentDate());
126 ete->setTime( QTime::currentTime() ); 126 ete->setTime( QTime::currentTime() );
127 QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); 127 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
128 lay->addWidget( ok ); 128 lay->addWidget( ok );
129 ok->setDefault( true ); 129 ok->setDefault( true );
130 QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); 130 QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
131 lay->addWidget( cancel ); 131 lay->addWidget( cancel );
132 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 132 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
133 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 133 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
134 ok = new QPushButton( i18n("Stop - do not save"), this ); 134 ok = new QPushButton( i18n("Stop - do not save"), this );
135 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); 135 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
136 lay->addWidget( ok ); 136 lay->addWidget( ok );
137 if (QApplication::desktop()->width() < 320 ) 137 if (QApplication::desktop()->width() < 320 )
138 resize( 240, sizeHint().height() ); 138 resize( 240, sizeHint().height() );
139 else 139 else
140 resize( 320, sizeHint().height() ); 140 resize( 320, sizeHint().height() );
141 141
142} 142}
143 143
144void KOStopTodoPrefs::accept() 144void KOStopTodoPrefs::accept()
145{ 145{
146 QDateTime start = QDateTime( sde->date(), ste->getTime() ); 146 QDateTime start = QDateTime( sde->date(), ste->getTime() );
147 QDateTime stop = QDateTime( ede->date(), ete->getTime() ); 147 QDateTime stop = QDateTime( ede->date(), ete->getTime() );
148 if ( start > stop ) { 148 if ( start > stop ) {
149 KMessageBox::sorry(this, 149 KMessageBox::sorry(this,
150 i18n("The start time is\nafter the end time!"), 150 i18n("The start time is\nafter the end time!"),
151 i18n("Time mismatch!")); 151 i18n("Time mismatch!"));
152 return; 152 return;
153 } 153 }
154 mTodo->saveRunningInfo( mComment->text(), start, stop ); 154 mTodo->saveRunningInfo( mComment->text(), start, stop );
155 QDialog::accept(); 155 QDialog::accept();
156} 156}
157void KOStopTodoPrefs::doNotSave() 157void KOStopTodoPrefs::doNotSave()
158{ 158{
159 int result = KMessageBox::warningContinueCancel(this, 159 int result = KMessageBox::warningContinueCancel(this,
160 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); 160 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") );
161 if (result != KMessageBox::Continue) return; 161 if (result != KMessageBox::Continue) return;
162 mTodo->stopRunning(); 162 mTodo->stopRunning();
163 QDialog::accept(); 163 QDialog::accept();
164} 164}
165 165
166 166
167class KOTodoViewWhatsThis :public QWhatsThis 167class KOTodoViewWhatsThis :public QWhatsThis
168{ 168{
169public: 169public:
170 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 170 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
171 171
172protected: 172protected:
173 virtual QString text( const QPoint& p) 173 virtual QString text( const QPoint& p)
174 { 174 {
175 return _view->getWhatsThisText(p) ; 175 return _view->getWhatsThisText(p) ;
176 } 176 }
177private: 177private:
178 QWidget* _wid; 178 QWidget* _wid;
179 KOTodoView * _view; 179 KOTodoView * _view;
180}; 180};
181 181
182KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 182KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
183 const char *name) : 183 const char *name) :
184 KListView(parent,name) 184 KListView(parent,name)
185{ 185{
186 mName = QString ( name ); 186 mName = QString ( name );
187 mCalendar = calendar; 187 mCalendar = calendar;
188#ifndef DESKTOP_VERSION 188#ifndef DESKTOP_VERSION
189 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 189 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
190#endif 190#endif
191 mOldCurrent = 0; 191 mOldCurrent = 0;
192 mMousePressed = false; 192 mMousePressed = false;
193 193
194 setAcceptDrops(true); 194 setAcceptDrops(true);
195 viewport()->setAcceptDrops(true); 195 viewport()->setAcceptDrops(true);
196 int size = 16; 196 int size = 16;
197 if (qApp->desktop()->width() < 300 ) 197 if (qApp->desktop()->width() < 300 )
198 size = 12; 198 size = 12;
199 setTreeStepSize( size + 6 ); 199 setTreeStepSize( size + 6 );
200 200
201} 201}
202 202
203void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 203void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
204{ 204{
205#ifndef KORG_NODND 205#ifndef KORG_NODND
206// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 206// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
207 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 207 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
208 !QTextDrag::canDecode( e ) ) { 208 !QTextDrag::canDecode( e ) ) {
209 e->ignore(); 209 e->ignore();
210 return; 210 return;
211 } 211 }
212 212
213 mOldCurrent = currentItem(); 213 mOldCurrent = currentItem();
214#endif 214#endif
215} 215}
216 216
217 217
218void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 218void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
219{ 219{
220#ifndef KORG_NODND 220#ifndef KORG_NODND
221// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 221// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
222 222
223 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 223 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
224 !QTextDrag::canDecode( e ) ) { 224 !QTextDrag::canDecode( e ) ) {
225 e->ignore(); 225 e->ignore();
226 return; 226 return;
227 } 227 }
228 228
229 e->accept(); 229 e->accept();
230#endif 230#endif
231} 231}
232 232
233void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 233void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
234{ 234{
235#ifndef KORG_NODND 235#ifndef KORG_NODND
236// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 236// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
237 237
238 setCurrentItem(mOldCurrent); 238 setCurrentItem(mOldCurrent);
239 setSelected(mOldCurrent,true); 239 setSelected(mOldCurrent,true);
240#endif 240#endif
241} 241}
242 242
243void KOTodoListView::contentsDropEvent(QDropEvent *e) 243void KOTodoListView::contentsDropEvent(QDropEvent *e)
244{ 244{
245#ifndef KORG_NODND 245#ifndef KORG_NODND
246// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 246// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
247 247
248 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 248 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
249 !QTextDrag::canDecode( e ) ) { 249 !QTextDrag::canDecode( e ) ) {
250 e->ignore(); 250 e->ignore();
251 return; 251 return;
252 } 252 }
253 253
254 DndFactory factory( mCalendar ); 254 DndFactory factory( mCalendar );
255 Todo *todo = factory.createDropTodo(e); 255 Todo *todo = factory.createDropTodo(e);
256 256
257 if (todo) { 257 if (todo) {
258 e->acceptAction(); 258 e->acceptAction();
259 259
260 KOTodoViewItem *destination = 260 KOTodoViewItem *destination =
261 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 261 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
262 Todo *destinationEvent = 0; 262 Todo *destinationEvent = 0;
263 if (destination) destinationEvent = destination->todo(); 263 if (destination) destinationEvent = destination->todo();
264 264
265 Todo *existingTodo = mCalendar->todo(todo->uid()); 265 Todo *existingTodo = mCalendar->todo(todo->uid());
266 266
267 if(existingTodo) { 267 if(existingTodo) {
268 Incidence *to = destinationEvent; 268 Incidence *to = destinationEvent;
269 while(to) { 269 while(to) {
270 if (to->uid() == todo->uid()) { 270 if (to->uid() == todo->uid()) {
271 KMessageBox::sorry(this, 271 KMessageBox::sorry(this,
272 i18n("Cannot move Todo to itself\nor a child of itself"), 272 i18n("Cannot move Todo to itself\nor a child of itself"),
273 i18n("Drop Todo")); 273 i18n("Drop Todo"));
274 delete todo; 274 delete todo;
275 return; 275 return;
276 } 276 }
277 to = to->relatedTo(); 277 to = to->relatedTo();
278 } 278 }
279 internalDrop = true; 279 internalDrop = true;
280 if ( destinationEvent ) 280 if ( destinationEvent )
281 reparentTodoSignal( destinationEvent, existingTodo ); 281 reparentTodoSignal( destinationEvent, existingTodo );
282 else 282 else
283 unparentTodoSignal(existingTodo); 283 unparentTodoSignal(existingTodo);
284 delete todo; 284 delete todo;
285 } else { 285 } else {
286 mCalendar->addTodo(todo); 286 mCalendar->addTodo(todo);
287 emit todoDropped(todo, KOGlobals::EVENTADDED); 287 emit todoDropped(todo, KOGlobals::EVENTADDED);
288 if ( destinationEvent ) 288 if ( destinationEvent )
289 reparentTodoSignal( destinationEvent, todo ); 289 reparentTodoSignal( destinationEvent, todo );
290 } 290 }
291 } 291 }
292 else { 292 else {
293 QString text; 293 QString text;
294 if (QTextDrag::decode(e,text)) { 294 if (QTextDrag::decode(e,text)) {
295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
297 qDebug("Dropped : " + text); 297 qDebug("Dropped : " + text);
298 QStringList emails = QStringList::split(",",text); 298 QStringList emails = QStringList::split(",",text);
299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
300 int pos = (*it).find("<"); 300 int pos = (*it).find("<");
301 QString name = (*it).left(pos); 301 QString name = (*it).left(pos);
302 QString email = (*it).mid(pos); 302 QString email = (*it).mid(pos);
303 if (!email.isEmpty() && todoi) { 303 if (!email.isEmpty() && todoi) {
304 todoi->todo()->addAttendee(new Attendee(name,email)); 304 todoi->todo()->addAttendee(new Attendee(name,email));
305 } 305 }
306 } 306 }
307 } 307 }
308 else { 308 else {
309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
310 e->ignore(); 310 e->ignore();
311 } 311 }
312 } 312 }
313#endif 313#endif
314} 314}
315void KOTodoListView::wheelEvent (QWheelEvent *e) 315void KOTodoListView::wheelEvent (QWheelEvent *e)
316{ 316{
317 QListView::wheelEvent (e); 317 QListView::wheelEvent (e);
318} 318}
319 319
320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
321{ 321{
322 322
323 QPoint p(contentsToViewport(e->pos())); 323 QPoint p(contentsToViewport(e->pos()));
324 QListViewItem *i = itemAt(p); 324 QListViewItem *i = itemAt(p);
325 bool rootClicked = true; 325 bool rootClicked = true;
326 if (i) { 326 if (i) {
327 // if the user clicked into the root decoration of the item, don't 327 // if the user clicked into the root decoration of the item, don't
328 // try to start a drag! 328 // try to start a drag!
329 int X = p.x(); 329 int X = p.x();
330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
331 if (X > header()->sectionPos(0) + 331 if (X > header()->sectionPos(0) +
332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
333 itemMargin() +i->height()|| 333 itemMargin() +i->height()||
334 X < header()->sectionPos(0)) { 334 X < header()->sectionPos(0)) {
335 rootClicked = false; 335 rootClicked = false;
336 } 336 }
337 } else { 337 } else {
338 rootClicked = false; 338 rootClicked = false;
339 } 339 }
340#ifndef KORG_NODND 340#ifndef KORG_NODND
341 mMousePressed = false; 341 mMousePressed = false;
342 if (! rootClicked && !( e->button() == RightButton) ) { 342 if (! rootClicked && !( e->button() == RightButton) ) {
343 mPressPos = e->pos(); 343 mPressPos = e->pos();
344 mMousePressed = true; 344 mMousePressed = true;
345 } else { 345 } else {
346 mMousePressed = false; 346 mMousePressed = false;
347 } 347 }
348#endif 348#endif
349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
350#ifndef DESKTOP_VERSION 350#ifndef DESKTOP_VERSION
351 if (!( e->button() == RightButton && rootClicked) ) 351 if (!( e->button() == RightButton && rootClicked) )
352 QListView::contentsMousePressEvent(e); 352 QListView::contentsMousePressEvent(e);
353#else 353#else
354 QListView::contentsMousePressEvent(e); 354 QListView::contentsMousePressEvent(e);
355#endif 355#endif
356} 356}
357void KOTodoListView::paintEvent(QPaintEvent* e) 357void KOTodoListView::paintEvent(QPaintEvent* e)
358{ 358{
359 emit paintNeeded(); 359 emit paintNeeded();
360 QListView::paintEvent( e); 360 QListView::paintEvent( e);
361} 361}
362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
363{ 363{
364 364
365#ifndef KORG_NODND 365#ifndef KORG_NODND
366 //QListView::contentsMouseMoveEvent(e); 366 //QListView::contentsMouseMoveEvent(e);
367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
368 QApplication::startDragDistance()*3) { 368 QApplication::startDragDistance()*3) {
369 mMousePressed = false; 369 mMousePressed = false;
370 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 370 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
371 if (item) { 371 if (item) {
372 DndFactory factory( mCalendar ); 372 DndFactory factory( mCalendar );
373 ICalDrag *vd = factory.createDrag( 373 ICalDrag *vd = factory.createDrag(
374 ((KOTodoViewItem *)item)->todo(),viewport()); 374 ((KOTodoViewItem *)item)->todo(),viewport());
375 internalDrop = false; 375 internalDrop = false;
376 // we cannot do any senseful here, because the DnD is still broken in Qt 376 // we cannot do any senseful here, because the DnD is still broken in Qt
377 if (vd->drag()) { 377 if (vd->drag()) {
378 if ( !internalDrop ) { 378 if ( !internalDrop ) {
379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
380 qDebug("Dnd: External move: Delete drag source "); 380 qDebug("Dnd: External move: Delete drag source ");
381 } else 381 } else
382 qDebug("Dnd: Internal move "); 382 qDebug("Dnd: Internal move ");
383 383
384 } else { 384 } else {
385 if ( !internalDrop ) { 385 if ( !internalDrop ) {
386 qDebug("Dnd: External Copy"); 386 qDebug("Dnd: External Copy");
387 } else 387 } else
388 qDebug("DnD: Internal copy: Copy pending"); 388 qDebug("DnD: Internal copy: Copy pending");
389 } 389 }
390 } 390 }
391 } 391 }
392#endif 392#endif
393} 393}
394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
395{ 395{
396 if ( !e->isAutoRepeat() ) { 396 if ( !e->isAutoRepeat() ) {
397 mFlagKeyPressed = false; 397 mFlagKeyPressed = false;
398 } 398 }
399} 399}
400 400
401 401
402void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 402void KOTodoListView::keyPressEvent ( QKeyEvent * e )
403{ 403{
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,
596 SLOT (newSubTodo())); 597 SLOT (newSubTodo()));
597 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 598 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
598 SLOT (unparentTodo()),0,21); 599 SLOT (unparentTodo()),0,21);
599 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 600 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
600 SLOT (reparentTodo()),0,22); 601 SLOT (reparentTodo()),0,22);
601 mItemPopupMenu->insertSeparator(); 602 mItemPopupMenu->insertSeparator();
602#if 0 603#if 0
603 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 604 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
604 this, SLOT( purgeCompleted() ) ); 605 this, SLOT( purgeCompleted() ) );
605 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 606 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
606 this, SLOT( toggleCompleted() ),0, 33 ); 607 this, SLOT( toggleCompleted() ),0, 33 );
607 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 608 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
608 this, SLOT( toggleQuickTodo() ),0, 34 ); 609 this, SLOT( toggleQuickTodo() ),0, 34 );
609 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 610 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
610 this, SLOT( toggleRunning() ),0, 35 ); 611 this, SLOT( toggleRunning() ),0, 35 );
611 612
612#endif 613#endif
613 mPopupMenu = new QPopupMenu(this); 614 mPopupMenu = new QPopupMenu(this);
614 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 615 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
615 SLOT (newTodo()),0,1); 616 SLOT (newTodo()),0,1);
616 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 617 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
617 this, SLOT(purgeCompleted()),0,2); 618 this, SLOT(purgeCompleted()),0,2);
618 mPopupMenu->insertItem(i18n("Show Completed"), 619 mPopupMenu->insertItem(i18n("Show Completed"),
619 this, SLOT( toggleCompleted() ),0,3 ); 620 this, SLOT( toggleCompleted() ),0,3 );
620 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 621 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
621 this, SLOT( toggleRunning() ),0,5 ); 622 this, SLOT( toggleRunning() ),0,5 );
622 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 623 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
623 this, SLOT( setAllOpen() ),0,6 ); 624 this, SLOT( setAllOpen() ),0,6 );
624 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 625 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
625 this, SLOT( setAllClose() ),0,7 ); 626 this, SLOT( setAllClose() ),0,7 );
626 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 627 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
627 this, SLOT( setAllFlat() ),0,8 ); 628 this, SLOT( setAllFlat() ),0,8 );
628 mPopupMenu->insertSeparator(); 629 mPopupMenu->insertSeparator();
629 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 630 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
630 this, SLOT( toggleQuickTodo() ),0,4 ); 631 this, SLOT( toggleQuickTodo() ),0,4 );
631 mDocPrefs = new DocPrefs( name ); 632 mDocPrefs = new DocPrefs( name );
632 633
633 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 634 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
634 mPopupMenu->setCheckable( true ); 635 mPopupMenu->setCheckable( true );
635 mItemPopupMenu->setCheckable( true ); 636 mItemPopupMenu->setCheckable( true );
636 637
637 638
638 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 639 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
639 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 640 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
640 641
641 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 642 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
642 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 643 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
643 644
644 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 645 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
645 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 646 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
646 647
647 648
648 // Double clicking conflicts with opening/closing the subtree 649 // Double clicking conflicts with opening/closing the subtree
649 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 650 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
650 SLOT( editItem( QListViewItem *) ) ); 651 SLOT( editItem( QListViewItem *) ) );
651 /* 652 /*
652 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 653 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
653 const QPoint &,int ) ), 654 const QPoint &,int ) ),
654 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 655 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
655 */ 656 */
656 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 657 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
657 const QPoint &,int ) ), 658 const QPoint &,int ) ),
658 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 659 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
659 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 660 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
660 SLOT( itemClicked( QListViewItem * ) ) ); 661 SLOT( itemClicked( QListViewItem * ) ) );
661 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 662 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
662 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 663 SLOT( itemDoubleClicked( QListViewItem * ) ) );
663 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 664 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
664 SLOT( updateView() ) ); 665 SLOT( updateView() ) );
665 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 666 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
666 SLOT( todoModified(Todo *, int) ) ); 667 SLOT( todoModified(Todo *, int) ) );
667 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 668 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
668 SLOT( itemStateChanged( QListViewItem * ) ) ); 669 SLOT( itemStateChanged( QListViewItem * ) ) );
669 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 670 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
670 SLOT( itemStateChanged( QListViewItem * ) ) ); 671 SLOT( itemStateChanged( QListViewItem * ) ) );
671 connect( mTodoListView, SIGNAL( paintNeeded() ), 672 connect( mTodoListView, SIGNAL( paintNeeded() ),
672 SLOT( paintNeeded()) ); 673 SLOT( paintNeeded()) );
673 674
674#if 0 675#if 0
675 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 676 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
676 SLOT(selectionChanged(QListViewItem *))); 677 SLOT(selectionChanged(QListViewItem *)));
677 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 678 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
678 SLOT(selectionChanged(QListViewItem *))); 679 SLOT(selectionChanged(QListViewItem *)));
679 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 680 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
680 SLOT(selectionChanged(QListViewItem *))); 681 SLOT(selectionChanged(QListViewItem *)));
681#endif 682#endif
682 683
683 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 684 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
684 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 685 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
685 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 686 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
686 687
687 connect( mTodoListView, SIGNAL(selectionChanged() ), 688 connect( mTodoListView, SIGNAL(selectionChanged() ),
688 SLOT( processSelectionChange() ) ); 689 SLOT( processSelectionChange() ) );
689 connect( mQuickAdd, SIGNAL( returnPressed () ), 690 connect( mQuickAdd, SIGNAL( returnPressed () ),
690 SLOT( addQuickTodo() ) ); 691 SLOT( addQuickTodo() ) );
691 692
692} 693}
693 694
694KOTodoView::~KOTodoView() 695KOTodoView::~KOTodoView()
695{ 696{
696 697
697#if QT_VERSION >= 0x030000 698#if QT_VERSION >= 0x030000
698 699
699#else 700#else
700 delete mKOTodoViewWhatsThis; 701 delete mKOTodoViewWhatsThis;
701#endif 702#endif
702 703
703 delete mDocPrefs; 704 delete mDocPrefs;
704} 705}
705QString KOTodoView::getWhatsThisText(QPoint p) 706QString KOTodoView::getWhatsThisText(QPoint p)
706{ 707{
707 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 708 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
708 if ( item ) 709 if ( item )
709 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 710 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
710 KOPrefs::instance()->mWTshowDetails, 711 KOPrefs::instance()->mWTshowDetails,
711 KOPrefs::instance()->mWTshowCreated, 712 KOPrefs::instance()->mWTshowCreated,
712 KOPrefs::instance()->mWTshowChanged); 713 KOPrefs::instance()->mWTshowChanged);
713 return i18n("That is the todo view" ); 714 return i18n("That is the todo view" );
714 715
715} 716}
716 717
717void KOTodoView::jumpToDate () 718void KOTodoView::jumpToDate ()
718{ 719{
719 // if (mActiveItem) { 720 // if (mActiveItem) {
720// mActiveItem->todo()); 721// mActiveItem->todo());
721// if ( mActiveItem->todo()->hasDueDate() ) 722// if ( mActiveItem->todo()->hasDueDate() )
722// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 723// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
723} 724}
724void KOTodoView::paintNeeded() 725void KOTodoView::paintNeeded()
725{ 726{
726 if ( mPendingUpdateBeforeRepaint ) { 727 if ( mPendingUpdateBeforeRepaint ) {
727 updateView(); 728 updateView();
728 mPendingUpdateBeforeRepaint = false; 729 mPendingUpdateBeforeRepaint = false;
729 } 730 }
730} 731}
731void KOTodoView::paintEvent(QPaintEvent * pevent) 732void KOTodoView::paintEvent(QPaintEvent * pevent)
732{ 733{
733 if ( mPendingUpdateBeforeRepaint ) { 734 if ( mPendingUpdateBeforeRepaint ) {
734 updateView(); 735 updateView();
735 mPendingUpdateBeforeRepaint = false; 736 mPendingUpdateBeforeRepaint = false;
736 } 737 }
737 KOrg::BaseView::paintEvent( pevent); 738 KOrg::BaseView::paintEvent( pevent);
738} 739}
739 740
740void KOTodoView::updateView() 741void KOTodoView::updateView()
741{ 742{
742 pendingSubtodo = 0; 743 pendingSubtodo = 0;
743 if ( mBlockUpdate ) { 744 if ( mBlockUpdate ) {
744 return; 745 return;
745 } 746 }
746 if ( !isVisible() ) { 747 if ( !isVisible() ) {
747 mPendingUpdateBeforeRepaint = true; 748 mPendingUpdateBeforeRepaint = true;
748 return; 749 return;
749 } 750 }
750 storeCurrentItem(); 751 storeCurrentItem();
751 //qDebug("KOTodoView::updateView() %x", this); 752 //qDebug("KOTodoView::updateView() %x", this);
752 if ( isFlatDisplay ) { 753 if ( isFlatDisplay ) {
753 displayAllFlat(); 754 displayAllFlat();
754 resetCurrentItem(); 755 resetCurrentItem();
755 return; 756 return;
756 } 757 }
757 //qDebug("update "); 758 //qDebug("update ");
758// kdDebug() << "KOTodoView::updateView()" << endl; 759// kdDebug() << "KOTodoView::updateView()" << endl;
759 QFont fo = KOPrefs::instance()->mTodoViewFont; 760 QFont fo = KOPrefs::instance()->mTodoViewFont;
760 761
761 762
762 mTodoListView->clear(); 763 mTodoListView->clear();
763 if ( mName == "todolistsmall" ) { 764 if ( mName == "todolistsmall" ) {
764 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 765 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
765 int ps = fo.pointSize() -2; 766 int ps = fo.pointSize() -2;
766 if ( ps > 12 ) 767 if ( ps > 12 )
767 ps -= 2; 768 ps -= 2;
768 fo.setPointSize( ps ); 769 fo.setPointSize( ps );
769 } 770 }
770 } 771 }
771 772
772 mTodoListView->setFont( fo ); 773 mTodoListView->setFont( fo );
773 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 774 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
774 //mTodoListView->header()->setMaximumHeight(fm.height()); 775 //mTodoListView->header()->setMaximumHeight(fm.height());
775 QPtrList<Todo> todoList = calendar()->todos(); 776 QPtrList<Todo> todoList = calendar()->todos();
776 777
777/* 778/*
778 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 779 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
779 Event *t; 780 Event *t;
780 for(t = todoList.first(); t; t = todoList.next()) { 781 for(t = todoList.first(); t; t = todoList.next()) {
781 kdDebug() << " " << t->getSummary() << endl; 782 kdDebug() << " " << t->getSummary() << endl;
782 783
783 if (t->getRelatedTo()) { 784 if (t->getRelatedTo()) {
784 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 785 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
785 } 786 }
786 787
787 QPtrList<Event> l = t->getRelations(); 788 QPtrList<Event> l = t->getRelations();
788 Event *c; 789 Event *c;
789 for(c=l.first();c;c=l.next()) { 790 for(c=l.first();c;c=l.next()) {
790 kdDebug() << " - relation: " << c->getSummary() << endl; 791 kdDebug() << " - relation: " << c->getSummary() << endl;
791 } 792 }
792 } 793 }
793*/ 794*/
794 795
795 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 796 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
796 // specific order of events. That means that we have to generate parent items 797 // specific order of events. That means that we have to generate parent items
797 // recursively for proper hierarchical display of Todos. 798 // recursively for proper hierarchical display of Todos.
798 mTodoMap.clear(); 799 mTodoMap.clear();
799 Todo *todo; 800 Todo *todo;
800 todo = todoList.first();// todo; todo = todoList.next()) { 801 todo = todoList.first();// todo; todo = todoList.next()) {
801 while ( todo ) { 802 while ( todo ) {
802 bool next = true; 803 bool next = true;
803 // qDebug("todo %s ", todo->summary().latin1()); 804 // qDebug("todo %s ", todo->summary().latin1());
804 Incidence *incidence = todo->relatedTo(); 805 Incidence *incidence = todo->relatedTo();
805 while ( incidence ) { 806 while ( incidence ) {
806 if ( incidence->typeID() == todoID ) { 807 if ( incidence->typeID() == todoID ) {
807 //qDebug("related %s ",incidence->summary().latin1() ); 808 //qDebug("related %s ",incidence->summary().latin1() );
808 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { 809 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) {
809 //qDebug("related not found "); 810 //qDebug("related not found ");
810 todoList.remove( ); 811 todoList.remove( );
811 todo = todoList.current(); 812 todo = todoList.current();
812 next = false; 813 next = false;
813 incidence = 0; 814 incidence = 0;
814 815
815 } else { 816 } else {
816 //qDebug("related found "); 817 //qDebug("related found ");
817 incidence = incidence->relatedTo(); 818 incidence = incidence->relatedTo();
818 } 819 }
819 } else 820 } else
820 incidence = 0; 821 incidence = 0;
821 } 822 }
822 if ( next ) 823 if ( next )
823 todo = todoList.next(); 824 todo = todoList.next();
824 } 825 }
825 826
826 for(todo = todoList.first(); todo; todo = todoList.next()) { 827 for(todo = todoList.first(); todo; todo = todoList.next()) {
827 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 828 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
828 { 829 {
829 insertTodoItem(todo); 830 insertTodoItem(todo);
830 } 831 }
831 } 832 }
832 // Restore opened/closed state 833 // Restore opened/closed state
833 mTodoListView->blockSignals( true ); 834 mTodoListView->blockSignals( true );
834 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 835 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
835 mTodoListView->blockSignals( false ); 836 mTodoListView->blockSignals( false );
836 resetCurrentItem(); 837 resetCurrentItem();
837 processSelectionChange(); 838 processSelectionChange();
838} 839}
839 840
840void KOTodoView::storeCurrentItem() 841void KOTodoView::storeCurrentItem()
841{ 842{
842 mCurItem = 0; 843 mCurItem = 0;
843 mCurItemRootParent = 0; 844 mCurItemRootParent = 0;
844 mCurItemParent = 0; 845 mCurItemParent = 0;
845 mCurItemAbove = 0; 846 mCurItemAbove = 0;
846 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 847 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
847 if (mActiveItem) { 848 if (mActiveItem) {
848 mCurItem = mActiveItem->todo(); 849 mCurItem = mActiveItem->todo();
849 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 850 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
850 if ( activeItemAbove ) 851 if ( activeItemAbove )
851 mCurItemAbove = activeItemAbove->todo(); 852 mCurItemAbove = activeItemAbove->todo();
852 mCurItemRootParent = mCurItem; 853 mCurItemRootParent = mCurItem;
853 mCurItemParent = mCurItemRootParent->relatedTo(); 854 mCurItemParent = mCurItemRootParent->relatedTo();
854 while ( mCurItemRootParent->relatedTo() != 0 ) 855 while ( mCurItemRootParent->relatedTo() != 0 )
855 mCurItemRootParent = mCurItemRootParent->relatedTo(); 856 mCurItemRootParent = mCurItemRootParent->relatedTo();
856 } 857 }
857 mActiveItem = 0; 858 mActiveItem = 0;
858} 859}
859 860
860void KOTodoView::resetCurrentItem() 861void KOTodoView::resetCurrentItem()
861{ 862{
862 mTodoListView->setFocus(); 863 mTodoListView->setFocus();
863 KOTodoViewItem* foundItem = 0; 864 KOTodoViewItem* foundItem = 0;
864 KOTodoViewItem* foundItemRoot = 0; 865 KOTodoViewItem* foundItemRoot = 0;
865 KOTodoViewItem* foundItemParent = 0; 866 KOTodoViewItem* foundItemParent = 0;
866 KOTodoViewItem* foundItemAbove = 0; 867 KOTodoViewItem* foundItemAbove = 0;
867 if ( mTodoListView->firstChild () ) { 868 if ( mTodoListView->firstChild () ) {
868 if ( mCurItem ) { 869 if ( mCurItem ) {
869 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 870 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
870 while ( item ) { 871 while ( item ) {
871 if ( item->todo() == mCurItem ) { 872 if ( item->todo() == mCurItem ) {
872 foundItem = item; 873 foundItem = item;
873 break; 874 break;
874 } else if ( item->todo() == mCurItemAbove ) { 875 } else if ( item->todo() == mCurItemAbove ) {
875 foundItemAbove = item; 876 foundItemAbove = item;
876 877
877 } 878 }
878 if ( item->todo() == mCurItemRootParent ) { 879 if ( item->todo() == mCurItemRootParent ) {
879 foundItemRoot = item; 880 foundItemRoot = item;
880 } 881 }
881 if ( item->todo() == mCurItemParent ) { 882 if ( item->todo() == mCurItemParent ) {
882 foundItemParent = item; 883 foundItemParent = item;
883 } 884 }
884 item = (KOTodoViewItem*)item->itemBelow(); 885 item = (KOTodoViewItem*)item->itemBelow();
885 } 886 }
886 if ( ! foundItem ) { 887 if ( ! foundItem ) {
887 if ( foundItemParent ) { 888 if ( foundItemParent ) {
888 foundItem = foundItemParent; 889 foundItem = foundItemParent;
889 } else { 890 } else {
890 if ( foundItemRoot ) 891 if ( foundItemRoot )
891 foundItem = foundItemRoot; 892 foundItem = foundItemRoot;
892 else 893 else
893 foundItem = foundItemAbove; 894 foundItem = foundItemAbove;
894 } 895 }
895 } 896 }
896 } 897 }
897 if ( foundItem ) { 898 if ( foundItem ) {
898 mTodoListView->setCurrentItem( foundItem ); 899 mTodoListView->setCurrentItem( foundItem );
899 mTodoListView->ensureItemVisible( foundItem ); 900 mTodoListView->ensureItemVisible( foundItem );
900 } else { 901 } else {
901 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 902 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
902 } 903 }
903 } 904 }
904 mTodoListView->setFocus(); 905 mTodoListView->setFocus();
905} 906}
906//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 907//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
907bool KOTodoView::checkTodo( Todo * todo ) 908bool KOTodoView::checkTodo( Todo * todo )
908{ 909{
909 910
910 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 911 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
911 return false; 912 return false;
912 if ( !todo->isCompleted() ) { 913 if ( !todo->isCompleted() ) {
913 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 914 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
914 return true; 915 return true;
915 } 916 }
916 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 917 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
917 if ( todo->hasStartDate() ) 918 if ( todo->hasStartDate() )
918 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 919 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
919 return false; 920 return false;
920 if ( todo->hasDueDate() ) 921 if ( todo->hasDueDate() )
921 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 922 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
922 return false; 923 return false;
923 } 924 }
924 return true; 925 return true;
925} 926}
926 927
927void KOTodoView::restoreItemState( QListViewItem *item ) 928void KOTodoView::restoreItemState( QListViewItem *item )
928{ 929{
929 pendingSubtodo = 0; 930 pendingSubtodo = 0;
930 while( item ) { 931 while( item ) {
931 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 932 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
932 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 933 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
933 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 934 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
934 item = item->nextSibling(); 935 item = item->nextSibling();
935 } 936 }
936} 937}
937 938
938 939
939QMap<Todo *,KOTodoViewItem *>::ConstIterator 940QMap<Todo *,KOTodoViewItem *>::ConstIterator
940KOTodoView::insertTodoItem(Todo *todo) 941KOTodoView::insertTodoItem(Todo *todo)
941{ 942{
942 943
943 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 944 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
944 // TODO: Check, if dynmaic cast is necessary 945 // TODO: Check, if dynmaic cast is necessary
945 946
946 pendingSubtodo = 0; 947 pendingSubtodo = 0;
947 Incidence *incidence = todo->relatedTo(); 948 Incidence *incidence = todo->relatedTo();
948 while ( incidence && !incidence->calEnabled() ) 949 while ( incidence && !incidence->calEnabled() )
949 incidence = incidence->relatedTo(); 950 incidence = incidence->relatedTo();
950 if (incidence && incidence->typeID() == todoID ) { 951 if (incidence && incidence->typeID() == todoID ) {
951 Todo *relatedTodo = static_cast<Todo *>(incidence); 952 Todo *relatedTodo = static_cast<Todo *>(incidence);
952 953
953 // kdDebug() << " has Related" << endl; 954 // kdDebug() << " has Related" << endl;
954 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 955 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
955 itemIterator = mTodoMap.find(relatedTodo); 956 itemIterator = mTodoMap.find(relatedTodo);
956 if (itemIterator == mTodoMap.end()) { 957 if (itemIterator == mTodoMap.end()) {
957 // kdDebug() << " related not yet in list" << endl; 958 // kdDebug() << " related not yet in list" << endl;
958 itemIterator = insertTodoItem (relatedTodo); 959 itemIterator = insertTodoItem (relatedTodo);
959 } 960 }
960 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 961 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
961 // and one into the map. Sure finding is more easy but why? -zecke 962 // and one into the map. Sure finding is more easy but why? -zecke
962 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 963 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
963 return mTodoMap.insert(todo,todoItem); 964 return mTodoMap.insert(todo,todoItem);
964 } else { 965 } else {
965 // kdDebug() << " no Related" << endl; 966 // kdDebug() << " no Related" << endl;
966 // see above -zecke 967 // see above -zecke
967 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 968 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
968 return mTodoMap.insert(todo,todoItem); 969 return mTodoMap.insert(todo,todoItem);
969 } 970 }
970} 971}
971 972
972 973
973void KOTodoView::updateConfig() 974void KOTodoView::updateConfig()
974{ 975{
975 updateView(); 976 updateView();
976 mTodoListView->repaintContents(); 977 mTodoListView->repaintContents();
977} 978}
978 979
979QPtrList<Incidence> KOTodoView::selectedIncidences() 980QPtrList<Incidence> KOTodoView::selectedIncidences()
980{ 981{
981 QPtrList<Incidence> selected; 982 QPtrList<Incidence> selected;
982 983
983 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 984 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
984// if (!item) item = mActiveItem; 985// if (!item) item = mActiveItem;
985 if (item) selected.append(item->todo()); 986 if (item) selected.append(item->todo());
986 987
987 return selected; 988 return selected;
988} 989}
989 990
990QPtrList<Todo> KOTodoView::selectedTodos() 991QPtrList<Todo> KOTodoView::selectedTodos()
991{ 992{
992 QPtrList<Todo> selected; 993 QPtrList<Todo> selected;
993 994
994 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 995 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
995// if (!item) item = mActiveItem; 996// if (!item) item = mActiveItem;
996 if (item) selected.append(item->todo()); 997 if (item) selected.append(item->todo());
997 998
998 return selected; 999 return selected;
999} 1000}
1000 1001
1001void KOTodoView::changeEventDisplay(Event *, int) 1002void KOTodoView::changeEventDisplay(Event *, int)
1002{ 1003{
1003 updateView(); 1004 updateView();
1004} 1005}
1005 1006
1006void KOTodoView::showDates(const QDate &, const QDate &) 1007void KOTodoView::showDates(const QDate &, const QDate &)
1007{ 1008{
1008} 1009}
1009 1010
1010void KOTodoView::showEvents(QPtrList<Event>) 1011void KOTodoView::showEvents(QPtrList<Event>)
1011{ 1012{
1012 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 1013 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
1013} 1014}
1014 1015
1015void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1016void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1016 const QDate &td) 1017 const QDate &td)
1017{ 1018{
1018#ifndef KORG_NOPRINTER 1019#ifndef KORG_NOPRINTER
1019 calPrinter->preview(CalPrinter::Todolist, fd, td); 1020 calPrinter->preview(CalPrinter::Todolist, fd, td);
1020#endif 1021#endif
1021} 1022}
1022 1023
1023void KOTodoView::editItem(QListViewItem *item ) 1024void KOTodoView::editItem(QListViewItem *item )
1024{ 1025{
1025 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 1026 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
1026} 1027}
1027 1028
1028void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 1029void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
1029{ 1030{
1030 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 1031 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
1031} 1032}
1032 1033
1033void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 1034void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
1034{ 1035{
1035 pendingSubtodo = 0; 1036 pendingSubtodo = 0;
1036 mActiveItem = (KOTodoViewItem *)item; 1037 mActiveItem = (KOTodoViewItem *)item;
1037 if (item) { 1038 if (item) {
1038 switch (column){ 1039 switch (column){
1039 case 1: 1040 case 1:
1040 mPriorityPopupMenu->popup(QCursor::pos ()); break; 1041 mPriorityPopupMenu->popup(QCursor::pos ()); break;
1041 case 2: 1042 case 2:
1042 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 1043 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
1043 case 3: 1044 case 3:
1044 moveTodo(); 1045 moveTodo();
1045 break; 1046 break;
1046 case 8: 1047 case 8:
1047 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 1048 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
1048 default: 1049 default:
1049 mItemPopupMenu->popup(QCursor::pos()); 1050 mItemPopupMenu->popup(QCursor::pos());
1050 } 1051 }
1051 } else mPopupMenu->popup(QCursor::pos()); 1052 } else mPopupMenu->popup(QCursor::pos());
1052} 1053}
1053void KOTodoView::newTodo() 1054void KOTodoView::newTodo()
1054{ 1055{
1055 emit newTodoSignal(); 1056 emit newTodoSignal();
1056} 1057}
1057 1058
1058void KOTodoView::newSubTodo() 1059void KOTodoView::newSubTodo()
1059{ 1060{
1060 if (mActiveItem) { 1061 if (mActiveItem) {
1061 emit newSubTodoSignal(mActiveItem->todo()); 1062 emit newSubTodoSignal(mActiveItem->todo());
1062 } 1063 }
1063} 1064}
1064void KOTodoView::unparentTodo() 1065void 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();
1273 t->setRunning( true ); 1274 t->setRunning( true );
1274 updateView(); 1275 updateView();
1275 } else { 1276 } else {
1276 t->setRunning( true ); 1277 t->setRunning( true );
1277 mActiveItem->construct(); 1278 mActiveItem->construct();
1278 } 1279 }
1279 } 1280 }
1280} 1281}
1281 1282
1282void KOTodoView::itemClicked(QListViewItem *item) 1283void KOTodoView::itemClicked(QListViewItem *item)
1283{ 1284{
1284 //qDebug("KOTodoView::itemClicked %d", item); 1285 //qDebug("KOTodoView::itemClicked %d", item);
1285 if (!item) { 1286 if (!item) {
1286 if ( pendingSubtodo != 0 ) { 1287 if ( pendingSubtodo != 0 ) {
1287 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1288 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1288 } 1289 }
1289 pendingSubtodo = 0; 1290 pendingSubtodo = 0;
1290 return; 1291 return;
1291 } 1292 }
1292 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1293 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1293 if ( pendingSubtodo != 0 ) { 1294 if ( pendingSubtodo != 0 ) {
1294 bool allowReparent = true; 1295 bool allowReparent = true;
1295 QListViewItem *par = item; 1296 QListViewItem *par = item;
1296 while ( par ) { 1297 while ( par ) {
1297 if ( par == pendingSubtodo ) { 1298 if ( par == pendingSubtodo ) {
1298 allowReparent = false; 1299 allowReparent = false;
1299 break; 1300 break;
1300 } 1301 }
1301 par = par->parent(); 1302 par = par->parent();
1302 } 1303 }
1303 if ( !allowReparent ) { 1304 if ( !allowReparent ) {
1304 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1305 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1305 pendingSubtodo = 0; 1306 pendingSubtodo = 0;
1306 } else { 1307 } else {
1307 Todo* newParent = todoItem->todo(); 1308 Todo* newParent = todoItem->todo();
1308 Todo* newSub = pendingSubtodo->todo(); 1309 Todo* newSub = pendingSubtodo->todo();
1309 pendingSubtodo = 0; 1310 pendingSubtodo = 0;
1310 emit reparentTodoSignal( newParent,newSub ); 1311 emit reparentTodoSignal( newParent,newSub );
1311 return; 1312 return;
1312 } 1313 }
1313 } 1314 }
1314 1315
1315} 1316}
1316 1317
1317void KOTodoView::setDocumentId( const QString &id ) 1318void KOTodoView::setDocumentId( const QString &id )
1318{ 1319{
1319 1320
1320 mDocPrefs->setDoc( id ); 1321 mDocPrefs->setDoc( id );
1321} 1322}
1322 1323
1323void KOTodoView::itemStateChanged( QListViewItem *item ) 1324void KOTodoView::itemStateChanged( QListViewItem *item )
1324{ 1325{
1325 if (!item) return; 1326 if (!item) return;
1326 1327
1327 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1328 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1328 1329
1329// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1330// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1330 1331
1331 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1332 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1332} 1333}
1333 1334
1334void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1335void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1335{ 1336{
1336 mTodoListView->saveLayout(config,group); 1337 mTodoListView->saveLayout(config,group);
1337} 1338}
1338 1339
1339void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1340void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1340{ 1341{
1341 mTodoListView->restoreLayout(config,group); 1342 mTodoListView->restoreLayout(config,group);
1342} 1343}
1343 1344
1344void KOTodoView::processSelectionChange() 1345void KOTodoView::processSelectionChange()
1345{ 1346{
1346// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1347// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1347 1348
1348 KOTodoViewItem *item = 1349 KOTodoViewItem *item =
1349 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1350 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1350 1351
1351 if ( !item ) { 1352 if ( !item ) {
1352 emit incidenceSelected( 0 ); 1353 emit incidenceSelected( 0 );
1353 } else { 1354 } else {
1354 emit incidenceSelected( item->todo() ); 1355 emit incidenceSelected( item->todo() );
1355 } 1356 }
1356} 1357}
1357 1358
1358void KOTodoView::modified(bool b) 1359void KOTodoView::modified(bool b)
1359{ 1360{
1360 emit isModified(b); 1361 emit isModified(b);
1361} 1362}
1362void KOTodoView::setTodoModified( Todo* todo ) 1363void KOTodoView::setTodoModified( Todo* todo )
1363{ 1364{
1364 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1365 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1365} 1366}
1366void KOTodoView::clearSelection() 1367void KOTodoView::clearSelection()
1367{ 1368{
1368 mTodoListView->selectAll( false ); 1369 mTodoListView->selectAll( false );
1369} 1370}
1370void KOTodoView::setAllOpen() 1371void KOTodoView::setAllOpen()
1371{ 1372{
1372 if ( isFlatDisplay ) { 1373 if ( isFlatDisplay ) {
1373 isFlatDisplay = false; 1374 isFlatDisplay = false;
1374 mPopupMenu->setItemChecked( 8,false ); 1375 mPopupMenu->setItemChecked( 8,false );
1375 updateView(); 1376 updateView();
1376 } else { 1377 } else {
1377 storeCurrentItem(); 1378 storeCurrentItem();
1378 } 1379 }
1379 setOpen(mTodoListView->firstChild(), true); 1380 setOpen(mTodoListView->firstChild(), true);
1380 resetCurrentItem(); 1381 resetCurrentItem();
1381} 1382}
1382void KOTodoView::setAllClose() 1383void KOTodoView::setAllClose()
1383{ 1384{
1384 if ( isFlatDisplay ) { 1385 if ( isFlatDisplay ) {
1385 isFlatDisplay = false; 1386 isFlatDisplay = false;
1386 mPopupMenu->setItemChecked( 8,false ); 1387 mPopupMenu->setItemChecked( 8,false );
1387 updateView(); 1388 updateView();
1388 } else { 1389 } else {
1389 storeCurrentItem(); 1390 storeCurrentItem();
1390 } 1391 }
1391 setOpen(mTodoListView->firstChild(), false); 1392 setOpen(mTodoListView->firstChild(), false);
1392 resetCurrentItem(); 1393 resetCurrentItem();
1393} 1394}
1394void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1395void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1395{ 1396{
1396 1397
1397 while ( item ) { 1398 while ( item ) {
1398 setOpen( item->firstChild(), setOpenI ); 1399 setOpen( item->firstChild(), setOpenI );
1399 item->setOpen( setOpenI ); 1400 item->setOpen( setOpenI );
1400 item = item->nextSibling(); 1401 item = item->nextSibling();
1401 } 1402 }
1402} 1403}
1403 1404
1404void KOTodoView::displayAllFlat() 1405void KOTodoView::displayAllFlat()
1405{ 1406{
1406 pendingSubtodo = 0; 1407 pendingSubtodo = 0;
1407 if ( mBlockUpdate ) { 1408 if ( mBlockUpdate ) {
1408 return; 1409 return;
1409 } 1410 }
1410 mPopupMenu->setItemChecked( 8,true ); 1411 mPopupMenu->setItemChecked( 8,true );
1411 isFlatDisplay = true; 1412 isFlatDisplay = true;
1412 QPtrList<Todo> todoList = calendar()->todos(); 1413 QPtrList<Todo> todoList = calendar()->todos();
1413 mTodoMap.clear(); 1414 mTodoMap.clear();
1414 mTodoListView->clear(); 1415 mTodoListView->clear();
1415 Todo *todo; 1416 Todo *todo;
1416 for(todo = todoList.first(); todo; todo = todoList.next()) { 1417 for(todo = todoList.first(); todo; todo = todoList.next()) {
1417 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1418 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1418 mTodoMap.insert(todo,todoItem); 1419 mTodoMap.insert(todo,todoItem);
1419 } 1420 }
1420 mTodoListView->setFocus(); 1421 mTodoListView->setFocus();
1421 processSelectionChange(); 1422 processSelectionChange();
1422} 1423}
1423 1424
1424void KOTodoView::setAllFlat() 1425void KOTodoView::setAllFlat()
1425{ 1426{
1426 if ( isFlatDisplay ) { 1427 if ( isFlatDisplay ) {
1427 isFlatDisplay = false; 1428 isFlatDisplay = false;
1428 mPopupMenu->setItemChecked( 8,false ); 1429 mPopupMenu->setItemChecked( 8,false );
1429 updateView(); 1430 updateView();
1430 return; 1431 return;
1431 } 1432 }
1432 storeCurrentItem(); 1433 storeCurrentItem();
1433 displayAllFlat(); 1434 displayAllFlat();
1434 resetCurrentItem(); 1435 resetCurrentItem();
1435} 1436}
1436 1437
1437void KOTodoView::purgeCompleted() 1438void KOTodoView::purgeCompleted()
1438{ 1439{
1439 emit purgeCompletedSignal(); 1440 emit purgeCompletedSignal();
1440 1441
1441} 1442}
1442void KOTodoView::toggleQuickTodo() 1443void KOTodoView::toggleQuickTodo()
1443{ 1444{
1444 if ( mQuickAdd->isVisible() ) { 1445 if ( mQuickAdd->isVisible() ) {
1445 mQuickAdd->hide(); 1446 mQuickAdd->hide();
1446 KOPrefs::instance()->mEnableQuickTodo = false; 1447 KOPrefs::instance()->mEnableQuickTodo = false;
1447 } 1448 }
1448 else { 1449 else {
1449 mQuickAdd->show(); 1450 mQuickAdd->show();
1450 KOPrefs::instance()->mEnableQuickTodo = true; 1451 KOPrefs::instance()->mEnableQuickTodo = true;
1451 } 1452 }
1452 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1453 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1453 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1454 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1454} 1455}
1455 1456
1456void KOTodoView::toggleRunning() 1457void KOTodoView::toggleRunning()
1457{ 1458{
1458 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1459 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1459 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1460 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1460 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1461 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1461 updateView(); 1462 updateView();
1462} 1463}
1463 1464
1464void KOTodoView::toggleCompleted() 1465void KOTodoView::toggleCompleted()
1465{ 1466{
1466 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1467 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1467 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1468 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1468 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1469 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1469 updateView(); 1470 updateView();
1470} 1471}
1471 1472
1472void KOTodoView::addQuickTodo() 1473void KOTodoView::addQuickTodo()
1473{ 1474{
1474 Todo *todo = new Todo(); 1475 Todo *todo = new Todo();
1475 todo->setSummary(mQuickAdd->text()); 1476 todo->setSummary(mQuickAdd->text());
1476 todo->setOrganizer(KOPrefs::instance()->email()); 1477 todo->setOrganizer(KOPrefs::instance()->email());
1477 CalFilter * cf = mCalendar->filter(); 1478 CalFilter * cf = mCalendar->filter();
1478 if ( cf ) { 1479 if ( cf ) {
1479 if ( cf->isEnabled()&& cf->showCategories()) { 1480 if ( cf->isEnabled()&& cf->showCategories()) {
1480 todo->setCategories(cf->categoryList()); 1481 todo->setCategories(cf->categoryList());
1481 } 1482 }
1482 if ( cf->isEnabled() ) 1483 if ( cf->isEnabled() )
1483 todo->setSecrecy( cf->getSecrecy()); 1484 todo->setSecrecy( cf->getSecrecy());
1484 } 1485 }
1485 mCalendar->addTodo(todo); 1486 mCalendar->addTodo(todo);
1486 mQuickAdd->setText(""); 1487 mQuickAdd->setText("");
1487 todoModified (todo, KOGlobals::EVENTADDED ); 1488 todoModified (todo, KOGlobals::EVENTADDED );
1488 updateView(); 1489 updateView();
1489} 1490}
1490 1491
1491void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1492void KOTodoView::keyPressEvent ( QKeyEvent * e )
1492{ 1493{
1493 // e->ignore(); 1494 // e->ignore();
1494 //return; 1495 //return;
1495 //qDebug("KOTodoView::keyPressEvent "); 1496 //qDebug("KOTodoView::keyPressEvent ");
1496 switch ( e->key() ) { 1497 switch ( e->key() ) {
1497 case Qt::Key_Down: 1498 case Qt::Key_Down:
1498 case Qt::Key_Up: 1499 case Qt::Key_Up:
1499 QWidget::keyPressEvent ( e ); 1500 QWidget::keyPressEvent ( e );
1500 break; 1501 break;
1501 1502
1502 case Qt::Key_Q: 1503 case Qt::Key_Q:
1503 toggleQuickTodo(); 1504 toggleQuickTodo();
1504 break; 1505 break;
1505 case Qt::Key_U: 1506 case Qt::Key_U:
1506 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1507 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1507 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1508 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1508 unparentTodo(); 1509 unparentTodo();
1509 e->accept(); 1510 e->accept();
1510 } else 1511 } else
1511 e->ignore(); 1512 e->ignore();
1512 break; 1513 break;
1513 case Qt::Key_S: 1514 case Qt::Key_S:
1514 if ( e->state() == Qt::ControlButton ) { 1515 if ( e->state() == Qt::ControlButton ) {
1515 e->ignore(); 1516 e->ignore();
1516 break; 1517 break;
1517 } 1518 }
1518 if ( e->state() == Qt::ShiftButton ) { 1519 if ( e->state() == Qt::ShiftButton ) {
1519 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1520 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1520 reparentTodo(); 1521 reparentTodo();
1521 e->accept(); 1522 e->accept();
1522 } else 1523 } else
1523 e->ignore(); 1524 e->ignore();
1524 break; 1525 break;
1525 case Qt::Key_P: 1526 case Qt::Key_P:
1526 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1527 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1527 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1528 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1528 if ( pendingSubtodo ) 1529 if ( pendingSubtodo )
1529 itemClicked(mActiveItem); 1530 itemClicked(mActiveItem);
1530 e->accept(); 1531 e->accept();
1531 } else 1532 } else
1532 e->ignore(); 1533 e->ignore();
1533 break; 1534 break;
1534 case Qt::Key_Escape: 1535 case Qt::Key_Escape:
1535 if ( pendingSubtodo ) { 1536 if ( pendingSubtodo ) {
1536 itemClicked(0); 1537 itemClicked(0);
1537 e->accept(); 1538 e->accept();
1538 } else 1539 } else
1539 e->ignore(); 1540 e->ignore();
1540 break; 1541 break;
1541 default: 1542 default:
1542 e->ignore(); 1543 e->ignore();
1543 } 1544 }
1544 1545
1545 if ( true ) { 1546 if ( true ) {
1546 if ( e->key() == Qt::Key_I ) { 1547 if ( e->key() == Qt::Key_I ) {
1547 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1548 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1548 if ( cn ) { 1549 if ( cn ) {
1549 mActiveItem = cn; 1550 mActiveItem = cn;
1550 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1551 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1551 if ( ci ){ 1552 if ( ci ){
1552 showTodo(); 1553 showTodo();
1553 cn = (KOTodoViewItem*)cn->itemBelow(); 1554 cn = (KOTodoViewItem*)cn->itemBelow();
1554 if ( cn ) { 1555 if ( cn ) {
1555 mTodoListView->setCurrentItem ( cn ); 1556 mTodoListView->setCurrentItem ( cn );
1556 mTodoListView->ensureItemVisible ( cn ); 1557 mTodoListView->ensureItemVisible ( cn );
1557 } 1558 }
1558 1559
1559 } 1560 }
1560 } 1561 }
1561 e->accept(); 1562 e->accept();
1562 1563
1563 } 1564 }
1564 1565
1565 } 1566 }
1566 1567
1567} 1568}
1568void KOTodoView::updateTodo( Todo * t, int type ) 1569void KOTodoView::updateTodo( Todo * t, int type )
1569{ 1570{
1570 if ( mBlockUpdate) 1571 if ( mBlockUpdate)
1571 return; 1572 return;
1572 1573
1573 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1574 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1574 itemIterator = mTodoMap.find(t); 1575 itemIterator = mTodoMap.find(t);
1575 if (itemIterator != mTodoMap.end()) { 1576 if (itemIterator != mTodoMap.end()) {
1576 (*itemIterator)->construct(); 1577 (*itemIterator)->construct();
1577 } else { 1578 } else {
1578 if ( type == KOGlobals::EVENTADDED ) { 1579 if ( type == KOGlobals::EVENTADDED ) {
1579 insertTodoItem( t ); 1580 insertTodoItem( t );
1580 } 1581 }
1581 } 1582 }
1582 1583
1583} 1584}
1584 1585
1585void KOTodoView::todoModified(Todo * t , int p ) 1586void KOTodoView::todoModified(Todo * t , int p )
1586{ 1587{
1587 mBlockUpdate = true; 1588 mBlockUpdate = true;
1588 emit todoModifiedSignal ( t, p ); 1589 emit todoModifiedSignal ( t, p );
1589 mBlockUpdate = false; 1590 mBlockUpdate = false;
1590} 1591}