summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-08-19 12:08:05 (UTC)
committer zautrix <zautrix>2005-08-19 12:08:05 (UTC)
commit9014049779be6cfec02d73e19596439f0f4f9bed (patch) (unidiff)
tree3983282e83183cc15dd615ba4ac5a800da21efe0 /korganizer
parent81891a49afc2f7cd89db4e2770c3b7831644428d (diff)
downloadkdepimpi-9014049779be6cfec02d73e19596439f0f4f9bed.zip
kdepimpi-9014049779be6cfec02d73e19596439f0f4f9bed.tar.gz
kdepimpi-9014049779be6cfec02d73e19596439f0f4f9bed.tar.bz2
list sort fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp21
-rw-r--r--korganizer/kotodoviewitem.cpp14
2 files changed, 11 insertions, 24 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index b236c2d..4fc1194 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1444 +1,1437 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qpaintdevicemetrics.h> 38#include <qpaintdevicemetrics.h>
39 39
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43#include <kglobal.h> 43#include <kglobal.h>
44 44
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46#include <libkcal/calendar.h> 46#include <libkcal/calendar.h>
47#include <libkcal/calendarlocal.h> 47#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 48#include <libkcal/icalformat.h>
49#include <libkcal/vcalformat.h> 49#include <libkcal/vcalformat.h>
50#include <libkcal/recurrence.h> 50#include <libkcal/recurrence.h>
51#include <libkcal/filestorage.h> 51#include <libkcal/filestorage.h>
52#include <libkdepim/categoryselectdialog.h> 52#include <libkdepim/categoryselectdialog.h>
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60#ifndef KORG_NOPRINTER 60#ifndef KORG_NOPRINTER
61#include "calprinter.h" 61#include "calprinter.h"
62#endif 62#endif
63#include "koglobals.h" 63#include "koglobals.h"
64#include "koprefs.h" 64#include "koprefs.h"
65#include "kfiledialog.h" 65#include "kfiledialog.h"
66 66
67#include "kolistview.h" 67#include "kolistview.h"
68#include "koeventviewer.h" 68#include "koeventviewer.h"
69 69
70extern QPixmap* sgListViewCompletedPix[6]; 70extern QPixmap* sgListViewCompletedPix[6];
71extern QPixmap* sgListViewJournalPix; 71extern QPixmap* sgListViewJournalPix;
72 72
73class KOListViewWhatsThis :public QWhatsThis 73class KOListViewWhatsThis :public QWhatsThis
74{ 74{
75public: 75public:
76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
77 77
78protected: 78protected:
79 virtual QString text( const QPoint& p) 79 virtual QString text( const QPoint& p)
80 { 80 {
81 return _view->getWhatsThisText(p) ; 81 return _view->getWhatsThisText(p) ;
82 } 82 }
83private: 83private:
84 QWidget* _wid; 84 QWidget* _wid;
85 KOListView * _view; 85 KOListView * _view;
86}; 86};
87 87
88 88
89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
90{ 90{
91 mItem = item; 91 mItem = item;
92 mDate = date; 92 mDate = date;
93} 93}
94 94
95ListItemVisitor::~ListItemVisitor() 95ListItemVisitor::~ListItemVisitor()
96{ 96{
97} 97}
98 98
99bool ListItemVisitor::visit(Event *e) 99bool ListItemVisitor::visit(Event *e)
100{ 100{
101 bool ok = false; 101 bool ok = false;
102 QString start, end; 102 QString start, end;
103 QDate ds, de; 103 QDate ds, de;
104 if ( e->doesRecur() ) { 104 if ( e->doesRecur() ) {
105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
106 if ( ok ) { 106 if ( ok ) {
107 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 107 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
108 start = KGlobal::locale()->formatDate(ds,true); 108 start = KGlobal::locale()->formatDate(ds,true);
109 de = ds.addDays( days); 109 de = ds.addDays( days);
110 end = KGlobal::locale()->formatDate(de,true); 110 end = KGlobal::locale()->formatDate(de,true);
111 } 111 }
112 112
113 } 113 }
114 if ( ! ok ) { 114 if ( ! ok ) {
115 start =e->dtStartDateStr(); 115 start =e->dtStartDateStr();
116 end = e->dtEndDateStr(); 116 end = e->dtEndDateStr();
117 ds = e->dtStart().date(); 117 ds = e->dtStart().date();
118 de = e->dtEnd().date(); 118 de = e->dtEnd().date();
119 } 119 }
120 mItem->setText(0,e->summary()); 120 mItem->setText(0,e->summary());
121 mItem->setText(1,start); 121 mItem->setText(1,start);
122 if ( e->doesFloat() ) 122 if ( e->doesFloat() )
123 mItem->setText(2,"---"); 123 mItem->setText(2,"---");
124 else 124 else
125 mItem->setText(2,e->dtStartTimeStr()); 125 mItem->setText(2,e->dtStartTimeStr());
126 mItem->setText(3,end); 126 mItem->setText(3,end);
127 if ( e->doesFloat() ) 127 if ( e->doesFloat() )
128 mItem->setText(4,"---"); 128 mItem->setText(4,"---");
129 else 129 else
130 mItem->setText(4,e->dtEndTimeStr()); 130 mItem->setText(4,e->dtEndTimeStr());
131 mItem->setText(5, e->durationText()); 131 mItem->setText(5, e->durationText());
132 if ( e->isAlarmEnabled() ) { 132 if ( e->isAlarmEnabled() ) {
133 mItem->setText(6,e->alarms().first()->offsetText() ); 133 mItem->setText(6,e->alarms().first()->offsetText() );
134 } else { 134 } else {
135 mItem->setText(6, i18n("No")); 135 mItem->setText(6, i18n("No"));
136 } 136 }
137 mItem->setText(7, e->recurrenceText()); 137 mItem->setText(7, e->recurrenceText());
138 if( ! e->doesRecur() ) 138 if( ! e->doesRecur() )
139 mItem->setSortKey( 7, "-" ); 139 mItem->setSortKey( 7, "-" );
140 mItem->setText(8, e->cancelled() ? i18n("Yes") : i18n("No")); 140 mItem->setText(8, e->cancelled() ? i18n("Yes") : i18n("No"));
141 mItem->setText(9,e->categoriesStr()); 141 mItem->setText(9,e->categoriesStr());
142 mItem->setText(10, KOPrefs::instance()->calName( e->calID() )); 142 mItem->setText(10, KOPrefs::instance()->calName( e->calID() ));
143 mItem->setText(11, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); 143 mItem->setText(11, KGlobal::locale()->formatDateTime( e->lastModified(), true, true ));
144 mItem->setSortKey(11,e->lastModifiedSortKey());
144 145
145 QString key; 146 QString key;
146 QDate d = e->lastModified().date(); 147 QTime t;
147 QTime t = e->lastModified().time();
148 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() );
149 mItem->setSortKey(12,key);
150 t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 148 t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
151 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 149 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
152 mItem->setSortKey(1,key); 150 mItem->setSortKey(1,key);
153 151
154 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 152 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
155 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 153 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
156 mItem->setSortKey(3,key); 154 mItem->setSortKey(3,key);
157 return true; 155 return true;
158} 156}
159 157
160bool ListItemVisitor::visit(Todo *t) 158bool ListItemVisitor::visit(Todo *t)
161{ 159{
162 mItem->setText(0,t->summary()); 160 mItem->setText(0,t->summary());
163 if ( t->isCompleted() ) { 161 if ( t->isCompleted() ) {
164 mItem->setSortKey(0,"99"+ t->summary().left(10)); 162 mItem->setSortKey(0,"99"+ t->summary().left(10));
165 } else 163 } else
166 mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); 164 mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10));
167 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); 165 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20]));
168 if (t->hasStartDate()) { 166 if (t->hasStartDate()) {
169 mItem->setText(1,t->dtStartDateStr()); 167 mItem->setText(1,t->dtStartDateStr());
170 if (t->doesFloat()) { 168 if (t->doesFloat()) {
171 mItem->setText(2,"---"); 169 mItem->setText(2,"---");
172 } else { 170 } else {
173 mItem->setText(2,t->dtStartTimeStr()); 171 mItem->setText(2,t->dtStartTimeStr());
174 } 172 }
175 } else { 173 } else {
176 mItem->setText(1,"---"); 174 mItem->setText(1,"---");
177 mItem->setText(2,"---"); 175 mItem->setText(2,"---");
178 } 176 }
179 if ( t->isAlarmEnabled() ) { 177 if ( t->isAlarmEnabled() ) {
180 mItem->setText(6,t->alarms().first()->offsetText() ); 178 mItem->setText(6,t->alarms().first()->offsetText() );
181 } else { 179 } else {
182 mItem->setText(6, i18n("No")); 180 mItem->setText(6, i18n("No"));
183 } 181 }
184 mItem->setText(7, t->recurrenceText()); 182 mItem->setText(7, t->recurrenceText());
185 if( ! t->doesRecur() ) 183 if( ! t->doesRecur() )
186 mItem->setSortKey( 7, "-" ); 184 mItem->setSortKey( 7, "-" );
187 if (t->hasDueDate()) { 185 if (t->hasDueDate()) {
188 mItem->setText(3,t->dtDueDateStr()); 186 mItem->setText(3,t->dtDueDateStr());
189 if (t->doesFloat()) { 187 if (t->doesFloat()) {
190 mItem->setText(4,"---"); 188 mItem->setText(4,"---");
191 } else { 189 } else {
192 mItem->setText(4,t->dtDueTimeStr()); 190 mItem->setText(4,t->dtDueTimeStr());
193 } 191 }
194 } else { 192 } else {
195 mItem->setText(3,"---"); 193 mItem->setText(3,"---");
196 mItem->setText(4,"---"); 194 mItem->setText(4,"---");
197 } 195 }
198 mItem->setText(5, t->durationText()); 196 mItem->setText(5, t->durationText());
199 mItem->setText(8, t->cancelled() ? i18n("Yes") : i18n("No")); 197 mItem->setText(8, t->cancelled() ? i18n("Yes") : i18n("No"));
200 mItem->setText(9,t->categoriesStr()); 198 mItem->setText(9,t->categoriesStr());
201 mItem->setText(10, KOPrefs::instance()->calName( t->calID() )); 199 mItem->setText(10, KOPrefs::instance()->calName( t->calID() ));
202 mItem->setText(11, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); 200 mItem->setText(11, KGlobal::locale()->formatDateTime( t->lastModified(), true, true ));
201 mItem->setSortKey(11,t->lastModifiedSortKey());
203 QString key; 202 QString key;
204 QDate d = t->lastModified().date(); 203 QDate d;
205 QTime tm = t->lastModified().time(); 204 QTime tm;
206 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() );
207 mItem->setSortKey(11,key);
208 if (t->hasDueDate()) { 205 if (t->hasDueDate()) {
209 d = t->dtDue().date(); 206 d = t->dtDue().date();
210 tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 207 tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
211 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 208 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
212 mItem->setSortKey(3,key); 209 mItem->setSortKey(3,key);
213 } 210 }
214 if ( t->hasStartDate() ) { 211 if ( t->hasStartDate() ) {
215 d = t->dtStart().date(); 212 d = t->dtStart().date();
216 tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 213 tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
217 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 214 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
218 mItem->setSortKey(1,key); 215 mItem->setSortKey(1,key);
219 } 216 }
220 return true; 217 return true;
221} 218}
222 219
223bool ListItemVisitor::visit(Journal * j) 220bool ListItemVisitor::visit(Journal * j)
224{ 221{
225 222
226 QString des; 223 QString des;
227 mItem->setPixmap( 0, *sgListViewJournalPix); 224 mItem->setPixmap( 0, *sgListViewJournalPix);
228 if ( !j->summary().isEmpty() ) { 225 if ( !j->summary().isEmpty() ) {
229 des = j->summary(); 226 des = j->summary();
230 } else { 227 } else {
231 des = j->description().left(30); 228 des = j->description().left(30);
232 des = des.simplifyWhiteSpace (); 229 des = des.simplifyWhiteSpace ();
233 des.replace (QRegExp ("\\n"),"" ); 230 des.replace (QRegExp ("\\n"),"" );
234 des.replace (QRegExp ("\\r"),"" ); 231 des.replace (QRegExp ("\\r"),"" );
235 } 232 }
236 mItem->setText(0,des.left(25)); 233 mItem->setText(0,des.left(25));
237 mItem->setSortKey(0,"0"+ des.left(25)); 234 mItem->setSortKey(0,"0"+ des.left(25));
238 mItem->setText(1,j->dtStartDateStr()); 235 mItem->setText(1,j->dtStartDateStr());
239 mItem->setText(2,"---"); 236 mItem->setText(2,"---");
240 mItem->setText(3,"---"); 237 mItem->setText(3,"---");
241 mItem->setText(4,"---"); 238 mItem->setText(4,"---");
242 mItem->setText(5,"---"); 239 mItem->setText(5,"---");
243 mItem->setText(6,"---"); 240 mItem->setText(6,"---");
244 mItem->setText(7,"---"); 241 mItem->setText(7,"---");
245 mItem->setText(8,"---"); 242 mItem->setText(8,"---");
246 mItem->setText(9,j->categoriesStr()); 243 mItem->setText(9,j->categoriesStr());
247 mItem->setText(10, KOPrefs::instance()->calName( j->calID() )); 244 mItem->setText(10, KOPrefs::instance()->calName( j->calID() ));
248 mItem->setText(11, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); 245 mItem->setText(11, KGlobal::locale()->formatDateTime( j->lastModified(), true, true ));
246 mItem->setSortKey(11,j->lastModifiedSortKey());
249 247
250 QString key; 248 QString key;
251 QDate d = j->lastModified().date(); 249 QDate d;
252 QTime tm = j->lastModified().time();
253 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() );
254 mItem->setSortKey(12,key);
255 d = j->dtStart().date(); 250 d = j->dtStart().date();
256 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 251 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
257 mItem->setSortKey(1,key); 252 mItem->setSortKey(1,key);
258 mItem->setSortKey(7,key);
259
260 return true; 253 return true;
261} 254}
262 255
263KOListView::KOListView(Calendar *calendar, QWidget *parent, 256KOListView::KOListView(Calendar *calendar, QWidget *parent,
264 const char *name) 257 const char *name)
265 : KOEventView(calendar, parent, name) 258 : KOEventView(calendar, parent, name)
266{ 259{
267 260
268 mActiveItem = 0; 261 mActiveItem = 0;
269 mForceShowCompletedTodos = false; 262 mForceShowCompletedTodos = false;
270 mListView = new KOListViewListView(this); 263 mListView = new KOListViewListView(this);
271 mListView->addColumn(i18n("Summary")); 264 mListView->addColumn(i18n("Summary"));
272 mListView->addColumn(i18n("Start Date")); 265 mListView->addColumn(i18n("Start Date"));
273 mListView->addColumn(i18n("Start Time")); 266 mListView->addColumn(i18n("Start Time"));
274 mListView->addColumn(i18n("End/Due Date")); 267 mListView->addColumn(i18n("End/Due Date"));
275 mListView->addColumn(i18n("End/Due Time")); 268 mListView->addColumn(i18n("End/Due Time"));
276 mListView->addColumn(i18n("Duration")); 269 mListView->addColumn(i18n("Duration"));
277 mListView->addColumn(i18n("Alarm")); // alarm set? 270 mListView->addColumn(i18n("Alarm")); // alarm set?
278 mListView->addColumn(i18n("Recurs")); // recurs? 271 mListView->addColumn(i18n("Recurs")); // recurs?
279 mListView->addColumn(i18n("Cancelled")); 272 mListView->addColumn(i18n("Cancelled"));
280 mListView->addColumn(i18n("Categories")); 273 mListView->addColumn(i18n("Categories"));
281 mListView->addColumn(i18n("Calendar")); 274 mListView->addColumn(i18n("Calendar"));
282 mListView->addColumn(i18n("Last Modified")); 275 mListView->addColumn(i18n("Last Modified"));
283 276
284 mListView->setColumnAlignment(0,AlignLeft); 277 mListView->setColumnAlignment(0,AlignLeft);
285 mListView->setColumnAlignment(1,AlignLeft); 278 mListView->setColumnAlignment(1,AlignLeft);
286 mListView->setColumnAlignment(2,AlignHCenter); 279 mListView->setColumnAlignment(2,AlignHCenter);
287 mListView->setColumnAlignment(3,AlignLeft); 280 mListView->setColumnAlignment(3,AlignLeft);
288 mListView->setColumnAlignment(4,AlignHCenter); 281 mListView->setColumnAlignment(4,AlignHCenter);
289 mListView->setColumnAlignment(5,AlignLeft); 282 mListView->setColumnAlignment(5,AlignLeft);
290 mListView->setColumnAlignment(6,AlignLeft); 283 mListView->setColumnAlignment(6,AlignLeft);
291 mListView->setColumnAlignment(7,AlignLeft); 284 mListView->setColumnAlignment(7,AlignLeft);
292 mListView->setColumnAlignment(8,AlignLeft); 285 mListView->setColumnAlignment(8,AlignLeft);
293 mListView->setColumnAlignment(9,AlignLeft); 286 mListView->setColumnAlignment(9,AlignLeft);
294 mListView->setColumnAlignment(10,AlignLeft); 287 mListView->setColumnAlignment(10,AlignLeft);
295 mListView->setColumnAlignment(11,AlignLeft); 288 mListView->setColumnAlignment(11,AlignLeft);
296 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 289 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
297 290
298 int iii = 0; 291 int iii = 0;
299 for ( iii = 0; iii< 12 ; ++iii ) 292 for ( iii = 0; iii< 12 ; ++iii )
300 mListView->setColumnWidthMode( iii, QListView::Manual ); 293 mListView->setColumnWidthMode( iii, QListView::Manual );
301 294
302 QBoxLayout *layoutTop = new QVBoxLayout(this); 295 QBoxLayout *layoutTop = new QVBoxLayout(this);
303 layoutTop->addWidget(mListView); 296 layoutTop->addWidget(mListView);
304 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 297 mListView->setFont ( KOPrefs::instance()->mListViewFont );
305 mPopupMenu = eventPopup(); 298 mPopupMenu = eventPopup();
306 QPopupMenu* selPopup = new QPopupMenu ( this ); 299 QPopupMenu* selPopup = new QPopupMenu ( this );
307 mPopupMenu->insertSeparator(); 300 mPopupMenu->insertSeparator();
308 301
309 selPopup->insertItem(i18n("All"),this, 302 selPopup->insertItem(i18n("All"),this,
310 SLOT(allSelection())); 303 SLOT(allSelection()));
311 selPopup->insertItem(i18n("None"),this, 304 selPopup->insertItem(i18n("None"),this,
312 SLOT(clearSelection())); 305 SLOT(clearSelection()));
313 selPopup->insertItem(i18n("Delete selected..."),this, 306 selPopup->insertItem(i18n("Delete selected..."),this,
314 SLOT(deleteAll())); 307 SLOT(deleteAll()));
315 mPopupMenu->insertItem(i18n("Selection"), selPopup ); 308 mPopupMenu->insertItem(i18n("Selection"), selPopup );
316 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
317 i18n("Hide all selected"),this, 310 i18n("Hide all selected"),this,
318 SLOT(hideAll()),true); 311 SLOT(hideAll()),true);
319 312
320 selPopup->insertSeparator(); 313 selPopup->insertSeparator();
321 QPopupMenu * exportPO = new QPopupMenu ( this ); 314 QPopupMenu * exportPO = new QPopupMenu ( this );
322 selPopup->insertItem( i18n("Export"), exportPO ); 315 selPopup->insertItem( i18n("Export"), exportPO );
323#ifdef DESKTOP_VERSION 316#ifdef DESKTOP_VERSION
324 mPopupMenu->insertSeparator(); 317 mPopupMenu->insertSeparator();
325 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 318 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
326 i18n("Print complete list..."),this, 319 i18n("Print complete list..."),this,
327 SLOT(printList()),true); 320 SLOT(printList()),true);
328#endif 321#endif
329 mCalPopup = new QPopupMenu ( this ); 322 mCalPopup = new QPopupMenu ( this );
330 selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); 323 selPopup->insertItem( i18n("Set Calendar"), mCalPopup );
331 324
332 selPopup->insertItem(i18n("Set categories")+"...",this, 325 selPopup->insertItem(i18n("Set categories")+"...",this,
333 SLOT(setCat()) ); 326 SLOT(setCat()) );
334 selPopup->insertItem( i18n("Set alarm..."),this, 327 selPopup->insertItem( i18n("Set alarm..."),this,
335 SLOT(setAlarm())); 328 SLOT(setAlarm()));
336#if 0 329#if 0
337 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
338 i18n("Set categories")+"...",this, 331 i18n("Set categories")+"...",this,
339 SLOT(setCat()),true); 332 SLOT(setCat()),true);
340 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 333 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
341 i18n("Set alarm..."),this, 334 i18n("Set alarm..."),this,
342 SLOT(setAlarm()),true); 335 SLOT(setAlarm()),true);
343#endif 336#endif
344 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, 337 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
345 SLOT( populateCalPopup() )); 338 SLOT( populateCalPopup() ));
346 QObject::connect(mCalPopup,SIGNAL(activated( int )),this, 339 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
347 SLOT( setCalendar( int ) )); 340 SLOT( setCalendar( int ) ));
348 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, 341 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this,
349 SLOT( catChanged( Incidence * ) )); 342 SLOT( catChanged( Incidence * ) ));
350 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 343 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
351 SLOT(saveToFile())); 344 SLOT(saveToFile()));
352 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 345 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
353 SLOT(saveToFileVCS())); 346 SLOT(saveToFileVCS()));
354 exportPO->insertItem( i18n("Journal/Details..."),this, 347 exportPO->insertItem( i18n("Journal/Details..."),this,
355 SLOT(saveDescriptionToFile())); 348 SLOT(saveDescriptionToFile()));
356 // mPopupMenu->insertSeparator(); 349 // mPopupMenu->insertSeparator();
357 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 350 // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
358 // i18n("Add Categ. to selected..."),this, 351 // i18n("Add Categ. to selected..."),this,
359 // SLOT(addCat()),true); 352 // SLOT(addCat()),true);
360 //mPopupMenu->insertSeparator(); 353 //mPopupMenu->insertSeparator();
361#ifndef DESKTOP_VERSION 354#ifndef DESKTOP_VERSION
362 selPopup->insertSeparator(); 355 selPopup->insertSeparator();
363 selPopup->insertItem( i18n("Beam via IR..."),this, 356 selPopup->insertItem( i18n("Beam via IR..."),this,
364 SLOT(beamSelected())); 357 SLOT(beamSelected()));
365#if 0 358#if 0
366 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 359 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
367 i18n("Beam via IR"),this, 360 i18n("Beam via IR"),this,
368 SLOT(beamSelected()),true); 361 SLOT(beamSelected()),true);
369#endif 362#endif
370#endif 363#endif
371 /* 364 /*
372 mPopupMenu = new QPopupMenu; 365 mPopupMenu = new QPopupMenu;
373 mPopupMenu->insertItem(i18n("Edit Event"), this, 366 mPopupMenu->insertItem(i18n("Edit Event"), this,
374 SLOT (editEvent())); 367 SLOT (editEvent()));
375 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 368 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
376 SLOT (deleteEvent())); 369 SLOT (deleteEvent()));
377 mPopupMenu->insertSeparator(); 370 mPopupMenu->insertSeparator();
378 mPopupMenu->insertItem(i18n("Show Dates"), this, 371 mPopupMenu->insertItem(i18n("Show Dates"), this,
379 SLOT(showDates())); 372 SLOT(showDates()));
380 mPopupMenu->insertItem(i18n("Hide Dates"), this, 373 mPopupMenu->insertItem(i18n("Hide Dates"), this,
381 SLOT(hideDates())); 374 SLOT(hideDates()));
382 */ 375 */
383 QObject::connect(mListView,SIGNAL( newEvent()), 376 QObject::connect(mListView,SIGNAL( newEvent()),
384 this,SIGNAL(signalNewEvent())); 377 this,SIGNAL(signalNewEvent()));
385 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 378 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
386 this,SLOT(defaultItemAction(QListViewItem *))); 379 this,SLOT(defaultItemAction(QListViewItem *)));
387 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 380 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
388 const QPoint &, int )), 381 const QPoint &, int )),
389 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 382 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
390 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 383 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
391 SLOT(processSelectionChange(QListViewItem *))); 384 SLOT(processSelectionChange(QListViewItem *)));
392 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 385 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
393 SIGNAL(showIncidenceSignal(Incidence *)) ); 386 SIGNAL(showIncidenceSignal(Incidence *)) );
394 387
395 readSettings(KOGlobals::config(),"KOListView Layout"); 388 readSettings(KOGlobals::config(),"KOListView Layout");
396} 389}
397 390
398KOListView::~KOListView() 391KOListView::~KOListView()
399{ 392{
400 delete mPopupMenu; 393 delete mPopupMenu;
401#if QT_VERSION >= 0x030000 394#if QT_VERSION >= 0x030000
402 395
403#else 396#else
404 delete mKOListViewWhatsThis; 397 delete mKOListViewWhatsThis;
405#endif 398#endif
406} 399}
407 400
408void KOListView::catChanged( Incidence* inc) 401void KOListView::catChanged( Incidence* inc)
409{ 402{
410 KOListViewItem* item = getItemForEvent(inc); 403 KOListViewItem* item = getItemForEvent(inc);
411 if (item) { 404 if (item) {
412 ListItemVisitor v(item, mStartDate ); 405 ListItemVisitor v(item, mStartDate );
413 inc->accept(v); 406 inc->accept(v);
414 } 407 }
415} 408}
416QString KOListView::getWhatsThisText(QPoint p) 409QString KOListView::getWhatsThisText(QPoint p)
417{ 410{
418 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 411 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
419 if ( item ) 412 if ( item )
420 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 413 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
421 KOPrefs::instance()->mWTshowDetails, 414 KOPrefs::instance()->mWTshowDetails,
422 KOPrefs::instance()->mWTshowCreated, 415 KOPrefs::instance()->mWTshowCreated,
423 KOPrefs::instance()->mWTshowChanged); 416 KOPrefs::instance()->mWTshowChanged);
424 return i18n("That is the list view" ); 417 return i18n("That is the list view" );
425 418
426} 419}
427 420
428void KOListView::setCalendar( int c ) 421void KOListView::setCalendar( int c )
429{ 422{
430 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 423 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
431 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), 424 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
432 i18n("Continue"), i18n("Cancel"), 0, 425 i18n("Continue"), i18n("Cancel"), 0,
433 0, 1 ); 426 0, 1 );
434 if ( result != 0 ) { 427 if ( result != 0 ) {
435 return; 428 return;
436 } 429 }
437 430
438 QPtrList<Incidence> delSel = getSelectedIncidences() ; 431 QPtrList<Incidence> delSel = getSelectedIncidences() ;
439 int icount = delSel.count(); 432 int icount = delSel.count();
440 if ( icount ) { 433 if ( icount ) {
441 Incidence *incidence = delSel.first(); 434 Incidence *incidence = delSel.first();
442 while ( incidence ) { 435 while ( incidence ) {
443 incidence->setCalID( c ); 436 incidence->setCalID( c );
444 KOListViewItem * item = getItemForEvent( incidence ); 437 KOListViewItem * item = getItemForEvent( incidence );
445 if ( item ) { 438 if ( item ) {
446 ListItemVisitor v(item, mStartDate ); 439 ListItemVisitor v(item, mStartDate );
447 incidence->accept(v); 440 incidence->accept(v);
448 } 441 }
449 incidence = delSel.next(); 442 incidence = delSel.next();
450 } 443 }
451 } 444 }
452 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 445 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
453 KopiCalendarFile * cal = calendars.first(); 446 KopiCalendarFile * cal = calendars.first();
454 while ( cal ) { 447 while ( cal ) {
455 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 448 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
456 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 449 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
457 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 450 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
458 if ( cal->isStandard ) 451 if ( cal->isStandard )
459 mCalendar->setDefaultCalendar( cal->mCalNumber ); 452 mCalendar->setDefaultCalendar( cal->mCalNumber );
460 cal = calendars.next(); 453 cal = calendars.next();
461 } 454 }
462 mCalendar->setSyncEventsReadOnly(); 455 mCalendar->setSyncEventsReadOnly();
463 mCalendar->reInitAlarmSettings(); 456 mCalendar->reInitAlarmSettings();
464 457
465} 458}
466void KOListView::populateCalPopup() 459void KOListView::populateCalPopup()
467{ 460{
468 mCalPopup->clear(); 461 mCalPopup->clear();
469 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 462 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
470 while ( kkf ) { 463 while ( kkf ) {
471 int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); 464 int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber);
472 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 465 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
473 mCalPopup->setItemEnabled( index, false ); 466 mCalPopup->setItemEnabled( index, false );
474 kkf = KOPrefs::instance()->mCalendars.next(); 467 kkf = KOPrefs::instance()->mCalendars.next();
475 } 468 }
476} 469}
477void KOListView::updateList() 470void KOListView::updateList()
478{ 471{
479 // qDebug(" KOListView::updateList() "); 472 // qDebug(" KOListView::updateList() ");
480 473
481} 474}
482 475
483void KOListView::clearList() 476void KOListView::clearList()
484{ 477{
485 clear (); 478 clear ();
486} 479}
487 480
488void KOListView::setCat() 481void KOListView::setCat()
489{ 482{
490 483
491 bool set = true; 484 bool set = true;
492 int result = KMessageBox::warningYesNoCancel(this, 485 int result = KMessageBox::warningYesNoCancel(this,
493 i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), 486 i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"),
494 i18n("Set categories"), 487 i18n("Set categories"),
495 i18n("Add"), 488 i18n("Add"),
496 i18n("Reset")); 489 i18n("Reset"));
497 if (result == KMessageBox::Cancel) return; 490 if (result == KMessageBox::Cancel) return;
498 if (result == KMessageBox::Yes) set = false; 491 if (result == KMessageBox::Yes) set = false;
499 setCategories( set ); 492 setCategories( set );
500} 493}
501 494
502void KOListView::setAlarm() 495void KOListView::setAlarm()
503{ 496{
504 KOAlarmPrefs kap( this); 497 KOAlarmPrefs kap( this);
505 if ( !kap.exec() ) 498 if ( !kap.exec() )
506 return; 499 return;
507 QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos 500 QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos
508 Incidence* inc = delSel.first(); 501 Incidence* inc = delSel.first();
509 int count = 0; 502 int count = 0;
510 while ( inc ) { 503 while ( inc ) {
511 ++count; 504 ++count;
512 if (kap.mAlarmButton->isChecked()) { 505 if (kap.mAlarmButton->isChecked()) {
513 if (inc->alarms().count() == 0) 506 if (inc->alarms().count() == 0)
514 inc->newAlarm(); 507 inc->newAlarm();
515 Alarm *alarm = inc->alarms().first(); 508 Alarm *alarm = inc->alarms().first();
516 alarm->setEnabled(true); 509 alarm->setEnabled(true);
517 int j = kap.mAlarmTimeEdit->value()* -60; 510 int j = kap.mAlarmTimeEdit->value()* -60;
518 if (kap.mAlarmIncrCombo->currentItem() == 1) 511 if (kap.mAlarmIncrCombo->currentItem() == 1)
519 j = j * 60; 512 j = j * 60;
520 else if (kap.mAlarmIncrCombo->currentItem() == 2) 513 else if (kap.mAlarmIncrCombo->currentItem() == 2)
521 j = j * (60 * 24); 514 j = j * (60 * 24);
522 alarm->setStartOffset( j ); 515 alarm->setStartOffset( j );
523 516
524 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 517 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
525 alarm->setProcedureAlarm(kap.mAlarmProgram); 518 alarm->setProcedureAlarm(kap.mAlarmProgram);
526 } 519 }
527 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 520 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
528 alarm->setAudioAlarm(kap.mAlarmSound); 521 alarm->setAudioAlarm(kap.mAlarmSound);
529 else 522 else
530 alarm->setType(Alarm::Invalid); 523 alarm->setType(Alarm::Invalid);
531 } else { 524 } else {
532 QPtrList<Alarm> alarms = inc->alarms(); 525 QPtrList<Alarm> alarms = inc->alarms();
533 Alarm *alarm; 526 Alarm *alarm;
534 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 527 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
535 alarm->setEnabled(false); 528 alarm->setEnabled(false);
536 alarm->setType(Alarm::Invalid); 529 alarm->setType(Alarm::Invalid);
537 } 530 }
538 } 531 }
539 KOListViewItem* item = getItemForEvent(inc); 532 KOListViewItem* item = getItemForEvent(inc);
540 if (item) { 533 if (item) {
541 ListItemVisitor v(item, mStartDate ); 534 ListItemVisitor v(item, mStartDate );
542 inc->accept(v); 535 inc->accept(v);
543 } 536 }
544 inc = delSel.next(); 537 inc = delSel.next();
545 } 538 }
546 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 539 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
547 qDebug("KO: Set alarm for %d items", count); 540 qDebug("KO: Set alarm for %d items", count);
548 calendar()->reInitAlarmSettings(); 541 calendar()->reInitAlarmSettings();
549 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 542 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
550} 543}
551void KOListView::setCategories( bool removeOld ) 544void KOListView::setCategories( bool removeOld )
552{ 545{
553 546
554 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 547 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
555 csd->setColorEnabled(); 548 csd->setColorEnabled();
556 if (! csd->exec()) { 549 if (! csd->exec()) {
557 delete csd; 550 delete csd;
558 return; 551 return;
559 } 552 }
560 QStringList catList = csd->selectedCategories(); 553 QStringList catList = csd->selectedCategories();
561 delete csd; 554 delete csd;
562 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 555 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
563 Incidence* inc = delSel.first(); 556 Incidence* inc = delSel.first();
564 while ( inc ) { 557 while ( inc ) {
565 if ( removeOld ) { 558 if ( removeOld ) {
566 inc->setCategories( catList, false ); 559 inc->setCategories( catList, false );
567 } else { 560 } else {
568 inc->addCategories( catList, false ); 561 inc->addCategories( catList, false );
569 } 562 }
570 KOListViewItem* item = getItemForEvent(inc); 563 KOListViewItem* item = getItemForEvent(inc);
571 if (item) { 564 if (item) {
572 ListItemVisitor v(item, mStartDate ); 565 ListItemVisitor v(item, mStartDate );
573 inc->accept(v); 566 inc->accept(v);
574 } 567 }
575 inc = delSel.next(); 568 inc = delSel.next();
576 } 569 }
577 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 570 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
578} 571}
579 572
580void KOListView::beamSelected() 573void KOListView::beamSelected()
581{ 574{
582 QPtrList<Incidence> delSel = getSelectedIncidences() ; 575 QPtrList<Incidence> delSel = getSelectedIncidences() ;
583 if ( delSel.count() ) 576 if ( delSel.count() )
584 emit beamIncidenceList( delSel ); 577 emit beamIncidenceList( delSel );
585} 578}
586 579
587void KOListView::saveDescriptionToFile() 580void KOListView::saveDescriptionToFile()
588{ 581{
589 582
590 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 583 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
591 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 584 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
592 i18n("Continue"), i18n("Cancel"), 0, 585 i18n("Continue"), i18n("Cancel"), 0,
593 0, 1 ); 586 0, 1 );
594 if ( result != 0 ) { 587 if ( result != 0 ) {
595 return; 588 return;
596 } 589 }
597 QPtrList<Incidence> delSel = getSelectedIncidences() ; 590 QPtrList<Incidence> delSel = getSelectedIncidences() ;
598 int icount = delSel.count(); 591 int icount = delSel.count();
599 if ( icount ) { 592 if ( icount ) {
600 QString fn = KOPrefs::instance()->mLastSaveFile; 593 QString fn = KOPrefs::instance()->mLastSaveFile;
601 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 594 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
602 595
603 if ( fn == "" ) 596 if ( fn == "" )
604 return; 597 return;
605 QFileInfo info; 598 QFileInfo info;
606 info.setFile( fn ); 599 info.setFile( fn );
607 QString mes; 600 QString mes;
608 bool createbup = true; 601 bool createbup = true;
609 if ( info. exists() ) { 602 if ( info. exists() ) {
610 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 603 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
611 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 604 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
612 i18n("Overwrite!"), i18n("Cancel"), 0, 605 i18n("Overwrite!"), i18n("Cancel"), 0,
613 0, 1 ); 606 0, 1 );
614 if ( result != 0 ) { 607 if ( result != 0 ) {
615 createbup = false; 608 createbup = false;
616 } 609 }
617 } 610 }
618 if ( createbup ) { 611 if ( createbup ) {
619 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 612 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
620 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 613 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
621 Incidence *incidence = delSel.first(); 614 Incidence *incidence = delSel.first();
622 icount = 0; 615 icount = 0;
623 while ( incidence ) { 616 while ( incidence ) {
624 if ( incidence->typeID() == journalID ) { 617 if ( incidence->typeID() == journalID ) {
625 text += "\n************************************\n"; 618 text += "\n************************************\n";
626 if ( !incidence->summary().isEmpty() ) 619 if ( !incidence->summary().isEmpty() )
627 text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); 620 text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false );
628 else 621 else
629 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 622 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
630 if ( !incidence->location().isEmpty() ) 623 if ( !incidence->location().isEmpty() )
631 text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; 624 text +="\n(" + i18n("Location: ") + incidence->location()+ ")";
632 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 625 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
633 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 626 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
634 ++icount; 627 ++icount;
635 628
636 } else { 629 } else {
637 if ( !incidence->description().isEmpty() ) { 630 if ( !incidence->description().isEmpty() ) {
638 text += "\n************************************\n"; 631 text += "\n************************************\n";
639 if ( incidence->typeID() == todoID ) 632 if ( incidence->typeID() == todoID )
640 text += i18n("To-Do: "); 633 text += i18n("To-Do: ");
641 text += incidence->summary(); 634 text += incidence->summary();
642 if ( !incidence->location().isEmpty() ) 635 if ( !incidence->location().isEmpty() )
643 text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; 636 text +="\n(" + i18n("Location: ") + incidence->location()+ ")";
644 if ( incidence->hasStartDate() ) 637 if ( incidence->hasStartDate() )
645 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 638 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
646 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 639 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
647 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 640 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
648 ++icount; 641 ++icount;
649 642
650 } 643 }
651 } 644 }
652 incidence = delSel.next(); 645 incidence = delSel.next();
653 } 646 }
654 QFile file( fn ); 647 QFile file( fn );
655 if (!file.open( IO_WriteOnly ) ) { 648 if (!file.open( IO_WriteOnly ) ) {
656 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 649 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
657 return; 650 return;
658 } 651 }
659 QTextStream ts( &file ); 652 QTextStream ts( &file );
660 ts << text; 653 ts << text;
661 file.close(); 654 file.close();
662 //qDebug("%s ", text.latin1()); 655 //qDebug("%s ", text.latin1());
663 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 656 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
664 KOPrefs::instance()->mLastSaveFile = fn; 657 KOPrefs::instance()->mLastSaveFile = fn;
665 topLevelWidget()->setCaption(mes); 658 topLevelWidget()->setCaption(mes);
666 } 659 }
667 } 660 }
668} 661}
669void KOListView::saveToFileVCS() 662void KOListView::saveToFileVCS()
670{ 663{
671 writeToFile( false ); 664 writeToFile( false );
672} 665}
673void KOListView::saveToFile() 666void KOListView::saveToFile()
674{ 667{
675 writeToFile( true ); 668 writeToFile( true );
676} 669}
677QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) 670QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos )
678{ 671{
679 QPtrList<Incidence> delSel ; 672 QPtrList<Incidence> delSel ;
680 bool addSubTodos = false; 673 bool addSubTodos = false;
681 bool askSubTodos = true; 674 bool askSubTodos = true;
682 QListViewItem *item = mListView->firstChild (); 675 QListViewItem *item = mListView->firstChild ();
683 while ( item ) { 676 while ( item ) {
684 if ( item->isSelected() ) { 677 if ( item->isSelected() ) {
685 Incidence* inc = ((KOListViewItem *)item)->data(); 678 Incidence* inc = ((KOListViewItem *)item)->data();
686 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { 679 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) {
687 if ( (inc->typeID() == todoID && includeTodos) || 680 if ( (inc->typeID() == todoID && includeTodos) ||
688 (inc->typeID() == eventID && includeEvents) || 681 (inc->typeID() == eventID && includeEvents) ||
689 (inc->typeID() == journalID && includeJournals) ) { 682 (inc->typeID() == journalID && includeJournals) ) {
690 if ( inc->typeID() == todoID && onlyDueTodos ) { 683 if ( inc->typeID() == todoID && onlyDueTodos ) {
691 if ( ((Todo*)inc)->hasDueDate() ) 684 if ( ((Todo*)inc)->hasDueDate() )
692 delSel.append( inc ); 685 delSel.append( inc );
693 } else 686 } else
694 delSel.append( inc ); 687 delSel.append( inc );
695 688
696 } 689 }
697 } 690 }
698 if ( inc->typeID() == todoID ) { 691 if ( inc->typeID() == todoID ) {
699 Todo * todo = (Todo*) inc; 692 Todo * todo = (Todo*) inc;
700 if ( todo->relations().count() ) { 693 if ( todo->relations().count() ) {
701 if ( askSubTodos ) { 694 if ( askSubTodos ) {
702 int result = KMessageBox::warningYesNoCancel(this, 695 int result = KMessageBox::warningYesNoCancel(this,
703 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), 696 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"),
704 i18n("Todo has subtodos"), 697 i18n("Todo has subtodos"),
705 i18n("Yes"), 698 i18n("Yes"),
706 i18n("No")); 699 i18n("No"));
707 if ( result == KMessageBox::Cancel ) { 700 if ( result == KMessageBox::Cancel ) {
708 delSel.clear(); 701 delSel.clear();
709 return delSel; 702 return delSel;
710 } 703 }
711 if (result == KMessageBox::Yes) 704 if (result == KMessageBox::Yes)
712 addSubTodos = true; 705 addSubTodos = true;
713 askSubTodos = false; 706 askSubTodos = false;
714 } 707 }
715 if ( addSubTodos ) { 708 if ( addSubTodos ) {
716 QPtrList<Incidence> tempSel ; 709 QPtrList<Incidence> tempSel ;
717 inc->addRelationsToList( &tempSel ); 710 inc->addRelationsToList( &tempSel );
718 Incidence* tempinc = tempSel.first(); 711 Incidence* tempinc = tempSel.first();
719 while ( tempinc ) { 712 while ( tempinc ) {
720 if ( delSel.findRef( tempinc ) == -1 ) { 713 if ( delSel.findRef( tempinc ) == -1 ) {
721 if ( tempinc->typeID() == todoID && onlyDueTodos ) { 714 if ( tempinc->typeID() == todoID && onlyDueTodos ) {
722 if ( ((Todo*)tempinc)->hasDueDate() ) 715 if ( ((Todo*)tempinc)->hasDueDate() )
723 delSel.append( tempinc ); 716 delSel.append( tempinc );
724 } else 717 } else
725 delSel.append( tempinc ); 718 delSel.append( tempinc );
726 } 719 }
727 tempinc = tempSel.next(); 720 tempinc = tempSel.next();
728 } 721 }
729 } 722 }
730 } 723 }
731 } 724 }
732 } 725 }
733 item = item->nextSibling(); 726 item = item->nextSibling();
734 } 727 }
735 return delSel; 728 return delSel;
736} 729}
737 730
738void KOListView::writeToFile( bool iCal ) 731void KOListView::writeToFile( bool iCal )
739{ 732{
740 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 733 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
741 if ( !iCal ) { 734 if ( !iCal ) {
742 bool journal = false; 735 bool journal = false;
743 Incidence *incidence = delSel.first(); 736 Incidence *incidence = delSel.first();
744 while ( incidence ) { 737 while ( incidence ) {
745 if ( incidence->typeID() == journalID ) { 738 if ( incidence->typeID() == journalID ) {
746 journal = true; 739 journal = true;
747 break; 740 break;
748 } 741 }
749 incidence = delSel.next(); 742 incidence = delSel.next();
750 } 743 }
751 if ( journal ) { 744 if ( journal ) {
752 int result = KMessageBox::warningContinueCancel(this, 745 int result = KMessageBox::warningContinueCancel(this,
753 i18n("The journal entries can not be\nexported to a vCalendar file."), 746 i18n("The journal entries can not be\nexported to a vCalendar file."),
754 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 747 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
755 true); 748 true);
756 if (result != KMessageBox::Continue) return; 749 if (result != KMessageBox::Continue) return;
757 } 750 }
758 } 751 }
759 if ( delSel.count() ) { 752 if ( delSel.count() ) {
760 QString fn = KOPrefs::instance()->mLastSaveFile; 753 QString fn = KOPrefs::instance()->mLastSaveFile;
761 QString extension; 754 QString extension;
762 if ( iCal ) { 755 if ( iCal ) {
763 if ( fn.right( 4 ).lower() == ".vcs" ) { 756 if ( fn.right( 4 ).lower() == ".vcs" ) {
764 fn = fn.left( fn.length() -3) + "ics"; 757 fn = fn.left( fn.length() -3) + "ics";
765 } 758 }
766 } else { 759 } else {
767 if ( fn.right( 4 ).lower() == ".ics" ) { 760 if ( fn.right( 4 ).lower() == ".ics" ) {
768 fn = fn.left( fn.length() -3) + "vcs"; 761 fn = fn.left( fn.length() -3) + "vcs";
769 } 762 }
770 } 763 }
771 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 764 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
772 765
773 if ( fn == "" ) 766 if ( fn == "" )
774 return; 767 return;
775 QFileInfo info; 768 QFileInfo info;
776 info.setFile( fn ); 769 info.setFile( fn );
777 QString mes; 770 QString mes;
778 bool createbup = true; 771 bool createbup = true;
779 if ( info. exists() ) { 772 if ( info. exists() ) {
780 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 773 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
781 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 774 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
782 i18n("Overwrite!"), i18n("Cancel"), 0, 775 i18n("Overwrite!"), i18n("Cancel"), 0,
783 0, 1 ); 776 0, 1 );
784 if ( result != 0 ) { 777 if ( result != 0 ) {
785 createbup = false; 778 createbup = false;
786 } 779 }
787 } 780 }
788 if ( createbup ) { 781 if ( createbup ) {
789 CalendarLocal cal; 782 CalendarLocal cal;
790 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 783 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
791 Incidence *incidence = delSel.first(); 784 Incidence *incidence = delSel.first();
792 while ( incidence ) { 785 while ( incidence ) {
793 cal.addIncidence( incidence->clone() ); 786 cal.addIncidence( incidence->clone() );
794 incidence = delSel.next(); 787 incidence = delSel.next();
795 } 788 }
796 if ( iCal ) { 789 if ( iCal ) {
797 ICalFormat format; 790 ICalFormat format;
798 format.save( &cal, fn ); 791 format.save( &cal, fn );
799 } else { 792 } else {
800 793
801 VCalFormat format; 794 VCalFormat format;
802 format.save( &cal, fn ); 795 format.save( &cal, fn );
803 } 796 }
804 mes = i18n("KO/Pi:Saved %1").arg(fn ); 797 mes = i18n("KO/Pi:Saved %1").arg(fn );
805 KOPrefs::instance()->mLastSaveFile = fn; 798 KOPrefs::instance()->mLastSaveFile = fn;
806 topLevelWidget()->setCaption(mes); 799 topLevelWidget()->setCaption(mes);
807 } 800 }
808 } 801 }
809 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 802 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
810} 803}
811void KOListView::hideAll() 804void KOListView::hideAll()
812{ 805{
813 QPtrList<QListViewItem> delSel ; 806 QPtrList<QListViewItem> delSel ;
814 QListViewItem *item = mListView->firstChild (); 807 QListViewItem *item = mListView->firstChild ();
815 while ( item ) { 808 while ( item ) {
816 if ( item->isSelected() ) { 809 if ( item->isSelected() ) {
817 delSel.append(item); 810 delSel.append(item);
818 } 811 }
819 item = item->nextSibling(); 812 item = item->nextSibling();
820 } 813 }
821 item = delSel.first() ; 814 item = delSel.first() ;
822 while ( item ) { 815 while ( item ) {
823 QListViewItem * del = item; 816 QListViewItem * del = item;
824 item = delSel.next(); 817 item = delSel.next();
825 delete del; 818 delete del;
826 } 819 }
827} 820}
828void KOListView::printList() 821void KOListView::printList()
829{ 822{
830 mListView->printList(); 823 mListView->printList();
831} 824}
832void KOListView::deleteAll() 825void KOListView::deleteAll()
833{ 826{
834 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; 827 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
835 if ( delSel.count() ) { 828 if ( delSel.count() ) {
836 int icount = delSel.count(); 829 int icount = delSel.count();
837 Incidence *incidence = delSel.first(); 830 Incidence *incidence = delSel.first();
838 Incidence *toDelete; 831 Incidence *toDelete;
839 KOPrefs *p = KOPrefs::instance(); 832 KOPrefs *p = KOPrefs::instance();
840 bool confirm = p->mConfirm; 833 bool confirm = p->mConfirm;
841 QString mess; 834 QString mess;
842 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 835 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
843 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 836 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
844 p->mConfirm = false; 837 p->mConfirm = false;
845 int delCounter = 0; 838 int delCounter = 0;
846 QDialog dia ( this, "p-dialog", true ); 839 QDialog dia ( this, "p-dialog", true );
847 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 840 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
848 QVBoxLayout lay( &dia ); 841 QVBoxLayout lay( &dia );
849 lay.setMargin(7); 842 lay.setMargin(7);
850 lay.setSpacing(7); 843 lay.setSpacing(7);
851 lay.addWidget( &lab); 844 lay.addWidget( &lab);
852 QProgressBar bar( icount, &dia ); 845 QProgressBar bar( icount, &dia );
853 lay.addWidget( &bar); 846 lay.addWidget( &bar);
854 int w = 220; 847 int w = 220;
855 int h = 50; 848 int h = 50;
856 int dw = QApplication::desktop()->width(); 849 int dw = QApplication::desktop()->width();
857 int dh = QApplication::desktop()->height(); 850 int dh = QApplication::desktop()->height();
858 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 851 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
859 //dia.resize( 240,50 ); 852 //dia.resize( 240,50 );
860 dia.show(); 853 dia.show();
861 KOPrefs::instance()->mGlobalUpdateDisabled = true; 854 KOPrefs::instance()->mGlobalUpdateDisabled = true;
862 while ( incidence ) { 855 while ( incidence ) {
863 bar.setProgress( delCounter ); 856 bar.setProgress( delCounter );
864 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 857 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
865 dia.setCaption( mess ); 858 dia.setCaption( mess );
866 qApp->processEvents(); 859 qApp->processEvents();
867 toDelete = (incidence); 860 toDelete = (incidence);
868 incidence = delSel.next(); 861 incidence = delSel.next();
869 emit deleteIncidenceSignal(toDelete ); 862 emit deleteIncidenceSignal(toDelete );
870 if ( dia.result() != 0 ) 863 if ( dia.result() != 0 )
871 break; 864 break;
872 865
873 } 866 }
874 KOPrefs::instance()->mGlobalUpdateDisabled = false; 867 KOPrefs::instance()->mGlobalUpdateDisabled = false;
875 emit deleteIncidenceSignal( 0 ); 868 emit deleteIncidenceSignal( 0 );
876 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 869 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
877 topLevelWidget ()->setCaption( mess ); 870 topLevelWidget ()->setCaption( mess );
878 p->mConfirm = confirm; 871 p->mConfirm = confirm;
879 } 872 }
880 } 873 }
881 874
882 875
883} 876}
884int KOListView::maxDatesHint() 877int KOListView::maxDatesHint()
885{ 878{
886 return 0; 879 return 0;
887} 880}
888 881
889int KOListView::currentDateCount() 882int KOListView::currentDateCount()
890{ 883{
891 return 0; 884 return 0;
892} 885}
893 886
894QPtrList<Incidence> KOListView::selectedIncidences() 887QPtrList<Incidence> KOListView::selectedIncidences()
895{ 888{
896 QPtrList<Incidence> eventList; 889 QPtrList<Incidence> eventList;
897 QListViewItem *item = mListView->firstChild (); 890 QListViewItem *item = mListView->firstChild ();
898 while ( item ) { 891 while ( item ) {
899 if ( item->isSelected() ) { 892 if ( item->isSelected() ) {
900 eventList.append(((KOListViewItem *)item)->data()); 893 eventList.append(((KOListViewItem *)item)->data());
901 } 894 }
902 895
903 item = item->nextSibling(); 896 item = item->nextSibling();
904 } 897 }
905 898
906 // // QListViewItem *item = mListView->selectedItem(); 899 // // QListViewItem *item = mListView->selectedItem();
907 //if (item) eventList.append(((KOListViewItem *)item)->data()); 900 //if (item) eventList.append(((KOListViewItem *)item)->data());
908 901
909 return eventList; 902 return eventList;
910} 903}
911 904
912DateList KOListView::selectedDates() 905DateList KOListView::selectedDates()
913{ 906{
914 DateList eventList; 907 DateList eventList;
915 return eventList; 908 return eventList;
916} 909}
917 910
918void KOListView::showDates(bool show) 911void KOListView::showDates(bool show)
919{ 912{
920 // Shouldn't we set it to a value greater 0? When showDates is called with 913 // Shouldn't we set it to a value greater 0? When showDates is called with
921 // show == true at first, then the columnwidths are set to zero. 914 // show == true at first, then the columnwidths are set to zero.
922 static int oldColWidth1 = 0; 915 static int oldColWidth1 = 0;
923 static int oldColWidth3 = 0; 916 static int oldColWidth3 = 0;
924 917
925 if (!show) { 918 if (!show) {
926 oldColWidth1 = mListView->columnWidth(1); 919 oldColWidth1 = mListView->columnWidth(1);
927 oldColWidth3 = mListView->columnWidth(3); 920 oldColWidth3 = mListView->columnWidth(3);
928 mListView->setColumnWidth(1, 0); 921 mListView->setColumnWidth(1, 0);
929 mListView->setColumnWidth(3, 0); 922 mListView->setColumnWidth(3, 0);
930 } else { 923 } else {
931 mListView->setColumnWidth(1, oldColWidth1); 924 mListView->setColumnWidth(1, oldColWidth1);
932 mListView->setColumnWidth(3, oldColWidth3); 925 mListView->setColumnWidth(3, oldColWidth3);
933 } 926 }
934 mListView->repaint(); 927 mListView->repaint();
935} 928}
936 929
937void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 930void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
938 const QDate &td) 931 const QDate &td)
939{ 932{
940#ifndef KORG_NOPRINTER 933#ifndef KORG_NOPRINTER
941 calPrinter->preview(CalPrinter::Day, fd, td); 934 calPrinter->preview(CalPrinter::Day, fd, td);
942#endif 935#endif
943} 936}
944 937
945void KOListView::showDates() 938void KOListView::showDates()
946{ 939{
947 showDates(true); 940 showDates(true);
948} 941}
949 942
950void KOListView::hideDates() 943void KOListView::hideDates()
951{ 944{
952 showDates(false); 945 showDates(false);
953} 946}
954 947
955void KOListView::resetFocus() 948void KOListView::resetFocus()
956{ 949{
957 topLevelWidget()->setActiveWindow(); 950 topLevelWidget()->setActiveWindow();
958 topLevelWidget()->raise(); 951 topLevelWidget()->raise();
959 mListView->setFocus(); 952 mListView->setFocus();
960} 953}
961void KOListView::updateView() 954void KOListView::updateView()
962{ 955{
963 mListView->setFocus(); 956 mListView->setFocus();
964 if ( mListView->firstChild () ) { 957 if ( mListView->firstChild () ) {
965 mListView->setCurrentItem( mListView->firstChild () ); 958 mListView->setCurrentItem( mListView->firstChild () );
966 } 959 }
967 processSelectionChange( mListView->firstChild () ); 960 processSelectionChange( mListView->firstChild () );
968} 961}
969void KOListView::updateConfig() 962void KOListView::updateConfig()
970{ 963{
971 964
972 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 965 mListView->setFont ( KOPrefs::instance()->mListViewFont );
973 updateView(); 966 updateView();
974 967
975} 968}
976void KOListView::setStartDate(const QDate &start) 969void KOListView::setStartDate(const QDate &start)
977{ 970{
978 mStartDate = start; 971 mStartDate = start;
979} 972}
980 973
981void KOListView::showDates(const QDate &start, const QDate &end) 974void KOListView::showDates(const QDate &start, const QDate &end)
982{ 975{
983 clear(); 976 clear();
984 mStartDate = start; 977 mStartDate = start;
985 QDate date = start; 978 QDate date = start;
986 while( date <= end ) { 979 while( date <= end ) {
987 addEvents(calendar()->events(date)); 980 addEvents(calendar()->events(date));
988 addTodos(calendar()->todos(date)); 981 addTodos(calendar()->todos(date));
989 addJournals( calendar()->journals4Date(date) ); 982 addJournals( calendar()->journals4Date(date) );
990 date = date.addDays( 1 ); 983 date = date.addDays( 1 );
991 } 984 }
992 //emit incidenceSelected( 0 ); 985 //emit incidenceSelected( 0 );
993 updateView(); 986 updateView();
994 987
995} 988}
996 989
997void KOListView::addEvents(QPtrList<Event> eventList) 990void KOListView::addEvents(QPtrList<Event> eventList)
998{ 991{
999 992
1000 Event *ev; 993 Event *ev;
1001 for(ev = eventList.first(); ev; ev = eventList.next()) { 994 for(ev = eventList.first(); ev; ev = eventList.next()) {
1002 addIncidence(ev); 995 addIncidence(ev);
1003 } 996 }
1004 if ( !mListView->currentItem() ){ 997 if ( !mListView->currentItem() ){
1005 updateView(); 998 updateView();
1006 } 999 }
1007} 1000}
1008 1001
1009void KOListView::addTodos(QPtrList<Todo> eventList) 1002void KOListView::addTodos(QPtrList<Todo> eventList)
1010{ 1003{
1011 Todo *ev; 1004 Todo *ev;
1012 for(ev = eventList.first(); ev; ev = eventList.next()) { 1005 for(ev = eventList.first(); ev; ev = eventList.next()) {
1013 addIncidence(ev); 1006 addIncidence(ev);
1014 } 1007 }
1015 if ( !mListView->currentItem() ){ 1008 if ( !mListView->currentItem() ){
1016 updateView(); 1009 updateView();
1017 } 1010 }
1018} 1011}
1019void KOListView::addJournals(QPtrList<Journal> eventList) 1012void KOListView::addJournals(QPtrList<Journal> eventList)
1020{ 1013{
1021 Journal *ev; 1014 Journal *ev;
1022 for(ev = eventList.first(); ev; ev = eventList.next()) { 1015 for(ev = eventList.first(); ev; ev = eventList.next()) {
1023 addIncidence(ev); 1016 addIncidence(ev);
1024 } 1017 }
1025 if ( !mListView->currentItem() ){ 1018 if ( !mListView->currentItem() ){
1026 updateView(); 1019 updateView();
1027 } 1020 }
1028} 1021}
1029 1022
1030void KOListView::showCompletedTodos() 1023void KOListView::showCompletedTodos()
1031{ 1024{
1032 mForceShowCompletedTodos = true; 1025 mForceShowCompletedTodos = true;
1033} 1026}
1034void KOListView::addIncidence(Incidence *incidence) 1027void KOListView::addIncidence(Incidence *incidence)
1035{ 1028{
1036 if ( mUidDict.find( incidence->uid() ) ) return; 1029 if ( mUidDict.find( incidence->uid() ) ) return;
1037 1030
1038 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1031 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
1039 if ( incidence->typeID() == todoID ) { 1032 if ( incidence->typeID() == todoID ) {
1040 if ( ! mForceShowCompletedTodos ) { 1033 if ( ! mForceShowCompletedTodos ) {
1041 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) 1034 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() )
1042 return; 1035 return;
1043 } 1036 }
1044 } 1037 }
1045 mUidDict.insert( incidence->uid(), incidence ); 1038 mUidDict.insert( incidence->uid(), incidence );
1046 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1039 KOListViewItem *item = new KOListViewItem( incidence, mListView );
1047 ListItemVisitor v(item, mStartDate ); 1040 ListItemVisitor v(item, mStartDate );
1048 if (incidence->accept(v)) { 1041 if (incidence->accept(v)) {
1049 return; 1042 return;
1050 } 1043 }
1051 else delete item; 1044 else delete item;
1052} 1045}
1053 1046
1054void KOListView::showEvents(QPtrList<Event> eventList) 1047void KOListView::showEvents(QPtrList<Event> eventList)
1055{ 1048{
1056 clear(); 1049 clear();
1057 1050
1058 addEvents(eventList); 1051 addEvents(eventList);
1059 1052
1060 // After new creation of list view no events are selected. 1053 // After new creation of list view no events are selected.
1061 emit incidenceSelected( 0 ); 1054 emit incidenceSelected( 0 );
1062} 1055}
1063int KOListView::count() 1056int KOListView::count()
1064{ 1057{
1065 return mListView->childCount(); 1058 return mListView->childCount();
1066} 1059}
1067 1060
1068void KOListView::changeEventDisplay(Event *event, int action) 1061void KOListView::changeEventDisplay(Event *event, int action)
1069{ 1062{
1070 KOListViewItem *item; 1063 KOListViewItem *item;
1071 1064
1072 switch(action) { 1065 switch(action) {
1073 case KOGlobals::EVENTADDED: 1066 case KOGlobals::EVENTADDED:
1074 addIncidence( event ); 1067 addIncidence( event );
1075 break; 1068 break;
1076 case KOGlobals::EVENTEDITED: 1069 case KOGlobals::EVENTEDITED:
1077 item = getItemForEvent(event); 1070 item = getItemForEvent(event);
1078 if (item) { 1071 if (item) {
1079 ListItemVisitor v(item, mStartDate ); 1072 ListItemVisitor v(item, mStartDate );
1080 ((Incidence*)event)->accept(v); 1073 ((Incidence*)event)->accept(v);
1081 } 1074 }
1082 break; 1075 break;
1083 case KOGlobals::EVENTDELETED: 1076 case KOGlobals::EVENTDELETED:
1084 item = getItemForEvent(event); 1077 item = getItemForEvent(event);
1085 if (item) { 1078 if (item) {
1086 mUidDict.remove( event->uid() ); 1079 mUidDict.remove( event->uid() );
1087 delete item; 1080 delete item;
1088 } 1081 }
1089 break; 1082 break;
1090 default: 1083 default:
1091 ; 1084 ;
1092 } 1085 }
1093} 1086}
1094 1087
1095KOListViewItem *KOListView::getItemForEvent(Incidence *event) 1088KOListViewItem *KOListView::getItemForEvent(Incidence *event)
1096{ 1089{
1097 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1090 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1098 while (item) { 1091 while (item) {
1099 if (item->data() == event) return item; 1092 if (item->data() == event) return item;
1100 item = (KOListViewItem *)item->nextSibling(); 1093 item = (KOListViewItem *)item->nextSibling();
1101 } 1094 }
1102 return 0; 1095 return 0;
1103} 1096}
1104 1097
1105void KOListView::defaultItemAction(QListViewItem *i) 1098void KOListView::defaultItemAction(QListViewItem *i)
1106{ 1099{
1107 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1100 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1108 if ( item ) defaultAction( item->data() ); 1101 if ( item ) defaultAction( item->data() );
1109 1102
1110} 1103}
1111 1104
1112void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1105void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1113{ 1106{
1114 mActiveItem = (KOListViewItem *)item; 1107 mActiveItem = (KOListViewItem *)item;
1115 if (mActiveItem) { 1108 if (mActiveItem) {
1116 Incidence *incidence = mActiveItem->data(); 1109 Incidence *incidence = mActiveItem->data();
1117 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1110 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1118 mPopupMenu->showIncidencePopup(incidence); 1111 mPopupMenu->showIncidencePopup(incidence);
1119 1112
1120 /* 1113 /*
1121 if ( incidence && incidence->type() == "Event" ) { 1114 if ( incidence && incidence->type() == "Event" ) {
1122 Event *event = static_cast<Event *>( incidence ); 1115 Event *event = static_cast<Event *>( incidence );
1123 mPopupMenu->showEventPopup(event); 1116 mPopupMenu->showEventPopup(event);
1124 } 1117 }
1125 */ 1118 */
1126 } 1119 }
1127} 1120}
1128 1121
1129void KOListView::readSettings(KConfig *config, QString setting) 1122void KOListView::readSettings(KConfig *config, QString setting)
1130{ 1123{
1131 // qDebug("KOListView::readSettings "); 1124 // qDebug("KOListView::readSettings ");
1132 mListView->restoreLayout(config,setting); 1125 mListView->restoreLayout(config,setting);
1133} 1126}
1134 1127
1135void KOListView::writeSettings(KConfig *config, QString setting) 1128void KOListView::writeSettings(KConfig *config, QString setting)
1136{ 1129{
1137 // qDebug("KOListView::writeSettings "); 1130 // qDebug("KOListView::writeSettings ");
1138 mListView->saveLayout(config, setting); 1131 mListView->saveLayout(config, setting);
1139} 1132}
1140 1133
1141void KOListView::processSelectionChange(QListViewItem *) 1134void KOListView::processSelectionChange(QListViewItem *)
1142{ 1135{
1143 1136
1144 KOListViewItem *item = 1137 KOListViewItem *item =
1145 static_cast<KOListViewItem *>( mListView->currentItem() ); 1138 static_cast<KOListViewItem *>( mListView->currentItem() );
1146 1139
1147 if ( !item ) { 1140 if ( !item ) {
1148 emit incidenceSelected( 0 ); 1141 emit incidenceSelected( 0 );
1149 } else { 1142 } else {
1150 emit incidenceSelected( item->data() ); 1143 emit incidenceSelected( item->data() );
1151 } 1144 }
1152} 1145}
1153 1146
1154void KOListView::clearSelection() 1147void KOListView::clearSelection()
1155{ 1148{
1156 mListView->selectAll( false ); 1149 mListView->selectAll( false );
1157} 1150}
1158void KOListView::allSelection() 1151void KOListView::allSelection()
1159{ 1152{
1160 mListView->selectAll( true ); 1153 mListView->selectAll( true );
1161} 1154}
1162 1155
1163void KOListView::clear() 1156void KOListView::clear()
1164{ 1157{
1165 mListView->clear(); 1158 mListView->clear();
1166 mUidDict.clear(); 1159 mUidDict.clear();
1167} 1160}
1168 1161
1169Incidence* KOListView::currentItem() 1162Incidence* KOListView::currentItem()
1170{ 1163{
1171 if ( mListView->currentItem() ) 1164 if ( mListView->currentItem() )
1172 return ((KOListViewItem*) mListView->currentItem())->data(); 1165 return ((KOListViewItem*) mListView->currentItem())->data();
1173 return 0; 1166 return 0;
1174} 1167}
1175void KOListView::keyPressEvent ( QKeyEvent *e) 1168void KOListView::keyPressEvent ( QKeyEvent *e)
1176{ 1169{
1177 1170
1178 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1171 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1179 deleteAll(); 1172 deleteAll();
1180 return; 1173 return;
1181 } 1174 }
1182 1175
1183 e->ignore(); 1176 e->ignore();
1184} 1177}
1185void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1178void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1186{ 1179{
1187 1180
1188 switch ( e->key() ) { 1181 switch ( e->key() ) {
1189 case Qt::Key_Down: 1182 case Qt::Key_Down:
1190 if ( e->state() == ShiftButton ) { 1183 if ( e->state() == ShiftButton ) {
1191 QListViewItem* cn = currentItem(); 1184 QListViewItem* cn = currentItem();
1192 if ( !cn ) 1185 if ( !cn )
1193 cn = firstChild(); 1186 cn = firstChild();
1194 if ( !cn ) 1187 if ( !cn )
1195 return; 1188 return;
1196 while ( cn->nextSibling() ) 1189 while ( cn->nextSibling() )
1197 cn = cn->nextSibling(); 1190 cn = cn->nextSibling();
1198 setCurrentItem ( cn ); 1191 setCurrentItem ( cn );
1199 ensureItemVisible ( cn ); 1192 ensureItemVisible ( cn );
1200 1193
1201 e->accept(); 1194 e->accept();
1202 return; 1195 return;
1203 } 1196 }
1204 if ( e->state() == ControlButton ) { 1197 if ( e->state() == ControlButton ) {
1205 int count = childCount (); 1198 int count = childCount ();
1206 int jump = count / 5; 1199 int jump = count / 5;
1207 QListViewItem* cn; 1200 QListViewItem* cn;
1208 cn = currentItem(); 1201 cn = currentItem();
1209 if ( ! cn ) 1202 if ( ! cn )
1210 return; 1203 return;
1211 if ( jump == 0 ) 1204 if ( jump == 0 )
1212 jump = 1; 1205 jump = 1;
1213 while ( jump && cn->nextSibling() ) { 1206 while ( jump && cn->nextSibling() ) {
1214 cn = cn->nextSibling(); 1207 cn = cn->nextSibling();
1215 --jump; 1208 --jump;
1216 } 1209 }
1217 setCurrentItem ( cn ); 1210 setCurrentItem ( cn );
1218 ensureItemVisible ( cn ); 1211 ensureItemVisible ( cn );
1219 1212
1220 } else 1213 } else
1221 QListView::keyPressEvent ( e ) ; 1214 QListView::keyPressEvent ( e ) ;
1222 e->accept(); 1215 e->accept();
1223 break; 1216 break;
1224 1217
1225 case Qt::Key_Up: 1218 case Qt::Key_Up:
1226 if ( e->state() == ShiftButton ) { 1219 if ( e->state() == ShiftButton ) {
1227 QListViewItem* cn = firstChild(); 1220 QListViewItem* cn = firstChild();
1228 if ( cn ) { 1221 if ( cn ) {
1229 setCurrentItem ( cn ); 1222 setCurrentItem ( cn );
1230 ensureItemVisible ( cn ); 1223 ensureItemVisible ( cn );
1231 } 1224 }
1232 e->accept(); 1225 e->accept();
1233 return; 1226 return;
1234 } 1227 }
1235 if ( e->state() == ControlButton ) { 1228 if ( e->state() == ControlButton ) {
1236 int count = childCount (); 1229 int count = childCount ();
1237 int jump = count / 5; 1230 int jump = count / 5;
1238 QListViewItem* cn; 1231 QListViewItem* cn;
1239 cn = currentItem(); 1232 cn = currentItem();
1240 if ( ! cn ) 1233 if ( ! cn )
1241 return; 1234 return;
1242 if ( jump == 0 ) 1235 if ( jump == 0 )
1243 jump = 1; 1236 jump = 1;
1244 while ( jump && cn->itemAbove ()) { 1237 while ( jump && cn->itemAbove ()) {
1245 cn = cn->itemAbove (); 1238 cn = cn->itemAbove ();
1246 --jump; 1239 --jump;
1247 } 1240 }
1248 setCurrentItem ( cn ); 1241 setCurrentItem ( cn );
1249 ensureItemVisible ( cn ); 1242 ensureItemVisible ( cn );
1250 } else 1243 } else
1251 QListView::keyPressEvent ( e ) ; 1244 QListView::keyPressEvent ( e ) ;
1252 e->accept(); 1245 e->accept();
1253 break; 1246 break;
1254 case Qt::Key_I: { 1247 case Qt::Key_I: {
1255 QListViewItem* cn; 1248 QListViewItem* cn;
1256 cn = currentItem(); 1249 cn = currentItem();
1257 if ( cn ) { 1250 if ( cn ) {
1258 KOListViewItem* ci = (KOListViewItem*)( cn ); 1251 KOListViewItem* ci = (KOListViewItem*)( cn );
1259 if ( ci ){ 1252 if ( ci ){
1260 //emit showIncidence( ci->data()); 1253 //emit showIncidence( ci->data());
1261 cn = cn->nextSibling(); 1254 cn = cn->nextSibling();
1262 if ( cn ) { 1255 if ( cn ) {
1263 setCurrentItem ( cn ); 1256 setCurrentItem ( cn );
1264 ensureItemVisible ( cn ); 1257 ensureItemVisible ( cn );
1265 } 1258 }
1266 emit showIncidence( ci->data()); 1259 emit showIncidence( ci->data());
1267 } 1260 }
1268 } 1261 }
1269 e->accept(); 1262 e->accept();
1270 } 1263 }
1271 break; 1264 break;
1272 case Qt::Key_Return: 1265 case Qt::Key_Return:
1273 case Qt::Key_Enter: 1266 case Qt::Key_Enter:
1274 { 1267 {
1275 QListViewItem* cn; 1268 QListViewItem* cn;
1276 cn = currentItem(); 1269 cn = currentItem();
1277 if ( cn ) { 1270 if ( cn ) {
1278 KOListViewItem* ci = (KOListViewItem*)( cn ); 1271 KOListViewItem* ci = (KOListViewItem*)( cn );
1279 if ( ci ){ 1272 if ( ci ){
1280 if ( e->state() == ShiftButton ) 1273 if ( e->state() == ShiftButton )
1281 ci->setSelected( false ); 1274 ci->setSelected( false );
1282 else 1275 else
1283 ci->setSelected( true ); 1276 ci->setSelected( true );
1284 cn = cn->nextSibling(); 1277 cn = cn->nextSibling();
1285 if ( cn ) { 1278 if ( cn ) {
1286 setCurrentItem ( cn ); 1279 setCurrentItem ( cn );
1287 ensureItemVisible ( cn ); 1280 ensureItemVisible ( cn );
1288 } else { 1281 } else {
1289 emit currentChanged( ci ); 1282 emit currentChanged( ci );
1290 } 1283 }
1291 } 1284 }
1292 } 1285 }
1293 e->accept(); 1286 e->accept();
1294 } 1287 }
1295 break; 1288 break;
1296 default: 1289 default:
1297 e->ignore(); 1290 e->ignore();
1298 } 1291 }
1299} 1292}
1300KOListViewListView::KOListViewListView(KOListView * lv ) 1293KOListViewListView::KOListViewListView(KOListView * lv )
1301 : KListView( lv, "kolistlistview", false ) 1294 : KListView( lv, "kolistlistview", false )
1302{ 1295{
1303 mYMousePos = 0; 1296 mYMousePos = 0;
1304 mPopupTimer = new QTimer(this); 1297 mPopupTimer = new QTimer(this);
1305 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1298 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1306#ifndef DESKTOP_VERSION 1299#ifndef DESKTOP_VERSION
1307 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1300 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1308#endif 1301#endif
1309 setSelectionMode( QListView::Multi ); 1302 setSelectionMode( QListView::Multi );
1310 setMultiSelection( true); 1303 setMultiSelection( true);
1311} 1304}
1312bool KOListViewListView::hasMultiSelection(QListViewItem* item) 1305bool KOListViewListView::hasMultiSelection(QListViewItem* item)
1313{ 1306{
1314 QListViewItem *qitem = firstChild (); 1307 QListViewItem *qitem = firstChild ();
1315 while ( qitem ) { 1308 while ( qitem ) {
1316 if ( qitem->isSelected() && item != qitem ) 1309 if ( qitem->isSelected() && item != qitem )
1317 return true; 1310 return true;
1318 qitem = qitem->nextSibling(); 1311 qitem = qitem->nextSibling();
1319 } 1312 }
1320 return false; 1313 return false;
1321} 1314}
1322void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1315void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1323{ 1316{
1324 if (!e) return; 1317 if (!e) return;
1325 QPoint vp = contentsToViewport(e->pos()); 1318 QPoint vp = contentsToViewport(e->pos());
1326 QListViewItem *item = itemAt(vp); 1319 QListViewItem *item = itemAt(vp);
1327 if (!item) { 1320 if (!item) {
1328 emit newEvent(); 1321 emit newEvent();
1329 return; 1322 return;
1330 } 1323 }
1331 KListView::contentsMouseDoubleClickEvent(e); 1324 KListView::contentsMouseDoubleClickEvent(e);
1332} 1325}
1333#if 0 1326#if 0
1334void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1327void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1335{ 1328{
1336 //qDebug("contentsMousePressEvent++++ "); 1329 //qDebug("contentsMousePressEvent++++ ");
1337 KListView::contentsMousePressEvent( e ); 1330 KListView::contentsMousePressEvent( e );
1338 if ( e->button() == RightButton ) { 1331 if ( e->button() == RightButton ) {
1339 QListViewItem* ci = currentItem(); 1332 QListViewItem* ci = currentItem();
1340 clearSelection () ; 1333 clearSelection () ;
1341 if ( ci ) 1334 if ( ci )
1342 ci->setSelected( true ); 1335 ci->setSelected( true );
1343 } 1336 }
1344} 1337}
1345void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1338void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1346{ 1339{
1347 KListView::contentsMouseReleaseEvent(e); 1340 KListView::contentsMouseReleaseEvent(e);
1348} 1341}
1349void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1342void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1350{ 1343{
1351 KListView::contentsMouseMoveEvent(e); 1344 KListView::contentsMouseMoveEvent(e);
1352} 1345}
1353#endif 1346#endif
1354void KOListViewListView::popupMenu() 1347void KOListViewListView::popupMenu()
1355{ 1348{
1356 mPopupTimer->stop(); 1349 mPopupTimer->stop();
1357 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1350 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1358 QApplication::postEvent( this->viewport(), e ); 1351 QApplication::postEvent( this->viewport(), e );
1359 1352
1360} 1353}
1361void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1354void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1362{ 1355{
1363 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1356 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1364 mYMousePos = mapToGlobal( (e->pos())).y(); 1357 mYMousePos = mapToGlobal( (e->pos())).y();
1365 if ( e->button() == LeftButton ) { 1358 if ( e->button() == LeftButton ) {
1366 mPopupTimer->start( 600 ); 1359 mPopupTimer->start( 600 );
1367 mEventPos = contentsToViewport(e->pos()); 1360 mEventPos = contentsToViewport(e->pos());
1368 mEventGlobalPos = e->globalPos(); 1361 mEventGlobalPos = e->globalPos();
1369 } 1362 }
1370 KListView::contentsMousePressEvent( e ); 1363 KListView::contentsMousePressEvent( e );
1371 if ( e->button() == RightButton ) { 1364 if ( e->button() == RightButton ) {
1372 QListViewItem* ci = currentItem(); 1365 QListViewItem* ci = currentItem();
1373 //clearSelection(); 1366 //clearSelection();
1374 if ( ci ) 1367 if ( ci )
1375 ci->setSelected( true ); 1368 ci->setSelected( true );
1376 } 1369 }
1377} 1370}
1378void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1371void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1379{ 1372{
1380 mPopupTimer->stop(); 1373 mPopupTimer->stop();
1381 KListView::contentsMouseReleaseEvent(e); 1374 KListView::contentsMouseReleaseEvent(e);
1382} 1375}
1383void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1376void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1384{ 1377{
1385 // qDebug("contentsMouseMoveEv....... "); 1378 // qDebug("contentsMouseMoveEv....... ");
1386 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1379 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1387 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1380 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1388 if ( diff < 0 ) diff = -diff; 1381 if ( diff < 0 ) diff = -diff;
1389 if ( diff > 15 ) 1382 if ( diff > 15 )
1390 mPopupTimer->stop(); 1383 mPopupTimer->stop();
1391 else { 1384 else {
1392 mEventPos = contentsToViewport(e->pos()); 1385 mEventPos = contentsToViewport(e->pos());
1393 mEventGlobalPos = e->globalPos(); 1386 mEventGlobalPos = e->globalPos();
1394 } 1387 }
1395 KListView::contentsMouseMoveEvent(e); 1388 KListView::contentsMouseMoveEvent(e);
1396} 1389}
1397 1390
1398#define protected public 1391#define protected public
1399#include <qheader.h> 1392#include <qheader.h>
1400#undef protected 1393#undef protected
1401void KOListViewListView::printList() 1394void KOListViewListView::printList()
1402{ 1395{
1403#ifdef DESKTOP_VERSION 1396#ifdef DESKTOP_VERSION
1404 KOPrintPrefs pp ( this ); 1397 KOPrintPrefs pp ( this );
1405 if (!pp.exec() ) 1398 if (!pp.exec() )
1406 return; 1399 return;
1407 int scaleval = pp.printMode() ; 1400 int scaleval = pp.printMode() ;
1408 1401
1409 QPrinter printer; 1402 QPrinter printer;
1410 if (!printer.setup() ) 1403 if (!printer.setup() )
1411 return; 1404 return;
1412 clearSelection (); 1405 clearSelection ();
1413 QPainter p; 1406 QPainter p;
1414 p.begin ( &printer ); 1407 p.begin ( &printer );
1415 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 1408 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
1416 float dx, dy; 1409 float dx, dy;
1417 int wid = (m.width() * 9)/10; 1410 int wid = (m.width() * 9)/10;
1418 dx = (float) wid/(float)contentsWidth (); 1411 dx = (float) wid/(float)contentsWidth ();
1419 dy = (float)(m.height()) / (float)contentsHeight (); 1412 dy = (float)(m.height()) / (float)contentsHeight ();
1420 float scale; 1413 float scale;
1421 // scale to fit the width or height of the paper 1414 // scale to fit the width or height of the paper
1422 if ( dx < dy ) 1415 if ( dx < dy )
1423 scale = dx; 1416 scale = dx;
1424 else 1417 else
1425 scale = dy; 1418 scale = dy;
1426 1419
1427 p.translate( m.width()/10,m.width()/10 ); 1420 p.translate( m.width()/10,m.width()/10 );
1428 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 1421 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
1429 p.scale( scale, scale ); 1422 p.scale( scale, scale );
1430 } 1423 }
1431 1424
1432 int cou = header()->count(); 1425 int cou = header()->count();
1433 int iii; 1426 int iii;
1434 QRect rect ( 0,0,0, header()->height()); 1427 QRect rect ( 0,0,0, header()->height());
1435 for ( iii = 0; iii < cou; ++iii ) { 1428 for ( iii = 0; iii < cou; ++iii ) {
1436 rect.setLeft ( header()->sectionPos( iii ) ); 1429 rect.setLeft ( header()->sectionPos( iii ) );
1437 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); 1430 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii));
1438 header()->paintSection ( & p, header()->mapToIndex (iii), rect ); 1431 header()->paintSection ( & p, header()->mapToIndex (iii), rect );
1439 } 1432 }
1440 p.translate( 0, header()->height()); 1433 p.translate( 0, header()->height());
1441 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); 1434 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () );
1442 p.end(); 1435 p.end();
1443#endif 1436#endif
1444} 1437}
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index bdef94c..848e9e7 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -1,576 +1,570 @@
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 19
20#include <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qapp.h> 22#include <qapp.h>
23#include <kglobal.h> 23#include <kglobal.h>
24 24
25#include <kiconloader.h> 25#include <kiconloader.h>
26#include "kotodoviewitem.h" 26#include "kotodoviewitem.h"
27#include "kotodoview.h" 27#include "kotodoview.h"
28#include "koprefs.h" 28#include "koprefs.h"
29 29
30KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) 30KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
31 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 31 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
32{ 32{
33 construct(); 33 construct();
34} 34}
35 35
36KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) 36KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
37 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 37 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
38{ 38{
39 construct(); 39 construct();
40} 40}
41 41
42QString KOTodoViewItem::key(int column,bool) const 42QString KOTodoViewItem::key(int column,bool) const
43{ 43{
44 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 44 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
45 if (it == mKeyMap.end()) { 45 if (it == mKeyMap.end()) {
46 return text(column).lower(); 46 return text(column).lower();
47 } else { 47 } else {
48 return *it; 48 return *it;
49 } 49 }
50} 50}
51 51
52void KOTodoViewItem:: setup() 52void KOTodoViewItem:: setup()
53{ 53{
54 54
55 int h = 20; 55 int h = 20;
56 if ( listView () ) { 56 if ( listView () ) {
57 QFontMetrics fm ( listView ()->font () ); 57 QFontMetrics fm ( listView ()->font () );
58 h = fm.height(); 58 h = fm.height();
59 } 59 }
60 setHeight( h ); 60 setHeight( h );
61 61
62} 62}
63void KOTodoViewItem::setSortKey(int column,const QString &key) 63void KOTodoViewItem::setSortKey(int column,const QString &key)
64{ 64{
65 mKeyMap.insert(column,key); 65 mKeyMap.insert(column,key);
66} 66}
67 67
68#if QT_VERSION >= 0x030000 68#if QT_VERSION >= 0x030000
69void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, 69void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
70 int y,int h) 70 int y,int h)
71{ 71{
72 QListViewItem::paintBranches(p,cg,w,y,h); 72 QListViewItem::paintBranches(p,cg,w,y,h);
73} 73}
74#else 74#else
75#endif 75#endif
76 76
77void KOTodoViewItem::construct() 77void KOTodoViewItem::construct()
78{ 78{
79 // qDebug("KOTodoViewItem::construct() "); 79 // qDebug("KOTodoViewItem::construct() ");
80 m_init = true; 80 m_init = true;
81 QString keyd = "=="; 81 QString keyd = "==";
82 QString keyt = "=="; 82 QString keyt = "==";
83 QString skeyd = "=="; 83 QString skeyd = "==";
84 QString skeyt = "=="; 84 QString skeyt = "==";
85 85
86 setOn(mTodo->isCompleted()); 86 setOn(mTodo->isCompleted());
87 setText(0,mTodo->summary()); 87 setText(0,mTodo->summary());
88 setText(1,QString::number(mTodo->priority())); 88 setText(1,QString::number(mTodo->priority()));
89 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 89 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
90 if (mTodo->percentComplete()<100) { 90 if (mTodo->percentComplete()<100) {
91 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 91 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
92 else setSortKey(2,QString::number(mTodo->percentComplete())); 92 else setSortKey(2,QString::number(mTodo->percentComplete()));
93 } 93 }
94 else { 94 else {
95 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 95 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
96 else setSortKey(2,QString::number(99)); 96 else setSortKey(2,QString::number(99));
97 } 97 }
98 if (mTodo->hasDueDate()) { 98 if (mTodo->hasDueDate()) {
99 setText(3, mTodo->dtDueDateStr()); 99 setText(3, mTodo->dtDueDateStr());
100 QDate d = mTodo->dtDue().date(); 100 QDate d = mTodo->dtDue().date();
101 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 101 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
102 // setSortKey(3,keyd); 102 // setSortKey(3,keyd);
103 if (mTodo->doesFloat()) { 103 if (mTodo->doesFloat()) {
104 setText(4,""); 104 setText(4,"");
105 } 105 }
106 else { 106 else {
107 setText(4,mTodo->dtDueTimeStr()); 107 setText(4,mTodo->dtDueTimeStr());
108 QTime t = mTodo->dtDue().time(); 108 QTime t = mTodo->dtDue().time();
109 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 109 keyt.sprintf("%02d%02d",t.hour(),t.minute());
110 //setSortKey(4,keyt); 110 //setSortKey(4,keyt);
111 } 111 }
112 } else { 112 } else {
113 setText(3,""); 113 setText(3,"");
114 setText(4,""); 114 setText(4,"");
115 } 115 }
116 setSortKey(3,keyd); 116 setSortKey(3,keyd);
117 setSortKey(4,keyt); 117 setSortKey(4,keyt);
118 118
119 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 119 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
120 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 120 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
121 121
122
123
124 keyd = ""; 122 keyd = "";
125 keyt = ""; 123 keyt = "";
126 124
127 if (mTodo->isRunning() ) { 125 if (mTodo->isRunning() ) {
128 QDate d = mTodo->runStart().date(); 126 QDate d = mTodo->runStart().date();
129 QTime t = mTodo->runStart().time(); 127 QTime t = mTodo->runStart().time();
130 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 128 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
131 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 129 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
132 keyd = KGlobal::locale()->formatDate( d , true); 130 keyd = KGlobal::locale()->formatDate( d , true);
133 keyt = KGlobal::locale()->formatTime( t ); 131 keyt = KGlobal::locale()->formatTime( t );
134 132
135 } else { 133 } else {
136 134
137 if (mTodo->hasStartDate()) { 135 if (mTodo->hasStartDate()) {
138 keyd = mTodo->dtStartDateStr(); 136 keyd = mTodo->dtStartDateStr();
139 QDate d = mTodo->dtStart().date(); 137 QDate d = mTodo->dtStart().date();
140 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 138 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
141 139
142 if ( !mTodo->doesFloat()) { 140 if ( !mTodo->doesFloat()) {
143 keyt = mTodo->dtStartTimeStr(); 141 keyt = mTodo->dtStartTimeStr();
144 QTime t = mTodo->dtStart().time(); 142 QTime t = mTodo->dtStart().time();
145 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 143 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
146 144
147 } 145 }
148 146
149 } 147 }
150 } 148 }
151 setText(5,keyd); 149 setText(5,keyd);
152 setText(6,keyt); 150 setText(6,keyt);
153 setSortKey(5,skeyd); 151 setSortKey(5,skeyd);
154 setSortKey(6,skeyt); 152 setSortKey(6,skeyt);
155 153
156 //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 154 //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
157 setText(7,mTodo->categoriesStr()); 155 setText(7,mTodo->categoriesStr());
158 setText(8,KOPrefs::instance()->calName( mTodo->calID())); 156 setText(8,KOPrefs::instance()->calName( mTodo->calID()));
159 setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true )); 157 setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true ));
160 setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true )); 158 setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true ));
161 setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true )); 159 setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true ));
162 QString key; 160 QString key;
163 QDate d = mTodo->lastModified().date(); 161 QDate d;
164 QTime t = mTodo->lastModified().time(); 162 QTime t;
165 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); 163 setSortKey(9,mTodo->lastModifiedSortKey());
166 setSortKey(9,key);
167 d = mTodo->created().date(); 164 d = mTodo->created().date();
168 t = mTodo->created().time(); 165 t = mTodo->created().time();
169 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); 166 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() );
170 setSortKey(10,key); 167 setSortKey(10,key);
171 d = mTodo->lastModifiedSub().date(); 168 setSortKey(11,mTodo->lastModifiedSubSortKey());
172 t = mTodo->lastModifiedSub().time();
173 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() );
174 setSortKey(11,key);
175 169
176#if 0 170#if 0
177 // Find sort id in description. It's the text behind the last '#' character 171 // Find sort id in description. It's the text behind the last '#' character
178 // found in the description. White spaces are removed from beginning and end 172 // found in the description. White spaces are removed from beginning and end
179 // of sort id. 173 // of sort id.
180 int pos = mTodo->description().findRev('#'); 174 int pos = mTodo->description().findRev('#');
181 if (pos < 0) { 175 if (pos < 0) {
182 setText(6,""); 176 setText(6,"");
183 } else { 177 } else {
184 QString str = mTodo->description().mid(pos+1); 178 QString str = mTodo->description().mid(pos+1);
185 str.stripWhiteSpace(); 179 str.stripWhiteSpace();
186 setText(6,str); 180 setText(6,str);
187 } 181 }
188#endif 182#endif
189 183
190 m_known = false; 184 m_known = false;
191 m_init = false; 185 m_init = false;
192 186
193 setMyPixmap(); 187 setMyPixmap();
194 188
195} 189}
196void KOTodoViewItem::setMyPixmap() 190void KOTodoViewItem::setMyPixmap()
197{ 191{
198 int size = 5; 192 int size = 5;
199 QPixmap pixi = QPixmap( 1, 1 ); 193 QPixmap pixi = QPixmap( 1, 1 );
200 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 194 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
201// pixi = SmallIcon("redcross16"); 195// pixi = SmallIcon("redcross16");
202// } else { 196// } else {
203 QPainter p; 197 QPainter p;
204 198
205 int pixSize = 0; 199 int pixSize = 0;
206 QPixmap pPix = QPixmap( size, size ); 200 QPixmap pPix = QPixmap( size, size );
207 if ( mTodo->description().length() > 0 ) { 201 if ( mTodo->description().length() > 0 ) {
208 pixi.resize(size, pixSize+size); 202 pixi.resize(size, pixSize+size);
209 pPix.fill( Qt::darkGreen ); 203 pPix.fill( Qt::darkGreen );
210 p.begin( &pixi ); 204 p.begin( &pixi );
211 p. drawPixmap ( 0, pixSize, pPix); 205 p. drawPixmap ( 0, pixSize, pPix);
212 p.end(); 206 p.end();
213 pixSize += size; 207 pixSize += size;
214 } 208 }
215 if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { 209 if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) {
216 pixi.resize(size, pixSize+size); 210 pixi.resize(size, pixSize+size);
217 pPix.fill( Qt::red ); 211 pPix.fill( Qt::red );
218 p.begin( &pixi ); 212 p.begin( &pixi );
219 p. drawPixmap ( 0, pixSize, pPix); 213 p. drawPixmap ( 0, pixSize, pPix);
220 p.end(); 214 p.end();
221 pixSize += size; 215 pixSize += size;
222 } 216 }
223 if ( mTodo->doesRecur() ) { 217 if ( mTodo->doesRecur() ) {
224 pixi.resize(size, pixSize+size); 218 pixi.resize(size, pixSize+size);
225 pPix.fill( Qt::blue ); 219 pPix.fill( Qt::blue );
226 p.begin( &pixi ); 220 p.begin( &pixi );
227 p. drawPixmap ( 0, pixSize, pPix); 221 p. drawPixmap ( 0, pixSize, pPix);
228 p.end(); 222 p.end();
229 pixSize += size; 223 pixSize += size;
230 } 224 }
231 // } 225 // }
232 if ( pixi.width() > 1 ) { 226 if ( pixi.width() > 1 ) {
233 setPixmap ( 0,pixi ) ; 227 setPixmap ( 0,pixi ) ;
234 } else { 228 } else {
235 setPixmap ( 0,QPixmap() ) ; 229 setPixmap ( 0,QPixmap() ) ;
236 } 230 }
237} 231}
238void KOTodoViewItem::stateChange(bool state) 232void KOTodoViewItem::stateChange(bool state)
239{ 233{
240 // qDebug("KOTodoViewItem::stateChange %d ", state); 234 // qDebug("KOTodoViewItem::stateChange %d ", state);
241 // do not change setting on startup 235 // do not change setting on startup
242 if ( m_init ) return; 236 if ( m_init ) return;
243 if (isOn()!=state) { 237 if (isOn()!=state) {
244 setOn(state); 238 setOn(state);
245 //qDebug("SETON "); 239 //qDebug("SETON ");
246 return; 240 return;
247 } 241 }
248 if ( mTodo->isCompleted() == state ) { 242 if ( mTodo->isCompleted() == state ) {
249 //qDebug("STATECHANGE:nothing to do "); 243 //qDebug("STATECHANGE:nothing to do ");
250 return; 244 return;
251 } 245 }
252 QString keyd = "=="; 246 QString keyd = "==";
253 QString keyt = "=="; 247 QString keyt = "==";
254 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); 248 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
255 if ( mTodo->doesRecur() ){ 249 if ( mTodo->doesRecur() ){
256 QDateTime start = mTodo->dtStart(); 250 QDateTime start = mTodo->dtStart();
257 mTodo->setCompleted(state); 251 mTodo->setCompleted(state);
258 if ( start != mTodo->dtStart() ) { 252 if ( start != mTodo->dtStart() ) {
259 if ( state && !mTodo->isCompleted() ) { 253 if ( state && !mTodo->isCompleted() ) {
260 setOn( false ); 254 setOn( false );
261 state = false; 255 state = false;
262 } 256 }
263 } 257 }
264 } else 258 } else
265 mTodo->setCompleted(state); 259 mTodo->setCompleted(state);
266 260
267 if (state) mTodo->setCompleted(QDateTime::currentDateTime()); 261 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
268 262
269 if (mTodo->hasDueDate()) { 263 if (mTodo->hasDueDate()) {
270 setText(3, mTodo->dtDueDateStr()); 264 setText(3, mTodo->dtDueDateStr());
271 QDate d = mTodo->dtDue().date(); 265 QDate d = mTodo->dtDue().date();
272 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 266 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
273 setSortKey(3,keyd); 267 setSortKey(3,keyd);
274 if (mTodo->doesFloat()) { 268 if (mTodo->doesFloat()) {
275 setText(4,""); 269 setText(4,"");
276 } 270 }
277 else { 271 else {
278 setText(4,mTodo->dtDueTimeStr()); 272 setText(4,mTodo->dtDueTimeStr());
279 QTime t = mTodo->dtDue().time(); 273 QTime t = mTodo->dtDue().time();
280 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 274 keyt.sprintf("%02d%02d",t.hour(),t.minute());
281 setSortKey(4,keyt); 275 setSortKey(4,keyt);
282 } 276 }
283 } 277 }
284 if (mTodo->hasStartDate()) { 278 if (mTodo->hasStartDate()) {
285 QString skeyt = "=="; 279 QString skeyt = "==";
286 QString skeyd = "=="; 280 QString skeyd = "==";
287 setText(5, mTodo->dtStartDateStr()); 281 setText(5, mTodo->dtStartDateStr());
288 QDate d = mTodo->dtStart().date(); 282 QDate d = mTodo->dtStart().date();
289 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 283 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
290 284
291 if (mTodo->doesFloat()) { 285 if (mTodo->doesFloat()) {
292 setText(6,""); 286 setText(6,"");
293 } 287 }
294 else { 288 else {
295 setText(6,mTodo->dtStartTimeStr()); 289 setText(6,mTodo->dtStartTimeStr());
296 QTime t = mTodo->dtStart().time(); 290 QTime t = mTodo->dtStart().time();
297 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 291 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
298 292
299 } 293 }
300 setSortKey(5,skeyd); 294 setSortKey(5,skeyd);
301 setSortKey(6,skeyt); 295 setSortKey(6,skeyt);
302 } 296 }
303 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 297 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
304 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 298 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
305 299
306 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 300 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
307 if (mTodo->percentComplete()<100) { 301 if (mTodo->percentComplete()<100) {
308 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 302 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
309 else setSortKey(2,QString::number(mTodo->percentComplete())); 303 else setSortKey(2,QString::number(mTodo->percentComplete()));
310 } 304 }
311 else { 305 else {
312 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 306 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
313 else setSortKey(2,QString::number(99)); 307 else setSortKey(2,QString::number(99));
314 } 308 }
315 if ( state ) { 309 if ( state ) {
316 QListViewItem * myChild = firstChild(); 310 QListViewItem * myChild = firstChild();
317 KOTodoViewItem *item; 311 KOTodoViewItem *item;
318 while( myChild ) { 312 while( myChild ) {
319 //qDebug("stateCH "); 313 //qDebug("stateCH ");
320 item = static_cast<KOTodoViewItem*>(myChild); 314 item = static_cast<KOTodoViewItem*>(myChild);
321 item->stateChange(state); 315 item->stateChange(state);
322 myChild = myChild->nextSibling(); 316 myChild = myChild->nextSibling();
323 } 317 }
324 } else { 318 } else {
325 QListViewItem * myChild = parent(); 319 QListViewItem * myChild = parent();
326 if ( myChild ) 320 if ( myChild )
327 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); 321 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state);
328 } 322 }
329 mTodoView->modified(true); 323 mTodoView->modified(true);
330 setMyPixmap(); 324 setMyPixmap();
331 mTodoView->setTodoModified( mTodo ); 325 mTodoView->setTodoModified( mTodo );
332} 326}
333 327
334bool KOTodoViewItem::isAlternate() 328bool KOTodoViewItem::isAlternate()
335{ 329{
336#if 0 330#if 0
337 //if ( m_known ) return m_odd; 331 //if ( m_known ) return m_odd;
338 //qDebug("test "); 332 //qDebug("test ");
339 KOTodoViewItem *item = static_cast<KOTodoViewItem *>(itemAbove()); 333 KOTodoViewItem *item = static_cast<KOTodoViewItem *>(itemAbove());
340 if ( item ) { 334 if ( item ) {
341 m_known = item->m_known; 335 m_known = item->m_known;
342 if ( m_known ) { 336 if ( m_known ) {
343 m_odd = !item->m_odd ; 337 m_odd = !item->m_odd ;
344 return m_odd; 338 return m_odd;
345 } 339 }
346 } else { 340 } else {
347 item = static_cast<KOTodoViewItem *>(itemBelow()); 341 item = static_cast<KOTodoViewItem *>(itemBelow());
348 if ( item ) { 342 if ( item ) {
349 m_known = item->m_known; 343 m_known = item->m_known;
350 if ( m_known ) { 344 if ( m_known ) {
351 m_odd = !item->m_odd ; 345 m_odd = !item->m_odd ;
352 return m_odd; 346 return m_odd;
353 } 347 }
354 } 348 }
355 } 349 }
356 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 350 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
357 item = static_cast<KOTodoViewItem *>(lv->firstChild()); 351 item = static_cast<KOTodoViewItem *>(lv->firstChild());
358 bool previous = true; 352 bool previous = true;
359 qDebug("WHILE "); 353 qDebug("WHILE ");
360 while ( item ) { 354 while ( item ) {
361 item->m_odd = !previous; 355 item->m_odd = !previous;
362 item->m_known = true; 356 item->m_known = true;
363 previous = !previous; 357 previous = !previous;
364 item = static_cast<KOTodoViewItem *>(item->itemBelow()); 358 item = static_cast<KOTodoViewItem *>(item->itemBelow());
365 } 359 }
366 return m_odd; 360 return m_odd;
367 361
368#else 362#else
369 363
370 //KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 364 //KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
371 //if (lv && lv->alternateBackground().isValid()) 365 //if (lv && lv->alternateBackground().isValid())
372 { 366 {
373 KOTodoViewItem *above = static_cast<KOTodoViewItem *>(itemAbove()); 367 KOTodoViewItem *above = static_cast<KOTodoViewItem *>(itemAbove());
374 m_known = above ? above->m_known : true; 368 m_known = above ? above->m_known : true;
375 if (m_known) 369 if (m_known)
376 { 370 {
377 m_odd = above ? !above->m_odd : false; 371 m_odd = above ? !above->m_odd : false;
378 } 372 }
379 else 373 else
380 { 374 {
381 KOTodoViewItem *item; 375 KOTodoViewItem *item;
382 bool previous = true; 376 bool previous = true;
383 if (QListViewItem::parent()) 377 if (QListViewItem::parent())
384 { 378 {
385 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); 379 item = static_cast<KOTodoViewItem *>(QListViewItem::parent());
386 if (item) 380 if (item)
387 previous = item->m_odd; 381 previous = item->m_odd;
388 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 382 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
389 } 383 }
390 else 384 else
391 { 385 {
392 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 386 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
393 item = static_cast<KOTodoViewItem *>(lv->firstChild()); 387 item = static_cast<KOTodoViewItem *>(lv->firstChild());
394 } 388 }
395 389
396 while(item) 390 while(item)
397 { 391 {
398 item->m_odd = previous = !previous; 392 item->m_odd = previous = !previous;
399 item->m_known = true; 393 item->m_known = true;
400 item = static_cast<KOTodoViewItem *>(item->nextSibling()); 394 item = static_cast<KOTodoViewItem *>(item->nextSibling());
401 } 395 }
402 } 396 }
403 return m_odd; 397 return m_odd;
404 } 398 }
405 return false; 399 return false;
406#endif 400#endif
407} 401}
408 402
409void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 403void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
410{ 404{
411 QColorGroup _cg = cg; 405 QColorGroup _cg = cg;
412 QColorGroup::ColorRole role; 406 QColorGroup::ColorRole role;
413 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning()) 407 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning())
414 role = QColorGroup::Text; 408 role = QColorGroup::Text;
415 else 409 else
416 role = QColorGroup::Base; 410 role = QColorGroup::Base;
417 //#ifndef KORG_NOLVALTERNATION 411 //#ifndef KORG_NOLVALTERNATION
418 if (isAlternate()) 412 if (isAlternate())
419 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 413 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
420 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 414 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
421 QColor colorToSet; 415 QColor colorToSet;
422 if ( column == 0 && mTodo->calID() > 1 ) { 416 if ( column == 0 && mTodo->calID() > 1 ) {
423 setColor = true; 417 setColor = true;
424 colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); 418 colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() );
425 } else if ( setColor ) { 419 } else if ( setColor ) {
426 QStringList categories = mTodo->categories(); 420 QStringList categories = mTodo->categories();
427 QString cat = categories.first(); 421 QString cat = categories.first();
428 if ( !cat.isEmpty()) { 422 if ( !cat.isEmpty()) {
429 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 423 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
430 } else 424 } else
431 setColor = false; 425 setColor = false;
432 } 426 }
433 bool openMode = !isOpen(); 427 bool openMode = !isOpen();
434 // maybe we are in flat-display-mode 428 // maybe we are in flat-display-mode
435 if ( !firstChild() ) 429 if ( !firstChild() )
436 openMode = false; 430 openMode = false;
437 bool colorRunning = mTodo->isRunning(); 431 bool colorRunning = mTodo->isRunning();
438 if ( ! colorRunning && openMode ) 432 if ( ! colorRunning && openMode )
439 colorRunning = mTodo->hasRunningSub(); 433 colorRunning = mTodo->hasRunningSub();
440 if ( colorRunning ) { 434 if ( colorRunning ) {
441 setColor = true; 435 setColor = true;
442 colorToSet = KOPrefs::instance()->mTodoRunColor; 436 colorToSet = KOPrefs::instance()->mTodoRunColor;
443 } else { 437 } else {
444 int odue = mTodo->hasDueSubTodo( openMode ); 438 int odue = mTodo->hasDueSubTodo( openMode );
445 if (odue == 2) { 439 if (odue == 2) {
446 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 440 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
447 setColor = true; 441 setColor = true;
448 } else if ( odue == 1 ) { 442 } else if ( odue == 1 ) {
449 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 443 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
450 setColor = true; 444 setColor = true;
451 } 445 }
452 } 446 }
453 447
454 448
455 if ( setColor ) { 449 if ( setColor ) {
456 _cg.setColor(role,colorToSet ); 450 _cg.setColor(role,colorToSet );
457 if ( role == QColorGroup::Base) { 451 if ( role == QColorGroup::Base) {
458 int rgb = colorToSet.red(); 452 int rgb = colorToSet.red();
459 rgb += colorToSet.blue()/2; 453 rgb += colorToSet.blue()/2;
460 rgb += colorToSet.green(); 454 rgb += colorToSet.green();
461 if ( rgb < 200 ) 455 if ( rgb < 200 )
462 _cg.setColor(QColorGroup::Text,Qt::white ); 456 _cg.setColor(QColorGroup::Text,Qt::white );
463 } 457 }
464 } 458 }
465 //#endif 459 //#endif
466 if ( column > 0 ){ 460 if ( column > 0 ){
467 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { 461 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
468 p->save(); 462 p->save();
469 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); 463 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
470 464
471 p->fillRect( 0, 0, width, height(), _cg.base() ); // background 465 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
472 // p->setPen(Qt::black ); //border 466 // p->setPen(Qt::black ); //border
473 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling 467 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
474 QColor fc = KOPrefs::instance()->mHighlightColor; 468 QColor fc = KOPrefs::instance()->mHighlightColor;
475 if ( mTodo->percentComplete() == 100 ) 469 if ( mTodo->percentComplete() == 100 )
476 fc = darkGreen; 470 fc = darkGreen;
477 p->drawRect( 2, 2, width-4, height()-4); 471 p->drawRect( 2, 2, width-4, height()-4);
478 p->fillRect( 3, 3, progress, height()-6, 472 p->fillRect( 3, 3, progress, height()-6,
479 fc ); 473 fc );
480 p->restore(); 474 p->restore();
481 } else { 475 } else {
482 QCheckListItem::paintCell(p, _cg, column, width, alignment); 476 QCheckListItem::paintCell(p, _cg, column, width, alignment);
483 } 477 }
484 return; 478 return;
485 } 479 }
486 480
487 int align = alignment; 481 int align = alignment;
488 482
489 if ( !p ) 483 if ( !p )
490 return; 484 return;
491 485
492 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); 486 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
493 487
494 QListView *lv = listView(); 488 QListView *lv = listView();
495 if ( !lv ) 489 if ( !lv )
496 return; 490 return;
497 int marg = 2;//lv->itemMargin(); 491 int marg = 2;//lv->itemMargin();
498 int r = 0; 492 int r = 0;
499 QCheckListItem::Type myType = QCheckListItem::CheckBox; 493 QCheckListItem::Type myType = QCheckListItem::CheckBox;
500 int BoxSize = 20; 494 int BoxSize = 20;
501 int boxOffset = 2; 495 int boxOffset = 2;
502 int xOffset = 2; 496 int xOffset = 2;
503 if (qApp->desktop()->width() < 300 ) { 497 if (qApp->desktop()->width() < 300 ) {
504 BoxSize = 14; 498 BoxSize = 14;
505 boxOffset = -1; 499 boxOffset = -1;
506 xOffset = 1; 500 xOffset = 1;
507 // marg = 0; 501 // marg = 0;
508 } 502 }
509 if ( height() < BoxSize ) { 503 if ( height() < BoxSize ) {
510 boxOffset = boxOffset - ((BoxSize - height())/2) ; 504 boxOffset = boxOffset - ((BoxSize - height())/2) ;
511 // qDebug("boxOffset %d height %d", boxOffset, height() ); 505 // qDebug("boxOffset %d height %d", boxOffset, height() );
512 BoxSize = height(); 506 BoxSize = height();
513 507
514 } 508 }
515 //bool winStyle = lv->style() == WindowsStyle; 509 //bool winStyle = lv->style() == WindowsStyle;
516 510
517 int lineStart = 5; 511 int lineStart = 5;
518 if ( myType == Controller ) { 512 if ( myType == Controller ) {
519 if ( !pixmap( 0 ) ) 513 if ( !pixmap( 0 ) )
520 r += BoxSize + 4; 514 r += BoxSize + 4;
521 } else { 515 } else {
522 ASSERT( lv ); //### 516 ASSERT( lv ); //###
523 //QFontMetrics fm( lv->font() ); 517 //QFontMetrics fm( lv->font() );
524 //int d = fm.height(); 518 //int d = fm.height();
525 int x = 0; 519 int x = 0;
526 int y = (height() - BoxSize) / 2; 520 int y = (height() - BoxSize) / 2;
527 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); 521 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
528 if ( myType == CheckBox ) { 522 if ( myType == CheckBox ) {
529 if ( isEnabled() ) 523 if ( isEnabled() )
530 p->setPen( QPen( _cg.text(), 1 ) ); 524 p->setPen( QPen( _cg.text(), 1 ) );
531 else 525 else
532 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); 526 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
533 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); 527 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
534 lineStart = x+marg; 528 lineStart = x+marg;
535 ///////////////////// 529 /////////////////////
536 x++; 530 x++;
537 y++; 531 y++;
538 if ( isOn() ) { 532 if ( isOn() ) {
539 QPointArray a( 7*2 ); 533 QPointArray a( 7*2 );
540 int i, xx, yy; 534 int i, xx, yy;
541 xx = x+xOffset+marg+(boxOffset/2); 535 xx = x+xOffset+marg+(boxOffset/2);
542 yy = y+5+boxOffset; 536 yy = y+5+boxOffset;
543 for ( i=0; i<3; i++ ) { 537 for ( i=0; i<3; i++ ) {
544 a.setPoint( 2*i, xx, yy ); 538 a.setPoint( 2*i, xx, yy );
545 a.setPoint( 2*i+1, xx, yy+2 ); 539 a.setPoint( 2*i+1, xx, yy+2 );
546 // qDebug(" "); 540 // qDebug(" ");
547 xx++; yy++; 541 xx++; yy++;
548 } 542 }
549 yy -= 2; 543 yy -= 2;
550 for ( i=3; i<7; i++ ) { 544 for ( i=3; i<7; i++ ) {
551 a.setPoint( 2*i, xx, yy ); 545 a.setPoint( 2*i, xx, yy );
552 a.setPoint( 2*i+1, xx, yy+2 ); 546 a.setPoint( 2*i+1, xx, yy+2 );
553 xx++; yy--; 547 xx++; yy--;
554 } 548 }
555 p->setPen( darkGreen ); 549 p->setPen( darkGreen );
556 p->drawLineSegments( a ); 550 p->drawLineSegments( a );
557 } 551 }
558 //////////////////////// 552 ////////////////////////
559 } 553 }
560 r += BoxSize + 4; 554 r += BoxSize + 4;
561 } 555 }
562 556
563 p->translate( r, 0 ); 557 p->translate( r, 0 );
564 p->setPen( QPen( _cg.text() ) ); 558 p->setPen( QPen( _cg.text() ) );
565 QListViewItem::paintCell( p, _cg, column, width - r, align ); 559 QListViewItem::paintCell( p, _cg, column, width - r, align );
566 if ( mTodo->cancelled () ) { 560 if ( mTodo->cancelled () ) {
567 p->setPen( black ); 561 p->setPen( black );
568 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); 562 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
569 int wid = br.width() +lineStart; 563 int wid = br.width() +lineStart;
570 if ( wid > width-3 ) 564 if ( wid > width-3 )
571 wid = width-3; 565 wid = width-3;
572 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); 566 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
573 567
574 } 568 }
575 569
576} 570}