summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kofilterview.cpp8
-rw-r--r--korganizer/kofilterview.h8
-rw-r--r--korganizer/kotodoview.cpp15
3 files changed, 26 insertions, 5 deletions
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 6a6fff9..e86ec95 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,490 +1,496 @@
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#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qwhatsthis.h>
32 33
33 34
34#include <libkcal/calfilter.h> 35#include <libkcal/calfilter.h>
35 36
36#include "kofilterview.h" 37#include "kofilterview.h"
37#include "koprefs.h" 38#include "koprefs.h"
38#include <kiconloader.h> 39#include <kiconloader.h>
39#include <kglobal.h> 40#include <kglobal.h>
40#include <kglobalsettings.h> 41#include <kglobalsettings.h>
41#include <kcolorbutton.h> 42#include <kcolorbutton.h>
42#include <kmessagebox.h> 43#include <kmessagebox.h>
43 44
44 45
45 46
46 47
47 48
48KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 49KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
49 const char* name,WFlags fl ) 50 const char* name,WFlags fl )
50 : KOFilterView_base(parent,name,fl) 51 : KOFilterView_base(parent,name,fl)
51{ 52{
52 mFilters = filterList; 53 mFilters = filterList;
53 54
54 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 55 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
55 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 56 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
56 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 57 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
57} 58}
58 59
59KOFilterView::~KOFilterView() 60KOFilterView::~KOFilterView()
60{ 61{
61 // no need to delete child widgets, Qt does it all for us 62 // no need to delete child widgets, Qt does it all for us
62} 63}
63 64
64bool KOFilterView::filtersEnabled() 65bool KOFilterView::filtersEnabled()
65{ 66{
66 return mEnabledCheck->isChecked(); 67 return mEnabledCheck->isChecked();
67} 68}
68 69
69void KOFilterView::setFiltersEnabled(bool set) 70void KOFilterView::setFiltersEnabled(bool set)
70{ 71{
71 mEnabledCheck->setChecked(set); 72 mEnabledCheck->setChecked(set);
72 emit filterChanged(); 73 emit filterChanged();
73} 74}
74 75
75 76
76void KOFilterView::updateFilters() 77void KOFilterView::updateFilters()
77{ 78{
78 mSelectionCombo->clear(); 79 mSelectionCombo->clear();
79 80
80 CalFilter *filter = mFilters->first(); 81 CalFilter *filter = mFilters->first();
81 while(filter) { 82 while(filter) {
82 mSelectionCombo->insertItem(filter->name()); 83 mSelectionCombo->insertItem(filter->name());
83 filter = mFilters->next(); 84 filter = mFilters->next();
84 } 85 }
85} 86}
86 87
87CalFilter *KOFilterView::selectedFilter() 88CalFilter *KOFilterView::selectedFilter()
88{ 89{
89 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 90 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
90 return f; 91 return f;
91} 92}
92 93
93void KOFilterView::setSelectedFilter(QString filterName) 94void KOFilterView::setSelectedFilter(QString filterName)
94{ 95{
95 int filter_num = mSelectionCombo->count(); 96 int filter_num = mSelectionCombo->count();
96 int i; 97 int i;
97 for (i=0;i<filter_num;i++) { 98 for (i=0;i<filter_num;i++) {
98 if (mSelectionCombo->text(i)==filterName) 99 if (mSelectionCombo->text(i)==filterName)
99 mSelectionCombo->setCurrentItem(i); 100 mSelectionCombo->setCurrentItem(i);
100 } 101 }
101 emit filterChanged(); 102 emit filterChanged();
102} 103}
103void KOFilterView::setSelectedFilter( int fil ) 104void KOFilterView::setSelectedFilter( int fil )
104{ 105{
105 if ( fil >= mSelectionCombo->count() ) 106 if ( fil >= mSelectionCombo->count() )
106 return; 107 return;
107 mSelectionCombo->setCurrentItem( fil ); 108 mSelectionCombo->setCurrentItem( fil );
108 emit filterChanged(); 109 emit filterChanged();
109} 110}
110 111
111 112
112 113
113KOCalEditView::KOCalEditView(QWidget* parent, 114KOCalEditView::KOCalEditView(QWidget* parent,
114 const char* name ) 115 const char* name )
115 : QScrollView(parent,name) 116 : QScrollView(parent,name)
116{ 117{
117 mw = 0; 118 mw = 0;
118 setResizePolicy( AutoOneFit ); 119 setResizePolicy( AutoOneFit );
119 setFrameStyle ( QFrame::Panel | QFrame::Plain ); 120 setFrameStyle ( QFrame::Panel | QFrame::Plain );
120 setLineWidth ( 1 ); 121 setLineWidth ( 1 );
121 setMidLineWidth ( 1 ); 122 setMidLineWidth ( 1 );
122 setFocusPolicy(NoFocus); 123 setFocusPolicy(NoFocus);
123} 124}
124 125
125KOCalEditView::~KOCalEditView() 126KOCalEditView::~KOCalEditView()
126{ 127{
127 // no need to delete child widgets, Qt does it all for us 128 // no need to delete child widgets, Qt does it all for us
128} 129}
129void KOCalEditView::selectCal(int id ,bool b) 130void KOCalEditView::selectCal(int id ,bool b)
130{ 131{
131 KOPrefs::instance()->getCalendar( id )->isEnabled = b; 132 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
132 emit calendarEnabled ( id, b ); 133 emit calendarEnabled ( id, b );
133 emit needsUpdate(); 134 emit needsUpdate();
134 135
135} 136}
136void KOCalEditView::selectStdCal( int id ) 137void KOCalEditView::selectStdCal( int id )
137{ 138{
138 KOCalRadioButton* it = mStdandardB.first(); 139 KOCalRadioButton* it = mStdandardB.first();
139 while ( it ) { 140 while ( it ) {
140 it->blockSignals( true ); 141 it->blockSignals( true );
141 it->setChecked( it->num() == id ); 142 it->setChecked( it->num() == id );
142 it->blockSignals( false ); 143 it->blockSignals( false );
143 it = mStdandardB.next(); 144 it = mStdandardB.next();
144 } 145 }
145 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 146 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
146 while ( kkf ) { 147 while ( kkf ) {
147 kkf->isStandard = (kkf->mCalNumber == id ); 148 kkf->isStandard = (kkf->mCalNumber == id );
148 kkf = KOPrefs::instance()->mCalendars.next(); 149 kkf = KOPrefs::instance()->mCalendars.next();
149 } 150 }
150 emit setCalendarDefault ( id ); 151 emit setCalendarDefault ( id );
151} 152}
152 153
153void KOCalEditView::selectCalAlarm(int id ,bool b ) 154void KOCalEditView::selectCalAlarm(int id ,bool b )
154{ 155{
155 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; 156 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
156 emit alarmEnabled ( id , b ); 157 emit alarmEnabled ( id , b );
157 emit needsUpdate(); 158 emit needsUpdate();
158} 159}
159void KOCalEditView::selectReadOnly(int id ,bool b ) 160void KOCalEditView::selectReadOnly(int id ,bool b )
160{ 161{
161 162
162 emit calendarReadonly ( id , b ); 163 emit calendarReadonly ( id , b );
163 KOPrefs::instance()->getCalendar( id )->isReadOnly = b; 164 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
164 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) { 165 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) {
165 findNewStandard(); 166 findNewStandard();
166 } 167 }
167 if ( !b ){ 168 if ( !b ){
168 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 169 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
169 while ( kkf ) { 170 while ( kkf ) {
170 if (kkf->isReadOnly && kkf->isStandard ) { 171 if (kkf->isReadOnly && kkf->isStandard ) {
171 selectStdCal( id ); 172 selectStdCal( id );
172 break; 173 break;
173 } 174 }
174 kkf = KOPrefs::instance()->mCalendars.next(); 175 kkf = KOPrefs::instance()->mCalendars.next();
175 } 176 }
176 } 177 }
177 178
178 mStdandardB.at(id-1)->setEnabled( !b ); 179 mStdandardB.at(id-1)->setEnabled( !b );
179 emit needsUpdate(); 180 emit needsUpdate();
180 181
181} 182}
182void KOCalEditView::findNewStandard() 183void KOCalEditView::findNewStandard()
183{ 184{
184 bool found = false; 185 bool found = false;
185 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 186 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
186 while ( kkf ) { 187 while ( kkf ) {
187 if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) { 188 if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) {
188 found = true; 189 found = true;
189 selectStdCal( kkf->mCalNumber ); 190 selectStdCal( kkf->mCalNumber );
190 break; 191 break;
191 } 192 }
192 kkf = KOPrefs::instance()->mCalendars.next(); 193 kkf = KOPrefs::instance()->mCalendars.next();
193 } 194 }
194 if ( !found ) { 195 if ( !found ) {
195 KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"), 196 KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"),
196 i18n("Houston, we have a problem!") ); 197 i18n("Houston, we have a problem!") );
197 198
198 } 199 }
199} 200}
200 201
201void KOCalEditView::setColor( const QColor& c, int id ) 202void KOCalEditView::setColor( const QColor& c, int id )
202{ 203{
203 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; 204 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
204 emit needsUpdate(); 205 emit needsUpdate();
205} 206}
206void KOCalEditView::deleteCal( int id ) 207void KOCalEditView::deleteCal( int id )
207{ 208{
208 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 209 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
209 QString name = kkf->mName; 210 QString name = kkf->mName;
210 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 211 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
211 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; 212 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
212 bool findnewstd = kkf->isStandard; 213 bool findnewstd = kkf->isStandard;
213 emit removeCalendar ( id ); 214 emit removeCalendar ( id );
214 KOPrefs::instance()->mCalendars.remove ( kkf ); 215 KOPrefs::instance()->mCalendars.remove ( kkf );
215 if ( findnewstd ) findNewStandard(); 216 if ( findnewstd ) findNewStandard();
216 emit needsUpdate(); 217 emit needsUpdate();
217 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 218 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
218} 219}
219void KOCalEditView::infoCal( int id ) 220void KOCalEditView::infoCal( int id )
220{ 221{
221 QString name = KOPrefs::instance()->getCalendar( id )->mName; 222 QString name = KOPrefs::instance()->getCalendar( id )->mName;
222 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); 223 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 );
223 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { 224 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
224 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) ) ) { 225 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) ) ) {
225 emit calendarAdded( id ); 226 emit calendarAdded( id );
226 emit needsUpdate(); 227 emit needsUpdate();
227 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 228 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
228 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); 229 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) );
229 } 230 }
230 } 231 }
231 else 232 else
232 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); 233 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
233} 234}
234void KOCalEditView::readConfig() 235void KOCalEditView::readConfig()
235{ 236{
236 237
237 mStdandardB.clear(); 238 mStdandardB.clear();
238 mEnabledB.clear(); 239 mEnabledB.clear();
239 mAlarmB.clear(); 240 mAlarmB.clear();
240 mROB.clear(); 241 mROB.clear();
241 242
242 if ( mw ) delete mw; 243 if ( mw ) delete mw;
243 mw = new QWidget ( viewport() ); 244 mw = new QWidget ( viewport() );
244 addChild(mw); 245 addChild(mw);
245 int ii = 0; 246 int ii = 0;
246 mainLayout = new QGridLayout ( mw , 2, 8 ); 247 mainLayout = new QGridLayout ( mw , 2, 8 );
247 mainLayout->setMargin( 2 ); 248 mainLayout->setMargin( 2 );
248 mainLayout->setSpacing( 2 ); 249 mainLayout->setSpacing( 2 );
249 QPushButton * addButT = new QPushButton ( mw ); 250 QPushButton * addButT = new QPushButton ( mw );
250 addButT->setFocusPolicy(NoFocus); 251 addButT->setFocusPolicy(NoFocus);
251 mainLayout->addWidget( addButT,0,0 ); 252 mainLayout->addWidget( addButT,0,0 );
252 addButT->setText( "D"); 253 addButT->setText( "D");
253 connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo())); 254 connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo()));
255 QWhatsThis::add( addButT, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") );
254 //addBut->setPixmap ( SmallIcon("greenhook16")); 256 //addBut->setPixmap ( SmallIcon("greenhook16"));
255 QPushButton *addBut = new QPushButton ( mw ); 257 QPushButton *addBut = new QPushButton ( mw );
256 addBut->setFocusPolicy(NoFocus); 258 addBut->setFocusPolicy(NoFocus);
257 mainLayout->addWidget( addBut,0,++ii ); 259 mainLayout->addWidget( addBut,0,++ii );
258 addBut->setPixmap ( SmallIcon("eye")); 260 addBut->setPixmap ( SmallIcon("eye"));
261 QWhatsThis::add( addBut, i18n("In this column you can <b>set a calendar to be visible</b>. If a calendar is not visible its entries are not displayed in the views. You can add items to it and it is loaded/saved as usual.") );
259 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 262 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
260 int max = addBut->sizeHint().height(); 263 int max = addBut->sizeHint().height();
261 addBut->setMaximumWidth( max ); 264 addBut->setMaximumWidth( max );
262 addButT->setFixedSize( QSize( max, max ) ); 265 addButT->setFixedSize( QSize( max, max ) );
263 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); 266 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw );
264 mainLayout->addWidget( lab,0,++ii ); 267 mainLayout->addWidget( lab,0,++ii );
268 QWhatsThis::add( lab, i18n("In this column you can see the <b>name of the calendar</b>. If you click on the name button you will get an information box about the loaded calendar file. If the file was not loaded at startup you can try to load it here again.") );
265 //lab = new QLabel ( i18n(" "), mw ); 269 //lab = new QLabel ( i18n(" "), mw );
266 //mainLayout->addWidget( lab,0,++ii ); 270 //mainLayout->addWidget( lab,0,++ii );
267 //lab->setFixedWidth( 1 ); 271 //lab->setFixedWidth( 1 );
268 addBut = new QPushButton ( mw ); 272 addBut = new QPushButton ( mw );
269 addBut->setFocusPolicy(NoFocus); 273 addBut->setFocusPolicy(NoFocus);
270 mainLayout->addWidget( addBut,0,++ii ); 274 mainLayout->addWidget( addBut,0,++ii );
271 addBut->setPixmap ( SmallIcon("bell")); 275 addBut->setPixmap ( SmallIcon("bell"));
276 QWhatsThis::add( addBut, i18n("In this column you can <b>disable the alarms of a calendar all together</b>. The alarm data in the calendar itself is not changed, the alarms are marked internally as \"do not use\". Useful if you load a calendar of another person but do not want to get notified about alarms of that person.") );
272 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 277 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
273 addBut->setMaximumWidth( addBut->sizeHint().height() ); 278 addBut->setMaximumWidth( addBut->sizeHint().height() );
274 279
275 addBut = new QPushButton ( mw ); 280 addBut = new QPushButton ( mw );
276 addBut->setFocusPolicy(NoFocus); 281 addBut->setFocusPolicy(NoFocus);
277 mainLayout->addWidget( addBut,0,++ii ); 282 mainLayout->addWidget( addBut,0,++ii );
278 addBut->setPixmap ( SmallIcon("pencil")); 283 addBut->setPixmap ( SmallIcon("pencil"));
284 QWhatsThis::add( addBut, i18n("In this column you can <b>set a calendar and all entries of the calendar to read only</b>. If a calendar is readonly the entries cannot be edited and no items can be added to the calendar. If you change a setting of a calendar to readonly in this column all data will be saved because the data of a readonly calendar is not saved later.") );
279 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 285 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
280 addBut->setMaximumWidth( addBut->sizeHint().height() ); 286 addBut->setMaximumWidth( addBut->sizeHint().height() );
281 lab = new QLabel ( "", mw ); 287 lab = new QLabel ( "", mw );
282 mainLayout->addWidget( lab,0,++ii ); 288 mainLayout->addWidget( lab,0,++ii );
283 289
284 addBut = new QPushButton ( mw ); 290 addBut = new QPushButton ( mw );
285 addBut->setFocusPolicy(NoFocus); 291 addBut->setFocusPolicy(NoFocus);
286 mainLayout->addWidget( addBut,0,++ii ); 292 mainLayout->addWidget( addBut,0,++ii );
287 addBut->setPixmap ( SmallIcon("plus")); 293 addBut->setPixmap ( SmallIcon("plus"));
288 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 294 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
289 295 QWhatsThis::add( addBut, i18n("Click this button to <b>add a calendar</b>. You can add an existing calendar file or you can add a new calendar and KO/Pi creates a new empty calendar file for you.") );
290 lab = new QLabel ( " ", mw ); 296 lab = new QLabel ( " ", mw );
291 mainLayout->addWidget( lab,0,++ii ); 297 mainLayout->addWidget( lab,0,++ii );
292 298
293 299
294 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 300 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
295 int row = 1; 301 int row = 1;
296 bool errorLoadStandard = false; 302 bool errorLoadStandard = false;
297 while ( kkf ) { 303 while ( kkf ) {
298 int iii = 0; 304 int iii = 0;
299 KOCalRadioButton* rb = new KOCalRadioButton( mw ); 305 KOCalRadioButton* rb = new KOCalRadioButton( mw );
300 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); 306 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb );
301 rb->setChecked( kkf->isStandard ); 307 rb->setChecked( kkf->isStandard );
302 if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) ) 308 if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) )
303 errorLoadStandard = true; 309 errorLoadStandard = true;
304 rb->setNum( kkf->mCalNumber ); 310 rb->setNum( kkf->mCalNumber );
305 connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) ); 311 connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) );
306 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 312 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
307 rb->setEnabled( false ); 313 rb->setEnabled( false );
308 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 314 KOCalCheckButton* cb = new KOCalCheckButton( mw );
309 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); 315 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb );
310 cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad ); 316 cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad );
311 cb->setNum( kkf->mCalNumber ); 317 cb->setNum( kkf->mCalNumber );
312 if ( kkf->mErrorOnLoad ) 318 if ( kkf->mErrorOnLoad )
313 cb->setEnabled( false ); 319 cb->setEnabled( false );
314 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 320 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
315 KOCalButton* name = new KOCalButton( mw ); 321 KOCalButton* name = new KOCalButton( mw );
316 name->setNum( kkf->mCalNumber ); 322 name->setNum( kkf->mCalNumber );
317 name->setText( kkf->mName ); 323 name->setText( kkf->mName );
318 mainLayout->addWidget( name,row,++iii ); 324 mainLayout->addWidget( name,row,++iii );
319 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 325 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
320 //lab = new QLabel (" ", mw ); 326 //lab = new QLabel (" ", mw );
321 //mainLayout->addWidget( lab,row,++iii ); 327 //mainLayout->addWidget( lab,row,++iii );
322 cb = new KOCalCheckButton( mw ); 328 cb = new KOCalCheckButton( mw );
323 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); 329 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb );
324 cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); 330 cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad);
325 cb->setNum( kkf->mCalNumber ); 331 cb->setNum( kkf->mCalNumber );
326 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 332 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
327 if ( kkf->mErrorOnLoad ) 333 if ( kkf->mErrorOnLoad )
328 cb->setEnabled( false ); 334 cb->setEnabled( false );
329 cb = new KOCalCheckButton( mw ); 335 cb = new KOCalCheckButton( mw );
330 mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); 336 mainLayout->addWidget( cb,row,++iii );mROB.append( cb );
331 cb->setChecked( kkf->isReadOnly ); 337 cb->setChecked( kkf->isReadOnly );
332 cb->setNum( kkf->mCalNumber ); 338 cb->setNum( kkf->mCalNumber );
333 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 339 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
334 if ( kkf->mErrorOnLoad ) 340 if ( kkf->mErrorOnLoad )
335 cb->setEnabled( false ); 341 cb->setEnabled( false );
336 if ( row > 1) { 342 if ( row > 1) {
337 KColorButton *colb = new KColorButton( mw ); 343 KColorButton *colb = new KColorButton( mw );
338 mainLayout->addWidget( colb,row,++iii ); 344 mainLayout->addWidget( colb,row,++iii );
339 colb->setID( kkf->mCalNumber ); 345 colb->setID( kkf->mCalNumber );
340 colb->setColor( kkf->mDefaultColor ); 346 colb->setColor( kkf->mDefaultColor );
341 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); 347 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
342 KOCalButton* calb = new KOCalButton( mw ); 348 KOCalButton* calb = new KOCalButton( mw );
343 mainLayout->addWidget( calb,row,++iii ); 349 mainLayout->addWidget( calb,row,++iii );
344 calb->setNum( kkf->mCalNumber ); 350 calb->setNum( kkf->mCalNumber );
345 calb->setPixmap ( SmallIcon("minus")); 351 calb->setPixmap ( SmallIcon("minus"));
346 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 352 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
347 int hei = calb->sizeHint().height(); 353 int hei = calb->sizeHint().height();
348 //calb->setMaximumSize( hei*9/10, hei*9/10 ); 354 //calb->setMaximumSize( hei*9/10, hei*9/10 );
349 } 355 }
350 ++row; 356 ++row;
351 kkf = KOPrefs::instance()->mCalendars.next(); 357 kkf = KOPrefs::instance()->mCalendars.next();
352 } 358 }
353 if ( errorLoadStandard ) 359 if ( errorLoadStandard )
354 findNewStandard(); 360 findNewStandard();
355 lab = new QLabel ( "", mw ); 361 lab = new QLabel ( "", mw );
356 mainLayout->addWidget( lab,row,0 ); 362 mainLayout->addWidget( lab,row,0 );
357 mw->show(); 363 mw->show();
358 364
359} 365}
360 366
361void KOCalEditView::defaultInfo() 367void KOCalEditView::defaultInfo()
362{ 368{
363 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); 369 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") );
364} 370}
365void KOCalEditView::addCal() 371void KOCalEditView::addCal()
366{ 372{
367 bool tryagain = true; 373 bool tryagain = true;
368 QString name, file = KGlobalSettings::calendarDir()+"newCal.ics"; 374 QString name, file = KGlobalSettings::calendarDir()+"newCal.ics";
369 while ( tryagain ) { 375 while ( tryagain ) {
370 KONewCalPrefs prefs ( this ); 376 KONewCalPrefs prefs ( this );
371 prefs.nameE->setText( name ); 377 prefs.nameE->setText( name );
372 prefs.url->setURL( file ); 378 prefs.url->setURL( file );
373 if ( ! prefs.exec() ) 379 if ( ! prefs.exec() )
374 return; 380 return;
375 name = prefs.calName(); 381 name = prefs.calName();
376 file = prefs.calFileName(); 382 file = prefs.calFileName();
377 tryagain = false; 383 tryagain = false;
378 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 384 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
379 while ( kkf ) { 385 while ( kkf ) {
380 if ( kkf->mName == name ) { 386 if ( kkf->mName == name ) {
381 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); 387 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
382 name = ""; 388 name = "";
383 tryagain = true; 389 tryagain = true;
384 break; 390 break;
385 } 391 }
386 if ( kkf->mFileName == file ) { 392 if ( kkf->mFileName == file ) {
387 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); 393 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) );
388 tryagain = true; 394 tryagain = true;
389 file = KGlobalSettings::calendarDir()+"newCal.ics"; 395 file = KGlobalSettings::calendarDir()+"newCal.ics";
390 break; 396 break;
391 } 397 }
392 kkf = KOPrefs::instance()->mCalendars.next(); 398 kkf = KOPrefs::instance()->mCalendars.next();
393 } 399 }
394 QFileInfo fi ( file ); 400 QFileInfo fi ( file );
395 if ( fi.isDir() ) { 401 if ( fi.isDir() ) {
396 tryagain = true; 402 tryagain = true;
397 } 403 }
398 } 404 }
399 addCalendar ( name, file ); 405 addCalendar ( name, file );
400 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); 406 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) );
401} 407}
402int KOCalEditView::addCalendar( QString name, QString file, bool ask ) 408int KOCalEditView::addCalendar( QString name, QString file, bool ask )
403{ 409{
404 410
405 QFileInfo fi ( file ); 411 QFileInfo fi ( file );
406 QString absFile = file; 412 QString absFile = file;
407 bool isRelative = false; 413 bool isRelative = false;
408 if ( fi.isRelative() ) { 414 if ( fi.isRelative() ) {
409 isRelative = true; 415 isRelative = true;
410 absFile = KGlobalSettings::calendarDir()+file; 416 absFile = KGlobalSettings::calendarDir()+file;
411 fi.setFile( absFile ); 417 fi.setFile( absFile );
412 } else { 418 } else {
413 QString cd = KGlobalSettings::calendarDir(); 419 QString cd = KGlobalSettings::calendarDir();
414 if ( file.left( cd.length() ) == cd ) { 420 if ( file.left( cd.length() ) == cd ) {
415 isRelative = true; 421 isRelative = true;
416 file = fi.fileName (); 422 file = fi.fileName ();
417 fi.setFile( absFile ); 423 fi.setFile( absFile );
418 } 424 }
419 } 425 }
420 if (!fi.exists() ) { 426 if (!fi.exists() ) {
421 if ( ask ) 427 if ( ask )
422 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) 428 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No )
423 return 0; 429 return 0;
424 QFile fileIn( absFile ); 430 QFile fileIn( absFile );
425 if (!fileIn.open( IO_WriteOnly ) ) { 431 if (!fileIn.open( IO_WriteOnly ) ) {
426 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); 432 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
427 return 0; 433 return 0;
428 } 434 }
429 QTextStream tsIn( &fileIn ); 435 QTextStream tsIn( &fileIn );
430 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 436 tsIn.setCodec( QTextCodec::codecForName("utf8") );
431 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; 437 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
432 fileIn.close(); 438 fileIn.close();
433 } 439 }
434 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 440 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
435 kkf->mName = name; 441 kkf->mName = name;
436 kkf->mFileName = absFile; 442 kkf->mFileName = absFile;
437 kkf->mSavedFileName = file; 443 kkf->mSavedFileName = file;
438 kkf->isRelative = isRelative; 444 kkf->isRelative = isRelative;
439 emit calendarAdded( kkf->mCalNumber ); 445 emit calendarAdded( kkf->mCalNumber );
440 if ( ask ) 446 if ( ask )
441 emit needsUpdate(); 447 emit needsUpdate();
442 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 448 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
443 return kkf->mCalNumber; 449 return kkf->mCalNumber;
444} 450}
445int KOCalEditView::getBirtdayID() 451int KOCalEditView::getBirtdayID()
446{ 452{
447 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 453 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
448 while ( kkf ) { 454 while ( kkf ) {
449 if ( kkf->mName == i18n("Birthdays") ) 455 if ( kkf->mName == i18n("Birthdays") )
450 return kkf->mCalNumber; 456 return kkf->mCalNumber;
451 kkf = KOPrefs::instance()->mCalendars.next(); 457 kkf = KOPrefs::instance()->mCalendars.next();
452 } 458 }
453 QString file = locateLocal( "data", "korganizer/birthdays.ics" ); 459 QString file = locateLocal( "data", "korganizer/birthdays.ics" );
454 return addCalendar( i18n("Birthdays"), file, false ); 460 return addCalendar( i18n("Birthdays"), file, false );
455} 461}
456 462
457void KOCalEditView::enableAll() 463void KOCalEditView::enableAll()
458{ 464{
459 toggleList( mEnabledB ); 465 toggleList( mEnabledB );
460} 466}
461void KOCalEditView::enableAlarm() 467void KOCalEditView::enableAlarm()
462{ 468{
463 toggleList( mAlarmB ); 469 toggleList( mAlarmB );
464} 470}
465void KOCalEditView::disableRO() 471void KOCalEditView::disableRO()
466{ 472{
467 toggleList( mROB, false ); 473 toggleList( mROB, false );
468} 474}
469void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) 475void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable )
470{ 476{
471 bool dis = !enable; 477 bool dis = !enable;
472 KOCalCheckButton* it = list.first(); 478 KOCalCheckButton* it = list.first();
473 while ( it ) { 479 while ( it ) {
474 if ( !it->isChecked() == enable && it->isEnabled() ) { 480 if ( !it->isChecked() == enable && it->isEnabled() ) {
475 dis = !dis; 481 dis = !dis;
476 break; 482 break;
477 } 483 }
478 it = list.next(); 484 it = list.next();
479 } 485 }
480 it = list.first(); 486 it = list.first();
481 while ( it ) { 487 while ( it ) {
482 if ( it->isEnabled() ) 488 if ( it->isEnabled() )
483 it->setChecked(dis); 489 it->setChecked(dis);
484 it = list.next(); 490 it = list.next();
485 } 491 }
486} 492}
487void KOCalEditView::deleteAll() 493void KOCalEditView::deleteAll()
488{ 494{
489 qDebug("delteAll"); 495 qDebug("delteAll");
490} 496}
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h
index be7b5b6..d534dbf 100644
--- a/korganizer/kofilterview.h
+++ b/korganizer/kofilterview.h
@@ -1,256 +1,256 @@
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 KOFILTERVIEW_H 23#ifndef KOFILTERVIEW_H
24#define KOFILTERVIEW_H 24#define KOFILTERVIEW_H
25 25
26#include <qstring.h> 26#include <qstring.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qapplication.h> 28#include <qapplication.h>
29#include <qradiobutton.h> 29#include <qradiobutton.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qscrollview.h> 33#include <qscrollview.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include "kofilterview_base.h" 36#include "kofilterview_base.h"
37 37
38#include <libkcal/calfilter.h> 38#include <libkcal/calfilter.h>
39 39
40#include <kurlrequester.h> 40#include <kurlrequester.h>
41#include <klineedit.h> 41#include <klineedit.h>
42#include <kglobal.h> 42#include <kglobal.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44 44
45class QGridLayout; 45class QGridLayout;
46 46
47using namespace KCal; 47using namespace KCal;
48 48
49class KONewCalPrefs : public QDialog 49class KONewCalPrefs : public QDialog
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : 53 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
54 QDialog( parent, name, true ) 54 QDialog( parent, name, true )
55 { 55 {
56 setCaption( i18n("Add new Calendar") ); 56 setCaption( i18n("Add new Calendar") );
57 QVBoxLayout* lay = new QVBoxLayout( this ); 57 QVBoxLayout* lay = new QVBoxLayout( this );
58 lay->setSpacing( 3 ); 58 lay->setSpacing( 3 );
59 lay->setMargin( 3 ); 59 lay->setMargin( 3 );
60 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); 60 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
61 lay->addWidget( lab ); 61 lay->addWidget( lab );
62 nameE = new KLineEdit( this ); 62 nameE = new KLineEdit( this );
63 lay->addWidget( nameE ); 63 lay->addWidget( nameE );
64 lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this ); 64 lab = new QLabel( i18n("<b>iCal (*.ics) file on disk:</b><br>(will be created, if not existing)"), this );
65 lay->addWidget( lab ); 65 lay->addWidget( lab );
66 url = new KURLRequester ( this ); 66 url = new KURLRequester ( this );
67 lay->addWidget( url ); 67 lay->addWidget( url );
68 QPushButton * ok = new QPushButton( i18n("OK"), this ); 68 QPushButton * ok = new QPushButton( i18n("OK"), this );
69 lay->addWidget( ok ); 69 lay->addWidget( ok );
70 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 70 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
71 lay->addWidget( cancel ); 71 lay->addWidget( cancel );
72 connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) ); 72 connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) );
73 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 73 connect (cancel, SIGNAL( clicked() ), this, SLOT ( reject()) );
74 int minwid = 220; 74 int minwid = 440;
75 if ( QApplication::desktop()->width() >= 320 ) minwid = 300; 75 if ( QApplication::desktop()->width() < 480 ) minwid = 220;
76 setMinimumWidth( minwid ); 76 setMinimumWidth( minwid );
77 resize(sizeHint() ); 77 resize(sizeHint() );
78 } 78 }
79 79
80 QString calName() { return nameE->text(); } 80 QString calName() { return nameE->text(); }
81 QString calFileName() { return url->url(); } 81 QString calFileName() { return url->url(); }
82 82
83public slots: 83public slots:
84void checkValid() { 84void checkValid() {
85 if ( nameE->text().isEmpty() ) { 85 if ( nameE->text().isEmpty() ) {
86 KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") ); 86 KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") );
87 nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () )); 87 nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () ));
88 return; 88 return;
89 } 89 }
90 if ( url->url().isEmpty() ) { 90 if ( url->url().isEmpty() ) {
91 KMessageBox::information( this, i18n("Sorry, the file name is empty!") ); 91 KMessageBox::information( this, i18n("Sorry, the file name is empty!") );
92 url->setURL( nameE->text() + ".ics" ); 92 url->setURL( nameE->text() + ".ics" );
93 return; 93 return;
94 } 94 }
95 accept(); 95 accept();
96} 96}
97 97
98public: 98public:
99 KLineEdit* nameE; 99 KLineEdit* nameE;
100 KURLRequester *url; 100 KURLRequester *url;
101}; 101};
102 102
103class KOCalButton : public QPushButton 103class KOCalButton : public QPushButton
104{ 104{
105 Q_OBJECT 105 Q_OBJECT
106 public: 106 public:
107 KOCalButton( QWidget *parent=0, const char *name=0 ) : 107 KOCalButton( QWidget *parent=0, const char *name=0 ) :
108 QPushButton( parent, name) 108 QPushButton( parent, name)
109 { 109 {
110 connect( this, SIGNAL( clicked() ), 110 connect( this, SIGNAL( clicked() ),
111 SLOT( bottonClicked() )); 111 SLOT( bottonClicked() ));
112 mNumber = -1; 112 mNumber = -1;
113 setFocusPolicy(NoFocus); 113 setFocusPolicy(NoFocus);
114 } 114 }
115 void setNum ( int num ) {mNumber = num; } 115 void setNum ( int num ) {mNumber = num; }
116 signals: 116 signals:
117 void selectNum ( int ); 117 void selectNum ( int );
118private: 118private:
119 int mNumber; 119 int mNumber;
120 void keyPressEvent ( QKeyEvent * e ) 120 void keyPressEvent ( QKeyEvent * e )
121 { 121 {
122 e->ignore(); 122 e->ignore();
123 } 123 }
124 124
125private slots : 125private slots :
126 void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); } 126 void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); }
127}; 127};
128class KOCalCheckButton : public QCheckBox 128class KOCalCheckButton : public QCheckBox
129{ 129{
130 Q_OBJECT 130 Q_OBJECT
131 public: 131 public:
132 KOCalCheckButton( QWidget *parent=0, const char *name=0 ) : 132 KOCalCheckButton( QWidget *parent=0, const char *name=0 ) :
133 QCheckBox( parent, name) 133 QCheckBox( parent, name)
134 { 134 {
135 connect( this, SIGNAL( toggled ( bool ) ), 135 connect( this, SIGNAL( toggled ( bool ) ),
136 SLOT( bottonClicked( bool ) )); 136 SLOT( bottonClicked( bool ) ));
137 mNumber = -1; 137 mNumber = -1;
138 setFocusPolicy(NoFocus); 138 setFocusPolicy(NoFocus);
139 //setMaximumWidth( 10 ); 139 //setMaximumWidth( 10 );
140 140
141 } 141 }
142 void setNum ( int num ) {mNumber = num; } 142 void setNum ( int num ) {mNumber = num; }
143 signals: 143 signals:
144 void selectNum ( int, bool ); 144 void selectNum ( int, bool );
145private: 145private:
146 int mNumber; 146 int mNumber;
147 void keyPressEvent ( QKeyEvent * e ) 147 void keyPressEvent ( QKeyEvent * e )
148 { 148 {
149 e->ignore(); 149 e->ignore();
150 } 150 }
151 151
152private slots : 152private slots :
153 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } 153 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); }
154}; 154};
155 155
156class KOCalRadioButton : public QRadioButton 156class KOCalRadioButton : public QRadioButton
157{ 157{
158 Q_OBJECT 158 Q_OBJECT
159 public: 159 public:
160 KOCalRadioButton( QWidget *parent=0, const char *name=0 ) : 160 KOCalRadioButton( QWidget *parent=0, const char *name=0 ) :
161 QRadioButton( parent, name) 161 QRadioButton( parent, name)
162 { 162 {
163 connect( this, SIGNAL( toggled ( bool ) ), 163 connect( this, SIGNAL( toggled ( bool ) ),
164 SLOT( bottonClicked( bool ) )); 164 SLOT( bottonClicked( bool ) ));
165 mNumber = -1; 165 mNumber = -1;
166 setFocusPolicy(NoFocus); 166 setFocusPolicy(NoFocus);
167 //setMaximumWidth( 10 ); 167 //setMaximumWidth( 10 );
168 168
169 } 169 }
170 int num() { return mNumber;} 170 int num() { return mNumber;}
171 void setNum ( int num ) {mNumber = num; } 171 void setNum ( int num ) {mNumber = num; }
172 signals: 172 signals:
173 void selectNum ( int ); 173 void selectNum ( int );
174private: 174private:
175 int mNumber; 175 int mNumber;
176 void keyPressEvent ( QKeyEvent * e ) 176 void keyPressEvent ( QKeyEvent * e )
177 { 177 {
178 e->ignore(); 178 e->ignore();
179 } 179 }
180 180
181private slots : 181private slots :
182 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber); } 182 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber); }
183}; 183};
184 184
185 185
186 186
187class KOFilterView : public KOFilterView_base 187class KOFilterView : public KOFilterView_base
188{ 188{
189 Q_OBJECT 189 Q_OBJECT
190 public: 190 public:
191 KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0); 191 KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0);
192 ~KOFilterView(); 192 ~KOFilterView();
193 193
194 void updateFilters(); 194 void updateFilters();
195 195
196 bool filtersEnabled(); 196 bool filtersEnabled();
197 void setFiltersEnabled(bool); 197 void setFiltersEnabled(bool);
198 CalFilter *selectedFilter(); 198 CalFilter *selectedFilter();
199 void setSelectedFilter(QString); 199 void setSelectedFilter(QString);
200 void setSelectedFilter( int ); 200 void setSelectedFilter( int );
201 201
202 signals: 202 signals:
203 void filterChanged(); 203 void filterChanged();
204 void editFilters(); 204 void editFilters();
205 205
206 private: 206 private:
207 QPtrList<CalFilter> *mFilters; 207 QPtrList<CalFilter> *mFilters;
208}; 208};
209 209
210class KOCalEditView : public QScrollView 210class KOCalEditView : public QScrollView
211{ 211{
212 Q_OBJECT 212 Q_OBJECT
213 public: 213 public:
214 KOCalEditView( QWidget* parent=0,const char* name=0); 214 KOCalEditView( QWidget* parent=0,const char* name=0);
215 ~KOCalEditView(); 215 ~KOCalEditView();
216 int addCalendar( QString calName, QString fileName, bool ask = true ); 216 int addCalendar( QString calName, QString fileName, bool ask = true );
217 int getBirtdayID(); 217 int getBirtdayID();
218 public slots: 218 public slots:
219 void addCal(); 219 void addCal();
220 void enableAll(); 220 void enableAll();
221 void enableAlarm(); 221 void enableAlarm();
222 void disableRO(); 222 void disableRO();
223 void deleteAll(); 223 void deleteAll();
224 void selectStdCal(int); 224 void selectStdCal(int);
225 void selectCal(int,bool ); 225 void selectCal(int,bool );
226 void selectCalAlarm(int,bool ); 226 void selectCalAlarm(int,bool );
227 void selectReadOnly(int,bool ); 227 void selectReadOnly(int,bool );
228 void setColor(const QColor &,int) ; 228 void setColor(const QColor &,int) ;
229 void deleteCal(int) ; 229 void deleteCal(int) ;
230 void infoCal(int) ; 230 void infoCal(int) ;
231 void readConfig(); 231 void readConfig();
232 void defaultInfo(); 232 void defaultInfo();
233 void findNewStandard(); 233 void findNewStandard();
234 signals: 234 signals:
235 void alarmEnabled ( int cal, bool enable ); 235 void alarmEnabled ( int cal, bool enable );
236 void calendarEnabled ( int cal, bool enable ); 236 void calendarEnabled ( int cal, bool enable );
237 void calendarReadonly ( int cal, bool readonly ); 237 void calendarReadonly ( int cal, bool readonly );
238 void setCalendarDefault ( int cal ); 238 void setCalendarDefault ( int cal );
239 void removeCalendar ( int cal ); 239 void removeCalendar ( int cal );
240 void calendarAdded( int ); 240 void calendarAdded( int );
241 void needsUpdate(); 241 void needsUpdate();
242 void checkCalendar(); 242 void checkCalendar();
243 243
244 private: 244 private:
245 QWidget *mw; 245 QWidget *mw;
246 void toggleList ( QPtrList<KOCalCheckButton> , bool b = true ); 246 void toggleList ( QPtrList<KOCalCheckButton> , bool b = true );
247 QPtrList<KOCalRadioButton> mStdandardB; 247 QPtrList<KOCalRadioButton> mStdandardB;
248 QPtrList<KOCalCheckButton> mEnabledB; 248 QPtrList<KOCalCheckButton> mEnabledB;
249 QPtrList<KOCalCheckButton> mAlarmB; 249 QPtrList<KOCalCheckButton> mAlarmB;
250 QPtrList<KOCalCheckButton> mROB; 250 QPtrList<KOCalCheckButton> mROB;
251 QGridLayout* mainLayout; 251 QGridLayout* mainLayout;
252}; 252};
253 253
254 254
255 255
256#endif // KOFILTERVIEW_H 256#endif // KOFILTERVIEW_H
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 27d755e..17248dc 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1735 +1,1750 @@
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 ( !isVisible() ) { 405 if ( !isVisible() ) {
406 e->ignore(); 406 e->ignore();
407 return; 407 return;
408 } 408 }
409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
410 e->ignore(); 410 e->ignore();
411 // qDebug(" ignore %d",e->isAutoRepeat() ); 411 // qDebug(" ignore %d",e->isAutoRepeat() );
412 return; 412 return;
413 } 413 }
414 if (! e->isAutoRepeat() ) 414 if (! e->isAutoRepeat() )
415 mFlagKeyPressed = true; 415 mFlagKeyPressed = true;
416 QListViewItem* cn; 416 QListViewItem* cn;
417 if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") { 417 if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") {
418 cn = currentItem(); 418 cn = currentItem();
419 if ( cn ) { 419 if ( cn ) {
420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
421 if ( ci ){ 421 if ( ci ){
422 if ( e->state() == ShiftButton ) 422 if ( e->state() == ShiftButton )
423 ci->setOn( false ); 423 ci->setOn( false );
424 else 424 else
425 ci->setOn( true ); 425 ci->setOn( true );
426 cn = cn->itemBelow(); 426 cn = cn->itemBelow();
427 if ( cn ) { 427 if ( cn ) {
428 setCurrentItem ( cn ); 428 setCurrentItem ( cn );
429 ensureItemVisible ( cn ); 429 ensureItemVisible ( cn );
430 } 430 }
431 431
432 } 432 }
433 } 433 }
434 434
435 e->accept(); 435 e->accept();
436 return; 436 return;
437 } 437 }
438 438
439 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 439 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
440 switch ( e->key() ) { 440 switch ( e->key() ) {
441 case Qt::Key_Down: 441 case Qt::Key_Down:
442 case Qt::Key_Up: 442 case Qt::Key_Up:
443 QListView::keyPressEvent ( e ); 443 QListView::keyPressEvent ( e );
444 e->accept(); 444 e->accept();
445 break; 445 break;
446 case Qt::Key_Left: 446 case Qt::Key_Left:
447 case Qt::Key_Right: 447 case Qt::Key_Right:
448 QListView::keyPressEvent ( e ); 448 QListView::keyPressEvent ( e );
449 e->accept(); 449 e->accept();
450 return; 450 return;
451 break; 451 break;
452 default: 452 default:
453 e->ignore(); 453 e->ignore();
454 break; 454 break;
455 } 455 }
456 return; 456 return;
457 } 457 }
458 e->ignore(); 458 e->ignore();
459} 459}
460void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 460void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
461{ 461{
462 QListView::contentsMouseReleaseEvent(e); 462 QListView::contentsMouseReleaseEvent(e);
463 mMousePressed = false; 463 mMousePressed = false;
464} 464}
465 465
466void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 466void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
467{ 467{
468 if (!e) return; 468 if (!e) return;
469 469
470 QPoint vp = contentsToViewport(e->pos()); 470 QPoint vp = contentsToViewport(e->pos());
471 471
472 QListViewItem *item = itemAt(vp); 472 QListViewItem *item = itemAt(vp);
473 473
474 emit double_Clicked(item); 474 emit double_Clicked(item);
475 if (!item) return; 475 if (!item) return;
476 476
477 emit doubleClicked(item,vp,0); 477 emit doubleClicked(item,vp,0);
478} 478}
479 479
480///////////////////////////////////////////////////////////////////////////// 480/////////////////////////////////////////////////////////////////////////////
481 481
482KOQuickTodo::KOQuickTodo(QWidget *parent) : 482KOQuickTodo::KOQuickTodo(QWidget *parent) :
483 QLineEdit(parent) 483 QLineEdit(parent)
484{ 484{
485 setText(i18n("Click to add new Todo")); 485 setText(i18n("Click to add new Todo"));
486 setFocusPolicy ( QWidget::ClickFocus );
486} 487}
487 488
488void KOQuickTodo::focusInEvent(QFocusEvent *ev) 489void KOQuickTodo::focusInEvent(QFocusEvent *ev)
489{ 490{
490 if ( text()==i18n("Click to add new Todo") ) 491 if ( text()==i18n("Click to add new Todo") )
491 setText(""); 492 setText("");
492 QLineEdit::focusInEvent(ev); 493 QLineEdit::focusInEvent(ev);
493} 494}
494 495
495void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 496void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
496{ 497{
497 setText(i18n("Click to add new Todo")); 498 setText(i18n("Click to add new Todo"));
498 QLineEdit::focusOutEvent(ev); 499 QLineEdit::focusOutEvent(ev);
499} 500}
500 501
501///////////////////////////////////////////////////////////////////////////// 502/////////////////////////////////////////////////////////////////////////////
502 503
503KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 504KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
504 KOrg::BaseView(calendar,parent,name) 505 KOrg::BaseView(calendar,parent,name)
505{ 506{
506 mActiveItem = 0; 507 mActiveItem = 0;
507 mCategoryPopupMenu = 0; 508 mCategoryPopupMenu = 0;
508 mPendingUpdateBeforeRepaint = false; 509 mPendingUpdateBeforeRepaint = false;
509 isFlatDisplay = false; 510 isFlatDisplay = false;
510 mNavigator = 0; 511 mNavigator = 0;
511 QBoxLayout *topLayout = new QVBoxLayout(this); 512 QBoxLayout *topLayout = new QVBoxLayout(this);
512 mName = QString ( name ); 513 mName = QString ( name );
513 mBlockUpdate = false; 514 mBlockUpdate = false;
514 mQuickBar = new QWidget( this ); 515 mQuickBar = new QWidget( this );
515 topLayout->addWidget(mQuickBar); 516 topLayout->addWidget(mQuickBar);
516 517
517 mQuickAdd = new KOQuickTodo(mQuickBar); 518 mQuickAdd = new KOQuickTodo(mQuickBar);
518 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); 519 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar);
519 quickLayout->addWidget( mQuickAdd ); 520 quickLayout->addWidget( mQuickAdd );
520 mNewSubBut = new QPushButton( "sub",mQuickBar ); 521 mNewSubBut = new QPushButton( "sub",mQuickBar );
521 QPushButton * s_done = new QPushButton( "D",mQuickBar ); 522 QPushButton * s_done = new QPushButton( "D",mQuickBar );
522 QPushButton * s_run = new QPushButton( "R",mQuickBar ); 523 QPushButton * s_run = new QPushButton( "R",mQuickBar );
523 QPushButton * allopen = new QPushButton( "O",mQuickBar ); 524 QPushButton * allopen = new QPushButton( "O",mQuickBar );
524 QPushButton * allclose = new QPushButton( "C",mQuickBar ); 525 QPushButton * allclose = new QPushButton( "C",mQuickBar );
525 QPushButton * flat = new QPushButton( "F",mQuickBar ); 526 QPushButton * flat = new QPushButton( "F",mQuickBar );
526 527
527 int fixwid = mQuickAdd->sizeHint().height(); 528 int fixwid = mQuickAdd->sizeHint().height();
528 int fixhei = fixwid; 529 int fixhei = fixwid;
529 if ( QApplication::desktop()->width() > 800 ) 530 if ( QApplication::desktop()->width() > 800 )
530 fixwid = (fixwid*3)/2; 531 fixwid = (fixwid*3)/2;
531 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); 532 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat()));
532 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); 533 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen()));
533 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); 534 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose()));
534 s_done->setPixmap( SmallIcon("greenhook16")); 535 s_done->setPixmap( SmallIcon("greenhook16"));
535 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); 536 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted()));
536 s_run->setPixmap( SmallIcon("ko16old")); 537 s_run->setPixmap( SmallIcon("ko16old"));
537 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); 538 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning()));
538 539
539 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); 540 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo()));
540 541
541 mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); 542 mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() );
542 mNewSubBut->setEnabled( false ); 543 mNewSubBut->setEnabled( false );
543 flat->setFixedWidth( fixwid ); 544 flat->setFixedWidth( fixwid );
544 s_done->setFixedWidth( fixwid ); 545 s_done->setFixedWidth( fixwid );
545 allopen->setFixedWidth( fixwid ); 546 allopen->setFixedWidth( fixwid );
546 allclose->setFixedWidth( fixwid ); 547 allclose->setFixedWidth( fixwid );
547 s_run->setFixedWidth( fixwid ); 548 s_run->setFixedWidth( fixwid );
548 549
549 flat->setFixedHeight(fixhei ); 550 flat->setFixedHeight(fixhei );
550 s_done->setFixedHeight(fixhei ); 551 s_done->setFixedHeight(fixhei );
551 allopen->setFixedHeight(fixhei ); 552 allopen->setFixedHeight(fixhei );
552 allclose->setFixedHeight(fixhei ); 553 allclose->setFixedHeight(fixhei );
553 s_run->setFixedHeight(fixhei ); 554 s_run->setFixedHeight(fixhei );
554 mNewSubBut->setFixedHeight(fixhei ); 555 mNewSubBut->setFixedHeight(fixhei );
556
557 flat->setFocusPolicy( NoFocus );
558 s_done->setFocusPolicy( NoFocus );
559 allopen->setFocusPolicy( NoFocus );
560 allclose->setFocusPolicy( NoFocus );
561 s_run->setFocusPolicy( NoFocus );
562 mNewSubBut->setFocusPolicy( NoFocus );
555 563
564 QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) );
565 QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) );
566 QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) );
567 QWhatsThis::add( s_run, i18n("Click this button to toggle show/hide <b>running</b> todos" ) );
568 QWhatsThis::add( mNewSubBut, i18n("Click this button to add a new subtodo to the currently selected todo" ) );
569 QWhatsThis::add( s_done, i18n("Click this button to toggle show/hide <b>completed</b> todos" ) );
570
556 quickLayout->addWidget( mNewSubBut ); 571 quickLayout->addWidget( mNewSubBut );
557 quickLayout->addWidget( s_done ); 572 quickLayout->addWidget( s_done );
558 quickLayout->addWidget( s_run ); 573 quickLayout->addWidget( s_run );
559 quickLayout->addWidget( allopen ); 574 quickLayout->addWidget( allopen );
560 quickLayout->addWidget( allclose ); 575 quickLayout->addWidget( allclose );
561 quickLayout->addWidget( flat ); 576 quickLayout->addWidget( flat );
562 577
563 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); 578 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide();
564 579
565 mTodoListView = new KOTodoListView(calendar,this, name ); 580 mTodoListView = new KOTodoListView(calendar,this, name );
566 topLayout->addWidget(mTodoListView); 581 topLayout->addWidget(mTodoListView);
567 //mTodoListView->header()->setMaximumHeight(30); 582 //mTodoListView->header()->setMaximumHeight(30);
568 mTodoListView->setRootIsDecorated(true); 583 mTodoListView->setRootIsDecorated(true);
569 mTodoListView->setAllColumnsShowFocus(true); 584 mTodoListView->setAllColumnsShowFocus(true);
570 585
571 mTodoListView->setShowSortIndicator(true); 586 mTodoListView->setShowSortIndicator(true);
572 587
573 mTodoListView->addColumn(i18n("Todo")); 588 mTodoListView->addColumn(i18n("Todo"));
574 mTodoListView->addColumn(i18n("Prio")); 589 mTodoListView->addColumn(i18n("Prio"));
575 mTodoListView->setColumnAlignment(1,AlignHCenter); 590 mTodoListView->setColumnAlignment(1,AlignHCenter);
576 mTodoListView->addColumn(i18n("Complete")); 591 mTodoListView->addColumn(i18n("Complete"));
577 mTodoListView->setColumnAlignment(2,AlignCenter); 592 mTodoListView->setColumnAlignment(2,AlignCenter);
578 593
579 mTodoListView->addColumn(i18n("Due Date")); 594 mTodoListView->addColumn(i18n("Due Date"));
580 mTodoListView->setColumnAlignment(3,AlignLeft); 595 mTodoListView->setColumnAlignment(3,AlignLeft);
581 mTodoListView->addColumn(i18n("Due Time")); 596 mTodoListView->addColumn(i18n("Due Time"));
582 mTodoListView->setColumnAlignment(4,AlignHCenter); 597 mTodoListView->setColumnAlignment(4,AlignHCenter);
583 598
584 mTodoListView->addColumn(i18n("Start Date")); 599 mTodoListView->addColumn(i18n("Start Date"));
585 mTodoListView->setColumnAlignment(5,AlignLeft); 600 mTodoListView->setColumnAlignment(5,AlignLeft);
586 mTodoListView->addColumn(i18n("Start Time")); 601 mTodoListView->addColumn(i18n("Start Time"));
587 mTodoListView->setColumnAlignment(6,AlignHCenter); 602 mTodoListView->setColumnAlignment(6,AlignHCenter);
588 603
589 //mTodoListView->addColumn(i18n("Cancelled")); 604 //mTodoListView->addColumn(i18n("Cancelled"));
590 mTodoListView->addColumn(i18n("Categories")); 605 mTodoListView->addColumn(i18n("Categories"));
591 mTodoListView->addColumn(i18n("Calendar")); 606 mTodoListView->addColumn(i18n("Calendar"));
592 mTodoListView->addColumn(i18n("Last Modified")); 607 mTodoListView->addColumn(i18n("Last Modified"));
593 mTodoListView->addColumn(i18n("Created")); 608 mTodoListView->addColumn(i18n("Created"));
594 mTodoListView->addColumn(i18n("Last Modified Sub")); 609 mTodoListView->addColumn(i18n("Last Modified Sub"));
595#if 0 610#if 0
596 mTodoListView->addColumn(i18n("Sort Id")); 611 mTodoListView->addColumn(i18n("Sort Id"));
597 mTodoListView->setColumnAlignment(4,AlignHCenter); 612 mTodoListView->setColumnAlignment(4,AlignHCenter);
598#endif 613#endif
599 614
600 mTodoListView->setMinimumHeight( 60 ); 615 mTodoListView->setMinimumHeight( 60 );
601 mTodoListView->setItemsRenameable( true ); 616 mTodoListView->setItemsRenameable( true );
602 mTodoListView->setRenameable( 0 ); 617 mTodoListView->setRenameable( 0 );
603 mTodoListView->setColumnWidth( 0, 120 ); 618 mTodoListView->setColumnWidth( 0, 120 );
604 int iii = 0; 619 int iii = 0;
605 for ( iii = 0; iii< 12 ; ++iii ) 620 for ( iii = 0; iii< 12 ; ++iii )
606 mTodoListView->setColumnWidthMode( iii, QListView::Manual ); 621 mTodoListView->setColumnWidthMode( iii, QListView::Manual );
607 622
608 623
609 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 624 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
610 625
611 mPriorityPopupMenu = new QPopupMenu(this); 626 mPriorityPopupMenu = new QPopupMenu(this);
612 for (int i = 1; i <= 5; i++) { 627 for (int i = 1; i <= 5; i++) {
613 QString label = QString ("%1").arg (i); 628 QString label = QString ("%1").arg (i);
614 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 629 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
615 } 630 }
616 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 631 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
617 632
618 mPercentageCompletedPopupMenu = new QPopupMenu(this); 633 mPercentageCompletedPopupMenu = new QPopupMenu(this);
619 for (int i = 0; i <= 100; i+=20) { 634 for (int i = 0; i <= 100; i+=20) {
620 QString label = QString ("%1 %").arg (i); 635 QString label = QString ("%1 %").arg (i);
621 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 636 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
622 } 637 }
623 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 638 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
624 639
625 640
626 mCategoryPopupMenu = new QPopupMenu (this); 641 mCategoryPopupMenu = new QPopupMenu (this);
627 mCategoryPopupMenu->setCheckable (true); 642 mCategoryPopupMenu->setCheckable (true);
628 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 643 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
629 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); 644 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ()));
630 645
631 mCalPopupMenu = new QPopupMenu (this); 646 mCalPopupMenu = new QPopupMenu (this);
632 mCalPopupMenu->setCheckable (true); 647 mCalPopupMenu->setCheckable (true);
633 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); 648 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int)));
634 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); 649 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ()));
635 650
636 651
637 652
638 653
639 mItemPopupMenu = new QPopupMenu(this); 654 mItemPopupMenu = new QPopupMenu(this);
640 mItemPopupMenu->insertItem(i18n("Show"), this, 655 mItemPopupMenu->insertItem(i18n("Show"), this,
641 SLOT (showTodo())); 656 SLOT (showTodo()));
642 mItemPopupMenu->insertItem(i18n("Edit..."), this, 657 mItemPopupMenu->insertItem(i18n("Edit..."), this,
643 SLOT (editTodo())); 658 SLOT (editTodo()));
644 mItemPopupMenu->insertItem( i18n("Delete..."), this, 659 mItemPopupMenu->insertItem( i18n("Delete..."), this,
645 SLOT (deleteTodo())); 660 SLOT (deleteTodo()));
646 mItemPopupMenu->insertItem( i18n("Clone..."), this, 661 mItemPopupMenu->insertItem( i18n("Clone..."), this,
647 SLOT (cloneTodo())); 662 SLOT (cloneTodo()));
648 mItemPopupMenu->insertItem( i18n("Move..."), this, 663 mItemPopupMenu->insertItem( i18n("Move..."), this,
649 SLOT (moveTodo())); 664 SLOT (moveTodo()));
650#ifndef DESKTOP_VERSION 665#ifndef DESKTOP_VERSION
651 mItemPopupMenu->insertItem( i18n("Beam..."), this, 666 mItemPopupMenu->insertItem( i18n("Beam..."), this,
652 SLOT (beamTodo())); 667 SLOT (beamTodo()));
653#endif 668#endif
654 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 669 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
655 SLOT (cancelTodo())); 670 SLOT (cancelTodo()));
656 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); 671 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu);
657 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); 672 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu);
658 mItemPopupMenu->insertSeparator(); 673 mItemPopupMenu->insertSeparator();
659 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 674 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
660 SLOT (toggleRunningItem())); 675 SLOT (toggleRunningItem()));
661 mItemPopupMenu->insertSeparator(); 676 mItemPopupMenu->insertSeparator();
662 /* 677 /*
663 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 678 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
664 SLOT (newTodo())); 679 SLOT (newTodo()));
665 */ 680 */
666 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 681 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
667 SLOT (newSubTodo())); 682 SLOT (newSubTodo()));
668 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 683 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
669 SLOT (unparentTodo()),0,21); 684 SLOT (unparentTodo()),0,21);
670 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 685 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
671 SLOT (reparentTodo()),0,22); 686 SLOT (reparentTodo()),0,22);
672 mItemPopupMenu->insertSeparator(); 687 mItemPopupMenu->insertSeparator();
673#if 0 688#if 0
674 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), 689 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."),
675 this, SLOT( purgeCompleted() ) ); 690 this, SLOT( purgeCompleted() ) );
676 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 691 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
677 this, SLOT( toggleCompleted() ),0, 33 ); 692 this, SLOT( toggleCompleted() ),0, 33 );
678 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 693 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
679 this, SLOT( toggleQuickTodo() ),0, 34 ); 694 this, SLOT( toggleQuickTodo() ),0, 34 );
680 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 695 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
681 this, SLOT( toggleRunning() ),0, 35 ); 696 this, SLOT( toggleRunning() ),0, 35 );
682 697
683#endif 698#endif
684 mPopupMenu = new QPopupMenu(this); 699 mPopupMenu = new QPopupMenu(this);
685 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 700 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
686 SLOT (newTodo()),0,1); 701 SLOT (newTodo()),0,1);
687 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), 702 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."),
688 this, SLOT(purgeCompleted()),0,2); 703 this, SLOT(purgeCompleted()),0,2);
689 mPopupMenu->insertItem(i18n("Show Completed"), 704 mPopupMenu->insertItem(i18n("Show Completed"),
690 this, SLOT( toggleCompleted() ),0,3 ); 705 this, SLOT( toggleCompleted() ),0,3 );
691 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 706 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
692 this, SLOT( toggleRunning() ),0,5 ); 707 this, SLOT( toggleRunning() ),0,5 );
693 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 708 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
694 this, SLOT( setAllOpen() ),0,6 ); 709 this, SLOT( setAllOpen() ),0,6 );
695 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 710 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
696 this, SLOT( setAllClose() ),0,7 ); 711 this, SLOT( setAllClose() ),0,7 );
697 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 712 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
698 this, SLOT( setAllFlat() ),0,8 ); 713 this, SLOT( setAllFlat() ),0,8 );
699 mPopupMenu->insertSeparator(); 714 mPopupMenu->insertSeparator();
700 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 715 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
701 this, SLOT( toggleQuickTodo() ),0,4 ); 716 this, SLOT( toggleQuickTodo() ),0,4 );
702 mDocPrefs = new DocPrefs( name ); 717 mDocPrefs = new DocPrefs( name );
703 718
704 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 719 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
705 mPopupMenu->setCheckable( true ); 720 mPopupMenu->setCheckable( true );
706 mItemPopupMenu->setCheckable( true ); 721 mItemPopupMenu->setCheckable( true );
707 722
708 723
709 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 724 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
710 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 725 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
711 726
712 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 727 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
713 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 728 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
714 729
715 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 730 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
716 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 731 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
717 732
718 733
719 // Double clicking conflicts with opening/closing the subtree 734 // Double clicking conflicts with opening/closing the subtree
720 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 735 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
721 SLOT( editItem( QListViewItem *) ) ); 736 SLOT( editItem( QListViewItem *) ) );
722 /* 737 /*
723 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 738 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
724 const QPoint &,int ) ), 739 const QPoint &,int ) ),
725 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 740 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
726 */ 741 */
727 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 742 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
728 const QPoint &,int ) ), 743 const QPoint &,int ) ),
729 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 744 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
730 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 745 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
731 SLOT( itemClicked( QListViewItem * ) ) ); 746 SLOT( itemClicked( QListViewItem * ) ) );
732 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 747 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
733 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 748 SLOT( itemDoubleClicked( QListViewItem * ) ) );
734 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 749 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
735 SLOT( updateView() ) ); 750 SLOT( updateView() ) );
736 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 751 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
737 SLOT( todoModified(Todo *, int) ) ); 752 SLOT( todoModified(Todo *, int) ) );
738 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 753 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
739 SLOT( itemStateChanged( QListViewItem * ) ) ); 754 SLOT( itemStateChanged( QListViewItem * ) ) );
740 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 755 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
741 SLOT( itemStateChanged( QListViewItem * ) ) ); 756 SLOT( itemStateChanged( QListViewItem * ) ) );
742 connect( mTodoListView, SIGNAL( paintNeeded() ), 757 connect( mTodoListView, SIGNAL( paintNeeded() ),
743 SLOT( paintNeeded()) ); 758 SLOT( paintNeeded()) );
744 759
745#if 0 760#if 0
746 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 761 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
747 SLOT(selectionChanged(QListViewItem *))); 762 SLOT(selectionChanged(QListViewItem *)));
748 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 763 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
749 SLOT(selectionChanged(QListViewItem *))); 764 SLOT(selectionChanged(QListViewItem *)));
750 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 765 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
751 SLOT(selectionChanged(QListViewItem *))); 766 SLOT(selectionChanged(QListViewItem *)));
752#endif 767#endif
753 768
754 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 769 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
755 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 770 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
756 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 771 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
757 772
758 connect( mTodoListView, SIGNAL(selectionChanged() ), 773 connect( mTodoListView, SIGNAL(selectionChanged() ),
759 SLOT( processSelectionChange() ) ); 774 SLOT( processSelectionChange() ) );
760 connect( mQuickAdd, SIGNAL( returnPressed () ), 775 connect( mQuickAdd, SIGNAL( returnPressed () ),
761 SLOT( addQuickTodo() ) ); 776 SLOT( addQuickTodo() ) );
762 777
763} 778}
764 779
765KOTodoView::~KOTodoView() 780KOTodoView::~KOTodoView()
766{ 781{
767 782
768#if QT_VERSION >= 0x030000 783#if QT_VERSION >= 0x030000
769 784
770#else 785#else
771 delete mKOTodoViewWhatsThis; 786 delete mKOTodoViewWhatsThis;
772#endif 787#endif
773 788
774 delete mDocPrefs; 789 delete mDocPrefs;
775} 790}
776QString KOTodoView::getWhatsThisText(QPoint p) 791QString KOTodoView::getWhatsThisText(QPoint p)
777{ 792{
778 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 793 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
779 if ( item ) 794 if ( item )
780 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 795 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
781 KOPrefs::instance()->mWTshowDetails, 796 KOPrefs::instance()->mWTshowDetails,
782 KOPrefs::instance()->mWTshowCreated, 797 KOPrefs::instance()->mWTshowCreated,
783 KOPrefs::instance()->mWTshowChanged); 798 KOPrefs::instance()->mWTshowChanged);
784 return i18n("That is the todo view" ); 799 return i18n("That is the todo view" );
785 800
786} 801}
787 802
788void KOTodoView::jumpToDate () 803void KOTodoView::jumpToDate ()
789{ 804{
790 // if (mActiveItem) { 805 // if (mActiveItem) {
791// mActiveItem->todo()); 806// mActiveItem->todo());
792// if ( mActiveItem->todo()->hasDueDate() ) 807// if ( mActiveItem->todo()->hasDueDate() )
793// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 808// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
794} 809}
795void KOTodoView::paintNeeded() 810void KOTodoView::paintNeeded()
796{ 811{
797 if ( mPendingUpdateBeforeRepaint ) { 812 if ( mPendingUpdateBeforeRepaint ) {
798 updateView(); 813 updateView();
799 mPendingUpdateBeforeRepaint = false; 814 mPendingUpdateBeforeRepaint = false;
800 } 815 }
801} 816}
802void KOTodoView::paintEvent(QPaintEvent * pevent) 817void KOTodoView::paintEvent(QPaintEvent * pevent)
803{ 818{
804 if ( mPendingUpdateBeforeRepaint ) { 819 if ( mPendingUpdateBeforeRepaint ) {
805 updateView(); 820 updateView();
806 mPendingUpdateBeforeRepaint = false; 821 mPendingUpdateBeforeRepaint = false;
807 } 822 }
808 KOrg::BaseView::paintEvent( pevent); 823 KOrg::BaseView::paintEvent( pevent);
809} 824}
810 825
811void KOTodoView::clearList( bool saveCurrentItem ) // default true 826void KOTodoView::clearList( bool saveCurrentItem ) // default true
812{ 827{
813 if ( mTodoListView->childCount() ) { 828 if ( mTodoListView->childCount() ) {
814 if ( saveCurrentItem ) 829 if ( saveCurrentItem )
815 storeCurrentItem(); 830 storeCurrentItem();
816 mTodoListView->clear(); 831 mTodoListView->clear();
817 mTodoMap.clear(); 832 mTodoMap.clear();
818 } 833 }
819} 834}
820void KOTodoView::updateView() 835void KOTodoView::updateView()
821{ 836{
822 mActiveItem = 0; 837 mActiveItem = 0;
823 pendingSubtodo = 0; 838 pendingSubtodo = 0;
824 if ( mBlockUpdate ) { 839 if ( mBlockUpdate ) {
825 return; 840 return;
826 } 841 }
827 if ( !isVisible() ) { 842 if ( !isVisible() ) {
828 clearList (); 843 clearList ();
829 mPendingUpdateBeforeRepaint = true; 844 mPendingUpdateBeforeRepaint = true;
830 return; 845 return;
831 } 846 }
832 //qDebug("KOTodoView::updateView() %x", this); 847 //qDebug("KOTodoView::updateView() %x", this);
833 if ( isFlatDisplay ) { 848 if ( isFlatDisplay ) {
834 displayAllFlat(); 849 displayAllFlat();
835 return; 850 return;
836 } 851 }
837 //qDebug("update "); 852 //qDebug("update ");
838// kdDebug() << "KOTodoView::updateView()" << endl; 853// kdDebug() << "KOTodoView::updateView()" << endl;
839 QFont fo = KOPrefs::instance()->mTodoViewFont; 854 QFont fo = KOPrefs::instance()->mTodoViewFont;
840 855
841 clearList (); 856 clearList ();
842 857
843 if ( mName == "todolistsmall" ) { 858 if ( mName == "todolistsmall" ) {
844 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 859 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
845 int ps = fo.pointSize() -2; 860 int ps = fo.pointSize() -2;
846 if ( ps > 12 ) 861 if ( ps > 12 )
847 ps -= 2; 862 ps -= 2;
848 fo.setPointSize( ps ); 863 fo.setPointSize( ps );
849 } 864 }
850 } 865 }
851 866
852 mTodoListView->setFont( fo ); 867 mTodoListView->setFont( fo );
853 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 868 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
854 //mTodoListView->header()->setMaximumHeight(fm.height()); 869 //mTodoListView->header()->setMaximumHeight(fm.height());
855 QPtrList<Todo> todoList = calendar()->todos(); 870 QPtrList<Todo> todoList = calendar()->todos();
856 871
857/* 872/*
858 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 873 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
859 Event *t; 874 Event *t;
860 for(t = todoList.first(); t; t = todoList.next()) { 875 for(t = todoList.first(); t; t = todoList.next()) {
861 kdDebug() << " " << t->getSummary() << endl; 876 kdDebug() << " " << t->getSummary() << endl;
862 877
863 if (t->getRelatedTo()) { 878 if (t->getRelatedTo()) {
864 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 879 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
865 } 880 }
866 881
867 QPtrList<Event> l = t->getRelations(); 882 QPtrList<Event> l = t->getRelations();
868 Event *c; 883 Event *c;
869 for(c=l.first();c;c=l.next()) { 884 for(c=l.first();c;c=l.next()) {
870 kdDebug() << " - relation: " << c->getSummary() << endl; 885 kdDebug() << " - relation: " << c->getSummary() << endl;
871 } 886 }
872 } 887 }
873*/ 888*/
874 889
875 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 890 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
876 // specific order of events. That means that we have to generate parent items 891 // specific order of events. That means that we have to generate parent items
877 // recursively for proper hierarchical display of Todos. 892 // recursively for proper hierarchical display of Todos.
878 Todo *todo; 893 Todo *todo;
879 todo = todoList.first();// todo; todo = todoList.next()) { 894 todo = todoList.first();// todo; todo = todoList.next()) {
880 while ( todo ) { 895 while ( todo ) {
881 bool next = true; 896 bool next = true;
882 // qDebug("todo %s ", todo->summary().latin1()); 897 // qDebug("todo %s ", todo->summary().latin1());
883 Incidence *incidence = todo->relatedTo(); 898 Incidence *incidence = todo->relatedTo();
884 while ( incidence ) { 899 while ( incidence ) {
885 if ( incidence->typeID() == todoID ) { 900 if ( incidence->typeID() == todoID ) {
886 //qDebug("related %s ",incidence->summary().latin1() ); 901 //qDebug("related %s ",incidence->summary().latin1() );
887 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { 902 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) {
888 //qDebug("related not found "); 903 //qDebug("related not found ");
889 todoList.remove( ); 904 todoList.remove( );
890 todo = todoList.current(); 905 todo = todoList.current();
891 next = false; 906 next = false;
892 incidence = 0; 907 incidence = 0;
893 908
894 } else { 909 } else {
895 //qDebug("related found "); 910 //qDebug("related found ");
896 incidence = incidence->relatedTo(); 911 incidence = incidence->relatedTo();
897 } 912 }
898 } else 913 } else
899 incidence = 0; 914 incidence = 0;
900 } 915 }
901 if ( next ) 916 if ( next )
902 todo = todoList.next(); 917 todo = todoList.next();
903 } 918 }
904 919
905 for(todo = todoList.first(); todo; todo = todoList.next()) { 920 for(todo = todoList.first(); todo; todo = todoList.next()) {
906 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 921 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
907 { 922 {
908 insertTodoItem(todo); 923 insertTodoItem(todo);
909 } 924 }
910 } 925 }
911 // Restore opened/closed state 926 // Restore opened/closed state
912 mTodoListView->blockSignals( true ); 927 mTodoListView->blockSignals( true );
913 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 928 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
914 mTodoListView->blockSignals( false ); 929 mTodoListView->blockSignals( false );
915 resetCurrentItem(); 930 resetCurrentItem();
916} 931}
917 932
918void KOTodoView::storeCurrentItem() 933void KOTodoView::storeCurrentItem()
919{ 934{
920 mCurItem = 0; 935 mCurItem = 0;
921 mCurItemRootParent = 0; 936 mCurItemRootParent = 0;
922 mCurItemParent = 0; 937 mCurItemParent = 0;
923 mCurItemAbove = 0; 938 mCurItemAbove = 0;
924 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 939 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
925 if (mActiveItem) { 940 if (mActiveItem) {
926 mCurItem = mActiveItem->todo(); 941 mCurItem = mActiveItem->todo();
927 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 942 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
928 if ( activeItemAbove ) 943 if ( activeItemAbove )
929 mCurItemAbove = activeItemAbove->todo(); 944 mCurItemAbove = activeItemAbove->todo();
930 mCurItemRootParent = mCurItem; 945 mCurItemRootParent = mCurItem;
931 mCurItemParent = mCurItemRootParent->relatedTo(); 946 mCurItemParent = mCurItemRootParent->relatedTo();
932 while ( mCurItemRootParent->relatedTo() != 0 ) 947 while ( mCurItemRootParent->relatedTo() != 0 )
933 mCurItemRootParent = mCurItemRootParent->relatedTo(); 948 mCurItemRootParent = mCurItemRootParent->relatedTo();
934 } 949 }
935 mActiveItem = 0; 950 mActiveItem = 0;
936} 951}
937 952
938void KOTodoView::resetCurrentItem() 953void KOTodoView::resetCurrentItem()
939{ 954{
940 //mTodoListView->setFocus(); 955 //mTodoListView->setFocus();
941 KOTodoViewItem* foundItem = 0; 956 KOTodoViewItem* foundItem = 0;
942 KOTodoViewItem* foundItemRoot = 0; 957 KOTodoViewItem* foundItemRoot = 0;
943 KOTodoViewItem* foundItemParent = 0; 958 KOTodoViewItem* foundItemParent = 0;
944 KOTodoViewItem* foundItemAbove = 0; 959 KOTodoViewItem* foundItemAbove = 0;
945 if ( mTodoListView->firstChild () ) { 960 if ( mTodoListView->firstChild () ) {
946 if ( mCurItem ) { 961 if ( mCurItem ) {
947 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 962 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
948 while ( item ) { 963 while ( item ) {
949 if ( item->todo() == mCurItem ) { 964 if ( item->todo() == mCurItem ) {
950 foundItem = item; 965 foundItem = item;
951 break; 966 break;
952 } else if ( item->todo() == mCurItemAbove ) { 967 } else if ( item->todo() == mCurItemAbove ) {
953 foundItemAbove = item; 968 foundItemAbove = item;
954 969
955 } 970 }
956 if ( item->todo() == mCurItemRootParent ) { 971 if ( item->todo() == mCurItemRootParent ) {
957 foundItemRoot = item; 972 foundItemRoot = item;
958 } 973 }
959 if ( item->todo() == mCurItemParent ) { 974 if ( item->todo() == mCurItemParent ) {
960 foundItemParent = item; 975 foundItemParent = item;
961 } 976 }
962 item = (KOTodoViewItem*)item->itemBelow(); 977 item = (KOTodoViewItem*)item->itemBelow();
963 } 978 }
964 if ( ! foundItem ) { 979 if ( ! foundItem ) {
965 if ( foundItemParent ) { 980 if ( foundItemParent ) {
966 foundItem = foundItemParent; 981 foundItem = foundItemParent;
967 } else { 982 } else {
968 if ( foundItemRoot ) 983 if ( foundItemRoot )
969 foundItem = foundItemRoot; 984 foundItem = foundItemRoot;
970 else 985 else
971 foundItem = foundItemAbove; 986 foundItem = foundItemAbove;
972 } 987 }
973 } 988 }
974 } 989 }
975 if ( foundItem ) { 990 if ( foundItem ) {
976 mTodoListView->setSelected ( foundItem, true ); 991 mTodoListView->setSelected ( foundItem, true );
977 mTodoListView->setCurrentItem( foundItem ); 992 mTodoListView->setCurrentItem( foundItem );
978 mTodoListView->ensureItemVisible( foundItem ); 993 mTodoListView->ensureItemVisible( foundItem );
979 } else { 994 } else {
980 if ( mTodoListView->firstChild () ) { 995 if ( mTodoListView->firstChild () ) {
981 mTodoListView->setSelected ( mTodoListView->firstChild (), true ); 996 mTodoListView->setSelected ( mTodoListView->firstChild (), true );
982 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 997 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
983 } 998 }
984 } 999 }
985 } 1000 }
986 processSelectionChange(); 1001 processSelectionChange();
987 if ( mName != "todolistsmall" ) 1002 if ( mName != "todolistsmall" )
988 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); 1003 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() ));
989} 1004}
990void KOTodoView::resetFocusToList() 1005void KOTodoView::resetFocusToList()
991{ 1006{
992 topLevelWidget()->setActiveWindow(); 1007 topLevelWidget()->setActiveWindow();
993 mTodoListView->setFocus(); 1008 mTodoListView->setFocus();
994} 1009}
995//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 1010//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
996bool KOTodoView::checkTodo( Todo * todo ) 1011bool KOTodoView::checkTodo( Todo * todo )
997{ 1012{
998 1013
999 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 1014 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
1000 return false; 1015 return false;
1001 if ( !todo->isCompleted() ) { 1016 if ( !todo->isCompleted() ) {
1002 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 1017 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
1003 return true; 1018 return true;
1004 } 1019 }
1005 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 1020 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
1006 if ( todo->hasStartDate() ) 1021 if ( todo->hasStartDate() )
1007 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 1022 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
1008 return false; 1023 return false;
1009 if ( todo->hasDueDate() ) 1024 if ( todo->hasDueDate() )
1010 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 1025 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
1011 return false; 1026 return false;
1012 } 1027 }
1013 return true; 1028 return true;
1014} 1029}
1015 1030
1016void KOTodoView::restoreItemState( QListViewItem *item ) 1031void KOTodoView::restoreItemState( QListViewItem *item )
1017{ 1032{
1018 pendingSubtodo = 0; 1033 pendingSubtodo = 0;
1019 while( item ) { 1034 while( item ) {
1020 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1035 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1021 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 1036 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
1022 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 1037 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
1023 item = item->nextSibling(); 1038 item = item->nextSibling();
1024 } 1039 }
1025} 1040}
1026 1041
1027 1042
1028QMap<Todo *,KOTodoViewItem *>::ConstIterator 1043QMap<Todo *,KOTodoViewItem *>::ConstIterator
1029KOTodoView::insertTodoItem(Todo *todo) 1044KOTodoView::insertTodoItem(Todo *todo)
1030{ 1045{
1031 1046
1032 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 1047 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
1033 // TODO: Check, if dynmaic cast is necessary 1048 // TODO: Check, if dynmaic cast is necessary
1034 1049
1035 pendingSubtodo = 0; 1050 pendingSubtodo = 0;
1036 Incidence *incidence = todo->relatedTo(); 1051 Incidence *incidence = todo->relatedTo();
1037 while ( incidence && !incidence->calEnabled() ) 1052 while ( incidence && !incidence->calEnabled() )
1038 incidence = incidence->relatedTo(); 1053 incidence = incidence->relatedTo();
1039 if (incidence && incidence->typeID() == todoID ) { 1054 if (incidence && incidence->typeID() == todoID ) {
1040 Todo *relatedTodo = static_cast<Todo *>(incidence); 1055 Todo *relatedTodo = static_cast<Todo *>(incidence);
1041 1056
1042 // kdDebug() << " has Related" << endl; 1057 // kdDebug() << " has Related" << endl;
1043 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1058 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1044 itemIterator = mTodoMap.find(relatedTodo); 1059 itemIterator = mTodoMap.find(relatedTodo);
1045 if (itemIterator == mTodoMap.end()) { 1060 if (itemIterator == mTodoMap.end()) {
1046 // kdDebug() << " related not yet in list" << endl; 1061 // kdDebug() << " related not yet in list" << endl;
1047 itemIterator = insertTodoItem (relatedTodo); 1062 itemIterator = insertTodoItem (relatedTodo);
1048 } 1063 }
1049 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 1064 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
1050 // and one into the map. Sure finding is more easy but why? -zecke 1065 // and one into the map. Sure finding is more easy but why? -zecke
1051 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 1066 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
1052 return mTodoMap.insert(todo,todoItem); 1067 return mTodoMap.insert(todo,todoItem);
1053 } else { 1068 } else {
1054 // kdDebug() << " no Related" << endl; 1069 // kdDebug() << " no Related" << endl;
1055 // see above -zecke 1070 // see above -zecke
1056 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1071 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1057 return mTodoMap.insert(todo,todoItem); 1072 return mTodoMap.insert(todo,todoItem);
1058 } 1073 }
1059} 1074}
1060 1075
1061 1076
1062void KOTodoView::updateConfig() 1077void KOTodoView::updateConfig()
1063{ 1078{
1064 updateView(); 1079 updateView();
1065 mTodoListView->repaintContents(); 1080 mTodoListView->repaintContents();
1066} 1081}
1067 1082
1068QPtrList<Incidence> KOTodoView::selectedIncidences() 1083QPtrList<Incidence> KOTodoView::selectedIncidences()
1069{ 1084{
1070 QPtrList<Incidence> selected; 1085 QPtrList<Incidence> selected;
1071 1086
1072 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 1087 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
1073// if (!item) item = mActiveItem; 1088// if (!item) item = mActiveItem;
1074 if (item) selected.append(item->todo()); 1089 if (item) selected.append(item->todo());
1075 1090
1076 return selected; 1091 return selected;
1077} 1092}
1078 1093
1079QPtrList<Todo> KOTodoView::selectedTodos() 1094QPtrList<Todo> KOTodoView::selectedTodos()
1080{ 1095{
1081 QPtrList<Todo> selected; 1096 QPtrList<Todo> selected;
1082 1097
1083 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 1098 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
1084// if (!item) item = mActiveItem; 1099// if (!item) item = mActiveItem;
1085 if (item) selected.append(item->todo()); 1100 if (item) selected.append(item->todo());
1086 1101
1087 return selected; 1102 return selected;
1088} 1103}
1089 1104
1090void KOTodoView::changeEventDisplay(Event *, int) 1105void KOTodoView::changeEventDisplay(Event *, int)
1091{ 1106{
1092 updateView(); 1107 updateView();
1093} 1108}
1094 1109
1095void KOTodoView::showDates(const QDate &, const QDate &) 1110void KOTodoView::showDates(const QDate &, const QDate &)
1096{ 1111{
1097} 1112}
1098 1113
1099void KOTodoView::showEvents(QPtrList<Event>) 1114void KOTodoView::showEvents(QPtrList<Event>)
1100{ 1115{
1101 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 1116 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
1102} 1117}
1103 1118
1104void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1119void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1105 const QDate &td) 1120 const QDate &td)
1106{ 1121{
1107#ifndef KORG_NOPRINTER 1122#ifndef KORG_NOPRINTER
1108 calPrinter->preview(CalPrinter::Todolist, fd, td); 1123 calPrinter->preview(CalPrinter::Todolist, fd, td);
1109#endif 1124#endif
1110} 1125}
1111 1126
1112void KOTodoView::editItem(QListViewItem *item ) 1127void KOTodoView::editItem(QListViewItem *item )
1113{ 1128{
1114 if ( item ) 1129 if ( item )
1115 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 1130 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
1116} 1131}
1117 1132
1118void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 1133void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
1119{ 1134{
1120 if ( item ) 1135 if ( item )
1121 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 1136 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
1122} 1137}
1123 1138
1124void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 1139void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
1125{ 1140{
1126 pendingSubtodo = 0; 1141 pendingSubtodo = 0;
1127 mActiveItem = (KOTodoViewItem *)item; 1142 mActiveItem = (KOTodoViewItem *)item;
1128 if (item) { 1143 if (item) {
1129 switch (column){ 1144 switch (column){
1130 case 1: 1145 case 1:
1131 mPriorityPopupMenu->popup(QCursor::pos ()); break; 1146 mPriorityPopupMenu->popup(QCursor::pos ()); break;
1132 case 2: 1147 case 2:
1133 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 1148 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
1134 case 3: 1149 case 3:
1135 moveTodo(); 1150 moveTodo();
1136 break; 1151 break;
1137 case 7: 1152 case 7:
1138 mCategoryPopupMenu->popup(QCursor::pos ()); break; 1153 mCategoryPopupMenu->popup(QCursor::pos ()); break;
1139 case 8: 1154 case 8:
1140 mCalPopupMenu->popup(QCursor::pos ()); break; 1155 mCalPopupMenu->popup(QCursor::pos ()); break;
1141 default: 1156 default:
1142 mItemPopupMenu->popup(QCursor::pos()); 1157 mItemPopupMenu->popup(QCursor::pos());
1143 } 1158 }
1144 } else mPopupMenu->popup(QCursor::pos()); 1159 } else mPopupMenu->popup(QCursor::pos());
1145} 1160}
1146void KOTodoView::newTodo() 1161void KOTodoView::newTodo()
1147{ 1162{
1148 emit newTodoSignal(); 1163 emit newTodoSignal();
1149} 1164}
1150 1165
1151void KOTodoView::newSubTodo() 1166void KOTodoView::newSubTodo()
1152{ 1167{
1153 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1168 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1154 if (mActiveItem) { 1169 if (mActiveItem) {
1155 if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { 1170 if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) {
1156 addQuickTodoPar( mActiveItem->todo()); 1171 addQuickTodoPar( mActiveItem->todo());
1157 } else 1172 } else
1158 emit newSubTodoSignal(mActiveItem->todo()); 1173 emit newSubTodoSignal(mActiveItem->todo());
1159 } 1174 }
1160} 1175}
1161void KOTodoView::unparentTodo() 1176void KOTodoView::unparentTodo()
1162{ 1177{
1163 if (mActiveItem) { 1178 if (mActiveItem) {
1164 emit unparentTodoSignal(mActiveItem->todo()); 1179 emit unparentTodoSignal(mActiveItem->todo());
1165 } 1180 }
1166} 1181}
1167 1182
1168void KOTodoView::reparentTodo() 1183void KOTodoView::reparentTodo()
1169{ 1184{
1170 if (mActiveItem) { 1185 if (mActiveItem) {
1171 topLevelWidget()->setCaption(i18n("Click on new parent item")); 1186 topLevelWidget()->setCaption(i18n("Click on new parent item"));
1172 pendingSubtodo = mActiveItem; 1187 pendingSubtodo = mActiveItem;
1173 } 1188 }
1174} 1189}
1175void KOTodoView::editTodo() 1190void KOTodoView::editTodo()
1176{ 1191{
1177 if (mActiveItem) { 1192 if (mActiveItem) {
1178 emit editTodoSignal(mActiveItem->todo()); 1193 emit editTodoSignal(mActiveItem->todo());
1179 } 1194 }
1180} 1195}
1181void KOTodoView::cloneTodo() 1196void KOTodoView::cloneTodo()
1182{ 1197{
1183 if (mActiveItem) { 1198 if (mActiveItem) {
1184 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 1199 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
1185 } 1200 }
1186} 1201}
1187void KOTodoView::cancelTodo() 1202void KOTodoView::cancelTodo()
1188{ 1203{
1189 if (mActiveItem) { 1204 if (mActiveItem) {
1190 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 1205 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
1191 } 1206 }
1192} 1207}
1193void KOTodoView::moveTodo() 1208void KOTodoView::moveTodo()
1194{ 1209{
1195 if (mActiveItem) { 1210 if (mActiveItem) {
1196 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 1211 emit moveTodoSignal((Incidence*)mActiveItem->todo());
1197 } 1212 }
1198} 1213}
1199void KOTodoView::beamTodo() 1214void KOTodoView::beamTodo()
1200{ 1215{
1201 if (mActiveItem) { 1216 if (mActiveItem) {
1202 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 1217 emit beamTodoSignal((Incidence*)mActiveItem->todo());
1203 } 1218 }
1204} 1219}
1205 1220
1206 1221
1207void KOTodoView::showTodo() 1222void KOTodoView::showTodo()
1208{ 1223{
1209 if (mActiveItem) { 1224 if (mActiveItem) {
1210 emit showTodoSignal(mActiveItem->todo()); 1225 emit showTodoSignal(mActiveItem->todo());
1211 } 1226 }
1212} 1227}
1213 1228
1214void KOTodoView::deleteTodo() 1229void KOTodoView::deleteTodo()
1215{ 1230{
1216 if (mActiveItem) { 1231 if (mActiveItem) {
1217 emit deleteTodoSignal(mActiveItem->todo()); 1232 emit deleteTodoSignal(mActiveItem->todo());
1218 } 1233 }
1219} 1234}
1220 1235
1221void KOTodoView::setNewPriority(int index) 1236void KOTodoView::setNewPriority(int index)
1222{ 1237{
1223 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1238 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1224 mActiveItem->todo()->setPriority(mPriority[index]); 1239 mActiveItem->todo()->setPriority(mPriority[index]);
1225 mActiveItem->construct(); 1240 mActiveItem->construct();
1226 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1241 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1227 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1242 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1228 } 1243 }
1229 processSelectionChange(); 1244 processSelectionChange();
1230} 1245}
1231 1246
1232void KOTodoView::setNewPercentage(int index) 1247void KOTodoView::setNewPercentage(int index)
1233{ 1248{
1234 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1249 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1235 1250
1236 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1251 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1237 mActiveItem->setOn( true ); 1252 mActiveItem->setOn( true );
1238 processSelectionChange(); 1253 processSelectionChange();
1239 return; 1254 return;
1240 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1255 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1241 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1256 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1242 if ( par && par->isOn() ) 1257 if ( par && par->isOn() )
1243 par->setOn( false ); 1258 par->setOn( false );
1244 } 1259 }
1245 if (mPercentage[index] == 100) { 1260 if (mPercentage[index] == 100) {
1246 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1261 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1247 } else { 1262 } else {
1248 mActiveItem->todo()->setCompleted(false); 1263 mActiveItem->todo()->setCompleted(false);
1249 } 1264 }
1250 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1265 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1251 mActiveItem->construct(); 1266 mActiveItem->construct();
1252 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1267 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1253 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1268 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1254 } 1269 }
1255 processSelectionChange(); 1270 processSelectionChange();
1256} 1271}
1257 1272
1258void KOTodoView::fillCategories () 1273void KOTodoView::fillCategories ()
1259{ 1274{
1260 mCategoryPopupMenu->clear(); 1275 mCategoryPopupMenu->clear();
1261 if ( ! mActiveItem ) return; 1276 if ( ! mActiveItem ) return;
1262 QStringList checkedCategories = mActiveItem->todo()->categories (); 1277 QStringList checkedCategories = mActiveItem->todo()->categories ();
1263 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1278 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1264 it != KOPrefs::instance()->mCustomCategories.end (); 1279 it != KOPrefs::instance()->mCustomCategories.end ();
1265 ++it) { 1280 ++it) {
1266 int index = mCategoryPopupMenu->insertItem (*it); 1281 int index = mCategoryPopupMenu->insertItem (*it);
1267 mCategory[index] = *it; 1282 mCategory[index] = *it;
1268 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); 1283 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true);
1269 } 1284 }
1270} 1285}
1271void KOTodoView::fillCal () 1286void KOTodoView::fillCal ()
1272{ 1287{
1273 mCalPopupMenu->clear(); 1288 mCalPopupMenu->clear();
1274 if (!mActiveItem) return; 1289 if (!mActiveItem) return;
1275 bool readO = mActiveItem->todo()->isReadOnly(); 1290 bool readO = mActiveItem->todo()->isReadOnly();
1276 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 1291 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
1277 while ( kkf ) { 1292 while ( kkf ) {
1278 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); 1293 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber);
1279 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) 1294 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
1280 mCalPopupMenu->setItemEnabled( index, false ); 1295 mCalPopupMenu->setItemEnabled( index, false );
1281 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); 1296 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID());
1282 kkf = KOPrefs::instance()->mCalendars.next(); 1297 kkf = KOPrefs::instance()->mCalendars.next();
1283 } 1298 }
1284} 1299}
1285void KOTodoView::changedCal (int index ) 1300void KOTodoView::changedCal (int index )
1286{ 1301{
1287 if (!mActiveItem) return; 1302 if (!mActiveItem) return;
1288 mActiveItem->todo()->setCalID( index ); 1303 mActiveItem->todo()->setCalID( index );
1289 mActiveItem->construct(); 1304 mActiveItem->construct();
1290} 1305}
1291void KOTodoView::changedCategories(int index) 1306void KOTodoView::changedCategories(int index)
1292{ 1307{
1293 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1308 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1294 QStringList categories = mActiveItem->todo()->categories (); 1309 QStringList categories = mActiveItem->todo()->categories ();
1295 QString colcat = categories.first(); 1310 QString colcat = categories.first();
1296 if (categories.find (mCategory[index]) != categories.end ()) 1311 if (categories.find (mCategory[index]) != categories.end ())
1297 categories.remove (mCategory[index]); 1312 categories.remove (mCategory[index]);
1298 else 1313 else
1299 categories.insert (categories.end(), mCategory[index]); 1314 categories.insert (categories.end(), mCategory[index]);
1300 categories.sort (); 1315 categories.sort ();
1301 if ( !colcat.isEmpty() ) { 1316 if ( !colcat.isEmpty() ) {
1302 if ( categories.find ( colcat ) != categories.end () ) { 1317 if ( categories.find ( colcat ) != categories.end () ) {
1303 categories.remove( colcat ); 1318 categories.remove( colcat );
1304 categories.prepend( colcat ); 1319 categories.prepend( colcat );
1305 } 1320 }
1306 } 1321 }
1307 mActiveItem->todo()->setCategories (categories); 1322 mActiveItem->todo()->setCategories (categories);
1308 mActiveItem->construct(); 1323 mActiveItem->construct();
1309 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1324 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1310 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1325 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1311 } 1326 }
1312} 1327}
1313void KOTodoView::itemDoubleClicked(QListViewItem *item) 1328void KOTodoView::itemDoubleClicked(QListViewItem *item)
1314{ 1329{
1315 if ( pendingSubtodo != 0 ) { 1330 if ( pendingSubtodo != 0 ) {
1316 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1331 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1317 } 1332 }
1318 pendingSubtodo = 0; 1333 pendingSubtodo = 0;
1319 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1334 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1320 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1335 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1321 //qDebug("ROW %d ", row); 1336 //qDebug("ROW %d ", row);
1322 if (!item) { 1337 if (!item) {
1323 newTodo(); 1338 newTodo();
1324 return; 1339 return;
1325 } else { 1340 } else {
1326 if ( row == 1 ) { 1341 if ( row == 1 ) {
1327 mActiveItem = (KOTodoViewItem *) item; 1342 mActiveItem = (KOTodoViewItem *) item;
1328 newSubTodo(); 1343 newSubTodo();
1329 return; 1344 return;
1330 } 1345 }
1331 if ( row == 5 || row == 6 || row == 2) { 1346 if ( row == 5 || row == 6 || row == 2) {
1332 mActiveItem = (KOTodoViewItem *) item; 1347 mActiveItem = (KOTodoViewItem *) item;
1333 Todo * t = mActiveItem->todo(); 1348 Todo * t = mActiveItem->todo();
1334 if ( t->isRunning() ) { 1349 if ( t->isRunning() ) {
1335 if ( t->runTime() < 15) { 1350 if ( t->runTime() < 15) {
1336 t->stopRunning(); 1351 t->stopRunning();
1337 mActiveItem->construct(); 1352 mActiveItem->construct();
1338 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); 1353 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!"));
1339 return; 1354 return;
1340 } 1355 }
1341 else 1356 else
1342 toggleRunningItem(); 1357 toggleRunningItem();
1343 return; 1358 return;
1344 } else { 1359 } else {
1345 t->setRunning( true ); 1360 t->setRunning( true );
1346 mActiveItem->construct(); 1361 mActiveItem->construct();
1347 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); 1362 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!"));
1348 return; 1363 return;
1349 } 1364 }
1350 } 1365 }
1351 } 1366 }
1352 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1367 if ( KOPrefs::instance()->mEditOnDoubleClick )
1353 editItem( item ); 1368 editItem( item );
1354 else 1369 else
1355 showItem( item , QPoint(), 0 ); 1370 showItem( item , QPoint(), 0 );
1356} 1371}
1357void KOTodoView::toggleRunningItem() 1372void KOTodoView::toggleRunningItem()
1358{ 1373{
1359 // qDebug("KOTodoView::toggleRunning() "); 1374 // qDebug("KOTodoView::toggleRunning() ");
1360 if ( ! mActiveItem ) 1375 if ( ! mActiveItem )
1361 return; 1376 return;
1362 Todo * t = mActiveItem->todo(); 1377 Todo * t = mActiveItem->todo();
1363 if ( t->isRunning() ) { 1378 if ( t->isRunning() ) {
1364 KOStopTodoPrefs tp ( t, this ); 1379 KOStopTodoPrefs tp ( t, this );
1365 if (QApplication::desktop()->width() <= 800 ){ 1380 if (QApplication::desktop()->width() <= 800 ){
1366 int wid = tp.width(); 1381 int wid = tp.width();
1367 int hei = tp.height(); 1382 int hei = tp.height();
1368 int xx = (QApplication::desktop()->width()-wid)/2; 1383 int xx = (QApplication::desktop()->width()-wid)/2;
1369 int yy = (QApplication::desktop()->height()-hei)/2; 1384 int yy = (QApplication::desktop()->height()-hei)/2;
1370 tp.setGeometry( xx,yy,wid,hei ); 1385 tp.setGeometry( xx,yy,wid,hei );
1371 } 1386 }
1372 tp.exec(); 1387 tp.exec();
1373 updateTodo ( t, KOGlobals::EVENTEDITED ); 1388 updateTodo ( t, KOGlobals::EVENTEDITED );
1374 } else { 1389 } else {
1375 KOStartTodoPrefs tp ( t->summary(), this ); 1390 KOStartTodoPrefs tp ( t->summary(), this );
1376 if (QApplication::desktop()->width() <= 800 ){ 1391 if (QApplication::desktop()->width() <= 800 ){
1377 int wid = tp.width(); 1392 int wid = tp.width();
1378 int hei = tp.height(); 1393 int hei = tp.height();
1379 int xx = (QApplication::desktop()->width()-wid)/2; 1394 int xx = (QApplication::desktop()->width()-wid)/2;
1380 int yy = (QApplication::desktop()->height()-hei)/2; 1395 int yy = (QApplication::desktop()->height()-hei)/2;
1381 tp.setGeometry( xx,yy,wid,hei ); 1396 tp.setGeometry( xx,yy,wid,hei );
1382 } 1397 }
1383 if ( !tp.exec() ) return; 1398 if ( !tp.exec() ) return;
1384 if ( tp.stopAll() ) { 1399 if ( tp.stopAll() ) {
1385 mCalendar->stopAllTodos(); 1400 mCalendar->stopAllTodos();
1386 t->setRunning( true ); 1401 t->setRunning( true );
1387 updateView(); 1402 updateView();
1388 } else { 1403 } else {
1389 t->setRunning( true ); 1404 t->setRunning( true );
1390 updateTodo ( t, KOGlobals::EVENTEDITED ); 1405 updateTodo ( t, KOGlobals::EVENTEDITED );
1391 } 1406 }
1392 } 1407 }
1393} 1408}
1394 1409
1395void KOTodoView::itemClicked(QListViewItem *item) 1410void KOTodoView::itemClicked(QListViewItem *item)
1396{ 1411{
1397 //qDebug("KOTodoView::itemClicked %d", item); 1412 //qDebug("KOTodoView::itemClicked %d", item);
1398 if (!item) { 1413 if (!item) {
1399 if ( pendingSubtodo != 0 ) { 1414 if ( pendingSubtodo != 0 ) {
1400 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1415 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1401 } 1416 }
1402 pendingSubtodo = 0; 1417 pendingSubtodo = 0;
1403 return; 1418 return;
1404 } 1419 }
1405 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1420 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1406 if ( pendingSubtodo != 0 ) { 1421 if ( pendingSubtodo != 0 ) {
1407 bool allowReparent = true; 1422 bool allowReparent = true;
1408 QListViewItem *par = item; 1423 QListViewItem *par = item;
1409 while ( par ) { 1424 while ( par ) {
1410 if ( par == pendingSubtodo ) { 1425 if ( par == pendingSubtodo ) {
1411 allowReparent = false; 1426 allowReparent = false;
1412 break; 1427 break;
1413 } 1428 }
1414 par = par->parent(); 1429 par = par->parent();
1415 } 1430 }
1416 if ( !allowReparent ) { 1431 if ( !allowReparent ) {
1417 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1432 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1418 pendingSubtodo = 0; 1433 pendingSubtodo = 0;
1419 } else { 1434 } else {
1420 Todo* newParent = todoItem->todo(); 1435 Todo* newParent = todoItem->todo();
1421 Todo* newSub = pendingSubtodo->todo(); 1436 Todo* newSub = pendingSubtodo->todo();
1422 pendingSubtodo = 0; 1437 pendingSubtodo = 0;
1423 emit reparentTodoSignal( newParent,newSub ); 1438 emit reparentTodoSignal( newParent,newSub );
1424 return; 1439 return;
1425 } 1440 }
1426 } 1441 }
1427 1442
1428} 1443}
1429 1444
1430void KOTodoView::setDocumentId( const QString &id ) 1445void KOTodoView::setDocumentId( const QString &id )
1431{ 1446{
1432 1447
1433 mDocPrefs->setDoc( id ); 1448 mDocPrefs->setDoc( id );
1434} 1449}
1435 1450
1436void KOTodoView::itemStateChanged( QListViewItem *item ) 1451void KOTodoView::itemStateChanged( QListViewItem *item )
1437{ 1452{
1438 if (!item) return; 1453 if (!item) return;
1439 1454
1440 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1455 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1441 1456
1442// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1457// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1443 1458
1444 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1459 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1445} 1460}
1446 1461
1447void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1462void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1448{ 1463{
1449 mTodoListView->saveLayout(config,group); 1464 mTodoListView->saveLayout(config,group);
1450} 1465}
1451 1466
1452void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1467void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1453{ 1468{
1454 mTodoListView->restoreLayout(config,group); 1469 mTodoListView->restoreLayout(config,group);
1455} 1470}
1456 1471
1457void KOTodoView::processSelectionChange() 1472void KOTodoView::processSelectionChange()
1458{ 1473{
1459// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1474// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1460 1475
1461 KOTodoViewItem *item = 1476 KOTodoViewItem *item =
1462 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1477 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1463 1478
1464 if ( !item ) { 1479 if ( !item ) {
1465 emit incidenceSelected( 0 ); 1480 emit incidenceSelected( 0 );
1466 mNewSubBut->setEnabled( false ); 1481 mNewSubBut->setEnabled( false );
1467 } else { 1482 } else {
1468 emit incidenceSelected( item->todo() ); 1483 emit incidenceSelected( item->todo() );
1469 mNewSubBut->setEnabled( true ); 1484 mNewSubBut->setEnabled( true );
1470 } 1485 }
1471} 1486}
1472 1487
1473void KOTodoView::modified(bool b) 1488void KOTodoView::modified(bool b)
1474{ 1489{
1475 emit isModified(b); 1490 emit isModified(b);
1476} 1491}
1477void KOTodoView::setTodoModified( Todo* todo ) 1492void KOTodoView::setTodoModified( Todo* todo )
1478{ 1493{
1479 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1494 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1480} 1495}
1481void KOTodoView::clearSelection() 1496void KOTodoView::clearSelection()
1482{ 1497{
1483 mTodoListView->selectAll( false ); 1498 mTodoListView->selectAll( false );
1484} 1499}
1485void KOTodoView::setAllOpen() 1500void KOTodoView::setAllOpen()
1486{ 1501{
1487 if ( isFlatDisplay ) { 1502 if ( isFlatDisplay ) {
1488 isFlatDisplay = false; 1503 isFlatDisplay = false;
1489 mPopupMenu->setItemChecked( 8,false ); 1504 mPopupMenu->setItemChecked( 8,false );
1490 updateView(); 1505 updateView();
1491 } else { 1506 } else {
1492 storeCurrentItem(); 1507 storeCurrentItem();
1493 } 1508 }
1494 setOpen(mTodoListView->firstChild(), true); 1509 setOpen(mTodoListView->firstChild(), true);
1495 resetCurrentItem(); 1510 resetCurrentItem();
1496} 1511}
1497void KOTodoView::setAllClose() 1512void KOTodoView::setAllClose()
1498{ 1513{
1499 if ( isFlatDisplay ) { 1514 if ( isFlatDisplay ) {
1500 isFlatDisplay = false; 1515 isFlatDisplay = false;
1501 mPopupMenu->setItemChecked( 8,false ); 1516 mPopupMenu->setItemChecked( 8,false );
1502 updateView(); 1517 updateView();
1503 } else { 1518 } else {
1504 storeCurrentItem(); 1519 storeCurrentItem();
1505 } 1520 }
1506 setOpen(mTodoListView->firstChild(), false); 1521 setOpen(mTodoListView->firstChild(), false);
1507 resetCurrentItem(); 1522 resetCurrentItem();
1508} 1523}
1509void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1524void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1510{ 1525{
1511 1526
1512 while ( item ) { 1527 while ( item ) {
1513 setOpen( item->firstChild(), setOpenI ); 1528 setOpen( item->firstChild(), setOpenI );
1514 item->setOpen( setOpenI ); 1529 item->setOpen( setOpenI );
1515 item = item->nextSibling(); 1530 item = item->nextSibling();
1516 } 1531 }
1517} 1532}
1518 1533
1519void KOTodoView::displayAllFlat() 1534void KOTodoView::displayAllFlat()
1520{ 1535{
1521 1536
1522 mActiveItem = 0; 1537 mActiveItem = 0;
1523 pendingSubtodo = 0; 1538 pendingSubtodo = 0;
1524 if ( mBlockUpdate ) { 1539 if ( mBlockUpdate ) {
1525 return; 1540 return;
1526 } 1541 }
1527 clearList (); 1542 clearList ();
1528 mPopupMenu->setItemChecked( 8,true ); 1543 mPopupMenu->setItemChecked( 8,true );
1529 isFlatDisplay = true; 1544 isFlatDisplay = true;
1530 QPtrList<Todo> todoList = calendar()->todos(); 1545 QPtrList<Todo> todoList = calendar()->todos();
1531 Todo *todo; 1546 Todo *todo;
1532 for(todo = todoList.first(); todo; todo = todoList.next()) { 1547 for(todo = todoList.first(); todo; todo = todoList.next()) {
1533 if ( checkTodo( todo ) ) { 1548 if ( checkTodo( todo ) ) {
1534 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1549 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1535 mTodoMap.insert(todo,todoItem); 1550 mTodoMap.insert(todo,todoItem);
1536 } 1551 }
1537 } 1552 }
1538 resetCurrentItem(); 1553 resetCurrentItem();
1539} 1554}
1540 1555
1541void KOTodoView::setAllFlat() 1556void KOTodoView::setAllFlat()
1542{ 1557{
1543 if ( isFlatDisplay ) { 1558 if ( isFlatDisplay ) {
1544 isFlatDisplay = false; 1559 isFlatDisplay = false;
1545 mPopupMenu->setItemChecked( 8,false ); 1560 mPopupMenu->setItemChecked( 8,false );
1546 updateView(); 1561 updateView();
1547 return; 1562 return;
1548 } 1563 }
1549 displayAllFlat(); 1564 displayAllFlat();
1550} 1565}
1551 1566
1552void KOTodoView::purgeCompleted() 1567void KOTodoView::purgeCompleted()
1553{ 1568{
1554 emit purgeCompletedSignal(); 1569 emit purgeCompletedSignal();
1555 1570
1556} 1571}
1557void KOTodoView::toggleQuickTodo() 1572void KOTodoView::toggleQuickTodo()
1558{ 1573{
1559 if ( mQuickBar->isVisible() ) { 1574 if ( mQuickBar->isVisible() ) {
1560 mQuickBar->hide(); 1575 mQuickBar->hide();
1561 KOPrefs::instance()->mEnableQuickTodo = false; 1576 KOPrefs::instance()->mEnableQuickTodo = false;
1562 } 1577 }
1563 else { 1578 else {
1564 mQuickBar->show(); 1579 mQuickBar->show();
1565 KOPrefs::instance()->mEnableQuickTodo = true; 1580 KOPrefs::instance()->mEnableQuickTodo = true;
1566 } 1581 }
1567 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1582 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1568 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1583 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1569} 1584}
1570 1585
1571void KOTodoView::toggleRunning() 1586void KOTodoView::toggleRunning()
1572{ 1587{
1573 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1588 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1574 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1589 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1575 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1590 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1576 updateView(); 1591 updateView();
1577 if ( KOPrefs::instance()->mHideNonStartedTodos ) 1592 if ( KOPrefs::instance()->mHideNonStartedTodos )
1578 topLevelWidget()->setCaption(i18n("Hide not Running")); 1593 topLevelWidget()->setCaption(i18n("Hide not Running"));
1579 else 1594 else
1580 topLevelWidget()->setCaption(i18n("Show not Running")); 1595 topLevelWidget()->setCaption(i18n("Show not Running"));
1581} 1596}
1582 1597
1583void KOTodoView::toggleCompleted() 1598void KOTodoView::toggleCompleted()
1584{ 1599{
1585 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1600 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1586 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1601 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1587 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1602 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1588 updateView(); 1603 updateView();
1589 if ( KOPrefs::instance()->mShowCompletedTodo ) 1604 if ( KOPrefs::instance()->mShowCompletedTodo )
1590 topLevelWidget()->setCaption(i18n("Show Completed")); 1605 topLevelWidget()->setCaption(i18n("Show Completed"));
1591 else 1606 else
1592 topLevelWidget()->setCaption(i18n("Hide Completed")); 1607 topLevelWidget()->setCaption(i18n("Hide Completed"));
1593} 1608}
1594 1609
1595void KOTodoView::addQuickTodo() 1610void KOTodoView::addQuickTodo()
1596{ 1611{
1597 addQuickTodoPar( 0 ); 1612 addQuickTodoPar( 0 );
1598} 1613}
1599void KOTodoView::addQuickTodoPar( Todo * parentTodo) 1614void KOTodoView::addQuickTodoPar( Todo * parentTodo)
1600{ 1615{
1601 Todo *todo = new Todo(); 1616 Todo *todo = new Todo();
1602 todo->setSummary(mQuickAdd->text()); 1617 todo->setSummary(mQuickAdd->text());
1603 todo->setOrganizer(KOPrefs::instance()->email()); 1618 todo->setOrganizer(KOPrefs::instance()->email());
1604 if ( parentTodo ) { 1619 if ( parentTodo ) {
1605 todo->setRelatedTo(parentTodo); 1620 todo->setRelatedTo(parentTodo);
1606 1621
1607 todo->setCategories (parentTodo->categoriesStr ()); 1622 todo->setCategories (parentTodo->categoriesStr ());
1608 todo->setSecrecy (parentTodo->secrecy ()); 1623 todo->setSecrecy (parentTodo->secrecy ());
1609 if ( parentTodo->priority() < 3 ) 1624 if ( parentTodo->priority() < 3 )
1610 todo->setPriority( parentTodo->priority() ); 1625 todo->setPriority( parentTodo->priority() );
1611 todo->setCalID( parentTodo->calID() ); 1626 todo->setCalID( parentTodo->calID() );
1612 } else { 1627 } else {
1613 CalFilter * cf = mCalendar->filter(); 1628 CalFilter * cf = mCalendar->filter();
1614 if ( cf ) { 1629 if ( cf ) {
1615 if ( cf->isEnabled()&& cf->showCategories()) { 1630 if ( cf->isEnabled()&& cf->showCategories()) {
1616 todo->setCategories(cf->categoryList()); 1631 todo->setCategories(cf->categoryList());
1617 } 1632 }
1618 if ( cf->isEnabled() ) 1633 if ( cf->isEnabled() )
1619 todo->setSecrecy( cf->getSecrecy()); 1634 todo->setSecrecy( cf->getSecrecy());
1620 } 1635 }
1621 } 1636 }
1622 mCalendar->addTodo(todo); 1637 mCalendar->addTodo(todo);
1623 mQuickAdd->setText(""); 1638 mQuickAdd->setText("");
1624 todoModified (todo, KOGlobals::EVENTADDED ); 1639 todoModified (todo, KOGlobals::EVENTADDED );
1625 updateView(); 1640 updateView();
1626 1641
1627} 1642}
1628void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1643void KOTodoView::keyPressEvent ( QKeyEvent * e )
1629{ 1644{
1630 // e->ignore(); 1645 // e->ignore();
1631 //return; 1646 //return;
1632 if ( !isVisible() ) { 1647 if ( !isVisible() ) {
1633 e->ignore(); 1648 e->ignore();
1634 return; 1649 return;
1635 } 1650 }
1636 switch ( e->key() ) { 1651 switch ( e->key() ) {
1637 case Qt::Key_Down: 1652 case Qt::Key_Down:
1638 case Qt::Key_Up: 1653 case Qt::Key_Up:
1639 // KOrg::BaseView::keyPressEvent ( e ); 1654 // KOrg::BaseView::keyPressEvent ( e );
1640 e->ignore(); 1655 e->ignore();
1641 break; 1656 break;
1642 1657
1643 case Qt::Key_Q: 1658 case Qt::Key_Q:
1644 1659
1645 1660
1646 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { 1661 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) {
1647 e->ignore(); 1662 e->ignore();
1648 break; 1663 break;
1649 } 1664 }
1650 toggleQuickTodo(); 1665 toggleQuickTodo();
1651 break; 1666 break;
1652 case Qt::Key_U: 1667 case Qt::Key_U:
1653 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1668 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1654 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1669 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1655 unparentTodo(); 1670 unparentTodo();
1656 e->accept(); 1671 e->accept();
1657 } else 1672 } else
1658 e->ignore(); 1673 e->ignore();
1659 break; 1674 break;
1660 case Qt::Key_S: 1675 case Qt::Key_S:
1661 if ( e->state() == Qt::ControlButton ) { 1676 if ( e->state() == Qt::ControlButton ) {
1662 e->ignore(); 1677 e->ignore();
1663 break; 1678 break;
1664 } 1679 }
1665 if ( e->state() == Qt::ShiftButton ) { 1680 if ( e->state() == Qt::ShiftButton ) {
1666 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1681 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1667 reparentTodo(); 1682 reparentTodo();
1668 e->accept(); 1683 e->accept();
1669 } else 1684 } else
1670 e->ignore(); 1685 e->ignore();
1671 break; 1686 break;
1672 case Qt::Key_P: 1687 case Qt::Key_P:
1673 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1688 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1674 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1689 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1675 if ( pendingSubtodo ) 1690 if ( pendingSubtodo )
1676 itemClicked(mActiveItem); 1691 itemClicked(mActiveItem);
1677 e->accept(); 1692 e->accept();
1678 } else 1693 } else
1679 e->ignore(); 1694 e->ignore();
1680 break; 1695 break;
1681 case Qt::Key_Escape: 1696 case Qt::Key_Escape:
1682 if ( pendingSubtodo ) { 1697 if ( pendingSubtodo ) {
1683 itemClicked(0); 1698 itemClicked(0);
1684 e->accept(); 1699 e->accept();
1685 } else 1700 } else
1686 e->ignore(); 1701 e->ignore();
1687 break; 1702 break;
1688 default: 1703 default:
1689 e->ignore(); 1704 e->ignore();
1690 } 1705 }
1691 1706
1692 if ( true ) { 1707 if ( true ) {
1693 if ( e->key() == Qt::Key_I ) { 1708 if ( e->key() == Qt::Key_I ) {
1694 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1709 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1695 if ( cn ) { 1710 if ( cn ) {
1696 mActiveItem = cn; 1711 mActiveItem = cn;
1697 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1712 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1698 if ( ci ){ 1713 if ( ci ){
1699 showTodo(); 1714 showTodo();
1700 cn = (KOTodoViewItem*)cn->itemBelow(); 1715 cn = (KOTodoViewItem*)cn->itemBelow();
1701 if ( cn ) { 1716 if ( cn ) {
1702 mTodoListView->setCurrentItem ( cn ); 1717 mTodoListView->setCurrentItem ( cn );
1703 mTodoListView->ensureItemVisible ( cn ); 1718 mTodoListView->ensureItemVisible ( cn );
1704 } 1719 }
1705 1720
1706 } 1721 }
1707 } 1722 }
1708 e->accept(); 1723 e->accept();
1709 } 1724 }
1710 } 1725 }
1711} 1726}
1712 1727
1713void KOTodoView::updateTodo( Todo * t, int type ) 1728void KOTodoView::updateTodo( Todo * t, int type )
1714{ 1729{
1715 if ( mBlockUpdate ) 1730 if ( mBlockUpdate )
1716 return; 1731 return;
1717 1732
1718 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1733 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1719 itemIterator = mTodoMap.find(t); 1734 itemIterator = mTodoMap.find(t);
1720 if (itemIterator != mTodoMap.end()) { 1735 if (itemIterator != mTodoMap.end()) {
1721 (*itemIterator)->construct(); 1736 (*itemIterator)->construct();
1722 } else { 1737 } else {
1723 if ( type == KOGlobals::EVENTADDED ) { 1738 if ( type == KOGlobals::EVENTADDED ) {
1724 insertTodoItem( t ); 1739 insertTodoItem( t );
1725 } 1740 }
1726 } 1741 }
1727 1742
1728} 1743}
1729 1744
1730void KOTodoView::todoModified(Todo * t , int p ) 1745void KOTodoView::todoModified(Todo * t , int p )
1731{ 1746{
1732 mBlockUpdate = true; 1747 mBlockUpdate = true;
1733 emit todoModifiedSignal ( t, p ); 1748 emit todoModifiedSignal ( t, p );
1734 mBlockUpdate = false; 1749 mBlockUpdate = false;
1735} 1750}