summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index a1bf9ff..bbf83d9 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,505 +1,511 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kglobal.h> 41#include <kglobal.h>
42 42
43#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
44#include <libkcal/calendar.h> 44#include <libkcal/calendar.h>
45#include <libkcal/calendarlocal.h> 45#include <libkcal/calendarlocal.h>
46#include <libkcal/icalformat.h> 46#include <libkcal/icalformat.h>
47#include <libkcal/vcalformat.h> 47#include <libkcal/vcalformat.h>
48#include <libkcal/recurrence.h> 48#include <libkcal/recurrence.h>
49#include <libkcal/filestorage.h> 49#include <libkcal/filestorage.h>
50#include <libkdepim/categoryselectdialog.h> 50#include <libkdepim/categoryselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57 57
58#ifndef KORG_NOPRINTER 58#ifndef KORG_NOPRINTER
59#include "calprinter.h" 59#include "calprinter.h"
60#endif 60#endif
61#include "koglobals.h" 61#include "koglobals.h"
62#include "koprefs.h" 62#include "koprefs.h"
63#include "kfiledialog.h" 63#include "kfiledialog.h"
64 64
65#include "kolistview.h" 65#include "kolistview.h"
66 66
67 67
68 68
69 69
70class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
71{ 71{
72public: 72public:
73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
74 74
75protected: 75protected:
76 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
77 { 77 {
78 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
79 } 79 }
80private: 80private:
81 QWidget* _wid; 81 QWidget* _wid;
82 KOListView * _view; 82 KOListView * _view;
83}; 83};
84 84
85 85
86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
87{ 87{
88 mItem = item; 88 mItem = item;
89 mDate = date; 89 mDate = date;
90} 90}
91 91
92ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
93{ 93{
94} 94}
95 95
96bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
97{ 97{
98 bool ok = false; 98 bool ok = false;
99 QString start, end; 99 QString start, end;
100 QDate ds, de; 100 QDate ds, de;
101 if ( e->doesRecur() ) { 101 if ( e->doesRecur() ) {
102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
103 if ( ok ) { 103 if ( ok ) {
104 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 104 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
105 start = KGlobal::locale()->formatDate(ds,true); 105 start = KGlobal::locale()->formatDate(ds,true);
106 de = ds.addDays( days); 106 de = ds.addDays( days);
107 end = KGlobal::locale()->formatDate(de,true); 107 end = KGlobal::locale()->formatDate(de,true);
108 } 108 }
109 109
110 } 110 }
111 if ( ! ok ) { 111 if ( ! ok ) {
112 start =e->dtStartDateStr(); 112 start =e->dtStartDateStr();
113 end = e->dtEndDateStr(); 113 end = e->dtEndDateStr();
114 ds = e->dtStart().date(); 114 ds = e->dtStart().date();
115 de = e->dtEnd().date(); 115 de = e->dtEnd().date();
116 } 116 }
117 mItem->setText(0,e->summary()); 117 mItem->setText(0,e->summary());
118 mItem->setText(1,start); 118 mItem->setText(1,start);
119 mItem->setText(2,e->dtStartTimeStr()); 119 if ( e->doesFloat() )
120 mItem->setText(2,"---");
121 else
122 mItem->setText(2,e->dtStartTimeStr());
120 mItem->setText(3,end); 123 mItem->setText(3,end);
121 mItem->setText(4,e->dtEndTimeStr()); 124 if ( e->doesFloat() )
125 mItem->setText(4,"---");
126 else
127 mItem->setText(4,e->dtEndTimeStr());
122 if ( e->isAlarmEnabled() ) { 128 if ( e->isAlarmEnabled() ) {
123 mItem->setText(5,e->alarms().first()->offsetText() ); 129 mItem->setText(5,e->alarms().first()->offsetText() );
124 } else { 130 } else {
125 mItem->setText(5, i18n("No")); 131 mItem->setText(5, i18n("No"));
126 } 132 }
127 mItem->setText(6, e->recurrence()->recurrenceText()); 133 mItem->setText(6, e->recurrence()->recurrenceText());
128 if( ! e->doesRecur() ) 134 if( ! e->doesRecur() )
129 mItem->setSortKey( 6, "-" ); 135 mItem->setSortKey( 6, "-" );
130 mItem->setText(7,"---"); 136 mItem->setText(7,"---");
131 mItem->setText(8,"---"); 137 mItem->setText(8,"---");
132 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
133 mItem->setText(10,e->categoriesStr()); 139 mItem->setText(10,e->categoriesStr());
134 140
135 QString key; 141 QString key;
136 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 142 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
137 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 143 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
138 mItem->setSortKey(1,key); 144 mItem->setSortKey(1,key);
139 145
140 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 146 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
141 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 147 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
142 mItem->setSortKey(3,key); 148 mItem->setSortKey(3,key);
143 return true; 149 return true;
144} 150}
145 151
146bool ListItemVisitor::visit(Todo *t) 152bool ListItemVisitor::visit(Todo *t)
147{ 153{
148 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 154 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
149 if (t->hasStartDate()) { 155 if (t->hasStartDate()) {
150 mItem->setText(1,t->dtStartDateStr()); 156 mItem->setText(1,t->dtStartDateStr());
151 if (t->doesFloat()) { 157 if (t->doesFloat()) {
152 mItem->setText(2,"---"); 158 mItem->setText(2,"---");
153 } else { 159 } else {
154 mItem->setText(2,t->dtStartTimeStr()); 160 mItem->setText(2,t->dtStartTimeStr());
155 } 161 }
156 } else { 162 } else {
157 mItem->setText(1,"---"); 163 mItem->setText(1,"---");
158 mItem->setText(2,"---"); 164 mItem->setText(2,"---");
159 } 165 }
160 mItem->setText(3,"---"); 166 mItem->setText(3,"---");
161 mItem->setText(4,"---"); 167 mItem->setText(4,"---");
162 if ( t->isAlarmEnabled() ) { 168 if ( t->isAlarmEnabled() ) {
163 mItem->setText(5,t->alarms().first()->offsetText() ); 169 mItem->setText(5,t->alarms().first()->offsetText() );
164 } else { 170 } else {
165 mItem->setText(5, i18n("No")); 171 mItem->setText(5, i18n("No"));
166 } 172 }
167 mItem->setText(6, t->recurrence()->recurrenceText()); 173 mItem->setText(6, t->recurrence()->recurrenceText());
168 if( ! t->doesRecur() ) 174 if( ! t->doesRecur() )
169 mItem->setSortKey( 6, "-" ); 175 mItem->setSortKey( 6, "-" );
170 if (t->hasDueDate()) { 176 if (t->hasDueDate()) {
171 mItem->setText(7,t->dtDueDateStr()); 177 mItem->setText(7,t->dtDueDateStr());
172 if (t->doesFloat()) { 178 if (t->doesFloat()) {
173 mItem->setText(8,"---"); 179 mItem->setText(8,"---");
174 } else { 180 } else {
175 mItem->setText(8,t->dtDueTimeStr()); 181 mItem->setText(8,t->dtDueTimeStr());
176 } 182 }
177 } else { 183 } else {
178 mItem->setText(7,"---"); 184 mItem->setText(7,"---");
179 mItem->setText(8,"---"); 185 mItem->setText(8,"---");
180 } 186 }
181 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 187 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
182 mItem->setText(10,t->categoriesStr()); 188 mItem->setText(10,t->categoriesStr());
183 189
184 QString key; 190 QString key;
185 QDate d; 191 QDate d;
186 if (t->hasDueDate()) { 192 if (t->hasDueDate()) {
187 d = t->dtDue().date(); 193 d = t->dtDue().date();
188 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
189 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
190 mItem->setSortKey(7,key); 196 mItem->setSortKey(7,key);
191 } 197 }
192 if ( t->hasStartDate() ) { 198 if ( t->hasStartDate() ) {
193 d = t->dtStart().date(); 199 d = t->dtStart().date();
194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 200 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 201 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
196 mItem->setSortKey(1,key); 202 mItem->setSortKey(1,key);
197 } 203 }
198 return true; 204 return true;
199} 205}
200 206
201bool ListItemVisitor::visit(Journal * j) 207bool ListItemVisitor::visit(Journal * j)
202{ 208{
203 QString des = j->description().left(30); 209 QString des = j->description().left(30);
204 des = des.simplifyWhiteSpace (); 210 des = des.simplifyWhiteSpace ();
205 des.replace (QRegExp ("\\n"),"" ); 211 des.replace (QRegExp ("\\n"),"" );
206 des.replace (QRegExp ("\\r"),"" ); 212 des.replace (QRegExp ("\\r"),"" );
207 mItem->setText(0,i18n("Journal: ")+des.left(25)); 213 mItem->setText(0,i18n("Journal: ")+des.left(25));
208 mItem->setText(1,j->dtStartDateStr()); 214 mItem->setText(1,j->dtStartDateStr());
209 mItem->setText(2,"---"); 215 mItem->setText(2,"---");
210 mItem->setText(3,"---"); 216 mItem->setText(3,"---");
211 mItem->setText(4,"---"); 217 mItem->setText(4,"---");
212 mItem->setText(5,"---"); 218 mItem->setText(5,"---");
213 mItem->setText(6,"---"); 219 mItem->setText(6,"---");
214 mItem->setText(7,j->dtStartDateStr()); 220 mItem->setText(7,j->dtStartDateStr());
215 mItem->setText(8,"---"); 221 mItem->setText(8,"---");
216 mItem->setText(9,"---"); 222 mItem->setText(9,"---");
217 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 223 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
218 224
219 QString key; 225 QString key;
220 QDate d = j->dtStart().date(); 226 QDate d = j->dtStart().date();
221 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 227 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
222 mItem->setSortKey(1,key); 228 mItem->setSortKey(1,key);
223 mItem->setSortKey(7,key); 229 mItem->setSortKey(7,key);
224 230
225 return true; 231 return true;
226} 232}
227 233
228KOListView::KOListView(Calendar *calendar, QWidget *parent, 234KOListView::KOListView(Calendar *calendar, QWidget *parent,
229 const char *name) 235 const char *name)
230 : KOEventView(calendar, parent, name) 236 : KOEventView(calendar, parent, name)
231{ 237{
232 mActiveItem = 0; 238 mActiveItem = 0;
233 mListView = new KOListViewListView(this); 239 mListView = new KOListViewListView(this);
234 mListView->addColumn(i18n("Summary")); 240 mListView->addColumn(i18n("Summary"));
235 mListView->addColumn(i18n("Start Date")); 241 mListView->addColumn(i18n("Start Date"));
236 mListView->addColumn(i18n("Start Time")); 242 mListView->addColumn(i18n("Start Time"));
237 mListView->addColumn(i18n("End Date")); 243 mListView->addColumn(i18n("End Date"));
238 mListView->addColumn(i18n("End Time")); 244 mListView->addColumn(i18n("End Time"));
239 mListView->addColumn(i18n("Alarm")); // alarm set? 245 mListView->addColumn(i18n("Alarm")); // alarm set?
240 mListView->addColumn(i18n("Recurs")); // recurs? 246 mListView->addColumn(i18n("Recurs")); // recurs?
241 mListView->addColumn(i18n("Due Date")); 247 mListView->addColumn(i18n("Due Date"));
242 mListView->addColumn(i18n("Due Time")); 248 mListView->addColumn(i18n("Due Time"));
243 mListView->addColumn(i18n("Cancelled")); 249 mListView->addColumn(i18n("Cancelled"));
244 mListView->addColumn(i18n("Categories")); 250 mListView->addColumn(i18n("Categories"));
245 251
246 mListView->setColumnAlignment(0,AlignLeft); 252 mListView->setColumnAlignment(0,AlignLeft);
247 mListView->setColumnAlignment(1,AlignLeft); 253 mListView->setColumnAlignment(1,AlignLeft);
248 mListView->setColumnAlignment(2,AlignHCenter); 254 mListView->setColumnAlignment(2,AlignHCenter);
249 mListView->setColumnAlignment(3,AlignLeft); 255 mListView->setColumnAlignment(3,AlignLeft);
250 mListView->setColumnAlignment(4,AlignHCenter); 256 mListView->setColumnAlignment(4,AlignHCenter);
251 mListView->setColumnAlignment(5,AlignLeft); 257 mListView->setColumnAlignment(5,AlignLeft);
252 mListView->setColumnAlignment(6,AlignLeft); 258 mListView->setColumnAlignment(6,AlignLeft);
253 mListView->setColumnAlignment(7,AlignLeft); 259 mListView->setColumnAlignment(7,AlignLeft);
254 mListView->setColumnAlignment(8,AlignLeft); 260 mListView->setColumnAlignment(8,AlignLeft);
255 mListView->setColumnAlignment(9,AlignLeft); 261 mListView->setColumnAlignment(9,AlignLeft);
256 mListView->setColumnAlignment(10,AlignLeft); 262 mListView->setColumnAlignment(10,AlignLeft);
257 mListView->setColumnWidthMode(10, QListView::Manual); 263 mListView->setColumnWidthMode(10, QListView::Manual);
258 new KOListViewWhatsThis(mListView->viewport(),this); 264 new KOListViewWhatsThis(mListView->viewport(),this);
259 265
260 int iii = 0; 266 int iii = 0;
261 for ( iii = 0; iii< 10 ; ++iii ) 267 for ( iii = 0; iii< 10 ; ++iii )
262 mListView->setColumnWidthMode( iii, QListView::Manual ); 268 mListView->setColumnWidthMode( iii, QListView::Manual );
263 269
264 QBoxLayout *layoutTop = new QVBoxLayout(this); 270 QBoxLayout *layoutTop = new QVBoxLayout(this);
265 layoutTop->addWidget(mListView); 271 layoutTop->addWidget(mListView);
266 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 272 mListView->setFont ( KOPrefs::instance()->mListViewFont );
267 mPopupMenu = eventPopup(); 273 mPopupMenu = eventPopup();
268 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
269 i18n("Select all"),this, 275 i18n("Select all"),this,
270 SLOT(allSelection()),true); 276 SLOT(allSelection()),true);
271 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
272 i18n("Deselect all"),this, 278 i18n("Deselect all"),this,
273 SLOT(clearSelection()),true); 279 SLOT(clearSelection()),true);
274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
275 i18n("Delete all selected"),this, 281 i18n("Delete all selected"),this,
276 SLOT(deleteAll()),true); 282 SLOT(deleteAll()),true);
277 mPopupMenu->insertSeparator(); 283 mPopupMenu->insertSeparator();
278 QPopupMenu * exportPO = new QPopupMenu ( this ); 284 QPopupMenu * exportPO = new QPopupMenu ( this );
279 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 285 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
280 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 286 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
281 SLOT(saveToFile())); 287 SLOT(saveToFile()));
282 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
283 SLOT(saveToFileVCS())); 289 SLOT(saveToFileVCS()));
284 exportPO->insertItem( i18n("Journal/Details..."),this, 290 exportPO->insertItem( i18n("Journal/Details..."),this,
285 SLOT(saveDescriptionToFile())); 291 SLOT(saveDescriptionToFile()));
286 // mPopupMenu->insertSeparator(); 292 // mPopupMenu->insertSeparator();
287 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
288 i18n("Add Categ. to selected..."),this, 294 i18n("Add Categ. to selected..."),this,
289 SLOT(addCat()),true); 295 SLOT(addCat()),true);
290 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
291 i18n("Set Categ. for selected..."),this, 297 i18n("Set Categ. for selected..."),this,
292 SLOT(setCat()),true); 298 SLOT(setCat()),true);
293 //mPopupMenu->insertSeparator(); 299 //mPopupMenu->insertSeparator();
294 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
295 i18n("Set alarm for selected..."),this, 301 i18n("Set alarm for selected..."),this,
296 SLOT(setAlarm()),true); 302 SLOT(setAlarm()),true);
297 303
298 304
299#ifndef DESKTOP_VERSION 305#ifndef DESKTOP_VERSION
300 mPopupMenu->insertSeparator(); 306 mPopupMenu->insertSeparator();
301 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
302 i18n("Beam selected via IR"),this, 308 i18n("Beam selected via IR"),this,
303 SLOT(beamSelected()),true); 309 SLOT(beamSelected()),true);
304#endif 310#endif
305 /* 311 /*
306 mPopupMenu = new QPopupMenu; 312 mPopupMenu = new QPopupMenu;
307 mPopupMenu->insertItem(i18n("Edit Event"), this, 313 mPopupMenu->insertItem(i18n("Edit Event"), this,
308 SLOT (editEvent())); 314 SLOT (editEvent()));
309 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
310 SLOT (deleteEvent())); 316 SLOT (deleteEvent()));
311 mPopupMenu->insertSeparator(); 317 mPopupMenu->insertSeparator();
312 mPopupMenu->insertItem(i18n("Show Dates"), this, 318 mPopupMenu->insertItem(i18n("Show Dates"), this,
313 SLOT(showDates())); 319 SLOT(showDates()));
314 mPopupMenu->insertItem(i18n("Hide Dates"), this, 320 mPopupMenu->insertItem(i18n("Hide Dates"), this,
315 SLOT(hideDates())); 321 SLOT(hideDates()));
316 */ 322 */
317 QObject::connect(mListView,SIGNAL( newEvent()), 323 QObject::connect(mListView,SIGNAL( newEvent()),
318 this,SIGNAL(signalNewEvent())); 324 this,SIGNAL(signalNewEvent()));
319 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
320 this,SLOT(defaultItemAction(QListViewItem *))); 326 this,SLOT(defaultItemAction(QListViewItem *)));
321 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
322 const QPoint &, int )), 328 const QPoint &, int )),
323 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
324 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
325 SLOT(processSelectionChange(QListViewItem *))); 331 SLOT(processSelectionChange(QListViewItem *)));
326 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
327 SIGNAL(showIncidenceSignal(Incidence *)) ); 333 SIGNAL(showIncidenceSignal(Incidence *)) );
328 334
329 readSettings(KOGlobals::config(),"KOListView Layout"); 335 readSettings(KOGlobals::config(),"KOListView Layout");
330} 336}
331 337
332KOListView::~KOListView() 338KOListView::~KOListView()
333{ 339{
334 delete mPopupMenu; 340 delete mPopupMenu;
335} 341}
336 342
337QString KOListView::getWhatsThisText(QPoint p) 343QString KOListView::getWhatsThisText(QPoint p)
338{ 344{
339 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 345 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
340 if ( item ) 346 if ( item )
341 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 347 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
342 KOPrefs::instance()->mWTshowDetails, 348 KOPrefs::instance()->mWTshowDetails,
343 KOPrefs::instance()->mWTshowCreated, 349 KOPrefs::instance()->mWTshowCreated,
344 KOPrefs::instance()->mWTshowChanged); 350 KOPrefs::instance()->mWTshowChanged);
345 return i18n("That is the list view" ); 351 return i18n("That is the list view" );
346 352
347} 353}
348 354
349void KOListView::updateList() 355void KOListView::updateList()
350{ 356{
351 // qDebug(" KOListView::updateList() "); 357 // qDebug(" KOListView::updateList() ");
352 358
353} 359}
354 360
355void KOListView::addCat( ) 361void KOListView::addCat( )
356{ 362{
357 setCategories( false ); 363 setCategories( false );
358} 364}
359void KOListView::setCat() 365void KOListView::setCat()
360{ 366{
361 setCategories( true ); 367 setCategories( true );
362} 368}
363void KOListView::setAlarm() 369void KOListView::setAlarm()
364{ 370{
365 KOAlarmPrefs kap( this); 371 KOAlarmPrefs kap( this);
366 if ( !kap.exec() ) 372 if ( !kap.exec() )
367 return; 373 return;
368 374
369 375
370 QStringList itemList; 376 QStringList itemList;
371 QPtrList<KOListViewItem> sel ; 377 QPtrList<KOListViewItem> sel ;
372 QListViewItem *qitem = mListView->firstChild (); 378 QListViewItem *qitem = mListView->firstChild ();
373 while ( qitem ) { 379 while ( qitem ) {
374 if ( qitem->isSelected() ) { 380 if ( qitem->isSelected() ) {
375 Incidence* inc = ((KOListViewItem *) qitem)->data(); 381 Incidence* inc = ((KOListViewItem *) qitem)->data();
376 if ( inc->type() != "Journal" ) { 382 if ( inc->type() != "Journal" ) {
377 if ( inc->type() == "Todo" ) { 383 if ( inc->type() == "Todo" ) {
378 if ( ((Todo*)inc)->hasDueDate() ) 384 if ( ((Todo*)inc)->hasDueDate() )
379 sel.append(((KOListViewItem *)qitem)); 385 sel.append(((KOListViewItem *)qitem));
380 } else 386 } else
381 sel.append(((KOListViewItem *)qitem)); 387 sel.append(((KOListViewItem *)qitem));
382 } 388 }
383 } 389 }
384 qitem = qitem->nextSibling(); 390 qitem = qitem->nextSibling();
385 } 391 }
386 int count = 0; 392 int count = 0;
387 KOListViewItem * item, *temp; 393 KOListViewItem * item, *temp;
388 item = sel.first(); 394 item = sel.first();
389 Incidence* inc; 395 Incidence* inc;
390 while ( item ) { 396 while ( item ) {
391 inc = item->data(); 397 inc = item->data();
392 ++count; 398 ++count;
393 if (kap.mAlarmButton->isChecked()) { 399 if (kap.mAlarmButton->isChecked()) {
394 if (inc->alarms().count() == 0) 400 if (inc->alarms().count() == 0)
395 inc->newAlarm(); 401 inc->newAlarm();
396 QPtrList<Alarm> alarms = inc->alarms(); 402 QPtrList<Alarm> alarms = inc->alarms();
397 Alarm *alarm; 403 Alarm *alarm;
398 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 404 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
399 alarm->setEnabled(true); 405 alarm->setEnabled(true);
400 int j = kap.mAlarmTimeEdit->value()* -60; 406 int j = kap.mAlarmTimeEdit->value()* -60;
401 if (kap.mAlarmIncrCombo->currentItem() == 1) 407 if (kap.mAlarmIncrCombo->currentItem() == 1)
402 j = j * 60; 408 j = j * 60;
403 else if (kap.mAlarmIncrCombo->currentItem() == 2) 409 else if (kap.mAlarmIncrCombo->currentItem() == 2)
404 j = j * (60 * 24); 410 j = j * (60 * 24);
405 alarm->setStartOffset( j ); 411 alarm->setStartOffset( j );
406 412
407 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 413 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
408 alarm->setProcedureAlarm(kap.mAlarmProgram); 414 alarm->setProcedureAlarm(kap.mAlarmProgram);
409 } 415 }
410 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 416 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
411 alarm->setAudioAlarm(kap.mAlarmSound); 417 alarm->setAudioAlarm(kap.mAlarmSound);
412 else 418 else
413 alarm->setType(Alarm::Invalid); 419 alarm->setType(Alarm::Invalid);
414 //alarm->setAudioAlarm("default"); 420 //alarm->setAudioAlarm("default");
415 // TODO: Deal with multiple alarms 421 // TODO: Deal with multiple alarms
416 break; // For now, stop after the first alarm 422 break; // For now, stop after the first alarm
417 } 423 }
418 } else { 424 } else {
419 Alarm* alarm = inc->alarms().first(); 425 Alarm* alarm = inc->alarms().first();
420 if ( alarm ) { 426 if ( alarm ) {
421 alarm->setEnabled(false); 427 alarm->setEnabled(false);
422 alarm->setType(Alarm::Invalid); 428 alarm->setType(Alarm::Invalid);
423 } 429 }
424 } 430 }
425 temp = item; 431 temp = item;
426 item = sel.next(); 432 item = sel.next();
427 mUidDict.remove( inc->uid() ); 433 mUidDict.remove( inc->uid() );
428 delete temp;; 434 delete temp;;
429 addIncidence( inc ); 435 addIncidence( inc );
430 } 436 }
431 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); 437 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) );
432 qDebug("KO: Set alarm for %d items", count); 438 qDebug("KO: Set alarm for %d items", count);
433 calendar()->reInitAlarmSettings(); 439 calendar()->reInitAlarmSettings();
434 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 440 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
435} 441}
436void KOListView::setCategories( bool removeOld ) 442void KOListView::setCategories( bool removeOld )
437{ 443{
438 444
439 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 445 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
440 if (! csd->exec()) { 446 if (! csd->exec()) {
441 delete csd; 447 delete csd;
442 return; 448 return;
443 } 449 }
444 QStringList catList = csd->selectedCategories(); 450 QStringList catList = csd->selectedCategories();
445 delete csd; 451 delete csd;
446 // if ( catList.count() == 0 ) 452 // if ( catList.count() == 0 )
447 // return; 453 // return;
448 catList.sort(); 454 catList.sort();
449 QString categoriesStr = catList.join(","); 455 QString categoriesStr = catList.join(",");
450 int i; 456 int i;
451 QStringList itemList; 457 QStringList itemList;
452 QPtrList<KOListViewItem> sel ; 458 QPtrList<KOListViewItem> sel ;
453 QListViewItem *qitem = mListView->firstChild (); 459 QListViewItem *qitem = mListView->firstChild ();
454 while ( qitem ) { 460 while ( qitem ) {
455 if ( qitem->isSelected() ) { 461 if ( qitem->isSelected() ) {
456 sel.append(((KOListViewItem *)qitem)); 462 sel.append(((KOListViewItem *)qitem));
457 } 463 }
458 qitem = qitem->nextSibling(); 464 qitem = qitem->nextSibling();
459 } 465 }
460 KOListViewItem * item, *temp; 466 KOListViewItem * item, *temp;
461 item = sel.first(); 467 item = sel.first();
462 Incidence* inc; 468 Incidence* inc;
463 while ( item ) { 469 while ( item ) {
464 inc = item->data(); 470 inc = item->data();
465 if ( removeOld ) { 471 if ( removeOld ) {
466 inc->setCategories( categoriesStr ); 472 inc->setCategories( categoriesStr );
467 } else { 473 } else {
468 itemList = QStringList::split (",", inc->categoriesStr() ); 474 itemList = QStringList::split (",", inc->categoriesStr() );
469 for( i = 0; i< catList.count(); ++i ) { 475 for( i = 0; i< catList.count(); ++i ) {
470 if ( !itemList.contains (catList[i])) 476 if ( !itemList.contains (catList[i]))
471 itemList.append( catList[i] ); 477 itemList.append( catList[i] );
472 } 478 }
473 itemList.sort(); 479 itemList.sort();
474 inc->setCategories( itemList.join(",") ); 480 inc->setCategories( itemList.join(",") );
475 } 481 }
476 temp = item; 482 temp = item;
477 item = sel.next(); 483 item = sel.next();
478 mUidDict.remove( inc->uid() ); 484 mUidDict.remove( inc->uid() );
479 delete temp;; 485 delete temp;;
480 addIncidence( inc ); 486 addIncidence( inc );
481 } 487 }
482 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 488 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
483} 489}
484 490
485void KOListView::beamSelected() 491void KOListView::beamSelected()
486{ 492{
487 int icount = 0; 493 int icount = 0;
488 QPtrList<Incidence> delSel ; 494 QPtrList<Incidence> delSel ;
489 QListViewItem *item = mListView->firstChild (); 495 QListViewItem *item = mListView->firstChild ();
490 while ( item ) { 496 while ( item ) {
491 if ( item->isSelected() ) { 497 if ( item->isSelected() ) {
492 delSel.append(((KOListViewItem *)item)->data()); 498 delSel.append(((KOListViewItem *)item)->data());
493 ++icount; 499 ++icount;
494 } 500 }
495 501
496 item = item->nextSibling(); 502 item = item->nextSibling();
497 } 503 }
498 if ( icount ) { 504 if ( icount ) {
499 emit beamIncidenceList( delSel ); 505 emit beamIncidenceList( delSel );
500 return; 506 return;
501 QString fn ; 507 QString fn ;
502 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 508 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
503 QString mes; 509 QString mes;
504 bool createbup = true; 510 bool createbup = true;
505 if ( createbup ) { 511 if ( createbup ) {