summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-13 23:07:29 (UTC)
committer zautrix <zautrix>2005-06-13 23:07:29 (UTC)
commitb3743f5abe0a95c9ffeadf6701c9943f604febd6 (patch) (unidiff)
treeca7b4fa180795d5d6fb7b212eea74e0ddf2e73ad
parent35d40d945aed8c9e7c3389182014a2d99edb5254 (diff)
downloadkdepimpi-b3743f5abe0a95c9ffeadf6701c9943f604febd6.zip
kdepimpi-b3743f5abe0a95c9ffeadf6701c9943f604febd6.tar.gz
kdepimpi-b3743f5abe0a95c9ffeadf6701c9943f604febd6.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp1
-rw-r--r--libkcal/todo.cpp4
-rw-r--r--libkcal/todo.h3
3 files changed, 6 insertions, 2 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 19d731f..9633b2c 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,407 +1,406 @@
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 <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qdialog.h> 29#include <qdialog.h>
30 30
31 31
32#include <libkcal/calfilter.h> 32#include <libkcal/calfilter.h>
33 33
34#include "kofilterview.h" 34#include "kofilterview.h"
35#include "koprefs.h" 35#include "koprefs.h"
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kcolorbutton.h> 38#include <kcolorbutton.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40 40
41 41
42#include <kurlrequester.h> 42#include <kurlrequester.h>
43#include <klineedit.h> 43#include <klineedit.h>
44 44
45class KONewCalPrefs : public QDialog 45class KONewCalPrefs : public QDialog
46{ 46{
47 public: 47 public:
48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : 48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
49 QDialog( parent, name, true ) 49 QDialog( parent, name, true )
50 { 50 {
51 setCaption( i18n("Add new Calendar") ); 51 setCaption( i18n("Add new Calendar") );
52 QVBoxLayout* lay = new QVBoxLayout( this ); 52 QVBoxLayout* lay = new QVBoxLayout( this );
53 lay->setSpacing( 3 ); 53 lay->setSpacing( 3 );
54 lay->setMargin( 3 ); 54 lay->setMargin( 3 );
55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); 55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
56 lay->addWidget( lab ); 56 lay->addWidget( lab );
57 nameE = new KLineEdit( this ); 57 nameE = new KLineEdit( this );
58 lay->addWidget( nameE ); 58 lay->addWidget( nameE );
59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this ); 59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this );
60 lay->addWidget( lab ); 60 lay->addWidget( lab );
61 url = new KURLRequester ( this ); 61 url = new KURLRequester ( this );
62 lay->addWidget( url ); 62 lay->addWidget( url );
63 QPushButton * ok = new QPushButton( i18n("OK"), this ); 63 QPushButton * ok = new QPushButton( i18n("OK"), this );
64 lay->addWidget( ok ); 64 lay->addWidget( ok );
65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
66 lay->addWidget( cancel ); 66 lay->addWidget( cancel );
67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
69 //resize( 200, 200 ); 69 //resize( 200, 200 );
70 } 70 }
71 71
72 QString calName() { return nameE->text(); } 72 QString calName() { return nameE->text(); }
73 QString calFileName() { return url->url(); } 73 QString calFileName() { return url->url(); }
74private: 74private:
75 KLineEdit* nameE; 75 KLineEdit* nameE;
76 KURLRequester *url; 76 KURLRequester *url;
77}; 77};
78 78
79 79
80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
81 const char* name,WFlags fl ) 81 const char* name,WFlags fl )
82 : KOFilterView_base(parent,name,fl) 82 : KOFilterView_base(parent,name,fl)
83{ 83{
84 mFilters = filterList; 84 mFilters = filterList;
85 85
86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
89} 89}
90 90
91KOFilterView::~KOFilterView() 91KOFilterView::~KOFilterView()
92{ 92{
93 // no need to delete child widgets, Qt does it all for us 93 // no need to delete child widgets, Qt does it all for us
94} 94}
95 95
96bool KOFilterView::filtersEnabled() 96bool KOFilterView::filtersEnabled()
97{ 97{
98 return mEnabledCheck->isChecked(); 98 return mEnabledCheck->isChecked();
99} 99}
100 100
101void KOFilterView::setFiltersEnabled(bool set) 101void KOFilterView::setFiltersEnabled(bool set)
102{ 102{
103 mEnabledCheck->setChecked(set); 103 mEnabledCheck->setChecked(set);
104 emit filterChanged(); 104 emit filterChanged();
105} 105}
106 106
107 107
108void KOFilterView::updateFilters() 108void KOFilterView::updateFilters()
109{ 109{
110 mSelectionCombo->clear(); 110 mSelectionCombo->clear();
111 111
112 CalFilter *filter = mFilters->first(); 112 CalFilter *filter = mFilters->first();
113 while(filter) { 113 while(filter) {
114 mSelectionCombo->insertItem(filter->name()); 114 mSelectionCombo->insertItem(filter->name());
115 filter = mFilters->next(); 115 filter = mFilters->next();
116 } 116 }
117} 117}
118 118
119CalFilter *KOFilterView::selectedFilter() 119CalFilter *KOFilterView::selectedFilter()
120{ 120{
121 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 121 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
122 return f; 122 return f;
123} 123}
124 124
125void KOFilterView::setSelectedFilter(QString filterName) 125void KOFilterView::setSelectedFilter(QString filterName)
126{ 126{
127 int filter_num = mSelectionCombo->count(); 127 int filter_num = mSelectionCombo->count();
128 int i; 128 int i;
129 for (i=0;i<filter_num;i++) { 129 for (i=0;i<filter_num;i++) {
130 if (mSelectionCombo->text(i)==filterName) 130 if (mSelectionCombo->text(i)==filterName)
131 mSelectionCombo->setCurrentItem(i); 131 mSelectionCombo->setCurrentItem(i);
132 } 132 }
133 emit filterChanged(); 133 emit filterChanged();
134} 134}
135void KOFilterView::setSelectedFilter( int fil ) 135void KOFilterView::setSelectedFilter( int fil )
136{ 136{
137 if ( fil >= mSelectionCombo->count() ) 137 if ( fil >= mSelectionCombo->count() )
138 return; 138 return;
139 mSelectionCombo->setCurrentItem( fil ); 139 mSelectionCombo->setCurrentItem( fil );
140 emit filterChanged(); 140 emit filterChanged();
141} 141}
142 142
143 143
144 144
145KOCalEditView::KOCalEditView(QWidget* parent, 145KOCalEditView::KOCalEditView(QWidget* parent,
146 const char* name ) 146 const char* name )
147 : QWidget(parent,name) 147 : QWidget(parent,name)
148{ 148{
149 mw = 0; 149 mw = 0;
150 ml = new QVBoxLayout ( this ); 150 ml = new QVBoxLayout ( this );
151} 151}
152 152
153KOCalEditView::~KOCalEditView() 153KOCalEditView::~KOCalEditView()
154{ 154{
155 // no need to delete child widgets, Qt does it all for us 155 // no need to delete child widgets, Qt does it all for us
156} 156}
157void KOCalEditView::selectCal(int id ,bool b) 157void KOCalEditView::selectCal(int id ,bool b)
158{ 158{
159 KOPrefs::instance()->getCalendar( id )->isEnabled = b; 159 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
160 emit calendarEnabled ( id, b ); 160 emit calendarEnabled ( id, b );
161 emit needsUpdate(); 161 emit needsUpdate();
162 162
163} 163}
164void KOCalEditView::selectStdCal( int id, bool b ) 164void KOCalEditView::selectStdCal( int id, bool b )
165{ 165{
166 166
167 if ( !b ) { 167 if ( !b ) {
168 KOCalCheckButton* it = (KOCalCheckButton*) sender(); 168 KOCalCheckButton* it = (KOCalCheckButton*) sender();
169 if ( it ) { 169 if ( it ) {
170 it->blockSignals( true ); 170 it->blockSignals( true );
171 it->setChecked( true ); 171 it->setChecked( true );
172 it->blockSignals( false ); 172 it->blockSignals( false );
173 return; 173 return;
174 } 174 }
175 return; 175 return;
176 } 176 }
177 KOCalCheckButton* sen = (KOCalCheckButton*) sender(); 177 KOCalCheckButton* sen = (KOCalCheckButton*) sender();
178 KOCalCheckButton* it = mStdandardB.first(); 178 KOCalCheckButton* it = mStdandardB.first();
179 while ( it ) { 179 while ( it ) {
180 if ( it->isChecked() ) { 180 if ( it->isChecked() ) {
181 if ( it != sen ) { 181 if ( it != sen ) {
182 it->blockSignals( true ); 182 it->blockSignals( true );
183 it->setChecked( false ); 183 it->setChecked( false );
184 it->blockSignals( false ); 184 it->blockSignals( false );
185 break; 185 break;
186 } 186 }
187 } 187 }
188 it = mStdandardB.next(); 188 it = mStdandardB.next();
189 } 189 }
190 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 190 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
191 while ( kkf ) { 191 while ( kkf ) {
192 kkf->isStandard = false; 192 kkf->isStandard = false;
193 kkf = KOPrefs::instance()->mCalendars.next(); 193 kkf = KOPrefs::instance()->mCalendars.next();
194 } 194 }
195 KOPrefs::instance()->getCalendar( id )->isStandard = true; 195 KOPrefs::instance()->getCalendar( id )->isStandard = true;
196 emit setCalendarDefault ( id ); 196 emit setCalendarDefault ( id );
197} 197}
198 198
199void KOCalEditView::selectCalAlarm(int id ,bool b ) 199void KOCalEditView::selectCalAlarm(int id ,bool b )
200{ 200{
201 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; 201 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
202 emit alarmEnabled ( id , b ); 202 emit alarmEnabled ( id , b );
203 emit needsUpdate(); 203 emit needsUpdate();
204} 204}
205void KOCalEditView::selectReadOnly(int id ,bool b ) 205void KOCalEditView::selectReadOnly(int id ,bool b )
206{ 206{
207 KOPrefs::instance()->getCalendar( id )->isReadOnly = b; 207 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
208 emit calendarReadonly ( id , b ); 208 emit calendarReadonly ( id , b );
209 emit needsUpdate(); 209 emit needsUpdate();
210 210
211} 211}
212void KOCalEditView::setColor( const QColor& c, int id ) 212void KOCalEditView::setColor( const QColor& c, int id )
213{ 213{
214 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; 214 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
215 emit needsUpdate(); 215 emit needsUpdate();
216} 216}
217void KOCalEditView::deleteCal( int id ) 217void KOCalEditView::deleteCal( int id )
218{ 218{
219 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 219 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
220 QString name = kkf->mName; 220 QString name = kkf->mName;
221 QString file = kkf->mFileName; 221 QString file = kkf->mFileName;
222 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; 222 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
223 if ( kkf->isStandard ) 223 if ( kkf->isStandard )
224 selectStdCal( 1, true ); 224 selectStdCal( 1, true );
225 emit removeCalendar ( id ); 225 emit removeCalendar ( id );
226 KOPrefs::instance()->mCalendars.remove ( kkf ); 226 KOPrefs::instance()->mCalendars.remove ( kkf );
227 emit needsUpdate(); 227 emit needsUpdate();
228 readConfig(); 228 readConfig();
229} 229}
230void KOCalEditView::infoCal( int id ) 230void KOCalEditView::infoCal( int id )
231{ 231{
232 QString name = KOPrefs::instance()->getCalendar( id )->mName; 232 QString name = KOPrefs::instance()->getCalendar( id )->mName;
233 QString file = KOPrefs::instance()->getCalendar( id )->mFileName; 233 QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
234 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { 234 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
235 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { 235 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) {
236 emit calendarAdded( id ); 236 emit calendarAdded( id );
237 readConfig(); 237 readConfig();
238 emit needsUpdate(); 238 emit needsUpdate();
239 } 239 }
240 } 240 }
241 else 241 else
242 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); 242 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
243} 243}
244void KOCalEditView::readConfig() 244void KOCalEditView::readConfig()
245{ 245{
246 246
247 mStdandardB.clear(); 247 mStdandardB.clear();
248 mEnabledB.clear(); 248 mEnabledB.clear();
249 mAlarmB.clear(); 249 mAlarmB.clear();
250 mROB.clear(); 250 mROB.clear();
251 251
252 if ( mw ) delete mw; 252 if ( mw ) delete mw;
253 mw = new QWidget ( this ); 253 mw = new QWidget ( this );
254 ml->addWidget ( mw ); 254 ml->addWidget ( mw );
255 255
256 mainLayout = new QGridLayout ( mw , 2, 8 ); 256 mainLayout = new QGridLayout ( mw , 2, 8 );
257 //mainLayout->setSpacing( 3 ); 257 //mainLayout->setSpacing( 3 );
258 QPushButton * addBut = new QPushButton ( mw ); 258 QPushButton * addBut = new QPushButton ( mw );
259 mainLayout->addWidget( addBut,0,0 ); 259 mainLayout->addWidget( addBut,0,0 );
260 addBut->setPixmap ( SmallIcon("plus")); 260 addBut->setPixmap ( SmallIcon("plus"));
261 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 261 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
262 addBut->setMaximumWidth( addBut->sizeHint().height() ); 262 addBut->setMaximumWidth( addBut->sizeHint().height() );
263 263
264 addBut = new QPushButton ( mw ); 264 addBut = new QPushButton ( mw );
265 mainLayout->addWidget( addBut,0,1 ); 265 mainLayout->addWidget( addBut,0,1 );
266 addBut->setPixmap ( SmallIcon("eye")); 266 addBut->setPixmap ( SmallIcon("eye"));
267 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 267 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
268 addBut->setMaximumWidth( addBut->sizeHint().height() ); 268 addBut->setMaximumWidth( addBut->sizeHint().height() );
269 269
270 QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw ); 270 QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw );
271 mainLayout->addWidget( lab,0,2 ); 271 mainLayout->addWidget( lab,0,2 );
272 272
273 addBut = new QPushButton ( mw ); 273 addBut = new QPushButton ( mw );
274 mainLayout->addWidget( addBut,0,3 ); 274 mainLayout->addWidget( addBut,0,3 );
275 addBut->setPixmap ( SmallIcon("bell")); 275 addBut->setPixmap ( SmallIcon("bell"));
276 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 276 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
277 addBut->setMaximumWidth( addBut->sizeHint().height() ); 277 addBut->setMaximumWidth( addBut->sizeHint().height() );
278 278
279 addBut = new QPushButton ( mw ); 279 addBut = new QPushButton ( mw );
280 mainLayout->addWidget( addBut,0,4 ); 280 mainLayout->addWidget( addBut,0,4 );
281 addBut->setPixmap ( SmallIcon("pencil")); 281 addBut->setPixmap ( SmallIcon("pencil"));
282 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 282 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
283 addBut->setMaximumWidth( addBut->sizeHint().height() ); 283 addBut->setMaximumWidth( addBut->sizeHint().height() );
284 284
285 lab = new QLabel ( i18n(" Color "), mw ); 285 lab = new QLabel ( i18n(" Color "), mw );
286 mainLayout->addWidget( lab,0,5 ); 286 mainLayout->addWidget( lab,0,5 );
287#if 0 287#if 0
288 addBut = new QPushButton ( mw ); 288 addBut = new QPushButton ( mw );
289 mainLayout->addWidget( addBut,0,6 ); 289 mainLayout->addWidget( addBut,0,6 );
290 addBut->setPixmap ( SmallIcon("minus")); 290 addBut->setPixmap ( SmallIcon("minus"));
291 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); 291 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll()));
292 addBut->setMaximumWidth( addBut->sizeHint().height() ); 292 addBut->setMaximumWidth( addBut->sizeHint().height() );
293#endif 293#endif
294 294
295 295
296 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 296 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
297 int row = 1; 297 int row = 1;
298 while ( kkf ) { 298 while ( kkf ) {
299 299
300 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 300 KOCalCheckButton* cb = new KOCalCheckButton( mw );
301 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); 301 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb );
302 cb->setChecked( kkf->isStandard ); 302 cb->setChecked( kkf->isStandard );
303 cb->setNum( kkf->mCalNumber ); 303 cb->setNum( kkf->mCalNumber );
304 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); 304 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
305 if ( kkf->mErrorOnLoad ) 305 if ( kkf->mErrorOnLoad )
306 cb->setEnabled( false ); 306 cb->setEnabled( false );
307 cb = new KOCalCheckButton( mw ); 307 cb = new KOCalCheckButton( mw );
308 mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb ); 308 mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb );
309 cb->setChecked( kkf->isEnabled ); 309 cb->setChecked( kkf->isEnabled );
310 cb->setNum( kkf->mCalNumber ); 310 cb->setNum( kkf->mCalNumber );
311 if ( kkf->mErrorOnLoad ) 311 if ( kkf->mErrorOnLoad )
312 cb->setEnabled( false ); 312 cb->setEnabled( false );
313 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 313 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
314 KOCalButton* name = new KOCalButton( mw ); 314 KOCalButton* name = new KOCalButton( mw );
315 name->setNum( kkf->mCalNumber ); 315 name->setNum( kkf->mCalNumber );
316 name->setText( kkf->mName ); 316 name->setText( kkf->mName );
317 mainLayout->addWidget( name,row,2 ); 317 mainLayout->addWidget( name,row,2 );
318 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 318 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
319 cb = new KOCalCheckButton( mw ); 319 cb = new KOCalCheckButton( mw );
320 mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb ); 320 mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb );
321 cb->setChecked( kkf->isAlarmEnabled ); 321 cb->setChecked( kkf->isAlarmEnabled );
322 cb->setNum( kkf->mCalNumber ); 322 cb->setNum( kkf->mCalNumber );
323 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 323 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
324 if ( kkf->mErrorOnLoad ) 324 if ( kkf->mErrorOnLoad )
325 cb->setEnabled( false ); 325 cb->setEnabled( false );
326 cb = new KOCalCheckButton( mw ); 326 cb = new KOCalCheckButton( mw );
327 mainLayout->addWidget( cb,row,4 );mROB.append( cb ); 327 mainLayout->addWidget( cb,row,4 );mROB.append( cb );
328 cb->setChecked( kkf->isReadOnly ); 328 cb->setChecked( kkf->isReadOnly );
329 cb->setNum( kkf->mCalNumber ); 329 cb->setNum( kkf->mCalNumber );
330 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 330 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
331 if ( kkf->mErrorOnLoad ) 331 if ( kkf->mErrorOnLoad )
332 cb->setEnabled( false ); 332 cb->setEnabled( false );
333 KColorButton *colb = new KColorButton( mw ); 333 KColorButton *colb = new KColorButton( mw );
334 mainLayout->addWidget( colb,row,5 ); 334 mainLayout->addWidget( colb,row,5 );
335 colb->setID( kkf->mCalNumber ); 335 colb->setID( kkf->mCalNumber );
336 colb->setColor( kkf->mDefaultColor ); 336 colb->setColor( kkf->mDefaultColor );
337 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); 337 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
338 if ( row > 1) { 338 if ( row > 1) {
339 KOCalButton* calb = new KOCalButton( mw ); 339 KOCalButton* calb = new KOCalButton( mw );
340 mainLayout->addWidget( calb,row,6 ); 340 mainLayout->addWidget( calb,row,6 );
341 calb->setNum( kkf->mCalNumber ); 341 calb->setNum( kkf->mCalNumber );
342 calb->setPixmap ( SmallIcon("minus")); 342 calb->setPixmap ( SmallIcon("minus"));
343 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 343 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
344 int hei = calb->sizeHint().height(); 344 int hei = calb->sizeHint().height();
345 //calb->setMaximumSize( hei*9/10, hei*9/10 ); 345 //calb->setMaximumSize( hei*9/10, hei*9/10 );
346 } 346 }
347 ++row; 347 ++row;
348 kkf = KOPrefs::instance()->mCalendars.next(); 348 kkf = KOPrefs::instance()->mCalendars.next();
349 } 349 }
350 lab = new QLabel ( "", mw ); 350 lab = new QLabel ( "", mw );
351 mainLayout->addWidget( lab,row,0 ); 351 mainLayout->addWidget( lab,row,0 );
352 mw->show(); 352 mw->show();
353 353
354} 354}
355void KOCalEditView::addCal() 355void KOCalEditView::addCal()
356{ 356{
357 qDebug("addcal ");
358 KONewCalPrefs prefs ( this ); 357 KONewCalPrefs prefs ( this );
359 if ( ! prefs.exec() ) 358 if ( ! prefs.exec() )
360 return; 359 return;
361 QString name = prefs.calName(); 360 QString name = prefs.calName();
362 QString file = prefs.calFileName(); 361 QString file = prefs.calFileName();
363 QFileInfo fi ( file ); 362 QFileInfo fi ( file );
364 if (!fi.exists() ) { 363 if (!fi.exists() ) {
365 KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!")); 364 KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!"));
366 return; 365 return;
367 } 366 }
368 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 367 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
369 kkf->mName = name; 368 kkf->mName = name;
370 kkf->mFileName = file; 369 kkf->mFileName = file;
371 emit calendarAdded( kkf->mCalNumber ); 370 emit calendarAdded( kkf->mCalNumber );
372 readConfig(); 371 readConfig();
373 emit needsUpdate(); 372 emit needsUpdate();
374} 373}
375void KOCalEditView::enableAll() 374void KOCalEditView::enableAll()
376{ 375{
377 toggleList( mEnabledB ); 376 toggleList( mEnabledB );
378} 377}
379void KOCalEditView::enableAlarm() 378void KOCalEditView::enableAlarm()
380{ 379{
381 toggleList( mAlarmB ); 380 toggleList( mAlarmB );
382} 381}
383void KOCalEditView::disableRO() 382void KOCalEditView::disableRO()
384{ 383{
385 toggleList( mROB ); 384 toggleList( mROB );
386} 385}
387void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) 386void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
388{ 387{
389 bool dis = false; 388 bool dis = false;
390 KOCalCheckButton* it = list.first(); 389 KOCalCheckButton* it = list.first();
391 while ( it ) { 390 while ( it ) {
392 if ( !it->isChecked() ) { 391 if ( !it->isChecked() ) {
393 dis = true; 392 dis = true;
394 break; 393 break;
395 } 394 }
396 it = list.next(); 395 it = list.next();
397 } 396 }
398 it = list.first(); 397 it = list.first();
399 while ( it ) { 398 while ( it ) {
400 it->setChecked(dis); 399 it->setChecked(dis);
401 it = list.next(); 400 it = list.next();
402 } 401 }
403} 402}
404void KOCalEditView::deleteAll() 403void KOCalEditView::deleteAll()
405{ 404{
406 qDebug("delteAll"); 405 qDebug("delteAll");
407} 406}
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 42274ff..e98af3c 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,474 +1,478 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <kglobalsettings.h> 22#include <kglobalsettings.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kdebug.h> 24#include <kdebug.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27 27
28#include "calendarlocal.h" 28#include "calendarlocal.h"
29#include "icalformat.h" 29#include "icalformat.h"
30#include "todo.h" 30#include "todo.h"
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34Todo::Todo(): QObject(), Incidence() 34Todo::Todo(): QObject(), Incidence()
35{ 35{
36// mStatus = TENTATIVE; 36// mStatus = TENTATIVE;
37 37
38 mHasDueDate = false; 38 mHasDueDate = false;
39 setHasStartDate( false ); 39 setHasStartDate( false );
40 mCompleted = getEvenTime(QDateTime::currentDateTime()); 40 mCompleted = getEvenTime(QDateTime::currentDateTime());
41 mHasCompletedDate = false; 41 mHasCompletedDate = false;
42 mPercentComplete = 0; 42 mPercentComplete = 0;
43 mRunning = false; 43 mRunning = false;
44 mRunSaveTimer = 0; 44 mRunSaveTimer = 0;
45} 45}
46 46
47Todo::Todo(const Todo &t) : QObject(),Incidence(t) 47Todo::Todo(const Todo &t) : QObject(),Incidence(t)
48{ 48{
49 mDtDue = t.mDtDue; 49 mDtDue = t.mDtDue;
50 mHasDueDate = t.mHasDueDate; 50 mHasDueDate = t.mHasDueDate;
51 mCompleted = t.mCompleted; 51 mCompleted = t.mCompleted;
52 mHasCompletedDate = t.mHasCompletedDate; 52 mHasCompletedDate = t.mHasCompletedDate;
53 mPercentComplete = t.mPercentComplete; 53 mPercentComplete = t.mPercentComplete;
54 mRunning = false; 54 mRunning = false;
55 mRunSaveTimer = 0; 55 mRunSaveTimer = 0;
56} 56}
57 57
58Todo::~Todo() 58Todo::~Todo()
59{ 59{
60 setRunning( false ); 60 setRunning( false );
61 //qDebug("Todo::~Todo() "); 61 //qDebug("Todo::~Todo() ");
62} 62}
63 63
64void Todo::setRunningFalse( QString s ) 64void Todo::setRunningFalse( QString s )
65{ 65{
66 if ( ! mRunning ) 66 if ( ! mRunning )
67 return; 67 return;
68 mRunning = false; 68 mRunning = false;
69 mRunSaveTimer->stop(); 69 mRunSaveTimer->stop();
70 saveRunningInfoToFile( s ); 70 saveRunningInfoToFile( s );
71} 71}
72void Todo::setRunning( bool run ) 72void Todo::setRunning( bool run )
73{ 73{
74 if ( run == mRunning ) 74 if ( run == mRunning )
75 return; 75 return;
76 //qDebug("Todo::setRunning %d ", run); 76 //qDebug("Todo::setRunning %d ", run);
77 if ( !mRunSaveTimer ) { 77 if ( !mRunSaveTimer ) {
78 mRunSaveTimer = new QTimer ( this ); 78 mRunSaveTimer = new QTimer ( this );
79 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 79 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
80 } 80 }
81 mRunning = run; 81 mRunning = run;
82 if ( mRunning ) { 82 if ( mRunning ) {
83 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 83 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
84 mRunStart = QDateTime::currentDateTime(); 84 mRunStart = QDateTime::currentDateTime();
85 } else { 85 } else {
86 mRunSaveTimer->stop(); 86 mRunSaveTimer->stop();
87 saveRunningInfoToFile(); 87 saveRunningInfoToFile();
88 } 88 }
89} 89}
90 90
91void Todo::saveRunningInfoToFile()
92{
93 saveRunningInfoToFile( QString::null );
94}
91void Todo::saveRunningInfoToFile( QString comment ) 95void Todo::saveRunningInfoToFile( QString comment )
92{ 96{
93 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 97 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
94 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { 98 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) {
95 qDebug("Running time < 30 seconds. Skipped. "); 99 qDebug("Running time < 30 seconds. Skipped. ");
96 return; 100 return;
97 } 101 }
98 QString dir = KGlobalSettings::timeTrackerDir(); 102 QString dir = KGlobalSettings::timeTrackerDir();
99 //qDebug("%s ", dir.latin1()); 103 //qDebug("%s ", dir.latin1());
100 QString file = "%1%2%3-%4%5%6-"; 104 QString file = "%1%2%3-%4%5%6-";
101 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); 105 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
102 file.replace ( QRegExp (" "), "0" ); 106 file.replace ( QRegExp (" "), "0" );
103 file += uid(); 107 file += uid();
104 //qDebug("File %s ",file.latin1() ); 108 //qDebug("File %s ",file.latin1() );
105 CalendarLocal cal; 109 CalendarLocal cal;
106 cal.setLocalTime(); 110 cal.setLocalTime();
107 Todo * to = (Todo*) clone(); 111 Todo * to = (Todo*) clone();
108 to->setFloats( false ); 112 to->setFloats( false );
109 to->setDtStart( mRunStart ); 113 to->setDtStart( mRunStart );
110 to->setHasStartDate( true ); 114 to->setHasStartDate( true );
111 to->setDtDue( QDateTime::currentDateTime() ); 115 to->setDtDue( QDateTime::currentDateTime() );
112 to->setHasDueDate( true ); 116 to->setHasDueDate( true );
113 to->setUid( file ); 117 to->setUid( file );
114 if ( !comment.isEmpty() ) { 118 if ( !comment.isEmpty() ) {
115 QString des = to->description(); 119 QString des = to->description();
116 if ( des.isEmpty () ) 120 if ( des.isEmpty () )
117 to->setDescription( "TT-Note: " + comment ); 121 to->setDescription( "TT-Note: " + comment );
118 else 122 else
119 to->setDescription( "TT-Note: " + comment +"\n" + des ); 123 to->setDescription( "TT-Note: " + comment +"\n" + des );
120 } 124 }
121 cal.addIncidence( to ); 125 cal.addIncidence( to );
122 ICalFormat format; 126 ICalFormat format;
123 file = dir +"/" +file +".ics"; 127 file = dir +"/" +file +".ics";
124 format.save( &cal, file ); 128 format.save( &cal, file );
125 saveParents(); 129 saveParents();
126 130
127} 131}
128void Todo::saveParents() 132void Todo::saveParents()
129{ 133{
130 if (!relatedTo() ) 134 if (!relatedTo() )
131 return; 135 return;
132 Incidence * inc = relatedTo(); 136 Incidence * inc = relatedTo();
133 if ( inc->typeID() != todoID ) 137 if ( inc->typeID() != todoID )
134 return; 138 return;
135 Todo* to = (Todo*)inc; 139 Todo* to = (Todo*)inc;
136 bool saveTodo = false; 140 bool saveTodo = false;
137 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; 141 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
138 QFileInfo fi ( file ); 142 QFileInfo fi ( file );
139 if ( fi.exists() ) { 143 if ( fi.exists() ) {
140 if ( fi.lastModified () < to->lastModified ()) 144 if ( fi.lastModified () < to->lastModified ())
141 saveTodo = true; 145 saveTodo = true;
142 } else { 146 } else {
143 saveTodo = true; 147 saveTodo = true;
144 } 148 }
145 if ( saveTodo ) { 149 if ( saveTodo ) {
146 CalendarLocal cal; 150 CalendarLocal cal;
147 cal.setLocalTime(); 151 cal.setLocalTime();
148 Todo * par = (Todo *) to->clone(); 152 Todo * par = (Todo *) to->clone();
149 cal.addIncidence( par ); 153 cal.addIncidence( par );
150 ICalFormat format; 154 ICalFormat format;
151 format.save( &cal, file ); 155 format.save( &cal, file );
152 } 156 }
153 to->saveParents(); 157 to->saveParents();
154} 158}
155 159
156int Todo::runTime() 160int Todo::runTime()
157{ 161{
158 if ( !mRunning ) 162 if ( !mRunning )
159 return 0; 163 return 0;
160 return mRunStart.secsTo( QDateTime::currentDateTime() ); 164 return mRunStart.secsTo( QDateTime::currentDateTime() );
161} 165}
162bool Todo::hasRunningSub() 166bool Todo::hasRunningSub()
163{ 167{
164 if ( mRunning ) 168 if ( mRunning )
165 return true; 169 return true;
166 Incidence *aTodo; 170 Incidence *aTodo;
167 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 171 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
168 if ( ((Todo*)aTodo)->hasRunningSub() ) 172 if ( ((Todo*)aTodo)->hasRunningSub() )
169 return true; 173 return true;
170 } 174 }
171 return false; 175 return false;
172} 176}
173Incidence *Todo::clone() 177Incidence *Todo::clone()
174{ 178{
175 return new Todo(*this); 179 return new Todo(*this);
176} 180}
177 181
178bool Todo::contains ( Todo* from ) 182bool Todo::contains ( Todo* from )
179{ 183{
180 184
181 if ( !from->summary().isEmpty() ) 185 if ( !from->summary().isEmpty() )
182 if ( !summary().startsWith( from->summary() )) 186 if ( !summary().startsWith( from->summary() ))
183 return false; 187 return false;
184 if ( from->hasStartDate() ) { 188 if ( from->hasStartDate() ) {
185 if ( !hasStartDate() ) 189 if ( !hasStartDate() )
186 return false; 190 return false;
187 if ( from->dtStart() != dtStart()) 191 if ( from->dtStart() != dtStart())
188 return false; 192 return false;
189 } 193 }
190 if ( from->hasDueDate() ){ 194 if ( from->hasDueDate() ){
191 if ( !hasDueDate() ) 195 if ( !hasDueDate() )
192 return false; 196 return false;
193 if ( from->dtDue() != dtDue()) 197 if ( from->dtDue() != dtDue())
194 return false; 198 return false;
195 } 199 }
196 if ( !from->location().isEmpty() ) 200 if ( !from->location().isEmpty() )
197 if ( !location().startsWith( from->location() ) ) 201 if ( !location().startsWith( from->location() ) )
198 return false; 202 return false;
199 if ( !from->description().isEmpty() ) 203 if ( !from->description().isEmpty() )
200 if ( !description().startsWith( from->description() )) 204 if ( !description().startsWith( from->description() ))
201 return false; 205 return false;
202 if ( from->alarms().count() ) { 206 if ( from->alarms().count() ) {
203 Alarm *a = from->alarms().first(); 207 Alarm *a = from->alarms().first();
204 if ( a->enabled() ){ 208 if ( a->enabled() ){
205 if ( !alarms().count() ) 209 if ( !alarms().count() )
206 return false; 210 return false;
207 Alarm *b = alarms().first(); 211 Alarm *b = alarms().first();
208 if( ! b->enabled() ) 212 if( ! b->enabled() )
209 return false; 213 return false;
210 if ( ! (a->offset() == b->offset() )) 214 if ( ! (a->offset() == b->offset() ))
211 return false; 215 return false;
212 } 216 }
213 } 217 }
214 218
215 QStringList cat = categories(); 219 QStringList cat = categories();
216 QStringList catFrom = from->categories(); 220 QStringList catFrom = from->categories();
217 QString nCat; 221 QString nCat;
218 unsigned int iii; 222 unsigned int iii;
219 for ( iii = 0; iii < catFrom.count();++iii ) { 223 for ( iii = 0; iii < catFrom.count();++iii ) {
220 nCat = catFrom[iii]; 224 nCat = catFrom[iii];
221 if ( !nCat.isEmpty() ) 225 if ( !nCat.isEmpty() )
222 if ( !cat.contains( nCat )) { 226 if ( !cat.contains( nCat )) {
223 return false; 227 return false;
224 } 228 }
225 } 229 }
226 if ( from->isCompleted() ) { 230 if ( from->isCompleted() ) {
227 if ( !isCompleted() ) 231 if ( !isCompleted() )
228 return false; 232 return false;
229 } 233 }
230 if( priority() != from->priority() ) 234 if( priority() != from->priority() )
231 return false; 235 return false;
232 236
233 237
234 return true; 238 return true;
235 239
236} 240}
237bool KCal::operator==( const Todo& t1, const Todo& t2 ) 241bool KCal::operator==( const Todo& t1, const Todo& t2 )
238{ 242{
239 243
240 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); 244 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
241 if ( ! ret ) 245 if ( ! ret )
242 return false; 246 return false;
243 if ( t1.hasDueDate() == t2.hasDueDate() ) { 247 if ( t1.hasDueDate() == t2.hasDueDate() ) {
244 if ( t1.hasDueDate() ) { 248 if ( t1.hasDueDate() ) {
245 if ( t1.doesFloat() == t2.doesFloat() ) { 249 if ( t1.doesFloat() == t2.doesFloat() ) {
246 if ( t1.doesFloat() ) { 250 if ( t1.doesFloat() ) {
247 if ( t1.dtDue().date() != t2.dtDue().date() ) 251 if ( t1.dtDue().date() != t2.dtDue().date() )
248 return false; 252 return false;
249 } else 253 } else
250 if ( t1.dtDue() != t2.dtDue() ) 254 if ( t1.dtDue() != t2.dtDue() )
251 return false; 255 return false;
252 } else 256 } else
253 return false;// float != 257 return false;// float !=
254 } 258 }
255 259
256 } else 260 } else
257 return false; 261 return false;
258 if ( t1.percentComplete() != t2.percentComplete() ) 262 if ( t1.percentComplete() != t2.percentComplete() )
259 return false; 263 return false;
260 if ( t1.isCompleted() ) { 264 if ( t1.isCompleted() ) {
261 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { 265 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
262 if ( t1.hasCompletedDate() ) { 266 if ( t1.hasCompletedDate() ) {
263 if ( t1.completed() != t2.completed() ) 267 if ( t1.completed() != t2.completed() )
264 return false; 268 return false;
265 } 269 }
266 270
267 } else 271 } else
268 return false; 272 return false;
269 } 273 }
270 return true; 274 return true;
271 275
272} 276}
273 277
274void Todo::setDtDue(const QDateTime &dtDue) 278void Todo::setDtDue(const QDateTime &dtDue)
275{ 279{
276 //int diffsecs = mDtDue.secsTo(dtDue); 280 //int diffsecs = mDtDue.secsTo(dtDue);
277 281
278 /*if (mReadOnly) return; 282 /*if (mReadOnly) return;
279 const QPtrList<Alarm>& alarms = alarms(); 283 const QPtrList<Alarm>& alarms = alarms();
280 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { 284 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
281 if (alarm->enabled()) { 285 if (alarm->enabled()) {
282 alarm->setTime(alarm->time().addSecs(diffsecs)); 286 alarm->setTime(alarm->time().addSecs(diffsecs));
283 } 287 }
284 }*/ 288 }*/
285 mDtDue = getEvenTime(dtDue); 289 mDtDue = getEvenTime(dtDue);
286 290
287 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; 291 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
288 292
289 /*const QPtrList<Alarm>& alarms = alarms(); 293 /*const QPtrList<Alarm>& alarms = alarms();
290 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) 294 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
291 alarm->setAlarmStart(mDtDue);*/ 295 alarm->setAlarmStart(mDtDue);*/
292 updated(); 296 updated();
293} 297}
294 298
295QDateTime Todo::dtDue() const 299QDateTime Todo::dtDue() const
296{ 300{
297 return mDtDue; 301 return mDtDue;
298} 302}
299 303
300QString Todo::dtDueTimeStr() const 304QString Todo::dtDueTimeStr() const
301{ 305{
302 return KGlobal::locale()->formatTime(mDtDue.time()); 306 return KGlobal::locale()->formatTime(mDtDue.time());
303} 307}
304 308
305QString Todo::dtDueDateStr(bool shortfmt) const 309QString Todo::dtDueDateStr(bool shortfmt) const
306{ 310{
307 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 311 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
308} 312}
309 313
310QString Todo::dtDueStr(bool shortfmt) const 314QString Todo::dtDueStr(bool shortfmt) const
311{ 315{
312 if ( doesFloat() ) 316 if ( doesFloat() )
313 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 317 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
314 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); 318 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
315} 319}
316// retval 0 : no found 320// retval 0 : no found
317// 1 : due for date found 321// 1 : due for date found
318// 2 : overdue for date found 322// 2 : overdue for date found
319int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) 323int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos )
320{ 324{
321 int retval = 0; 325 int retval = 0;
322 if ( isCompleted() ) 326 if ( isCompleted() )
323 return 0; 327 return 0;
324 if ( hasDueDate() ) { 328 if ( hasDueDate() ) {
325 if ( dtDue().date() < date ) 329 if ( dtDue().date() < date )
326 return 2; 330 return 2;
327 // we do not return, because we may find an overdue sub todo 331 // we do not return, because we may find an overdue sub todo
328 if ( dtDue().date() == date ) 332 if ( dtDue().date() == date )
329 retval = 1; 333 retval = 1;
330 } 334 }
331 if ( checkSubtodos ) { 335 if ( checkSubtodos ) {
332 Incidence *aTodo; 336 Incidence *aTodo;
333 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 337 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
334 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); 338 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos );
335 if ( ret == 2 ) 339 if ( ret == 2 )
336 return 2; 340 return 2;
337 if ( ret == 1) 341 if ( ret == 1)
338 retval = 1; 342 retval = 1;
339 } 343 }
340 } 344 }
341 return retval; 345 return retval;
342} 346}
343int Todo::hasDueSubTodo( bool checkSubtodos ) //= true 347int Todo::hasDueSubTodo( bool checkSubtodos ) //= true
344{ 348{
345 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); 349 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos );
346} 350}
347bool Todo::hasDueDate() const 351bool Todo::hasDueDate() const
348{ 352{
349 return mHasDueDate; 353 return mHasDueDate;
350} 354}
351 355
352void Todo::setHasDueDate(bool f) 356void Todo::setHasDueDate(bool f)
353{ 357{
354 if (mReadOnly) return; 358 if (mReadOnly) return;
355 mHasDueDate = f; 359 mHasDueDate = f;
356 updated(); 360 updated();
357} 361}
358 362
359 363
360#if 0 364#if 0
361void Todo::setStatus(const QString &statStr) 365void Todo::setStatus(const QString &statStr)
362{ 366{
363 if (mReadOnly) return; 367 if (mReadOnly) return;
364 QString ss(statStr.upper()); 368 QString ss(statStr.upper());
365 369
366 if (ss == "X-ACTION") 370 if (ss == "X-ACTION")
367 mStatus = NEEDS_ACTION; 371 mStatus = NEEDS_ACTION;
368 else if (ss == "NEEDS ACTION") 372 else if (ss == "NEEDS ACTION")
369 mStatus = NEEDS_ACTION; 373 mStatus = NEEDS_ACTION;
370 else if (ss == "ACCEPTED") 374 else if (ss == "ACCEPTED")
371 mStatus = ACCEPTED; 375 mStatus = ACCEPTED;
372 else if (ss == "SENT") 376 else if (ss == "SENT")
373 mStatus = SENT; 377 mStatus = SENT;
374 else if (ss == "TENTATIVE") 378 else if (ss == "TENTATIVE")
375 mStatus = TENTATIVE; 379 mStatus = TENTATIVE;
376 else if (ss == "CONFIRMED") 380 else if (ss == "CONFIRMED")
377 mStatus = CONFIRMED; 381 mStatus = CONFIRMED;
378 else if (ss == "DECLINED") 382 else if (ss == "DECLINED")
379 mStatus = DECLINED; 383 mStatus = DECLINED;
380 else if (ss == "COMPLETED") 384 else if (ss == "COMPLETED")
381 mStatus = COMPLETED; 385 mStatus = COMPLETED;
382 else if (ss == "DELEGATED") 386 else if (ss == "DELEGATED")
383 mStatus = DELEGATED; 387 mStatus = DELEGATED;
384 388
385 updated(); 389 updated();
386} 390}
387 391
388void Todo::setStatus(int status) 392void Todo::setStatus(int status)
389{ 393{
390 if (mReadOnly) return; 394 if (mReadOnly) return;
391 mStatus = status; 395 mStatus = status;
392 updated(); 396 updated();
393} 397}
394 398
395int Todo::status() const 399int Todo::status() const
396{ 400{
397 return mStatus; 401 return mStatus;
398} 402}
399 403
400QString Todo::statusStr() const 404QString Todo::statusStr() const
401{ 405{
402 switch(mStatus) { 406 switch(mStatus) {
403 case NEEDS_ACTION: 407 case NEEDS_ACTION:
404 return QString("NEEDS ACTION"); 408 return QString("NEEDS ACTION");
405 break; 409 break;
406 case ACCEPTED: 410 case ACCEPTED:
407 return QString("ACCEPTED"); 411 return QString("ACCEPTED");
408 break; 412 break;
409 case SENT: 413 case SENT:
410 return QString("SENT"); 414 return QString("SENT");
411 break; 415 break;
412 case TENTATIVE: 416 case TENTATIVE:
413 return QString("TENTATIVE"); 417 return QString("TENTATIVE");
414 break; 418 break;
415 case CONFIRMED: 419 case CONFIRMED:
416 return QString("CONFIRMED"); 420 return QString("CONFIRMED");
417 break; 421 break;
418 case DECLINED: 422 case DECLINED:
419 return QString("DECLINED"); 423 return QString("DECLINED");
420 break; 424 break;
421 case COMPLETED: 425 case COMPLETED:
422 return QString("COMPLETED"); 426 return QString("COMPLETED");
423 break; 427 break;
424 case DELEGATED: 428 case DELEGATED:
425 return QString("DELEGATED"); 429 return QString("DELEGATED");
426 break; 430 break;
427 } 431 }
428 return QString(""); 432 return QString("");
429} 433}
430#endif 434#endif
431 435
432bool Todo::isCompleted() const 436bool Todo::isCompleted() const
433{ 437{
434 if (mPercentComplete == 100) { 438 if (mPercentComplete == 100) {
435 return true; 439 return true;
436 } 440 }
437 else return false; 441 else return false;
438} 442}
439 443
440void Todo::setCompleted(bool completed) 444void Todo::setCompleted(bool completed)
441{ 445{
442 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { 446 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
443 if ( !setRecurDates() ) 447 if ( !setRecurDates() )
444 completed = false; 448 completed = false;
445 } 449 }
446 if (completed) mPercentComplete = 100; 450 if (completed) mPercentComplete = 100;
447 else { 451 else {
448 mPercentComplete = 0; 452 mPercentComplete = 0;
449 mHasCompletedDate = false; 453 mHasCompletedDate = false;
450 } 454 }
451 updated(); 455 updated();
452} 456}
453 457
454QDateTime Todo::completed() const 458QDateTime Todo::completed() const
455{ 459{
456 return mCompleted; 460 return mCompleted;
457} 461}
458 462
459QString Todo::completedStr( bool shortF ) const 463QString Todo::completedStr( bool shortF ) const
460{ 464{
461 return KGlobal::locale()->formatDateTime(mCompleted, shortF); 465 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
462} 466}
463 467
464void Todo::setCompleted(const QDateTime &completed) 468void Todo::setCompleted(const QDateTime &completed)
465{ 469{
466 //qDebug("Todo::setCompleted "); 470 //qDebug("Todo::setCompleted ");
467 if ( mHasCompletedDate ) { 471 if ( mHasCompletedDate ) {
468 // qDebug("has completed data - return "); 472 // qDebug("has completed data - return ");
469 return; 473 return;
470 } 474 }
471 mHasCompletedDate = true; 475 mHasCompletedDate = true;
472 mPercentComplete = 100; 476 mPercentComplete = 100;
473 mCompleted = getEvenTime(completed); 477 mCompleted = getEvenTime(completed);
474 updated(); 478 updated();
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 501c2ba..6fc4d4b 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -1,151 +1,152 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef TODO_H 20#ifndef TODO_H
21#define TODO_H 21#define TODO_H
22// 22//
23// Todo component, representing a VTODO object 23// Todo component, representing a VTODO object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30namespace KCal { 30namespace KCal {
31 31
32/** 32/**
33 This class provides a Todo in the sense of RFC2445. 33 This class provides a Todo in the sense of RFC2445.
34*/ 34*/
35 class Todo : public QObject,public Incidence 35 class Todo : public QObject,public Incidence
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 Todo(); 39 Todo();
40 Todo(const Todo &); 40 Todo(const Todo &);
41 ~Todo(); 41 ~Todo();
42 typedef ListBase<Todo> List; 42 typedef ListBase<Todo> List;
43 QCString type() const { return "Todo"; } 43 QCString type() const { return "Todo"; }
44 IncTypeID typeID() const { return todoID; } 44 IncTypeID typeID() const { return todoID; }
45 45
46 /** Return an exact copy of this todo. */ 46 /** Return an exact copy of this todo. */
47 Incidence *clone(); 47 Incidence *clone();
48 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; 48 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const;
49 49
50 /** for setting the todo's due date/time with a QDateTime. */ 50 /** for setting the todo's due date/time with a QDateTime. */
51 void setDtDue(const QDateTime &dtDue); 51 void setDtDue(const QDateTime &dtDue);
52 /** returns an event's Due date/time as a QDateTime. */ 52 /** returns an event's Due date/time as a QDateTime. */
53 QDateTime dtDue() const; 53 QDateTime dtDue() const;
54 /** returns an event's due time as a string formatted according to the 54 /** returns an event's due time as a string formatted according to the
55 users locale settings */ 55 users locale settings */
56 QString dtDueTimeStr() const; 56 QString dtDueTimeStr() const;
57 /** returns an event's due date as a string formatted according to the 57 /** returns an event's due date as a string formatted according to the
58 users locale settings */ 58 users locale settings */
59 QString dtDueDateStr(bool shortfmt=true) const; 59 QString dtDueDateStr(bool shortfmt=true) const;
60 /** returns an event's due date and time as a string formatted according 60 /** returns an event's due date and time as a string formatted according
61 to the users locale settings */ 61 to the users locale settings */
62 QString dtDueStr(bool shortfmt=true) const; 62 QString dtDueStr(bool shortfmt=true) const;
63 63
64 /** returns TRUE or FALSE depending on whether the todo has a due date */ 64 /** returns TRUE or FALSE depending on whether the todo has a due date */
65 bool hasDueDate() const; 65 bool hasDueDate() const;
66 /** sets the event's hasDueDate value. */ 66 /** sets the event's hasDueDate value. */
67 void setHasDueDate(bool f); 67 void setHasDueDate(bool f);
68 68
69 /* 69 /*
70 Looks for a subtodo (including itself ) which is not complete and is 70 Looks for a subtodo (including itself ) which is not complete and is
71 - overdue, or 71 - overdue, or
72 - due today. 72 - due today.
73 It returns 0 for nothing found, 73 It returns 0 for nothing found,
74 1 for found a todo which is due today and no overdue found 74 1 for found a todo which is due today and no overdue found
75 2 for found a overdue todo 75 2 for found a overdue todo
76 */ 76 */
77 int hasDueSubTodo( bool checkSubtodos = true ); 77 int hasDueSubTodo( bool checkSubtodos = true );
78 /* same as above, but a specific date can be specified*/ 78 /* same as above, but a specific date can be specified*/
79 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); 79 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos );
80 80
81 81
82 /** sets the event's status to the string specified. The string 82 /** sets the event's status to the string specified. The string
83 * must be a recognized value for the status field, i.e. a string 83 * must be a recognized value for the status field, i.e. a string
84 * equivalent of the possible status enumerations previously described. */ 84 * equivalent of the possible status enumerations previously described. */
85// void setStatus(const QString &statStr); 85// void setStatus(const QString &statStr);
86 /** sets the event's status to the value specified. See the enumeration 86 /** sets the event's status to the value specified. See the enumeration
87 * above for possible values. */ 87 * above for possible values. */
88// void setStatus(int); 88// void setStatus(int);
89 /** return the event's status. */ 89 /** return the event's status. */
90// int status() const; 90// int status() const;
91 /** return the event's status in string format. */ 91 /** return the event's status in string format. */
92// QString statusStr() const; 92// QString statusStr() const;
93 93
94 /** return, if this todo is completed */ 94 /** return, if this todo is completed */
95 bool isCompleted() const; 95 bool isCompleted() const;
96 /** set completed state of this todo */ 96 /** set completed state of this todo */
97 void setCompleted(bool); 97 void setCompleted(bool);
98 98
99 /** 99 /**
100 Return how many percent of the task are completed. Returns a value 100 Return how many percent of the task are completed. Returns a value
101 between 0 and 100. 101 between 0 and 100.
102 */ 102 */
103 int percentComplete() const; 103 int percentComplete() const;
104 /** 104 /**
105 Set how many percent of the task are completed. Valid values are in the 105 Set how many percent of the task are completed. Valid values are in the
106 range from 0 to 100. 106 range from 0 to 100.
107 */ 107 */
108 void setPercentComplete(int); 108 void setPercentComplete(int);
109 109
110 /** return date and time when todo was completed */ 110 /** return date and time when todo was completed */
111 QDateTime completed() const; 111 QDateTime completed() const;
112 QString completedStr(bool shortF = true) const; 112 QString completedStr(bool shortF = true) const;
113 /** set date and time of completion */ 113 /** set date and time of completion */
114 void setCompleted(const QDateTime &completed); 114 void setCompleted(const QDateTime &completed);
115 115
116 /** Return true, if todo has a date associated with completion */ 116 /** Return true, if todo has a date associated with completion */
117 bool hasCompletedDate() const; 117 bool hasCompletedDate() const;
118 bool contains ( Todo*); 118 bool contains ( Todo*);
119 void checkSetCompletedFalse(); 119 void checkSetCompletedFalse();
120 bool setRecurDates(); 120 bool setRecurDates();
121 bool isRunning() {return mRunning;} 121 bool isRunning() {return mRunning;}
122 bool hasRunningSub(); 122 bool hasRunningSub();
123 void setRunning( bool ); 123 void setRunning( bool );
124 void setRunningFalse( QString ); 124 void setRunningFalse( QString );
125 int runTime(); 125 int runTime();
126 QDateTime runStart () const { return mRunStart;} 126 QDateTime runStart () const { return mRunStart;}
127 public slots: 127 public slots:
128 void saveRunningInfoToFile( QString st = QString::null ); 128 void saveRunningInfoToFile( QString st );
129 void saveRunningInfoToFile( );
129 void saveParents(); 130 void saveParents();
130 private: 131 private:
131 bool mRunning; 132 bool mRunning;
132 QTimer * mRunSaveTimer; 133 QTimer * mRunSaveTimer;
133 QDateTime mRunStart; 134 QDateTime mRunStart;
134 bool accept(Visitor &v) { return v.visit(this); } 135 bool accept(Visitor &v) { return v.visit(this); }
135 136
136 QDateTime mDtDue; // due date of todo 137 QDateTime mDtDue; // due date of todo
137 138
138 bool mHasDueDate; // if todo has associated due date 139 bool mHasDueDate; // if todo has associated due date
139 140
140// int mStatus; // confirmed/delegated/tentative/etc 141// int mStatus; // confirmed/delegated/tentative/etc
141 142
142 QDateTime mCompleted; 143 QDateTime mCompleted;
143 bool mHasCompletedDate; 144 bool mHasCompletedDate;
144 145
145 int mPercentComplete; 146 int mPercentComplete;
146}; 147};
147 148
148 bool operator==( const Todo&, const Todo& ); 149 bool operator==( const Todo&, const Todo& );
149} 150}
150 151
151#endif 152#endif