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