summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-23 14:56:10 (UTC)
committer zautrix <zautrix>2004-10-23 14:56:10 (UTC)
commita682b1d39c63cff8d709c67460569c70b661d889 (patch) (unidiff)
treedd5cb4052b07927b63bafa68b2fd6d40bce6a6dc /korganizer
parent73c0cb5307a8276f628765c651ef0284b85d64de (diff)
downloadkdepimpi-a682b1d39c63cff8d709c67460569c70b661d889.zip
kdepimpi-a682b1d39c63cff8d709c67460569c70b661d889.tar.gz
kdepimpi-a682b1d39c63cff8d709c67460569c70b661d889.tar.bz2
fixed several memory leaks
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp1
-rw-r--r--korganizer/koprefs.cpp10
-rw-r--r--korganizer/main.cpp3
3 files changed, 4 insertions, 10 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index d3aa650..3d4acb7 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1073 +1,1074 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qregexp.h> 35#include <qregexp.h>
36 36
37#include <klocale.h> 37#include <klocale.h>
38#include <kdebug.h> 38#include <kdebug.h>
39#include <kiconloader.h> 39#include <kiconloader.h>
40#include <kglobal.h> 40#include <kglobal.h>
41 41
42#include <libkdepim/kpimglobalprefs.h> 42#include <libkdepim/kpimglobalprefs.h>
43#include <libkcal/calendar.h> 43#include <libkcal/calendar.h>
44#include <libkcal/calendarlocal.h> 44#include <libkcal/calendarlocal.h>
45#include <libkcal/icalformat.h> 45#include <libkcal/icalformat.h>
46#include <libkcal/vcalformat.h> 46#include <libkcal/vcalformat.h>
47#include <libkcal/recurrence.h> 47#include <libkcal/recurrence.h>
48#include <libkcal/filestorage.h> 48#include <libkcal/filestorage.h>
49#include <libkdepim/categoryselectdialog.h> 49#include <libkdepim/categoryselectdialog.h>
50#ifndef DESKTOP_VERSION 50#ifndef DESKTOP_VERSION
51#include <qpe/qpeapplication.h> 51#include <qpe/qpeapplication.h>
52#else 52#else
53#include <qapplication.h> 53#include <qapplication.h>
54#endif 54#endif
55 55
56#ifndef KORG_NOPRINTER 56#ifndef KORG_NOPRINTER
57#include "calprinter.h" 57#include "calprinter.h"
58#endif 58#endif
59#include "koglobals.h" 59#include "koglobals.h"
60#include "koprefs.h" 60#include "koprefs.h"
61#include "kfiledialog.h" 61#include "kfiledialog.h"
62 62
63#include "kolistview.h" 63#include "kolistview.h"
64 64
65ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 65ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
66{ 66{
67 mItem = item; 67 mItem = item;
68 mDate = date; 68 mDate = date;
69} 69}
70 70
71ListItemVisitor::~ListItemVisitor() 71ListItemVisitor::~ListItemVisitor()
72{ 72{
73} 73}
74 74
75bool ListItemVisitor::visit(Event *e) 75bool ListItemVisitor::visit(Event *e)
76{ 76{
77 77
78 bool ok = false; 78 bool ok = false;
79 QString start, end; 79 QString start, end;
80 if ( e->doesRecur() ) { 80 if ( e->doesRecur() ) {
81 QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 81 QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
82 if ( ok ) { 82 if ( ok ) {
83 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 83 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
84 start = KGlobal::locale()->formatDate(d,true); 84 start = KGlobal::locale()->formatDate(d,true);
85 end = KGlobal::locale()->formatDate(d.addDays( days),true); 85 end = KGlobal::locale()->formatDate(d.addDays( days),true);
86 } 86 }
87 87
88 } 88 }
89 if ( ! ok ) { 89 if ( ! ok ) {
90 start =e->dtStartDateStr(); 90 start =e->dtStartDateStr();
91 end = e->dtEndDateStr(); 91 end = e->dtEndDateStr();
92 } 92 }
93 mItem->setText(0,e->summary()); 93 mItem->setText(0,e->summary());
94 mItem->setText(1,start); 94 mItem->setText(1,start);
95 mItem->setText(2,e->dtStartTimeStr()); 95 mItem->setText(2,e->dtStartTimeStr());
96 mItem->setText(3,end); 96 mItem->setText(3,end);
97 mItem->setText(4,e->dtEndTimeStr()); 97 mItem->setText(4,e->dtEndTimeStr());
98 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); 98 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No"));
99 mItem->setText(6, e->recurrence()->recurrenceText()); 99 mItem->setText(6, e->recurrence()->recurrenceText());
100 mItem->setText(7,"---"); 100 mItem->setText(7,"---");
101 mItem->setText(8,"---"); 101 mItem->setText(8,"---");
102 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 102 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
103 mItem->setText(10,e->categoriesStr()); 103 mItem->setText(10,e->categoriesStr());
104 104
105 QString key; 105 QString key;
106 QDate d = e->dtStart().date(); 106 QDate d = e->dtStart().date();
107 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 107 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
108 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); 108 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute());
109 mItem->setSortKey(1,key); 109 mItem->setSortKey(1,key);
110 110
111 d = e->dtEnd().date(); 111 d = e->dtEnd().date();
112 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 112 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
113 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); 113 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute());
114 mItem->setSortKey(3,key); 114 mItem->setSortKey(3,key);
115 115
116 return true; 116 return true;
117} 117}
118 118
119bool ListItemVisitor::visit(Todo *t) 119bool ListItemVisitor::visit(Todo *t)
120{ 120{
121 mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); 121 mItem->setText(0,i18n("To-Do: %1").arg(t->summary()));
122 if (t->hasStartDate()) { 122 if (t->hasStartDate()) {
123 mItem->setText(1,t->dtStartDateStr()); 123 mItem->setText(1,t->dtStartDateStr());
124 if (t->doesFloat()) { 124 if (t->doesFloat()) {
125 mItem->setText(2,"---"); 125 mItem->setText(2,"---");
126 } else { 126 } else {
127 mItem->setText(2,t->dtStartTimeStr()); 127 mItem->setText(2,t->dtStartTimeStr());
128 } 128 }
129 } else { 129 } else {
130 mItem->setText(1,"---"); 130 mItem->setText(1,"---");
131 mItem->setText(2,"---"); 131 mItem->setText(2,"---");
132 } 132 }
133 mItem->setText(3,"---"); 133 mItem->setText(3,"---");
134 mItem->setText(4,"---"); 134 mItem->setText(4,"---");
135 mItem->setText(5,"---"); 135 mItem->setText(5,"---");
136 mItem->setText(6,"---"); 136 mItem->setText(6,"---");
137 if (t->hasDueDate()) { 137 if (t->hasDueDate()) {
138 mItem->setText(7,t->dtDueDateStr()); 138 mItem->setText(7,t->dtDueDateStr());
139 if (t->doesFloat()) { 139 if (t->doesFloat()) {
140 mItem->setText(8,"---"); 140 mItem->setText(8,"---");
141 } else { 141 } else {
142 mItem->setText(8,t->dtDueTimeStr()); 142 mItem->setText(8,t->dtDueTimeStr());
143 } 143 }
144 } else { 144 } else {
145 mItem->setText(7,"---"); 145 mItem->setText(7,"---");
146 mItem->setText(8,"---"); 146 mItem->setText(8,"---");
147 } 147 }
148 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 148 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
149 mItem->setText(10,t->categoriesStr()); 149 mItem->setText(10,t->categoriesStr());
150 150
151 QString key; 151 QString key;
152 QDate d; 152 QDate d;
153 if (t->hasDueDate()) { 153 if (t->hasDueDate()) {
154 d = t->dtDue().date(); 154 d = t->dtDue().date();
155 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 155 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
156 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 156 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
157 mItem->setSortKey(7,key); 157 mItem->setSortKey(7,key);
158 } 158 }
159 if ( t->hasStartDate() ) { 159 if ( t->hasStartDate() ) {
160 d = t->dtStart().date(); 160 d = t->dtStart().date();
161 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 161 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
162 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 162 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
163 mItem->setSortKey(1,key); 163 mItem->setSortKey(1,key);
164 } 164 }
165 return true; 165 return true;
166} 166}
167 167
168bool ListItemVisitor::visit(Journal * j) 168bool ListItemVisitor::visit(Journal * j)
169{ 169{
170 QString des = j->description().left(50); 170 QString des = j->description().left(50);
171 des = des.simplifyWhiteSpace (); 171 des = des.simplifyWhiteSpace ();
172 des.replace (QRegExp ("\\n"),"" ); 172 des.replace (QRegExp ("\\n"),"" );
173 des.replace (QRegExp ("\\r"),"" ); 173 des.replace (QRegExp ("\\r"),"" );
174 mItem->setText(0,i18n("Journal")+": "+des.left(25)); 174 mItem->setText(0,i18n("Journal")+": "+des.left(25));
175 mItem->setText(1,j->dtStartDateStr()); 175 mItem->setText(1,j->dtStartDateStr());
176 mItem->setText(2,"---"); 176 mItem->setText(2,"---");
177 mItem->setText(3,"---"); 177 mItem->setText(3,"---");
178 mItem->setText(4,"---"); 178 mItem->setText(4,"---");
179 mItem->setText(5,"---"); 179 mItem->setText(5,"---");
180 mItem->setText(6,"---"); 180 mItem->setText(6,"---");
181 mItem->setText(7,j->dtStartDateStr()); 181 mItem->setText(7,j->dtStartDateStr());
182 mItem->setText(8,"---"); 182 mItem->setText(8,"---");
183 mItem->setText(9,"---"); 183 mItem->setText(9,"---");
184 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 184 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
185 185
186 QString key; 186 QString key;
187 QDate d = j->dtStart().date(); 187 QDate d = j->dtStart().date();
188 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 188 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
189 mItem->setSortKey(1,key); 189 mItem->setSortKey(1,key);
190 mItem->setSortKey(7,key); 190 mItem->setSortKey(7,key);
191 191
192 return true; 192 return true;
193} 193}
194 194
195KOListView::KOListView(Calendar *calendar, QWidget *parent, 195KOListView::KOListView(Calendar *calendar, QWidget *parent,
196 const char *name) 196 const char *name)
197 : KOEventView(calendar, parent, name) 197 : KOEventView(calendar, parent, name)
198{ 198{
199 mActiveItem = 0; 199 mActiveItem = 0;
200 mListView = new KOListViewListView(this); 200 mListView = new KOListViewListView(this);
201 mListView->addColumn(i18n("Summary")); 201 mListView->addColumn(i18n("Summary"));
202 mListView->addColumn(i18n("Start Date")); 202 mListView->addColumn(i18n("Start Date"));
203 mListView->addColumn(i18n("Start Time")); 203 mListView->addColumn(i18n("Start Time"));
204 mListView->addColumn(i18n("End Date")); 204 mListView->addColumn(i18n("End Date"));
205 mListView->addColumn(i18n("End Time")); 205 mListView->addColumn(i18n("End Time"));
206 mListView->addColumn(i18n("Alarm")); // alarm set? 206 mListView->addColumn(i18n("Alarm")); // alarm set?
207 mListView->addColumn(i18n("Recurs")); // recurs? 207 mListView->addColumn(i18n("Recurs")); // recurs?
208 mListView->addColumn(i18n("Due Date")); 208 mListView->addColumn(i18n("Due Date"));
209 mListView->addColumn(i18n("Due Time")); 209 mListView->addColumn(i18n("Due Time"));
210 mListView->addColumn(i18n("Cancelled")); 210 mListView->addColumn(i18n("Cancelled"));
211 mListView->addColumn(i18n("Categories")); 211 mListView->addColumn(i18n("Categories"));
212 212
213 mListView->setColumnAlignment(0,AlignLeft); 213 mListView->setColumnAlignment(0,AlignLeft);
214 mListView->setColumnAlignment(1,AlignLeft); 214 mListView->setColumnAlignment(1,AlignLeft);
215 mListView->setColumnAlignment(2,AlignHCenter); 215 mListView->setColumnAlignment(2,AlignHCenter);
216 mListView->setColumnAlignment(3,AlignLeft); 216 mListView->setColumnAlignment(3,AlignLeft);
217 mListView->setColumnAlignment(4,AlignHCenter); 217 mListView->setColumnAlignment(4,AlignHCenter);
218 mListView->setColumnAlignment(5,AlignLeft); 218 mListView->setColumnAlignment(5,AlignLeft);
219 mListView->setColumnAlignment(6,AlignLeft); 219 mListView->setColumnAlignment(6,AlignLeft);
220 mListView->setColumnAlignment(7,AlignLeft); 220 mListView->setColumnAlignment(7,AlignLeft);
221 mListView->setColumnAlignment(8,AlignLeft); 221 mListView->setColumnAlignment(8,AlignLeft);
222 mListView->setColumnAlignment(9,AlignLeft); 222 mListView->setColumnAlignment(9,AlignLeft);
223 mListView->setColumnAlignment(10,AlignLeft); 223 mListView->setColumnAlignment(10,AlignLeft);
224 224
225 int iii = 0; 225 int iii = 0;
226 for ( iii = 0; iii< 10 ; ++iii ) 226 for ( iii = 0; iii< 10 ; ++iii )
227 mListView->setColumnWidthMode( iii, QListView::Manual ); 227 mListView->setColumnWidthMode( iii, QListView::Manual );
228 228
229 QBoxLayout *layoutTop = new QVBoxLayout(this); 229 QBoxLayout *layoutTop = new QVBoxLayout(this);
230 layoutTop->addWidget(mListView); 230 layoutTop->addWidget(mListView);
231 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 231 mListView->setFont ( KOPrefs::instance()->mListViewFont );
232 mPopupMenu = eventPopup(); 232 mPopupMenu = eventPopup();
233 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 233 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
234 i18n("Select all"),this, 234 i18n("Select all"),this,
235 SLOT(allSelection()),true); 235 SLOT(allSelection()),true);
236 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 236 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
237 i18n("Deselect All"),this, 237 i18n("Deselect All"),this,
238 SLOT(clearSelection()),true); 238 SLOT(clearSelection()),true);
239 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 239 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
240 i18n("Delete all selected"),this, 240 i18n("Delete all selected"),this,
241 SLOT(deleteAll()),true); 241 SLOT(deleteAll()),true);
242 mPopupMenu->insertSeparator(); 242 mPopupMenu->insertSeparator();
243 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 243 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
244 i18n("Save selected to file..."),this, 244 i18n("Save selected to file..."),this,
245 SLOT(saveToFile()),true); 245 SLOT(saveToFile()),true);
246 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 246 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
247 i18n("Save Journal/Description..."),this, 247 i18n("Save Journal/Description..."),this,
248 SLOT(saveDescriptionToFile()),true); 248 SLOT(saveDescriptionToFile()),true);
249 mPopupMenu->insertSeparator(); 249 mPopupMenu->insertSeparator();
250 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 250 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
251 i18n("Add Categ. to selected..."),this, 251 i18n("Add Categ. to selected..."),this,
252 SLOT(addCat()),true); 252 SLOT(addCat()),true);
253 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 253 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
254 i18n("Set Categ. for selected..."),this, 254 i18n("Set Categ. for selected..."),this,
255 SLOT(setCat()),true); 255 SLOT(setCat()),true);
256 mPopupMenu->insertSeparator(); 256 mPopupMenu->insertSeparator();
257 257
258 258
259#ifndef DESKTOP_VERSION 259#ifndef DESKTOP_VERSION
260 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 260 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
261 i18n("Beam selected via IR"),this, 261 i18n("Beam selected via IR"),this,
262 SLOT(beamSelected()),true); 262 SLOT(beamSelected()),true);
263#endif 263#endif
264 /* 264 /*
265 mPopupMenu = new QPopupMenu; 265 mPopupMenu = new QPopupMenu;
266 mPopupMenu->insertItem(i18n("Edit Event"), this, 266 mPopupMenu->insertItem(i18n("Edit Event"), this,
267 SLOT (editEvent())); 267 SLOT (editEvent()));
268 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 268 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
269 SLOT (deleteEvent())); 269 SLOT (deleteEvent()));
270 mPopupMenu->insertSeparator(); 270 mPopupMenu->insertSeparator();
271 mPopupMenu->insertItem(i18n("Show Dates"), this, 271 mPopupMenu->insertItem(i18n("Show Dates"), this,
272 SLOT(showDates())); 272 SLOT(showDates()));
273 mPopupMenu->insertItem(i18n("Hide Dates"), this, 273 mPopupMenu->insertItem(i18n("Hide Dates"), this,
274 SLOT(hideDates())); 274 SLOT(hideDates()));
275 */ 275 */
276 QObject::connect(mListView,SIGNAL( newEvent()), 276 QObject::connect(mListView,SIGNAL( newEvent()),
277 this,SIGNAL(signalNewEvent())); 277 this,SIGNAL(signalNewEvent()));
278 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 278 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
279 this,SLOT(defaultItemAction(QListViewItem *))); 279 this,SLOT(defaultItemAction(QListViewItem *)));
280 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, 280 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *,
281 const QPoint &, int )), 281 const QPoint &, int )),
282 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 282 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
283 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 283 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
284 SLOT(processSelectionChange(QListViewItem *))); 284 SLOT(processSelectionChange(QListViewItem *)));
285 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 285 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
286 SIGNAL(showIncidenceSignal(Incidence *)) ); 286 SIGNAL(showIncidenceSignal(Incidence *)) );
287 287
288 readSettings(KOGlobals::config(),"KOListView Layout"); 288 readSettings(KOGlobals::config(),"KOListView Layout");
289} 289}
290 290
291KOListView::~KOListView() 291KOListView::~KOListView()
292{ 292{
293 delete mPopupMenu; 293 delete mPopupMenu;
294} 294}
295 295
296void KOListView::updateList() 296void KOListView::updateList()
297{ 297{
298 // qDebug(" KOListView::updateList() "); 298 // qDebug(" KOListView::updateList() ");
299 299
300} 300}
301 301
302void KOListView::addCat( ) 302void KOListView::addCat( )
303{ 303{
304 setCategories( false ); 304 setCategories( false );
305} 305}
306void KOListView::setCat() 306void KOListView::setCat()
307{ 307{
308 setCategories( true ); 308 setCategories( true );
309} 309}
310void KOListView::setCategories( bool removeOld ) 310void KOListView::setCategories( bool removeOld )
311{ 311{
312 312
313 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 313 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
314 if (! csd->exec()) { 314 if (! csd->exec()) {
315 delete csd; 315 delete csd;
316 return; 316 return;
317 } 317 }
318 QStringList catList = csd->selectedCategories(); 318 QStringList catList = csd->selectedCategories();
319 delete csd; 319 delete csd;
320 // if ( catList.count() == 0 ) 320 // if ( catList.count() == 0 )
321 // return; 321 // return;
322 catList.sort(); 322 catList.sort();
323 QString categoriesStr = catList.join(","); 323 QString categoriesStr = catList.join(",");
324 int i; 324 int i;
325 QStringList itemList; 325 QStringList itemList;
326 QPtrList<KOListViewItem> sel ; 326 QPtrList<KOListViewItem> sel ;
327 QListViewItem *qitem = mListView->firstChild (); 327 QListViewItem *qitem = mListView->firstChild ();
328 while ( qitem ) { 328 while ( qitem ) {
329 if ( qitem->isSelected() ) { 329 if ( qitem->isSelected() ) {
330 sel.append(((KOListViewItem *)qitem)); 330 sel.append(((KOListViewItem *)qitem));
331 } 331 }
332 qitem = qitem->nextSibling(); 332 qitem = qitem->nextSibling();
333 } 333 }
334 KOListViewItem * item, *temp; 334 KOListViewItem * item, *temp;
335 item = sel.first(); 335 item = sel.first();
336 Incidence* inc; 336 Incidence* inc;
337 while ( item ) { 337 while ( item ) {
338 inc = item->data(); 338 inc = item->data();
339 if ( removeOld ) { 339 if ( removeOld ) {
340 inc->setCategories( categoriesStr ); 340 inc->setCategories( categoriesStr );
341 } else { 341 } else {
342 itemList = QStringList::split (",", inc->categoriesStr() ); 342 itemList = QStringList::split (",", inc->categoriesStr() );
343 for( i = 0; i< catList.count(); ++i ) { 343 for( i = 0; i< catList.count(); ++i ) {
344 if ( !itemList.contains (catList[i])) 344 if ( !itemList.contains (catList[i]))
345 itemList.append( catList[i] ); 345 itemList.append( catList[i] );
346 } 346 }
347 itemList.sort(); 347 itemList.sort();
348 inc->setCategories( itemList.join(",") ); 348 inc->setCategories( itemList.join(",") );
349 } 349 }
350 temp = item; 350 temp = item;
351 item = sel.next(); 351 item = sel.next();
352 mUidDict.remove( inc->uid() ); 352 mUidDict.remove( inc->uid() );
353 delete temp;; 353 delete temp;;
354 addIncidence( inc ); 354 addIncidence( inc );
355 } 355 }
356} 356}
357 357
358void KOListView::beamSelected() 358void KOListView::beamSelected()
359{ 359{
360 int icount = 0; 360 int icount = 0;
361 QPtrList<Incidence> delSel ; 361 QPtrList<Incidence> delSel ;
362 QListViewItem *item = mListView->firstChild (); 362 QListViewItem *item = mListView->firstChild ();
363 while ( item ) { 363 while ( item ) {
364 if ( item->isSelected() ) { 364 if ( item->isSelected() ) {
365 delSel.append(((KOListViewItem *)item)->data()); 365 delSel.append(((KOListViewItem *)item)->data());
366 ++icount; 366 ++icount;
367 } 367 }
368 368
369 item = item->nextSibling(); 369 item = item->nextSibling();
370 } 370 }
371 if ( icount ) { 371 if ( icount ) {
372 emit beamIncidenceList( delSel ); 372 emit beamIncidenceList( delSel );
373 return; 373 return;
374 QString fn ; 374 QString fn ;
375 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 375 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
376 QString mes; 376 QString mes;
377 bool createbup = true; 377 bool createbup = true;
378 if ( createbup ) { 378 if ( createbup ) {
379 QString description = "\n"; 379 QString description = "\n";
380 CalendarLocal* cal = new CalendarLocal(); 380 CalendarLocal* cal = new CalendarLocal();
381 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 381 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
382 Incidence *incidence = delSel.first(); 382 Incidence *incidence = delSel.first();
383 while ( incidence ) { 383 while ( incidence ) {
384 Incidence *in = incidence->clone(); 384 Incidence *in = incidence->clone();
385 description += in->summary() + "\n"; 385 description += in->summary() + "\n";
386 cal->addIncidence( in ); 386 cal->addIncidence( in );
387 incidence = delSel.next(); 387 incidence = delSel.next();
388 } 388 }
389 FileStorage storage( cal, fn, new VCalFormat ); 389 FileStorage storage( cal, fn, new VCalFormat );
390 storage.save(); 390 storage.save();
391 delete cal; 391 delete cal;
392 mes = i18n("KO/Pi: Ready for beaming"); 392 mes = i18n("KO/Pi: Ready for beaming");
393 topLevelWidget()->setCaption(mes); 393 topLevelWidget()->setCaption(mes);
394 394
395#ifndef DESKTOP_VERSION 395#ifndef DESKTOP_VERSION
396 Ir *ir = new Ir( this ); 396 Ir *ir = new Ir( this );
397 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 397 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
398 ir->send( fn, description, "text/x-vCalendar" ); 398 ir->send( fn, description, "text/x-vCalendar" );
399#endif 399#endif
400 } 400 }
401 } 401 }
402} 402}
403void KOListView::beamDone( Ir *ir ) 403void KOListView::beamDone( Ir *ir )
404{ 404{
405#ifndef DESKTOP_VERSION 405#ifndef DESKTOP_VERSION
406 delete ir; 406 delete ir;
407#endif 407#endif
408 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 408 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
409} 409}
410 410
411void KOListView::saveDescriptionToFile() 411void KOListView::saveDescriptionToFile()
412{ 412{
413 413
414 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 414 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
415 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 415 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
416 i18n("Continue"), i18n("Cancel"), 0, 416 i18n("Continue"), i18n("Cancel"), 0,
417 0, 1 ); 417 0, 1 );
418 if ( result != 0 ) { 418 if ( result != 0 ) {
419 return; 419 return;
420 } 420 }
421 int icount = 0; 421 int icount = 0;
422 QPtrList<Incidence> delSel ; 422 QPtrList<Incidence> delSel ;
423 QListViewItem *item = mListView->firstChild (); 423 QListViewItem *item = mListView->firstChild ();
424 while ( item ) { 424 while ( item ) {
425 if ( item->isSelected() ) { 425 if ( item->isSelected() ) {
426 delSel.append(((KOListViewItem *)item)->data()); 426 delSel.append(((KOListViewItem *)item)->data());
427 ++icount; 427 ++icount;
428 } 428 }
429 429
430 item = item->nextSibling(); 430 item = item->nextSibling();
431 } 431 }
432 if ( icount ) { 432 if ( icount ) {
433 QString fn = KOPrefs::instance()->mLastSaveFile; 433 QString fn = KOPrefs::instance()->mLastSaveFile;
434 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 434 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
435 435
436 if ( fn == "" ) 436 if ( fn == "" )
437 return; 437 return;
438 QFileInfo info; 438 QFileInfo info;
439 info.setFile( fn ); 439 info.setFile( fn );
440 QString mes; 440 QString mes;
441 bool createbup = true; 441 bool createbup = true;
442 if ( info. exists() ) { 442 if ( info. exists() ) {
443 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 443 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
444 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 444 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
445 i18n("Overwrite!"), i18n("Cancel"), 0, 445 i18n("Overwrite!"), i18n("Cancel"), 0,
446 0, 1 ); 446 0, 1 );
447 if ( result != 0 ) { 447 if ( result != 0 ) {
448 createbup = false; 448 createbup = false;
449 } 449 }
450 } 450 }
451 if ( createbup ) { 451 if ( createbup ) {
452 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 452 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
453 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 453 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
454 Incidence *incidence = delSel.first(); 454 Incidence *incidence = delSel.first();
455 icount = 0; 455 icount = 0;
456 while ( incidence ) { 456 while ( incidence ) {
457 if ( incidence->type() == "Journal" ) { 457 if ( incidence->type() == "Journal" ) {
458 text += "\n************************************\n"; 458 text += "\n************************************\n";
459 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 459 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
460 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 460 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
461 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 461 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
462 ++icount; 462 ++icount;
463 463
464 } else { 464 } else {
465 if ( !incidence->description().isEmpty() ) { 465 if ( !incidence->description().isEmpty() ) {
466 text += "\n************************************\n"; 466 text += "\n************************************\n";
467 if ( incidence->type() == "Todo" ) 467 if ( incidence->type() == "Todo" )
468 text += i18n("To-Do: "); 468 text += i18n("To-Do: ");
469 text += incidence->summary(); 469 text += incidence->summary();
470 if ( incidence->hasStartDate() ) 470 if ( incidence->hasStartDate() )
471 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 471 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
472 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 472 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
473 if ( !incidence->location().isEmpty() ) 473 if ( !incidence->location().isEmpty() )
474 text += "\n" +i18n("Location: ") + incidence->location(); 474 text += "\n" +i18n("Location: ") + incidence->location();
475 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 475 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
476 ++icount; 476 ++icount;
477 477
478 } 478 }
479 } 479 }
480 incidence = delSel.next(); 480 incidence = delSel.next();
481 } 481 }
482 QFile file( fn ); 482 QFile file( fn );
483 if (!file.open( IO_WriteOnly ) ) { 483 if (!file.open( IO_WriteOnly ) ) {
484 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 484 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
485 return; 485 return;
486 } 486 }
487 QTextStream ts( &file ); 487 QTextStream ts( &file );
488 ts << text; 488 ts << text;
489 file.close(); 489 file.close();
490 //qDebug("%s ", text.latin1()); 490 //qDebug("%s ", text.latin1());
491 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 491 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
492 KOPrefs::instance()->mLastSaveFile = fn; 492 KOPrefs::instance()->mLastSaveFile = fn;
493 topLevelWidget()->setCaption(mes); 493 topLevelWidget()->setCaption(mes);
494 } 494 }
495 } 495 }
496} 496}
497void KOListView::saveToFile() 497void KOListView::saveToFile()
498{ 498{
499 499
500 int icount = 0; 500 int icount = 0;
501 QPtrList<Incidence> delSel ; 501 QPtrList<Incidence> delSel ;
502 QListViewItem *item = mListView->firstChild (); 502 QListViewItem *item = mListView->firstChild ();
503 while ( item ) { 503 while ( item ) {
504 if ( item->isSelected() ) { 504 if ( item->isSelected() ) {
505 delSel.append(((KOListViewItem *)item)->data()); 505 delSel.append(((KOListViewItem *)item)->data());
506 ++icount; 506 ++icount;
507 } 507 }
508 508
509 item = item->nextSibling(); 509 item = item->nextSibling();
510 } 510 }
511 if ( icount ) { 511 if ( icount ) {
512 QString fn = KOPrefs::instance()->mLastSaveFile; 512 QString fn = KOPrefs::instance()->mLastSaveFile;
513 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 513 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
514 514
515 if ( fn == "" ) 515 if ( fn == "" )
516 return; 516 return;
517 QFileInfo info; 517 QFileInfo info;
518 info.setFile( fn ); 518 info.setFile( fn );
519 QString mes; 519 QString mes;
520 bool createbup = true; 520 bool createbup = true;
521 if ( info. exists() ) { 521 if ( info. exists() ) {
522 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 522 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
523 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 523 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
524 i18n("Overwrite!"), i18n("Cancel"), 0, 524 i18n("Overwrite!"), i18n("Cancel"), 0,
525 0, 1 ); 525 0, 1 );
526 if ( result != 0 ) { 526 if ( result != 0 ) {
527 createbup = false; 527 createbup = false;
528 } 528 }
529 } 529 }
530 if ( createbup ) { 530 if ( createbup ) {
531 CalendarLocal cal; 531 CalendarLocal cal;
532 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 532 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
533 Incidence *incidence = delSel.first(); 533 Incidence *incidence = delSel.first();
534 while ( incidence ) { 534 while ( incidence ) {
535 cal.addIncidence( incidence->clone() ); 535 cal.addIncidence( incidence->clone() );
536 incidence = delSel.next(); 536 incidence = delSel.next();
537 } 537 }
538 ICalFormat format; 538 ICalFormat format;
539 format.save( &cal, fn ); 539 format.save( &cal, fn );
540 mes = i18n("KO/Pi:Saved %1").arg(fn ); 540 mes = i18n("KO/Pi:Saved %1").arg(fn );
541 KOPrefs::instance()->mLastSaveFile = fn; 541 KOPrefs::instance()->mLastSaveFile = fn;
542 topLevelWidget()->setCaption(mes); 542 topLevelWidget()->setCaption(mes);
543 } 543 }
544 } 544 }
545} 545}
546void KOListView::deleteAll() 546void KOListView::deleteAll()
547{ 547{
548 int icount = 0; 548 int icount = 0;
549 QPtrList<Incidence> delSel ; 549 QPtrList<Incidence> delSel ;
550 QListViewItem *item = mListView->firstChild (); 550 QListViewItem *item = mListView->firstChild ();
551 while ( item ) { 551 while ( item ) {
552 if ( item->isSelected() ) { 552 if ( item->isSelected() ) {
553 delSel.append(((KOListViewItem *)item)->data()); 553 delSel.append(((KOListViewItem *)item)->data());
554 ++icount; 554 ++icount;
555 } 555 }
556 556
557 item = item->nextSibling(); 557 item = item->nextSibling();
558 } 558 }
559 if ( icount ) { 559 if ( icount ) {
560 Incidence *incidence = delSel.first(); 560 Incidence *incidence = delSel.first();
561 Incidence *toDelete; 561 Incidence *toDelete;
562 KOPrefs *p = KOPrefs::instance(); 562 KOPrefs *p = KOPrefs::instance();
563 bool confirm = p->mConfirm; 563 bool confirm = p->mConfirm;
564 QString mess; 564 QString mess;
565 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 565 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
566 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")) ) { 566 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")) ) {
567 p->mConfirm = false; 567 p->mConfirm = false;
568 int delCounter = 0; 568 int delCounter = 0;
569 QDialog dia ( this, "p-dialog", true ); 569 QDialog dia ( this, "p-dialog", true );
570 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 570 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
571 QVBoxLayout lay( &dia ); 571 QVBoxLayout lay( &dia );
572 lay.setMargin(7); 572 lay.setMargin(7);
573 lay.setSpacing(7); 573 lay.setSpacing(7);
574 lay.addWidget( &lab); 574 lay.addWidget( &lab);
575 QProgressBar bar( icount, &dia ); 575 QProgressBar bar( icount, &dia );
576 lay.addWidget( &bar); 576 lay.addWidget( &bar);
577 int w = 220; 577 int w = 220;
578 int h = 50; 578 int h = 50;
579 int dw = QApplication::desktop()->width(); 579 int dw = QApplication::desktop()->width();
580 int dh = QApplication::desktop()->height(); 580 int dh = QApplication::desktop()->height();
581 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 581 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
582 //dia.resize( 240,50 ); 582 //dia.resize( 240,50 );
583 dia.show(); 583 dia.show();
584 584
585 while ( incidence ) { 585 while ( incidence ) {
586 bar.setProgress( delCounter ); 586 bar.setProgress( delCounter );
587 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 587 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
588 dia.setCaption( mess ); 588 dia.setCaption( mess );
589 qApp->processEvents(); 589 qApp->processEvents();
590 toDelete = (incidence); 590 toDelete = (incidence);
591 incidence = delSel.next(); 591 incidence = delSel.next();
592 emit deleteIncidenceSignal(toDelete ); 592 emit deleteIncidenceSignal(toDelete );
593 if ( dia.result() != 0 ) 593 if ( dia.result() != 0 )
594 break; 594 break;
595 595
596 } 596 }
597 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 597 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
598 topLevelWidget ()->setCaption( mess ); 598 topLevelWidget ()->setCaption( mess );
599 p->mConfirm = confirm; 599 p->mConfirm = confirm;
600 } 600 }
601 } 601 }
602 602
603 603
604} 604}
605int KOListView::maxDatesHint() 605int KOListView::maxDatesHint()
606{ 606{
607 return 0; 607 return 0;
608} 608}
609 609
610int KOListView::currentDateCount() 610int KOListView::currentDateCount()
611{ 611{
612 return 0; 612 return 0;
613} 613}
614 614
615QPtrList<Incidence> KOListView::selectedIncidences() 615QPtrList<Incidence> KOListView::selectedIncidences()
616{ 616{
617 QPtrList<Incidence> eventList; 617 QPtrList<Incidence> eventList;
618 QListViewItem *item = mListView->firstChild (); 618 QListViewItem *item = mListView->firstChild ();
619 while ( item ) { 619 while ( item ) {
620 if ( item->isSelected() ) { 620 if ( item->isSelected() ) {
621 eventList.append(((KOListViewItem *)item)->data()); 621 eventList.append(((KOListViewItem *)item)->data());
622 } 622 }
623 623
624 item = item->nextSibling(); 624 item = item->nextSibling();
625 } 625 }
626 626
627 // // QListViewItem *item = mListView->selectedItem(); 627 // // QListViewItem *item = mListView->selectedItem();
628 //if (item) eventList.append(((KOListViewItem *)item)->data()); 628 //if (item) eventList.append(((KOListViewItem *)item)->data());
629 629
630 return eventList; 630 return eventList;
631} 631}
632 632
633DateList KOListView::selectedDates() 633DateList KOListView::selectedDates()
634{ 634{
635 DateList eventList; 635 DateList eventList;
636 return eventList; 636 return eventList;
637} 637}
638 638
639void KOListView::showDates(bool show) 639void KOListView::showDates(bool show)
640{ 640{
641 // Shouldn't we set it to a value greater 0? When showDates is called with 641 // Shouldn't we set it to a value greater 0? When showDates is called with
642 // show == true at first, then the columnwidths are set to zero. 642 // show == true at first, then the columnwidths are set to zero.
643 static int oldColWidth1 = 0; 643 static int oldColWidth1 = 0;
644 static int oldColWidth3 = 0; 644 static int oldColWidth3 = 0;
645 645
646 if (!show) { 646 if (!show) {
647 oldColWidth1 = mListView->columnWidth(1); 647 oldColWidth1 = mListView->columnWidth(1);
648 oldColWidth3 = mListView->columnWidth(3); 648 oldColWidth3 = mListView->columnWidth(3);
649 mListView->setColumnWidth(1, 0); 649 mListView->setColumnWidth(1, 0);
650 mListView->setColumnWidth(3, 0); 650 mListView->setColumnWidth(3, 0);
651 } else { 651 } else {
652 mListView->setColumnWidth(1, oldColWidth1); 652 mListView->setColumnWidth(1, oldColWidth1);
653 mListView->setColumnWidth(3, oldColWidth3); 653 mListView->setColumnWidth(3, oldColWidth3);
654 } 654 }
655 mListView->repaint(); 655 mListView->repaint();
656} 656}
657 657
658void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 658void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
659 const QDate &td) 659 const QDate &td)
660{ 660{
661#ifndef KORG_NOPRINTER 661#ifndef KORG_NOPRINTER
662 calPrinter->preview(CalPrinter::Day, fd, td); 662 calPrinter->preview(CalPrinter::Day, fd, td);
663#endif 663#endif
664} 664}
665 665
666void KOListView::showDates() 666void KOListView::showDates()
667{ 667{
668 showDates(true); 668 showDates(true);
669} 669}
670 670
671void KOListView::hideDates() 671void KOListView::hideDates()
672{ 672{
673 showDates(false); 673 showDates(false);
674} 674}
675 675
676void KOListView::updateView() 676void KOListView::updateView()
677{ 677{
678 mListView->setFocus(); 678 mListView->setFocus();
679 if ( mListView->firstChild () ) 679 if ( mListView->firstChild () )
680 mListView->setCurrentItem( mListView->firstChild () ); 680 mListView->setCurrentItem( mListView->firstChild () );
681} 681}
682void KOListView::updateConfig() 682void KOListView::updateConfig()
683{ 683{
684 684
685 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 685 mListView->setFont ( KOPrefs::instance()->mListViewFont );
686 updateView(); 686 updateView();
687 687
688} 688}
689void KOListView::setStartDate(const QDate &start) 689void KOListView::setStartDate(const QDate &start)
690{ 690{
691 mStartDate = start; 691 mStartDate = start;
692} 692}
693 693
694void KOListView::showDates(const QDate &start, const QDate &end) 694void KOListView::showDates(const QDate &start, const QDate &end)
695{ 695{
696 clear(); 696 clear();
697 mStartDate = start; 697 mStartDate = start;
698 QDate date = start; 698 QDate date = start;
699 QPtrList<Journal> j_list; 699 QPtrList<Journal> j_list;
700 while( date <= end ) { 700 while( date <= end ) {
701 addEvents(calendar()->events(date)); 701 addEvents(calendar()->events(date));
702 addTodos(calendar()->todos(date)); 702 addTodos(calendar()->todos(date));
703 Journal* jo = calendar()->journal(date); 703 Journal* jo = calendar()->journal(date);
704 if ( jo ) 704 if ( jo )
705 j_list.append( jo ); 705 j_list.append( jo );
706 date = date.addDays( 1 ); 706 date = date.addDays( 1 );
707 } 707 }
708 addJournals(j_list); 708 addJournals(j_list);
709 emit incidenceSelected( 0 ); 709 emit incidenceSelected( 0 );
710 updateView(); 710 updateView();
711 711
712} 712}
713 713
714void KOListView::addEvents(QPtrList<Event> eventList) 714void KOListView::addEvents(QPtrList<Event> eventList)
715{ 715{
716 Event *ev; 716 Event *ev;
717 for(ev = eventList.first(); ev; ev = eventList.next()) { 717 for(ev = eventList.first(); ev; ev = eventList.next()) {
718 addIncidence(ev); 718 addIncidence(ev);
719 } 719 }
720 if ( !mListView->currentItem() ){ 720 if ( !mListView->currentItem() ){
721 updateView(); 721 updateView();
722 } 722 }
723} 723}
724 724
725void KOListView::addTodos(QPtrList<Todo> eventList) 725void KOListView::addTodos(QPtrList<Todo> eventList)
726{ 726{
727 Todo *ev; 727 Todo *ev;
728 for(ev = eventList.first(); ev; ev = eventList.next()) { 728 for(ev = eventList.first(); ev; ev = eventList.next()) {
729 addIncidence(ev); 729 addIncidence(ev);
730 } 730 }
731 if ( !mListView->currentItem() ){ 731 if ( !mListView->currentItem() ){
732 updateView(); 732 updateView();
733 } 733 }
734} 734}
735void KOListView::addJournals(QPtrList<Journal> eventList) 735void KOListView::addJournals(QPtrList<Journal> eventList)
736{ 736{
737 Journal *ev; 737 Journal *ev;
738 for(ev = eventList.first(); ev; ev = eventList.next()) { 738 for(ev = eventList.first(); ev; ev = eventList.next()) {
739 addIncidence(ev); 739 addIncidence(ev);
740 } 740 }
741 if ( !mListView->currentItem() ){ 741 if ( !mListView->currentItem() ){
742 updateView(); 742 updateView();
743 } 743 }
744} 744}
745 745
746void KOListView::addIncidence(Incidence *incidence) 746void KOListView::addIncidence(Incidence *incidence)
747{ 747{
748 if ( mUidDict.find( incidence->uid() ) ) return; 748 if ( mUidDict.find( incidence->uid() ) ) return;
749 749
750 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 750 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
751 mUidDict.insert( incidence->uid(), incidence ); 751 mUidDict.insert( incidence->uid(), incidence );
752 752
753 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 753 KOListViewItem *item = new KOListViewItem( incidence, mListView );
754 ListItemVisitor v(item, mStartDate ); 754 ListItemVisitor v(item, mStartDate );
755 if (incidence->accept(v)) return; 755 if (incidence->accept(v)) return;
756 else delete item; 756 else delete item;
757 //qDebug("delete item "); 757 //qDebug("delete item ");
758} 758}
759 759
760void KOListView::showEvents(QPtrList<Event> eventList) 760void KOListView::showEvents(QPtrList<Event> eventList)
761{ 761{
762 clear(); 762 clear();
763 763
764 addEvents(eventList); 764 addEvents(eventList);
765 765
766 // After new creation of list view no events are selected. 766 // After new creation of list view no events are selected.
767 emit incidenceSelected( 0 ); 767 emit incidenceSelected( 0 );
768} 768}
769int KOListView::count() 769int KOListView::count()
770{ 770{
771 return mListView->childCount(); 771 return mListView->childCount();
772} 772}
773 773
774void KOListView::changeEventDisplay(Event *event, int action) 774void KOListView::changeEventDisplay(Event *event, int action)
775{ 775{
776 KOListViewItem *item; 776 KOListViewItem *item;
777 777
778 switch(action) { 778 switch(action) {
779 case KOGlobals::EVENTADDED: 779 case KOGlobals::EVENTADDED:
780 addIncidence( event ); 780 addIncidence( event );
781 break; 781 break;
782 case KOGlobals::EVENTEDITED: 782 case KOGlobals::EVENTEDITED:
783 item = getItemForEvent(event); 783 item = getItemForEvent(event);
784 if (item) { 784 if (item) {
785 mUidDict.remove( event->uid() ); 785 mUidDict.remove( event->uid() );
786 delete item; 786 delete item;
787 addIncidence( event ); 787 addIncidence( event );
788 } 788 }
789 break; 789 break;
790 case KOGlobals::EVENTDELETED: 790 case KOGlobals::EVENTDELETED:
791 item = getItemForEvent(event); 791 item = getItemForEvent(event);
792 if (item) { 792 if (item) {
793 mUidDict.remove( event->uid() ); 793 mUidDict.remove( event->uid() );
794 delete item; 794 delete item;
795 } 795 }
796 break; 796 break;
797 default: 797 default:
798 ; 798 ;
799 } 799 }
800} 800}
801 801
802KOListViewItem *KOListView::getItemForEvent(Event *event) 802KOListViewItem *KOListView::getItemForEvent(Event *event)
803{ 803{
804 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 804 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
805 while (item) { 805 while (item) {
806 if (item->data() == event) return item; 806 if (item->data() == event) return item;
807 item = (KOListViewItem *)item->nextSibling(); 807 item = (KOListViewItem *)item->nextSibling();
808 } 808 }
809 return 0; 809 return 0;
810} 810}
811 811
812void KOListView::defaultItemAction(QListViewItem *i) 812void KOListView::defaultItemAction(QListViewItem *i)
813{ 813{
814 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 814 KOListViewItem *item = static_cast<KOListViewItem *>( i );
815 if ( item ) defaultAction( item->data() ); 815 if ( item ) defaultAction( item->data() );
816 816
817} 817}
818 818
819void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 819void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
820{ 820{
821 mActiveItem = (KOListViewItem *)item; 821 mActiveItem = (KOListViewItem *)item;
822 if (mActiveItem) { 822 if (mActiveItem) {
823 Incidence *incidence = mActiveItem->data(); 823 Incidence *incidence = mActiveItem->data();
824 mPopupMenu->showIncidencePopup(incidence); 824 mPopupMenu->showIncidencePopup(incidence);
825 825
826 /* 826 /*
827 if ( incidence && incidence->type() == "Event" ) { 827 if ( incidence && incidence->type() == "Event" ) {
828 Event *event = static_cast<Event *>( incidence ); 828 Event *event = static_cast<Event *>( incidence );
829 mPopupMenu->showEventPopup(event); 829 mPopupMenu->showEventPopup(event);
830 } 830 }
831 */ 831 */
832 } 832 }
833} 833}
834 834
835void KOListView::readSettings(KConfig *config, QString setting) 835void KOListView::readSettings(KConfig *config, QString setting)
836{ 836{
837 // qDebug("KOListView::readSettings "); 837 // qDebug("KOListView::readSettings ");
838 mListView->restoreLayout(config,setting); 838 mListView->restoreLayout(config,setting);
839} 839}
840 840
841void KOListView::writeSettings(KConfig *config, QString setting) 841void KOListView::writeSettings(KConfig *config, QString setting)
842{ 842{
843 // qDebug("KOListView::writeSettings "); 843 // qDebug("KOListView::writeSettings ");
844 mListView->saveLayout(config, setting); 844 mListView->saveLayout(config, setting);
845} 845}
846 846
847void KOListView::processSelectionChange(QListViewItem *) 847void KOListView::processSelectionChange(QListViewItem *)
848{ 848{
849 849
850 KOListViewItem *item = 850 KOListViewItem *item =
851 static_cast<KOListViewItem *>( mListView->currentItem() ); 851 static_cast<KOListViewItem *>( mListView->currentItem() );
852 852
853 if ( !item ) { 853 if ( !item ) {
854 emit incidenceSelected( 0 ); 854 emit incidenceSelected( 0 );
855 } else { 855 } else {
856 emit incidenceSelected( item->data() ); 856 emit incidenceSelected( item->data() );
857 } 857 }
858} 858}
859 859
860void KOListView::clearSelection() 860void KOListView::clearSelection()
861{ 861{
862 mListView->selectAll( false ); 862 mListView->selectAll( false );
863} 863}
864void KOListView::allSelection() 864void KOListView::allSelection()
865{ 865{
866 mListView->selectAll( true ); 866 mListView->selectAll( true );
867} 867}
868 868
869void KOListView::clear() 869void KOListView::clear()
870{ 870{
871 mListView->clear(); 871 mListView->clear();
872 mUidDict.clear(); 872 mUidDict.clear();
873} 873}
874 874
875Incidence* KOListView::currentItem() 875Incidence* KOListView::currentItem()
876{ 876{
877 if ( mListView->currentItem() ) 877 if ( mListView->currentItem() )
878 return ((KOListViewItem*) mListView->currentItem())->data(); 878 return ((KOListViewItem*) mListView->currentItem())->data();
879 return 0; 879 return 0;
880} 880}
881void KOListView::keyPressEvent ( QKeyEvent *e) 881void KOListView::keyPressEvent ( QKeyEvent *e)
882{ 882{
883 883
884 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 884 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
885 deleteAll(); 885 deleteAll();
886 return; 886 return;
887 } 887 }
888 888
889 e->ignore(); 889 e->ignore();
890} 890}
891void KOListViewListView::keyPressEvent ( QKeyEvent *e) 891void KOListViewListView::keyPressEvent ( QKeyEvent *e)
892{ 892{
893 893
894 switch ( e->key() ) { 894 switch ( e->key() ) {
895 case Qt::Key_Down: 895 case Qt::Key_Down:
896 if ( e->state() == ShiftButton ) { 896 if ( e->state() == ShiftButton ) {
897 QListViewItem* cn = currentItem(); 897 QListViewItem* cn = currentItem();
898 if ( !cn ) 898 if ( !cn )
899 cn = firstChild(); 899 cn = firstChild();
900 if ( !cn ) 900 if ( !cn )
901 return; 901 return;
902 while ( cn->nextSibling() ) 902 while ( cn->nextSibling() )
903 cn = cn->nextSibling(); 903 cn = cn->nextSibling();
904 setCurrentItem ( cn ); 904 setCurrentItem ( cn );
905 ensureItemVisible ( cn ); 905 ensureItemVisible ( cn );
906 906
907 e->accept(); 907 e->accept();
908 return; 908 return;
909 } 909 }
910 if ( e->state() == ControlButton ) { 910 if ( e->state() == ControlButton ) {
911 int count = childCount (); 911 int count = childCount ();
912 int jump = count / 5; 912 int jump = count / 5;
913 QListViewItem* cn; 913 QListViewItem* cn;
914 cn = currentItem(); 914 cn = currentItem();
915 if ( ! cn ) 915 if ( ! cn )
916 return; 916 return;
917 if ( jump == 0 ) 917 if ( jump == 0 )
918 jump = 1; 918 jump = 1;
919 while ( jump && cn->nextSibling() ) { 919 while ( jump && cn->nextSibling() ) {
920 cn = cn->nextSibling(); 920 cn = cn->nextSibling();
921 --jump; 921 --jump;
922 } 922 }
923 setCurrentItem ( cn ); 923 setCurrentItem ( cn );
924 ensureItemVisible ( cn ); 924 ensureItemVisible ( cn );
925 925
926 } else 926 } else
927 QListView::keyPressEvent ( e ) ; 927 QListView::keyPressEvent ( e ) ;
928 e->accept(); 928 e->accept();
929 break; 929 break;
930 930
931 case Qt::Key_Up: 931 case Qt::Key_Up:
932 if ( e->state() == ShiftButton ) { 932 if ( e->state() == ShiftButton ) {
933 QListViewItem* cn = firstChild(); 933 QListViewItem* cn = firstChild();
934 if ( cn ) { 934 if ( cn ) {
935 setCurrentItem ( cn ); 935 setCurrentItem ( cn );
936 ensureItemVisible ( cn ); 936 ensureItemVisible ( cn );
937 } 937 }
938 e->accept(); 938 e->accept();
939 return; 939 return;
940 } 940 }
941 if ( e->state() == ControlButton ) { 941 if ( e->state() == ControlButton ) {
942 int count = childCount (); 942 int count = childCount ();
943 int jump = count / 5; 943 int jump = count / 5;
944 QListViewItem* cn; 944 QListViewItem* cn;
945 cn = currentItem(); 945 cn = currentItem();
946 if ( ! cn ) 946 if ( ! cn )
947 return; 947 return;
948 if ( jump == 0 ) 948 if ( jump == 0 )
949 jump = 1; 949 jump = 1;
950 while ( jump && cn->itemAbove ()) { 950 while ( jump && cn->itemAbove ()) {
951 cn = cn->itemAbove (); 951 cn = cn->itemAbove ();
952 --jump; 952 --jump;
953 } 953 }
954 setCurrentItem ( cn ); 954 setCurrentItem ( cn );
955 ensureItemVisible ( cn ); 955 ensureItemVisible ( cn );
956 } else 956 } else
957 QListView::keyPressEvent ( e ) ; 957 QListView::keyPressEvent ( e ) ;
958 e->accept(); 958 e->accept();
959 break; 959 break;
960 case Qt::Key_I: { 960 case Qt::Key_I: {
961 QListViewItem* cn; 961 QListViewItem* cn;
962 cn = currentItem(); 962 cn = currentItem();
963 if ( cn ) { 963 if ( cn ) {
964 KOListViewItem* ci = (KOListViewItem*)( cn ); 964 KOListViewItem* ci = (KOListViewItem*)( cn );
965 if ( ci ){ 965 if ( ci ){
966 emit showIncidence( ci->data()); 966 emit showIncidence( ci->data());
967 cn = cn->nextSibling(); 967 cn = cn->nextSibling();
968 if ( cn ) { 968 if ( cn ) {
969 setCurrentItem ( cn ); 969 setCurrentItem ( cn );
970 ensureItemVisible ( cn ); 970 ensureItemVisible ( cn );
971 } 971 }
972 } 972 }
973 } 973 }
974 e->accept(); 974 e->accept();
975 } 975 }
976 break; 976 break;
977 case Qt::Key_Return: 977 case Qt::Key_Return:
978 case Qt::Key_Enter: 978 case Qt::Key_Enter:
979 { 979 {
980 QListViewItem* cn; 980 QListViewItem* cn;
981 cn = currentItem(); 981 cn = currentItem();
982 if ( cn ) { 982 if ( cn ) {
983 KOListViewItem* ci = (KOListViewItem*)( cn ); 983 KOListViewItem* ci = (KOListViewItem*)( cn );
984 if ( ci ){ 984 if ( ci ){
985 if ( e->state() == ShiftButton ) 985 if ( e->state() == ShiftButton )
986 ci->setSelected( false ); 986 ci->setSelected( false );
987 else 987 else
988 ci->setSelected( true ); 988 ci->setSelected( true );
989 cn = cn->nextSibling(); 989 cn = cn->nextSibling();
990 if ( cn ) { 990 if ( cn ) {
991 setCurrentItem ( cn ); 991 setCurrentItem ( cn );
992 ensureItemVisible ( cn ); 992 ensureItemVisible ( cn );
993 } 993 }
994 } 994 }
995 } 995 }
996 e->accept(); 996 e->accept();
997 } 997 }
998 break; 998 break;
999 default: 999 default:
1000 e->ignore(); 1000 e->ignore();
1001 } 1001 }
1002} 1002}
1003KOListViewListView::KOListViewListView(KOListView * lv ) 1003KOListViewListView::KOListViewListView(KOListView * lv )
1004 : KListView( lv ) 1004 : KListView( lv )
1005{ 1005{
1006#ifndef DESKTOP_VERSION 1006#ifndef DESKTOP_VERSION
1007 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1007 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1008#endif 1008#endif
1009 mYMousePos = -1000;
1009 setSelectionMode( QListView::Multi ); 1010 setSelectionMode( QListView::Multi );
1010 setMultiSelection( true); 1011 setMultiSelection( true);
1011 mAllowPopupMenu = true; 1012 mAllowPopupMenu = true;
1012 mMouseDown = false; 1013 mMouseDown = false;
1013 1014
1014} 1015}
1015void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1016void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1016{ 1017{
1017 if (!e) return; 1018 if (!e) return;
1018 QPoint vp = contentsToViewport(e->pos()); 1019 QPoint vp = contentsToViewport(e->pos());
1019 QListViewItem *item = itemAt(vp); 1020 QListViewItem *item = itemAt(vp);
1020 if (!item) { 1021 if (!item) {
1021 emit newEvent(); 1022 emit newEvent();
1022 return; 1023 return;
1023 } 1024 }
1024 KListView::contentsMouseDoubleClickEvent(e); 1025 KListView::contentsMouseDoubleClickEvent(e);
1025} 1026}
1026 1027
1027 1028
1028void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1029void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1029{ 1030{
1030 //qDebug("contentsMousePressEvent++++ "); 1031 //qDebug("contentsMousePressEvent++++ ");
1031 if (! mMouseDown ) { 1032 if (! mMouseDown ) {
1032 mAllowPopupMenu = true; 1033 mAllowPopupMenu = true;
1033 mYMousePos = mapToGlobal( (e->pos())).y(); 1034 mYMousePos = mapToGlobal( (e->pos())).y();
1034 } 1035 }
1035 if ( e->button() == RightButton && mMouseDown ) 1036 if ( e->button() == RightButton && mMouseDown )
1036 return; 1037 return;
1037 if ( e->button() == LeftButton ) 1038 if ( e->button() == LeftButton )
1038 mMouseDown = true; 1039 mMouseDown = true;
1039 KListView::contentsMousePressEvent( e ); 1040 KListView::contentsMousePressEvent( e );
1040} 1041}
1041void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1042void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1042{ 1043{
1043 //qDebug("contentsMouseReleaseEv---- "); 1044 //qDebug("contentsMouseReleaseEv---- ");
1044 if ( ! mMouseDown ) { 1045 if ( ! mMouseDown ) {
1045 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1046 if ( e->button() == RightButton && ! mAllowPopupMenu )
1046 return; 1047 return;
1047 QListViewItem* ci = currentItem(); 1048 QListViewItem* ci = currentItem();
1048 if ( ci ) 1049 if ( ci )
1049 ci->setSelected( true ); 1050 ci->setSelected( true );
1050 KListView::contentsMouseReleaseEvent(e); 1051 KListView::contentsMouseReleaseEvent(e);
1051 return; 1052 return;
1052 } 1053 }
1053 if ( e->button() == LeftButton ) 1054 if ( e->button() == LeftButton )
1054 mMouseDown = false; 1055 mMouseDown = false;
1055 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1056 if ( e->button() == RightButton && ! mAllowPopupMenu )
1056 return; 1057 return;
1057 if ( e->button() == RightButton ) { 1058 if ( e->button() == RightButton ) {
1058 QListViewItem* ci = currentItem(); 1059 QListViewItem* ci = currentItem();
1059 if ( ci ) 1060 if ( ci )
1060 ci->setSelected( true ); 1061 ci->setSelected( true );
1061 } 1062 }
1062 KListView::contentsMouseReleaseEvent(e); 1063 KListView::contentsMouseReleaseEvent(e);
1063} 1064}
1064void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1065void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1065{ 1066{
1066 // qDebug("contentsMouseMoveEv....... "); 1067 // qDebug("contentsMouseMoveEv....... ");
1067 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1068 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1068 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1069 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1069 if ( diff < 0 ) diff = -diff; 1070 if ( diff < 0 ) diff = -diff;
1070 if ( diff > 20 ) 1071 if ( diff > 20 )
1071 mAllowPopupMenu = false; 1072 mAllowPopupMenu = false;
1072 KListView::contentsMouseMoveEvent(e); 1073 KListView::contentsMouseMoveEvent(e);
1073} 1074}
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index f44debc..8dca3ae 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,477 +1,467 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "koprefs.h" 46#include "koprefs.h"
47#include "mainwindow.h" 47#include "mainwindow.h"
48 48
49KOPrefs *KOPrefs::mInstance = 0; 49KOPrefs *KOPrefs::mInstance = 0;
50static KStaticDeleter<KOPrefs> insd; 50static KStaticDeleter<KOPrefs> insd;
51 51
52KOPrefs::KOPrefs() : 52KOPrefs::KOPrefs() :
53 KPimPrefs("korganizerrc") 53 KPimPrefs("korganizerrc")
54{ 54{
55 mCategoryColors.setAutoDelete(true); 55 mCategoryColors.setAutoDelete(true);
56 fillMailDefaults(); 56 fillMailDefaults();
57 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 57 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
58 QColor defaultHolidayColor = QColor(255,0,0); 58 QColor defaultHolidayColor = QColor(255,0,0);
59 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 59 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
60 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 60 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
61 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 61 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
62 QColor defaultTodoDueTodayColor = QColor(255,220,100); 62 QColor defaultTodoDueTodayColor = QColor(255,220,100);
63 QColor defaultTodoOverdueColor = QColor(255,153,125); 63 QColor defaultTodoOverdueColor = QColor(255,153,125);
64 64
65 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); 65 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
66 mDefaultViewFont = QFont("helvetica",10); 66 mDefaultViewFont = QFont("helvetica",10);
67 mDefaultMonthViewFont = QFont("helvetica",8); 67 mDefaultMonthViewFont = QFont("helvetica",8);
68 mMarcusBainsFont= QFont("helvetica",10); 68 mMarcusBainsFont= QFont("helvetica",10);
69 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); 69 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
70 mEditBoxFont = QFont("helvetica",12); 70 mEditBoxFont = QFont("helvetica",12);
71 mJornalViewFont = QFont("helvetica",12); 71 mJornalViewFont = QFont("helvetica",12);
72 72
73 KPrefs::setCurrentGroup("General"); 73 KPrefs::setCurrentGroup("General");
74 74
75 75
76 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 76 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
77 77
78 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 78 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
79 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 79 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
80 addItemBool("ShowIconSearch",&mShowIconSearch,true); 80 addItemBool("ShowIconSearch",&mShowIconSearch,true);
81 addItemBool("ShowIconList",&mShowIconList,true); 81 addItemBool("ShowIconList",&mShowIconList,true);
82 addItemBool("ShowIconDay1",&mShowIconDay1,true); 82 addItemBool("ShowIconDay1",&mShowIconDay1,true);
83 addItemBool("ShowIconDay5",&mShowIconDay5,true); 83 addItemBool("ShowIconDay5",&mShowIconDay5,true);
84 addItemBool("ShowIconDay7",&mShowIconDay7,true); 84 addItemBool("ShowIconDay7",&mShowIconDay7,true);
85 addItemBool("ShowIconMonth",&mShowIconMonth,true); 85 addItemBool("ShowIconMonth",&mShowIconMonth,true);
86 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 86 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
87 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 87 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
88 addItemBool("ShowIconBack",&mShowIconBack,true); 88 addItemBool("ShowIconBack",&mShowIconBack,true);
89 addItemBool("ShowIconToday",&mShowIconToday,true); 89 addItemBool("ShowIconToday",&mShowIconToday,true);
90 addItemBool("ShowIconForward",&mShowIconForward,true); 90 addItemBool("ShowIconForward",&mShowIconForward,true);
91 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 91 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
92 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); 92 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
93 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 93 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
94 addItemBool("ShowIconNext",&mShowIconNext,true); 94 addItemBool("ShowIconNext",&mShowIconNext,true);
95 addItemBool("ShowIconJournal",&mShowIconJournal,true); 95 addItemBool("ShowIconJournal",&mShowIconJournal,true);
96 addItemBool("ShowIconStretch",&mShowIconStretch,true); 96 addItemBool("ShowIconStretch",&mShowIconStretch,true);
97 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 97 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
98 98
99 addItemBool("AskForQuit",&mAskForQuit,false); 99 addItemBool("AskForQuit",&mAskForQuit,false);
100 100
101#ifndef DESKTOP_VERSION 101#ifndef DESKTOP_VERSION
102 addItemBool("ShowFullMenu",&mShowFullMenu,false); 102 addItemBool("ShowFullMenu",&mShowFullMenu,false);
103#else 103#else
104 addItemBool("ShowFullMenu",&mShowFullMenu,true); 104 addItemBool("ShowFullMenu",&mShowFullMenu,true);
105#endif 105#endif
106 addItemBool("ToolBarHor",&mToolBarHor, true ); 106 addItemBool("ToolBarHor",&mToolBarHor, true );
107 addItemBool("ToolBarUp",&mToolBarUp, false ); 107 addItemBool("ToolBarUp",&mToolBarUp, false );
108 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 108 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
109 addItemInt("Whats Next Days",&mWhatsNextDays,3); 109 addItemInt("Whats Next Days",&mWhatsNextDays,3);
110 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 110 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
111 111
112 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 112 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
113 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 113 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
114 addItemInt("AllDay Size",&mAllDaySize,28); 114 addItemInt("AllDay Size",&mAllDaySize,28);
115 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 115 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
116 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 116 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
117 117
118 addItemStringList("LocationDefaults",&mLocationDefaults ); 118 addItemStringList("LocationDefaults",&mLocationDefaults );
119 addItemStringList("EventSummary User",&mEventSummaryUser); 119 addItemStringList("EventSummary User",&mEventSummaryUser);
120 addItemStringList("TodoSummary User",&mTodoSummaryUser); 120 addItemStringList("TodoSummary User",&mTodoSummaryUser);
121 121
122 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 122 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
123 addItemBool("Enable Project View",&mEnableProjectView,false); 123 addItemBool("Enable Project View",&mEnableProjectView,false);
124 addItemBool("Auto Save",&mAutoSave,false); 124 addItemBool("Auto Save",&mAutoSave,false);
125 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 125 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
126 addItemBool("Confirm Deletes",&mConfirm,true); 126 addItemBool("Confirm Deletes",&mConfirm,true);
127 addItemString("Archive File",&mArchiveFile); 127 addItemString("Archive File",&mArchiveFile);
128 addItemString("Html Export File",&mHtmlExportFile, 128 addItemString("Html Export File",&mHtmlExportFile,
129 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 129 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
130 addItemBool("Html With Save",&mHtmlWithSave,false); 130 addItemBool("Html With Save",&mHtmlWithSave,false);
131 131
132 KPrefs::setCurrentGroup("Personal Settings"); 132 KPrefs::setCurrentGroup("Personal Settings");
133 133
134 addItemInt("Mail Client",&mMailClient,MailClientKMail); 134 addItemInt("Mail Client",&mMailClient,MailClientKMail);
135 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 135 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
136 addItemBool("Bcc",&mBcc,false); 136 addItemBool("Bcc",&mBcc,false);
137 137
138 KPrefs::setCurrentGroup("Time & Date"); 138 KPrefs::setCurrentGroup("Time & Date");
139 139
140 140
141 addItemInt("Default Start Time",&mStartTime,10); 141 addItemInt("Default Start Time",&mStartTime,10);
142 addItemInt("Default Duration",&mDefaultDuration,2); 142 addItemInt("Default Duration",&mDefaultDuration,2);
143 addItemInt("Default Alarm Time",&mAlarmTime,3); 143 addItemInt("Default Alarm Time",&mAlarmTime,3);
144 KPrefs::setCurrentGroup("AlarmSettings"); 144 KPrefs::setCurrentGroup("AlarmSettings");
145 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 145 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
146 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 146 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
147 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 147 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
148 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 148 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
149 149
150 150
151 KPrefs::setCurrentGroup("Calendar"); 151 KPrefs::setCurrentGroup("Calendar");
152 152
153 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 153 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
154 154
155 KPrefs::setCurrentGroup("Fonts"); 155 KPrefs::setCurrentGroup("Fonts");
156 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 156 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
157 addItemFont("TimeBar Font",&mTimeBarFont); 157 addItemFont("TimeBar Font",&mTimeBarFont);
158 addItemFont("MonthView Font",&mMonthViewFont); 158 addItemFont("MonthView Font",&mMonthViewFont);
159 addItemFont("AgendaView Font",&mAgendaViewFont); 159 addItemFont("AgendaView Font",&mAgendaViewFont);
160 addItemFont("MarcusBains Font",&mMarcusBainsFont); 160 addItemFont("MarcusBains Font",&mMarcusBainsFont);
161 addItemFont("TimeLabels Font",&mTimeLabelsFont); 161 addItemFont("TimeLabels Font",&mTimeLabelsFont);
162 addItemFont("TodoView Font",&mTodoViewFont); 162 addItemFont("TodoView Font",&mTodoViewFont);
163 addItemFont("ListView Font",&mListViewFont); 163 addItemFont("ListView Font",&mListViewFont);
164 addItemFont("DateNavigator Font",&mDateNavigatorFont); 164 addItemFont("DateNavigator Font",&mDateNavigatorFont);
165 addItemFont("EditBox Font",&mEditBoxFont); 165 addItemFont("EditBox Font",&mEditBoxFont);
166 addItemFont("JournalView Font",&mJornalViewFont); 166 addItemFont("JournalView Font",&mJornalViewFont);
167 addItemFont("WhatsNextView Font",&mWhatsNextFont); 167 addItemFont("WhatsNextView Font",&mWhatsNextFont);
168 addItemFont("EventView Font",&mEventViewFont); 168 addItemFont("EventView Font",&mEventViewFont);
169 169
170// KPrefs::setCurrentGroup("SyncProfiles");
171// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
172// addItemStringList("SyncProfileNames",&mSyncProfileNames);
173// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
174
175 KPrefs::setCurrentGroup("RemoteSyncing"); 170 KPrefs::setCurrentGroup("RemoteSyncing");
176// addItemBool("UsePasswd",&mUsePassWd,false);
177// addItemBool("WriteBackFile",&mWriteBackFile,true);
178// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
179// addItemBool("AskForPreferences",&mAskForPreferences,true);
180// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
181 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 171 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
182 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 172 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
183 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 173 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
184 addItemInt("LastSyncTime",&mLastSyncTime,0); 174 addItemInt("LastSyncTime",&mLastSyncTime,0);
185 175
186#ifdef _WIN32_ 176#ifdef _WIN32_
187 QString hdp= locateLocal("data","korganizer")+"\\\\"; 177 QString hdp= locateLocal("data","korganizer")+"\\\\";
188#else 178#else
189 QString hdp= locateLocal("data","korganizer")+"/"; 179 QString hdp= locateLocal("data","korganizer")+"/";
190#endif 180#endif
191 181
192 KPrefs::setCurrentGroup("LoadSaveFileNames"); 182 KPrefs::setCurrentGroup("LoadSaveFileNames");
193 183
194 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 184 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
195 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 185 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
196 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 186 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
197 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 187 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
198 188
199 189
200 KPrefs::setCurrentGroup("Locale"); 190 KPrefs::setCurrentGroup("Locale");
201 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 191 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
202 192
203 193
204 KPrefs::setCurrentGroup("Colors"); 194 KPrefs::setCurrentGroup("Colors");
205 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 195 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
206 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 196 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
207 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 197 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
208 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 198 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
209 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 199 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
210 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 200 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
211 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 201 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
212 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 202 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
213 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 203 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
214 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 204 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
215 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 205 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
216 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 206 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
217 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 207 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
218 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 208 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
219 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 209 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
220 addItemBool("UseAppColors",&mUseAppColors,false); 210 addItemBool("UseAppColors",&mUseAppColors,false);
221 211
222 212
223 213
224 KPrefs::setCurrentGroup("Views"); 214 KPrefs::setCurrentGroup("Views");
225 addItemInt("Hour Size",&mHourSize,8); 215 addItemInt("Hour Size",&mHourSize,8);
226 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 216 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
227 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 217 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
228 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 218 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
229 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 219 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
230 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 220 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
231 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 221 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
232 addItemBool("Enable ToolTips",&mEnableToolTips,false); 222 addItemBool("Enable ToolTips",&mEnableToolTips,false);
233 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 223 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
234 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 224 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
235 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 225 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
236 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 226 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
237 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); 227 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
238 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 228 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
239 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 229 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
240 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 230 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
241 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 231 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
242 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); 232 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
243 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 233 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
244 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 234 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
245 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 235 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
246 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 236 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
247 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 237 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
248 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); 238 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
249 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 239 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
250 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 240 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
251#ifdef DESKTOP_VERSION 241#ifdef DESKTOP_VERSION
252 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 242 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
253#else 243#else
254 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 244 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
255#endif 245#endif
256 addItemInt("Day Begins",&mDayBegins,7); 246 addItemInt("Day Begins",&mDayBegins,7);
257 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 247 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
258 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 248 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
259 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 249 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
260 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 250 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
261 251
262 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 252 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
263 addItemBool("Full View Month",&mFullViewMonth,true); 253 addItemBool("Full View Month",&mFullViewMonth,true);
264 addItemBool("Full View Todo",&mFullViewTodo,true); 254 addItemBool("Full View Todo",&mFullViewTodo,true);
265 addItemBool("Quick Todo",&mEnableQuickTodo,false); 255 addItemBool("Quick Todo",&mEnableQuickTodo,false);
266 256
267 addItemInt("Next X Days",&mNextXDays,3); 257 addItemInt("Next X Days",&mNextXDays,3);
268 258
269 KPrefs::setCurrentGroup("Printer"); 259 KPrefs::setCurrentGroup("Printer");
270 260
271 KPrefs::setCurrentGroup("Layout"); 261 KPrefs::setCurrentGroup("Layout");
272 262
273 addItemBool("CompactDialogs",&mCompactDialogs,false); 263 addItemBool("CompactDialogs",&mCompactDialogs,false);
274 addItemBool("VerticalScreen",&mVerticalScreen,true); 264 addItemBool("VerticalScreen",&mVerticalScreen,true);
275 265
276 KPrefs::setCurrentGroup("KOrganizer Plugins"); 266 KPrefs::setCurrentGroup("KOrganizer Plugins");
277 267
278 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 268 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
279 269
280 KPrefs::setCurrentGroup("Group Scheduling"); 270 KPrefs::setCurrentGroup("Group Scheduling");
281 271
282 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 272 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
283 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 273 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
284 addItemStringList("AdditionalMails",&mAdditionalMails,""); 274 addItemStringList("AdditionalMails",&mAdditionalMails,"");
285 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 275 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
286 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 276 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
287 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 277 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
288 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 278 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
289 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 279 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
290 280
291 KPrefs::setCurrentGroup( "Editors" ); 281 KPrefs::setCurrentGroup( "Editors" );
292 282
293 addItemStringList( "EventTemplates", &mEventTemplates ); 283 addItemStringList( "EventTemplates", &mEventTemplates );
294 addItemStringList( "TodoTemplates", &mTodoTemplates ); 284 addItemStringList( "TodoTemplates", &mTodoTemplates );
295 285
296 addItemInt("DestinationPolicy",&mDestination,standardDestination); 286 addItemInt("DestinationPolicy",&mDestination,standardDestination);
297 287
298 288
299 289
300} 290}
301 291
302 292
303KOPrefs::~KOPrefs() 293KOPrefs::~KOPrefs()
304{ 294{
305 if (mInstance == this) 295 if (mInstance == this)
306 mInstance = insd.setObject(0); 296 mInstance = insd.setObject(0);
307 297
308 //qDebug("KOPrefs::~KOPrefs() "); 298 //qDebug("KOPrefs::~KOPrefs() ");
309} 299}
310 300
311 301
312KOPrefs *KOPrefs::instance() 302KOPrefs *KOPrefs::instance()
313{ 303{
314 if (!mInstance) { 304 if (!mInstance) {
315 mInstance = insd.setObject(new KOPrefs()); 305 mInstance = insd.setObject(new KOPrefs());
316 mInstance->readConfig(); 306 mInstance->readConfig();
317 } 307 }
318 308
319 return mInstance; 309 return mInstance;
320} 310}
321 311
322void KOPrefs::usrSetDefaults() 312void KOPrefs::usrSetDefaults()
323{ 313{
324 314
325} 315}
326 316
327void KOPrefs::fillMailDefaults() 317void KOPrefs::fillMailDefaults()
328{ 318{
329 if (mName.isEmpty()) mName = i18n("Anonymous"); 319 if (mName.isEmpty()) mName = i18n("Anonymous");
330 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 320 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
331} 321}
332 322
333void KOPrefs::setTimeZoneIdDefault() 323void KOPrefs::setTimeZoneIdDefault()
334{ 324{
335 ; 325 ;
336} 326}
337 327
338void KOPrefs::setCategoryDefaults() 328void KOPrefs::setCategoryDefaults()
339{ 329{
340 mCustomCategories.clear(); 330 mCustomCategories.clear();
341 mCustomCategories = getDefaultList(); 331 mCustomCategories = getDefaultList();
342 332
343 QStringList::Iterator it; 333 QStringList::Iterator it;
344 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 334 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
345 setCategoryColor(*it,mDefaultCategoryColor); 335 setCategoryColor(*it,mDefaultCategoryColor);
346 } 336 }
347} 337}
348 338
349QStringList KOPrefs::getDefaultList() 339QStringList KOPrefs::getDefaultList()
350{ 340{
351 QStringList retval ; 341 QStringList retval ;
352 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 342 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
353 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 343 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
354 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 344 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
355 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 345 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
356 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 346 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
357 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 347 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
358 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 348 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
359 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 349 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
360 retval.sort(); 350 retval.sort();
361 return retval; 351 return retval;
362} 352}
363 353
364void KOPrefs::usrReadConfig() 354void KOPrefs::usrReadConfig()
365{ 355{
366 config()->setGroup("General"); 356 config()->setGroup("General");
367 357
368 mCustomCategories = config()->readListEntry("Custom Categories"); 358 mCustomCategories = config()->readListEntry("Custom Categories");
369 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) { 359 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) {
370 mLocationDefaults.clear(); 360 mLocationDefaults.clear();
371 mEventSummaryUser.clear(); 361 mEventSummaryUser.clear();
372 mTodoSummaryUser.clear(); 362 mTodoSummaryUser.clear();
373 } 363 }
374 mOldLoadedLanguage = mOldLanguage ; 364 mOldLoadedLanguage = mOldLanguage ;
375 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 365 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
376 if (mLocationDefaults.isEmpty()) { 366 if (mLocationDefaults.isEmpty()) {
377 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 367 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
378 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 368 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
379 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 369 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
380 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 370 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
381 mLocationDefaults.sort(); 371 mLocationDefaults.sort();
382 } 372 }
383 373
384 if (mEventSummaryUser.isEmpty()) { 374 if (mEventSummaryUser.isEmpty()) {
385 mEventSummaryUser = getDefaultList() ; 375 mEventSummaryUser = getDefaultList() ;
386 } 376 }
387 if (mTodoSummaryUser.isEmpty()) { 377 if (mTodoSummaryUser.isEmpty()) {
388 mTodoSummaryUser = getDefaultList() ; 378 mTodoSummaryUser = getDefaultList() ;
389 } 379 }
390 380
391 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 381 if (mCustomCategories.isEmpty()) setCategoryDefaults();
392 382
393 config()->setGroup("Personal Settings"); 383 config()->setGroup("Personal Settings");
394 mName = config()->readEntry("user_name",""); 384 mName = config()->readEntry("user_name","");
395 mEmail = config()->readEntry("user_email",""); 385 mEmail = config()->readEntry("user_email","");
396 fillMailDefaults(); 386 fillMailDefaults();
397 387
398 config()->setGroup("Category Colors"); 388 config()->setGroup("Category Colors");
399 QStringList::Iterator it; 389 QStringList::Iterator it;
400 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 390 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
401 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 391 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
402 392
403 } 393 }
404 394
405 KPimPrefs::usrReadConfig(); 395 KPimPrefs::usrReadConfig();
406} 396}
407 397
408 398
409void KOPrefs::usrWriteConfig() 399void KOPrefs::usrWriteConfig()
410{ 400{
411 config()->setGroup("General"); 401 config()->setGroup("General");
412 config()->writeEntry("Custom Categories",mCustomCategories); 402 config()->writeEntry("Custom Categories",mCustomCategories);
413 403
414 config()->setGroup("Personal Settings"); 404 config()->setGroup("Personal Settings");
415 config()->writeEntry("user_name",mName); 405 config()->writeEntry("user_name",mName);
416 config()->writeEntry("user_email",mEmail); 406 config()->writeEntry("user_email",mEmail);
417 407
418 config()->setGroup("Category Colors"); 408 config()->setGroup("Category Colors");
419 QDictIterator<QColor> it(mCategoryColors); 409 QDictIterator<QColor> it(mCategoryColors);
420 while (it.current()) { 410 while (it.current()) {
421 config()->writeEntry(it.currentKey(),*(it.current())); 411 config()->writeEntry(it.currentKey(),*(it.current()));
422 ++it; 412 ++it;
423 } 413 }
424 414
425 415
426 KPimPrefs::usrWriteConfig(); 416 KPimPrefs::usrWriteConfig();
427} 417}
428 418
429void KOPrefs::setCategoryColor(QString cat,const QColor & color) 419void KOPrefs::setCategoryColor(QString cat,const QColor & color)
430{ 420{
431 mCategoryColors.replace(cat,new QColor(color)); 421 mCategoryColors.replace(cat,new QColor(color));
432} 422}
433 423
434QColor *KOPrefs::categoryColor(QString cat) 424QColor *KOPrefs::categoryColor(QString cat)
435{ 425{
436 QColor *color = 0; 426 QColor *color = 0;
437 427
438 if (!cat.isEmpty()) color = mCategoryColors[cat]; 428 if (!cat.isEmpty()) color = mCategoryColors[cat];
439 429
440 if (color) return color; 430 if (color) return color;
441 else return &mDefaultCategoryColor; 431 else return &mDefaultCategoryColor;
442} 432}
443 433
444void KOPrefs::setFullName(const QString &name) 434void KOPrefs::setFullName(const QString &name)
445{ 435{
446 mName = name; 436 mName = name;
447} 437}
448 438
449void KOPrefs::setEmail(const QString &email) 439void KOPrefs::setEmail(const QString &email)
450{ 440{
451 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 441 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
452 mEmail = email; 442 mEmail = email;
453} 443}
454 444
455QString KOPrefs::fullName() 445QString KOPrefs::fullName()
456{ 446{
457 if (mEmailControlCenter) { 447 if (mEmailControlCenter) {
458 KEMailSettings settings; 448 KEMailSettings settings;
459 return settings.getSetting(KEMailSettings::RealName); 449 return settings.getSetting(KEMailSettings::RealName);
460 } else { 450 } else {
461 return mName; 451 return mName;
462 } 452 }
463} 453}
464 454
465QString KOPrefs::email() 455QString KOPrefs::email()
466{ 456{
467 if (mEmailControlCenter) { 457 if (mEmailControlCenter) {
468 KEMailSettings settings; 458 KEMailSettings settings;
469 return settings.getSetting(KEMailSettings::EmailAddress); 459 return settings.getSetting(KEMailSettings::EmailAddress);
470 } else { 460 } else {
471 return mEmail; 461 return mEmail;
472 } 462 }
473} 463}
474KConfig* KOPrefs::getConfig() 464KConfig* KOPrefs::getConfig()
475{ 465{
476 return config(); 466 return config();
477} 467}
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
index 4194d12..2481ca4 100644
--- a/korganizer/main.cpp
+++ b/korganizer/main.cpp
@@ -1,106 +1,109 @@
1 1
2 2
3#ifndef DESKTOP_VERSION 3#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include <qcopchannel_qws.h> 5#include <qcopchannel_qws.h>
6#include <qpe/global.h> 6#include <qpe/global.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#else 8#else
9#include <qapplication.h> 9#include <qapplication.h>
10#include <qstring.h> 10#include <qstring.h>
11#include <qwindowsstyle.h> 11#include <qwindowsstyle.h>
12#include <qplatinumstyle.h> 12#include <qplatinumstyle.h>
13#include <qsgistyle.h> 13#include <qsgistyle.h>
14#endif 14#endif
15#include <qtextcodec.h> 15#include <qtextcodec.h>
16 16
17#include <qdir.h> 17#include <qdir.h>
18#include <kstandarddirs.h> 18#include <kstandarddirs.h>
19#include <kglobal.h> 19#include <kglobal.h>
20#include <stdio.h> 20#include <stdio.h>
21#include "mainwindow.h" 21#include "mainwindow.h"
22#include <libkdepim/kpimglobalprefs.h>
22void dumpMissing(); 23void dumpMissing();
23int main( int argc, char **argv ) 24int main( int argc, char **argv )
24{ 25{
25#ifndef DESKTOP_VERSION 26#ifndef DESKTOP_VERSION
26 QPEApplication a( argc, argv ); 27 QPEApplication a( argc, argv );
27 a.setKeepRunning (); 28 a.setKeepRunning ();
28#else 29#else
29 QApplication a( argc, argv ); 30 QApplication a( argc, argv );
30 QApplication::setStyle( new QPlatinumStyle ()); 31 QApplication::setStyle( new QPlatinumStyle ());
31 QString hdir = QDir::homeDirPath(); 32 QString hdir = QDir::homeDirPath();
32 // there is a bug when creating dirs for WIN 98 33 // there is a bug when creating dirs for WIN 98
33 // it is difficult to fix, because we have no WIN 98 runnung 34 // it is difficult to fix, because we have no WIN 98 runnung
34 // such that we try it to create the dirs at startup here 35 // such that we try it to create the dirs at startup here
35 if ( hdir == "C:\\" ) { // win 98 or ME 36 if ( hdir == "C:\\" ) { // win 98 or ME
36 QDir app_dir; 37 QDir app_dir;
37 if ( !app_dir.exists("C:\\kdepim") ) 38 if ( !app_dir.exists("C:\\kdepim") )
38 app_dir.mkdir ("C:\\kdepim"); 39 app_dir.mkdir ("C:\\kdepim");
39 if ( !app_dir.exists("C:\\kdepim\\apps") ) 40 if ( !app_dir.exists("C:\\kdepim\\apps") )
40 app_dir.mkdir ("C:\\kdepim\\apps"); 41 app_dir.mkdir ("C:\\kdepim\\apps");
41 if ( !app_dir.exists("C:\\kdepim\\config") ) 42 if ( !app_dir.exists("C:\\kdepim\\config") )
42 app_dir.mkdir ("C:\\kdepim\\config"); 43 app_dir.mkdir ("C:\\kdepim\\config");
43 if ( !app_dir.exists("C:\\kdepim\\apps\\korganizer") ) 44 if ( !app_dir.exists("C:\\kdepim\\apps\\korganizer") )
44 app_dir.mkdir ("C:\\kdepim\\apps\\korganizer"); 45 app_dir.mkdir ("C:\\kdepim\\apps\\korganizer");
45 } 46 }
46#endif 47#endif
47 bool exitHelp = false; 48 bool exitHelp = false;
48 if ( argc > 1 ) { 49 if ( argc > 1 ) {
49 QString command = argv[1]; 50 QString command = argv[1];
50 if ( command == "-help" ){ 51 if ( command == "-help" ){
51 printf("KO/Pi command line commands:\n"); 52 printf("KO/Pi command line commands:\n");
52 printf(" no command: Start KO/Pi in usual way\n"); 53 printf(" no command: Start KO/Pi in usual way\n");
53 printf(" -help: This output\n"); 54 printf(" -help: This output\n");
54 printf("Next Option: Open or Show after start:\n"); 55 printf("Next Option: Open or Show after start:\n");
55 printf(" -newTodo: New Todo dialog\n"); 56 printf(" -newTodo: New Todo dialog\n");
56 printf(" -newEvent: New Event dialog\n"); 57 printf(" -newEvent: New Event dialog\n");
57 printf(" -showList: List view\n"); 58 printf(" -showList: List view\n");
58 printf(" -showDay: Day view\n"); 59 printf(" -showDay: Day view\n");
59 printf(" -showWWeek: Work Week view\n"); 60 printf(" -showWWeek: Work Week view\n");
60 printf(" -showWeek: Week view\n"); 61 printf(" -showWeek: Week view\n");
61 printf(" -showTodo: Todo view\n"); 62 printf(" -showTodo: Todo view\n");
62 printf(" -showJournal: Journal view\n"); 63 printf(" -showJournal: Journal view\n");
63 printf(" -showKO: Next Days view\n"); 64 printf(" -showKO: Next Days view\n");
64 printf(" -showWNext: What's Next view\n"); 65 printf(" -showWNext: What's Next view\n");
65 printf(" -showNextXView: Next X View\n"); 66 printf(" -showNextXView: Next X View\n");
66 printf(" -new[Y] and -show[X] may be used togehther\n"); 67 printf(" -new[Y] and -show[X] may be used togehther\n");
67 printf(" KO/Pi is exiting now. Bye!\n"); 68 printf(" KO/Pi is exiting now. Bye!\n");
68 exitHelp = true; 69 exitHelp = true;
69 } 70 }
70 } 71 }
71 if ( ! exitHelp ) { 72 if ( ! exitHelp ) {
72 KGlobal::setAppName( "korganizer" ); 73 KGlobal::setAppName( "korganizer" );
73 QString fileName ; 74 QString fileName ;
74#ifndef DESKTOP_VERSION 75#ifndef DESKTOP_VERSION
75 fileName = getenv("QPEDIR"); 76 fileName = getenv("QPEDIR");
76 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); 77 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
77#else 78#else
78 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/"; 79 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
79 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName)); 80 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
80#endif 81#endif
81 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer"))); 82 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer")));
82 MainWindow m; 83 MainWindow m;
83#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
84 85
85 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 86 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
86 a.showMainWidget(&m ); 87 a.showMainWidget(&m );
87#else 88#else
88 a.setMainWidget(&m ); 89 a.setMainWidget(&m );
89 m.show(); 90 m.show();
90 //m.resize( 800, 600 ); 91 //m.resize( 800, 600 );
91 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 92 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
92#endif 93#endif
93 if ( argc > 1 ) { 94 if ( argc > 1 ) {
94 QCString command = argv[1]; 95 QCString command = argv[1];
95 if ( argc > 2 ) 96 if ( argc > 2 )
96 command += argv[2]; 97 command += argv[2];
97 qApp->processEvents(); 98 qApp->processEvents();
98 m.recieve(command, QByteArray() ); 99 m.recieve(command, QByteArray() );
99 100
100 } 101 }
101 102
102 a.exec(); 103 a.exec();
103 dumpMissing(); 104 dumpMissing();
105
106 KPimGlobalPrefs::instance()->writeConfig();
104 } 107 }
105 qDebug("KO: Bye! "); 108 qDebug("KO: Bye! ");
106} 109}