summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index a1bf9ff..bbf83d9 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1260 +1,1266 @@
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 37
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kglobal.h> 41#include <kglobal.h>
42 42
43#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
44#include <libkcal/calendar.h> 44#include <libkcal/calendar.h>
45#include <libkcal/calendarlocal.h> 45#include <libkcal/calendarlocal.h>
46#include <libkcal/icalformat.h> 46#include <libkcal/icalformat.h>
47#include <libkcal/vcalformat.h> 47#include <libkcal/vcalformat.h>
48#include <libkcal/recurrence.h> 48#include <libkcal/recurrence.h>
49#include <libkcal/filestorage.h> 49#include <libkcal/filestorage.h>
50#include <libkdepim/categoryselectdialog.h> 50#include <libkdepim/categoryselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57 57
58#ifndef KORG_NOPRINTER 58#ifndef KORG_NOPRINTER
59#include "calprinter.h" 59#include "calprinter.h"
60#endif 60#endif
61#include "koglobals.h" 61#include "koglobals.h"
62#include "koprefs.h" 62#include "koprefs.h"
63#include "kfiledialog.h" 63#include "kfiledialog.h"
64 64
65#include "kolistview.h" 65#include "kolistview.h"
66 66
67 67
68 68
69 69
70class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
71{ 71{
72public: 72public:
73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
74 74
75protected: 75protected:
76 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
77 { 77 {
78 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
79 } 79 }
80private: 80private:
81 QWidget* _wid; 81 QWidget* _wid;
82 KOListView * _view; 82 KOListView * _view;
83}; 83};
84 84
85 85
86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
87{ 87{
88 mItem = item; 88 mItem = item;
89 mDate = date; 89 mDate = date;
90} 90}
91 91
92ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
93{ 93{
94} 94}
95 95
96bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
97{ 97{
98 bool ok = false; 98 bool ok = false;
99 QString start, end; 99 QString start, end;
100 QDate ds, de; 100 QDate ds, de;
101 if ( e->doesRecur() ) { 101 if ( e->doesRecur() ) {
102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
103 if ( ok ) { 103 if ( ok ) {
104 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 104 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
105 start = KGlobal::locale()->formatDate(ds,true); 105 start = KGlobal::locale()->formatDate(ds,true);
106 de = ds.addDays( days); 106 de = ds.addDays( days);
107 end = KGlobal::locale()->formatDate(de,true); 107 end = KGlobal::locale()->formatDate(de,true);
108 } 108 }
109 109
110 } 110 }
111 if ( ! ok ) { 111 if ( ! ok ) {
112 start =e->dtStartDateStr(); 112 start =e->dtStartDateStr();
113 end = e->dtEndDateStr(); 113 end = e->dtEndDateStr();
114 ds = e->dtStart().date(); 114 ds = e->dtStart().date();
115 de = e->dtEnd().date(); 115 de = e->dtEnd().date();
116 } 116 }
117 mItem->setText(0,e->summary()); 117 mItem->setText(0,e->summary());
118 mItem->setText(1,start); 118 mItem->setText(1,start);
119 mItem->setText(2,e->dtStartTimeStr()); 119 if ( e->doesFloat() )
120 mItem->setText(2,"---");
121 else
122 mItem->setText(2,e->dtStartTimeStr());
120 mItem->setText(3,end); 123 mItem->setText(3,end);
121 mItem->setText(4,e->dtEndTimeStr()); 124 if ( e->doesFloat() )
125 mItem->setText(4,"---");
126 else
127 mItem->setText(4,e->dtEndTimeStr());
122 if ( e->isAlarmEnabled() ) { 128 if ( e->isAlarmEnabled() ) {
123 mItem->setText(5,e->alarms().first()->offsetText() ); 129 mItem->setText(5,e->alarms().first()->offsetText() );
124 } else { 130 } else {
125 mItem->setText(5, i18n("No")); 131 mItem->setText(5, i18n("No"));
126 } 132 }
127 mItem->setText(6, e->recurrence()->recurrenceText()); 133 mItem->setText(6, e->recurrence()->recurrenceText());
128 if( ! e->doesRecur() ) 134 if( ! e->doesRecur() )
129 mItem->setSortKey( 6, "-" ); 135 mItem->setSortKey( 6, "-" );
130 mItem->setText(7,"---"); 136 mItem->setText(7,"---");
131 mItem->setText(8,"---"); 137 mItem->setText(8,"---");
132 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
133 mItem->setText(10,e->categoriesStr()); 139 mItem->setText(10,e->categoriesStr());
134 140
135 QString key; 141 QString key;
136 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 142 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
137 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 143 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
138 mItem->setSortKey(1,key); 144 mItem->setSortKey(1,key);
139 145
140 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 146 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
141 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 147 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
142 mItem->setSortKey(3,key); 148 mItem->setSortKey(3,key);
143 return true; 149 return true;
144} 150}
145 151
146bool ListItemVisitor::visit(Todo *t) 152bool ListItemVisitor::visit(Todo *t)
147{ 153{
148 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 154 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
149 if (t->hasStartDate()) { 155 if (t->hasStartDate()) {
150 mItem->setText(1,t->dtStartDateStr()); 156 mItem->setText(1,t->dtStartDateStr());
151 if (t->doesFloat()) { 157 if (t->doesFloat()) {
152 mItem->setText(2,"---"); 158 mItem->setText(2,"---");
153 } else { 159 } else {
154 mItem->setText(2,t->dtStartTimeStr()); 160 mItem->setText(2,t->dtStartTimeStr());
155 } 161 }
156 } else { 162 } else {
157 mItem->setText(1,"---"); 163 mItem->setText(1,"---");
158 mItem->setText(2,"---"); 164 mItem->setText(2,"---");
159 } 165 }
160 mItem->setText(3,"---"); 166 mItem->setText(3,"---");
161 mItem->setText(4,"---"); 167 mItem->setText(4,"---");
162 if ( t->isAlarmEnabled() ) { 168 if ( t->isAlarmEnabled() ) {
163 mItem->setText(5,t->alarms().first()->offsetText() ); 169 mItem->setText(5,t->alarms().first()->offsetText() );
164 } else { 170 } else {
165 mItem->setText(5, i18n("No")); 171 mItem->setText(5, i18n("No"));
166 } 172 }
167 mItem->setText(6, t->recurrence()->recurrenceText()); 173 mItem->setText(6, t->recurrence()->recurrenceText());
168 if( ! t->doesRecur() ) 174 if( ! t->doesRecur() )
169 mItem->setSortKey( 6, "-" ); 175 mItem->setSortKey( 6, "-" );
170 if (t->hasDueDate()) { 176 if (t->hasDueDate()) {
171 mItem->setText(7,t->dtDueDateStr()); 177 mItem->setText(7,t->dtDueDateStr());
172 if (t->doesFloat()) { 178 if (t->doesFloat()) {
173 mItem->setText(8,"---"); 179 mItem->setText(8,"---");
174 } else { 180 } else {
175 mItem->setText(8,t->dtDueTimeStr()); 181 mItem->setText(8,t->dtDueTimeStr());
176 } 182 }
177 } else { 183 } else {
178 mItem->setText(7,"---"); 184 mItem->setText(7,"---");
179 mItem->setText(8,"---"); 185 mItem->setText(8,"---");
180 } 186 }
181 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 187 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
182 mItem->setText(10,t->categoriesStr()); 188 mItem->setText(10,t->categoriesStr());
183 189
184 QString key; 190 QString key;
185 QDate d; 191 QDate d;
186 if (t->hasDueDate()) { 192 if (t->hasDueDate()) {
187 d = t->dtDue().date(); 193 d = t->dtDue().date();
188 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
189 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
190 mItem->setSortKey(7,key); 196 mItem->setSortKey(7,key);
191 } 197 }
192 if ( t->hasStartDate() ) { 198 if ( t->hasStartDate() ) {
193 d = t->dtStart().date(); 199 d = t->dtStart().date();
194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 200 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 201 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
196 mItem->setSortKey(1,key); 202 mItem->setSortKey(1,key);
197 } 203 }
198 return true; 204 return true;
199} 205}
200 206
201bool ListItemVisitor::visit(Journal * j) 207bool ListItemVisitor::visit(Journal * j)
202{ 208{
203 QString des = j->description().left(30); 209 QString des = j->description().left(30);
204 des = des.simplifyWhiteSpace (); 210 des = des.simplifyWhiteSpace ();
205 des.replace (QRegExp ("\\n"),"" ); 211 des.replace (QRegExp ("\\n"),"" );
206 des.replace (QRegExp ("\\r"),"" ); 212 des.replace (QRegExp ("\\r"),"" );
207 mItem->setText(0,i18n("Journal: ")+des.left(25)); 213 mItem->setText(0,i18n("Journal: ")+des.left(25));
208 mItem->setText(1,j->dtStartDateStr()); 214 mItem->setText(1,j->dtStartDateStr());
209 mItem->setText(2,"---"); 215 mItem->setText(2,"---");
210 mItem->setText(3,"---"); 216 mItem->setText(3,"---");
211 mItem->setText(4,"---"); 217 mItem->setText(4,"---");
212 mItem->setText(5,"---"); 218 mItem->setText(5,"---");
213 mItem->setText(6,"---"); 219 mItem->setText(6,"---");
214 mItem->setText(7,j->dtStartDateStr()); 220 mItem->setText(7,j->dtStartDateStr());
215 mItem->setText(8,"---"); 221 mItem->setText(8,"---");
216 mItem->setText(9,"---"); 222 mItem->setText(9,"---");
217 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 223 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
218 224
219 QString key; 225 QString key;
220 QDate d = j->dtStart().date(); 226 QDate d = j->dtStart().date();
221 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 227 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
222 mItem->setSortKey(1,key); 228 mItem->setSortKey(1,key);
223 mItem->setSortKey(7,key); 229 mItem->setSortKey(7,key);
224 230
225 return true; 231 return true;
226} 232}
227 233
228KOListView::KOListView(Calendar *calendar, QWidget *parent, 234KOListView::KOListView(Calendar *calendar, QWidget *parent,
229 const char *name) 235 const char *name)
230 : KOEventView(calendar, parent, name) 236 : KOEventView(calendar, parent, name)
231{ 237{
232 mActiveItem = 0; 238 mActiveItem = 0;
233 mListView = new KOListViewListView(this); 239 mListView = new KOListViewListView(this);
234 mListView->addColumn(i18n("Summary")); 240 mListView->addColumn(i18n("Summary"));
235 mListView->addColumn(i18n("Start Date")); 241 mListView->addColumn(i18n("Start Date"));
236 mListView->addColumn(i18n("Start Time")); 242 mListView->addColumn(i18n("Start Time"));
237 mListView->addColumn(i18n("End Date")); 243 mListView->addColumn(i18n("End Date"));
238 mListView->addColumn(i18n("End Time")); 244 mListView->addColumn(i18n("End Time"));
239 mListView->addColumn(i18n("Alarm")); // alarm set? 245 mListView->addColumn(i18n("Alarm")); // alarm set?
240 mListView->addColumn(i18n("Recurs")); // recurs? 246 mListView->addColumn(i18n("Recurs")); // recurs?
241 mListView->addColumn(i18n("Due Date")); 247 mListView->addColumn(i18n("Due Date"));
242 mListView->addColumn(i18n("Due Time")); 248 mListView->addColumn(i18n("Due Time"));
243 mListView->addColumn(i18n("Cancelled")); 249 mListView->addColumn(i18n("Cancelled"));
244 mListView->addColumn(i18n("Categories")); 250 mListView->addColumn(i18n("Categories"));
245 251
246 mListView->setColumnAlignment(0,AlignLeft); 252 mListView->setColumnAlignment(0,AlignLeft);
247 mListView->setColumnAlignment(1,AlignLeft); 253 mListView->setColumnAlignment(1,AlignLeft);
248 mListView->setColumnAlignment(2,AlignHCenter); 254 mListView->setColumnAlignment(2,AlignHCenter);
249 mListView->setColumnAlignment(3,AlignLeft); 255 mListView->setColumnAlignment(3,AlignLeft);
250 mListView->setColumnAlignment(4,AlignHCenter); 256 mListView->setColumnAlignment(4,AlignHCenter);
251 mListView->setColumnAlignment(5,AlignLeft); 257 mListView->setColumnAlignment(5,AlignLeft);
252 mListView->setColumnAlignment(6,AlignLeft); 258 mListView->setColumnAlignment(6,AlignLeft);
253 mListView->setColumnAlignment(7,AlignLeft); 259 mListView->setColumnAlignment(7,AlignLeft);
254 mListView->setColumnAlignment(8,AlignLeft); 260 mListView->setColumnAlignment(8,AlignLeft);
255 mListView->setColumnAlignment(9,AlignLeft); 261 mListView->setColumnAlignment(9,AlignLeft);
256 mListView->setColumnAlignment(10,AlignLeft); 262 mListView->setColumnAlignment(10,AlignLeft);
257 mListView->setColumnWidthMode(10, QListView::Manual); 263 mListView->setColumnWidthMode(10, QListView::Manual);
258 new KOListViewWhatsThis(mListView->viewport(),this); 264 new KOListViewWhatsThis(mListView->viewport(),this);
259 265
260 int iii = 0; 266 int iii = 0;
261 for ( iii = 0; iii< 10 ; ++iii ) 267 for ( iii = 0; iii< 10 ; ++iii )
262 mListView->setColumnWidthMode( iii, QListView::Manual ); 268 mListView->setColumnWidthMode( iii, QListView::Manual );
263 269
264 QBoxLayout *layoutTop = new QVBoxLayout(this); 270 QBoxLayout *layoutTop = new QVBoxLayout(this);
265 layoutTop->addWidget(mListView); 271 layoutTop->addWidget(mListView);
266 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 272 mListView->setFont ( KOPrefs::instance()->mListViewFont );
267 mPopupMenu = eventPopup(); 273 mPopupMenu = eventPopup();
268 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
269 i18n("Select all"),this, 275 i18n("Select all"),this,
270 SLOT(allSelection()),true); 276 SLOT(allSelection()),true);
271 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
272 i18n("Deselect all"),this, 278 i18n("Deselect all"),this,
273 SLOT(clearSelection()),true); 279 SLOT(clearSelection()),true);
274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
275 i18n("Delete all selected"),this, 281 i18n("Delete all selected"),this,
276 SLOT(deleteAll()),true); 282 SLOT(deleteAll()),true);
277 mPopupMenu->insertSeparator(); 283 mPopupMenu->insertSeparator();
278 QPopupMenu * exportPO = new QPopupMenu ( this ); 284 QPopupMenu * exportPO = new QPopupMenu ( this );
279 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 285 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
280 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 286 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
281 SLOT(saveToFile())); 287 SLOT(saveToFile()));
282 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
283 SLOT(saveToFileVCS())); 289 SLOT(saveToFileVCS()));
284 exportPO->insertItem( i18n("Journal/Details..."),this, 290 exportPO->insertItem( i18n("Journal/Details..."),this,
285 SLOT(saveDescriptionToFile())); 291 SLOT(saveDescriptionToFile()));
286 // mPopupMenu->insertSeparator(); 292 // mPopupMenu->insertSeparator();
287 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
288 i18n("Add Categ. to selected..."),this, 294 i18n("Add Categ. to selected..."),this,
289 SLOT(addCat()),true); 295 SLOT(addCat()),true);
290 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
291 i18n("Set Categ. for selected..."),this, 297 i18n("Set Categ. for selected..."),this,
292 SLOT(setCat()),true); 298 SLOT(setCat()),true);
293 //mPopupMenu->insertSeparator(); 299 //mPopupMenu->insertSeparator();
294 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
295 i18n("Set alarm for selected..."),this, 301 i18n("Set alarm for selected..."),this,
296 SLOT(setAlarm()),true); 302 SLOT(setAlarm()),true);
297 303
298 304
299#ifndef DESKTOP_VERSION 305#ifndef DESKTOP_VERSION
300 mPopupMenu->insertSeparator(); 306 mPopupMenu->insertSeparator();
301 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
302 i18n("Beam selected via IR"),this, 308 i18n("Beam selected via IR"),this,
303 SLOT(beamSelected()),true); 309 SLOT(beamSelected()),true);
304#endif 310#endif
305 /* 311 /*
306 mPopupMenu = new QPopupMenu; 312 mPopupMenu = new QPopupMenu;
307 mPopupMenu->insertItem(i18n("Edit Event"), this, 313 mPopupMenu->insertItem(i18n("Edit Event"), this,
308 SLOT (editEvent())); 314 SLOT (editEvent()));
309 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
310 SLOT (deleteEvent())); 316 SLOT (deleteEvent()));
311 mPopupMenu->insertSeparator(); 317 mPopupMenu->insertSeparator();
312 mPopupMenu->insertItem(i18n("Show Dates"), this, 318 mPopupMenu->insertItem(i18n("Show Dates"), this,
313 SLOT(showDates())); 319 SLOT(showDates()));
314 mPopupMenu->insertItem(i18n("Hide Dates"), this, 320 mPopupMenu->insertItem(i18n("Hide Dates"), this,
315 SLOT(hideDates())); 321 SLOT(hideDates()));
316 */ 322 */
317 QObject::connect(mListView,SIGNAL( newEvent()), 323 QObject::connect(mListView,SIGNAL( newEvent()),
318 this,SIGNAL(signalNewEvent())); 324 this,SIGNAL(signalNewEvent()));
319 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
320 this,SLOT(defaultItemAction(QListViewItem *))); 326 this,SLOT(defaultItemAction(QListViewItem *)));
321 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
322 const QPoint &, int )), 328 const QPoint &, int )),
323 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
324 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
325 SLOT(processSelectionChange(QListViewItem *))); 331 SLOT(processSelectionChange(QListViewItem *)));
326 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
327 SIGNAL(showIncidenceSignal(Incidence *)) ); 333 SIGNAL(showIncidenceSignal(Incidence *)) );
328 334
329 readSettings(KOGlobals::config(),"KOListView Layout"); 335 readSettings(KOGlobals::config(),"KOListView Layout");
330} 336}
331 337
332KOListView::~KOListView() 338KOListView::~KOListView()
333{ 339{
334 delete mPopupMenu; 340 delete mPopupMenu;
335} 341}
336 342
337QString KOListView::getWhatsThisText(QPoint p) 343QString KOListView::getWhatsThisText(QPoint p)
338{ 344{
339 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 345 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
340 if ( item ) 346 if ( item )
341 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 347 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
342 KOPrefs::instance()->mWTshowDetails, 348 KOPrefs::instance()->mWTshowDetails,
343 KOPrefs::instance()->mWTshowCreated, 349 KOPrefs::instance()->mWTshowCreated,
344 KOPrefs::instance()->mWTshowChanged); 350 KOPrefs::instance()->mWTshowChanged);
345 return i18n("That is the list view" ); 351 return i18n("That is the list view" );
346 352
347} 353}
348 354
349void KOListView::updateList() 355void KOListView::updateList()
350{ 356{
351 // qDebug(" KOListView::updateList() "); 357 // qDebug(" KOListView::updateList() ");
352 358
353} 359}
354 360
355void KOListView::addCat( ) 361void KOListView::addCat( )
356{ 362{
357 setCategories( false ); 363 setCategories( false );
358} 364}
359void KOListView::setCat() 365void KOListView::setCat()
360{ 366{
361 setCategories( true ); 367 setCategories( true );
362} 368}
363void KOListView::setAlarm() 369void KOListView::setAlarm()
364{ 370{
365 KOAlarmPrefs kap( this); 371 KOAlarmPrefs kap( this);
366 if ( !kap.exec() ) 372 if ( !kap.exec() )
367 return; 373 return;
368 374
369 375
370 QStringList itemList; 376 QStringList itemList;
371 QPtrList<KOListViewItem> sel ; 377 QPtrList<KOListViewItem> sel ;
372 QListViewItem *qitem = mListView->firstChild (); 378 QListViewItem *qitem = mListView->firstChild ();
373 while ( qitem ) { 379 while ( qitem ) {
374 if ( qitem->isSelected() ) { 380 if ( qitem->isSelected() ) {
375 Incidence* inc = ((KOListViewItem *) qitem)->data(); 381 Incidence* inc = ((KOListViewItem *) qitem)->data();
376 if ( inc->type() != "Journal" ) { 382 if ( inc->type() != "Journal" ) {
377 if ( inc->type() == "Todo" ) { 383 if ( inc->type() == "Todo" ) {
378 if ( ((Todo*)inc)->hasDueDate() ) 384 if ( ((Todo*)inc)->hasDueDate() )
379 sel.append(((KOListViewItem *)qitem)); 385 sel.append(((KOListViewItem *)qitem));
380 } else 386 } else
381 sel.append(((KOListViewItem *)qitem)); 387 sel.append(((KOListViewItem *)qitem));
382 } 388 }
383 } 389 }
384 qitem = qitem->nextSibling(); 390 qitem = qitem->nextSibling();
385 } 391 }
386 int count = 0; 392 int count = 0;
387 KOListViewItem * item, *temp; 393 KOListViewItem * item, *temp;
388 item = sel.first(); 394 item = sel.first();
389 Incidence* inc; 395 Incidence* inc;
390 while ( item ) { 396 while ( item ) {
391 inc = item->data(); 397 inc = item->data();
392 ++count; 398 ++count;
393 if (kap.mAlarmButton->isChecked()) { 399 if (kap.mAlarmButton->isChecked()) {
394 if (inc->alarms().count() == 0) 400 if (inc->alarms().count() == 0)
395 inc->newAlarm(); 401 inc->newAlarm();
396 QPtrList<Alarm> alarms = inc->alarms(); 402 QPtrList<Alarm> alarms = inc->alarms();
397 Alarm *alarm; 403 Alarm *alarm;
398 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 404 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
399 alarm->setEnabled(true); 405 alarm->setEnabled(true);
400 int j = kap.mAlarmTimeEdit->value()* -60; 406 int j = kap.mAlarmTimeEdit->value()* -60;
401 if (kap.mAlarmIncrCombo->currentItem() == 1) 407 if (kap.mAlarmIncrCombo->currentItem() == 1)
402 j = j * 60; 408 j = j * 60;
403 else if (kap.mAlarmIncrCombo->currentItem() == 2) 409 else if (kap.mAlarmIncrCombo->currentItem() == 2)
404 j = j * (60 * 24); 410 j = j * (60 * 24);
405 alarm->setStartOffset( j ); 411 alarm->setStartOffset( j );
406 412
407 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 413 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
408 alarm->setProcedureAlarm(kap.mAlarmProgram); 414 alarm->setProcedureAlarm(kap.mAlarmProgram);
409 } 415 }
410 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 416 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
411 alarm->setAudioAlarm(kap.mAlarmSound); 417 alarm->setAudioAlarm(kap.mAlarmSound);
412 else 418 else
413 alarm->setType(Alarm::Invalid); 419 alarm->setType(Alarm::Invalid);
414 //alarm->setAudioAlarm("default"); 420 //alarm->setAudioAlarm("default");
415 // TODO: Deal with multiple alarms 421 // TODO: Deal with multiple alarms
416 break; // For now, stop after the first alarm 422 break; // For now, stop after the first alarm
417 } 423 }
418 } else { 424 } else {
419 Alarm* alarm = inc->alarms().first(); 425 Alarm* alarm = inc->alarms().first();
420 if ( alarm ) { 426 if ( alarm ) {
421 alarm->setEnabled(false); 427 alarm->setEnabled(false);
422 alarm->setType(Alarm::Invalid); 428 alarm->setType(Alarm::Invalid);
423 } 429 }
424 } 430 }
425 temp = item; 431 temp = item;
426 item = sel.next(); 432 item = sel.next();
427 mUidDict.remove( inc->uid() ); 433 mUidDict.remove( inc->uid() );
428 delete temp;; 434 delete temp;;
429 addIncidence( inc ); 435 addIncidence( inc );
430 } 436 }
431 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); 437 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) );
432 qDebug("KO: Set alarm for %d items", count); 438 qDebug("KO: Set alarm for %d items", count);
433 calendar()->reInitAlarmSettings(); 439 calendar()->reInitAlarmSettings();
434 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 440 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
435} 441}
436void KOListView::setCategories( bool removeOld ) 442void KOListView::setCategories( bool removeOld )
437{ 443{
438 444
439 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 445 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
440 if (! csd->exec()) { 446 if (! csd->exec()) {
441 delete csd; 447 delete csd;
442 return; 448 return;
443 } 449 }
444 QStringList catList = csd->selectedCategories(); 450 QStringList catList = csd->selectedCategories();
445 delete csd; 451 delete csd;
446 // if ( catList.count() == 0 ) 452 // if ( catList.count() == 0 )
447 // return; 453 // return;
448 catList.sort(); 454 catList.sort();
449 QString categoriesStr = catList.join(","); 455 QString categoriesStr = catList.join(",");
450 int i; 456 int i;
451 QStringList itemList; 457 QStringList itemList;
452 QPtrList<KOListViewItem> sel ; 458 QPtrList<KOListViewItem> sel ;
453 QListViewItem *qitem = mListView->firstChild (); 459 QListViewItem *qitem = mListView->firstChild ();
454 while ( qitem ) { 460 while ( qitem ) {
455 if ( qitem->isSelected() ) { 461 if ( qitem->isSelected() ) {
456 sel.append(((KOListViewItem *)qitem)); 462 sel.append(((KOListViewItem *)qitem));
457 } 463 }
458 qitem = qitem->nextSibling(); 464 qitem = qitem->nextSibling();
459 } 465 }
460 KOListViewItem * item, *temp; 466 KOListViewItem * item, *temp;
461 item = sel.first(); 467 item = sel.first();
462 Incidence* inc; 468 Incidence* inc;
463 while ( item ) { 469 while ( item ) {
464 inc = item->data(); 470 inc = item->data();
465 if ( removeOld ) { 471 if ( removeOld ) {
466 inc->setCategories( categoriesStr ); 472 inc->setCategories( categoriesStr );
467 } else { 473 } else {
468 itemList = QStringList::split (",", inc->categoriesStr() ); 474 itemList = QStringList::split (",", inc->categoriesStr() );
469 for( i = 0; i< catList.count(); ++i ) { 475 for( i = 0; i< catList.count(); ++i ) {
470 if ( !itemList.contains (catList[i])) 476 if ( !itemList.contains (catList[i]))
471 itemList.append( catList[i] ); 477 itemList.append( catList[i] );
472 } 478 }
473 itemList.sort(); 479 itemList.sort();
474 inc->setCategories( itemList.join(",") ); 480 inc->setCategories( itemList.join(",") );
475 } 481 }
476 temp = item; 482 temp = item;
477 item = sel.next(); 483 item = sel.next();
478 mUidDict.remove( inc->uid() ); 484 mUidDict.remove( inc->uid() );
479 delete temp;; 485 delete temp;;
480 addIncidence( inc ); 486 addIncidence( inc );
481 } 487 }
482 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 488 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
483} 489}
484 490
485void KOListView::beamSelected() 491void KOListView::beamSelected()
486{ 492{
487 int icount = 0; 493 int icount = 0;
488 QPtrList<Incidence> delSel ; 494 QPtrList<Incidence> delSel ;
489 QListViewItem *item = mListView->firstChild (); 495 QListViewItem *item = mListView->firstChild ();
490 while ( item ) { 496 while ( item ) {
491 if ( item->isSelected() ) { 497 if ( item->isSelected() ) {
492 delSel.append(((KOListViewItem *)item)->data()); 498 delSel.append(((KOListViewItem *)item)->data());
493 ++icount; 499 ++icount;
494 } 500 }
495 501
496 item = item->nextSibling(); 502 item = item->nextSibling();
497 } 503 }
498 if ( icount ) { 504 if ( icount ) {
499 emit beamIncidenceList( delSel ); 505 emit beamIncidenceList( delSel );
500 return; 506 return;
501 QString fn ; 507 QString fn ;
502 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 508 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
503 QString mes; 509 QString mes;
504 bool createbup = true; 510 bool createbup = true;
505 if ( createbup ) { 511 if ( createbup ) {
506 QString description = "\n"; 512 QString description = "\n";
507 CalendarLocal* cal = new CalendarLocal(); 513 CalendarLocal* cal = new CalendarLocal();
508 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 514 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
509 Incidence *incidence = delSel.first(); 515 Incidence *incidence = delSel.first();
510 while ( incidence ) { 516 while ( incidence ) {
511 Incidence *in = incidence->clone(); 517 Incidence *in = incidence->clone();
512 description += in->summary() + "\n"; 518 description += in->summary() + "\n";
513 cal->addIncidence( in ); 519 cal->addIncidence( in );
514 incidence = delSel.next(); 520 incidence = delSel.next();
515 } 521 }
516 FileStorage storage( cal, fn, new VCalFormat ); 522 FileStorage storage( cal, fn, new VCalFormat );
517 storage.save(); 523 storage.save();
518 delete cal; 524 delete cal;
519 mes = i18n("KO/Pi: Ready for beaming"); 525 mes = i18n("KO/Pi: Ready for beaming");
520 topLevelWidget()->setCaption(mes); 526 topLevelWidget()->setCaption(mes);
521 527
522#ifndef DESKTOP_VERSION 528#ifndef DESKTOP_VERSION
523 Ir *ir = new Ir( this ); 529 Ir *ir = new Ir( this );
524 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 530 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
525 ir->send( fn, description, "text/x-vCalendar" ); 531 ir->send( fn, description, "text/x-vCalendar" );
526#endif 532#endif
527 } 533 }
528 } 534 }
529} 535}
530void KOListView::beamDone( Ir *ir ) 536void KOListView::beamDone( Ir *ir )
531{ 537{
532#ifndef DESKTOP_VERSION 538#ifndef DESKTOP_VERSION
533 delete ir; 539 delete ir;
534#endif 540#endif
535 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 541 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
536} 542}
537 543
538void KOListView::saveDescriptionToFile() 544void KOListView::saveDescriptionToFile()
539{ 545{
540 546
541 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 547 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
542 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 548 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
543 i18n("Continue"), i18n("Cancel"), 0, 549 i18n("Continue"), i18n("Cancel"), 0,
544 0, 1 ); 550 0, 1 );
545 if ( result != 0 ) { 551 if ( result != 0 ) {
546 return; 552 return;
547 } 553 }
548 int icount = 0; 554 int icount = 0;
549 QPtrList<Incidence> delSel ; 555 QPtrList<Incidence> delSel ;
550 QListViewItem *item = mListView->firstChild (); 556 QListViewItem *item = mListView->firstChild ();
551 while ( item ) { 557 while ( item ) {
552 if ( item->isSelected() ) { 558 if ( item->isSelected() ) {
553 delSel.append(((KOListViewItem *)item)->data()); 559 delSel.append(((KOListViewItem *)item)->data());
554 ++icount; 560 ++icount;
555 } 561 }
556 562
557 item = item->nextSibling(); 563 item = item->nextSibling();
558 } 564 }
559 if ( icount ) { 565 if ( icount ) {
560 QString fn = KOPrefs::instance()->mLastSaveFile; 566 QString fn = KOPrefs::instance()->mLastSaveFile;
561 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 567 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
562 568
563 if ( fn == "" ) 569 if ( fn == "" )
564 return; 570 return;
565 QFileInfo info; 571 QFileInfo info;
566 info.setFile( fn ); 572 info.setFile( fn );
567 QString mes; 573 QString mes;
568 bool createbup = true; 574 bool createbup = true;
569 if ( info. exists() ) { 575 if ( info. exists() ) {
570 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 576 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
571 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 577 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
572 i18n("Overwrite!"), i18n("Cancel"), 0, 578 i18n("Overwrite!"), i18n("Cancel"), 0,
573 0, 1 ); 579 0, 1 );
574 if ( result != 0 ) { 580 if ( result != 0 ) {
575 createbup = false; 581 createbup = false;
576 } 582 }
577 } 583 }
578 if ( createbup ) { 584 if ( createbup ) {
579 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 585 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
580 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 586 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
581 Incidence *incidence = delSel.first(); 587 Incidence *incidence = delSel.first();
582 icount = 0; 588 icount = 0;
583 while ( incidence ) { 589 while ( incidence ) {
584 if ( incidence->type() == "Journal" ) { 590 if ( incidence->type() == "Journal" ) {
585 text += "\n************************************\n"; 591 text += "\n************************************\n";
586 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 592 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
587 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 593 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
588 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 594 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
589 ++icount; 595 ++icount;
590 596
591 } else { 597 } else {
592 if ( !incidence->description().isEmpty() ) { 598 if ( !incidence->description().isEmpty() ) {
593 text += "\n************************************\n"; 599 text += "\n************************************\n";
594 if ( incidence->type() == "Todo" ) 600 if ( incidence->type() == "Todo" )
595 text += i18n("To-Do: "); 601 text += i18n("To-Do: ");
596 text += incidence->summary(); 602 text += incidence->summary();
597 if ( incidence->hasStartDate() ) 603 if ( incidence->hasStartDate() )
598 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 604 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
599 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 605 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
600 if ( !incidence->location().isEmpty() ) 606 if ( !incidence->location().isEmpty() )
601 text += "\n" +i18n("Location: ") + incidence->location(); 607 text += "\n" +i18n("Location: ") + incidence->location();
602 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 608 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
603 ++icount; 609 ++icount;
604 610
605 } 611 }
606 } 612 }
607 incidence = delSel.next(); 613 incidence = delSel.next();
608 } 614 }
609 QFile file( fn ); 615 QFile file( fn );
610 if (!file.open( IO_WriteOnly ) ) { 616 if (!file.open( IO_WriteOnly ) ) {
611 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 617 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
612 return; 618 return;
613 } 619 }
614 QTextStream ts( &file ); 620 QTextStream ts( &file );
615 ts << text; 621 ts << text;
616 file.close(); 622 file.close();
617 //qDebug("%s ", text.latin1()); 623 //qDebug("%s ", text.latin1());
618 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 624 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
619 KOPrefs::instance()->mLastSaveFile = fn; 625 KOPrefs::instance()->mLastSaveFile = fn;
620 topLevelWidget()->setCaption(mes); 626 topLevelWidget()->setCaption(mes);
621 } 627 }
622 } 628 }
623} 629}
624void KOListView::saveToFileVCS() 630void KOListView::saveToFileVCS()
625{ 631{
626 writeToFile( false ); 632 writeToFile( false );
627} 633}
628void KOListView::saveToFile() 634void KOListView::saveToFile()
629{ 635{
630 writeToFile( true ); 636 writeToFile( true );
631} 637}
632void KOListView::writeToFile( bool iCal ) 638void KOListView::writeToFile( bool iCal )
633{ 639{
634 640
635 int icount = 0; 641 int icount = 0;
636 QPtrList<Incidence> delSel ; 642 QPtrList<Incidence> delSel ;
637 QListViewItem *item = mListView->firstChild (); 643 QListViewItem *item = mListView->firstChild ();
638 bool journal = iCal; // warn only for vCal 644 bool journal = iCal; // warn only for vCal
639 while ( item ) { 645 while ( item ) {
640 if ( item->isSelected() ) { 646 if ( item->isSelected() ) {
641 if ( !journal ) 647 if ( !journal )
642 if ( ((KOListViewItem *)item)->data()->type() == "Journal") 648 if ( ((KOListViewItem *)item)->data()->type() == "Journal")
643 journal = true; 649 journal = true;
644 delSel.append(((KOListViewItem *)item)->data()); 650 delSel.append(((KOListViewItem *)item)->data());
645 ++icount; 651 ++icount;
646 } 652 }
647 653
648 item = item->nextSibling(); 654 item = item->nextSibling();
649 } 655 }
650 if ( !iCal && journal ) { 656 if ( !iCal && journal ) {
651 int result = KMessageBox::warningContinueCancel(this, 657 int result = KMessageBox::warningContinueCancel(this,
652 i18n("The journal entries can not be\nexported to a vCalendar file."), 658 i18n("The journal entries can not be\nexported to a vCalendar file."),
653 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 659 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
654 true); 660 true);
655 if (result != KMessageBox::Continue) return; 661 if (result != KMessageBox::Continue) return;
656 } 662 }
657 if ( icount ) { 663 if ( icount ) {
658 QString fn = KOPrefs::instance()->mLastSaveFile; 664 QString fn = KOPrefs::instance()->mLastSaveFile;
659 QString extension; 665 QString extension;
660 if ( iCal ) { 666 if ( iCal ) {
661 if ( fn.right( 4 ).lower() == ".vcs" ) { 667 if ( fn.right( 4 ).lower() == ".vcs" ) {
662 fn = fn.left( fn.length() -3) + "ics"; 668 fn = fn.left( fn.length() -3) + "ics";
663 } 669 }
664 } else { 670 } else {
665 if ( fn.right( 4 ).lower() == ".ics" ) { 671 if ( fn.right( 4 ).lower() == ".ics" ) {
666 fn = fn.left( fn.length() -3) + "vcs"; 672 fn = fn.left( fn.length() -3) + "vcs";
667 } 673 }
668 } 674 }
669 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 675 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
670 676
671 if ( fn == "" ) 677 if ( fn == "" )
672 return; 678 return;
673 QFileInfo info; 679 QFileInfo info;
674 info.setFile( fn ); 680 info.setFile( fn );
675 QString mes; 681 QString mes;
676 bool createbup = true; 682 bool createbup = true;
677 if ( info. exists() ) { 683 if ( info. exists() ) {
678 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 684 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
679 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 685 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
680 i18n("Overwrite!"), i18n("Cancel"), 0, 686 i18n("Overwrite!"), i18n("Cancel"), 0,
681 0, 1 ); 687 0, 1 );
682 if ( result != 0 ) { 688 if ( result != 0 ) {
683 createbup = false; 689 createbup = false;
684 } 690 }
685 } 691 }
686 if ( createbup ) { 692 if ( createbup ) {
687 CalendarLocal cal; 693 CalendarLocal cal;
688 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 694 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
689 Incidence *incidence = delSel.first(); 695 Incidence *incidence = delSel.first();
690 while ( incidence ) { 696 while ( incidence ) {
691 cal.addIncidence( incidence->clone() ); 697 cal.addIncidence( incidence->clone() );
692 incidence = delSel.next(); 698 incidence = delSel.next();
693 } 699 }
694 if ( iCal ) { 700 if ( iCal ) {
695 ICalFormat format; 701 ICalFormat format;
696 format.save( &cal, fn ); 702 format.save( &cal, fn );
697 } else { 703 } else {
698 704
699 VCalFormat format; 705 VCalFormat format;
700 format.save( &cal, fn ); 706 format.save( &cal, fn );
701 } 707 }
702 mes = i18n("KO/Pi:Saved %1").arg(fn ); 708 mes = i18n("KO/Pi:Saved %1").arg(fn );
703 KOPrefs::instance()->mLastSaveFile = fn; 709 KOPrefs::instance()->mLastSaveFile = fn;
704 topLevelWidget()->setCaption(mes); 710 topLevelWidget()->setCaption(mes);
705 } 711 }
706 } 712 }
707 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 713 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
708} 714}
709void KOListView::deleteAll() 715void KOListView::deleteAll()
710{ 716{
711 int icount = 0; 717 int icount = 0;
712 QPtrList<Incidence> delSel ; 718 QPtrList<Incidence> delSel ;
713 QListViewItem *item = mListView->firstChild (); 719 QListViewItem *item = mListView->firstChild ();
714 while ( item ) { 720 while ( item ) {
715 if ( item->isSelected() ) { 721 if ( item->isSelected() ) {
716 delSel.append(((KOListViewItem *)item)->data()); 722 delSel.append(((KOListViewItem *)item)->data());
717 ++icount; 723 ++icount;
718 } 724 }
719 725
720 item = item->nextSibling(); 726 item = item->nextSibling();
721 } 727 }
722 if ( icount ) { 728 if ( icount ) {
723 Incidence *incidence = delSel.first(); 729 Incidence *incidence = delSel.first();
724 Incidence *toDelete; 730 Incidence *toDelete;
725 KOPrefs *p = KOPrefs::instance(); 731 KOPrefs *p = KOPrefs::instance();
726 bool confirm = p->mConfirm; 732 bool confirm = p->mConfirm;
727 QString mess; 733 QString mess;
728 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 734 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
729 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")) ) { 735 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")) ) {
730 p->mConfirm = false; 736 p->mConfirm = false;
731 int delCounter = 0; 737 int delCounter = 0;
732 QDialog dia ( this, "p-dialog", true ); 738 QDialog dia ( this, "p-dialog", true );
733 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 739 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
734 QVBoxLayout lay( &dia ); 740 QVBoxLayout lay( &dia );
735 lay.setMargin(7); 741 lay.setMargin(7);
736 lay.setSpacing(7); 742 lay.setSpacing(7);
737 lay.addWidget( &lab); 743 lay.addWidget( &lab);
738 QProgressBar bar( icount, &dia ); 744 QProgressBar bar( icount, &dia );
739 lay.addWidget( &bar); 745 lay.addWidget( &bar);
740 int w = 220; 746 int w = 220;
741 int h = 50; 747 int h = 50;
742 int dw = QApplication::desktop()->width(); 748 int dw = QApplication::desktop()->width();
743 int dh = QApplication::desktop()->height(); 749 int dh = QApplication::desktop()->height();
744 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 750 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
745 //dia.resize( 240,50 ); 751 //dia.resize( 240,50 );
746 dia.show(); 752 dia.show();
747 753
748 while ( incidence ) { 754 while ( incidence ) {
749 bar.setProgress( delCounter ); 755 bar.setProgress( delCounter );
750 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 756 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
751 dia.setCaption( mess ); 757 dia.setCaption( mess );
752 qApp->processEvents(); 758 qApp->processEvents();
753 toDelete = (incidence); 759 toDelete = (incidence);
754 incidence = delSel.next(); 760 incidence = delSel.next();
755 emit deleteIncidenceSignal(toDelete ); 761 emit deleteIncidenceSignal(toDelete );
756 if ( dia.result() != 0 ) 762 if ( dia.result() != 0 )
757 break; 763 break;
758 764
759 } 765 }
760 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 766 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
761 topLevelWidget ()->setCaption( mess ); 767 topLevelWidget ()->setCaption( mess );
762 p->mConfirm = confirm; 768 p->mConfirm = confirm;
763 } 769 }
764 } 770 }
765 771
766 772
767} 773}
768int KOListView::maxDatesHint() 774int KOListView::maxDatesHint()
769{ 775{
770 return 0; 776 return 0;
771} 777}
772 778
773int KOListView::currentDateCount() 779int KOListView::currentDateCount()
774{ 780{
775 return 0; 781 return 0;
776} 782}
777 783
778QPtrList<Incidence> KOListView::selectedIncidences() 784QPtrList<Incidence> KOListView::selectedIncidences()
779{ 785{
780 QPtrList<Incidence> eventList; 786 QPtrList<Incidence> eventList;
781 QListViewItem *item = mListView->firstChild (); 787 QListViewItem *item = mListView->firstChild ();
782 while ( item ) { 788 while ( item ) {
783 if ( item->isSelected() ) { 789 if ( item->isSelected() ) {
784 eventList.append(((KOListViewItem *)item)->data()); 790 eventList.append(((KOListViewItem *)item)->data());
785 } 791 }
786 792
787 item = item->nextSibling(); 793 item = item->nextSibling();
788 } 794 }
789 795
790 // // QListViewItem *item = mListView->selectedItem(); 796 // // QListViewItem *item = mListView->selectedItem();
791 //if (item) eventList.append(((KOListViewItem *)item)->data()); 797 //if (item) eventList.append(((KOListViewItem *)item)->data());
792 798
793 return eventList; 799 return eventList;
794} 800}
795 801
796DateList KOListView::selectedDates() 802DateList KOListView::selectedDates()
797{ 803{
798 DateList eventList; 804 DateList eventList;
799 return eventList; 805 return eventList;
800} 806}
801 807
802void KOListView::showDates(bool show) 808void KOListView::showDates(bool show)
803{ 809{
804 // Shouldn't we set it to a value greater 0? When showDates is called with 810 // Shouldn't we set it to a value greater 0? When showDates is called with
805 // show == true at first, then the columnwidths are set to zero. 811 // show == true at first, then the columnwidths are set to zero.
806 static int oldColWidth1 = 0; 812 static int oldColWidth1 = 0;
807 static int oldColWidth3 = 0; 813 static int oldColWidth3 = 0;
808 814
809 if (!show) { 815 if (!show) {
810 oldColWidth1 = mListView->columnWidth(1); 816 oldColWidth1 = mListView->columnWidth(1);
811 oldColWidth3 = mListView->columnWidth(3); 817 oldColWidth3 = mListView->columnWidth(3);
812 mListView->setColumnWidth(1, 0); 818 mListView->setColumnWidth(1, 0);
813 mListView->setColumnWidth(3, 0); 819 mListView->setColumnWidth(3, 0);
814 } else { 820 } else {
815 mListView->setColumnWidth(1, oldColWidth1); 821 mListView->setColumnWidth(1, oldColWidth1);
816 mListView->setColumnWidth(3, oldColWidth3); 822 mListView->setColumnWidth(3, oldColWidth3);
817 } 823 }
818 mListView->repaint(); 824 mListView->repaint();
819} 825}
820 826
821void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 827void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
822 const QDate &td) 828 const QDate &td)
823{ 829{
824#ifndef KORG_NOPRINTER 830#ifndef KORG_NOPRINTER
825 calPrinter->preview(CalPrinter::Day, fd, td); 831 calPrinter->preview(CalPrinter::Day, fd, td);
826#endif 832#endif
827} 833}
828 834
829void KOListView::showDates() 835void KOListView::showDates()
830{ 836{
831 showDates(true); 837 showDates(true);
832} 838}
833 839
834void KOListView::hideDates() 840void KOListView::hideDates()
835{ 841{
836 showDates(false); 842 showDates(false);
837} 843}
838 844
839void KOListView::resetFocus() 845void KOListView::resetFocus()
840{ 846{
841 topLevelWidget()->setActiveWindow(); 847 topLevelWidget()->setActiveWindow();
842 topLevelWidget()->raise(); 848 topLevelWidget()->raise();
843 mListView->setFocus(); 849 mListView->setFocus();
844} 850}
845void KOListView::updateView() 851void KOListView::updateView()
846{ 852{
847 mListView->setFocus(); 853 mListView->setFocus();
848 if ( mListView->firstChild () ) 854 if ( mListView->firstChild () )
849 mListView->setCurrentItem( mListView->firstChild () ); 855 mListView->setCurrentItem( mListView->firstChild () );
850} 856}
851void KOListView::updateConfig() 857void KOListView::updateConfig()
852{ 858{
853 859
854 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 860 mListView->setFont ( KOPrefs::instance()->mListViewFont );
855 updateView(); 861 updateView();
856 862
857} 863}
858void KOListView::setStartDate(const QDate &start) 864void KOListView::setStartDate(const QDate &start)
859{ 865{
860 mStartDate = start; 866 mStartDate = start;
861} 867}
862 868
863void KOListView::showDates(const QDate &start, const QDate &end) 869void KOListView::showDates(const QDate &start, const QDate &end)
864{ 870{
865 clear(); 871 clear();
866 mStartDate = start; 872 mStartDate = start;
867 QDate date = start; 873 QDate date = start;
868 QPtrList<Journal> j_list; 874 QPtrList<Journal> j_list;
869 while( date <= end ) { 875 while( date <= end ) {
870 addEvents(calendar()->events(date)); 876 addEvents(calendar()->events(date));
871 addTodos(calendar()->todos(date)); 877 addTodos(calendar()->todos(date));
872 Journal* jo = calendar()->journal(date); 878 Journal* jo = calendar()->journal(date);
873 if ( jo ) 879 if ( jo )
874 j_list.append( jo ); 880 j_list.append( jo );
875 date = date.addDays( 1 ); 881 date = date.addDays( 1 );
876 } 882 }
877 addJournals(j_list); 883 addJournals(j_list);
878 emit incidenceSelected( 0 ); 884 emit incidenceSelected( 0 );
879 updateView(); 885 updateView();
880 886
881} 887}
882 888
883void KOListView::addEvents(QPtrList<Event> eventList) 889void KOListView::addEvents(QPtrList<Event> eventList)
884{ 890{
885 891
886 Event *ev; 892 Event *ev;
887 for(ev = eventList.first(); ev; ev = eventList.next()) { 893 for(ev = eventList.first(); ev; ev = eventList.next()) {
888 addIncidence(ev); 894 addIncidence(ev);
889 } 895 }
890 if ( !mListView->currentItem() ){ 896 if ( !mListView->currentItem() ){
891 updateView(); 897 updateView();
892 } 898 }
893} 899}
894 900
895void KOListView::addTodos(QPtrList<Todo> eventList) 901void KOListView::addTodos(QPtrList<Todo> eventList)
896{ 902{
897 Todo *ev; 903 Todo *ev;
898 for(ev = eventList.first(); ev; ev = eventList.next()) { 904 for(ev = eventList.first(); ev; ev = eventList.next()) {
899 addIncidence(ev); 905 addIncidence(ev);
900 } 906 }
901 if ( !mListView->currentItem() ){ 907 if ( !mListView->currentItem() ){
902 updateView(); 908 updateView();
903 } 909 }
904} 910}
905void KOListView::addJournals(QPtrList<Journal> eventList) 911void KOListView::addJournals(QPtrList<Journal> eventList)
906{ 912{
907 Journal *ev; 913 Journal *ev;
908 for(ev = eventList.first(); ev; ev = eventList.next()) { 914 for(ev = eventList.first(); ev; ev = eventList.next()) {
909 addIncidence(ev); 915 addIncidence(ev);
910 } 916 }
911 if ( !mListView->currentItem() ){ 917 if ( !mListView->currentItem() ){
912 updateView(); 918 updateView();
913 } 919 }
914} 920}
915 921
916void KOListView::addIncidence(Incidence *incidence) 922void KOListView::addIncidence(Incidence *incidence)
917{ 923{
918 if ( mUidDict.find( incidence->uid() ) ) return; 924 if ( mUidDict.find( incidence->uid() ) ) return;
919 925
920 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 926 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
921 mUidDict.insert( incidence->uid(), incidence ); 927 mUidDict.insert( incidence->uid(), incidence );
922 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 928 KOListViewItem *item = new KOListViewItem( incidence, mListView );
923 ListItemVisitor v(item, mStartDate ); 929 ListItemVisitor v(item, mStartDate );
924 if (incidence->accept(v)) { 930 if (incidence->accept(v)) {
925 return; 931 return;
926 } 932 }
927 else delete item; 933 else delete item;
928} 934}
929 935
930void KOListView::showEvents(QPtrList<Event> eventList) 936void KOListView::showEvents(QPtrList<Event> eventList)
931{ 937{
932 clear(); 938 clear();
933 939
934 addEvents(eventList); 940 addEvents(eventList);
935 941
936 // After new creation of list view no events are selected. 942 // After new creation of list view no events are selected.
937 emit incidenceSelected( 0 ); 943 emit incidenceSelected( 0 );
938} 944}
939int KOListView::count() 945int KOListView::count()
940{ 946{
941 return mListView->childCount(); 947 return mListView->childCount();
942} 948}
943 949
944void KOListView::changeEventDisplay(Event *event, int action) 950void KOListView::changeEventDisplay(Event *event, int action)
945{ 951{
946 KOListViewItem *item; 952 KOListViewItem *item;
947 953
948 switch(action) { 954 switch(action) {
949 case KOGlobals::EVENTADDED: 955 case KOGlobals::EVENTADDED:
950 addIncidence( event ); 956 addIncidence( event );
951 break; 957 break;
952 case KOGlobals::EVENTEDITED: 958 case KOGlobals::EVENTEDITED:
953 item = getItemForEvent(event); 959 item = getItemForEvent(event);
954 if (item) { 960 if (item) {
955 mUidDict.remove( event->uid() ); 961 mUidDict.remove( event->uid() );
956 delete item; 962 delete item;
957 addIncidence( event ); 963 addIncidence( event );
958 } 964 }
959 break; 965 break;
960 case KOGlobals::EVENTDELETED: 966 case KOGlobals::EVENTDELETED:
961 item = getItemForEvent(event); 967 item = getItemForEvent(event);
962 if (item) { 968 if (item) {
963 mUidDict.remove( event->uid() ); 969 mUidDict.remove( event->uid() );
964 delete item; 970 delete item;
965 } 971 }
966 break; 972 break;
967 default: 973 default:
968 ; 974 ;
969 } 975 }
970} 976}
971 977
972KOListViewItem *KOListView::getItemForEvent(Event *event) 978KOListViewItem *KOListView::getItemForEvent(Event *event)
973{ 979{
974 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 980 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
975 while (item) { 981 while (item) {
976 if (item->data() == event) return item; 982 if (item->data() == event) return item;
977 item = (KOListViewItem *)item->nextSibling(); 983 item = (KOListViewItem *)item->nextSibling();
978 } 984 }
979 return 0; 985 return 0;
980} 986}
981 987
982void KOListView::defaultItemAction(QListViewItem *i) 988void KOListView::defaultItemAction(QListViewItem *i)
983{ 989{
984 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 990 KOListViewItem *item = static_cast<KOListViewItem *>( i );
985 if ( item ) defaultAction( item->data() ); 991 if ( item ) defaultAction( item->data() );
986 992
987} 993}
988 994
989void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 995void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
990{ 996{
991 mActiveItem = (KOListViewItem *)item; 997 mActiveItem = (KOListViewItem *)item;
992 if (mActiveItem) { 998 if (mActiveItem) {
993 Incidence *incidence = mActiveItem->data(); 999 Incidence *incidence = mActiveItem->data();
994 mPopupMenu->showIncidencePopup(incidence); 1000 mPopupMenu->showIncidencePopup(incidence);
995 1001
996 /* 1002 /*
997 if ( incidence && incidence->type() == "Event" ) { 1003 if ( incidence && incidence->type() == "Event" ) {
998 Event *event = static_cast<Event *>( incidence ); 1004 Event *event = static_cast<Event *>( incidence );
999 mPopupMenu->showEventPopup(event); 1005 mPopupMenu->showEventPopup(event);
1000 } 1006 }
1001 */ 1007 */
1002 } 1008 }
1003} 1009}
1004 1010
1005void KOListView::readSettings(KConfig *config, QString setting) 1011void KOListView::readSettings(KConfig *config, QString setting)
1006{ 1012{
1007 // qDebug("KOListView::readSettings "); 1013 // qDebug("KOListView::readSettings ");
1008 mListView->restoreLayout(config,setting); 1014 mListView->restoreLayout(config,setting);
1009} 1015}
1010 1016
1011void KOListView::writeSettings(KConfig *config, QString setting) 1017void KOListView::writeSettings(KConfig *config, QString setting)
1012{ 1018{
1013 // qDebug("KOListView::writeSettings "); 1019 // qDebug("KOListView::writeSettings ");
1014 mListView->saveLayout(config, setting); 1020 mListView->saveLayout(config, setting);
1015} 1021}
1016 1022
1017void KOListView::processSelectionChange(QListViewItem *) 1023void KOListView::processSelectionChange(QListViewItem *)
1018{ 1024{
1019 1025
1020 KOListViewItem *item = 1026 KOListViewItem *item =
1021 static_cast<KOListViewItem *>( mListView->currentItem() ); 1027 static_cast<KOListViewItem *>( mListView->currentItem() );
1022 1028
1023 if ( !item ) { 1029 if ( !item ) {
1024 emit incidenceSelected( 0 ); 1030 emit incidenceSelected( 0 );
1025 } else { 1031 } else {
1026 emit incidenceSelected( item->data() ); 1032 emit incidenceSelected( item->data() );
1027 } 1033 }
1028} 1034}
1029 1035
1030void KOListView::clearSelection() 1036void KOListView::clearSelection()
1031{ 1037{
1032 mListView->selectAll( false ); 1038 mListView->selectAll( false );
1033} 1039}
1034void KOListView::allSelection() 1040void KOListView::allSelection()
1035{ 1041{
1036 mListView->selectAll( true ); 1042 mListView->selectAll( true );
1037} 1043}
1038 1044
1039void KOListView::clear() 1045void KOListView::clear()
1040{ 1046{
1041 mListView->clear(); 1047 mListView->clear();
1042 mUidDict.clear(); 1048 mUidDict.clear();
1043} 1049}
1044 1050
1045Incidence* KOListView::currentItem() 1051Incidence* KOListView::currentItem()
1046{ 1052{
1047 if ( mListView->currentItem() ) 1053 if ( mListView->currentItem() )
1048 return ((KOListViewItem*) mListView->currentItem())->data(); 1054 return ((KOListViewItem*) mListView->currentItem())->data();
1049 return 0; 1055 return 0;
1050} 1056}
1051void KOListView::keyPressEvent ( QKeyEvent *e) 1057void KOListView::keyPressEvent ( QKeyEvent *e)
1052{ 1058{
1053 1059
1054 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1060 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1055 deleteAll(); 1061 deleteAll();
1056 return; 1062 return;
1057 } 1063 }
1058 1064
1059 e->ignore(); 1065 e->ignore();
1060} 1066}
1061void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1067void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1062{ 1068{
1063 1069
1064 switch ( e->key() ) { 1070 switch ( e->key() ) {
1065 case Qt::Key_Down: 1071 case Qt::Key_Down:
1066 if ( e->state() == ShiftButton ) { 1072 if ( e->state() == ShiftButton ) {
1067 QListViewItem* cn = currentItem(); 1073 QListViewItem* cn = currentItem();
1068 if ( !cn ) 1074 if ( !cn )
1069 cn = firstChild(); 1075 cn = firstChild();
1070 if ( !cn ) 1076 if ( !cn )
1071 return; 1077 return;
1072 while ( cn->nextSibling() ) 1078 while ( cn->nextSibling() )
1073 cn = cn->nextSibling(); 1079 cn = cn->nextSibling();
1074 setCurrentItem ( cn ); 1080 setCurrentItem ( cn );
1075 ensureItemVisible ( cn ); 1081 ensureItemVisible ( cn );
1076 1082
1077 e->accept(); 1083 e->accept();
1078 return; 1084 return;
1079 } 1085 }
1080 if ( e->state() == ControlButton ) { 1086 if ( e->state() == ControlButton ) {
1081 int count = childCount (); 1087 int count = childCount ();
1082 int jump = count / 5; 1088 int jump = count / 5;
1083 QListViewItem* cn; 1089 QListViewItem* cn;
1084 cn = currentItem(); 1090 cn = currentItem();
1085 if ( ! cn ) 1091 if ( ! cn )
1086 return; 1092 return;
1087 if ( jump == 0 ) 1093 if ( jump == 0 )
1088 jump = 1; 1094 jump = 1;
1089 while ( jump && cn->nextSibling() ) { 1095 while ( jump && cn->nextSibling() ) {
1090 cn = cn->nextSibling(); 1096 cn = cn->nextSibling();
1091 --jump; 1097 --jump;
1092 } 1098 }
1093 setCurrentItem ( cn ); 1099 setCurrentItem ( cn );
1094 ensureItemVisible ( cn ); 1100 ensureItemVisible ( cn );
1095 1101
1096 } else 1102 } else
1097 QListView::keyPressEvent ( e ) ; 1103 QListView::keyPressEvent ( e ) ;
1098 e->accept(); 1104 e->accept();
1099 break; 1105 break;
1100 1106
1101 case Qt::Key_Up: 1107 case Qt::Key_Up:
1102 if ( e->state() == ShiftButton ) { 1108 if ( e->state() == ShiftButton ) {
1103 QListViewItem* cn = firstChild(); 1109 QListViewItem* cn = firstChild();
1104 if ( cn ) { 1110 if ( cn ) {
1105 setCurrentItem ( cn ); 1111 setCurrentItem ( cn );
1106 ensureItemVisible ( cn ); 1112 ensureItemVisible ( cn );
1107 } 1113 }
1108 e->accept(); 1114 e->accept();
1109 return; 1115 return;
1110 } 1116 }
1111 if ( e->state() == ControlButton ) { 1117 if ( e->state() == ControlButton ) {
1112 int count = childCount (); 1118 int count = childCount ();
1113 int jump = count / 5; 1119 int jump = count / 5;
1114 QListViewItem* cn; 1120 QListViewItem* cn;
1115 cn = currentItem(); 1121 cn = currentItem();
1116 if ( ! cn ) 1122 if ( ! cn )
1117 return; 1123 return;
1118 if ( jump == 0 ) 1124 if ( jump == 0 )
1119 jump = 1; 1125 jump = 1;
1120 while ( jump && cn->itemAbove ()) { 1126 while ( jump && cn->itemAbove ()) {
1121 cn = cn->itemAbove (); 1127 cn = cn->itemAbove ();
1122 --jump; 1128 --jump;
1123 } 1129 }
1124 setCurrentItem ( cn ); 1130 setCurrentItem ( cn );
1125 ensureItemVisible ( cn ); 1131 ensureItemVisible ( cn );
1126 } else 1132 } else
1127 QListView::keyPressEvent ( e ) ; 1133 QListView::keyPressEvent ( e ) ;
1128 e->accept(); 1134 e->accept();
1129 break; 1135 break;
1130 case Qt::Key_I: { 1136 case Qt::Key_I: {
1131 QListViewItem* cn; 1137 QListViewItem* cn;
1132 cn = currentItem(); 1138 cn = currentItem();
1133 if ( cn ) { 1139 if ( cn ) {
1134 KOListViewItem* ci = (KOListViewItem*)( cn ); 1140 KOListViewItem* ci = (KOListViewItem*)( cn );
1135 if ( ci ){ 1141 if ( ci ){
1136 //emit showIncidence( ci->data()); 1142 //emit showIncidence( ci->data());
1137 cn = cn->nextSibling(); 1143 cn = cn->nextSibling();
1138 if ( cn ) { 1144 if ( cn ) {
1139 setCurrentItem ( cn ); 1145 setCurrentItem ( cn );
1140 ensureItemVisible ( cn ); 1146 ensureItemVisible ( cn );
1141 } 1147 }
1142 emit showIncidence( ci->data()); 1148 emit showIncidence( ci->data());
1143 } 1149 }
1144 } 1150 }
1145 e->accept(); 1151 e->accept();
1146 } 1152 }
1147 break; 1153 break;
1148 case Qt::Key_Return: 1154 case Qt::Key_Return:
1149 case Qt::Key_Enter: 1155 case Qt::Key_Enter:
1150 { 1156 {
1151 QListViewItem* cn; 1157 QListViewItem* cn;
1152 cn = currentItem(); 1158 cn = currentItem();
1153 if ( cn ) { 1159 if ( cn ) {
1154 KOListViewItem* ci = (KOListViewItem*)( cn ); 1160 KOListViewItem* ci = (KOListViewItem*)( cn );
1155 if ( ci ){ 1161 if ( ci ){
1156 if ( e->state() == ShiftButton ) 1162 if ( e->state() == ShiftButton )
1157 ci->setSelected( false ); 1163 ci->setSelected( false );
1158 else 1164 else
1159 ci->setSelected( true ); 1165 ci->setSelected( true );
1160 cn = cn->nextSibling(); 1166 cn = cn->nextSibling();
1161 if ( cn ) { 1167 if ( cn ) {
1162 setCurrentItem ( cn ); 1168 setCurrentItem ( cn );
1163 ensureItemVisible ( cn ); 1169 ensureItemVisible ( cn );
1164 } 1170 }
1165 } 1171 }
1166 } 1172 }
1167 e->accept(); 1173 e->accept();
1168 } 1174 }
1169 break; 1175 break;
1170 default: 1176 default:
1171 e->ignore(); 1177 e->ignore();
1172 } 1178 }
1173} 1179}
1174KOListViewListView::KOListViewListView(KOListView * lv ) 1180KOListViewListView::KOListViewListView(KOListView * lv )
1175 : KListView( lv, "kolistlistview", false ) 1181 : KListView( lv, "kolistlistview", false )
1176{ 1182{
1177 mPopupTimer = new QTimer(this); 1183 mPopupTimer = new QTimer(this);
1178 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1184 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1179#ifndef DESKTOP_VERSION 1185#ifndef DESKTOP_VERSION
1180 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1186 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1181#endif 1187#endif
1182 setSelectionMode( QListView::Multi ); 1188 setSelectionMode( QListView::Multi );
1183 setMultiSelection( true); 1189 setMultiSelection( true);
1184} 1190}
1185void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1191void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1186{ 1192{
1187 if (!e) return; 1193 if (!e) return;
1188 QPoint vp = contentsToViewport(e->pos()); 1194 QPoint vp = contentsToViewport(e->pos());
1189 QListViewItem *item = itemAt(vp); 1195 QListViewItem *item = itemAt(vp);
1190 if (!item) { 1196 if (!item) {
1191 emit newEvent(); 1197 emit newEvent();
1192 return; 1198 return;
1193 } 1199 }
1194 KListView::contentsMouseDoubleClickEvent(e); 1200 KListView::contentsMouseDoubleClickEvent(e);
1195} 1201}
1196#if 0 1202#if 0
1197void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1203void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1198{ 1204{
1199 //qDebug("contentsMousePressEvent++++ "); 1205 //qDebug("contentsMousePressEvent++++ ");
1200 KListView::contentsMousePressEvent( e ); 1206 KListView::contentsMousePressEvent( e );
1201 if ( e->button() == RightButton ) { 1207 if ( e->button() == RightButton ) {
1202 QListViewItem* ci = currentItem(); 1208 QListViewItem* ci = currentItem();
1203 clearSelection () ; 1209 clearSelection () ;
1204 if ( ci ) 1210 if ( ci )
1205 ci->setSelected( true ); 1211 ci->setSelected( true );
1206 } 1212 }
1207} 1213}
1208void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1214void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1209{ 1215{
1210 KListView::contentsMouseReleaseEvent(e); 1216 KListView::contentsMouseReleaseEvent(e);
1211} 1217}
1212void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1218void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1213{ 1219{
1214 KListView::contentsMouseMoveEvent(e); 1220 KListView::contentsMouseMoveEvent(e);
1215} 1221}
1216#endif 1222#endif
1217void KOListViewListView::popupMenu() 1223void KOListViewListView::popupMenu()
1218{ 1224{
1219 mPopupTimer->stop(); 1225 mPopupTimer->stop();
1220 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1226 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1221 QApplication::postEvent( this->viewport(), e ); 1227 QApplication::postEvent( this->viewport(), e );
1222 1228
1223} 1229}
1224void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1230void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1225{ 1231{
1226 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1232 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1227 mYMousePos = mapToGlobal( (e->pos())).y(); 1233 mYMousePos = mapToGlobal( (e->pos())).y();
1228 if ( e->button() == LeftButton ) { 1234 if ( e->button() == LeftButton ) {
1229 mPopupTimer->start( 600 ); 1235 mPopupTimer->start( 600 );
1230 mEventPos = contentsToViewport(e->pos()); 1236 mEventPos = contentsToViewport(e->pos());
1231 mEventGlobalPos = e->globalPos(); 1237 mEventGlobalPos = e->globalPos();
1232 } 1238 }
1233 KListView::contentsMousePressEvent( e ); 1239 KListView::contentsMousePressEvent( e );
1234 if ( e->button() == RightButton ) { 1240 if ( e->button() == RightButton ) {
1235 QListViewItem* ci = currentItem(); 1241 QListViewItem* ci = currentItem();
1236 //clearSelection(); 1242 //clearSelection();
1237 if ( ci ) 1243 if ( ci )
1238 ci->setSelected( true ); 1244 ci->setSelected( true );
1239 } 1245 }
1240} 1246}
1241void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1247void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1242{ 1248{
1243 mPopupTimer->stop(); 1249 mPopupTimer->stop();
1244 KListView::contentsMouseReleaseEvent(e); 1250 KListView::contentsMouseReleaseEvent(e);
1245} 1251}
1246void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1252void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1247{ 1253{
1248 // qDebug("contentsMouseMoveEv....... "); 1254 // qDebug("contentsMouseMoveEv....... ");
1249 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1255 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1250 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1256 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1251 if ( diff < 0 ) diff = -diff; 1257 if ( diff < 0 ) diff = -diff;
1252 if ( diff > 15 ) 1258 if ( diff > 15 )
1253 mPopupTimer->stop(); 1259 mPopupTimer->stop();
1254 else { 1260 else {
1255 mEventPos = contentsToViewport(e->pos()); 1261 mEventPos = contentsToViewport(e->pos());
1256 mEventGlobalPos = e->globalPos(); 1262 mEventGlobalPos = e->globalPos();
1257 } 1263 }
1258 KListView::contentsMouseMoveEvent(e); 1264 KListView::contentsMouseMoveEvent(e);
1259} 1265}
1260 1266