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