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