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