summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/koprefsdialog.cpp4
-rw-r--r--korganizer/calendarview.cpp18
-rw-r--r--korganizer/mainwindow.cpp23
-rw-r--r--korganizer/mainwindow.h1
4 files changed, 35 insertions, 11 deletions
diff --git a/kmicromail/koprefsdialog.cpp b/kmicromail/koprefsdialog.cpp
index 4af4a8c..40347cc 100644
--- a/kmicromail/koprefsdialog.cpp
+++ b/kmicromail/koprefsdialog.cpp
@@ -1,1746 +1,1750 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,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#include <kdialog.h> 23#include <kdialog.h>
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qvbox.h> 34#include <qvbox.h>
35#include <qhbox.h> 35#include <qhbox.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44 44
45#include <kcolorbutton.h> 45#include <kcolorbutton.h>
46#include <kdebug.h> 46#include <kdebug.h>
47#include <klocale.h> 47#include <klocale.h>
48#include <kglobal.h> 48#include <kglobal.h>
49#include <kfontdialog.h> 49#include <kfontdialog.h>
50#include <kfiledialog.h> 50#include <kfiledialog.h>
51#include <kmessagebox.h> 51#include <kmessagebox.h>
52#include <kcolordialog.h> 52#include <kcolordialog.h>
53#include <kiconloader.h> 53#include <kiconloader.h>
54#include <kemailsettings.h> 54#include <kemailsettings.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56 56
57#include <klineedit.h> 57#include <klineedit.h>
58 58
59 59
60#include "koprefs.h" 60#include "koprefs.h"
61 61
62#include "koprefsdialog.h" 62#include "koprefsdialog.h"
63//#include <kprefswidget.h> 63//#include <kprefswidget.h>
64 64
65 65
66KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : 66KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) :
67 KPrefsDialog(KOPrefs::instance(),parent,name,true) 67 KPrefsDialog(KOPrefs::instance(),parent,name,true)
68{ 68{
69 69
70 setCaption( i18n("Settings - some need a restart (nr)")); 70 setCaption( i18n("Settings - some need a restart (nr)"));
71 setupGlobalTab(); 71 setupGlobalTab();
72 setupMainTab(); 72 setupMainTab();
73 setupMailTab();; 73 setupMailTab();;
74 setupFontsTab(); 74 setupFontsTab();
75 readConfig(); 75 readConfig();
76#ifndef DESKTOP_VERSION
77 if ( QApplication::desktop()->height() == 480 )
78 hideButtons();
79#endif
76 80
77#if 0 81#if 0
78 82
79 setupMainTab(); 83 setupMainTab();
80 setupLocaleTab(); 84 setupLocaleTab();
81 setupTimeZoneTab(); 85 setupTimeZoneTab();
82 setupTimeTab(); 86 setupTimeTab();
83 setupLocaleDateTab(); 87 setupLocaleDateTab();
84 setupFontsTab(); 88 setupFontsTab();
85 setupColorsTab(); 89 setupColorsTab();
86 setupViewsTab(); 90 setupViewsTab();
87 //setupSyncTab(); 91 //setupSyncTab();
88 //setupSyncAlgTab(); 92 //setupSyncAlgTab();
89 //setupPrinterTab(); 93 //setupPrinterTab();
90 //setupGroupSchedulingTab(); 94 //setupGroupSchedulingTab();
91 //setupGroupAutomationTab(); 95 //setupGroupAutomationTab();
92#endif 96#endif
93} 97}
94 98
95#include "kpimglobalprefs.h" 99#include "kpimglobalprefs.h"
96 100
97KOPrefsDialog::~KOPrefsDialog() 101KOPrefsDialog::~KOPrefsDialog()
98{ 102{
99} 103}
100void KOPrefsDialog::setupGlobalTab() 104void KOPrefsDialog::setupGlobalTab()
101{ 105{
102 QFrame *topFrame = addPage(i18n("Global"),0,0); 106 QFrame *topFrame = addPage(i18n("Global"),0,0);
103 kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" ); 107 kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" );
104 QVBoxLayout *topLayout = new QVBoxLayout(topFrame); 108 QVBoxLayout *topLayout = new QVBoxLayout(topFrame);
105 topLayout->addWidget( kdelibcfg ); 109 topLayout->addWidget( kdelibcfg );
106 110
107 111
108} 112}
109void KOPrefsDialog::setupMainTab() 113void KOPrefsDialog::setupMainTab()
110{ 114{
111 QFrame *topFrame = addPage(i18n("General"),0,0); 115 QFrame *topFrame = addPage(i18n("General"),0,0);
112 116
113 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 117 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
114 topLayout->setSpacing(spacingHint()); 118 topLayout->setSpacing(spacingHint());
115 topLayout->setMargin(marginHint()); 119 topLayout->setMargin(marginHint());
116 120
117 121
118 mNameEdit = new QLineEdit(topFrame); 122 mNameEdit = new QLineEdit(topFrame);
119 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); 123 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame);
120 topLayout->addWidget(mNameLabel,0,0); 124 topLayout->addWidget(mNameLabel,0,0);
121 topLayout->addWidget(mNameEdit,0,1); 125 topLayout->addWidget(mNameEdit,0,1);
122 126
123 mEmailEdit = new QLineEdit(topFrame); 127 mEmailEdit = new QLineEdit(topFrame);
124 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); 128 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame);
125 topLayout->addWidget(mEmailLabel,1,0); 129 topLayout->addWidget(mEmailLabel,1,0);
126 topLayout->addWidget(mEmailEdit,1,1); 130 topLayout->addWidget(mEmailEdit,1,1);
127 QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame); 131 QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame);
128 topLayout->addMultiCellWidget(lab,2,2,0,1); 132 topLayout->addMultiCellWidget(lab,2,2,0,1);
129 KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"), 133 KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"),
130 &(KOPrefs::instance()->mUseKapi),topFrame); 134 &(KOPrefs::instance()->mUseKapi),topFrame);
131 topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1); 135 topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1);
132} 136}
133 137
134void KOPrefsDialog::setupMailTab() 138void KOPrefsDialog::setupMailTab()
135{ 139{
136 QFrame *topFrame = addPage(i18n("Mail"),0,0); 140 QFrame *topFrame = addPage(i18n("Mail"),0,0);
137 141
138 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 142 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
139 topLayout->setSpacing(spacingHint()); 143 topLayout->setSpacing(spacingHint());
140 topLayout->setMargin(marginHint()); 144 topLayout->setMargin(marginHint());
141 145
142 KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"), 146 KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"),
143 &(KOPrefs::instance()->mViewAsHtml),topFrame); 147 &(KOPrefs::instance()->mViewAsHtml),topFrame);
144 topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); 148 topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1);
145 149
146 150
147 ttt = addWidBool(i18n("Send mails later"), 151 ttt = addWidBool(i18n("Send mails later"),
148 &(KOPrefs::instance()->mSendLater),topFrame); 152 &(KOPrefs::instance()->mSendLater),topFrame);
149 topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1); 153 topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1);
150 ttt = addWidBool(i18n("Show \"To\" field in list view"), 154 ttt = addWidBool(i18n("Show \"To\" field in list view"),
151 &(KOPrefs::instance()->mShowToField),topFrame); 155 &(KOPrefs::instance()->mShowToField),topFrame);
152 topLayout->addMultiCellWidget(ttt->checkBox(),2,2,0,1); 156 topLayout->addMultiCellWidget(ttt->checkBox(),2,2,0,1);
153 157
154 int iii =3; 158 int iii =3;
155 ttt = addWidBool(i18n("Show info fields at startup"), 159 ttt = addWidBool(i18n("Show info fields at startup"),
156 &(KOPrefs::instance()->mShowInfoStart),topFrame); 160 &(KOPrefs::instance()->mShowInfoStart),topFrame);
157 topLayout->addMultiCellWidget(ttt->checkBox(),iii,iii,0,1); 161 topLayout->addMultiCellWidget(ttt->checkBox(),iii,iii,0,1);
158 ++iii; 162 ++iii;
159 ttt = addWidBool(i18n("Show \"Subject\" info field"), 163 ttt = addWidBool(i18n("Show \"Subject\" info field"),
160 &(KOPrefs::instance()->mShowInfoSub),topFrame); 164 &(KOPrefs::instance()->mShowInfoSub),topFrame);
161 topLayout->addMultiCellWidget(ttt->checkBox(),iii,iii,0,1); 165 topLayout->addMultiCellWidget(ttt->checkBox(),iii,iii,0,1);
162 ++iii; 166 ++iii;
163 ttt = addWidBool(i18n("Show \"From\" info field"), 167 ttt = addWidBool(i18n("Show \"From\" info field"),
164 &(KOPrefs::instance()->mShowInfoFrom),topFrame); 168 &(KOPrefs::instance()->mShowInfoFrom),topFrame);
165 topLayout->addMultiCellWidget(ttt->checkBox(),iii,iii,0,1); 169 topLayout->addMultiCellWidget(ttt->checkBox(),iii,iii,0,1);
166 ++iii; 170 ++iii;
167 ttt = addWidBool(i18n("Show \"To\" info field"), 171 ttt = addWidBool(i18n("Show \"To\" info field"),
168 &(KOPrefs::instance()->mShowInfoTo),topFrame); 172 &(KOPrefs::instance()->mShowInfoTo),topFrame);
169 topLayout->addMultiCellWidget(ttt->checkBox(),iii,iii,0,1); 173 topLayout->addMultiCellWidget(ttt->checkBox(),iii,iii,0,1);
170 ++iii; 174 ++iii;
171 175
172 /* 176 /*
173 mCodecEdit = new QLineEdit(topFrame); 177 mCodecEdit = new QLineEdit(topFrame);
174 topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1); 178 topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1);
175 topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1); 179 topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1);
176 topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1); 180 topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1);
177 */ 181 */
178} 182}
179void KOPrefsDialog::setupFontsTab() 183void KOPrefsDialog::setupFontsTab()
180{ 184{
181 185
182 QFrame *topFrame = addPage(i18n("Fonts"),0,0); 186 QFrame *topFrame = addPage(i18n("Fonts"),0,0);
183 // DesktopIcon("fonts",KIcon::SizeMedium)); 187 // DesktopIcon("fonts",KIcon::SizeMedium));
184 188
185 QGridLayout *topLayout = new QGridLayout(topFrame,7,3); 189 QGridLayout *topLayout = new QGridLayout(topFrame,7,3);
186 topLayout->setSpacing(1); 190 topLayout->setSpacing(1);
187 topLayout->setMargin(3); 191 topLayout->setMargin(3);
188 KPrefsDialogWidFont * tVFont; 192 KPrefsDialogWidFont * tVFont;
189 int i = 0; 193 int i = 0;
190 KPrefsDialogWidFont *timeLabelsFont = 194 KPrefsDialogWidFont *timeLabelsFont =
191 addWidFont(i18n("OK"),i18n("Application(nr)"), 195 addWidFont(i18n("OK"),i18n("Application(nr)"),
192 &(KOPrefs::instance()->mAppFont),topFrame); 196 &(KOPrefs::instance()->mAppFont),topFrame);
193 topLayout->addWidget(timeLabelsFont->label(),i,0); 197 topLayout->addWidget(timeLabelsFont->label(),i,0);
194 topLayout->addWidget(timeLabelsFont->preview(),i,1); 198 topLayout->addWidget(timeLabelsFont->preview(),i,1);
195 topLayout->addWidget(timeLabelsFont->button(),i,2); 199 topLayout->addWidget(timeLabelsFont->button(),i,2);
196 ++i; 200 ++i;
197 201
198 202
199 timeLabelsFont = 203 timeLabelsFont =
200 addWidFont(i18n("Dear Mr."),i18n("Compose mail:"), 204 addWidFont(i18n("Dear Mr."),i18n("Compose mail:"),
201 &(KOPrefs::instance()->mComposeFont),topFrame); 205 &(KOPrefs::instance()->mComposeFont),topFrame);
202 topLayout->addWidget(timeLabelsFont->label(),i,0); 206 topLayout->addWidget(timeLabelsFont->label(),i,0);
203 topLayout->addWidget(timeLabelsFont->preview(),i,1); 207 topLayout->addWidget(timeLabelsFont->preview(),i,1);
204 topLayout->addWidget(timeLabelsFont->button(),i,2); 208 topLayout->addWidget(timeLabelsFont->button(),i,2);
205 ++i; 209 ++i;
206 210
207 KPrefsDialogWidFont *timeBarFont = 211 KPrefsDialogWidFont *timeBarFont =
208 addWidFont(i18n("Hello"),i18n("Read mail:"), 212 addWidFont(i18n("Hello"),i18n("Read mail:"),
209 &(KOPrefs::instance()->mReadFont),topFrame); 213 &(KOPrefs::instance()->mReadFont),topFrame);
210 topLayout->addWidget(timeBarFont->label(),i,0); 214 topLayout->addWidget(timeBarFont->label(),i,0);
211 topLayout->addWidget(timeBarFont->preview(),i,1); 215 topLayout->addWidget(timeBarFont->preview(),i,1);
212 topLayout->addWidget(timeBarFont->button(),i,2); 216 topLayout->addWidget(timeBarFont->button(),i,2);
213 ++i; 217 ++i;
214 218
215 topLayout->setColStretch(1,1); 219 topLayout->setColStretch(1,1);
216 topLayout->setRowStretch(4,1); 220 topLayout->setRowStretch(4,1);
217 221
218} 222}
219void KOPrefsDialog::usrReadConfig() 223void KOPrefsDialog::usrReadConfig()
220{ 224{
221 225
222 mNameEdit->setText(KOPrefs::instance()->mName); 226 mNameEdit->setText(KOPrefs::instance()->mName);
223 mEmailEdit->setText(KOPrefs::instance()->mEmail); 227 mEmailEdit->setText(KOPrefs::instance()->mEmail);
224 //mCodecEdit->setText(KOPrefs::instance()->mSendCodec); 228 //mCodecEdit->setText(KOPrefs::instance()->mSendCodec);
225 kdelibcfg->readConfig(); 229 kdelibcfg->readConfig();
226} 230}
227void KOPrefsDialog::usrWriteConfig() 231void KOPrefsDialog::usrWriteConfig()
228{ 232{
229 KOPrefs::instance()->mName = mNameEdit->text(); 233 KOPrefs::instance()->mName = mNameEdit->text();
230 KOPrefs::instance()->mEmail = mEmailEdit->text(); 234 KOPrefs::instance()->mEmail = mEmailEdit->text();
231 //KOPrefs::instance()->mSendCodec = mCodecEdit->text(); 235 //KOPrefs::instance()->mSendCodec = mCodecEdit->text();
232 kdelibcfg->writeConfig(); 236 kdelibcfg->writeConfig();
233 237
234 238
235} 239}
236 240
237#if 0 241#if 0
238void KOPrefsDialog::setupLocaleDateTab() 242void KOPrefsDialog::setupLocaleDateTab()
239{ 243{
240QFrame *topFrame = addPage(i18n("Date Format"),0,0); 244QFrame *topFrame = addPage(i18n("Date Format"),0,0);
241 QGridLayout *topLayout = new QGridLayout(topFrame,3,2); 245 QGridLayout *topLayout = new QGridLayout(topFrame,3,2);
242 topLayout->setSpacing(spacingHint()); 246 topLayout->setSpacing(spacingHint());
243 topLayout->setMargin(marginHint()); 247 topLayout->setMargin(marginHint());
244 int iii = 0; 248 int iii = 0;
245 249
246 250
247 KPrefsWidRadios *syncPrefsGroup = 251 KPrefsWidRadios *syncPrefsGroup =
248 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); 252 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame);
249 QString format; 253 QString format;
250 if ( QApplication::desktop()->width() < 480 ) 254 if ( QApplication::desktop()->width() < 480 )
251 format = "(%d.%m.%Y)"; 255 format = "(%d.%m.%Y)";
252 else 256 else
253 format = "(%d.%m.%Y|%A %d %B %Y)"; 257 format = "(%d.%m.%Y|%A %d %B %Y)";
254 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 258 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
255 if ( QApplication::desktop()->width() < 480 ) 259 if ( QApplication::desktop()->width() < 480 )
256 format = "(%m.%d.%Y)"; 260 format = "(%m.%d.%Y)";
257 else 261 else
258 format = "(%m.%d.%Y|%A %B %d %Y)"; 262 format = "(%m.%d.%Y|%A %B %d %Y)";
259 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); 263 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
260 if ( QApplication::desktop()->width() < 480 ) 264 if ( QApplication::desktop()->width() < 480 )
261 format = "(%Y-%m-%d)"; 265 format = "(%Y-%m-%d)";
262 else 266 else
263 format = "(%Y-%m-%d|%A %Y %B %d)"; 267 format = "(%Y-%m-%d|%A %Y %B %d)";
264 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); 268 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
265 syncPrefsGroup->addRadio(i18n("User defined")); 269 syncPrefsGroup->addRadio(i18n("User defined"));
266 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 270 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
267 ++iii; 271 ++iii;
268 ++iii; 272 ++iii;
269 QLabel * lab; 273 QLabel * lab;
270 mUserDateFormatLong = new QLineEdit(topFrame); 274 mUserDateFormatLong = new QLineEdit(topFrame);
271 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); 275 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
272 topLayout->addWidget(lab ,iii,0); 276 topLayout->addWidget(lab ,iii,0);
273 topLayout->addWidget(mUserDateFormatLong,iii,1); 277 topLayout->addWidget(mUserDateFormatLong,iii,1);
274 ++iii; 278 ++iii;
275 mUserDateFormatShort = new QLineEdit(topFrame); 279 mUserDateFormatShort = new QLineEdit(topFrame);
276 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); 280 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
277 topLayout->addWidget(lab ,iii,0); 281 topLayout->addWidget(lab ,iii,0);
278 topLayout->addWidget(mUserDateFormatShort,iii,1); 282 topLayout->addWidget(mUserDateFormatShort,iii,1);
279 ++iii; 283 ++iii;
280 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); 284 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
281 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 285 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
282 ++iii; 286 ++iii;
283 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); 287 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
284 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 288 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
285 ++iii; 289 ++iii;
286 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); 290 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
287 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 291 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
288 ++iii; 292 ++iii;
289 293
290} 294}
291 295
292void KOPrefsDialog::setupLocaleTab() 296void KOPrefsDialog::setupLocaleTab()
293{ 297{
294 QFrame *topFrame = addPage(i18n("Locale"),0,0); 298 QFrame *topFrame = addPage(i18n("Locale"),0,0);
295 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 299 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
296 topLayout->setSpacing(spacingHint()); 300 topLayout->setSpacing(spacingHint());
297 topLayout->setMargin(marginHint()); 301 topLayout->setMargin(marginHint());
298 int iii = 0; 302 int iii = 0;
299 KPrefsWidRadios *syncPrefsGroup = 303 KPrefsWidRadios *syncPrefsGroup =
300 addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); 304 addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame);
301 syncPrefsGroup->addRadio(i18n("English")); 305 syncPrefsGroup->addRadio(i18n("English"));
302 syncPrefsGroup->addRadio(i18n("German")); 306 syncPrefsGroup->addRadio(i18n("German"));
303 syncPrefsGroup->addRadio(i18n("French")); 307 syncPrefsGroup->addRadio(i18n("French"));
304 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); 308 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
305 if ( QApplication::desktop()->width() < 300 ) 309 if ( QApplication::desktop()->width() < 300 )
306 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 310 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
307 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 311 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
308 ++iii; 312 ++iii;
309 313
310 syncPrefsGroup = 314 syncPrefsGroup =
311 addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); 315 addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame);
312 if ( QApplication::desktop()->width() > 300 ) 316 if ( QApplication::desktop()->width() > 300 )
313 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 317 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
314 syncPrefsGroup->addRadio(i18n("24:00")); 318 syncPrefsGroup->addRadio(i18n("24:00"));
315 syncPrefsGroup->addRadio(i18n("12:00am")); 319 syncPrefsGroup->addRadio(i18n("12:00am"));
316 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 320 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
317 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 321 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
318 ++iii; 322 ++iii;
319 KPrefsDialogWidBool *sb; 323 KPrefsDialogWidBool *sb;
320 if ( QApplication::desktop()->width() < 300 ) { 324 if ( QApplication::desktop()->width() < 300 ) {
321 sb = 325 sb =
322 addWidBool(i18n("Week starts on Sunday"), 326 addWidBool(i18n("Week starts on Sunday"),
323 &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); 327 &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame);
324 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 328 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
325 ++iii; 329 ++iii;
326 sb = 330 sb =
327 addWidBool(i18n("Use short date in (WN/E) view"), 331 addWidBool(i18n("Use short date in (WN/E) view"),
328 &(KOPrefs::instance()->mShortDateInViewer),topFrame); 332 &(KOPrefs::instance()->mShortDateInViewer),topFrame);
329 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 333 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
330 } 334 }
331 else { 335 else {
332 QWidget * hb = new QWidget( topFrame ); 336 QWidget * hb = new QWidget( topFrame );
333 QHBoxLayout *hbLayout = new QHBoxLayout(hb); 337 QHBoxLayout *hbLayout = new QHBoxLayout(hb);
334 sb = 338 sb =
335 addWidBool(i18n("Week starts on Sunday"), 339 addWidBool(i18n("Week starts on Sunday"),
336 &(KOPrefs::instance()->mWeekStartsOnSunday),hb); 340 &(KOPrefs::instance()->mWeekStartsOnSunday),hb);
337 hbLayout->addWidget(sb->checkBox() ); 341 hbLayout->addWidget(sb->checkBox() );
338 sb = 342 sb =
339 addWidBool(i18n("Use short date in (WN/E) view"), 343 addWidBool(i18n("Use short date in (WN/E) view"),
340 &(KOPrefs::instance()->mShortDateInViewer),hb); 344 &(KOPrefs::instance()->mShortDateInViewer),hb);
341 hbLayout->addWidget(sb->checkBox() ); 345 hbLayout->addWidget(sb->checkBox() );
342 topLayout->addMultiCellWidget(hb, iii,iii,0,1); 346 topLayout->addMultiCellWidget(hb, iii,iii,0,1);
343 347
344 } 348 }
345 //#ifndef DESKTOP_VERSION 349 //#ifndef DESKTOP_VERSION
346#if 0 350#if 0
347 ++iii; 351 ++iii;
348 sb = 352 sb =
349 addWidBool(i18n("Quick load/save (w/o Unicode)"), 353 addWidBool(i18n("Quick load/save (w/o Unicode)"),
350 &(KOPrefs::instance()->mUseQuicksave),topFrame); 354 &(KOPrefs::instance()->mUseQuicksave),topFrame);
351 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 355 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
352#endif 356#endif
353} 357}
354void KOPrefsDialog::showSyncPage() 358void KOPrefsDialog::showSyncPage()
355{ 359{
356 showPage ( 2 ) ; 360 showPage ( 2 ) ;
357 361
358} 362}
359void KOPrefsDialog::setupSyncAlgTab() 363void KOPrefsDialog::setupSyncAlgTab()
360{ 364{
361#if 0 365#if 0
362 QLabel * lab; 366 QLabel * lab;
363 QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0); 367 QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0);
364 mSetupSyncAlgTab = topFrame; 368 mSetupSyncAlgTab = topFrame;
365 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 369 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
366 topLayout->setSpacing(spacingHint()); 370 topLayout->setSpacing(spacingHint());
367 topLayout->setMargin(marginHint()); 371 topLayout->setMargin(marginHint());
368 int iii = 0; 372 int iii = 0;
369 373
370 KPrefsDialogWidBool *sb = 374 KPrefsDialogWidBool *sb =
371 addWidBool(i18n("Ask for preferences before syncing"), 375 addWidBool(i18n("Ask for preferences before syncing"),
372 &(KOPrefs::instance()->mAskForPreferences),topFrame); 376 &(KOPrefs::instance()->mAskForPreferences),topFrame);
373 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 377 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
374 378
375 ++iii; 379 ++iii;
376 380
377 KPrefsWidRadios *syncPrefsGroup = 381 KPrefsWidRadios *syncPrefsGroup =
378 addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs), 382 addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs),
379 topFrame); 383 topFrame);
380 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 384 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
381 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 385 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
382 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 386 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
383 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 387 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
384 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 388 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
385 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 389 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
386 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 390 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
387 ++iii; 391 ++iii;
388 sb = 392 sb =
389 addWidBool(i18n("Show summary after syncing"), 393 addWidBool(i18n("Show summary after syncing"),
390 &(KOPrefs::instance()->mShowSyncSummary),topFrame); 394 &(KOPrefs::instance()->mShowSyncSummary),topFrame);
391 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 395 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
392 396
393 ++iii; 397 ++iii;
394#endif 398#endif
395 399
396 400
397 401
398} 402}
399 403
400 404
401void KOPrefsDialog::setupSyncTab() 405void KOPrefsDialog::setupSyncTab()
402{ 406{
403#if 0 407#if 0
404 QLabel * lab; 408 QLabel * lab;
405 QFrame *topFrame = addPage(i18n("Sync Network"),0,0); 409 QFrame *topFrame = addPage(i18n("Sync Network"),0,0);
406 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 410 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
407 topLayout->setSpacing(spacingHint()); 411 topLayout->setSpacing(spacingHint());
408 topLayout->setMargin(marginHint()); 412 topLayout->setMargin(marginHint());
409 lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame); 413 lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame);
410 int iii = 0; 414 int iii = 0;
411 topLayout->addMultiCellWidget(lab , iii,iii,0,1); 415 topLayout->addMultiCellWidget(lab , iii,iii,0,1);
412 ++iii; 416 ++iii;
413 417
414 mRemoteIPEdit = new QLineEdit(topFrame); 418 mRemoteIPEdit = new QLineEdit(topFrame);
415 lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame); 419 lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame);
416 topLayout->addWidget(lab ,iii,0); 420 topLayout->addWidget(lab ,iii,0);
417 topLayout->addWidget(mRemoteIPEdit,iii,1); 421 topLayout->addWidget(mRemoteIPEdit,iii,1);
418 ++iii; 422 ++iii;
419 mRemoteUser = new QLineEdit(topFrame); 423 mRemoteUser = new QLineEdit(topFrame);
420 lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame); 424 lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame);
421 topLayout->addWidget(lab ,iii,0); 425 topLayout->addWidget(lab ,iii,0);
422 topLayout->addWidget(mRemoteUser, iii,1); 426 topLayout->addWidget(mRemoteUser, iii,1);
423 ++iii; 427 ++iii;
424 428
425 mRemoteFile = new QLineEdit(topFrame); 429 mRemoteFile = new QLineEdit(topFrame);
426 lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame); 430 lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame);
427 topLayout->addWidget(lab ,iii,0); 431 topLayout->addWidget(lab ,iii,0);
428 topLayout->addWidget(mRemoteFile,iii,1); 432 topLayout->addWidget(mRemoteFile,iii,1);
429 ++iii; 433 ++iii;
430 434
431 mLocalTempFile = new QLineEdit(topFrame); 435 mLocalTempFile = new QLineEdit(topFrame);
432 lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame); 436 lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame);
433 topLayout->addWidget(lab ,iii,0); 437 topLayout->addWidget(lab ,iii,0);
434 topLayout->addWidget(mLocalTempFile,iii,1); 438 topLayout->addWidget(mLocalTempFile,iii,1);
435 ++iii; 439 ++iii;
436 440
437 KPrefsDialogWidBool *wb = 441 KPrefsDialogWidBool *wb =
438 addWidBool(i18n("Write back synced file"), 442 addWidBool(i18n("Write back synced file"),
439 &(KOPrefs::instance()->mWriteBackFile),topFrame); 443 &(KOPrefs::instance()->mWriteBackFile),topFrame);
440 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); 444 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1);
441 ++iii; 445 ++iii;
442 wb = 446 wb =
443 addWidBool(i18n("Write back existing entries only"), 447 addWidBool(i18n("Write back existing entries only"),
444 &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame); 448 &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame);
445 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); 449 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1);
446 ++iii; 450 ++iii;
447 451
448#endif 452#endif
449} 453}
450 454
451void KOPrefsDialog::setupMainTab() 455void KOPrefsDialog::setupMainTab()
452{ 456{
453 QFrame *topFrame = addPage(i18n("General"),0,0); 457 QFrame *topFrame = addPage(i18n("General"),0,0);
454 // DesktopIcon("identity",KIcon::SizeMedium)); 458 // DesktopIcon("identity",KIcon::SizeMedium));
455 459
456 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 460 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
457 topLayout->setSpacing(spacingHint()); 461 topLayout->setSpacing(spacingHint());
458 topLayout->setMargin(marginHint()); 462 topLayout->setMargin(marginHint());
459 463
460 // KPrefsDialogWidBool *emailControlCenter = 464 // KPrefsDialogWidBool *emailControlCenter =
461// addWidBool(i18n("&Use email settings from Control Center"), 465// addWidBool(i18n("&Use email settings from Control Center"),
462// &(KOPrefs::instance()->mEmailControlCenter),topFrame); 466// &(KOPrefs::instance()->mEmailControlCenter),topFrame);
463// topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); 467// topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1);
464 // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), 468 // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)),
465 // SLOT(toggleEmailSettings(bool))); 469 // SLOT(toggleEmailSettings(bool)));
466 470
467 mNameEdit = new QLineEdit(topFrame); 471 mNameEdit = new QLineEdit(topFrame);
468 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); 472 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame);
469 topLayout->addWidget(mNameLabel,0,0); 473 topLayout->addWidget(mNameLabel,0,0);
470 topLayout->addWidget(mNameEdit,0,1); 474 topLayout->addWidget(mNameEdit,0,1);
471 475
472 mEmailEdit = new QLineEdit(topFrame); 476 mEmailEdit = new QLineEdit(topFrame);
473 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); 477 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame);
474 topLayout->addWidget(mEmailLabel,1,0); 478 topLayout->addWidget(mEmailLabel,1,0);
475 topLayout->addWidget(mEmailEdit,1,1); 479 topLayout->addWidget(mEmailEdit,1,1);
476 KPrefsDialogWidBool *wb; 480 KPrefsDialogWidBool *wb;
477 QHBox *dummy; 481 QHBox *dummy;
478 if ( QApplication::desktop()->width() > 480 ) { 482 if ( QApplication::desktop()->width() > 480 ) {
479 dummy = new QHBox(topFrame); 483 dummy = new QHBox(topFrame);
480 } else { 484 } else {
481 dummy = new QVBox(topFrame); 485 dummy = new QVBox(topFrame);
482 } 486 }
483 487
484 topLayout->addMultiCellWidget(dummy, 2,2,0,1); 488 topLayout->addMultiCellWidget(dummy, 2,2,0,1);
485 addWidBool(i18n("Full menu bar(nr)"), 489 addWidBool(i18n("Full menu bar(nr)"),
486 &(KOPrefs::instance()->mShowFullMenu),dummy); 490 &(KOPrefs::instance()->mShowFullMenu),dummy);
487 491
488 492
489 addWidBool(i18n("Mini icons in toolbar(nr)"), 493 addWidBool(i18n("Mini icons in toolbar(nr)"),
490 &(KOPrefs::instance()->mToolBarMiniIcons),dummy); 494 &(KOPrefs::instance()->mToolBarMiniIcons),dummy);
491 495
492 496
493 dummy = new QHBox(topFrame); 497 dummy = new QHBox(topFrame);
494 new QLabel(i18n("Days in What's Next:"),dummy); 498 new QLabel(i18n("Days in What's Next:"),dummy);
495 mWhatsNextSpin = new QSpinBox(1,14,1,dummy); 499 mWhatsNextSpin = new QSpinBox(1,14,1,dummy);
496 500
497 topLayout->addMultiCellWidget(dummy,3,3,0,1); 501 topLayout->addMultiCellWidget(dummy,3,3,0,1);
498 502
499 503
500 504
501 dummy = new QHBox(topFrame); 505 dummy = new QHBox(topFrame);
502 new QLabel(i18n("Days in Next-X-Days:"),dummy); 506 new QLabel(i18n("Days in Next-X-Days:"),dummy);
503 mNextXDaysSpin = new QSpinBox(2,14,1,dummy); 507 mNextXDaysSpin = new QSpinBox(2,14,1,dummy);
504 508
505 topLayout->addMultiCellWidget(dummy,4,4,0,1); 509 topLayout->addMultiCellWidget(dummy,4,4,0,1);
506 510
507 QHBox *prioBox = new QHBox(topFrame); 511 QHBox *prioBox = new QHBox(topFrame);
508 // intervalBox->setSpacing(spacingHint()); 512 // intervalBox->setSpacing(spacingHint());
509 topLayout->addMultiCellWidget(prioBox,5,5,0,1); 513 topLayout->addMultiCellWidget(prioBox,5,5,0,1);
510 QString messa = i18n("Show topmost todo prios in What's Next:"); 514 QString messa = i18n("Show topmost todo prios in What's Next:");
511 515
512 if ( QApplication::desktop()->width() < 300 ) 516 if ( QApplication::desktop()->width() < 300 )
513 messa = i18n("Show topmost todo prios in What's N.:"); 517 messa = i18n("Show topmost todo prios in What's N.:");
514 QLabel *prioLabel = new QLabel(messa, prioBox); 518 QLabel *prioLabel = new QLabel(messa, prioBox);
515 mPrioSpin = new QSpinBox(0,5,1,prioBox); 519 mPrioSpin = new QSpinBox(0,5,1,prioBox);
516 if ( QApplication::desktop()->width() < 300 ) 520 if ( QApplication::desktop()->width() < 300 )
517 mPrioSpin->setFixedWidth( 40 ); 521 mPrioSpin->setFixedWidth( 40 );
518 522
519 // KPrefsDialogWidBool *bcc = 523 // KPrefsDialogWidBool *bcc =
520// addWidBool(i18n("Send copy to owner when mailing events"), 524// addWidBool(i18n("Send copy to owner when mailing events"),
521// &(KOPrefs::instance()->mBcc),topFrame); 525// &(KOPrefs::instance()->mBcc),topFrame);
522// topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); 526// topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1);
523 527
524 528
525 // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); 529 // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame);
526 //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); 530 //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1);
527 531
528 // addWidBool(i18n("Enable automatic saving of calendar"), 532 // addWidBool(i18n("Enable automatic saving of calendar"),
529 // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); 533 // &(KOPrefs::instance()->mAutoSave),autoSaveGroup);
530 534
531 QHBox *intervalBox = new QHBox(topFrame); 535 QHBox *intervalBox = new QHBox(topFrame);
532 // intervalBox->setSpacing(spacingHint()); 536 // intervalBox->setSpacing(spacingHint());
533 topLayout->addMultiCellWidget(intervalBox,6,6,0,1); 537 topLayout->addMultiCellWidget(intervalBox,6,6,0,1);
534 QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); 538 QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox);
535 mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); 539 mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox);
536 autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); 540 autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin);
537 /* 541 /*
538 QHBox * agendasize = new QHBox ( topFrame ); 542 QHBox * agendasize = new QHBox ( topFrame );
539 543
540 new QLabel (i18n("AllDayAgenda Height:"), agendasize ); 544 new QLabel (i18n("AllDayAgenda Height:"), agendasize );
541 545
542 546
543 mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); 547 mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize);
544 topLayout->addMultiCellWidget(agendasize,7,7,0,1); 548 topLayout->addMultiCellWidget(agendasize,7,7,0,1);
545 */ 549 */
546 KPrefsDialogWidBool *verticalScreen = 550 KPrefsDialogWidBool *verticalScreen =
547 addWidBool(i18n("Show vertical screen (Needs restart)"), 551 addWidBool(i18n("Show vertical screen (Needs restart)"),
548 &(KOPrefs::instance()->mVerticalScreen),topFrame); 552 &(KOPrefs::instance()->mVerticalScreen),topFrame);
549 //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); 553 //topLayout->addWidget(verticalScreen->checkBox(),ii++,0);
550 topLayout->addMultiCellWidget(verticalScreen->checkBox(),7,7,0,1); 554 topLayout->addMultiCellWidget(verticalScreen->checkBox(),7,7,0,1);
551 555
552 KPrefsDialogWidBool *ask = 556 KPrefsDialogWidBool *ask =
553 addWidBool(i18n("Ask for quit when closing KO/Pi"), 557 addWidBool(i18n("Ask for quit when closing KO/Pi"),
554 &(KOPrefs::instance()->mAskForQuit),topFrame); 558 &(KOPrefs::instance()->mAskForQuit),topFrame);
555 topLayout->addMultiCellWidget(ask->checkBox(),8,8,0,1); 559 topLayout->addMultiCellWidget(ask->checkBox(),8,8,0,1);
556 560
557 561
558 /* 562 /*
559 KPrefsDialogWidBool *confirmCheck = 563 KPrefsDialogWidBool *confirmCheck =
560 addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), 564 addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm),
561 topFrame); 565 topFrame);
562 topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); 566 topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1);
563 567
564 568
565 mEnableGroupScheduling = 569 mEnableGroupScheduling =
566 addWidBool(i18n("Enable group scheduling"), 570 addWidBool(i18n("Enable group scheduling"),
567 &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); 571 &(KOPrefs::instance()->mEnableGroupScheduling),topFrame);
568 topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); 572 topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0);
569 connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), 573 connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()),
570 SLOT(warningGroupScheduling())); 574 SLOT(warningGroupScheduling()));
571 575
572 mEnableProjectView = 576 mEnableProjectView =
573 addWidBool(i18n("Enable project view"), 577 addWidBool(i18n("Enable project view"),
574 &(KOPrefs::instance()->mEnableProjectView),topFrame); 578 &(KOPrefs::instance()->mEnableProjectView),topFrame);
575 topLayout->addWidget(mEnableProjectView->checkBox(),9,0); 579 topLayout->addWidget(mEnableProjectView->checkBox(),9,0);
576 connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), 580 connect(mEnableProjectView->checkBox(),SIGNAL(clicked()),
577 SLOT(warningProjectView())); 581 SLOT(warningProjectView()));
578 582
579 // Can't be disabled anymore 583 // Can't be disabled anymore
580 mEnableGroupScheduling->checkBox()->hide(); 584 mEnableGroupScheduling->checkBox()->hide();
581 585
582 // Disable setting, because this feature now becomes stable 586 // Disable setting, because this feature now becomes stable
583 mEnableProjectView->checkBox()->hide(); 587 mEnableProjectView->checkBox()->hide();
584 588
585 KPrefsWidRadios *defaultFormatGroup = 589 KPrefsWidRadios *defaultFormatGroup =
586 addWidRadios(i18n("Default Calendar Format"), 590 addWidRadios(i18n("Default Calendar Format"),
587 &(KOPrefs::instance()->mDefaultFormat),topFrame); 591 &(KOPrefs::instance()->mDefaultFormat),topFrame);
588 defaultFormatGroup->addRadio(i18n("vCalendar")); 592 defaultFormatGroup->addRadio(i18n("vCalendar"));
589 defaultFormatGroup->addRadio(i18n("iCalendar")); 593 defaultFormatGroup->addRadio(i18n("iCalendar"));
590 594
591 topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); 595 topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1);
592 596
593 // Default format unconditionally is iCalendar 597 // Default format unconditionally is iCalendar
594 defaultFormatGroup->groupBox()->hide(); 598 defaultFormatGroup->groupBox()->hide();
595 599
596 KPrefsWidRadios *mailClientGroup = 600 KPrefsWidRadios *mailClientGroup =
597 addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), 601 addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient),
598 topFrame); 602 topFrame);
599 mailClientGroup->addRadio(i18n("KMail")); 603 mailClientGroup->addRadio(i18n("KMail"));
600 mailClientGroup->addRadio(i18n("Sendmail")); 604 mailClientGroup->addRadio(i18n("Sendmail"));
601 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); 605 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1);
602 606
603 KPrefsDialogWidBool *htmlsave = 607 KPrefsDialogWidBool *htmlsave =
604 addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), 608 addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave),
605 topFrame); 609 topFrame);
606 topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); 610 topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1);
607 611
608 KPrefsWidRadios *destinationGroup = 612 KPrefsWidRadios *destinationGroup =
609 addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), 613 addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination),
610 topFrame); 614 topFrame);
611 destinationGroup->addRadio(i18n("be added to the standard resource")); 615 destinationGroup->addRadio(i18n("be added to the standard resource"));
612 destinationGroup->addRadio(i18n("be asked which resource to use")); 616 destinationGroup->addRadio(i18n("be asked which resource to use"));
613 topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); 617 topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1);
614 618
615 topLayout->setRowStretch(14,1); 619 topLayout->setRowStretch(14,1);
616 */ 620 */
617} 621}
618 622
619 623
620void KOPrefsDialog::setupTimeTab() 624void KOPrefsDialog::setupTimeTab()
621{ 625{
622 QFrame *topFrame = addPage(i18n("Time"),0,0); 626 QFrame *topFrame = addPage(i18n("Time"),0,0);
623 // DesktopIcon("clock",KIcon::SizeMedium)); 627 // DesktopIcon("clock",KIcon::SizeMedium));
624 628
625 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 629 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
626 topLayout->setSpacing(spacingHint()); 630 topLayout->setSpacing(spacingHint());
627 topLayout->setMargin(marginHint()); 631 topLayout->setMargin(marginHint());
628 632
629 QHBox *dummy = new QHBox(topFrame); 633 QHBox *dummy = new QHBox(topFrame);
630 KPrefsWidTime *dayBegins = 634 KPrefsWidTime *dayBegins =
631 addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), 635 addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins),
632 dummy); 636 dummy);
633 //topLayout->addWidget(dayBegins->label(),2,0); 637 //topLayout->addWidget(dayBegins->label(),2,0);
634 638
635 //topLayout->addWidget(dayBegins->spinBox(),2,1); 639 //topLayout->addWidget(dayBegins->spinBox(),2,1);
636 topLayout->addMultiCellWidget(dummy,0,0,0,1); 640 topLayout->addMultiCellWidget(dummy,0,0,0,1);
637 641
638 topLayout->addWidget(new QLabel(i18n("Default appointment time:"), 642 topLayout->addWidget(new QLabel(i18n("Default appointment time:"),
639 topFrame),1,0); 643 topFrame),1,0);
640 mStartTimeSpin = new QSpinBox(0,23,1,topFrame); 644 mStartTimeSpin = new QSpinBox(0,23,1,topFrame);
641 mStartTimeSpin->setSuffix(":00"); 645 mStartTimeSpin->setSuffix(":00");
642 topLayout->addWidget(mStartTimeSpin,1,1); 646 topLayout->addWidget(mStartTimeSpin,1,1);
643 647
644 topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"), 648 topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"),
645 topFrame),2,0); 649 topFrame),2,0);
646 mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); 650 mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame);
647 mDefaultDurationSpin->setSuffix(":00"); 651 mDefaultDurationSpin->setSuffix(":00");
648 topLayout->addWidget(mDefaultDurationSpin,2,1); 652 topLayout->addWidget(mDefaultDurationSpin,2,1);
649 653
650 QStringList alarmList; 654 QStringList alarmList;
651 alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") 655 alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes")
652 << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ; 656 << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ;
653 topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame), 657 topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame),
654 3,0); 658 3,0);
655 mAlarmTimeCombo = new QComboBox(topFrame); 659 mAlarmTimeCombo = new QComboBox(topFrame);
656 mAlarmTimeCombo->insertStringList(alarmList); 660 mAlarmTimeCombo->insertStringList(alarmList);
657 topLayout->addWidget(mAlarmTimeCombo,3,1); 661 topLayout->addWidget(mAlarmTimeCombo,3,1);
658 662
659 663
660 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, 664 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal,
661 i18n("Working Hours"), 665 i18n("Working Hours"),
662 topFrame); 666 topFrame);
663 topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1); 667 topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1);
664 workingHoursGroup->layout()->setSpacing( 0 ); 668 workingHoursGroup->layout()->setSpacing( 0 );
665 workingHoursGroup->layout()->setMargin( 4 ); 669 workingHoursGroup->layout()->setMargin( 4 );
666 QHBox *workStartBox = new QHBox(workingHoursGroup); 670 QHBox *workStartBox = new QHBox(workingHoursGroup);
667 // workStartBox->setMargin( 0 ); 671 // workStartBox->setMargin( 0 );
668 addWidTime(i18n("Daily starting hour:"), 672 addWidTime(i18n("Daily starting hour:"),
669 &(KOPrefs::instance()->mWorkingHoursStart),workStartBox); 673 &(KOPrefs::instance()->mWorkingHoursStart),workStartBox);
670 674
671 QHBox *workEndBox = new QHBox(workingHoursGroup); 675 QHBox *workEndBox = new QHBox(workingHoursGroup);
672 //workEndBox->setMargin( 0 ); 676 //workEndBox->setMargin( 0 );
673 addWidTime(i18n("Daily ending hour:"), 677 addWidTime(i18n("Daily ending hour:"),
674 &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox); 678 &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox);
675 QVBox *excludeBox = new QVBox(workingHoursGroup); 679 QVBox *excludeBox = new QVBox(workingHoursGroup);
676 //excludeBox->setMargin( 0 ); 680 //excludeBox->setMargin( 0 );
677 addWidBool(i18n("Exclude holidays"), 681 addWidBool(i18n("Exclude holidays"),
678 &(KOPrefs::instance()->mExcludeHolidays),excludeBox); 682 &(KOPrefs::instance()->mExcludeHolidays),excludeBox);
679 683
680 addWidBool(i18n("Exclude Saturdays"), 684 addWidBool(i18n("Exclude Saturdays"),
681 &(KOPrefs::instance()->mExcludeSaturdays),excludeBox); 685 &(KOPrefs::instance()->mExcludeSaturdays),excludeBox);
682 686
683// KPrefsDialogWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"), 687// KPrefsDialogWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"),
684 // &(KOPrefs::instance()->mMarcusBainsShowSeconds), 688 // &(KOPrefs::instance()->mMarcusBainsShowSeconds),
685 // topFrame); 689 // topFrame);
686// topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0); 690// topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0);
687 691
688 // topLayout->setRowStretch(6,1); 692 // topLayout->setRowStretch(6,1);
689} 693}
690 694
691 695
692void KOPrefsDialog::setupViewsTab() 696void KOPrefsDialog::setupViewsTab()
693{ 697{
694 698
695 QFrame *topFrame = addPage(i18n("Views"),0,0); 699 QFrame *topFrame = addPage(i18n("Views"),0,0);
696 // DesktopIcon("viewmag",KIcon::SizeMedium)); 700 // DesktopIcon("viewmag",KIcon::SizeMedium));
697 701
698 QGridLayout *topLayout = new QGridLayout(topFrame,6,1); 702 QGridLayout *topLayout = new QGridLayout(topFrame,6,1);
699 topLayout->setSpacing(spacingHint()); 703 topLayout->setSpacing(spacingHint());
700 topLayout->setMargin(marginHint()); 704 topLayout->setMargin(marginHint());
701 705
702// QBoxLayout *dayBeginsLayout = new QHBoxLayout; 706// QBoxLayout *dayBeginsLayout = new QHBoxLayout;
703// topLayout->addLayout(dayBeginsLayout,0,0); 707// topLayout->addLayout(dayBeginsLayout,0,0);
704 708
705// KPrefsWidTime *dayBegins = 709// KPrefsWidTime *dayBegins =
706// addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), 710// addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins),
707// topFrame); 711// topFrame);
708// dayBeginsLayout->addWidget(dayBegins->label()); 712// dayBeginsLayout->addWidget(dayBegins->label());
709// dayBeginsLayout->addStretch(1); 713// dayBeginsLayout->addStretch(1);
710// dayBeginsLayout->addWidget(dayBegins->spinBox()); 714// dayBeginsLayout->addWidget(dayBegins->spinBox());
711 715
712// QBoxLayout *nextDaysLayout = new QHBoxLayout; 716// QBoxLayout *nextDaysLayout = new QHBoxLayout;
713// topLayout->addLayout(nextDaysLayout,1,0); 717// topLayout->addLayout(nextDaysLayout,1,0);
714// nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame)); 718// nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame));
715// mNextXDaysSpin = new QSpinBox(2,14,1,topFrame); 719// mNextXDaysSpin = new QSpinBox(2,14,1,topFrame);
716// nextDaysLayout->addStretch(1); 720// nextDaysLayout->addStretch(1);
717// nextDaysLayout->addWidget(mNextXDaysSpin); 721// nextDaysLayout->addWidget(mNextXDaysSpin);
718 722
719 723
720 int ii = 0; 724 int ii = 0;
721 KPrefsDialogWidBool *dummy = 725 KPrefsDialogWidBool *dummy =
722 addWidBool(i18n("Edit item on doubleclick (if not, show)"), 726 addWidBool(i18n("Edit item on doubleclick (if not, show)"),
723 &(KOPrefs::instance()->mEditOnDoubleClick),topFrame); 727 &(KOPrefs::instance()->mEditOnDoubleClick),topFrame);
724 topLayout->addWidget(dummy->checkBox(),ii++,0); 728 topLayout->addWidget(dummy->checkBox(),ii++,0);
725 729
726 dummy = 730 dummy =
727 addWidBool(i18n("Highlight current day in agenda"), 731 addWidBool(i18n("Highlight current day in agenda"),
728 &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); 732 &(KOPrefs::instance()->mHighlightCurrentDay),topFrame);
729 topLayout->addWidget(dummy->checkBox(),ii++,0); 733 topLayout->addWidget(dummy->checkBox(),ii++,0);
730 734
731 dummy = 735 dummy =
732 addWidBool(i18n("Use light color for highlight current day"), 736 addWidBool(i18n("Use light color for highlight current day"),
733 &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); 737 &(KOPrefs::instance()->mUseHighlightLightColor),topFrame);
734 topLayout->addWidget(dummy->checkBox(),ii++,0); 738 topLayout->addWidget(dummy->checkBox(),ii++,0);
735 739
736 KPrefsDialogWidBool *dailyRecur = 740 KPrefsDialogWidBool *dailyRecur =
737 addWidBool(i18n("Show events that recur daily in date nav."), 741 addWidBool(i18n("Show events that recur daily in date nav."),
738 &(KOPrefs::instance()->mDailyRecur),topFrame); 742 &(KOPrefs::instance()->mDailyRecur),topFrame);
739 topLayout->addWidget(dailyRecur->checkBox(),ii++,0); 743 topLayout->addWidget(dailyRecur->checkBox(),ii++,0);
740 744
741 KPrefsDialogWidBool *weeklyRecur = 745 KPrefsDialogWidBool *weeklyRecur =
742 addWidBool(i18n("Show ev. that recur weekly in date nav."), 746 addWidBool(i18n("Show ev. that recur weekly in date nav."),
743 &(KOPrefs::instance()->mWeeklyRecur),topFrame); 747 &(KOPrefs::instance()->mWeeklyRecur),topFrame);
744 topLayout->addWidget(weeklyRecur->checkBox(),ii++,0); 748 topLayout->addWidget(weeklyRecur->checkBox(),ii++,0);
745 if ( QApplication::desktop()->width() > 640 ) { 749 if ( QApplication::desktop()->width() > 640 ) {
746 750
747 KPrefsDialogWidBool *enableToolTips = 751 KPrefsDialogWidBool *enableToolTips =
748 addWidBool(i18n("Enable tooltips displaying summary of ev."), 752 addWidBool(i18n("Enable tooltips displaying summary of ev."),
749 &(KOPrefs::instance()->mEnableToolTips),topFrame); 753 &(KOPrefs::instance()->mEnableToolTips),topFrame);
750 topLayout->addWidget(enableToolTips->checkBox(),ii++,0); 754 topLayout->addWidget(enableToolTips->checkBox(),ii++,0);
751 755
752 } 756 }
753 KPrefsDialogWidBool *passwdk = 757 KPrefsDialogWidBool *passwdk =
754 addWidBool(i18n("Show parent To-Do's in What's Next view"), 758 addWidBool(i18n("Show parent To-Do's in What's Next view"),
755 &(KOPrefs::instance()->mWNViewShowsParents),topFrame); 759 &(KOPrefs::instance()->mWNViewShowsParents),topFrame);
756 topLayout->addWidget(passwdk->checkBox(), ii++,0); 760 topLayout->addWidget(passwdk->checkBox(), ii++,0);
757 761
758 passwdk = 762 passwdk =
759 addWidBool(i18n("Show location in What's Next view"), 763 addWidBool(i18n("Show location in What's Next view"),
760 &(KOPrefs::instance()->mWNViewShowLocation),topFrame); 764 &(KOPrefs::instance()->mWNViewShowLocation),topFrame);
761 topLayout->addWidget(passwdk->checkBox(), ii++,0); 765 topLayout->addWidget(passwdk->checkBox(), ii++,0);
762 766
763 passwdk = 767 passwdk =
764 addWidBool(i18n("Show Sync Events in WN/Agenda view"), 768 addWidBool(i18n("Show Sync Events in WN/Agenda view"),
765 &(KOPrefs::instance()->mShowSyncEvents),topFrame); 769 &(KOPrefs::instance()->mShowSyncEvents),topFrame);
766 topLayout->addWidget(passwdk->checkBox(), ii++,0); 770 topLayout->addWidget(passwdk->checkBox(), ii++,0);
767 771
768 772
769 KPrefsDialogWidBool *marcusBainsEnabled = 773 KPrefsDialogWidBool *marcusBainsEnabled =
770 addWidBool(i18n("Show Marcus Bains line"), 774 addWidBool(i18n("Show Marcus Bains line"),
771 &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); 775 &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame);
772 topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); 776 topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0);
773 777
774 778
775 // topLayout->addWidget(hourSizeGroup,ii++,0); 779 // topLayout->addWidget(hourSizeGroup,ii++,0);
776 // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0); 780 // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0);
777 //topLayout->setRowStretch(11,1); 781 //topLayout->setRowStretch(11,1);
778 782
779 783
780 784
781 785
782 786
783 787
784 topFrame = addPage(i18n("ViewChange"),0,0); 788 topFrame = addPage(i18n("ViewChange"),0,0);
785 // DesktopIcon("viewmag",KIcon::SizeMedium)); 789 // DesktopIcon("viewmag",KIcon::SizeMedium));
786 790
787 topLayout = new QGridLayout(topFrame,6,1); 791 topLayout = new QGridLayout(topFrame,6,1);
788 topLayout->setSpacing(spacingHint()); 792 topLayout->setSpacing(spacingHint());
789 topLayout->setMargin(marginHint()); 793 topLayout->setMargin(marginHint());
790 ii = 0; 794 ii = 0;
791 795
792 796
793 dummy = 797 dummy =
794 addWidBool(i18n("Hold fullscreen on view change"), 798 addWidBool(i18n("Hold fullscreen on view change"),
795 &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame); 799 &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame);
796 topLayout->addWidget(dummy->checkBox(),ii++,0); 800 topLayout->addWidget(dummy->checkBox(),ii++,0);
797 801
798 dummy = 802 dummy =
799 addWidBool(i18n("Hold non-fullscreen on view change"), 803 addWidBool(i18n("Hold non-fullscreen on view change"),
800 &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame); 804 &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame);
801 topLayout->addWidget(dummy->checkBox(),ii++,0); 805 topLayout->addWidget(dummy->checkBox(),ii++,0);
802 806
803 807
804 KPrefsDialogWidBool *fullViewTodo = 808 KPrefsDialogWidBool *fullViewTodo =
805 addWidBool(i18n("Event list view uses full window"), 809 addWidBool(i18n("Event list view uses full window"),
806 &(KOPrefs::instance()->mFullViewTodo),topFrame); 810 &(KOPrefs::instance()->mFullViewTodo),topFrame);
807 topLayout->addWidget(fullViewTodo->checkBox(),ii++,0); 811 topLayout->addWidget(fullViewTodo->checkBox(),ii++,0);
808 812
809 KPrefsDialogWidBool *fullViewMonth = 813 KPrefsDialogWidBool *fullViewMonth =
810 addWidBool(i18n("Next days view uses full window"), 814 addWidBool(i18n("Next days view uses full window"),
811 &(KOPrefs::instance()->mFullViewMonth),topFrame); 815 &(KOPrefs::instance()->mFullViewMonth),topFrame);
812 topLayout->addWidget(fullViewMonth->checkBox(),ii++,0); 816 topLayout->addWidget(fullViewMonth->checkBox(),ii++,0);
813 817
814 dummy = 818 dummy =
815 addWidBool(i18n("Set agenda to DayBeginsAt on change"), 819 addWidBool(i18n("Set agenda to DayBeginsAt on change"),
816 &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); 820 &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame);
817 topLayout->addWidget(dummy->checkBox(),ii++,0); 821 topLayout->addWidget(dummy->checkBox(),ii++,0);
818 822
819 dummy = 823 dummy =
820 addWidBool(i18n("Set agenda to current time on change"), 824 addWidBool(i18n("Set agenda to current time on change"),
821 &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); 825 &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame);
822 topLayout->addWidget(dummy->checkBox(),ii++,0); 826 topLayout->addWidget(dummy->checkBox(),ii++,0);
823 827
824 dummy = 828 dummy =
825 addWidBool(i18n("Listview uses monthly timespan"), 829 addWidBool(i18n("Listview uses monthly timespan"),
826 &(KOPrefs::instance()->mListViewMonthTimespan),topFrame); 830 &(KOPrefs::instance()->mListViewMonthTimespan),topFrame);
827 topLayout->addWidget(dummy->checkBox(),ii++,0); 831 topLayout->addWidget(dummy->checkBox(),ii++,0);
828 dummy = 832 dummy =
829 addWidBool(i18n("Highlight selection in Time Edit"), 833 addWidBool(i18n("Highlight selection in Time Edit"),
830 &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame); 834 &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame);
831 topLayout->addWidget( dummy->checkBox(), ii++,0); 835 topLayout->addWidget( dummy->checkBox(), ii++,0);
832 836
833 837
834 838
835 839
836 840
837 topFrame = addPage(i18n("Month View"),0,0); 841 topFrame = addPage(i18n("Month View"),0,0);
838 // DesktopIcon("viewmag",KIcon::SizeMedium)); 842 // DesktopIcon("viewmag",KIcon::SizeMedium));
839 843
840 topLayout = new QGridLayout(topFrame,5,1); 844 topLayout = new QGridLayout(topFrame,5,1);
841 topLayout->setSpacing(spacingHint()); 845 topLayout->setSpacing(spacingHint());
842 topLayout->setMargin(marginHint()); 846 topLayout->setMargin(marginHint());
843 ii = 0; 847 ii = 0;
844 QLabel *lab; 848 QLabel *lab;
845 QHBox *habo = new QHBox( topFrame ); 849 QHBox *habo = new QHBox( topFrame );
846 if ( QApplication::desktop()->width() < 320 ) { 850 if ( QApplication::desktop()->width() < 320 ) {
847 lab = new QLabel ( i18n("Show events that recur "), topFrame ); 851 lab = new QLabel ( i18n("Show events that recur "), topFrame );
848 topLayout->addMultiCellWidget(lab,ii, ii,0,1); 852 topLayout->addMultiCellWidget(lab,ii, ii,0,1);
849 ii++; 853 ii++;
850 854
851 } else { 855 } else {
852 new QLabel ( i18n("Show events that recur "), habo ); 856 new QLabel ( i18n("Show events that recur "), habo );
853 857
854 } 858 }
855 dailyRecur = 859 dailyRecur =
856 addWidBool(i18n("daily"), 860 addWidBool(i18n("daily"),
857 &(KOPrefs::instance()->mMonthDailyRecur),habo); 861 &(KOPrefs::instance()->mMonthDailyRecur),habo);
858 // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); 862 // topLayout->addWidget(dailyRecur->checkBox(),ii++,0);
859 863
860 weeklyRecur = 864 weeklyRecur =
861 addWidBool(i18n("weekly"), 865 addWidBool(i18n("weekly"),
862 &(KOPrefs::instance()->mMonthWeeklyRecur),habo); 866 &(KOPrefs::instance()->mMonthWeeklyRecur),habo);
863 topLayout->addMultiCellWidget(habo,ii, ii,0,1); 867 topLayout->addMultiCellWidget(habo,ii, ii,0,1);
864 ii++; 868 ii++;
865 869
866 870
867 habo = new QHBox( topFrame ); 871 habo = new QHBox( topFrame );
868 if ( QApplication::desktop()->width() < 320 ) { 872 if ( QApplication::desktop()->width() < 320 ) {
869 lab = new QLabel (i18n("Show in every cell ") , topFrame ); 873 lab = new QLabel (i18n("Show in every cell ") , topFrame );
870 topLayout->addMultiCellWidget(lab,ii, ii,0,1); 874 topLayout->addMultiCellWidget(lab,ii, ii,0,1);
871 ii++; 875 ii++;
872 876
873 } else { 877 } else {
874 new QLabel ( i18n("Show in every cell "), habo ); 878 new QLabel ( i18n("Show in every cell "), habo );
875 } 879 }
876 weeklyRecur = 880 weeklyRecur =
877 addWidBool(i18n("short month"), 881 addWidBool(i18n("short month"),
878 &(KOPrefs::instance()->mMonthShowShort),habo); 882 &(KOPrefs::instance()->mMonthShowShort),habo);
879 weeklyRecur = 883 weeklyRecur =
880 addWidBool(i18n("icons"), 884 addWidBool(i18n("icons"),
881 &(KOPrefs::instance()->mMonthShowIcons),habo); 885 &(KOPrefs::instance()->mMonthShowIcons),habo);
882 886
883 topLayout->addMultiCellWidget(habo,ii, ii,0,1); 887 topLayout->addMultiCellWidget(habo,ii, ii,0,1);
884 ii++; 888 ii++;
885#ifdef DESKTOP_VERSION 889#ifdef DESKTOP_VERSION
886 KPrefsDialogWidBool *enableMonthScroll = 890 KPrefsDialogWidBool *enableMonthScroll =
887 addWidBool(i18n("Enable scrollbars in month view cells"), 891 addWidBool(i18n("Enable scrollbars in month view cells"),
888 &(KOPrefs::instance()->mEnableMonthScroll),topFrame); 892 &(KOPrefs::instance()->mEnableMonthScroll),topFrame);
889 topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); 893 topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0);
890#endif 894#endif
891 895
892 dummy = 896 dummy =
893 addWidBool(i18n("Show Sat/Sun together"), 897 addWidBool(i18n("Show Sat/Sun together"),
894 &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); 898 &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame);
895 topLayout->addWidget(dummy->checkBox(),ii++,0); 899 topLayout->addWidget(dummy->checkBox(),ii++,0);
896 900
897 KPrefsDialogWidBool *coloredCategoriesInMonthView = 901 KPrefsDialogWidBool *coloredCategoriesInMonthView =
898 addWidBool(i18n("Month view uses category colors"), 902 addWidBool(i18n("Month view uses category colors"),
899 &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); 903 &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame);
900 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); 904 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0);
901 905
902 dummy = 906 dummy =
903 addWidBool(i18n("Categorie colors are applied to text"), 907 addWidBool(i18n("Categorie colors are applied to text"),
904 &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); 908 &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame);
905 topLayout->addWidget(dummy->checkBox(),ii++,0); 909 topLayout->addWidget(dummy->checkBox(),ii++,0);
906 coloredCategoriesInMonthView = 910 coloredCategoriesInMonthView =
907 addWidBool(i18n("Month view uses day colors"), 911 addWidBool(i18n("Month view uses day colors"),
908 &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); 912 &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame);
909 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); 913 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0);
910 914
911 KPrefsWidColor *holidayColor = 915 KPrefsWidColor *holidayColor =
912 addWidColor(i18n("Day color odd months"), 916 addWidColor(i18n("Day color odd months"),
913 &(KOPrefs::instance()->mMonthViewOddColor),topFrame); 917 &(KOPrefs::instance()->mMonthViewOddColor),topFrame);
914 topLayout->addWidget(holidayColor->label(),ii,0); 918 topLayout->addWidget(holidayColor->label(),ii,0);
915 topLayout->addWidget(holidayColor->button(),ii++,1); 919 topLayout->addWidget(holidayColor->button(),ii++,1);
916 920
917 holidayColor = 921 holidayColor =
918 addWidColor(i18n("Day color even months"), 922 addWidColor(i18n("Day color even months"),
919 &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); 923 &(KOPrefs::instance()->mMonthViewEvenColor),topFrame);
920 topLayout->addWidget(holidayColor->label(),ii,0); 924 topLayout->addWidget(holidayColor->label(),ii,0);
921 topLayout->addWidget(holidayColor->button(),ii++,1); 925 topLayout->addWidget(holidayColor->button(),ii++,1);
922 926
923 927
924 holidayColor = 928 holidayColor =
925 addWidColor(i18n("Color for Sundays + category \"Holiday\""), 929 addWidColor(i18n("Color for Sundays + category \"Holiday\""),
926 &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); 930 &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame);
927 topLayout->addWidget(holidayColor->label(),ii,0); 931 topLayout->addWidget(holidayColor->label(),ii,0);
928 topLayout->addWidget(holidayColor->button(),ii++,1); 932 topLayout->addWidget(holidayColor->button(),ii++,1);
929 933
930 // *********************** Todo View 934 // *********************** Todo View
931 935
932 topFrame = addPage(i18n("Todo View"),0,0); 936 topFrame = addPage(i18n("Todo View"),0,0);
933 // DesktopIcon("viewmag",KIcon::SizeMedium)); 937 // DesktopIcon("viewmag",KIcon::SizeMedium));
934 938
935 topLayout = new QGridLayout(topFrame,4,1); 939 topLayout = new QGridLayout(topFrame,4,1);
936 topLayout->setSpacing(spacingHint()); 940 topLayout->setSpacing(spacingHint());
937 topLayout->setMargin(marginHint()); 941 topLayout->setMargin(marginHint());
938 ii = 0; 942 ii = 0;
939 943
940 KPrefsDialogWidBool *showCompletedTodo = 944 KPrefsDialogWidBool *showCompletedTodo =
941 addWidBool(i18n("To-do view shows completed Todos"), 945 addWidBool(i18n("To-do view shows completed Todos"),
942 &(KOPrefs::instance()->mShowCompletedTodo),topFrame); 946 &(KOPrefs::instance()->mShowCompletedTodo),topFrame);
943 topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); 947 topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0);
944 dummy = 948 dummy =
945 addWidBool(i18n("To-do view shows complete as 'xx %'"), 949 addWidBool(i18n("To-do view shows complete as 'xx %'"),
946 &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); 950 &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame);
947 topLayout->addWidget(dummy->checkBox(),ii++,0); 951 topLayout->addWidget(dummy->checkBox(),ii++,0);
948 952
949 dummy = 953 dummy =
950 addWidBool(i18n("Small To-do view uses smaller font"), 954 addWidBool(i18n("Small To-do view uses smaller font"),
951 &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); 955 &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame);
952 topLayout->addWidget(dummy->checkBox(),ii++,0); 956 topLayout->addWidget(dummy->checkBox(),ii++,0);
953 957
954 958
955 959
956 dummy = 960 dummy =
957 addWidBool(i18n("Todo view uses category colors"), 961 addWidBool(i18n("Todo view uses category colors"),
958 &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); 962 &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame);
959 topLayout->addWidget(dummy->checkBox(),ii++,0); 963 topLayout->addWidget(dummy->checkBox(),ii++,0);
960 964
961 965
962 QWidget* wid = new QWidget( topFrame ); 966 QWidget* wid = new QWidget( topFrame );
963 // Todo due today color 967 // Todo due today color
964 KPrefsWidColor *todoDueTodayColor = 968 KPrefsWidColor *todoDueTodayColor =
965 addWidColor(i18n("Todo due today color:"), 969 addWidColor(i18n("Todo due today color:"),
966 &(KOPrefs::instance()->mTodoDueTodayColor),wid); 970 &(KOPrefs::instance()->mTodoDueTodayColor),wid);
967 QHBoxLayout *widLayout = new QHBoxLayout(wid); 971 QHBoxLayout *widLayout = new QHBoxLayout(wid);
968 widLayout->addWidget( todoDueTodayColor->label() ); 972 widLayout->addWidget( todoDueTodayColor->label() );
969 widLayout->addWidget( todoDueTodayColor->button() ); 973 widLayout->addWidget( todoDueTodayColor->button() );
970 topLayout->addWidget(wid,ii++,0); 974 topLayout->addWidget(wid,ii++,0);
971 //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); 975 //topLayout->addWidget(todoDueTodayColor->button(),ii++,1);
972 976
973 // Todo overdue color 977 // Todo overdue color
974 wid = new QWidget( topFrame ); 978 wid = new QWidget( topFrame );
975 widLayout = new QHBoxLayout(wid); 979 widLayout = new QHBoxLayout(wid);
976 KPrefsWidColor *todoOverdueColor = 980 KPrefsWidColor *todoOverdueColor =
977 addWidColor(i18n("Todo overdue color:"), 981 addWidColor(i18n("Todo overdue color:"),
978 &(KOPrefs::instance()->mTodoOverdueColor),wid); 982 &(KOPrefs::instance()->mTodoOverdueColor),wid);
979 widLayout->addWidget(todoOverdueColor->label()); 983 widLayout->addWidget(todoOverdueColor->label());
980 widLayout->addWidget(todoOverdueColor->button()); 984 widLayout->addWidget(todoOverdueColor->button());
981 topLayout->addWidget(wid,ii++,0); 985 topLayout->addWidget(wid,ii++,0);
982 986
983 dummy = 987 dummy =
984 addWidBool(i18n("Colors are applied to text"), 988 addWidBool(i18n("Colors are applied to text"),
985 &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); 989 &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame);
986 topLayout->addWidget(dummy->checkBox(),ii++,0); 990 topLayout->addWidget(dummy->checkBox(),ii++,0);
987 991
988 dummy = 992 dummy =
989 addWidBool(i18n("Allday Agenda view shows todos"), 993 addWidBool(i18n("Allday Agenda view shows todos"),
990 &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); 994 &(KOPrefs::instance()->mShowTodoInAgenda),topFrame);
991 topLayout->addWidget(dummy->checkBox(),ii++,0); 995 topLayout->addWidget(dummy->checkBox(),ii++,0);
992 996
993 997
994 998
995 999
996 topFrame = addPage(i18n("Alarm"),0,0); 1000 topFrame = addPage(i18n("Alarm"),0,0);
997 // DesktopIcon("viewmag",KIcon::SizeMedium)); 1001 // DesktopIcon("viewmag",KIcon::SizeMedium));
998 1002
999 topLayout = new QGridLayout(topFrame,2,1); 1003 topLayout = new QGridLayout(topFrame,2,1);
1000 topLayout->setSpacing(spacingHint()); 1004 topLayout->setSpacing(spacingHint());
1001 topLayout->setMargin(marginHint()); 1005 topLayout->setMargin(marginHint());
1002 int iii = 0; 1006 int iii = 0;
1003 1007
1004 dummy = 1008 dummy =
1005 addWidBool(i18n("Use internal alarm notification"), 1009 addWidBool(i18n("Use internal alarm notification"),
1006 &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); 1010 &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame);
1007 topLayout->addWidget(dummy->checkBox(),iii++,0); 1011 topLayout->addWidget(dummy->checkBox(),iii++,0);
1008 lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame); 1012 lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame);
1009 1013
1010 topLayout->addWidget(lab ,iii++,0); 1014 topLayout->addWidget(lab ,iii++,0);
1011#ifndef DESKTOP_VERSION 1015#ifndef DESKTOP_VERSION
1012 lab->setAlignment( AlignLeft|WordBreak|AlignTop); 1016 lab->setAlignment( AlignLeft|WordBreak|AlignTop);
1013#else 1017#else
1014 lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 1018 lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
1015 lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); 1019 lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) );
1016#endif 1020#endif
1017 1021
1018 QHBox* dummyBox = new QHBox(topFrame); 1022 QHBox* dummyBox = new QHBox(topFrame);
1019 new QLabel(i18n("Play beeps count:"),dummyBox); 1023 new QLabel(i18n("Play beeps count:"),dummyBox);
1020 mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); 1024 mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox);
1021 topLayout->addWidget(dummyBox,iii++,0); 1025 topLayout->addWidget(dummyBox,iii++,0);
1022 1026
1023 dummyBox = new QHBox(topFrame); 1027 dummyBox = new QHBox(topFrame);
1024 new QLabel(i18n("Beeps interval in sec:"),dummyBox); 1028 new QLabel(i18n("Beeps interval in sec:"),dummyBox);
1025 mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); 1029 mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox);
1026 topLayout->addWidget(dummyBox,iii++,0); 1030 topLayout->addWidget(dummyBox,iii++,0);
1027 1031
1028 dummyBox = new QHBox(topFrame); 1032 dummyBox = new QHBox(topFrame);
1029 new QLabel(i18n("Default suspend time in min:"),dummyBox); 1033 new QLabel(i18n("Default suspend time in min:"),dummyBox);
1030 mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); 1034 mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox);
1031 topLayout->addWidget(dummyBox,iii++,0); 1035 topLayout->addWidget(dummyBox,iii++,0);
1032 1036
1033 dummyBox = new QHBox(topFrame); 1037 dummyBox = new QHBox(topFrame);
1034 new QLabel(i18n("Auto suspend count:"),dummyBox); 1038 new QLabel(i18n("Auto suspend count:"),dummyBox);
1035 mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); 1039 mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox);
1036 topLayout->addWidget(dummyBox,iii++,0); 1040 topLayout->addWidget(dummyBox,iii++,0);
1037 1041
1038 1042
1039 1043
1040 1044
1041 1045
1042 1046
1043 1047
1044 QHBox* hbo = new QHBox ( topFrame ); 1048 QHBox* hbo = new QHBox ( topFrame );
1045 mDefaultAlarmFile = new QLineEdit(hbo); 1049 mDefaultAlarmFile = new QLineEdit(hbo);
1046 QPushButton * loadTemplate = new QPushButton(hbo); 1050 QPushButton * loadTemplate = new QPushButton(hbo);
1047 QPixmap icon; 1051 QPixmap icon;
1048 if ( QApplication::desktop()->width() < 321 ) 1052 if ( QApplication::desktop()->width() < 321 )
1049 icon = SmallIcon("fileimport16"); 1053 icon = SmallIcon("fileimport16");
1050 else 1054 else
1051 icon = SmallIcon("fileimport"); 1055 icon = SmallIcon("fileimport");
1052 loadTemplate->setIconSet (icon ) ; 1056 loadTemplate->setIconSet (icon ) ;
1053 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); 1057 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) );
1054 int size = loadTemplate->sizeHint().height(); 1058 int size = loadTemplate->sizeHint().height();
1055 loadTemplate->setFixedSize( size, size ); 1059 loadTemplate->setFixedSize( size, size );
1056 //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); 1060 //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame);
1057 // topLayout->addWidget(lab ,iii++,0); 1061 // topLayout->addWidget(lab ,iii++,0);
1058 lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); 1062 lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame);
1059 topLayout->addWidget(lab ,iii++,0); 1063 topLayout->addWidget(lab ,iii++,0);
1060 topLayout->addWidget(hbo,iii++,0); 1064 topLayout->addWidget(hbo,iii++,0);
1061 // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame); 1065 // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame);
1062 1066
1063// topLayout->addWidget(lab ,iii++,0); 1067// topLayout->addWidget(lab ,iii++,0);
1064// #ifndef DESKTOP_VERSION 1068// #ifndef DESKTOP_VERSION
1065// lab->setAlignment( AlignLeft|WordBreak|AlignTop); 1069// lab->setAlignment( AlignLeft|WordBreak|AlignTop);
1066// #else 1070// #else
1067// lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 1071// lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
1068// lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); 1072// lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) );
1069// #endif 1073// #endif
1070 1074
1071 1075
1072} 1076}
1073 1077
1074void KOPrefsDialog::selectSoundFile() 1078void KOPrefsDialog::selectSoundFile()
1075{ 1079{
1076 QString fileName = mDefaultAlarmFile->text(); 1080 QString fileName = mDefaultAlarmFile->text();
1077 fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); 1081 fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this );
1078 if ( fileName.length() > 0 ) 1082 if ( fileName.length() > 0 )
1079 mDefaultAlarmFile->setText( fileName ); 1083 mDefaultAlarmFile->setText( fileName );
1080} 1084}
1081void KOPrefsDialog::setupFontsTab() 1085void KOPrefsDialog::setupFontsTab()
1082{ 1086{
1083 1087
1084 QFrame *topFrame = addPage(i18n("Fonts"),0,0); 1088 QFrame *topFrame = addPage(i18n("Fonts"),0,0);
1085 // DesktopIcon("fonts",KIcon::SizeMedium)); 1089 // DesktopIcon("fonts",KIcon::SizeMedium));
1086 1090
1087 QGridLayout *topLayout = new QGridLayout(topFrame,7,3); 1091 QGridLayout *topLayout = new QGridLayout(topFrame,7,3);
1088 topLayout->setSpacing(1); 1092 topLayout->setSpacing(1);
1089 topLayout->setMargin(3); 1093 topLayout->setMargin(3);
1090 KPrefsDialogWidFont * tVFont; 1094 KPrefsDialogWidFont * tVFont;
1091 int i = 0; 1095 int i = 0;
1092 KPrefsDialogWidFont *timeLabelsFont = 1096 KPrefsDialogWidFont *timeLabelsFont =
1093 addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), 1097 addWidFont(i18n("23"),i18n("DateNavigator:(nr)"),
1094 &(KOPrefs::instance()->mDateNavigatorFont),topFrame); 1098 &(KOPrefs::instance()->mDateNavigatorFont),topFrame);
1095 topLayout->addWidget(timeLabelsFont->label(),i,0); 1099 topLayout->addWidget(timeLabelsFont->label(),i,0);
1096 topLayout->addWidget(timeLabelsFont->preview(),i,1); 1100 topLayout->addWidget(timeLabelsFont->preview(),i,1);
1097 topLayout->addWidget(timeLabelsFont->button(),i,2); 1101 topLayout->addWidget(timeLabelsFont->button(),i,2);
1098 ++i; 1102 ++i;
1099 1103
1100 1104
1101 timeLabelsFont = 1105 timeLabelsFont =
1102 addWidFont(i18n("Mon 15"),i18n("Date Labels:"), 1106 addWidFont(i18n("Mon 15"),i18n("Date Labels:"),
1103 &(KOPrefs::instance()->mTimeLabelsFont),topFrame); 1107 &(KOPrefs::instance()->mTimeLabelsFont),topFrame);
1104 topLayout->addWidget(timeLabelsFont->label(),i,0); 1108 topLayout->addWidget(timeLabelsFont->label(),i,0);
1105 topLayout->addWidget(timeLabelsFont->preview(),i,1); 1109 topLayout->addWidget(timeLabelsFont->preview(),i,1);
1106 topLayout->addWidget(timeLabelsFont->button(),i,2); 1110 topLayout->addWidget(timeLabelsFont->button(),i,2);
1107 ++i; 1111 ++i;
1108 1112
1109 KPrefsDialogWidFont *timeBarFont = 1113 KPrefsDialogWidFont *timeBarFont =
1110 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), 1114 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"),
1111 &(KOPrefs::instance()->mTimeBarFont),topFrame); 1115 &(KOPrefs::instance()->mTimeBarFont),topFrame);
1112 topLayout->addWidget(timeBarFont->label(),i,0); 1116 topLayout->addWidget(timeBarFont->label(),i,0);
1113 topLayout->addWidget(timeBarFont->preview(),i,1); 1117 topLayout->addWidget(timeBarFont->preview(),i,1);
1114 topLayout->addWidget(timeBarFont->button(),i,2); 1118 topLayout->addWidget(timeBarFont->button(),i,2);
1115 ++i; 1119 ++i;
1116 1120
1117 1121
1118 KPrefsDialogWidFont *marcusBainsFont = 1122 KPrefsDialogWidFont *marcusBainsFont =
1119 addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), 1123 addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"),
1120 &(KOPrefs::instance()->mMarcusBainsFont),topFrame); 1124 &(KOPrefs::instance()->mMarcusBainsFont),topFrame);
1121 topLayout->addWidget(marcusBainsFont->label(),i,0); 1125 topLayout->addWidget(marcusBainsFont->label(),i,0);
1122 topLayout->addWidget(marcusBainsFont->preview(),i,1); 1126 topLayout->addWidget(marcusBainsFont->preview(),i,1);
1123 topLayout->addWidget(marcusBainsFont->button(),i,2); 1127 topLayout->addWidget(marcusBainsFont->button(),i,2);
1124 ++i; 1128 ++i;
1125 1129
1126 tVFont = 1130 tVFont =
1127 addWidFont(i18n("Summary"),i18n("Event Viewer:"), 1131 addWidFont(i18n("Summary"),i18n("Event Viewer:"),
1128 &(KOPrefs::instance()->mEventViewFont),topFrame); 1132 &(KOPrefs::instance()->mEventViewFont),topFrame);
1129 topLayout->addWidget(tVFont->label(),i,0); 1133 topLayout->addWidget(tVFont->label(),i,0);
1130 topLayout->addWidget(tVFont->preview(),i,1); 1134 topLayout->addWidget(tVFont->preview(),i,1);
1131 topLayout->addWidget(tVFont->button(),i,2); 1135 topLayout->addWidget(tVFont->button(),i,2);
1132 ++i; 1136 ++i;
1133 1137
1134 1138
1135 1139
1136 tVFont = 1140 tVFont =
1137 addWidFont(i18n("Details"),i18n("EditorBox:"), 1141 addWidFont(i18n("Details"),i18n("EditorBox:"),
1138 &(KOPrefs::instance()->mEditBoxFont),topFrame); 1142 &(KOPrefs::instance()->mEditBoxFont),topFrame);
1139 topLayout->addWidget(tVFont->label(),i,0); 1143 topLayout->addWidget(tVFont->label(),i,0);
1140 topLayout->addWidget(tVFont->preview(),i,1); 1144 topLayout->addWidget(tVFont->preview(),i,1);
1141 topLayout->addWidget(tVFont->button(),i,2); 1145 topLayout->addWidget(tVFont->button(),i,2);
1142 ++i; 1146 ++i;
1143 1147
1144 1148
1145 1149
1146 topLayout->setColStretch(1,1); 1150 topLayout->setColStretch(1,1);
1147 topLayout->setRowStretch(4,1); 1151 topLayout->setRowStretch(4,1);
1148 1152
1149 1153
1150 i = 0; 1154 i = 0;
1151 topFrame = addPage(i18n("View Fonts"),0, 1155 topFrame = addPage(i18n("View Fonts"),0,
1152 DesktopIcon("fonts",KIcon::SizeMedium)); 1156 DesktopIcon("fonts",KIcon::SizeMedium));
1153 1157
1154 topLayout = new QGridLayout(topFrame,7,3); 1158 topLayout = new QGridLayout(topFrame,7,3);
1155 topLayout->setSpacing(1); 1159 topLayout->setSpacing(1);
1156 topLayout->setMargin(3); 1160 topLayout->setMargin(3);
1157 1161
1158 tVFont = 1162 tVFont =
1159 addWidFont(i18n("Configure KO"),i18n("What's Next View:"), 1163 addWidFont(i18n("Configure KO"),i18n("What's Next View:"),
1160 &(KOPrefs::instance()->mWhatsNextFont),topFrame); 1164 &(KOPrefs::instance()->mWhatsNextFont),topFrame);
1161 topLayout->addWidget(tVFont->label(),i,0); 1165 topLayout->addWidget(tVFont->label(),i,0);
1162 topLayout->addWidget(tVFont->preview(),i,1); 1166 topLayout->addWidget(tVFont->preview(),i,1);
1163 topLayout->addWidget(tVFont->button(),i,2); 1167 topLayout->addWidget(tVFont->button(),i,2);
1164 ++i; 1168 ++i;
1165 KPrefsDialogWidFont *agendaViewFont = 1169 KPrefsDialogWidFont *agendaViewFont =
1166 addWidFont(i18n("Event text"),i18n("Agenda view:"), 1170 addWidFont(i18n("Event text"),i18n("Agenda view:"),
1167 &(KOPrefs::instance()->mAgendaViewFont),topFrame); 1171 &(KOPrefs::instance()->mAgendaViewFont),topFrame);
1168 topLayout->addWidget(agendaViewFont->label(),i,0); 1172 topLayout->addWidget(agendaViewFont->label(),i,0);
1169 topLayout->addWidget(agendaViewFont->preview(),i,1); 1173 topLayout->addWidget(agendaViewFont->preview(),i,1);
1170 topLayout->addWidget(agendaViewFont->button(),i,2); 1174 topLayout->addWidget(agendaViewFont->button(),i,2);
1171 ++i; 1175 ++i;
1172 1176
1173 1177
1174 KPrefsDialogWidFont *monthViewFont = 1178 KPrefsDialogWidFont *monthViewFont =
1175 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), 1179 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"),
1176 i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); 1180 i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame);
1177 topLayout->addWidget(monthViewFont->label(),i,0); 1181 topLayout->addWidget(monthViewFont->label(),i,0);
1178 topLayout->addWidget(monthViewFont->preview(),i,1); 1182 topLayout->addWidget(monthViewFont->preview(),i,1);
1179 topLayout->addWidget(monthViewFont->button(),i,2); 1183 topLayout->addWidget(monthViewFont->button(),i,2);
1180 ++i; 1184 ++i;
1181 1185
1182 1186
1183 KPrefsDialogWidFont *lVFont = 1187 KPrefsDialogWidFont *lVFont =
1184 addWidFont(i18n("Event"),i18n("List View:"), 1188 addWidFont(i18n("Event"),i18n("List View:"),
1185 &(KOPrefs::instance()->mListViewFont),topFrame); 1189 &(KOPrefs::instance()->mListViewFont),topFrame);
1186 topLayout->addWidget(lVFont->label(),i,0); 1190 topLayout->addWidget(lVFont->label(),i,0);
1187 topLayout->addWidget(lVFont->preview(),i,1); 1191 topLayout->addWidget(lVFont->preview(),i,1);
1188 topLayout->addWidget(lVFont->button(),i,2); 1192 topLayout->addWidget(lVFont->button(),i,2);
1189 ++i; 1193 ++i;
1190 1194
1191 1195
1192 tVFont = 1196 tVFont =
1193 addWidFont(i18n("ToDo"),i18n("ToDoView:"), 1197 addWidFont(i18n("ToDo"),i18n("ToDoView:"),
1194 &(KOPrefs::instance()->mTodoViewFont),topFrame); 1198 &(KOPrefs::instance()->mTodoViewFont),topFrame);
1195 topLayout->addWidget(tVFont->label(),i,0); 1199 topLayout->addWidget(tVFont->label(),i,0);
1196 topLayout->addWidget(tVFont->preview(),i,1); 1200 topLayout->addWidget(tVFont->preview(),i,1);
1197 topLayout->addWidget(tVFont->button(),i,2); 1201 topLayout->addWidget(tVFont->button(),i,2);
1198 ++i; 1202 ++i;
1199 1203
1200 1204
1201 tVFont = 1205 tVFont =
1202 addWidFont(i18n("Today"),i18n("JournalView:"), 1206 addWidFont(i18n("Today"),i18n("JournalView:"),
1203 &(KOPrefs::instance()->mJornalViewFont),topFrame); 1207 &(KOPrefs::instance()->mJornalViewFont),topFrame);
1204 topLayout->addWidget(tVFont->label(),i,0); 1208 topLayout->addWidget(tVFont->label(),i,0);
1205 topLayout->addWidget(tVFont->preview(),i,1); 1209 topLayout->addWidget(tVFont->preview(),i,1);
1206 topLayout->addWidget(tVFont->button(),i,2); 1210 topLayout->addWidget(tVFont->button(),i,2);
1207 ++i; 1211 ++i;
1208 1212
1209 1213
1210 1214
1211 1215
1212 topLayout->setColStretch(1,1); 1216 topLayout->setColStretch(1,1);
1213 topLayout->setRowStretch(4,1); 1217 topLayout->setRowStretch(4,1);
1214 1218
1215 1219
1216 1220
1217 1221
1218} 1222}
1219 1223
1220void KOPrefsDialog::setupColorsTab() 1224void KOPrefsDialog::setupColorsTab()
1221{ 1225{
1222 QFrame *topFrame = addPage(i18n("Colors"),0,0); 1226 QFrame *topFrame = addPage(i18n("Colors"),0,0);
1223 // DesktopIcon("colorize",KIcon::SizeMedium)); 1227 // DesktopIcon("colorize",KIcon::SizeMedium));
1224 1228
1225 QGridLayout *topLayout = new QGridLayout(topFrame,5,2); 1229 QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
1226 // topLayout->setSpacing(spacingHint()); 1230 // topLayout->setSpacing(spacingHint());
1227 // topLayout->setMargin(marginHint()); 1231 // topLayout->setMargin(marginHint());
1228 1232
1229 topLayout->setSpacing(2); 1233 topLayout->setSpacing(2);
1230 topLayout->setMargin(3); 1234 topLayout->setMargin(3);
1231 1235
1232 int ii = 1; 1236 int ii = 1;
1233 QGroupBox *categoryGroup ; 1237 QGroupBox *categoryGroup ;
1234 1238
1235 categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), 1239 categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"),
1236 topFrame); 1240 topFrame);
1237 topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); 1241 topLayout->addMultiCellWidget(categoryGroup,0,0,0,1);
1238 1242
1239 mCategoryCombo = new QComboBox(categoryGroup); 1243 mCategoryCombo = new QComboBox(categoryGroup);
1240 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 1244 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
1241 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); 1245 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor()));
1242 1246
1243 mCategoryButton = new KColorButton(categoryGroup); 1247 mCategoryButton = new KColorButton(categoryGroup);
1244 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); 1248 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor()));
1245 updateCategoryColor(); 1249 updateCategoryColor();
1246 1250
1247 1251
1248 // Holiday Color 1252 // Holiday Color
1249 1253
1250 KPrefsWidColor *holidayColor = 1254 KPrefsWidColor *holidayColor =
1251 addWidColor(i18n("Holiday color:"), 1255 addWidColor(i18n("Holiday color:"),
1252 &(KOPrefs::instance()->mHolidayColor),topFrame); 1256 &(KOPrefs::instance()->mHolidayColor),topFrame);
1253 topLayout->addWidget(holidayColor->label(),ii,0); 1257 topLayout->addWidget(holidayColor->label(),ii,0);
1254 topLayout->addWidget(holidayColor->button(),ii++,1); 1258 topLayout->addWidget(holidayColor->button(),ii++,1);
1255 1259
1256 // Highlight Color 1260 // Highlight Color
1257 KPrefsWidColor *highlightColor = 1261 KPrefsWidColor *highlightColor =
1258 addWidColor(i18n("Highlight color:"), 1262 addWidColor(i18n("Highlight color:"),
1259 &(KOPrefs::instance()->mHighlightColor),topFrame); 1263 &(KOPrefs::instance()->mHighlightColor),topFrame);
1260 topLayout->addWidget(highlightColor->label(),ii,0); 1264 topLayout->addWidget(highlightColor->label(),ii,0);
1261 topLayout->addWidget(highlightColor->button(),ii++,1); 1265 topLayout->addWidget(highlightColor->button(),ii++,1);
1262 1266
1263 // Event color 1267 // Event color
1264 KPrefsWidColor *eventColor = 1268 KPrefsWidColor *eventColor =
1265 addWidColor(i18n("Default event color:"), 1269 addWidColor(i18n("Default event color:"),
1266 &(KOPrefs::instance()->mEventColor),topFrame); 1270 &(KOPrefs::instance()->mEventColor),topFrame);
1267 topLayout->addWidget(eventColor->label(),ii,0); 1271 topLayout->addWidget(eventColor->label(),ii,0);
1268 topLayout->addWidget(eventColor->button(),ii++,1); 1272 topLayout->addWidget(eventColor->button(),ii++,1);
1269 1273
1270 // agenda view background color 1274 // agenda view background color
1271 KPrefsWidColor *agendaBgColor = 1275 KPrefsWidColor *agendaBgColor =
1272 addWidColor(i18n("Agenda view background color:"), 1276 addWidColor(i18n("Agenda view background color:"),
1273 &(KOPrefs::instance()->mAgendaBgColor),topFrame); 1277 &(KOPrefs::instance()->mAgendaBgColor),topFrame);
1274 topLayout->addWidget(agendaBgColor->label(),ii,0); 1278 topLayout->addWidget(agendaBgColor->label(),ii,0);
1275 topLayout->addWidget(agendaBgColor->button(),ii++,1); 1279 topLayout->addWidget(agendaBgColor->button(),ii++,1);
1276 1280
1277 // working hours color 1281 // working hours color
1278 KPrefsWidColor *workingHoursColor = 1282 KPrefsWidColor *workingHoursColor =
1279 addWidColor(i18n("Working hours color:"), 1283 addWidColor(i18n("Working hours color:"),
1280 &(KOPrefs::instance()->mWorkingHoursColor),topFrame); 1284 &(KOPrefs::instance()->mWorkingHoursColor),topFrame);
1281 topLayout->addWidget(workingHoursColor->label(),ii,0); 1285 topLayout->addWidget(workingHoursColor->label(),ii,0);
1282 topLayout->addWidget(workingHoursColor->button(),ii++,1); 1286 topLayout->addWidget(workingHoursColor->button(),ii++,1);
1283 1287
1284 KPrefsDialogWidBool *sb = 1288 KPrefsDialogWidBool *sb =
1285 addWidBool(i18n("Use colors for application:"), 1289 addWidBool(i18n("Use colors for application:"),
1286 &(KOPrefs::instance()->mUseAppColors),topFrame); 1290 &(KOPrefs::instance()->mUseAppColors),topFrame);
1287 topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); 1291 topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 );
1288 1292
1289 ii++; 1293 ii++;
1290 KPrefsWidColor * workingHoursColor1 = 1294 KPrefsWidColor * workingHoursColor1 =
1291 addWidColor(i18n("Buttons, menus, etc.:"), 1295 addWidColor(i18n("Buttons, menus, etc.:"),
1292 &(KOPrefs::instance()->mAppColor1),topFrame); 1296 &(KOPrefs::instance()->mAppColor1),topFrame);
1293 topLayout->addWidget(workingHoursColor1->label(),ii,0); 1297 topLayout->addWidget(workingHoursColor1->label(),ii,0);
1294 topLayout->addWidget(workingHoursColor1->button(),ii++,1); 1298 topLayout->addWidget(workingHoursColor1->button(),ii++,1);
1295 1299
1296 KPrefsWidColor * workingHoursColor2 = 1300 KPrefsWidColor * workingHoursColor2 =
1297 addWidColor(i18n("Frames, labels, etc.:"), 1301 addWidColor(i18n("Frames, labels, etc.:"),
1298 &(KOPrefs::instance()->mAppColor2),topFrame); 1302 &(KOPrefs::instance()->mAppColor2),topFrame);
1299 topLayout->addWidget(workingHoursColor2->label(),ii,0); 1303 topLayout->addWidget(workingHoursColor2->label(),ii,0);
1300 topLayout->addWidget(workingHoursColor2->button(),ii++,1); 1304 topLayout->addWidget(workingHoursColor2->button(),ii++,1);
1301 1305
1302 1306
1303 1307
1304} 1308}
1305 1309
1306void KOPrefsDialog::setCategoryColor() 1310void KOPrefsDialog::setCategoryColor()
1307{ 1311{
1308 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); 1312 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color()));
1309} 1313}
1310 1314
1311void KOPrefsDialog::updateCategoryColor() 1315void KOPrefsDialog::updateCategoryColor()
1312{ 1316{
1313 QString cat = mCategoryCombo->currentText(); 1317 QString cat = mCategoryCombo->currentText();
1314 QColor *color = mCategoryDict.find(cat); 1318 QColor *color = mCategoryDict.find(cat);
1315 if (!color) { 1319 if (!color) {
1316 color = KOPrefs::instance()->categoryColor(cat); 1320 color = KOPrefs::instance()->categoryColor(cat);
1317 } 1321 }
1318 if (color) { 1322 if (color) {
1319 mCategoryButton->setColor(*color); 1323 mCategoryButton->setColor(*color);
1320 } 1324 }
1321} 1325}
1322 1326
1323void KOPrefsDialog::setupPrinterTab() 1327void KOPrefsDialog::setupPrinterTab()
1324{ 1328{
1325 mPrinterTab = addPage(i18n("Printing"),0, 1329 mPrinterTab = addPage(i18n("Printing"),0,
1326 DesktopIcon("fileprint",KIcon::SizeMedium)); 1330 DesktopIcon("fileprint",KIcon::SizeMedium));
1327 1331
1328 QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); 1332 QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2);
1329 topLayout->setSpacing(spacingHint()); 1333 topLayout->setSpacing(spacingHint());
1330 topLayout->setMargin(marginHint()); 1334 topLayout->setMargin(marginHint());
1331 1335
1332 topLayout->setRowStretch(4,1); 1336 topLayout->setRowStretch(4,1);
1333} 1337}
1334 1338
1335void KOPrefsDialog::setupGroupSchedulingTab() 1339void KOPrefsDialog::setupGroupSchedulingTab()
1336{ 1340{
1337#if 0 1341#if 0
1338 QFrame *topFrame = addPage(i18n("Group Scheduling"),0, 1342 QFrame *topFrame = addPage(i18n("Group Scheduling"),0,
1339 DesktopIcon("personal",KIcon::SizeMedium)); 1343 DesktopIcon("personal",KIcon::SizeMedium));
1340 1344
1341 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 1345 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
1342 topLayout->setSpacing(spacingHint()); 1346 topLayout->setSpacing(spacingHint());
1343 topLayout->setMargin(marginHint()); 1347 topLayout->setMargin(marginHint());
1344 1348
1345#if 0 1349#if 0
1346 KPrefsWidRadios *schedulerGroup = 1350 KPrefsWidRadios *schedulerGroup =
1347 addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), 1351 addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler),
1348 topFrame); 1352 topFrame);
1349 schedulerGroup->addRadio("Dummy"); // Only for debugging 1353 schedulerGroup->addRadio("Dummy"); // Only for debugging
1350 schedulerGroup->addRadio(i18n("Mail client")); 1354 schedulerGroup->addRadio(i18n("Mail client"));
1351 1355
1352 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); 1356 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1);
1353#endif 1357#endif
1354 1358
1355 KPrefsWidRadios *sendGroup = 1359 KPrefsWidRadios *sendGroup =
1356 addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), 1360 addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend),
1357 topFrame); 1361 topFrame);
1358 sendGroup->addRadio(i18n("Send to outbox")); 1362 sendGroup->addRadio(i18n("Send to outbox"));
1359 sendGroup->addRadio(i18n("Send directly")); 1363 sendGroup->addRadio(i18n("Send directly"));
1360 1364
1361 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); 1365 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1);
1362 1366
1363 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); 1367 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1);
1364 mAMails = new QListView(topFrame); 1368 mAMails = new QListView(topFrame);
1365 mAMails->addColumn(i18n("Email"),300); 1369 mAMails->addColumn(i18n("Email"),300);
1366 topLayout->addMultiCellWidget(mAMails,3,3,0,1); 1370 topLayout->addMultiCellWidget(mAMails,3,3,0,1);
1367 1371
1368 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); 1372 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0);
1369 aEmailsEdit = new QLineEdit(topFrame); 1373 aEmailsEdit = new QLineEdit(topFrame);
1370 aEmailsEdit->setEnabled(false); 1374 aEmailsEdit->setEnabled(false);
1371 topLayout->addWidget(aEmailsEdit,4,1); 1375 topLayout->addWidget(aEmailsEdit,4,1);
1372 1376
1373 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); 1377 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new");
1374 topLayout->addWidget(add,5,0); 1378 topLayout->addWidget(add,5,0);
1375 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); 1379 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove");
1376 topLayout->addWidget(del,5,1); 1380 topLayout->addWidget(del,5,1);
1377 1381
1378 //topLayout->setRowStretch(2,1); 1382 //topLayout->setRowStretch(2,1);
1379 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); 1383 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) );
1380 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); 1384 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) );
1381 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); 1385 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem()));
1382 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); 1386 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput()));
1383#endif 1387#endif
1384} 1388}
1385 1389
1386void KOPrefsDialog::setupGroupAutomationTab() 1390void KOPrefsDialog::setupGroupAutomationTab()
1387{ 1391{
1388 return; 1392 return;
1389 QFrame *topFrame = addPage(i18n("Group Automation"),0, 1393 QFrame *topFrame = addPage(i18n("Group Automation"),0,
1390 DesktopIcon("personal",KIcon::SizeMedium)); 1394 DesktopIcon("personal",KIcon::SizeMedium));
1391 1395
1392 QGridLayout *topLayout = new QGridLayout(topFrame,5,1); 1396 QGridLayout *topLayout = new QGridLayout(topFrame,5,1);
1393 topLayout->setSpacing(spacingHint()); 1397 topLayout->setSpacing(spacingHint());
1394 topLayout->setMargin(marginHint()); 1398 topLayout->setMargin(marginHint());
1395 1399
1396 KPrefsWidRadios *autoRefreshGroup = 1400 KPrefsWidRadios *autoRefreshGroup =
1397 addWidRadios(i18n("Auto Send Refresh"), 1401 addWidRadios(i18n("Auto Send Refresh"),
1398 &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); 1402 &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame);
1399 autoRefreshGroup->addRadio(i18n("Never")); 1403 autoRefreshGroup->addRadio(i18n("Never"));
1400 autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); 1404 autoRefreshGroup->addRadio(i18n("If attendee is in addressbook"));
1401 //autoRefreshGroup->addRadio(i18n("selected emails")); 1405 //autoRefreshGroup->addRadio(i18n("selected emails"));
1402 topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); 1406 topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0);
1403 1407
1404 KPrefsWidRadios *autoInsertGroup = 1408 KPrefsWidRadios *autoInsertGroup =
1405 addWidRadios(i18n("Auto Insert IMIP Replies"), 1409 addWidRadios(i18n("Auto Insert IMIP Replies"),
1406 &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); 1410 &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame);
1407 autoInsertGroup->addRadio(i18n("Never")); 1411 autoInsertGroup->addRadio(i18n("Never"));
1408 autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); 1412 autoInsertGroup->addRadio(i18n("If attendee is in addressbook"));
1409 //autoInsertGroup->addRadio(i18n("selected emails")); 1413 //autoInsertGroup->addRadio(i18n("selected emails"));
1410 topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); 1414 topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0);
1411 1415
1412 KPrefsWidRadios *autoRequestGroup = 1416 KPrefsWidRadios *autoRequestGroup =
1413 addWidRadios(i18n("Auto Insert IMIP Requests"), 1417 addWidRadios(i18n("Auto Insert IMIP Requests"),
1414 &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); 1418 &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame);
1415 autoRequestGroup->addRadio(i18n("Never")); 1419 autoRequestGroup->addRadio(i18n("Never"));
1416 autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); 1420 autoRequestGroup->addRadio(i18n("If organizer is in addressbook"));
1417 //autoInsertGroup->addRadio(i18n("selected emails")); 1421 //autoInsertGroup->addRadio(i18n("selected emails"));
1418 topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); 1422 topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0);
1419 1423
1420 KPrefsWidRadios *autoFreeBusyGroup = 1424 KPrefsWidRadios *autoFreeBusyGroup =
1421 addWidRadios(i18n("Auto Send FreeBusy Information"), 1425 addWidRadios(i18n("Auto Send FreeBusy Information"),
1422 &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); 1426 &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame);
1423 autoFreeBusyGroup->addRadio(i18n("Never")); 1427 autoFreeBusyGroup->addRadio(i18n("Never"));
1424 autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); 1428 autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook"));
1425 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 1429 //autoFreeBusyGroup->addRadio(i18n("selected emails"));
1426 topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); 1430 topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0);
1427 1431
1428 KPrefsWidRadios *autoFreeBusyReplyGroup = 1432 KPrefsWidRadios *autoFreeBusyReplyGroup =
1429 addWidRadios(i18n("Auto Save FreeBusy Replies"), 1433 addWidRadios(i18n("Auto Save FreeBusy Replies"),
1430 &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); 1434 &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame);
1431 autoFreeBusyReplyGroup->addRadio(i18n("Never")); 1435 autoFreeBusyReplyGroup->addRadio(i18n("Never"));
1432 autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); 1436 autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook"));
1433 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 1437 //autoFreeBusyGroup->addRadio(i18n("selected emails"));
1434 topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); 1438 topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0);
1435} 1439}
1436 1440
1437void KOPrefsDialog::showPrinterTab() 1441void KOPrefsDialog::showPrinterTab()
1438{ 1442{
1439 showPage(pageIndex(mPrinterTab)); 1443 showPage(pageIndex(mPrinterTab));
1440} 1444}
1441 1445
1442 1446
1443void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, 1447void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text,
1444 const QStringList *tags) 1448 const QStringList *tags)
1445{ 1449{
1446 if (tags) { 1450 if (tags) {
1447 int i = tags->findIndex(text); 1451 int i = tags->findIndex(text);
1448 if (i > 0) combo->setCurrentItem(i); 1452 if (i > 0) combo->setCurrentItem(i);
1449 } else { 1453 } else {
1450 for(int i=0;i<combo->count();++i) { 1454 for(int i=0;i<combo->count();++i) {
1451 if (combo->text(i) == text) { 1455 if (combo->text(i) == text) {
1452 combo->setCurrentItem(i); 1456 combo->setCurrentItem(i);
1453 break; 1457 break;
1454 } 1458 }
1455 } 1459 }
1456 } 1460 }
1457} 1461}
1458 1462
1459void KOPrefsDialog::usrReadConfig() 1463void KOPrefsDialog::usrReadConfig()
1460{ 1464{
1461 mNameEdit->setText(KOPrefs::instance()->fullName()); 1465 mNameEdit->setText(KOPrefs::instance()->fullName());
1462 mEmailEdit->setText(KOPrefs::instance()->email()); 1466 mEmailEdit->setText(KOPrefs::instance()->email());
1463 1467
1464 mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); 1468 mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval);
1465 QDate current ( 2001, 1,1); 1469 QDate current ( 2001, 1,1);
1466 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); 1470 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1));
1467 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); 1471 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1));
1468 setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId)); 1472 setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId));
1469 //mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); 1473 //mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset);
1470 mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); 1474 mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime);
1471 mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); 1475 mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration);
1472 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); 1476 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime);
1473 // if (KOPrefs::instance()->mAllDaySize > 47 ) 1477 // if (KOPrefs::instance()->mAllDaySize > 47 )
1474 // KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize/2; 1478 // KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize/2;
1475 //mHourSizeSlider->setValue(KOPrefs::instance()->mAllDaySize); 1479 //mHourSizeSlider->setValue(KOPrefs::instance()->mAllDaySize);
1476 1480
1477 mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); 1481 mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays);
1478 mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); 1482 mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays);
1479 mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); 1483 mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios);
1480 // mAMails->clear(); 1484 // mAMails->clear();
1481 // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); 1485 // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin();
1482// it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { 1486// it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) {
1483// QListViewItem *item = new QListViewItem(mAMails); 1487// QListViewItem *item = new QListViewItem(mAMails);
1484// item->setText(0,*it); 1488// item->setText(0,*it);
1485// mAMails->insertItem(item); 1489// mAMails->insertItem(item);
1486// } 1490// }
1487 1491
1488 // mRemoteIPEdit->setText(KOPrefs::instance()->mRemoteIP); 1492 // mRemoteIPEdit->setText(KOPrefs::instance()->mRemoteIP);
1489 //mRemoteUser->setText(KOPrefs::instance()->mRemoteUser); 1493 //mRemoteUser->setText(KOPrefs::instance()->mRemoteUser);
1490 //mRemotePassWd->setText(KOPrefs::instance()->mRemotePassWd); 1494 //mRemotePassWd->setText(KOPrefs::instance()->mRemotePassWd);
1491 //mRemoteFile->setText(KOPrefs::instance()->mRemoteFile); 1495 //mRemoteFile->setText(KOPrefs::instance()->mRemoteFile);
1492 1496
1493 //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); 1497 //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile);
1494 mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); 1498 mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile);
1495 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1499 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1496 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); 1500 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
1497 dummy = KOPrefs::instance()->mUserDateFormatShort; 1501 dummy = KOPrefs::instance()->mUserDateFormatShort;
1498 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); 1502 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
1499 updateCategories(); 1503 updateCategories();
1500 mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); 1504 mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps );
1501 mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); 1505 mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime );
1502 mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); 1506 mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount );
1503 mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); 1507 mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval );
1504} 1508}
1505 1509
1506 1510
1507void KOPrefsDialog::usrWriteConfig() 1511void KOPrefsDialog::usrWriteConfig()
1508{ 1512{
1509 1513
1510 // KOPrefs::instance()->mRemoteIP = mRemoteIPEdit->text(); 1514 // KOPrefs::instance()->mRemoteIP = mRemoteIPEdit->text();
1511 //KOPrefs::instance()->mRemoteUser = mRemoteUser->text(); 1515 //KOPrefs::instance()->mRemoteUser = mRemoteUser->text();
1512 //KOPrefs::instance()->mRemotePassWd = mRemotePassWd->text(); 1516 //KOPrefs::instance()->mRemotePassWd = mRemotePassWd->text();
1513 //KOPrefs::instance()->mRemoteFile= mRemoteFile->text(); 1517 //KOPrefs::instance()->mRemoteFile= mRemoteFile->text();
1514 //KOPrefs::instance()->mLocalTempFile =mLocalTempFile->text(); 1518 //KOPrefs::instance()->mLocalTempFile =mLocalTempFile->text();
1515 KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); 1519 KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text();
1516 1520
1517 KOPrefs::instance()->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); 1521 KOPrefs::instance()->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
1518 KOPrefs::instance()->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); 1522 KOPrefs::instance()->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
1519 KOPrefs::instance()->setFullName(mNameEdit->text()); 1523 KOPrefs::instance()->setFullName(mNameEdit->text());
1520 KOPrefs::instance()->setEmail(mEmailEdit->text()); 1524 KOPrefs::instance()->setEmail(mEmailEdit->text());
1521 1525
1522 KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); 1526 KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value();
1523 1527
1524 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText(); 1528 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText();
1525 QDate date; 1529 QDate date;
1526 date = mStartDateSavingEdit->date(); 1530 date = mStartDateSavingEdit->date();
1527 int sub = 0; 1531 int sub = 0;
1528 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 1532 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
1529 sub = 1; 1533 sub = 1;
1530 KOPrefs::instance()->mDaylightsavingStart = date.dayOfYear()-sub; 1534 KOPrefs::instance()->mDaylightsavingStart = date.dayOfYear()-sub;
1531 date = mEndDateSavingEdit->date(); 1535 date = mEndDateSavingEdit->date();
1532 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 1536 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
1533 sub = 1; 1537 sub = 1;
1534 else 1538 else
1535 sub = 0; 1539 sub = 0;
1536 KOPrefs::instance()->mDaylightsavingEnd = date.dayOfYear()-sub; 1540 KOPrefs::instance()->mDaylightsavingEnd = date.dayOfYear()-sub;
1537 // KOPrefs::instance()->mTimeZoneOffset = mTimezoneOffsetSpin->value(); 1541 // KOPrefs::instance()->mTimeZoneOffset = mTimezoneOffsetSpin->value();
1538 1542
1539 KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); 1543 KOPrefs::instance()->mStartTime = mStartTimeSpin->value();
1540 KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); 1544 KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value();
1541 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); 1545 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem();
1542 1546
1543 //KOPrefs::instance()->mAllDaySize = mHourSizeSlider->value(); 1547 //KOPrefs::instance()->mAllDaySize = mHourSizeSlider->value();
1544 1548
1545 QDictIterator<QColor> it(mCategoryDict); 1549 QDictIterator<QColor> it(mCategoryDict);
1546 while (it.current()) { 1550 while (it.current()) {
1547 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); 1551 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current());
1548 ++it; 1552 ++it;
1549 } 1553 }
1550 1554
1551 KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); 1555 KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value();
1552 KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); 1556 KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value();
1553 KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); 1557 KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value();
1554 1558
1555 KOPrefs::instance()->mAdditionalMails.clear(); 1559 KOPrefs::instance()->mAdditionalMails.clear();
1556 // QListViewItem *item; 1560 // QListViewItem *item;
1557 // item = mAMails->firstChild(); 1561 // item = mAMails->firstChild();
1558 // while (item) 1562 // while (item)
1559 // { 1563 // {
1560 // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); 1564 // KOPrefs::instance()->mAdditionalMails.append( item->text(0) );
1561 // item = item->nextSibling(); 1565 // item = item->nextSibling();
1562 // } 1566 // }
1563 KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); 1567 KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value();
1564 KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; 1568 KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ;
1565 KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; 1569 KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ;
1566 KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; 1570 KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ;
1567 1571
1568} 1572}
1569 1573
1570void KOPrefsDialog::updateCategories() 1574void KOPrefsDialog::updateCategories()
1571{ 1575{
1572 mCategoryCombo->clear(); 1576 mCategoryCombo->clear();
1573 mCategoryDict.clear(); 1577 mCategoryDict.clear();
1574 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 1578 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
1575 updateCategoryColor(); 1579 updateCategoryColor();
1576} 1580}
1577 1581
1578void KOPrefsDialog::warningGroupScheduling() 1582void KOPrefsDialog::warningGroupScheduling()
1579{ 1583{
1580 warningExperimental(mEnableGroupScheduling->checkBox()->isChecked()); 1584 warningExperimental(mEnableGroupScheduling->checkBox()->isChecked());
1581} 1585}
1582 1586
1583void KOPrefsDialog::warningProjectView() 1587void KOPrefsDialog::warningProjectView()
1584{ 1588{
1585 warningExperimental(mEnableProjectView->checkBox()->isChecked()); 1589 warningExperimental(mEnableProjectView->checkBox()->isChecked());
1586} 1590}
1587 1591
1588void KOPrefsDialog::warningExperimental(bool on) 1592void KOPrefsDialog::warningExperimental(bool on)
1589{ 1593{
1590 if (on) { 1594 if (on) {
1591 KMessageBox::information(this,i18n("This is an experimental feature. " 1595 KMessageBox::information(this,i18n("This is an experimental feature. "
1592 "It may not work, it may do nothing useful and it may cause data loss. " 1596 "It may not work, it may do nothing useful and it may cause data loss. "
1593 "Use with care.\n" 1597 "Use with care.\n"
1594 "You have to restart KOrganizer for this setting to take effect.")); 1598 "You have to restart KOrganizer for this setting to take effect."));
1595 } else { 1599 } else {
1596 KMessageBox::information(this, 1600 KMessageBox::information(this,
1597 i18n("You have to restart KOrganizer for this setting to take effect.")); 1601 i18n("You have to restart KOrganizer for this setting to take effect."));
1598 } 1602 }
1599} 1603}
1600 1604
1601void KOPrefsDialog::toggleEmailSettings(bool on) 1605void KOPrefsDialog::toggleEmailSettings(bool on)
1602{ 1606{
1603 if (on) { 1607 if (on) {
1604 mEmailEdit->setEnabled(false); 1608 mEmailEdit->setEnabled(false);
1605 mNameEdit->setEnabled(false); 1609 mNameEdit->setEnabled(false);
1606 mEmailLabel->setEnabled(false); 1610 mEmailLabel->setEnabled(false);
1607 mNameLabel->setEnabled(false); 1611 mNameLabel->setEnabled(false);
1608 1612
1609 KEMailSettings settings; 1613 KEMailSettings settings;
1610 mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); 1614 mNameEdit->setText(settings.getSetting(KEMailSettings::RealName));
1611 mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); 1615 mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress));
1612 } else { 1616 } else {
1613 mEmailEdit->setEnabled(true); 1617 mEmailEdit->setEnabled(true);
1614 mNameEdit->setEnabled(true); 1618 mNameEdit->setEnabled(true);
1615 mEmailLabel->setEnabled(true); 1619 mEmailLabel->setEnabled(true);
1616 mNameLabel->setEnabled(true); 1620 mNameLabel->setEnabled(true);
1617 } 1621 }
1618} 1622}
1619 1623
1620void KOPrefsDialog::addItem() 1624void KOPrefsDialog::addItem()
1621{ 1625{
1622 // aEmailsEdit->setEnabled(true); 1626 // aEmailsEdit->setEnabled(true);
1623// QListViewItem *item = new QListViewItem(mAMails); 1627// QListViewItem *item = new QListViewItem(mAMails);
1624// mAMails->insertItem(item); 1628// mAMails->insertItem(item);
1625// mAMails->setSelected(item,true); 1629// mAMails->setSelected(item,true);
1626// aEmailsEdit->setText(i18n("(EmptyEmail)")); 1630// aEmailsEdit->setText(i18n("(EmptyEmail)"));
1627} 1631}
1628 1632
1629void KOPrefsDialog::removeItem() 1633void KOPrefsDialog::removeItem()
1630{ 1634{
1631// QListViewItem *item; 1635// QListViewItem *item;
1632// item = mAMails->selectedItem(); 1636// item = mAMails->selectedItem();
1633// if (!item) return; 1637// if (!item) return;
1634// mAMails->takeItem(item); 1638// mAMails->takeItem(item);
1635// item = mAMails->selectedItem(); 1639// item = mAMails->selectedItem();
1636// if (!item) { 1640// if (!item) {
1637// aEmailsEdit->setText(""); 1641// aEmailsEdit->setText("");
1638// aEmailsEdit->setEnabled(false); 1642// aEmailsEdit->setEnabled(false);
1639// } 1643// }
1640// if (mAMails->childCount() == 0) { 1644// if (mAMails->childCount() == 0) {
1641// aEmailsEdit->setEnabled(false); 1645// aEmailsEdit->setEnabled(false);
1642// } 1646// }
1643} 1647}
1644 1648
1645void KOPrefsDialog::updateItem() 1649void KOPrefsDialog::updateItem()
1646{ 1650{
1647 // QListViewItem *item; 1651 // QListViewItem *item;
1648// item = mAMails->selectedItem(); 1652// item = mAMails->selectedItem();
1649// if (!item) return; 1653// if (!item) return;
1650// item->setText(0,aEmailsEdit->text()); 1654// item->setText(0,aEmailsEdit->text());
1651} 1655}
1652 1656
1653void KOPrefsDialog::updateInput() 1657void KOPrefsDialog::updateInput()
1654{ 1658{
1655// QListViewItem *item; 1659// QListViewItem *item;
1656// item = mAMails->selectedItem(); 1660// item = mAMails->selectedItem();
1657// if (!item) return; 1661// if (!item) return;
1658// aEmailsEdit->setEnabled(true); 1662// aEmailsEdit->setEnabled(true);
1659// aEmailsEdit->setText(item->text(0)); 1663// aEmailsEdit->setText(item->text(0));
1660} 1664}
1661void KOPrefsDialog::updateTimezoneOffset( int index ) 1665void KOPrefsDialog::updateTimezoneOffset( int index )
1662{ 1666{
1663 /* 1667 /*
1664 qDebug("updateTimezoneOffset %d ", index); 1668 qDebug("updateTimezoneOffset %d ", index);
1665 if ( index < 24 ) { 1669 if ( index < 24 ) {
1666 mTimezoneOffsetSpin->setEnabled ( false ); 1670 mTimezoneOffsetSpin->setEnabled ( false );
1667 mTimezoneOffsetSpin->setValue( ( index-11 ) * 60 ); 1671 mTimezoneOffsetSpin->setValue( ( index-11 ) * 60 );
1668 1672
1669 1673
1670 } else { 1674 } else {
1671 if ( index == 24 ) { 1675 if ( index == 24 ) {
1672 mTimezoneOffsetSpin->setEnabled ( true ); 1676 mTimezoneOffsetSpin->setEnabled ( true );
1673 mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); 1677 mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset);
1674 1678
1675 } else { 1679 } else {
1676 mTimezoneOffsetSpin->setEnabled ( false ); 1680 mTimezoneOffsetSpin->setEnabled ( false );
1677 mTimezoneOffsetSpin->setValue( 0 ); 1681 mTimezoneOffsetSpin->setValue( 0 );
1678 } 1682 }
1679 } 1683 }
1680 */ 1684 */
1681} 1685}
1682 1686
1683void KOPrefsDialog::setupTimeZoneTab() 1687void KOPrefsDialog::setupTimeZoneTab()
1684{ 1688{
1685 QFrame *topFrame = addPage(i18n("Time Zone"),0,0); 1689 QFrame *topFrame = addPage(i18n("Time Zone"),0,0);
1686 // DesktopIcon("clock",KIcon::SizeMedium)); 1690 // DesktopIcon("clock",KIcon::SizeMedium));
1687 1691
1688 QGridLayout *topLayout = new QGridLayout(topFrame,5,2); 1692 QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
1689 topLayout->setSpacing(spacingHint()); 1693 topLayout->setSpacing(spacingHint());
1690 topLayout->setMargin(marginHint()); 1694 topLayout->setMargin(marginHint());
1691 1695
1692 QHBox *timeZoneBox = new QHBox( topFrame ); 1696 QHBox *timeZoneBox = new QHBox( topFrame );
1693 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); 1697 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
1694 1698
1695 new QLabel( i18n("Timezone:"), timeZoneBox ); 1699 new QLabel( i18n("Timezone:"), timeZoneBox );
1696 mTimeZoneCombo = new QComboBox( timeZoneBox ); 1700 mTimeZoneCombo = new QComboBox( timeZoneBox );
1697 if ( QApplication::desktop()->width() < 300 ) { 1701 if ( QApplication::desktop()->width() < 300 ) {
1698 mTimeZoneCombo->setMaximumWidth(150); 1702 mTimeZoneCombo->setMaximumWidth(150);
1699 } 1703 }
1700 1704
1701 QStringList list; 1705 QStringList list;
1702 list = KGlobal::locale()->timeZoneList(); 1706 list = KGlobal::locale()->timeZoneList();
1703 mTimeZoneCombo->insertStringList(list); 1707 mTimeZoneCombo->insertStringList(list);
1704 1708
1705 // find the currently set time zone and select it 1709 // find the currently set time zone and select it
1706 QString sCurrentlySet = KOPrefs::instance()->mTimeZoneId; 1710 QString sCurrentlySet = KOPrefs::instance()->mTimeZoneId;
1707 int nCurrentlySet = 11; 1711 int nCurrentlySet = 11;
1708 for (int i = 0; i < mTimeZoneCombo->count(); i++) 1712 for (int i = 0; i < mTimeZoneCombo->count(); i++)
1709 { 1713 {
1710 if (mTimeZoneCombo->text(i) == sCurrentlySet) 1714 if (mTimeZoneCombo->text(i) == sCurrentlySet)
1711 { 1715 {
1712 nCurrentlySet = i; 1716 nCurrentlySet = i;
1713 break; 1717 break;
1714 } 1718 }
1715 } 1719 }
1716 mTimeZoneCombo->setCurrentItem(nCurrentlySet); 1720 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
1717 int iii = 1; 1721 int iii = 1;
1718 KPrefsDialogWidBool *sb = 1722 KPrefsDialogWidBool *sb =
1719 addWidBool(i18n("Timezone has daylight saving"), 1723 addWidBool(i18n("Timezone has daylight saving"),
1720 &(KOPrefs::instance()->mUseDaylightsaving),topFrame); 1724 &(KOPrefs::instance()->mUseDaylightsaving),topFrame);
1721 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 1725 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
1722 ++iii; 1726 ++iii;
1723 QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); 1727 QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame );
1724 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 1728 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
1725 ++iii; 1729 ++iii;
1726 lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); 1730 lab = new QLabel( i18n("The year in the date is ignored."), topFrame );
1727 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 1731 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
1728 ++iii; 1732 ++iii;
1729 lab = new QLabel( i18n("Daylight start:"), topFrame ); 1733 lab = new QLabel( i18n("Daylight start:"), topFrame );
1730 topLayout->addWidget(lab, iii,0); 1734 topLayout->addWidget(lab, iii,0);
1731 mStartDateSavingEdit = new KDateEdit(topFrame); 1735 mStartDateSavingEdit = new KDateEdit(topFrame);
1732 topLayout->addWidget(mStartDateSavingEdit, iii,1); 1736 topLayout->addWidget(mStartDateSavingEdit, iii,1);
1733 ++iii; 1737 ++iii;
1734 1738
1735 lab = new QLabel( i18n("Daylight end:"), topFrame ); 1739 lab = new QLabel( i18n("Daylight end:"), topFrame );
1736 topLayout->addWidget(lab, iii,0); 1740 topLayout->addWidget(lab, iii,0);
1737 mEndDateSavingEdit = new KDateEdit(topFrame); 1741 mEndDateSavingEdit = new KDateEdit(topFrame);
1738 topLayout->addWidget(mEndDateSavingEdit, iii,1); 1742 topLayout->addWidget(mEndDateSavingEdit, iii,1);
1739 ++iii; 1743 ++iii;
1740 QDate current ( 2001, 1,1); 1744 QDate current ( 2001, 1,1);
1741 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); 1745 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1));
1742 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); 1746 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1));
1743 1747
1744 1748
1745} 1749}
1746#endif 1750#endif
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 92fd59c..3a16fe6 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4060 +1,4066 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141 141
142class KOBeamPrefs : public QDialog 142class KOBeamPrefs : public QDialog
143{ 143{
144 public: 144 public:
145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
146 QDialog( parent, name, true ) 146 QDialog( parent, name, true )
147 { 147 {
148 setCaption( i18n("Beam Options") ); 148 setCaption( i18n("Beam Options") );
149 QVBoxLayout* lay = new QVBoxLayout( this ); 149 QVBoxLayout* lay = new QVBoxLayout( this );
150 lay->setSpacing( 3 ); 150 lay->setSpacing( 3 );
151 lay->setMargin( 3 ); 151 lay->setMargin( 3 );
152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
153 lay->addWidget( format ); 153 lay->addWidget( format );
154 format->setExclusive ( true ) ; 154 format->setExclusive ( true ) ;
155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
156 lay->addWidget( time ); time->setExclusive ( true ) ; 156 lay->addWidget( time ); time->setExclusive ( true ) ;
157 vcal = new QRadioButton(" vCalendar ", format ); 157 vcal = new QRadioButton(" vCalendar ", format );
158 ical = new QRadioButton(" iCalendar ", format ); 158 ical = new QRadioButton(" iCalendar ", format );
159 vcal->setChecked( true ); 159 vcal->setChecked( true );
160 tz = new QRadioButton(i18n(" With timezone "), time ); 160 tz = new QRadioButton(i18n(" With timezone "), time );
161 local = new QRadioButton(i18n(" Local time "), time ); 161 local = new QRadioButton(i18n(" Local time "), time );
162 tz->setChecked( true ); 162 tz->setChecked( true );
163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
164 lay->addWidget( ok ); 164 lay->addWidget( ok );
165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
166 lay->addWidget( cancel ); 166 lay->addWidget( cancel );
167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
169 resize( 200, 200 ); 169 resize( 200, 200 );
170 } 170 }
171 171
172 bool beamVcal() { return vcal->isChecked(); } 172 bool beamVcal() { return vcal->isChecked(); }
173 bool beamLocal() { return local->isChecked(); } 173 bool beamLocal() { return local->isChecked(); }
174private: 174private:
175 QRadioButton* vcal, *ical, *local, *tz; 175 QRadioButton* vcal, *ical, *local, *tz;
176}; 176};
177class KOCatPrefs : public QDialog 177class KOCatPrefs : public QDialog
178{ 178{
179 public: 179 public:
180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
181 QDialog( parent, name, true ) 181 QDialog( parent, name, true )
182 { 182 {
183 setCaption( i18n("Manage new Categories") ); 183 setCaption( i18n("Manage new Categories") );
184 QVBoxLayout* lay = new QVBoxLayout( this ); 184 QVBoxLayout* lay = new QVBoxLayout( this );
185 lay->setSpacing( 3 ); 185 lay->setSpacing( 3 );
186 lay->setMargin( 3 ); 186 lay->setMargin( 3 );
187 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 187 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
188 lay->addWidget( lab ); 188 lay->addWidget( lab );
189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
190 lay->addWidget( format ); 190 lay->addWidget( format );
191 format->setExclusive ( true ) ; 191 format->setExclusive ( true ) ;
192 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 192 addCatBut = new QRadioButton(i18n("Add to category list"), format );
193 new QRadioButton(i18n("Remove from Events/Todos"), format ); 193 new QRadioButton(i18n("Remove from Events/Todos"), format );
194 addCatBut->setChecked( true ); 194 addCatBut->setChecked( true );
195 QPushButton * ok = new QPushButton( i18n("OK"), this ); 195 QPushButton * ok = new QPushButton( i18n("OK"), this );
196 lay->addWidget( ok ); 196 lay->addWidget( ok );
197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
198 lay->addWidget( cancel ); 198 lay->addWidget( cancel );
199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
201 resize( 200, 200 ); 201 resize( 200, 200 );
202 } 202 }
203 203
204 bool addCat() { return addCatBut->isChecked(); } 204 bool addCat() { return addCatBut->isChecked(); }
205private: 205private:
206 QRadioButton* addCatBut; 206 QRadioButton* addCatBut;
207}; 207};
208 208
209 209
210 210
211CalendarView::CalendarView( CalendarResources *calendar, 211CalendarView::CalendarView( CalendarResources *calendar,
212 QWidget *parent, const char *name ) 212 QWidget *parent, const char *name )
213 : CalendarViewBase( parent, name ), 213 : CalendarViewBase( parent, name ),
214 mCalendar( calendar ), 214 mCalendar( calendar ),
215 mResourceManager( calendar->resourceManager() ) 215 mResourceManager( calendar->resourceManager() )
216{ 216{
217 217
218 mEventEditor = 0; 218 mEventEditor = 0;
219 mTodoEditor = 0; 219 mTodoEditor = 0;
220 220
221 init(); 221 init();
222} 222}
223 223
224CalendarView::CalendarView( Calendar *calendar, 224CalendarView::CalendarView( Calendar *calendar,
225 QWidget *parent, const char *name ) 225 QWidget *parent, const char *name )
226 : CalendarViewBase( parent, name ), 226 : CalendarViewBase( parent, name ),
227 mCalendar( calendar ), 227 mCalendar( calendar ),
228 mResourceManager( 0 ) 228 mResourceManager( 0 )
229{ 229{
230 230
231 mEventEditor = 0; 231 mEventEditor = 0;
232 mTodoEditor = 0; 232 mTodoEditor = 0;
233 init(); 233 init();
234} 234}
235 235
236void CalendarView::init() 236void CalendarView::init()
237{ 237{
238 238
239 setFocusPolicy ( WheelFocus ); 239 setFocusPolicy ( WheelFocus );
240 mViewerCallerIsSearchDialog = false; 240 mViewerCallerIsSearchDialog = false;
241 mBlockShowDates = false; 241 mBlockShowDates = false;
242 beamDialog = new KOBeamPrefs(); 242 beamDialog = new KOBeamPrefs();
243 mDatePickerMode = 0; 243 mDatePickerMode = 0;
244 mCurrentSyncDevice = ""; 244 mCurrentSyncDevice = "";
245 writeLocale(); 245 writeLocale();
246 mViewManager = new KOViewManager( this ); 246 mViewManager = new KOViewManager( this );
247 mDialogManager = new KODialogManager( this ); 247 mDialogManager = new KODialogManager( this );
248 mEventViewerDialog = 0; 248 mEventViewerDialog = 0;
249 mModified = false; 249 mModified = false;
250 mReadOnly = false; 250 mReadOnly = false;
251 mSelectedIncidence = 0; 251 mSelectedIncidence = 0;
252 mCalPrinter = 0; 252 mCalPrinter = 0;
253 mFilters.setAutoDelete(true); 253 mFilters.setAutoDelete(true);
254 254
255 mCalendar->registerObserver( this ); 255 mCalendar->registerObserver( this );
256 // TODO: Make sure that view is updated, when calendar is changed. 256 // TODO: Make sure that view is updated, when calendar is changed.
257 257
258 mStorage = new FileStorage( mCalendar ); 258 mStorage = new FileStorage( mCalendar );
259 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 259 mNavigator = new DateNavigator( this, "datevav", mViewManager );
260 260
261 QBoxLayout *topLayout = (QBoxLayout*)layout(); 261 QBoxLayout *topLayout = (QBoxLayout*)layout();
262#ifndef KORG_NOSPLITTER 262#ifndef KORG_NOSPLITTER
263 // create the main layout frames. 263 // create the main layout frames.
264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
265 topLayout->addWidget(mPanner); 265 topLayout->addWidget(mPanner);
266 266
267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
268 "CalendarView::LeftFrame"); 268 "CalendarView::LeftFrame");
269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
270 270
271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
272 "CalendarView::DateNavigator" ); 272 "CalendarView::DateNavigator" );
273 273
274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
276 mTodoList->setNavigator( mNavigator ); 276 mTodoList->setNavigator( mNavigator );
277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
278 278
279#ifdef KORG_NORESOURCEVIEW 279#ifdef KORG_NORESOURCEVIEW
280 mResourceView = 0; 280 mResourceView = 0;
281#else 281#else
282 if ( mResourceManager ) { 282 if ( mResourceManager ) {
283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
284 mResourceView->updateView(); 284 mResourceView->updateView();
285 connect( mResourceView, SIGNAL( resourcesChanged() ), 285 connect( mResourceView, SIGNAL( resourcesChanged() ),
286 SLOT( updateView() ) ); 286 SLOT( updateView() ) );
287 } else { 287 } else {
288 mResourceView = 0; 288 mResourceView = 0;
289 } 289 }
290#endif 290#endif
291 QWidget *rightBox = new QWidget( mPanner ); 291 QWidget *rightBox = new QWidget( mPanner );
292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
293 293
294 mRightFrame = new QWidgetStack( rightBox ); 294 mRightFrame = new QWidgetStack( rightBox );
295 rightLayout->addWidget( mRightFrame, 1 ); 295 rightLayout->addWidget( mRightFrame, 1 );
296 296
297 mLeftFrame = mLeftSplitter; 297 mLeftFrame = mLeftSplitter;
298#else 298#else
299 //QWidget *mainBox = new QWidget( this ); 299 //QWidget *mainBox = new QWidget( this );
300 //QWidget *leftFrame = new QWidget( mainBox ); 300 //QWidget *leftFrame = new QWidget( mainBox );
301 //QBoxLayout * mainBoxLayout; 301 //QBoxLayout * mainBoxLayout;
302 if ( KOPrefs::instance()->mVerticalScreen ) { 302 if ( KOPrefs::instance()->mVerticalScreen ) {
303 //mainBoxLayout = new QVBoxLayout(mainBox); 303 //mainBoxLayout = new QVBoxLayout(mainBox);
304 //leftFrameLayout = new QHBoxLayout(leftFrame ); 304 //leftFrameLayout = new QHBoxLayout(leftFrame );
305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
309 } else { 309 } else {
310 //mainBoxLayout = new QHBoxLayout(mainBox); 310 //mainBoxLayout = new QHBoxLayout(mainBox);
311 //leftFrameLayout = new QVBoxLayout(leftFrame ); 311 //leftFrameLayout = new QVBoxLayout(leftFrame );
312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
316 } 316 }
317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
318 //QBoxLayout * leftFrameLayout; 318 //QBoxLayout * leftFrameLayout;
319 topLayout->addWidget( mMainFrame ); 319 topLayout->addWidget( mMainFrame );
320 //mainBoxLayout->addWidget (mLeftFrame); 320 //mainBoxLayout->addWidget (mLeftFrame);
321 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 321 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
322 "CalendarView::DateNavigator" ); 322 "CalendarView::DateNavigator" );
323#if 0 323#if 0
324 // FIXME 324 // FIXME
325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
326 "CalendarView::DateNavigator", QDate::currentDate()); 326 "CalendarView::DateNavigator", QDate::currentDate());
327#endif 327#endif
328 // mDateNavigator->blockSignals( true ); 328 // mDateNavigator->blockSignals( true );
329 //leftFrameLayout->addWidget( mDateNavigator ); 329 //leftFrameLayout->addWidget( mDateNavigator );
330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
332 mTodoList->setNavigator( mNavigator ); 332 mTodoList->setNavigator( mNavigator );
333#if 0 333#if 0
334 if ( QApplication::desktop()->width() < 480 ) { 334 if ( QApplication::desktop()->width() < 480 ) {
335 leftFrameLayout->addWidget(mFilterView); 335 leftFrameLayout->addWidget(mFilterView);
336 leftFrameLayout->addWidget(mTodoList, 2 ); 336 leftFrameLayout->addWidget(mTodoList, 2 );
337 337
338 } else { 338 } else {
339 leftFrameLayout->addWidget(mTodoList,2 ); 339 leftFrameLayout->addWidget(mTodoList,2 );
340 leftFrameLayout->addWidget(mFilterView ); 340 leftFrameLayout->addWidget(mFilterView );
341 } 341 }
342#endif 342#endif
343 mFilterView->hide(); 343 mFilterView->hide();
344 QWidget *rightBox = new QWidget( mMainFrame ); 344 QWidget *rightBox = new QWidget( mMainFrame );
345 //mainBoxLayout->addWidget ( rightBox, 10 ); 345 //mainBoxLayout->addWidget ( rightBox, 10 );
346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
347 mRightFrame = new QWidgetStack( rightBox ); 347 mRightFrame = new QWidgetStack( rightBox );
348 rightLayout->addWidget( mRightFrame, 10 ); 348 rightLayout->addWidget( mRightFrame, 10 );
349 349
350 //mLeftFrame = (QWidget *)leftFrame; 350 //mLeftFrame = (QWidget *)leftFrame;
351 if ( KOPrefs::instance()->mVerticalScreen ) { 351 if ( KOPrefs::instance()->mVerticalScreen ) {
352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
356 } else { 356 } else {
357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
360 } 360 }
361 if ( !KOPrefs::instance()->mShowDateNavigator) 361 if ( !KOPrefs::instance()->mShowDateNavigator)
362 mDateNavigator->hide(); 362 mDateNavigator->hide();
363 //qDebug("Calendarview Size %d %d ", width(), height()); 363 //qDebug("Calendarview Size %d %d ", width(), height());
364#endif 364#endif
365 365
366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
367 SLOT( showDates( const KCal::DateList & ) ) ); 367 SLOT( showDates( const KCal::DateList & ) ) );
368 368
369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
371 371
372 372
373 373
374 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 374 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
375 mViewManager, SLOT( showMonth( const QDate & ) ) ); 375 mViewManager, SLOT( showMonth( const QDate & ) ) );
376 376
377 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 377 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
378 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 378 mNavigator, SLOT( selectWeek( const QDate & ) ) );
379 379
380 connect( mDateNavigator, SIGNAL( goPrevYear() ), 380 connect( mDateNavigator, SIGNAL( goPrevYear() ),
381 mNavigator, SLOT( selectPreviousYear() ) ); 381 mNavigator, SLOT( selectPreviousYear() ) );
382 connect( mDateNavigator, SIGNAL( goNextYear() ), 382 connect( mDateNavigator, SIGNAL( goNextYear() ),
383 mNavigator, SLOT( selectNextYear() ) ); 383 mNavigator, SLOT( selectNextYear() ) );
384 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 384 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
385 mNavigator, SLOT( selectPreviousMonth() ) ); 385 mNavigator, SLOT( selectPreviousMonth() ) );
386 connect( mDateNavigator, SIGNAL( goNextMonth() ), 386 connect( mDateNavigator, SIGNAL( goNextMonth() ),
387 mNavigator, SLOT( selectNextMonth() ) ); 387 mNavigator, SLOT( selectNextMonth() ) );
388 388
389 connect( mDateNavigator, SIGNAL( goPrevious() ), 389 connect( mDateNavigator, SIGNAL( goPrevious() ),
390 mNavigator, SLOT( selectPrevious() ) ); 390 mNavigator, SLOT( selectPrevious() ) );
391 connect( mDateNavigator, SIGNAL( goNext() ), 391 connect( mDateNavigator, SIGNAL( goNext() ),
392 mNavigator, SLOT( selectNext() ) ); 392 mNavigator, SLOT( selectNext() ) );
393 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 393 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
394 mNavigator, SLOT( slotMonthSelect( int ) ) ); 394 mNavigator, SLOT( slotMonthSelect( int ) ) );
395 395
396 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 396 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
397 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 397 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
398#if 0 398#if 0
399 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 399 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
400 SLOT( incidenceAdded( Incidence *) ) ); 400 SLOT( incidenceAdded( Incidence *) ) );
401#endif 401#endif
402 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 402 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
403 403
404 connect( this, SIGNAL( configChanged() ), 404 connect( this, SIGNAL( configChanged() ),
405 mDateNavigator, SLOT( updateConfig() ) ); 405 mDateNavigator, SLOT( updateConfig() ) );
406 406
407 connect( mTodoList, SIGNAL( newTodoSignal() ), 407 connect( mTodoList, SIGNAL( newTodoSignal() ),
408 SLOT( newTodo() ) ); 408 SLOT( newTodo() ) );
409 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 409 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
410 SLOT( newSubTodo( Todo * ) ) ); 410 SLOT( newSubTodo( Todo * ) ) );
411 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 411 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
412 SLOT( editTodo( Todo * ) ) ); 412 SLOT( editTodo( Todo * ) ) );
413 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
414 SLOT( showTodo( Todo *) ) ); 414 SLOT( showTodo( Todo *) ) );
415 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 415 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
416 SLOT( deleteTodo( Todo *) ) ); 416 SLOT( deleteTodo( Todo *) ) );
417 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 417 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
418 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 418 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
419 SLOT( purgeCompleted() ) ); 419 SLOT( purgeCompleted() ) );
420 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 420 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
421 SIGNAL( todoModified( Todo *, int ) ) ); 421 SIGNAL( todoModified( Todo *, int ) ) );
422 422
423 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 423 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
424 this, SLOT ( cloneIncidence( Incidence * ) ) ); 424 this, SLOT ( cloneIncidence( Incidence * ) ) );
425 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 425 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
426 this, SLOT (cancelIncidence( Incidence * ) ) ); 426 this, SLOT (cancelIncidence( Incidence * ) ) );
427 427
428 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 428 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
429 this, SLOT ( moveIncidence( Incidence * ) ) ); 429 this, SLOT ( moveIncidence( Incidence * ) ) );
430 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 430 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
431 this, SLOT ( beamIncidence( Incidence * ) ) ); 431 this, SLOT ( beamIncidence( Incidence * ) ) );
432 432
433 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 433 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
434 this, SLOT ( todo_unsub( Todo * ) ) ); 434 this, SLOT ( todo_unsub( Todo * ) ) );
435 435
436 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 436 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
437 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 437 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
438 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 438 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
439 SLOT( updateTodo( Todo *, int ) ) ); 439 SLOT( updateTodo( Todo *, int ) ) );
440 connect( this, SIGNAL( todoModified( Todo *, int )), this, 440 connect( this, SIGNAL( todoModified( Todo *, int )), this,
441 SLOT( changeTodoDisplay( Todo *, int ) ) ); 441 SLOT( changeTodoDisplay( Todo *, int ) ) );
442 442
443 443
444 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 444 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
445 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 445 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
446 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 446 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
447 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 447 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
448 448
449 449
450 450
451 451
452 452
453 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 453 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
454 SLOT(checkClipboard())); 454 SLOT(checkClipboard()));
455 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 455 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
456 SLOT( processTodoListSelection( Incidence * ) ) ); 456 SLOT( processTodoListSelection( Incidence * ) ) );
457 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 457 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
458 458
459 // kdDebug() << "CalendarView::CalendarView() done" << endl; 459 // kdDebug() << "CalendarView::CalendarView() done" << endl;
460 460
461 mDateFrame = new QVBox(0,0,WType_Popup); 461 mDateFrame = new QVBox(0,0,WType_Popup);
462 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 462 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
463 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 463 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
464 mDateFrame->setLineWidth(3); 464 mDateFrame->setLineWidth(3);
465 mDateFrame->hide(); 465 mDateFrame->hide();
466 mDateFrame->setCaption( i18n( "Pick a date to display")); 466 mDateFrame->setCaption( i18n( "Pick a date to display"));
467 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 467 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
468 468
469 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 469 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
470 470
471 mEventEditor = mDialogManager->getEventEditor(); 471 mEventEditor = mDialogManager->getEventEditor();
472 mTodoEditor = mDialogManager->getTodoEditor(); 472 mTodoEditor = mDialogManager->getTodoEditor();
473 473
474 mFlagEditDescription = false; 474 mFlagEditDescription = false;
475 475
476 mSuspendTimer = new QTimer( this ); 476 mSuspendTimer = new QTimer( this );
477 mAlarmTimer = new QTimer( this ); 477 mAlarmTimer = new QTimer( this );
478 mRecheckAlarmTimer = new QTimer( this ); 478 mRecheckAlarmTimer = new QTimer( this );
479 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 479 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
480 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 480 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
481 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 481 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
482 mAlarmDialog = new AlarmDialog( this ); 482 mAlarmDialog = new AlarmDialog( this );
483 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 483 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
484 mAlarmDialog->setServerNotification( false ); 484 mAlarmDialog->setServerNotification( false );
485 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 485 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
486 486
487 487
488#ifndef DESKTOP_VERSION 488#ifndef DESKTOP_VERSION
489//US listen for arriving address resultsets 489//US listen for arriving address resultsets
490 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 490 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
491 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 491 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
492#endif 492#endif
493 mDateNavigator->setCalendar( mCalendar ); 493 mDateNavigator->setCalendar( mCalendar );
494} 494}
495 495
496 496
497CalendarView::~CalendarView() 497CalendarView::~CalendarView()
498{ 498{
499 // kdDebug() << "~CalendarView()" << endl; 499 // kdDebug() << "~CalendarView()" << endl;
500 //qDebug("CalendarView::~CalendarView() "); 500 //qDebug("CalendarView::~CalendarView() ");
501 delete mDialogManager; 501 delete mDialogManager;
502 delete mViewManager; 502 delete mViewManager;
503 delete mStorage; 503 delete mStorage;
504 delete mDateFrame ; 504 delete mDateFrame ;
505 delete beamDialog; 505 delete beamDialog;
506 delete mEventViewerDialog; 506 delete mEventViewerDialog;
507 //kdDebug() << "~CalendarView() done" << endl; 507 //kdDebug() << "~CalendarView() done" << endl;
508} 508}
509 509
510void CalendarView::showDay( QDate d ) 510void CalendarView::showDay( QDate d )
511{ 511{
512 dateNavigator()->blockSignals( true ); 512 dateNavigator()->blockSignals( true );
513 dateNavigator()->selectDate( d ); 513 dateNavigator()->selectDate( d );
514 dateNavigator()->blockSignals( false ); 514 dateNavigator()->blockSignals( false );
515 mViewManager->showDayView(); 515 mViewManager->showDayView();
516 //dateNavigator()->selectDate( d ); 516 //dateNavigator()->selectDate( d );
517} 517}
518void CalendarView::timerAlarm() 518void CalendarView::timerAlarm()
519{ 519{
520 //qDebug("CalendarView::timerAlarm() "); 520 //qDebug("CalendarView::timerAlarm() ");
521 computeAlarm(mAlarmNotification ); 521 computeAlarm(mAlarmNotification );
522} 522}
523 523
524void CalendarView::suspendAlarm() 524void CalendarView::suspendAlarm()
525{ 525{
526 //qDebug(" CalendarView::suspendAlarm() "); 526 //qDebug(" CalendarView::suspendAlarm() ");
527 computeAlarm(mSuspendAlarmNotification ); 527 computeAlarm(mSuspendAlarmNotification );
528 528
529} 529}
530 530
531void CalendarView::startAlarm( QString mess , QString filename) 531void CalendarView::startAlarm( QString mess , QString filename)
532{ 532{
533 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 533 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
534 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 534 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
535 535
536} 536}
537 537
538void CalendarView::checkNextTimerAlarm() 538void CalendarView::checkNextTimerAlarm()
539{ 539{
540 mCalendar->checkAlarmForIncidence( 0, true ); 540 mCalendar->checkAlarmForIncidence( 0, true );
541} 541}
542 542
543void CalendarView::computeAlarm( QString msg ) 543void CalendarView::computeAlarm( QString msg )
544{ 544{
545 545
546 QString mess = msg; 546 QString mess = msg;
547 QString mAlarmMessage = mess.mid( 9 ); 547 QString mAlarmMessage = mess.mid( 9 );
548 QString filename = MainWindow::resourcePath(); 548 QString filename = MainWindow::resourcePath();
549 filename += "koalarm.wav"; 549 filename += "koalarm.wav";
550 QString tempfilename; 550 QString tempfilename;
551 if ( mess.left( 13 ) == "suspend_alarm") { 551 if ( mess.left( 13 ) == "suspend_alarm") {
552 bool error = false; 552 bool error = false;
553 int len = mess.mid( 13 ).find("+++"); 553 int len = mess.mid( 13 ).find("+++");
554 if ( len < 2 ) 554 if ( len < 2 )
555 error = true; 555 error = true;
556 else { 556 else {
557 tempfilename = mess.mid( 13, len ); 557 tempfilename = mess.mid( 13, len );
558 if ( !QFile::exists( tempfilename ) ) 558 if ( !QFile::exists( tempfilename ) )
559 error = true; 559 error = true;
560 } 560 }
561 if ( ! error ) { 561 if ( ! error ) {
562 filename = tempfilename; 562 filename = tempfilename;
563 } 563 }
564 mAlarmMessage = mess.mid( 13+len+3 ); 564 mAlarmMessage = mess.mid( 13+len+3 );
565 //qDebug("suspend file %s ",tempfilename.latin1() ); 565 //qDebug("suspend file %s ",tempfilename.latin1() );
566 startAlarm( mAlarmMessage, filename); 566 startAlarm( mAlarmMessage, filename);
567 return; 567 return;
568 } 568 }
569 if ( mess.left( 11 ) == "timer_alarm") { 569 if ( mess.left( 11 ) == "timer_alarm") {
570 //mTimerTime = 0; 570 //mTimerTime = 0;
571 startAlarm( mess.mid( 11 ), filename ); 571 startAlarm( mess.mid( 11 ), filename );
572 return; 572 return;
573 } 573 }
574 if ( mess.left( 10 ) == "proc_alarm") { 574 if ( mess.left( 10 ) == "proc_alarm") {
575 bool error = false; 575 bool error = false;
576 int len = mess.mid( 10 ).find("+++"); 576 int len = mess.mid( 10 ).find("+++");
577 if ( len < 2 ) 577 if ( len < 2 )
578 error = true; 578 error = true;
579 else { 579 else {
580 tempfilename = mess.mid( 10, len ); 580 tempfilename = mess.mid( 10, len );
581 if ( !QFile::exists( tempfilename ) ) 581 if ( !QFile::exists( tempfilename ) )
582 error = true; 582 error = true;
583 } 583 }
584 if ( error ) { 584 if ( error ) {
585 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 585 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
586 mAlarmMessage += mess.mid( 10+len+3+9 ); 586 mAlarmMessage += mess.mid( 10+len+3+9 );
587 } else { 587 } else {
588 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 588 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
589 //qDebug("-----system command %s ",tempfilename.latin1() ); 589 //qDebug("-----system command %s ",tempfilename.latin1() );
590#ifndef _WIN32_ 590#ifndef _WIN32_
591 if ( vfork () == 0 ) { 591 if ( vfork () == 0 ) {
592 execl ( tempfilename.latin1(), 0 ); 592 execl ( tempfilename.latin1(), 0 );
593 return; 593 return;
594 } 594 }
595#else 595#else
596 QProcess* p = new QProcess(); 596 QProcess* p = new QProcess();
597 p->addArgument( tempfilename.latin1() ); 597 p->addArgument( tempfilename.latin1() );
598 p->start(); 598 p->start();
599 return; 599 return;
600#endif 600#endif
601 601
602 return; 602 return;
603 } 603 }
604 604
605 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 605 //qDebug("+++++++system command %s ",tempfilename.latin1() );
606 } 606 }
607 if ( mess.left( 11 ) == "audio_alarm") { 607 if ( mess.left( 11 ) == "audio_alarm") {
608 bool error = false; 608 bool error = false;
609 int len = mess.mid( 11 ).find("+++"); 609 int len = mess.mid( 11 ).find("+++");
610 if ( len < 2 ) 610 if ( len < 2 )
611 error = true; 611 error = true;
612 else { 612 else {
613 tempfilename = mess.mid( 11, len ); 613 tempfilename = mess.mid( 11, len );
614 if ( !QFile::exists( tempfilename ) ) 614 if ( !QFile::exists( tempfilename ) )
615 error = true; 615 error = true;
616 } 616 }
617 if ( ! error ) { 617 if ( ! error ) {
618 filename = tempfilename; 618 filename = tempfilename;
619 } 619 }
620 mAlarmMessage = mess.mid( 11+len+3+9 ); 620 mAlarmMessage = mess.mid( 11+len+3+9 );
621 //qDebug("audio file command %s ",tempfilename.latin1() ); 621 //qDebug("audio file command %s ",tempfilename.latin1() );
622 } 622 }
623 if ( mess.left( 9 ) == "cal_alarm") { 623 if ( mess.left( 9 ) == "cal_alarm") {
624 mAlarmMessage = mess.mid( 9 ) ; 624 mAlarmMessage = mess.mid( 9 ) ;
625 } 625 }
626 626
627 startAlarm( mAlarmMessage, filename ); 627 startAlarm( mAlarmMessage, filename );
628 628
629 629
630} 630}
631 631
632void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 632void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
633{ 633{
634 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 634 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
635 635
636 mSuspendAlarmNotification = noti; 636 mSuspendAlarmNotification = noti;
637 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 637 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
638 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 638 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
639 mSuspendTimer->start( ms , true ); 639 mSuspendTimer->start( ms , true );
640 640
641} 641}
642 642
643void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 643void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
644{ 644{
645 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 645 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
646 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 646 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
647#ifndef DESKTOP_VERSION 647#ifndef DESKTOP_VERSION
648 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 648 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
649#endif 649#endif
650 return; 650 return;
651 } 651 }
652 int maxSec; 652 int maxSec;
653 //maxSec = 5; //testing only 653 //maxSec = 5; //testing only
654 maxSec = 86400+3600; // one day+1hour 654 maxSec = 86400+3600; // one day+1hour
655 mAlarmNotification = noti; 655 mAlarmNotification = noti;
656 int sec = QDateTime::currentDateTime().secsTo( qdt ); 656 int sec = QDateTime::currentDateTime().secsTo( qdt );
657 if ( sec > maxSec ) { 657 if ( sec > maxSec ) {
658 mRecheckAlarmTimer->start( maxSec * 1000 ); 658 mRecheckAlarmTimer->start( maxSec * 1000 );
659 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 659 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
660 return; 660 return;
661 } else { 661 } else {
662 mRecheckAlarmTimer->stop(); 662 mRecheckAlarmTimer->stop();
663 } 663 }
664 //qDebug("Alarm timer started with secs: %d ", sec); 664 //qDebug("Alarm timer started with secs: %d ", sec);
665 mAlarmTimer->start( sec *1000 , true ); 665 mAlarmTimer->start( sec *1000 , true );
666 666
667} 667}
668// called by mRecheckAlarmTimer to get next alarm 668// called by mRecheckAlarmTimer to get next alarm
669// we need this, because a QTimer has only a max range of 25 days 669// we need this, because a QTimer has only a max range of 25 days
670void CalendarView::recheckTimerAlarm() 670void CalendarView::recheckTimerAlarm()
671{ 671{
672 mAlarmTimer->stop(); 672 mAlarmTimer->stop();
673 mRecheckAlarmTimer->stop(); 673 mRecheckAlarmTimer->stop();
674 mCalendar->checkAlarmForIncidence( 0, true ); 674 mCalendar->checkAlarmForIncidence( 0, true );
675} 675}
676void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 676void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
677{ 677{
678 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 678 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
679 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 679 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
680#ifndef DESKTOP_VERSION 680#ifndef DESKTOP_VERSION
681 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 681 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
682#endif 682#endif
683 return; 683 return;
684 } 684 }
685 mAlarmTimer->stop(); 685 mAlarmTimer->stop();
686} 686}
687void CalendarView::selectWeekNum ( int num ) 687void CalendarView::selectWeekNum ( int num )
688{ 688{
689 dateNavigator()->blockSignals( true ); 689 dateNavigator()->blockSignals( true );
690 dateNavigator()->selectWeek( num ); 690 dateNavigator()->selectWeek( num );
691 dateNavigator()->blockSignals( false ); 691 dateNavigator()->blockSignals( false );
692 mViewManager->showWeekView(); 692 mViewManager->showWeekView();
693} 693}
694KOViewManager *CalendarView::viewManager() 694KOViewManager *CalendarView::viewManager()
695{ 695{
696 return mViewManager; 696 return mViewManager;
697} 697}
698 698
699KODialogManager *CalendarView::dialogManager() 699KODialogManager *CalendarView::dialogManager()
700{ 700{
701 return mDialogManager; 701 return mDialogManager;
702} 702}
703 703
704QDate CalendarView::startDate() 704QDate CalendarView::startDate()
705{ 705{
706 DateList dates = mNavigator->selectedDates(); 706 DateList dates = mNavigator->selectedDates();
707 707
708 return dates.first(); 708 return dates.first();
709} 709}
710 710
711QDate CalendarView::endDate() 711QDate CalendarView::endDate()
712{ 712{
713 DateList dates = mNavigator->selectedDates(); 713 DateList dates = mNavigator->selectedDates();
714 714
715 return dates.last(); 715 return dates.last();
716} 716}
717 717
718 718
719void CalendarView::createPrinter() 719void CalendarView::createPrinter()
720{ 720{
721#ifndef KORG_NOPRINTER 721#ifndef KORG_NOPRINTER
722 if (!mCalPrinter) { 722 if (!mCalPrinter) {
723 mCalPrinter = new CalPrinter(this, mCalendar); 723 mCalPrinter = new CalPrinter(this, mCalendar);
724 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 724 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
725 } 725 }
726#endif 726#endif
727} 727}
728 728
729 729
730//KOPrefs::instance()->mWriteBackFile 730//KOPrefs::instance()->mWriteBackFile
731//KOPrefs::instance()->mWriteBackExistingOnly 731//KOPrefs::instance()->mWriteBackExistingOnly
732 732
733// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 733// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
734// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 734// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
735// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 735// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
736// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 736// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
737// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 737// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
738// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 738// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
739 739
740int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 740int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
741{ 741{
742 742
743 // 0 equal 743 // 0 equal
744 // 1 take local 744 // 1 take local
745 // 2 take remote 745 // 2 take remote
746 // 3 cancel 746 // 3 cancel
747 QDateTime lastSync = mLastCalendarSync; 747 QDateTime lastSync = mLastCalendarSync;
748 QDateTime localMod = local->lastModified(); 748 QDateTime localMod = local->lastModified();
749 QDateTime remoteMod = remote->lastModified(); 749 QDateTime remoteMod = remote->lastModified();
750 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 750 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
751 bool remCh, locCh; 751 bool remCh, locCh;
752 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 752 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
753 //if ( remCh ) 753 //if ( remCh )
754 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 754 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
755 locCh = ( localMod > mLastCalendarSync ); 755 locCh = ( localMod > mLastCalendarSync );
756 if ( !remCh && ! locCh ) { 756 if ( !remCh && ! locCh ) {
757 //qDebug("both not changed "); 757 //qDebug("both not changed ");
758 lastSync = localMod.addDays(1); 758 lastSync = localMod.addDays(1);
759 if ( mode <= SYNC_PREF_ASK ) 759 if ( mode <= SYNC_PREF_ASK )
760 return 0; 760 return 0;
761 } else { 761 } else {
762 if ( locCh ) { 762 if ( locCh ) {
763 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 763 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
764 lastSync = localMod.addDays( -1 ); 764 lastSync = localMod.addDays( -1 );
765 if ( !remCh ) 765 if ( !remCh )
766 remoteMod = ( lastSync.addDays( -1 ) ); 766 remoteMod = ( lastSync.addDays( -1 ) );
767 } else { 767 } else {
768 //qDebug(" not loc changed "); 768 //qDebug(" not loc changed ");
769 lastSync = localMod.addDays( 1 ); 769 lastSync = localMod.addDays( 1 );
770 if ( remCh ) 770 if ( remCh )
771 remoteMod =( lastSync.addDays( 1 ) ); 771 remoteMod =( lastSync.addDays( 1 ) );
772 772
773 } 773 }
774 } 774 }
775 full = true; 775 full = true;
776 if ( mode < SYNC_PREF_ASK ) 776 if ( mode < SYNC_PREF_ASK )
777 mode = SYNC_PREF_ASK; 777 mode = SYNC_PREF_ASK;
778 } else { 778 } else {
779 if ( localMod == remoteMod ) 779 if ( localMod == remoteMod )
780 // if ( local->revision() == remote->revision() ) 780 // if ( local->revision() == remote->revision() )
781 return 0; 781 return 0;
782 782
783 } 783 }
784 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 784 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
785 785
786 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 786 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
787 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 787 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
788 //full = true; //debug only 788 //full = true; //debug only
789 if ( full ) { 789 if ( full ) {
790 bool equ = false; 790 bool equ = false;
791 if ( local->type() == "Event" ) { 791 if ( local->type() == "Event" ) {
792 equ = (*((Event*) local) == *((Event*) remote)); 792 equ = (*((Event*) local) == *((Event*) remote));
793 } 793 }
794 else if ( local->type() =="Todo" ) 794 else if ( local->type() =="Todo" )
795 equ = (*((Todo*) local) == (*(Todo*) remote)); 795 equ = (*((Todo*) local) == (*(Todo*) remote));
796 else if ( local->type() =="Journal" ) 796 else if ( local->type() =="Journal" )
797 equ = (*((Journal*) local) == *((Journal*) remote)); 797 equ = (*((Journal*) local) == *((Journal*) remote));
798 if ( equ ) { 798 if ( equ ) {
799 //qDebug("equal "); 799 //qDebug("equal ");
800 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 800 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
801 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 801 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
802 } 802 }
803 if ( mode < SYNC_PREF_FORCE_LOCAL ) 803 if ( mode < SYNC_PREF_FORCE_LOCAL )
804 return 0; 804 return 0;
805 805
806 }//else //debug only 806 }//else //debug only
807 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 807 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
808 } 808 }
809 int result; 809 int result;
810 bool localIsNew; 810 bool localIsNew;
811 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 811 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
812 812
813 if ( full && mode < SYNC_PREF_NEWEST ) 813 if ( full && mode < SYNC_PREF_NEWEST )
814 mode = SYNC_PREF_ASK; 814 mode = SYNC_PREF_ASK;
815 815
816 switch( mode ) { 816 switch( mode ) {
817 case SYNC_PREF_LOCAL: 817 case SYNC_PREF_LOCAL:
818 if ( lastSync > remoteMod ) 818 if ( lastSync > remoteMod )
819 return 1; 819 return 1;
820 if ( lastSync > localMod ) 820 if ( lastSync > localMod )
821 return 2; 821 return 2;
822 return 1; 822 return 1;
823 break; 823 break;
824 case SYNC_PREF_REMOTE: 824 case SYNC_PREF_REMOTE:
825 if ( lastSync > remoteMod ) 825 if ( lastSync > remoteMod )
826 return 1; 826 return 1;
827 if ( lastSync > localMod ) 827 if ( lastSync > localMod )
828 return 2; 828 return 2;
829 return 2; 829 return 2;
830 break; 830 break;
831 case SYNC_PREF_NEWEST: 831 case SYNC_PREF_NEWEST:
832 if ( localMod > remoteMod ) 832 if ( localMod > remoteMod )
833 return 1; 833 return 1;
834 else 834 else
835 return 2; 835 return 2;
836 break; 836 break;
837 case SYNC_PREF_ASK: 837 case SYNC_PREF_ASK:
838 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 838 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
839 if ( lastSync > remoteMod ) 839 if ( lastSync > remoteMod )
840 return 1; 840 return 1;
841 if ( lastSync > localMod ) 841 if ( lastSync > localMod )
842 return 2; 842 return 2;
843 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 843 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
844 localIsNew = localMod >= remoteMod; 844 localIsNew = localMod >= remoteMod;
845 if ( localIsNew ) 845 if ( localIsNew )
846 getEventViewerDialog()->setColorMode( 1 ); 846 getEventViewerDialog()->setColorMode( 1 );
847 else 847 else
848 getEventViewerDialog()->setColorMode( 2 ); 848 getEventViewerDialog()->setColorMode( 2 );
849 getEventViewerDialog()->setIncidence(local); 849 getEventViewerDialog()->setIncidence(local);
850 if ( localIsNew ) 850 if ( localIsNew )
851 getEventViewerDialog()->setColorMode( 2 ); 851 getEventViewerDialog()->setColorMode( 2 );
852 else 852 else
853 getEventViewerDialog()->setColorMode( 1 ); 853 getEventViewerDialog()->setColorMode( 1 );
854 getEventViewerDialog()->addIncidence(remote); 854 getEventViewerDialog()->addIncidence(remote);
855 getEventViewerDialog()->setColorMode( 0 ); 855 getEventViewerDialog()->setColorMode( 0 );
856 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 856 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
857 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 857 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
858 getEventViewerDialog()->showMe(); 858 getEventViewerDialog()->showMe();
859 result = getEventViewerDialog()->executeS( localIsNew ); 859 result = getEventViewerDialog()->executeS( localIsNew );
860 return result; 860 return result;
861 861
862 break; 862 break;
863 case SYNC_PREF_FORCE_LOCAL: 863 case SYNC_PREF_FORCE_LOCAL:
864 return 1; 864 return 1;
865 break; 865 break;
866 case SYNC_PREF_FORCE_REMOTE: 866 case SYNC_PREF_FORCE_REMOTE:
867 return 2; 867 return 2;
868 break; 868 break;
869 869
870 default: 870 default:
871 // SYNC_PREF_TAKE_BOTH not implemented 871 // SYNC_PREF_TAKE_BOTH not implemented
872 break; 872 break;
873 } 873 }
874 return 0; 874 return 0;
875} 875}
876Event* CalendarView::getLastSyncEvent() 876Event* CalendarView::getLastSyncEvent()
877{ 877{
878 Event* lse; 878 Event* lse;
879 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 879 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
880 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 880 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
881 if (!lse) { 881 if (!lse) {
882 lse = new Event(); 882 lse = new Event();
883 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 883 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
884 QString sum = ""; 884 QString sum = "";
885 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 885 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
886 sum = "E: "; 886 sum = "E: ";
887 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 887 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
888 lse->setDtStart( mLastCalendarSync ); 888 lse->setDtStart( mLastCalendarSync );
889 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 889 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
890 lse->setCategories( i18n("SyncEvent") ); 890 lse->setCategories( i18n("SyncEvent") );
891 lse->setReadOnly( true ); 891 lse->setReadOnly( true );
892 mCalendar->addEvent( lse ); 892 mCalendar->addEvent( lse );
893 } 893 }
894 894
895 return lse; 895 return lse;
896 896
897} 897}
898 898
899// we check, if the to delete event has a id for a profile 899// we check, if the to delete event has a id for a profile
900// if yes, we set this id in the profile to delete 900// if yes, we set this id in the profile to delete
901void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 901void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
902{ 902{
903 if ( lastSync.count() == 0 ) { 903 if ( lastSync.count() == 0 ) {
904 //qDebug(" lastSync.count() == 0"); 904 //qDebug(" lastSync.count() == 0");
905 return; 905 return;
906 } 906 }
907 if ( toDelete->type() == "Journal" ) 907 if ( toDelete->type() == "Journal" )
908 return; 908 return;
909 909
910 Event* eve = lastSync.first(); 910 Event* eve = lastSync.first();
911 911
912 while ( eve ) { 912 while ( eve ) {
913 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 913 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
914 if ( !id.isEmpty() ) { 914 if ( !id.isEmpty() ) {
915 QString des = eve->description(); 915 QString des = eve->description();
916 QString pref = "e"; 916 QString pref = "e";
917 if ( toDelete->type() == "Todo" ) 917 if ( toDelete->type() == "Todo" )
918 pref = "t"; 918 pref = "t";
919 des += pref+ id + ","; 919 des += pref+ id + ",";
920 eve->setReadOnly( false ); 920 eve->setReadOnly( false );
921 eve->setDescription( des ); 921 eve->setDescription( des );
922 //qDebug("setdes %s ", des.latin1()); 922 //qDebug("setdes %s ", des.latin1());
923 eve->setReadOnly( true ); 923 eve->setReadOnly( true );
924 } 924 }
925 eve = lastSync.next(); 925 eve = lastSync.next();
926 } 926 }
927 927
928} 928}
929void CalendarView::checkExternalId( Incidence * inc ) 929void CalendarView::checkExternalId( Incidence * inc )
930{ 930{
931 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 931 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
932 checkExternSyncEvent( lastSync, inc ); 932 checkExternSyncEvent( lastSync, inc );
933 933
934} 934}
935bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 935bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
936{ 936{
937 bool syncOK = true; 937 bool syncOK = true;
938 int addedEvent = 0; 938 int addedEvent = 0;
939 int addedEventR = 0; 939 int addedEventR = 0;
940 int deletedEventR = 0; 940 int deletedEventR = 0;
941 int deletedEventL = 0; 941 int deletedEventL = 0;
942 int changedLocal = 0; 942 int changedLocal = 0;
943 int changedRemote = 0; 943 int changedRemote = 0;
944 int filteredIN = 0; 944 int filteredIN = 0;
945 int filteredOUT = 0; 945 int filteredOUT = 0;
946 //QPtrList<Event> el = local->rawEvents(); 946 //QPtrList<Event> el = local->rawEvents();
947 Event* eventR; 947 Event* eventR;
948 QString uid; 948 QString uid;
949 int take; 949 int take;
950 Event* eventL; 950 Event* eventL;
951 Event* eventRSync; 951 Event* eventRSync;
952 Event* eventLSync; 952 Event* eventLSync;
953 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 953 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
954 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 954 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
955 bool fullDateRange = false; 955 bool fullDateRange = false;
956 local->resetTempSyncStat(); 956 local->resetTempSyncStat();
957 mLastCalendarSync = QDateTime::currentDateTime(); 957 mLastCalendarSync = QDateTime::currentDateTime();
958 if ( mSyncManager->syncWithDesktop() ) { 958 if ( mSyncManager->syncWithDesktop() ) {
959 remote->resetPilotStat(1); 959 remote->resetPilotStat(1);
960 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 960 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
961 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 961 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
962 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 962 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
963 } else { 963 } else {
964 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 964 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
965 } 965 }
966 } 966 }
967 QDateTime modifiedCalendar = mLastCalendarSync; 967 QDateTime modifiedCalendar = mLastCalendarSync;
968 eventLSync = getLastSyncEvent(); 968 eventLSync = getLastSyncEvent();
969 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 969 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
970 if ( eventR ) { 970 if ( eventR ) {
971 eventRSync = (Event*) eventR->clone(); 971 eventRSync = (Event*) eventR->clone();
972 remote->deleteEvent(eventR ); 972 remote->deleteEvent(eventR );
973 973
974 } else { 974 } else {
975 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 975 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
976 eventRSync = (Event*)eventLSync->clone(); 976 eventRSync = (Event*)eventLSync->clone();
977 } else { 977 } else {
978 fullDateRange = true; 978 fullDateRange = true;
979 eventRSync = new Event(); 979 eventRSync = new Event();
980 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 980 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
981 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 981 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
982 eventRSync->setDtStart( mLastCalendarSync ); 982 eventRSync->setDtStart( mLastCalendarSync );
983 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 983 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
984 eventRSync->setCategories( i18n("SyncEvent") ); 984 eventRSync->setCategories( i18n("SyncEvent") );
985 } 985 }
986 } 986 }
987 if ( eventLSync->dtStart() == mLastCalendarSync ) 987 if ( eventLSync->dtStart() == mLastCalendarSync )
988 fullDateRange = true; 988 fullDateRange = true;
989 989
990 if ( ! fullDateRange ) { 990 if ( ! fullDateRange ) {
991 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 991 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
992 992
993 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 993 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
994 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 994 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
995 fullDateRange = true; 995 fullDateRange = true;
996 } 996 }
997 } 997 }
998 if ( mSyncManager->syncWithDesktop() ) { 998 if ( mSyncManager->syncWithDesktop() ) {
999 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 999 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1000 } 1000 }
1001 if ( fullDateRange ) 1001 if ( fullDateRange )
1002 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1002 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1003 else 1003 else
1004 mLastCalendarSync = eventLSync->dtStart(); 1004 mLastCalendarSync = eventLSync->dtStart();
1005 // for resyncing if own file has changed 1005 // for resyncing if own file has changed
1006 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1006 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1007 mLastCalendarSync = loadedFileVersion; 1007 mLastCalendarSync = loadedFileVersion;
1008 //qDebug("setting mLastCalendarSync "); 1008 //qDebug("setting mLastCalendarSync ");
1009 } 1009 }
1010 //qDebug("*************************** "); 1010 //qDebug("*************************** ");
1011 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1011 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1012 QPtrList<Incidence> er = remote->rawIncidences(); 1012 QPtrList<Incidence> er = remote->rawIncidences();
1013 Incidence* inR = er.first(); 1013 Incidence* inR = er.first();
1014 Incidence* inL; 1014 Incidence* inL;
1015 QProgressBar bar( er.count(),0 ); 1015 QProgressBar bar( er.count(),0 );
1016 bar.setCaption (i18n("Syncing - close to abort!") ); 1016 bar.setCaption (i18n("Syncing - close to abort!") );
1017 1017
1018 // ************** setting up filter ************* 1018 // ************** setting up filter *************
1019 CalFilter *filterIN = 0; 1019 CalFilter *filterIN = 0;
1020 CalFilter *filterOUT = 0; 1020 CalFilter *filterOUT = 0;
1021 CalFilter *filter = mFilters.first(); 1021 CalFilter *filter = mFilters.first();
1022 while(filter) { 1022 while(filter) {
1023 if ( filter->name() == mSyncManager->mFilterInCal ) 1023 if ( filter->name() == mSyncManager->mFilterInCal )
1024 filterIN = filter; 1024 filterIN = filter;
1025 if ( filter->name() == mSyncManager->mFilterOutCal ) 1025 if ( filter->name() == mSyncManager->mFilterOutCal )
1026 filterOUT = filter; 1026 filterOUT = filter;
1027 filter = mFilters.next(); 1027 filter = mFilters.next();
1028 } 1028 }
1029 int w = 300; 1029 int w = 300;
1030 if ( QApplication::desktop()->width() < 320 ) 1030 if ( QApplication::desktop()->width() < 320 )
1031 w = 220; 1031 w = 220;
1032 int h = bar.sizeHint().height() ; 1032 int h = bar.sizeHint().height() ;
1033 int dw = QApplication::desktop()->width(); 1033 int dw = QApplication::desktop()->width();
1034 int dh = QApplication::desktop()->height(); 1034 int dh = QApplication::desktop()->height();
1035 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1035 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1036 bar.show(); 1036 bar.show();
1037 int modulo = (er.count()/10)+1; 1037 int modulo = (er.count()/10)+1;
1038 int incCounter = 0; 1038 int incCounter = 0;
1039 while ( inR ) { 1039 while ( inR ) {
1040 if ( ! bar.isVisible() ) 1040 if ( ! bar.isVisible() )
1041 return false; 1041 return false;
1042 if ( incCounter % modulo == 0 ) 1042 if ( incCounter % modulo == 0 )
1043 bar.setProgress( incCounter ); 1043 bar.setProgress( incCounter );
1044 ++incCounter; 1044 ++incCounter;
1045 uid = inR->uid(); 1045 uid = inR->uid();
1046 bool skipIncidence = false; 1046 bool skipIncidence = false;
1047 if ( uid.left(15) == QString("last-syncEvent-") ) 1047 if ( uid.left(15) == QString("last-syncEvent-") )
1048 skipIncidence = true; 1048 skipIncidence = true;
1049 QString idS; 1049 QString idS;
1050 qApp->processEvents(); 1050 qApp->processEvents();
1051 if ( !skipIncidence ) { 1051 if ( !skipIncidence ) {
1052 inL = local->incidence( uid ); 1052 inL = local->incidence( uid );
1053 if ( inL ) { // maybe conflict - same uid in both calendars 1053 if ( inL ) { // maybe conflict - same uid in both calendars
1054 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1054 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1055 //qDebug("take %d %s ", take, inL->summary().latin1()); 1055 //qDebug("take %d %s ", take, inL->summary().latin1());
1056 if ( take == 3 ) 1056 if ( take == 3 )
1057 return false; 1057 return false;
1058 if ( take == 1 ) {// take local ********************** 1058 if ( take == 1 ) {// take local **********************
1059 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1059 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1060 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1060 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1061 else 1061 else
1062 idS = inR->IDStr(); 1062 idS = inR->IDStr();
1063 remote->deleteIncidence( inR ); 1063 remote->deleteIncidence( inR );
1064 inR = inL->clone(); 1064 inR = inL->clone();
1065 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1065 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1066 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1066 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1067 inR->setIDStr( idS ); 1067 inR->setIDStr( idS );
1068 remote->addIncidence( inR ); 1068 remote->addIncidence( inR );
1069 if ( mSyncManager->syncWithDesktop() ) 1069 if ( mSyncManager->syncWithDesktop() )
1070 inR->setPilotId( 2 ); 1070 inR->setPilotId( 2 );
1071 ++changedRemote; 1071 ++changedRemote;
1072 } else {// take remote ********************** 1072 } else {// take remote **********************
1073 idS = inL->IDStr(); 1073 idS = inL->IDStr();
1074 int pid = inL->pilotId(); 1074 int pid = inL->pilotId();
1075 local->deleteIncidence( inL ); 1075 local->deleteIncidence( inL );
1076 inL = inR->clone(); 1076 inL = inR->clone();
1077 if ( mSyncManager->syncWithDesktop() ) 1077 if ( mSyncManager->syncWithDesktop() )
1078 inL->setPilotId( pid ); 1078 inL->setPilotId( pid );
1079 inL->setIDStr( idS ); 1079 inL->setIDStr( idS );
1080 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1080 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1081 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1081 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1082 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1082 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1083 } 1083 }
1084 local->addIncidence( inL ); 1084 local->addIncidence( inL );
1085 ++changedLocal; 1085 ++changedLocal;
1086 } 1086 }
1087 } 1087 }
1088 } else { // no conflict ********** add or delete remote 1088 } else { // no conflict ********** add or delete remote
1089 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1089 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1091 QString des = eventLSync->description(); 1091 QString des = eventLSync->description();
1092 QString pref = "e"; 1092 QString pref = "e";
1093 if ( inR->type() == "Todo" ) 1093 if ( inR->type() == "Todo" )
1094 pref = "t"; 1094 pref = "t";
1095 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1095 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1096 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1096 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1097 //remote->deleteIncidence( inR ); 1097 //remote->deleteIncidence( inR );
1098 ++deletedEventR; 1098 ++deletedEventR;
1099 } else { 1099 } else {
1100 inR->setLastModified( modifiedCalendar ); 1100 inR->setLastModified( modifiedCalendar );
1101 inL = inR->clone(); 1101 inL = inR->clone();
1102 inL->setIDStr( ":" ); 1102 inL->setIDStr( ":" );
1103 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1103 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1104 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1104 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1105 local->addIncidence( inL ); 1105 local->addIncidence( inL );
1106 ++addedEvent; 1106 ++addedEvent;
1107 1107
1108 } 1108 }
1109 } else { 1109 } else {
1110 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1110 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1111 inR->setLastModified( modifiedCalendar ); 1111 inR->setLastModified( modifiedCalendar );
1112 inL = inR->clone(); 1112 inL = inR->clone();
1113 inL->setIDStr( ":" ); 1113 inL->setIDStr( ":" );
1114 local->addIncidence( inL ); 1114 local->addIncidence( inL );
1115 ++addedEvent; 1115 ++addedEvent;
1116 1116
1117 } else { 1117 } else {
1118 checkExternSyncEvent(eventRSyncSharp, inR); 1118 checkExternSyncEvent(eventRSyncSharp, inR);
1119 remote->deleteIncidence( inR ); 1119 remote->deleteIncidence( inR );
1120 ++deletedEventR; 1120 ++deletedEventR;
1121 } 1121 }
1122 } 1122 }
1123 } else { 1123 } else {
1124 ++filteredIN; 1124 ++filteredIN;
1125 } 1125 }
1126 } 1126 }
1127 } 1127 }
1128 inR = er.next(); 1128 inR = er.next();
1129 } 1129 }
1130 QPtrList<Incidence> el = local->rawIncidences(); 1130 QPtrList<Incidence> el = local->rawIncidences();
1131 inL = el.first(); 1131 inL = el.first();
1132 modulo = (el.count()/10)+1; 1132 modulo = (el.count()/10)+1;
1133 bar.setCaption (i18n("Add / remove events") ); 1133 bar.setCaption (i18n("Add / remove events") );
1134 bar.setTotalSteps ( el.count() ) ; 1134 bar.setTotalSteps ( el.count() ) ;
1135 bar.show(); 1135 bar.show();
1136 incCounter = 0; 1136 incCounter = 0;
1137 1137
1138 while ( inL ) { 1138 while ( inL ) {
1139 1139
1140 qApp->processEvents(); 1140 qApp->processEvents();
1141 if ( ! bar.isVisible() ) 1141 if ( ! bar.isVisible() )
1142 return false; 1142 return false;
1143 if ( incCounter % modulo == 0 ) 1143 if ( incCounter % modulo == 0 )
1144 bar.setProgress( incCounter ); 1144 bar.setProgress( incCounter );
1145 ++incCounter; 1145 ++incCounter;
1146 uid = inL->uid(); 1146 uid = inL->uid();
1147 bool skipIncidence = false; 1147 bool skipIncidence = false;
1148 if ( uid.left(15) == QString("last-syncEvent-") ) 1148 if ( uid.left(15) == QString("last-syncEvent-") )
1149 skipIncidence = true; 1149 skipIncidence = true;
1150 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1150 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1151 skipIncidence = true; 1151 skipIncidence = true;
1152 if ( !skipIncidence ) { 1152 if ( !skipIncidence ) {
1153 inR = remote->incidence( uid ); 1153 inR = remote->incidence( uid );
1154 if ( ! inR ) { 1154 if ( ! inR ) {
1155 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1155 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1156 // no conflict ********** add or delete local 1156 // no conflict ********** add or delete local
1157 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1157 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1158 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1158 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1159 checkExternSyncEvent(eventLSyncSharp, inL); 1159 checkExternSyncEvent(eventLSyncSharp, inL);
1160 local->deleteIncidence( inL ); 1160 local->deleteIncidence( inL );
1161 ++deletedEventL; 1161 ++deletedEventL;
1162 } else { 1162 } else {
1163 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1163 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1164 inL->removeID(mCurrentSyncDevice ); 1164 inL->removeID(mCurrentSyncDevice );
1165 ++addedEventR; 1165 ++addedEventR;
1166 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1166 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1167 inL->setLastModified( modifiedCalendar ); 1167 inL->setLastModified( modifiedCalendar );
1168 inR = inL->clone(); 1168 inR = inL->clone();
1169 inR->setIDStr( ":" ); 1169 inR->setIDStr( ":" );
1170 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1170 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1171 remote->addIncidence( inR ); 1171 remote->addIncidence( inR );
1172 } 1172 }
1173 } 1173 }
1174 } else { 1174 } else {
1175 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1175 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1176 checkExternSyncEvent(eventLSyncSharp, inL); 1176 checkExternSyncEvent(eventLSyncSharp, inL);
1177 local->deleteIncidence( inL ); 1177 local->deleteIncidence( inL );
1178 ++deletedEventL; 1178 ++deletedEventL;
1179 } else { 1179 } else {
1180 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1180 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1181 ++addedEventR; 1181 ++addedEventR;
1182 inL->setLastModified( modifiedCalendar ); 1182 inL->setLastModified( modifiedCalendar );
1183 inR = inL->clone(); 1183 inR = inL->clone();
1184 inR->setIDStr( ":" ); 1184 inR->setIDStr( ":" );
1185 remote->addIncidence( inR ); 1185 remote->addIncidence( inR );
1186 } 1186 }
1187 } 1187 }
1188 } 1188 }
1189 } else { 1189 } else {
1190 ++filteredOUT; 1190 ++filteredOUT;
1191 } 1191 }
1192 } 1192 }
1193 } 1193 }
1194 inL = el.next(); 1194 inL = el.next();
1195 } 1195 }
1196 int delFut = 0; 1196 int delFut = 0;
1197 int remRem = 0; 1197 int remRem = 0;
1198 if ( mSyncManager->mWriteBackInFuture ) { 1198 if ( mSyncManager->mWriteBackInFuture ) {
1199 er = remote->rawIncidences(); 1199 er = remote->rawIncidences();
1200 remRem = er.count(); 1200 remRem = er.count();
1201 inR = er.first(); 1201 inR = er.first();
1202 QDateTime dt; 1202 QDateTime dt;
1203 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1203 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1204 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1204 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1205 while ( inR ) { 1205 while ( inR ) {
1206 if ( inR->type() == "Todo" ) { 1206 if ( inR->type() == "Todo" ) {
1207 Todo * t = (Todo*)inR; 1207 Todo * t = (Todo*)inR;
1208 if ( t->hasDueDate() ) 1208 if ( t->hasDueDate() )
1209 dt = t->dtDue(); 1209 dt = t->dtDue();
1210 else 1210 else
1211 dt = cur.addSecs( 62 ); 1211 dt = cur.addSecs( 62 );
1212 } 1212 }
1213 else if (inR->type() == "Event" ) { 1213 else if (inR->type() == "Event" ) {
1214 bool ok; 1214 bool ok;
1215 dt = inR->getNextOccurence( cur, &ok ); 1215 dt = inR->getNextOccurence( cur, &ok );
1216 if ( !ok ) 1216 if ( !ok )
1217 dt = cur.addSecs( -62 ); 1217 dt = cur.addSecs( -62 );
1218 } 1218 }
1219 else 1219 else
1220 dt = inR->dtStart(); 1220 dt = inR->dtStart();
1221 if ( dt < cur || dt > end ) { 1221 if ( dt < cur || dt > end ) {
1222 remote->deleteIncidence( inR ); 1222 remote->deleteIncidence( inR );
1223 ++delFut; 1223 ++delFut;
1224 } 1224 }
1225 inR = er.next(); 1225 inR = er.next();
1226 } 1226 }
1227 } 1227 }
1228 bar.hide(); 1228 bar.hide();
1229 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1229 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1230 eventLSync->setReadOnly( false ); 1230 eventLSync->setReadOnly( false );
1231 eventLSync->setDtStart( mLastCalendarSync ); 1231 eventLSync->setDtStart( mLastCalendarSync );
1232 eventRSync->setDtStart( mLastCalendarSync ); 1232 eventRSync->setDtStart( mLastCalendarSync );
1233 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1233 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1234 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1234 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1235 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1235 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1236 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1236 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1237 eventLSync->setReadOnly( true ); 1237 eventLSync->setReadOnly( true );
1238 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1238 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1239 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1239 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1240 remote->addEvent( eventRSync ); 1240 remote->addEvent( eventRSync );
1241 else 1241 else
1242 delete eventRSync; 1242 delete eventRSync;
1243 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1243 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1244 QString mes; 1244 QString mes;
1245 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1245 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1246 QString delmess; 1246 QString delmess;
1247 if ( delFut ) { 1247 if ( delFut ) {
1248 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1248 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1249 mes += delmess; 1249 mes += delmess;
1250 } 1250 }
1251 mes = i18n("Local calendar changed!\n") +mes; 1251 mes = i18n("Local calendar changed!\n") +mes;
1252 mCalendar->checkAlarmForIncidence( 0, true ); 1252 mCalendar->checkAlarmForIncidence( 0, true );
1253 qDebug( mes ); 1253 qDebug( mes );
1254 if ( mSyncManager->mShowSyncSummary ) { 1254 if ( mSyncManager->mShowSyncSummary ) {
1255 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1255 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1256 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1256 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1257 qDebug("KO: WB cancelled "); 1257 qDebug("KO: WB cancelled ");
1258 mSyncManager->mWriteBackFile = false; 1258 mSyncManager->mWriteBackFile = false;
1259 return syncOK; 1259 return syncOK;
1260 } 1260 }
1261 } 1261 }
1262 return syncOK; 1262 return syncOK;
1263} 1263}
1264 1264
1265void CalendarView::setSyncDevice( QString s ) 1265void CalendarView::setSyncDevice( QString s )
1266{ 1266{
1267 mCurrentSyncDevice= s; 1267 mCurrentSyncDevice= s;
1268} 1268}
1269void CalendarView::setSyncName( QString s ) 1269void CalendarView::setSyncName( QString s )
1270{ 1270{
1271 mCurrentSyncName= s; 1271 mCurrentSyncName= s;
1272} 1272}
1273bool CalendarView::syncCalendar(QString filename, int mode) 1273bool CalendarView::syncCalendar(QString filename, int mode)
1274{ 1274{
1275 //qDebug("syncCalendar %s ", filename.latin1()); 1275 //qDebug("syncCalendar %s ", filename.latin1());
1276 mGlobalSyncMode = SYNC_MODE_NORMAL; 1276 mGlobalSyncMode = SYNC_MODE_NORMAL;
1277 CalendarLocal* calendar = new CalendarLocal(); 1277 CalendarLocal* calendar = new CalendarLocal();
1278 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1278 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1279 FileStorage* storage = new FileStorage( calendar ); 1279 FileStorage* storage = new FileStorage( calendar );
1280 bool syncOK = false; 1280 bool syncOK = false;
1281 storage->setFileName( filename ); 1281 storage->setFileName( filename );
1282 // qDebug("loading ... "); 1282 // qDebug("loading ... ");
1283 if ( storage->load() ) { 1283 if ( storage->load() ) {
1284 getEventViewerDialog()->setSyncMode( true ); 1284 getEventViewerDialog()->setSyncMode( true );
1285 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1285 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1286 getEventViewerDialog()->setSyncMode( false ); 1286 getEventViewerDialog()->setSyncMode( false );
1287 if ( syncOK ) { 1287 if ( syncOK ) {
1288 if ( mSyncManager->mWriteBackFile ) 1288 if ( mSyncManager->mWriteBackFile )
1289 { 1289 {
1290 storage->setSaveFormat( new ICalFormat() ); 1290 storage->setSaveFormat( new ICalFormat() );
1291 storage->save(); 1291 storage->save();
1292 } 1292 }
1293 } 1293 }
1294 setModified( true ); 1294 setModified( true );
1295 } 1295 }
1296 delete storage; 1296 delete storage;
1297 delete calendar; 1297 delete calendar;
1298 if ( syncOK ) 1298 if ( syncOK )
1299 updateView(); 1299 updateView();
1300 return syncOK; 1300 return syncOK;
1301} 1301}
1302 1302
1303void CalendarView::syncExternal( int mode ) 1303void CalendarView::syncExternal( int mode )
1304{ 1304{
1305 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1305 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1306 1306
1307 qApp->processEvents(); 1307 qApp->processEvents();
1308 CalendarLocal* calendar = new CalendarLocal(); 1308 CalendarLocal* calendar = new CalendarLocal();
1309 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1309 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1310 bool syncOK = false; 1310 bool syncOK = false;
1311 bool loadSuccess = false; 1311 bool loadSuccess = false;
1312 PhoneFormat* phoneFormat = 0; 1312 PhoneFormat* phoneFormat = 0;
1313 emit tempDisableBR(true); 1313 emit tempDisableBR(true);
1314#ifndef DESKTOP_VERSION 1314#ifndef DESKTOP_VERSION
1315 SharpFormat* sharpFormat = 0; 1315 SharpFormat* sharpFormat = 0;
1316 if ( mode == 0 ) { // sharp 1316 if ( mode == 0 ) { // sharp
1317 sharpFormat = new SharpFormat () ; 1317 sharpFormat = new SharpFormat () ;
1318 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1318 loadSuccess = sharpFormat->load( calendar, mCalendar );
1319 1319
1320 } else 1320 } else
1321#endif 1321#endif
1322 if ( mode == 1 ) { // phone 1322 if ( mode == 1 ) { // phone
1323 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1323 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1324 mSyncManager->mPhoneDevice, 1324 mSyncManager->mPhoneDevice,
1325 mSyncManager->mPhoneConnection, 1325 mSyncManager->mPhoneConnection,
1326 mSyncManager->mPhoneModel); 1326 mSyncManager->mPhoneModel);
1327 loadSuccess = phoneFormat->load( calendar,mCalendar); 1327 loadSuccess = phoneFormat->load( calendar,mCalendar);
1328 1328
1329 } else { 1329 } else {
1330 emit tempDisableBR(false); 1330 emit tempDisableBR(false);
1331 return; 1331 return;
1332 } 1332 }
1333 if ( loadSuccess ) { 1333 if ( loadSuccess ) {
1334 getEventViewerDialog()->setSyncMode( true ); 1334 getEventViewerDialog()->setSyncMode( true );
1335 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1335 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1336 getEventViewerDialog()->setSyncMode( false ); 1336 getEventViewerDialog()->setSyncMode( false );
1337 qApp->processEvents(); 1337 qApp->processEvents();
1338 if ( syncOK ) { 1338 if ( syncOK ) {
1339 if ( mSyncManager->mWriteBackFile ) 1339 if ( mSyncManager->mWriteBackFile )
1340 { 1340 {
1341 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1341 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1342 Incidence* inc = iL.first(); 1342 Incidence* inc = iL.first();
1343 if ( phoneFormat ) { 1343 if ( phoneFormat ) {
1344 while ( inc ) { 1344 while ( inc ) {
1345 inc->removeID(mCurrentSyncDevice); 1345 inc->removeID(mCurrentSyncDevice);
1346 inc = iL.next(); 1346 inc = iL.next();
1347 } 1347 }
1348 } 1348 }
1349#ifndef DESKTOP_VERSION 1349#ifndef DESKTOP_VERSION
1350 if ( sharpFormat ) 1350 if ( sharpFormat )
1351 sharpFormat->save(calendar); 1351 sharpFormat->save(calendar);
1352#endif 1352#endif
1353 if ( phoneFormat ) 1353 if ( phoneFormat )
1354 phoneFormat->save(calendar); 1354 phoneFormat->save(calendar);
1355 iL = calendar->rawIncidences(); 1355 iL = calendar->rawIncidences();
1356 inc = iL.first(); 1356 inc = iL.first();
1357 Incidence* loc; 1357 Incidence* loc;
1358 while ( inc ) { 1358 while ( inc ) {
1359 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1359 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1360 loc = mCalendar->incidence(inc->uid() ); 1360 loc = mCalendar->incidence(inc->uid() );
1361 if ( loc ) { 1361 if ( loc ) {
1362 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1362 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1363 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1363 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1364 } 1364 }
1365 } 1365 }
1366 inc = iL.next(); 1366 inc = iL.next();
1367 } 1367 }
1368 Incidence* lse = getLastSyncEvent(); 1368 Incidence* lse = getLastSyncEvent();
1369 if ( lse ) { 1369 if ( lse ) {
1370 lse->setReadOnly( false ); 1370 lse->setReadOnly( false );
1371 lse->setDescription( "" ); 1371 lse->setDescription( "" );
1372 lse->setReadOnly( true ); 1372 lse->setReadOnly( true );
1373 } 1373 }
1374 } 1374 }
1375 } else { 1375 } else {
1376 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1376 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1377 } 1377 }
1378 setModified( true ); 1378 setModified( true );
1379 } else { 1379 } else {
1380 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1380 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1381 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1381 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1382 question, i18n("Ok")) ; 1382 question, i18n("Ok")) ;
1383 1383
1384 } 1384 }
1385 delete calendar; 1385 delete calendar;
1386 updateView(); 1386 updateView();
1387 emit tempDisableBR(false); 1387 emit tempDisableBR(false);
1388 return ;//syncOK; 1388 return ;//syncOK;
1389 1389
1390} 1390}
1391 1391
1392bool CalendarView::importBday() 1392bool CalendarView::importBday()
1393{ 1393{
1394#ifndef KORG_NOKABC 1394#ifndef KORG_NOKABC
1395 1395
1396#ifdef DESKTOP_VERSION 1396#ifdef DESKTOP_VERSION
1397 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1397 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1398 KABC::AddressBook::Iterator it; 1398 KABC::AddressBook::Iterator it;
1399 int count = 0; 1399 int count = 0;
1400 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1400 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1401 ++count; 1401 ++count;
1402 } 1402 }
1403 QProgressBar bar(count,0 ); 1403 QProgressBar bar(count,0 );
1404 int w = 300; 1404 int w = 300;
1405 if ( QApplication::desktop()->width() < 320 ) 1405 if ( QApplication::desktop()->width() < 320 )
1406 w = 220; 1406 w = 220;
1407 int h = bar.sizeHint().height() ; 1407 int h = bar.sizeHint().height() ;
1408 int dw = QApplication::desktop()->width(); 1408 int dw = QApplication::desktop()->width();
1409 int dh = QApplication::desktop()->height(); 1409 int dh = QApplication::desktop()->height();
1410 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1410 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1411 bar.show(); 1411 bar.show();
1412 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1412 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1413 qApp->processEvents(); 1413 qApp->processEvents();
1414 count = 0; 1414 count = 0;
1415 int addCount = 0; 1415 int addCount = 0;
1416 KCal::Attendee* a = 0; 1416 KCal::Attendee* a = 0;
1417 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1417 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1418 if ( ! bar.isVisible() ) 1418 if ( ! bar.isVisible() )
1419 return false; 1419 return false;
1420 bar.setProgress( count++ ); 1420 bar.setProgress( count++ );
1421 qApp->processEvents(); 1421 qApp->processEvents();
1422 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1422 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1423 if ( (*it).birthday().date().isValid() ){ 1423 if ( (*it).birthday().date().isValid() ){
1424 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1424 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1425 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1425 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1426 ++addCount; 1426 ++addCount;
1427 } 1427 }
1428 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1428 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1429 if ( anni.isValid() ){ 1429 if ( anni.isValid() ){
1430 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1430 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1431 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1431 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1432 ++addCount; 1432 ++addCount;
1433 } 1433 }
1434 } 1434 }
1435 updateView(); 1435 updateView();
1436 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1436 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1437#else //DESKTOP_VERSION 1437#else //DESKTOP_VERSION
1438 1438
1439 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1439 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1440 // the result should now arrive through method insertBirthdays 1440 // the result should now arrive through method insertBirthdays
1441 1441
1442#endif //DESKTOP_VERSION 1442#endif //DESKTOP_VERSION
1443 1443
1444#endif //KORG_NOKABC 1444#endif //KORG_NOKABC
1445 1445
1446 1446
1447 return true; 1447 return true;
1448} 1448}
1449 1449
1450// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1450// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1451void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1451void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1452 const QStringList& anniversaryList, const QStringList& realNameList, 1452 const QStringList& anniversaryList, const QStringList& realNameList,
1453 const QStringList& emailList, const QStringList& assembledNameList, 1453 const QStringList& emailList, const QStringList& assembledNameList,
1454 const QStringList& uidList) 1454 const QStringList& uidList)
1455{ 1455{
1456 //qDebug("KO::CalendarView::insertBirthdays"); 1456 //qDebug("KO::CalendarView::insertBirthdays");
1457 if (uid == this->name()) 1457 if (uid == this->name())
1458 { 1458 {
1459 int count = birthdayList.count(); 1459 int count = birthdayList.count();
1460 int addCount = 0; 1460 int addCount = 0;
1461 KCal::Attendee* a = 0; 1461 KCal::Attendee* a = 0;
1462 1462
1463 //qDebug("CalView 1 %i", count); 1463 //qDebug("CalView 1 %i", count);
1464 1464
1465 QProgressBar bar(count,0 ); 1465 QProgressBar bar(count,0 );
1466 int w = 300; 1466 int w = 300;
1467 if ( QApplication::desktop()->width() < 320 ) 1467 if ( QApplication::desktop()->width() < 320 )
1468 w = 220; 1468 w = 220;
1469 int h = bar.sizeHint().height() ; 1469 int h = bar.sizeHint().height() ;
1470 int dw = QApplication::desktop()->width(); 1470 int dw = QApplication::desktop()->width();
1471 int dh = QApplication::desktop()->height(); 1471 int dh = QApplication::desktop()->height();
1472 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1472 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1473 bar.show(); 1473 bar.show();
1474 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1474 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1475 qApp->processEvents(); 1475 qApp->processEvents();
1476 1476
1477 QDate birthday; 1477 QDate birthday;
1478 QDate anniversary; 1478 QDate anniversary;
1479 QString realName; 1479 QString realName;
1480 QString email; 1480 QString email;
1481 QString assembledName; 1481 QString assembledName;
1482 QString uid; 1482 QString uid;
1483 bool ok = true; 1483 bool ok = true;
1484 for ( int i = 0; i < count; i++) 1484 for ( int i = 0; i < count; i++)
1485 { 1485 {
1486 if ( ! bar.isVisible() ) 1486 if ( ! bar.isVisible() )
1487 return; 1487 return;
1488 bar.setProgress( i ); 1488 bar.setProgress( i );
1489 qApp->processEvents(); 1489 qApp->processEvents();
1490 1490
1491 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1491 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1492 if (!ok) { 1492 if (!ok) {
1493 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1493 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1494 } 1494 }
1495 1495
1496 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1496 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1497 if (!ok) { 1497 if (!ok) {
1498 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1498 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1499 } 1499 }
1500 realName = realNameList[i]; 1500 realName = realNameList[i];
1501 email = emailList[i]; 1501 email = emailList[i];
1502 assembledName = assembledNameList[i]; 1502 assembledName = assembledNameList[i];
1503 uid = uidList[i]; 1503 uid = uidList[i];
1504 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1504 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1505 1505
1506 if ( birthday.isValid() ){ 1506 if ( birthday.isValid() ){
1507 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1507 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1508 KCal::Attendee::ReqParticipant,uid) ; 1508 KCal::Attendee::ReqParticipant,uid) ;
1509 if ( addAnniversary( birthday, assembledName, a, true ) ) 1509 if ( addAnniversary( birthday, assembledName, a, true ) )
1510 ++addCount; 1510 ++addCount;
1511 } 1511 }
1512 1512
1513 if ( anniversary.isValid() ){ 1513 if ( anniversary.isValid() ){
1514 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1514 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1515 KCal::Attendee::ReqParticipant,uid) ; 1515 KCal::Attendee::ReqParticipant,uid) ;
1516 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1516 if ( addAnniversary( anniversary, assembledName, a, false ) )
1517 ++addCount; 1517 ++addCount;
1518 } 1518 }
1519 } 1519 }
1520 1520
1521 updateView(); 1521 updateView();
1522 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1522 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1523 1523
1524 } 1524 }
1525 1525
1526} 1526}
1527 1527
1528 1528
1529 1529
1530bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1530bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1531{ 1531{
1532 //qDebug("addAnni "); 1532 //qDebug("addAnni ");
1533 Event * ev = new Event(); 1533 Event * ev = new Event();
1534 ev->setOrganizer(KOPrefs::instance()->email()); 1534 ev->setOrganizer(KOPrefs::instance()->email());
1535 if ( a ) { 1535 if ( a ) {
1536 ev->addAttendee( a ); 1536 ev->addAttendee( a );
1537 } 1537 }
1538 QString kind; 1538 QString kind;
1539 if ( birthday ) { 1539 if ( birthday ) {
1540 kind = i18n( "Birthday" ); 1540 kind = i18n( "Birthday" );
1541 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1541 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1542 } 1542 }
1543 else { 1543 else {
1544 kind = i18n( "Anniversary" ); 1544 kind = i18n( "Anniversary" );
1545 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1545 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1546 } 1546 }
1547 ev->setCategories( kind ); 1547 ev->setCategories( kind );
1548 ev->setDtStart( QDateTime(date) ); 1548 ev->setDtStart( QDateTime(date) );
1549 ev->setDtEnd( QDateTime(date) ); 1549 ev->setDtEnd( QDateTime(date) );
1550 ev->setFloats( true ); 1550 ev->setFloats( true );
1551 Recurrence * rec = ev->recurrence(); 1551 Recurrence * rec = ev->recurrence();
1552 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1552 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1553 rec->addYearlyNum( date.month() ); 1553 rec->addYearlyNum( date.month() );
1554 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1554 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1555 delete ev; 1555 delete ev;
1556 return false; 1556 return false;
1557 } 1557 }
1558 return true; 1558 return true;
1559 1559
1560} 1560}
1561bool CalendarView::importQtopia( const QString &categories, 1561bool CalendarView::importQtopia( const QString &categories,
1562 const QString &datebook, 1562 const QString &datebook,
1563 const QString &todolist ) 1563 const QString &todolist )
1564{ 1564{
1565 1565
1566 QtopiaFormat qtopiaFormat; 1566 QtopiaFormat qtopiaFormat;
1567 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1567 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1568 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1568 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1569 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1569 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1570 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1570 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1571 1571
1572 updateView(); 1572 updateView();
1573 return true; 1573 return true;
1574 1574
1575#if 0 1575#if 0
1576 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1576 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1577 mCurrentSyncDevice = "qtopia-XML"; 1577 mCurrentSyncDevice = "qtopia-XML";
1578 if ( mSyncManager->mAskForPreferences ) 1578 if ( mSyncManager->mAskForPreferences )
1579 edit_sync_options(); 1579 edit_sync_options();
1580 qApp->processEvents(); 1580 qApp->processEvents();
1581 CalendarLocal* calendar = new CalendarLocal(); 1581 CalendarLocal* calendar = new CalendarLocal();
1582 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1582 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1583 bool syncOK = false; 1583 bool syncOK = false;
1584 QtopiaFormat qtopiaFormat; 1584 QtopiaFormat qtopiaFormat;
1585 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1585 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1586 bool loadOk = true; 1586 bool loadOk = true;
1587 if ( !categories.isEmpty() ) 1587 if ( !categories.isEmpty() )
1588 loadOk = qtopiaFormat.load( calendar, categories ); 1588 loadOk = qtopiaFormat.load( calendar, categories );
1589 if ( loadOk && !datebook.isEmpty() ) 1589 if ( loadOk && !datebook.isEmpty() )
1590 loadOk = qtopiaFormat.load( calendar, datebook ); 1590 loadOk = qtopiaFormat.load( calendar, datebook );
1591 if ( loadOk && !todolist.isEmpty() ) 1591 if ( loadOk && !todolist.isEmpty() )
1592 loadOk = qtopiaFormat.load( calendar, todolist ); 1592 loadOk = qtopiaFormat.load( calendar, todolist );
1593 1593
1594 if ( loadOk ) { 1594 if ( loadOk ) {
1595 getEventViewerDialog()->setSyncMode( true ); 1595 getEventViewerDialog()->setSyncMode( true );
1596 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1596 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1597 getEventViewerDialog()->setSyncMode( false ); 1597 getEventViewerDialog()->setSyncMode( false );
1598 qApp->processEvents(); 1598 qApp->processEvents();
1599 if ( syncOK ) { 1599 if ( syncOK ) {
1600 if ( mSyncManager->mWriteBackFile ) 1600 if ( mSyncManager->mWriteBackFile )
1601 { 1601 {
1602 // write back XML file 1602 // write back XML file
1603 1603
1604 } 1604 }
1605 setModified( true ); 1605 setModified( true );
1606 } 1606 }
1607 } else { 1607 } else {
1608 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1608 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1609 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1609 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1610 question, i18n("Ok")) ; 1610 question, i18n("Ok")) ;
1611 } 1611 }
1612 delete calendar; 1612 delete calendar;
1613 updateView(); 1613 updateView();
1614 return syncOK; 1614 return syncOK;
1615 1615
1616 1616
1617#endif 1617#endif
1618 1618
1619} 1619}
1620 1620
1621void CalendarView::setSyncEventsReadOnly() 1621void CalendarView::setSyncEventsReadOnly()
1622{ 1622{
1623 Event * ev; 1623 Event * ev;
1624 QPtrList<Event> eL = mCalendar->rawEvents(); 1624 QPtrList<Event> eL = mCalendar->rawEvents();
1625 ev = eL.first(); 1625 ev = eL.first();
1626 while ( ev ) { 1626 while ( ev ) {
1627 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1627 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1628 ev->setReadOnly( true ); 1628 ev->setReadOnly( true );
1629 ev = eL.next(); 1629 ev = eL.next();
1630 } 1630 }
1631} 1631}
1632bool CalendarView::openCalendar(QString filename, bool merge) 1632bool CalendarView::openCalendar(QString filename, bool merge)
1633{ 1633{
1634 1634
1635 if (filename.isEmpty()) { 1635 if (filename.isEmpty()) {
1636 return false; 1636 return false;
1637 } 1637 }
1638 1638
1639 if (!QFile::exists(filename)) { 1639 if (!QFile::exists(filename)) {
1640 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1640 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1641 return false; 1641 return false;
1642 } 1642 }
1643 1643
1644 globalFlagBlockAgenda = 1; 1644 globalFlagBlockAgenda = 1;
1645 if (!merge) mCalendar->close(); 1645 if (!merge) mCalendar->close();
1646 1646
1647 mStorage->setFileName( filename ); 1647 mStorage->setFileName( filename );
1648 1648
1649 if ( mStorage->load() ) { 1649 if ( mStorage->load() ) {
1650 if ( merge ) ;//setModified( true ); 1650 if ( merge ) ;//setModified( true );
1651 else { 1651 else {
1652 //setModified( true ); 1652 //setModified( true );
1653 mViewManager->setDocumentId( filename ); 1653 mViewManager->setDocumentId( filename );
1654 mDialogManager->setDocumentId( filename ); 1654 mDialogManager->setDocumentId( filename );
1655 mTodoList->setDocumentId( filename ); 1655 mTodoList->setDocumentId( filename );
1656 } 1656 }
1657 globalFlagBlockAgenda = 2; 1657 globalFlagBlockAgenda = 2;
1658 // if ( getLastSyncEvent() ) 1658 // if ( getLastSyncEvent() )
1659 // getLastSyncEvent()->setReadOnly( true ); 1659 // getLastSyncEvent()->setReadOnly( true );
1660 mCalendar->reInitAlarmSettings(); 1660 mCalendar->reInitAlarmSettings();
1661 setSyncEventsReadOnly(); 1661 setSyncEventsReadOnly();
1662 updateUnmanagedViews(); 1662 updateUnmanagedViews();
1663 updateView(); 1663 updateView();
1664 if ( filename != MainWindow::defaultFileName() ) { 1664 if ( filename != MainWindow::defaultFileName() ) {
1665 saveCalendar( MainWindow::defaultFileName() ); 1665 saveCalendar( MainWindow::defaultFileName() );
1666 } else { 1666 } else {
1667 QFileInfo finf ( MainWindow::defaultFileName()); 1667 QFileInfo finf ( MainWindow::defaultFileName());
1668 if ( finf.exists() ) { 1668 if ( finf.exists() ) {
1669 setLoadedFileVersion( finf.lastModified () ); 1669 setLoadedFileVersion( finf.lastModified () );
1670 } 1670 }
1671 } 1671 }
1672 return true; 1672 return true;
1673 } else { 1673 } else {
1674 // while failing to load, the calendar object could 1674 // while failing to load, the calendar object could
1675 // have become partially populated. Clear it out. 1675 // have become partially populated. Clear it out.
1676 if ( !merge ) { 1676 if ( !merge ) {
1677 mCalendar->close(); 1677 mCalendar->close();
1678 mViewManager->setDocumentId( filename ); 1678 mViewManager->setDocumentId( filename );
1679 mDialogManager->setDocumentId( filename ); 1679 mDialogManager->setDocumentId( filename );
1680 mTodoList->setDocumentId( filename ); 1680 mTodoList->setDocumentId( filename );
1681 } 1681 }
1682 1682
1683 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1683 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1684 1684
1685 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1685 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1686 globalFlagBlockAgenda = 2; 1686 globalFlagBlockAgenda = 2;
1687 mCalendar->reInitAlarmSettings(); 1687 mCalendar->reInitAlarmSettings();
1688 setSyncEventsReadOnly(); 1688 setSyncEventsReadOnly();
1689 updateUnmanagedViews(); 1689 updateUnmanagedViews();
1690 updateView(); 1690 updateView();
1691 } 1691 }
1692 return false; 1692 return false;
1693} 1693}
1694void CalendarView::showOpenError() 1694void CalendarView::showOpenError()
1695{ 1695{
1696 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1696 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1697} 1697}
1698void CalendarView::setLoadedFileVersion(QDateTime dt) 1698void CalendarView::setLoadedFileVersion(QDateTime dt)
1699{ 1699{
1700 loadedFileVersion = dt; 1700 loadedFileVersion = dt;
1701} 1701}
1702bool CalendarView::checkFileChanged(QString fn) 1702bool CalendarView::checkFileChanged(QString fn)
1703{ 1703{
1704 QFileInfo finf ( fn ); 1704 QFileInfo finf ( fn );
1705 if ( !finf.exists() ) 1705 if ( !finf.exists() )
1706 return true; 1706 return true;
1707 QDateTime dt = finf.lastModified (); 1707 QDateTime dt = finf.lastModified ();
1708 if ( dt <= loadedFileVersion ) 1708 if ( dt <= loadedFileVersion )
1709 return false; 1709 return false;
1710 return true; 1710 return true;
1711 1711
1712} 1712}
1713void CalendarView::watchSavedFile() 1713void CalendarView::watchSavedFile()
1714{ 1714{
1715 QFileInfo finf ( MainWindow::defaultFileName()); 1715 QFileInfo finf ( MainWindow::defaultFileName());
1716 if ( !finf.exists() ) 1716 if ( !finf.exists() )
1717 return; 1717 return;
1718 QDateTime dt = finf.lastModified (); 1718 QDateTime dt = finf.lastModified ();
1719 if ( dt < loadedFileVersion ) { 1719 if ( dt < loadedFileVersion ) {
1720 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1720 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1721 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1721 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1722 return; 1722 return;
1723 } 1723 }
1724 loadedFileVersion = dt; 1724 loadedFileVersion = dt;
1725} 1725}
1726 1726
1727bool CalendarView::checkFileVersion(QString fn) 1727bool CalendarView::checkFileVersion(QString fn)
1728{ 1728{
1729 QFileInfo finf ( fn ); 1729 QFileInfo finf ( fn );
1730 if ( !finf.exists() ) 1730 if ( !finf.exists() )
1731 return true; 1731 return true;
1732 QDateTime dt = finf.lastModified (); 1732 QDateTime dt = finf.lastModified ();
1733 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1733 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1734 //qDebug("file on disk version %s",dt.toString().latin1()); 1734 //qDebug("file on disk version %s",dt.toString().latin1());
1735 if ( dt <= loadedFileVersion ) 1735 if ( dt <= loadedFileVersion )
1736 return true; 1736 return true;
1737 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1737 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1738 i18n("KO/Pi Warning"),i18n("Overwrite"), 1738 i18n("KO/Pi Warning"),i18n("Overwrite"),
1739 i18n("Sync+save")); 1739 i18n("Sync+save"));
1740 1740
1741 if ( km == KMessageBox::Cancel ) 1741 if ( km == KMessageBox::Cancel )
1742 return false; 1742 return false;
1743 if ( km == KMessageBox::Yes ) 1743 if ( km == KMessageBox::Yes )
1744 return true; 1744 return true;
1745 1745
1746 setSyncDevice("deleteaftersync" ); 1746 setSyncDevice("deleteaftersync" );
1747 mSyncManager->mAskForPreferences = true; 1747 mSyncManager->mAskForPreferences = true;
1748 mSyncManager->mSyncAlgoPrefs = 3; 1748 mSyncManager->mSyncAlgoPrefs = 3;
1749 mSyncManager->mWriteBackFile = false; 1749 mSyncManager->mWriteBackFile = false;
1750 mSyncManager->mWriteBackExistingOnly = false; 1750 mSyncManager->mWriteBackExistingOnly = false;
1751 mSyncManager->mShowSyncSummary = false; 1751 mSyncManager->mShowSyncSummary = false;
1752 syncCalendar( fn, 3 ); 1752 syncCalendar( fn, 3 );
1753 Event * e = getLastSyncEvent(); 1753 Event * e = getLastSyncEvent();
1754 mCalendar->deleteEvent ( e ); 1754 mCalendar->deleteEvent ( e );
1755 updateView(); 1755 updateView();
1756 return true; 1756 return true;
1757} 1757}
1758 1758
1759bool CalendarView::saveCalendar( QString filename ) 1759bool CalendarView::saveCalendar( QString filename )
1760{ 1760{
1761 1761
1762 // Store back all unsaved data into calendar object 1762 // Store back all unsaved data into calendar object
1763 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1763 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1764 if ( mViewManager->currentView() ) 1764 if ( mViewManager->currentView() )
1765 mViewManager->currentView()->flushView(); 1765 mViewManager->currentView()->flushView();
1766 1766
1767 1767
1768 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1768 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1769 mStorage->setSaveFormat( new ICalFormat() ); 1769 mStorage->setSaveFormat( new ICalFormat() );
1770 mStorage->setFileName( filename ); 1770 mStorage->setFileName( filename );
1771 bool success; 1771 bool success;
1772 success = mStorage->save(); 1772 success = mStorage->save();
1773 if ( !success ) { 1773 if ( !success ) {
1774 return false; 1774 return false;
1775 } 1775 }
1776 if ( filename == MainWindow::defaultFileName() ) { 1776 if ( filename == MainWindow::defaultFileName() ) {
1777 setLoadedFileVersion( lfv ); 1777 setLoadedFileVersion( lfv );
1778 watchSavedFile(); 1778 watchSavedFile();
1779 } 1779 }
1780 return true; 1780 return true;
1781} 1781}
1782 1782
1783void CalendarView::closeCalendar() 1783void CalendarView::closeCalendar()
1784{ 1784{
1785 1785
1786 // child windows no longer valid 1786 // child windows no longer valid
1787 emit closingDown(); 1787 emit closingDown();
1788 1788
1789 mCalendar->close(); 1789 mCalendar->close();
1790 setModified(false); 1790 setModified(false);
1791 updateView(); 1791 updateView();
1792} 1792}
1793 1793
1794void CalendarView::archiveCalendar() 1794void CalendarView::archiveCalendar()
1795{ 1795{
1796 mDialogManager->showArchiveDialog(); 1796 mDialogManager->showArchiveDialog();
1797} 1797}
1798 1798
1799 1799
1800void CalendarView::readSettings() 1800void CalendarView::readSettings()
1801{ 1801{
1802 1802
1803 1803
1804 // mViewManager->showAgendaView(); 1804 // mViewManager->showAgendaView();
1805 QString str; 1805 QString str;
1806 //qDebug("CalendarView::readSettings() "); 1806 //qDebug("CalendarView::readSettings() ");
1807 // read settings from the KConfig, supplying reasonable 1807 // read settings from the KConfig, supplying reasonable
1808 // defaults where none are to be found 1808 // defaults where none are to be found
1809 KConfig *config = KOGlobals::config(); 1809 KConfig *config = KOGlobals::config();
1810#ifndef KORG_NOSPLITTER 1810#ifndef KORG_NOSPLITTER
1811 config->setGroup("KOrganizer Geometry"); 1811 config->setGroup("KOrganizer Geometry");
1812 1812
1813 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1813 QValueList<int> sizes = config->readIntListEntry("Separator1");
1814 if (sizes.count() != 2) { 1814 if (sizes.count() != 2) {
1815 sizes << mDateNavigator->minimumSizeHint().width(); 1815 sizes << mDateNavigator->minimumSizeHint().width();
1816 sizes << 300; 1816 sizes << 300;
1817 } 1817 }
1818 mPanner->setSizes(sizes); 1818 mPanner->setSizes(sizes);
1819 1819
1820 sizes = config->readIntListEntry("Separator2"); 1820 sizes = config->readIntListEntry("Separator2");
1821 if ( ( mResourceView && sizes.count() == 4 ) || 1821 if ( ( mResourceView && sizes.count() == 4 ) ||
1822 ( !mResourceView && sizes.count() == 3 ) ) { 1822 ( !mResourceView && sizes.count() == 3 ) ) {
1823 mLeftSplitter->setSizes(sizes); 1823 mLeftSplitter->setSizes(sizes);
1824 } 1824 }
1825#endif 1825#endif
1826 globalFlagBlockAgenda = 1; 1826 globalFlagBlockAgenda = 1;
1827 mViewManager->showAgendaView(); 1827 mViewManager->showAgendaView();
1828 //mViewManager->readSettings( config ); 1828 //mViewManager->readSettings( config );
1829 mTodoList->restoreLayout(config,QString("Todo Layout")); 1829 mTodoList->restoreLayout(config,QString("Todo Layout"));
1830 readFilterSettings(config); 1830 readFilterSettings(config);
1831 1831
1832#ifdef DESKTOP_VERSION 1832#ifdef DESKTOP_VERSION
1833 config->setGroup("WidgetLayout"); 1833 config->setGroup("WidgetLayout");
1834 QStringList list; 1834 QStringList list;
1835 list = config->readListEntry("MainLayout"); 1835 list = config->readListEntry("MainLayout");
1836 int x,y,w,h; 1836 int x,y,w,h;
1837 if ( ! list.isEmpty() ) { 1837 if ( ! list.isEmpty() ) {
1838 x = list[0].toInt(); 1838 x = list[0].toInt();
1839 y = list[1].toInt(); 1839 y = list[1].toInt();
1840 w = list[2].toInt(); 1840 w = list[2].toInt();
1841 h = list[3].toInt(); 1841 h = list[3].toInt();
1842 topLevelWidget()->setGeometry(x,y,w,h); 1842 topLevelWidget()->setGeometry(x,y,w,h);
1843 1843
1844 } else { 1844 } else {
1845 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1845 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1846 } 1846 }
1847 list = config->readListEntry("EditEventLayout"); 1847 list = config->readListEntry("EditEventLayout");
1848 if ( ! list.isEmpty() ) { 1848 if ( ! list.isEmpty() ) {
1849 x = list[0].toInt(); 1849 x = list[0].toInt();
1850 y = list[1].toInt(); 1850 y = list[1].toInt();
1851 w = list[2].toInt(); 1851 w = list[2].toInt();
1852 h = list[3].toInt(); 1852 h = list[3].toInt();
1853 mEventEditor->setGeometry(x,y,w,h); 1853 mEventEditor->setGeometry(x,y,w,h);
1854 1854
1855 } 1855 }
1856 list = config->readListEntry("EditTodoLayout"); 1856 list = config->readListEntry("EditTodoLayout");
1857 if ( ! list.isEmpty() ) { 1857 if ( ! list.isEmpty() ) {
1858 x = list[0].toInt(); 1858 x = list[0].toInt();
1859 y = list[1].toInt(); 1859 y = list[1].toInt();
1860 w = list[2].toInt(); 1860 w = list[2].toInt();
1861 h = list[3].toInt(); 1861 h = list[3].toInt();
1862 mTodoEditor->setGeometry(x,y,w,h); 1862 mTodoEditor->setGeometry(x,y,w,h);
1863 1863
1864 } 1864 }
1865 list = config->readListEntry("ViewerLayout"); 1865 list = config->readListEntry("ViewerLayout");
1866 if ( ! list.isEmpty() ) { 1866 if ( ! list.isEmpty() ) {
1867 x = list[0].toInt(); 1867 x = list[0].toInt();
1868 y = list[1].toInt(); 1868 y = list[1].toInt();
1869 w = list[2].toInt(); 1869 w = list[2].toInt();
1870 h = list[3].toInt(); 1870 h = list[3].toInt();
1871 getEventViewerDialog()->setGeometry(x,y,w,h); 1871 getEventViewerDialog()->setGeometry(x,y,w,h);
1872 } 1872 }
1873#endif 1873#endif
1874 config->setGroup( "Views" ); 1874 config->setGroup( "Views" );
1875 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1875 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1876 1876
1877 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1877 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1878 1878
1879 int resetval = 0; 1879 int resetval = 0;
1880 int maxVal = 0; 1880 int maxVal = 0;
1881 if (sizes.count() != 3) { 1881 if (sizes.count() != 3) {
1882 if ( KOPrefs::instance()->mVerticalScreen ) { 1882 if ( KOPrefs::instance()->mVerticalScreen ) {
1883 resetval = mDateNavigator->sizeHint().width()+2; 1883 resetval = mDateNavigator->sizeHint().width()+2;
1884 } else { 1884 } else {
1885 resetval = mDateNavigator->sizeHint().height()+2; 1885 resetval = mDateNavigator->sizeHint().height()+2;
1886 } 1886 }
1887 } 1887 }
1888 if ( resetval ) { 1888 if ( resetval ) {
1889 sizes.clear(); 1889 sizes.clear();
1890 if ( KOPrefs::instance()->mVerticalScreen ) { 1890 if ( KOPrefs::instance()->mVerticalScreen ) {
1891 maxVal = QApplication::desktop()->width() -10; 1891 maxVal = QApplication::desktop()->width() -10;
1892 } else { 1892 } else {
1893 maxVal = QApplication::desktop()->height()-10; 1893 maxVal = QApplication::desktop()->height()-10;
1894 } 1894 }
1895 sizes << resetval; 1895 sizes << resetval;
1896 if ( maxVal < resetval + resetval) 1896 if ( maxVal < resetval + resetval)
1897 resetval = maxVal - resetval; 1897 resetval = maxVal - resetval;
1898 sizes << resetval; 1898 sizes << resetval;
1899 sizes << 100; 1899 sizes << 100;
1900 } 1900 }
1901 mLeftFrame->setSizes(sizes); 1901 mLeftFrame->setSizes(sizes);
1902 sizes = config->readIntListEntry("Main Splitter Frame"); 1902 sizes = config->readIntListEntry("Main Splitter Frame");
1903 resetval = 0; 1903 resetval = 0;
1904 maxVal = 0; 1904 maxVal = 0;
1905 if (sizes.count() != 2) { 1905 if (sizes.count() != 2) {
1906 if ( !KOPrefs::instance()->mVerticalScreen ) { 1906 if ( !KOPrefs::instance()->mVerticalScreen ) {
1907 resetval = mDateNavigator->sizeHint().width()+2; 1907 resetval = mDateNavigator->sizeHint().width()+2;
1908 } else { 1908 } else {
1909 resetval = mDateNavigator->sizeHint().height()+2; 1909 resetval = mDateNavigator->sizeHint().height()+2;
1910 } 1910 }
1911 } 1911 }
1912 if ( resetval ) { 1912 if ( resetval ) {
1913 sizes.clear(); 1913 sizes.clear();
1914 if ( !KOPrefs::instance()->mVerticalScreen ) { 1914 if ( !KOPrefs::instance()->mVerticalScreen ) {
1915 maxVal = QApplication::desktop()->width() -10; 1915 maxVal = QApplication::desktop()->width() -10;
1916 } else { 1916 } else {
1917 maxVal = QApplication::desktop()->height()-10; 1917 maxVal = QApplication::desktop()->height()-10;
1918 } 1918 }
1919 sizes << resetval; 1919 sizes << resetval;
1920 if ( maxVal < resetval + resetval) 1920 if ( maxVal < resetval + resetval)
1921 resetval = maxVal - resetval; 1921 resetval = maxVal - resetval;
1922 sizes << resetval; 1922 sizes << resetval;
1923 } 1923 }
1924 mMainFrame->setSizes(sizes); 1924 mMainFrame->setSizes(sizes);
1925 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1925 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1926 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1926 else if ( dateCount == 7 ) mNavigator->selectWeek();
1927 else mNavigator->selectDates( dateCount ); 1927 else mNavigator->selectDates( dateCount );
1928 // mViewManager->readSettings( config ); 1928 // mViewManager->readSettings( config );
1929 updateConfig(); 1929 updateConfig();
1930 globalFlagBlockAgenda = 2; 1930 globalFlagBlockAgenda = 2;
1931 mViewManager->readSettings( config ); 1931 mViewManager->readSettings( config );
1932 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 1932 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
1933} 1933}
1934 1934
1935 1935
1936void CalendarView::writeSettings() 1936void CalendarView::writeSettings()
1937{ 1937{
1938 // kdDebug() << "CalendarView::writeSettings" << endl; 1938 // kdDebug() << "CalendarView::writeSettings" << endl;
1939 1939
1940 KConfig *config = KOGlobals::config(); 1940 KConfig *config = KOGlobals::config();
1941 1941
1942 mViewManager->writeSettings( config ); 1942 mViewManager->writeSettings( config );
1943 mTodoList->saveLayout(config,QString("Todo Layout")); 1943 mTodoList->saveLayout(config,QString("Todo Layout"));
1944 mDialogManager->writeSettings( config ); 1944 mDialogManager->writeSettings( config );
1945 //KOPrefs::instance()->usrWriteConfig(); 1945 //KOPrefs::instance()->usrWriteConfig();
1946 KOPrefs::instance()->writeConfig(); 1946 KOPrefs::instance()->writeConfig();
1947 1947
1948 writeFilterSettings(config); 1948 writeFilterSettings(config);
1949 1949
1950 config->setGroup( "Views" ); 1950 config->setGroup( "Views" );
1951 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1951 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1952 1952
1953 QValueList<int> listINT = mLeftFrame->sizes(); 1953 QValueList<int> listINT = mLeftFrame->sizes();
1954 config->writeEntry("Left Splitter Frame",listINT); 1954 config->writeEntry("Left Splitter Frame",listINT);
1955 QValueList<int> listINT2 = mMainFrame->sizes(); 1955 QValueList<int> listINT2 = mMainFrame->sizes();
1956 config->writeEntry("Main Splitter Frame",listINT2); 1956 config->writeEntry("Main Splitter Frame",listINT2);
1957#ifdef DESKTOP_VERSION 1957#ifdef DESKTOP_VERSION
1958 config->setGroup("WidgetLayout"); 1958 config->setGroup("WidgetLayout");
1959 QStringList list ;//= config->readListEntry("MainLayout"); 1959 QStringList list ;//= config->readListEntry("MainLayout");
1960 int x,y,w,h; 1960 int x,y,w,h;
1961 QWidget* wid; 1961 QWidget* wid;
1962 wid = topLevelWidget(); 1962 wid = topLevelWidget();
1963 x = wid->geometry().x(); 1963 x = wid->geometry().x();
1964 y = wid->geometry().y(); 1964 y = wid->geometry().y();
1965 w = wid->width(); 1965 w = wid->width();
1966 h = wid->height(); 1966 h = wid->height();
1967 list.clear(); 1967 list.clear();
1968 list << QString::number( x ); 1968 list << QString::number( x );
1969 list << QString::number( y ); 1969 list << QString::number( y );
1970 list << QString::number( w ); 1970 list << QString::number( w );
1971 list << QString::number( h ); 1971 list << QString::number( h );
1972 config->writeEntry("MainLayout",list ); 1972 config->writeEntry("MainLayout",list );
1973 1973
1974 wid = mEventEditor; 1974 wid = mEventEditor;
1975 x = wid->geometry().x(); 1975 x = wid->geometry().x();
1976 y = wid->geometry().y(); 1976 y = wid->geometry().y();
1977 w = wid->width(); 1977 w = wid->width();
1978 h = wid->height(); 1978 h = wid->height();
1979 list.clear(); 1979 list.clear();
1980 list << QString::number( x ); 1980 list << QString::number( x );
1981 list << QString::number( y ); 1981 list << QString::number( y );
1982 list << QString::number( w ); 1982 list << QString::number( w );
1983 list << QString::number( h ); 1983 list << QString::number( h );
1984 config->writeEntry("EditEventLayout",list ); 1984 config->writeEntry("EditEventLayout",list );
1985 1985
1986 wid = mTodoEditor; 1986 wid = mTodoEditor;
1987 x = wid->geometry().x(); 1987 x = wid->geometry().x();
1988 y = wid->geometry().y(); 1988 y = wid->geometry().y();
1989 w = wid->width(); 1989 w = wid->width();
1990 h = wid->height(); 1990 h = wid->height();
1991 list.clear(); 1991 list.clear();
1992 list << QString::number( x ); 1992 list << QString::number( x );
1993 list << QString::number( y ); 1993 list << QString::number( y );
1994 list << QString::number( w ); 1994 list << QString::number( w );
1995 list << QString::number( h ); 1995 list << QString::number( h );
1996 config->writeEntry("EditTodoLayout",list ); 1996 config->writeEntry("EditTodoLayout",list );
1997 wid = getEventViewerDialog(); 1997 wid = getEventViewerDialog();
1998 x = wid->geometry().x(); 1998 x = wid->geometry().x();
1999 y = wid->geometry().y(); 1999 y = wid->geometry().y();
2000 w = wid->width(); 2000 w = wid->width();
2001 h = wid->height(); 2001 h = wid->height();
2002 list.clear(); 2002 list.clear();
2003 list << QString::number( x ); 2003 list << QString::number( x );
2004 list << QString::number( y ); 2004 list << QString::number( y );
2005 list << QString::number( w ); 2005 list << QString::number( w );
2006 list << QString::number( h ); 2006 list << QString::number( h );
2007 config->writeEntry("ViewerLayout",list ); 2007 config->writeEntry("ViewerLayout",list );
2008 wid = mDialogManager->getSearchDialog(); 2008 wid = mDialogManager->getSearchDialog();
2009 if ( wid ) { 2009 if ( wid ) {
2010 x = wid->geometry().x(); 2010 x = wid->geometry().x();
2011 y = wid->geometry().y(); 2011 y = wid->geometry().y();
2012 w = wid->width(); 2012 w = wid->width();
2013 h = wid->height(); 2013 h = wid->height();
2014 list.clear(); 2014 list.clear();
2015 list << QString::number( x ); 2015 list << QString::number( x );
2016 list << QString::number( y ); 2016 list << QString::number( y );
2017 list << QString::number( w ); 2017 list << QString::number( w );
2018 list << QString::number( h ); 2018 list << QString::number( h );
2019 config->writeEntry("SearchLayout",list ); 2019 config->writeEntry("SearchLayout",list );
2020 } 2020 }
2021#endif 2021#endif
2022 2022
2023 2023
2024 config->sync(); 2024 config->sync();
2025} 2025}
2026 2026
2027void CalendarView::readFilterSettings(KConfig *config) 2027void CalendarView::readFilterSettings(KConfig *config)
2028{ 2028{
2029 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2029 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2030 2030
2031 mFilters.clear(); 2031 mFilters.clear();
2032 2032
2033 config->setGroup("General"); 2033 config->setGroup("General");
2034 QStringList filterList = config->readListEntry("CalendarFilters"); 2034 QStringList filterList = config->readListEntry("CalendarFilters");
2035 2035
2036 QStringList::ConstIterator it = filterList.begin(); 2036 QStringList::ConstIterator it = filterList.begin();
2037 QStringList::ConstIterator end = filterList.end(); 2037 QStringList::ConstIterator end = filterList.end();
2038 while(it != end) { 2038 while(it != end) {
2039 // kdDebug() << " filter: " << (*it) << endl; 2039 // kdDebug() << " filter: " << (*it) << endl;
2040 2040
2041 CalFilter *filter; 2041 CalFilter *filter;
2042 filter = new CalFilter(*it); 2042 filter = new CalFilter(*it);
2043 config->setGroup("Filter_" + (*it)); 2043 config->setGroup("Filter_" + (*it));
2044 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2044 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2045 filter->setCriteria(config->readNumEntry("Criteria",0)); 2045 filter->setCriteria(config->readNumEntry("Criteria",0));
2046 filter->setCategoryList(config->readListEntry("CategoryList")); 2046 filter->setCategoryList(config->readListEntry("CategoryList"));
2047 mFilters.append(filter); 2047 mFilters.append(filter);
2048 2048
2049 ++it; 2049 ++it;
2050 } 2050 }
2051 2051
2052 if (mFilters.count() == 0) { 2052 if (mFilters.count() == 0) {
2053 CalFilter *filter = new CalFilter(i18n("Default")); 2053 CalFilter *filter = new CalFilter(i18n("Default"));
2054 mFilters.append(filter); 2054 mFilters.append(filter);
2055 } 2055 }
2056 mFilterView->updateFilters(); 2056 mFilterView->updateFilters();
2057 config->setGroup("FilterView"); 2057 config->setGroup("FilterView");
2058 2058
2059 mFilterView->blockSignals(true); 2059 mFilterView->blockSignals(true);
2060 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2060 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2061 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2061 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2062 mFilterView->blockSignals(false); 2062 mFilterView->blockSignals(false);
2063 // We do it manually to avoid it being done twice by the above calls 2063 // We do it manually to avoid it being done twice by the above calls
2064 updateFilter(); 2064 updateFilter();
2065} 2065}
2066 2066
2067void CalendarView::writeFilterSettings(KConfig *config) 2067void CalendarView::writeFilterSettings(KConfig *config)
2068{ 2068{
2069 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2069 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2070 2070
2071 QStringList filterList; 2071 QStringList filterList;
2072 2072
2073 CalFilter *filter = mFilters.first(); 2073 CalFilter *filter = mFilters.first();
2074 while(filter) { 2074 while(filter) {
2075 // kdDebug() << " fn: " << filter->name() << endl; 2075 // kdDebug() << " fn: " << filter->name() << endl;
2076 filterList << filter->name(); 2076 filterList << filter->name();
2077 config->setGroup("Filter_" + filter->name()); 2077 config->setGroup("Filter_" + filter->name());
2078 config->writeEntry("Criteria",filter->criteria()); 2078 config->writeEntry("Criteria",filter->criteria());
2079 config->writeEntry("CategoryList",filter->categoryList()); 2079 config->writeEntry("CategoryList",filter->categoryList());
2080 filter = mFilters.next(); 2080 filter = mFilters.next();
2081 } 2081 }
2082 config->setGroup("General"); 2082 config->setGroup("General");
2083 config->writeEntry("CalendarFilters",filterList); 2083 config->writeEntry("CalendarFilters",filterList);
2084 2084
2085 config->setGroup("FilterView"); 2085 config->setGroup("FilterView");
2086 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2086 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2087 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2087 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2088} 2088}
2089 2089
2090 2090
2091void CalendarView::goToday() 2091void CalendarView::goToday()
2092{ 2092{
2093 if ( mViewManager->currentView()->isMonthView() ) 2093 if ( mViewManager->currentView()->isMonthView() )
2094 mNavigator->selectTodayMonth(); 2094 mNavigator->selectTodayMonth();
2095 else 2095 else
2096 mNavigator->selectToday(); 2096 mNavigator->selectToday();
2097} 2097}
2098 2098
2099void CalendarView::goNext() 2099void CalendarView::goNext()
2100{ 2100{
2101 mNavigator->selectNext(); 2101 mNavigator->selectNext();
2102} 2102}
2103 2103
2104void CalendarView::goPrevious() 2104void CalendarView::goPrevious()
2105{ 2105{
2106 mNavigator->selectPrevious(); 2106 mNavigator->selectPrevious();
2107} 2107}
2108void CalendarView::goNextMonth() 2108void CalendarView::goNextMonth()
2109{ 2109{
2110 mNavigator->selectNextMonth(); 2110 mNavigator->selectNextMonth();
2111} 2111}
2112 2112
2113void CalendarView::goPreviousMonth() 2113void CalendarView::goPreviousMonth()
2114{ 2114{
2115 mNavigator->selectPreviousMonth(); 2115 mNavigator->selectPreviousMonth();
2116} 2116}
2117void CalendarView::writeLocale() 2117void CalendarView::writeLocale()
2118{ 2118{
2119 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2119 //KPimGlobalPrefs::instance()->setGlobalConfig();
2120#if 0 2120#if 0
2121 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2121 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2122 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2122 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2123 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2123 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2124 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2124 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2125 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2125 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2126 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2126 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2127 dummy = KOPrefs::instance()->mUserDateFormatShort; 2127 dummy = KOPrefs::instance()->mUserDateFormatShort;
2128 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2128 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2129 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2129 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2130 KOPrefs::instance()->mDaylightsavingStart, 2130 KOPrefs::instance()->mDaylightsavingStart,
2131 KOPrefs::instance()->mDaylightsavingEnd ); 2131 KOPrefs::instance()->mDaylightsavingEnd );
2132 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2132 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2133#endif 2133#endif
2134} 2134}
2135void CalendarView::updateConfig() 2135void CalendarView::updateConfig()
2136{ 2136{
2137 writeLocale(); 2137 writeLocale();
2138 if ( KOPrefs::instance()->mUseAppColors ) 2138 if ( KOPrefs::instance()->mUseAppColors )
2139 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2139 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2140 emit configChanged(); 2140 emit configChanged();
2141 mTodoList->updateConfig(); 2141 mTodoList->updateConfig();
2142 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2142 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2143 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2143 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2144 // To make the "fill window" configurations work 2144 // To make the "fill window" configurations work
2145 //mViewManager->raiseCurrentView(); 2145 //mViewManager->raiseCurrentView();
2146} 2146}
2147 2147
2148 2148
2149void CalendarView::eventChanged(Event *event) 2149void CalendarView::eventChanged(Event *event)
2150{ 2150{
2151 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2151 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2152 //updateUnmanagedViews(); 2152 //updateUnmanagedViews();
2153} 2153}
2154 2154
2155void CalendarView::eventAdded(Event *event) 2155void CalendarView::eventAdded(Event *event)
2156{ 2156{
2157 changeEventDisplay(event,KOGlobals::EVENTADDED); 2157 changeEventDisplay(event,KOGlobals::EVENTADDED);
2158} 2158}
2159 2159
2160void CalendarView::eventToBeDeleted(Event *) 2160void CalendarView::eventToBeDeleted(Event *)
2161{ 2161{
2162 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2162 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2163} 2163}
2164 2164
2165void CalendarView::eventDeleted() 2165void CalendarView::eventDeleted()
2166{ 2166{
2167 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2167 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2168} 2168}
2169void CalendarView::changeTodoDisplay(Todo *which, int action) 2169void CalendarView::changeTodoDisplay(Todo *which, int action)
2170{ 2170{
2171 changeIncidenceDisplay((Incidence *)which, action); 2171 changeIncidenceDisplay((Incidence *)which, action);
2172 mDateNavigator->updateView(); //LR 2172 mDateNavigator->updateView(); //LR
2173 //mDialogManager->updateSearchDialog(); 2173 //mDialogManager->updateSearchDialog();
2174 2174
2175 if (which) { 2175 if (which) {
2176 mViewManager->updateWNview(); 2176 mViewManager->updateWNview();
2177 //mTodoList->updateView(); 2177 //mTodoList->updateView();
2178 } 2178 }
2179 2179
2180} 2180}
2181 2181
2182void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2182void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2183{ 2183{
2184 updateUnmanagedViews(); 2184 updateUnmanagedViews();
2185 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2185 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2186 if ( action == KOGlobals::EVENTDELETED ) { //delete 2186 if ( action == KOGlobals::EVENTDELETED ) { //delete
2187 mCalendar->checkAlarmForIncidence( 0, true ); 2187 mCalendar->checkAlarmForIncidence( 0, true );
2188 if ( mEventViewerDialog ) 2188 if ( mEventViewerDialog )
2189 mEventViewerDialog->hide(); 2189 mEventViewerDialog->hide();
2190 } 2190 }
2191 else 2191 else
2192 mCalendar->checkAlarmForIncidence( which , false ); 2192 mCalendar->checkAlarmForIncidence( which , false );
2193} 2193}
2194 2194
2195// most of the changeEventDisplays() right now just call the view's 2195// most of the changeEventDisplays() right now just call the view's
2196// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2196// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2197void CalendarView::changeEventDisplay(Event *which, int action) 2197void CalendarView::changeEventDisplay(Event *which, int action)
2198{ 2198{
2199 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2199 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2200 changeIncidenceDisplay((Incidence *)which, action); 2200 changeIncidenceDisplay((Incidence *)which, action);
2201 mDateNavigator->updateView(); 2201 mDateNavigator->updateView();
2202 //mDialogManager->updateSearchDialog(); 2202 //mDialogManager->updateSearchDialog();
2203 2203
2204 if (which) { 2204 if (which) {
2205 // If there is an event view visible update the display 2205 // If there is an event view visible update the display
2206 mViewManager->currentView()->changeEventDisplay(which,action); 2206 mViewManager->currentView()->changeEventDisplay(which,action);
2207 // TODO: check, if update needed 2207 // TODO: check, if update needed
2208 // if (which->getTodoStatus()) { 2208 // if (which->getTodoStatus()) {
2209 mTodoList->updateView(); 2209 mTodoList->updateView();
2210 // } 2210 // }
2211 } else { 2211 } else {
2212 mViewManager->currentView()->updateView(); 2212 mViewManager->currentView()->updateView();
2213 } 2213 }
2214} 2214}
2215 2215
2216 2216
2217void CalendarView::updateTodoViews() 2217void CalendarView::updateTodoViews()
2218{ 2218{
2219 mTodoList->updateView(); 2219 mTodoList->updateView();
2220 mViewManager->currentView()->updateView(); 2220 mViewManager->currentView()->updateView();
2221 2221
2222} 2222}
2223 2223
2224 2224
2225void CalendarView::updateView(const QDate &start, const QDate &end) 2225void CalendarView::updateView(const QDate &start, const QDate &end)
2226{ 2226{
2227 mTodoList->updateView(); 2227 mTodoList->updateView();
2228 mViewManager->updateView(start, end); 2228 mViewManager->updateView(start, end);
2229 //mDateNavigator->updateView(); 2229 //mDateNavigator->updateView();
2230} 2230}
2231 2231
2232void CalendarView::updateView() 2232void CalendarView::updateView()
2233{ 2233{
2234 DateList tmpList = mNavigator->selectedDates(); 2234 DateList tmpList = mNavigator->selectedDates();
2235 2235
2236 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2236 if ( KOPrefs::instance()->mHideNonStartedTodos )
2237 mTodoList->updateView(); 2237 mTodoList->updateView();
2238 // We assume that the navigator only selects consecutive days. 2238 // We assume that the navigator only selects consecutive days.
2239 updateView( tmpList.first(), tmpList.last() ); 2239 updateView( tmpList.first(), tmpList.last() );
2240} 2240}
2241 2241
2242void CalendarView::updateUnmanagedViews() 2242void CalendarView::updateUnmanagedViews()
2243{ 2243{
2244 mDateNavigator->updateDayMatrix(); 2244 mDateNavigator->updateDayMatrix();
2245} 2245}
2246 2246
2247int CalendarView::msgItemDelete(const QString name) 2247int CalendarView::msgItemDelete(const QString name)
2248{ 2248{
2249 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2249 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2250 i18n("This item will be\npermanently deleted."), 2250 i18n("This item will be\npermanently deleted."),
2251 i18n("KO/Pi Confirmation"),i18n("Delete")); 2251 i18n("KO/Pi Confirmation"),i18n("Delete"));
2252} 2252}
2253 2253
2254 2254
2255void CalendarView::edit_cut() 2255void CalendarView::edit_cut()
2256{ 2256{
2257 Event *anEvent=0; 2257 Event *anEvent=0;
2258 2258
2259 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2259 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2260 2260
2261 if (mViewManager->currentView()->isEventView()) { 2261 if (mViewManager->currentView()->isEventView()) {
2262 if ( incidence && incidence->type() == "Event" ) { 2262 if ( incidence && incidence->type() == "Event" ) {
2263 anEvent = static_cast<Event *>(incidence); 2263 anEvent = static_cast<Event *>(incidence);
2264 } 2264 }
2265 } 2265 }
2266 2266
2267 if (!anEvent) { 2267 if (!anEvent) {
2268 KNotifyClient::beep(); 2268 KNotifyClient::beep();
2269 return; 2269 return;
2270 } 2270 }
2271 DndFactory factory( mCalendar ); 2271 DndFactory factory( mCalendar );
2272 factory.cutIncidence(anEvent); 2272 factory.cutIncidence(anEvent);
2273 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2273 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2274} 2274}
2275 2275
2276void CalendarView::edit_copy() 2276void CalendarView::edit_copy()
2277{ 2277{
2278 Event *anEvent=0; 2278 Event *anEvent=0;
2279 2279
2280 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2280 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2281 2281
2282 if (mViewManager->currentView()->isEventView()) { 2282 if (mViewManager->currentView()->isEventView()) {
2283 if ( incidence && incidence->type() == "Event" ) { 2283 if ( incidence && incidence->type() == "Event" ) {
2284 anEvent = static_cast<Event *>(incidence); 2284 anEvent = static_cast<Event *>(incidence);
2285 } 2285 }
2286 } 2286 }
2287 2287
2288 if (!anEvent) { 2288 if (!anEvent) {
2289 KNotifyClient::beep(); 2289 KNotifyClient::beep();
2290 return; 2290 return;
2291 } 2291 }
2292 DndFactory factory( mCalendar ); 2292 DndFactory factory( mCalendar );
2293 factory.copyIncidence(anEvent); 2293 factory.copyIncidence(anEvent);
2294} 2294}
2295 2295
2296void CalendarView::edit_paste() 2296void CalendarView::edit_paste()
2297{ 2297{
2298 QDate date = mNavigator->selectedDates().first(); 2298 QDate date = mNavigator->selectedDates().first();
2299 2299
2300 DndFactory factory( mCalendar ); 2300 DndFactory factory( mCalendar );
2301 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2301 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2302 2302
2303 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2303 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2304} 2304}
2305 2305
2306void CalendarView::edit_options() 2306void CalendarView::edit_options()
2307{ 2307{
2308 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2308 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2309 emit save(); 2309 emit save();
2310 emit saveStopTimer(); 2310 emit saveStopTimer();
2311 mDialogManager->showOptionsDialog(); 2311 mDialogManager->showOptionsDialog();
2312 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2312 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2313 emit saveStopTimer(); 2313 emit saveStopTimer();
2314 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2314 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2315 i18n("Timezone settings"),i18n("Reload"))) { 2315 i18n("Timezone settings"),i18n("Reload"))) {
2316 qDebug("KO: TZ reload cancelled "); 2316 qDebug("KO: TZ reload cancelled ");
2317 return; 2317 return;
2318 } 2318 }
2319 qDebug("KO: Timezone change "); 2319 qDebug("KO: Timezone change ");
2320 openCalendar( MainWindow::defaultFileName() ); 2320 openCalendar( MainWindow::defaultFileName() );
2321 setModified(true); 2321 setModified(true);
2322 } 2322 }
2323 else 2323 else
2324 qDebug("KO: No tz change "); 2324 qDebug("KO: No tz change ");
2325 2325
2326} 2326}
2327 2327
2328 2328
2329void CalendarView::slotSelectPickerDate( QDate d) 2329void CalendarView::slotSelectPickerDate( QDate d)
2330{ 2330{
2331 mDateFrame->hide(); 2331 mDateFrame->hide();
2332 if ( mDatePickerMode == 1 ) { 2332 if ( mDatePickerMode == 1 ) {
2333 mNavigator->slotDaySelect( d ); 2333 mNavigator->slotDaySelect( d );
2334 } else if ( mDatePickerMode == 2 ) { 2334 } else if ( mDatePickerMode == 2 ) {
2335 if ( mMoveIncidence->type() == "Todo" ) { 2335 if ( mMoveIncidence->type() == "Todo" ) {
2336 Todo * to = (Todo *) mMoveIncidence; 2336 Todo * to = (Todo *) mMoveIncidence;
2337 QTime tim; 2337 QTime tim;
2338 int len = 0; 2338 int len = 0;
2339 if ( to->hasStartDate() && to->hasDueDate() ) 2339 if ( to->hasStartDate() && to->hasDueDate() )
2340 len = to->dtStart().secsTo( to->dtDue()); 2340 len = to->dtStart().secsTo( to->dtDue());
2341 if ( to->hasDueDate() ) 2341 if ( to->hasDueDate() )
2342 tim = to->dtDue().time(); 2342 tim = to->dtDue().time();
2343 else { 2343 else {
2344 tim = QTime ( 0,0,0 ); 2344 tim = QTime ( 0,0,0 );
2345 to->setFloats( true ); 2345 to->setFloats( true );
2346 to->setHasDueDate( true ); 2346 to->setHasDueDate( true );
2347 } 2347 }
2348 QDateTime dt ( d,tim ); 2348 QDateTime dt ( d,tim );
2349 to->setDtDue( dt ); 2349 to->setDtDue( dt );
2350 2350
2351 if ( to->hasStartDate() ) { 2351 if ( to->hasStartDate() ) {
2352 if ( len>0 ) 2352 if ( len>0 )
2353 to->setDtStart(to->dtDue().addSecs( -len )); 2353 to->setDtStart(to->dtDue().addSecs( -len ));
2354 else 2354 else
2355 if (to->dtStart() > to->dtDue() ) 2355 if (to->dtStart() > to->dtDue() )
2356 to->setDtStart(to->dtDue().addDays( -3 )); 2356 to->setDtStart(to->dtDue().addDays( -3 ));
2357 } 2357 }
2358 2358
2359 todoChanged( to ); 2359 todoChanged( to );
2360 } else { 2360 } else {
2361 if ( mMoveIncidence->doesRecur() ) { 2361 if ( mMoveIncidence->doesRecur() ) {
2362#if 0 2362#if 0
2363 // PENDING implement this 2363 // PENDING implement this
2364 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2364 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2365 mCalendar()->addIncidence( newInc ); 2365 mCalendar()->addIncidence( newInc );
2366 if ( mMoveIncidence->type() == "Todo" ) 2366 if ( mMoveIncidence->type() == "Todo" )
2367 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2367 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2368 else 2368 else
2369 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2369 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2370 mMoveIncidence = newInc; 2370 mMoveIncidence = newInc;
2371 2371
2372#endif 2372#endif
2373 } 2373 }
2374 QTime tim = mMoveIncidence->dtStart().time(); 2374 QTime tim = mMoveIncidence->dtStart().time();
2375 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2375 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2376 QDateTime dt ( d,tim ); 2376 QDateTime dt ( d,tim );
2377 mMoveIncidence->setDtStart( dt ); 2377 mMoveIncidence->setDtStart( dt );
2378 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2378 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2379 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2379 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2380 } 2380 }
2381 2381
2382 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2382 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2383 } 2383 }
2384} 2384}
2385 2385
2386void CalendarView::removeCategories() 2386void CalendarView::removeCategories()
2387{ 2387{
2388 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2388 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2389 QStringList catList = KOPrefs::instance()->mCustomCategories; 2389 QStringList catList = KOPrefs::instance()->mCustomCategories;
2390 QStringList catIncList; 2390 QStringList catIncList;
2391 QStringList newCatList; 2391 QStringList newCatList;
2392 Incidence* inc = incList.first(); 2392 Incidence* inc = incList.first();
2393 int i; 2393 int i;
2394 int count = 0; 2394 int count = 0;
2395 while ( inc ) { 2395 while ( inc ) {
2396 newCatList.clear(); 2396 newCatList.clear();
2397 catIncList = inc->categories() ; 2397 catIncList = inc->categories() ;
2398 for( i = 0; i< catIncList.count(); ++i ) { 2398 for( i = 0; i< catIncList.count(); ++i ) {
2399 if ( catList.contains (catIncList[i])) 2399 if ( catList.contains (catIncList[i]))
2400 newCatList.append( catIncList[i] ); 2400 newCatList.append( catIncList[i] );
2401 } 2401 }
2402 newCatList.sort(); 2402 newCatList.sort();
2403 inc->setCategories( newCatList.join(",") ); 2403 inc->setCategories( newCatList.join(",") );
2404 inc = incList.next(); 2404 inc = incList.next();
2405 } 2405 }
2406} 2406}
2407 2407
2408int CalendarView::addCategories() 2408int CalendarView::addCategories()
2409{ 2409{
2410 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2410 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2411 QStringList catList = KOPrefs::instance()->mCustomCategories; 2411 QStringList catList = KOPrefs::instance()->mCustomCategories;
2412 QStringList catIncList; 2412 QStringList catIncList;
2413 Incidence* inc = incList.first(); 2413 Incidence* inc = incList.first();
2414 int i; 2414 int i;
2415 int count = 0; 2415 int count = 0;
2416 while ( inc ) { 2416 while ( inc ) {
2417 catIncList = inc->categories() ; 2417 catIncList = inc->categories() ;
2418 for( i = 0; i< catIncList.count(); ++i ) { 2418 for( i = 0; i< catIncList.count(); ++i ) {
2419 if ( !catList.contains (catIncList[i])) { 2419 if ( !catList.contains (catIncList[i])) {
2420 catList.append( catIncList[i] ); 2420 catList.append( catIncList[i] );
2421 //qDebug("add cat %s ", catIncList[i].latin1()); 2421 //qDebug("add cat %s ", catIncList[i].latin1());
2422 ++count; 2422 ++count;
2423 } 2423 }
2424 } 2424 }
2425 inc = incList.next(); 2425 inc = incList.next();
2426 } 2426 }
2427 catList.sort(); 2427 catList.sort();
2428 KOPrefs::instance()->mCustomCategories = catList; 2428 KOPrefs::instance()->mCustomCategories = catList;
2429 return count; 2429 return count;
2430} 2430}
2431 2431
2432void CalendarView::manageCategories() 2432void CalendarView::manageCategories()
2433{ 2433{
2434 KOCatPrefs* cp = new KOCatPrefs(); 2434 KOCatPrefs* cp = new KOCatPrefs();
2435 cp->show(); 2435 cp->show();
2436 int w =cp->sizeHint().width() ; 2436 int w =cp->sizeHint().width() ;
2437 int h = cp->sizeHint().height() ; 2437 int h = cp->sizeHint().height() ;
2438 int dw = QApplication::desktop()->width(); 2438 int dw = QApplication::desktop()->width();
2439 int dh = QApplication::desktop()->height(); 2439 int dh = QApplication::desktop()->height();
2440 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2440 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2441 if ( !cp->exec() ) { 2441 if ( !cp->exec() ) {
2442 delete cp; 2442 delete cp;
2443 return; 2443 return;
2444 } 2444 }
2445 int count = 0; 2445 int count = 0;
2446 if ( cp->addCat() ) { 2446 if ( cp->addCat() ) {
2447 count = addCategories(); 2447 count = addCategories();
2448 if ( count ) { 2448 if ( count ) {
2449 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2449 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2450 writeSettings(); 2450 writeSettings();
2451 } else 2451 } else
2452 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2452 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2453 } else { 2453 } else {
2454 removeCategories(); 2454 removeCategories();
2455 updateView(); 2455 updateView();
2456 } 2456 }
2457 delete cp; 2457 delete cp;
2458} 2458}
2459 2459
2460void CalendarView::beamIncidence(Incidence * Inc) 2460void CalendarView::beamIncidence(Incidence * Inc)
2461{ 2461{
2462 QPtrList<Incidence> delSel ; 2462 QPtrList<Incidence> delSel ;
2463 delSel.append(Inc); 2463 delSel.append(Inc);
2464 beamIncidenceList( delSel ); 2464 beamIncidenceList( delSel );
2465} 2465}
2466void CalendarView::beamCalendar() 2466void CalendarView::beamCalendar()
2467{ 2467{
2468 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2468 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2469 //qDebug("beamCalendar() "); 2469 //qDebug("beamCalendar() ");
2470 beamIncidenceList( delSel ); 2470 beamIncidenceList( delSel );
2471} 2471}
2472void CalendarView::beamFilteredCalendar() 2472void CalendarView::beamFilteredCalendar()
2473{ 2473{
2474 QPtrList<Incidence> delSel = mCalendar->incidences(); 2474 QPtrList<Incidence> delSel = mCalendar->incidences();
2475 //qDebug("beamFilteredCalendar() "); 2475 //qDebug("beamFilteredCalendar() ");
2476 beamIncidenceList( delSel ); 2476 beamIncidenceList( delSel );
2477} 2477}
2478void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2478void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2479{ 2479{
2480 if ( beamDialog->exec () == QDialog::Rejected ) 2480 if ( beamDialog->exec () == QDialog::Rejected )
2481 return; 2481 return;
2482#ifdef DESKTOP_VERSION 2482#ifdef DESKTOP_VERSION
2483 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2483 QString fn = locateLocal( "tmp", "kopibeamfile" );
2484#else 2484#else
2485 QString fn = "/tmp/kopibeamfile"; 2485 QString fn = "/tmp/kopibeamfile";
2486#endif 2486#endif
2487 QString mes; 2487 QString mes;
2488 bool createbup = true; 2488 bool createbup = true;
2489 if ( createbup ) { 2489 if ( createbup ) {
2490 QString description = "\n"; 2490 QString description = "\n";
2491 CalendarLocal* cal = new CalendarLocal(); 2491 CalendarLocal* cal = new CalendarLocal();
2492 if ( beamDialog->beamLocal() ) 2492 if ( beamDialog->beamLocal() )
2493 cal->setLocalTime(); 2493 cal->setLocalTime();
2494 else 2494 else
2495 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2495 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2496 Incidence *incidence = delSel.first(); 2496 Incidence *incidence = delSel.first();
2497 bool addText = false; 2497 bool addText = false;
2498 if ( delSel.count() < 10 ) 2498 if ( delSel.count() < 10 )
2499 addText = true; 2499 addText = true;
2500 else { 2500 else {
2501 description.sprintf(i18n(" %d items?"),delSel.count() ); 2501 description.sprintf(i18n(" %d items?"),delSel.count() );
2502 } 2502 }
2503 while ( incidence ) { 2503 while ( incidence ) {
2504 Incidence *in = incidence->clone(); 2504 Incidence *in = incidence->clone();
2505 if ( ! in->summary().isEmpty() ) { 2505 if ( ! in->summary().isEmpty() ) {
2506 in->setDescription(""); 2506 in->setDescription("");
2507 } else { 2507 } else {
2508 in->setSummary( in->description().left(20)); 2508 in->setSummary( in->description().left(20));
2509 in->setDescription(""); 2509 in->setDescription("");
2510 } 2510 }
2511 if ( addText ) 2511 if ( addText )
2512 description += in->summary() + "\n"; 2512 description += in->summary() + "\n";
2513 cal->addIncidence( in ); 2513 cal->addIncidence( in );
2514 incidence = delSel.next(); 2514 incidence = delSel.next();
2515 } 2515 }
2516 if ( beamDialog->beamVcal() ) { 2516 if ( beamDialog->beamVcal() ) {
2517 fn += ".vcs"; 2517 fn += ".vcs";
2518 FileStorage storage( cal, fn, new VCalFormat ); 2518 FileStorage storage( cal, fn, new VCalFormat );
2519 storage.save(); 2519 storage.save();
2520 } else { 2520 } else {
2521 fn += ".ics"; 2521 fn += ".ics";
2522 FileStorage storage( cal, fn, new ICalFormat( ) ); 2522 FileStorage storage( cal, fn, new ICalFormat( ) );
2523 storage.save(); 2523 storage.save();
2524 } 2524 }
2525 delete cal; 2525 delete cal;
2526 mes = i18n("KO/Pi: Ready for beaming"); 2526 mes = i18n("KO/Pi: Ready for beaming");
2527 topLevelWidget()->setCaption(mes); 2527 topLevelWidget()->setCaption(mes);
2528 KApplication::convert2latin1( fn ); 2528 KApplication::convert2latin1( fn );
2529#ifndef DESKTOP_VERSION 2529#ifndef DESKTOP_VERSION
2530 Ir *ir = new Ir( this ); 2530 Ir *ir = new Ir( this );
2531 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2531 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2532 ir->send( fn, description, "text/x-vCalendar" ); 2532 ir->send( fn, description, "text/x-vCalendar" );
2533#endif 2533#endif
2534 } 2534 }
2535} 2535}
2536void CalendarView::beamDone( Ir *ir ) 2536void CalendarView::beamDone( Ir *ir )
2537{ 2537{
2538#ifndef DESKTOP_VERSION 2538#ifndef DESKTOP_VERSION
2539 delete ir; 2539 delete ir;
2540#endif 2540#endif
2541 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2541 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2542 topLevelWidget()->raise(); 2542 topLevelWidget()->raise();
2543} 2543}
2544 2544
2545void CalendarView::moveIncidence(Incidence * inc ) 2545void CalendarView::moveIncidence(Incidence * inc )
2546{ 2546{
2547 if ( !inc ) return; 2547 if ( !inc ) return;
2548 showDatePickerPopup(); 2548 showDatePickerPopup();
2549 mDatePickerMode = 2; 2549 mDatePickerMode = 2;
2550 mMoveIncidence = inc ; 2550 mMoveIncidence = inc ;
2551 QDate da; 2551 QDate da;
2552 if ( mMoveIncidence->type() == "Todo" ) { 2552 if ( mMoveIncidence->type() == "Todo" ) {
2553 Todo * to = (Todo *) mMoveIncidence; 2553 Todo * to = (Todo *) mMoveIncidence;
2554 if ( to->hasDueDate() ) 2554 if ( to->hasDueDate() )
2555 da = to->dtDue().date(); 2555 da = to->dtDue().date();
2556 else 2556 else
2557 da = QDate::currentDate(); 2557 da = QDate::currentDate();
2558 } else { 2558 } else {
2559 da = mMoveIncidence->dtStart().date(); 2559 da = mMoveIncidence->dtStart().date();
2560 } 2560 }
2561 //PENDING set date for recurring incidence to date of recurrence 2561 //PENDING set date for recurring incidence to date of recurrence
2562 //mMoveIncidenceOldDate; 2562 //mMoveIncidenceOldDate;
2563 mDatePicker->setDate( da ); 2563 mDatePicker->setDate( da );
2564} 2564}
2565void CalendarView::showDatePickerPopup() 2565void CalendarView::showDatePickerPopup()
2566{ 2566{
2567 if ( mDateFrame->isVisible() ) 2567 if ( mDateFrame->isVisible() )
2568 mDateFrame->hide(); 2568 mDateFrame->hide();
2569 else { 2569 else {
2570 int offX = 0, offY = 0; 2570 int offX = 0, offY = 0;
2571#ifdef DESKTOP_VERSION 2571#ifdef DESKTOP_VERSION
2572 int w =mDatePicker->sizeHint().width() ; 2572 int w =mDatePicker->sizeHint().width() ;
2573 int h = mDatePicker->sizeHint().height() ; 2573 int h = mDatePicker->sizeHint().height() ;
2574 int dw = topLevelWidget()->width(); 2574 int dw = topLevelWidget()->width();
2575 int dh = topLevelWidget()->height(); 2575 int dh = topLevelWidget()->height();
2576 offX = topLevelWidget()->x(); 2576 offX = topLevelWidget()->x();
2577 offY = topLevelWidget()->y(); 2577 offY = topLevelWidget()->y();
2578#else 2578#else
2579 int w =mDatePicker->sizeHint().width() ; 2579 int w =mDatePicker->sizeHint().width() ;
2580 int h = mDatePicker->sizeHint().height() ; 2580 int h = mDatePicker->sizeHint().height() ;
2581 int dw = QApplication::desktop()->width(); 2581 int dw = QApplication::desktop()->width();
2582 int dh = QApplication::desktop()->height(); 2582 int dh = QApplication::desktop()->height();
2583#endif 2583#endif
2584 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2584 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2585 mDateFrame->show(); 2585 mDateFrame->show();
2586 } 2586 }
2587} 2587}
2588void CalendarView::showDatePicker( ) 2588void CalendarView::showDatePicker( )
2589{ 2589{
2590 showDatePickerPopup(); 2590 showDatePickerPopup();
2591 mDatePickerMode = 1; 2591 mDatePickerMode = 1;
2592 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2592 mDatePicker->setDate( mNavigator->selectedDates().first() );
2593} 2593}
2594 2594
2595void CalendarView::showEventEditor() 2595void CalendarView::showEventEditor()
2596{ 2596{
2597#ifdef DESKTOP_VERSION 2597#ifdef DESKTOP_VERSION
2598 int x,y,w,h; 2598 int x,y,w,h;
2599 x = mEventEditor->geometry().x(); 2599 x = mEventEditor->geometry().x();
2600 y = mEventEditor->geometry().y(); 2600 y = mEventEditor->geometry().y();
2601 w = mEventEditor->width(); 2601 w = mEventEditor->width();
2602 h = mEventEditor->height(); 2602 h = mEventEditor->height();
2603 mEventEditor->show(); 2603 mEventEditor->show();
2604 mEventEditor->setGeometry(x,y,w,h); 2604 mEventEditor->setGeometry(x,y,w,h);
2605#else 2605#else
2606 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2606 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2607 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2607 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2608 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2608 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2609 qApp->processEvents(); 2609 qApp->processEvents();
2610 delete mEventEditor; 2610 delete mEventEditor;
2611 mEventEditor = mDialogManager->getEventEditor(); 2611 mEventEditor = mDialogManager->getEventEditor();
2612 topLevelWidget()->setCaption( i18n("") ); 2612 topLevelWidget()->setCaption( i18n("") );
2613 } 2613 }
2614 mEventEditor->showMaximized(); 2614 mEventEditor->showMaximized();
2615#endif 2615#endif
2616} 2616}
2617void CalendarView::showTodoEditor() 2617void CalendarView::showTodoEditor()
2618{ 2618{
2619#ifdef DESKTOP_VERSION 2619#ifdef DESKTOP_VERSION
2620 int x,y,w,h; 2620 int x,y,w,h;
2621 x = mTodoEditor->geometry().x(); 2621 x = mTodoEditor->geometry().x();
2622 y = mTodoEditor->geometry().y(); 2622 y = mTodoEditor->geometry().y();
2623 w = mTodoEditor->width(); 2623 w = mTodoEditor->width();
2624 h = mTodoEditor->height(); 2624 h = mTodoEditor->height();
2625 mTodoEditor->show(); 2625 mTodoEditor->show();
2626 mTodoEditor->setGeometry(x,y,w,h); 2626 mTodoEditor->setGeometry(x,y,w,h);
2627#else 2627#else
2628 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2628 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2629 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2629 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2630 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2630 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2631 qApp->processEvents(); 2631 qApp->processEvents();
2632 delete mTodoEditor; 2632 delete mTodoEditor;
2633 mTodoEditor = mDialogManager->getTodoEditor(); 2633 mTodoEditor = mDialogManager->getTodoEditor();
2634 topLevelWidget()->setCaption( i18n("") ); 2634 topLevelWidget()->setCaption( i18n("") );
2635 } 2635 }
2636 mTodoEditor->showMaximized(); 2636 mTodoEditor->showMaximized();
2637#endif 2637#endif
2638} 2638}
2639 2639
2640void CalendarView::cloneIncidence() 2640void CalendarView::cloneIncidence()
2641{ 2641{
2642 Incidence *incidence = currentSelection(); 2642 Incidence *incidence = currentSelection();
2643 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2643 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2644 if ( incidence ) { 2644 if ( incidence ) {
2645 cloneIncidence(incidence); 2645 cloneIncidence(incidence);
2646 } 2646 }
2647} 2647}
2648void CalendarView::moveIncidence() 2648void CalendarView::moveIncidence()
2649{ 2649{
2650 Incidence *incidence = currentSelection(); 2650 Incidence *incidence = currentSelection();
2651 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2651 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2652 if ( incidence ) { 2652 if ( incidence ) {
2653 moveIncidence(incidence); 2653 moveIncidence(incidence);
2654 } 2654 }
2655} 2655}
2656void CalendarView::beamIncidence() 2656void CalendarView::beamIncidence()
2657{ 2657{
2658 Incidence *incidence = currentSelection(); 2658 Incidence *incidence = currentSelection();
2659 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2659 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2660 if ( incidence ) { 2660 if ( incidence ) {
2661 beamIncidence(incidence); 2661 beamIncidence(incidence);
2662 } 2662 }
2663} 2663}
2664void CalendarView::toggleCancelIncidence() 2664void CalendarView::toggleCancelIncidence()
2665{ 2665{
2666 Incidence *incidence = currentSelection(); 2666 Incidence *incidence = currentSelection();
2667 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2667 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2668 if ( incidence ) { 2668 if ( incidence ) {
2669 cancelIncidence(incidence); 2669 cancelIncidence(incidence);
2670 } 2670 }
2671} 2671}
2672 2672
2673 2673
2674void CalendarView::cancelIncidence(Incidence * inc ) 2674void CalendarView::cancelIncidence(Incidence * inc )
2675{ 2675{
2676 inc->setCancelled( ! inc->cancelled() ); 2676 inc->setCancelled( ! inc->cancelled() );
2677 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2677 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2678 updateView(); 2678 updateView();
2679} 2679}
2680void CalendarView::cloneIncidence(Incidence * orgInc ) 2680void CalendarView::cloneIncidence(Incidence * orgInc )
2681{ 2681{
2682 Incidence * newInc = orgInc->clone(); 2682 Incidence * newInc = orgInc->clone();
2683 newInc->recreate(); 2683 newInc->recreate();
2684 2684
2685 if ( newInc->type() == "Todo" ) { 2685 if ( newInc->type() == "Todo" ) {
2686 Todo* t = (Todo*) newInc; 2686 Todo* t = (Todo*) newInc;
2687 showTodoEditor(); 2687 showTodoEditor();
2688 mTodoEditor->editTodo( t ); 2688 mTodoEditor->editTodo( t );
2689 if ( mTodoEditor->exec() ) { 2689 if ( mTodoEditor->exec() ) {
2690 mCalendar->addTodo( t ); 2690 mCalendar->addTodo( t );
2691 updateView(); 2691 updateView();
2692 } else { 2692 } else {
2693 delete t; 2693 delete t;
2694 } 2694 }
2695 } 2695 }
2696 else { 2696 else {
2697 Event* e = (Event*) newInc; 2697 Event* e = (Event*) newInc;
2698 showEventEditor(); 2698 showEventEditor();
2699 mEventEditor->editEvent( e ); 2699 mEventEditor->editEvent( e );
2700 if ( mEventEditor->exec() ) { 2700 if ( mEventEditor->exec() ) {
2701 mCalendar->addEvent( e ); 2701 mCalendar->addEvent( e );
2702 updateView(); 2702 updateView();
2703 } else { 2703 } else {
2704 delete e; 2704 delete e;
2705 } 2705 }
2706 } 2706 }
2707 setActiveWindow(); 2707 setActiveWindow();
2708} 2708}
2709 2709
2710void CalendarView::newEvent() 2710void CalendarView::newEvent()
2711{ 2711{
2712 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2712 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2713 KOAgendaView *aView = mViewManager->agendaView(); 2713 KOAgendaView *aView = mViewManager->agendaView();
2714 if (aView) { 2714 if (aView) {
2715 if (aView->selectionStart().isValid()) { 2715 if (aView->selectionStart().isValid()) {
2716 if (aView->selectedIsAllDay()) { 2716 if (aView->selectedIsAllDay()) {
2717 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2717 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2718 } else { 2718 } else {
2719 newEvent(aView->selectionStart(),aView->selectionEnd()); 2719 newEvent(aView->selectionStart(),aView->selectionEnd());
2720 } 2720 }
2721 return; 2721 return;
2722 } 2722 }
2723 } 2723 }
2724 2724
2725 QDate date = mNavigator->selectedDates().first(); 2725 QDate date = mNavigator->selectedDates().first();
2726 QDateTime current = QDateTime::currentDateTime(); 2726 QDateTime current = QDateTime::currentDateTime();
2727 if ( date <= current.date() ) { 2727 if ( date <= current.date() ) {
2728 int hour = current.time().hour() +1; 2728 int hour = current.time().hour() +1;
2729 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2729 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2730 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2730 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2731 } else 2731 } else
2732 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2732 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2733 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2733 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2734 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2734 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2735} 2735}
2736 2736
2737void CalendarView::newEvent(QDateTime fh) 2737void CalendarView::newEvent(QDateTime fh)
2738{ 2738{
2739 newEvent(fh, 2739 newEvent(fh,
2740 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2740 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2741} 2741}
2742 2742
2743void CalendarView::newEvent(QDate dt) 2743void CalendarView::newEvent(QDate dt)
2744{ 2744{
2745 newEvent(QDateTime(dt, QTime(0,0,0)), 2745 newEvent(QDateTime(dt, QTime(0,0,0)),
2746 QDateTime(dt, QTime(0,0,0)), true); 2746 QDateTime(dt, QTime(0,0,0)), true);
2747} 2747}
2748void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2748void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2749{ 2749{
2750 newEvent(fromHint, toHint, false); 2750 newEvent(fromHint, toHint, false);
2751} 2751}
2752void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2752void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2753{ 2753{
2754 2754
2755 showEventEditor(); 2755 showEventEditor();
2756 mEventEditor->newEvent(fromHint,toHint,allDay); 2756 mEventEditor->newEvent(fromHint,toHint,allDay);
2757 if ( mFilterView->filtersEnabled() ) { 2757 if ( mFilterView->filtersEnabled() ) {
2758 CalFilter *filter = mFilterView->selectedFilter(); 2758 CalFilter *filter = mFilterView->selectedFilter();
2759 if (filter && filter->showCategories()) { 2759 if (filter && filter->showCategories()) {
2760 mEventEditor->setCategories(filter->categoryList().join(",") ); 2760 mEventEditor->setCategories(filter->categoryList().join(",") );
2761 } 2761 }
2762 if ( filter ) 2762 if ( filter )
2763 mEventEditor->setSecrecy( filter->getSecrecy() ); 2763 mEventEditor->setSecrecy( filter->getSecrecy() );
2764 } 2764 }
2765 mEventEditor->exec(); 2765 mEventEditor->exec();
2766 setActiveWindow(); 2766 setActiveWindow();
2767} 2767}
2768void CalendarView::todoAdded(Todo * t) 2768void CalendarView::todoAdded(Todo * t)
2769{ 2769{
2770 2770
2771 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2771 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2772 updateTodoViews(); 2772 updateTodoViews();
2773} 2773}
2774void CalendarView::todoChanged(Todo * t) 2774void CalendarView::todoChanged(Todo * t)
2775{ 2775{
2776 emit todoModified( t, 4 ); 2776 emit todoModified( t, 4 );
2777 // updateTodoViews(); 2777 // updateTodoViews();
2778} 2778}
2779void CalendarView::todoToBeDeleted(Todo *) 2779void CalendarView::todoToBeDeleted(Todo *)
2780{ 2780{
2781 //qDebug("todoToBeDeleted(Todo *) "); 2781 //qDebug("todoToBeDeleted(Todo *) ");
2782 updateTodoViews(); 2782 updateTodoViews();
2783} 2783}
2784void CalendarView::todoDeleted() 2784void CalendarView::todoDeleted()
2785{ 2785{
2786 //qDebug(" todoDeleted()"); 2786 //qDebug(" todoDeleted()");
2787 updateTodoViews(); 2787 updateTodoViews();
2788} 2788}
2789 2789
2790 2790
2791void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2791void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2792{ 2792{
2793 showTodoEditor(); 2793 showTodoEditor();
2794 mTodoEditor->newTodo(dt,0,allday); 2794 mTodoEditor->newTodo(dt,0,allday);
2795 if ( mFilterView->filtersEnabled() ) { 2795 if ( mFilterView->filtersEnabled() ) {
2796 CalFilter *filter = mFilterView->selectedFilter(); 2796 CalFilter *filter = mFilterView->selectedFilter();
2797 if (filter && filter->showCategories()) { 2797 if (filter && filter->showCategories()) {
2798 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2798 mTodoEditor->setCategories(filter->categoryList().join(",") );
2799 } 2799 }
2800 if ( filter ) 2800 if ( filter )
2801 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2801 mTodoEditor->setSecrecy( filter->getSecrecy() );
2802 } 2802 }
2803 mTodoEditor->exec(); 2803 mTodoEditor->exec();
2804 setActiveWindow(); 2804 setActiveWindow();
2805} 2805}
2806 2806
2807void CalendarView::newTodo() 2807void CalendarView::newTodo()
2808{ 2808{
2809 newTodoDateTime( QDateTime(),true ); 2809 newTodoDateTime( QDateTime(),true );
2810} 2810}
2811 2811
2812void CalendarView::newSubTodo() 2812void CalendarView::newSubTodo()
2813{ 2813{
2814 Todo *todo = selectedTodo(); 2814 Todo *todo = selectedTodo();
2815 if ( todo ) newSubTodo( todo ); 2815 if ( todo ) newSubTodo( todo );
2816} 2816}
2817 2817
2818void CalendarView::newSubTodo(Todo *parentEvent) 2818void CalendarView::newSubTodo(Todo *parentEvent)
2819{ 2819{
2820 2820
2821 showTodoEditor(); 2821 showTodoEditor();
2822 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2822 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2823 mTodoEditor->exec(); 2823 mTodoEditor->exec();
2824 setActiveWindow(); 2824 setActiveWindow();
2825} 2825}
2826 2826
2827void CalendarView::newFloatingEvent() 2827void CalendarView::newFloatingEvent()
2828{ 2828{
2829 DateList tmpList = mNavigator->selectedDates(); 2829 DateList tmpList = mNavigator->selectedDates();
2830 QDate date = tmpList.first(); 2830 QDate date = tmpList.first();
2831 2831
2832 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2832 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2833 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2833 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2834} 2834}
2835 2835
2836 2836
2837void CalendarView::editEvent( Event *event ) 2837void CalendarView::editEvent( Event *event )
2838{ 2838{
2839 2839
2840 if ( !event ) return; 2840 if ( !event ) return;
2841 if ( event->isReadOnly() ) { 2841 if ( event->isReadOnly() ) {
2842 showEvent( event ); 2842 showEvent( event );
2843 return; 2843 return;
2844 } 2844 }
2845 showEventEditor(); 2845 showEventEditor();
2846 mEventEditor->editEvent( event , mFlagEditDescription); 2846 mEventEditor->editEvent( event , mFlagEditDescription);
2847 mEventEditor->exec(); 2847 mEventEditor->exec();
2848 setActiveWindow(); 2848 setActiveWindow();
2849 2849
2850} 2850}
2851void CalendarView::editJournal( Journal *jour ) 2851void CalendarView::editJournal( Journal *jour )
2852{ 2852{
2853 if ( !jour ) return; 2853 if ( !jour ) return;
2854 mDialogManager->hideSearchDialog(); 2854 mDialogManager->hideSearchDialog();
2855 mViewManager->showJournalView(); 2855 mViewManager->showJournalView();
2856 mNavigator->slotDaySelect( jour->dtStart().date() ); 2856 mNavigator->slotDaySelect( jour->dtStart().date() );
2857} 2857}
2858void CalendarView::editTodo( Todo *todo ) 2858void CalendarView::editTodo( Todo *todo )
2859{ 2859{
2860 if ( !todo ) return; 2860 if ( !todo ) return;
2861 2861
2862 if ( todo->isReadOnly() ) { 2862 if ( todo->isReadOnly() ) {
2863 showTodo( todo ); 2863 showTodo( todo );
2864 return; 2864 return;
2865 } 2865 }
2866 showTodoEditor(); 2866 showTodoEditor();
2867 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2867 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2868 mTodoEditor->exec(); 2868 mTodoEditor->exec();
2869 setActiveWindow(); 2869 setActiveWindow();
2870 2870
2871} 2871}
2872 2872
2873KOEventViewerDialog* CalendarView::getEventViewerDialog() 2873KOEventViewerDialog* CalendarView::getEventViewerDialog()
2874{ 2874{
2875 if ( !mEventViewerDialog ) { 2875 if ( !mEventViewerDialog ) {
2876 mEventViewerDialog = new KOEventViewerDialog(0); 2876 mEventViewerDialog = new KOEventViewerDialog(0);
2877 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2877 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2878 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2878 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2879 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2879 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2880 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2880 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2881 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2881 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2882 viewManager(), SLOT( showAgendaView( bool ) ) ); 2882 viewManager(), SLOT( showAgendaView( bool ) ) );
2883 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 2883 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2884 this, SLOT( slotViewerClosed() ) ); 2884 this, SLOT( slotViewerClosed() ) );
2885 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2885 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2886 this, SLOT( todoChanged(Todo *) ) ); 2886 this, SLOT( todoChanged(Todo *) ) );
2887 mEventViewerDialog->resize( 640, 480 ); 2887 mEventViewerDialog->resize( 640, 480 );
2888 2888
2889 } 2889 }
2890 return mEventViewerDialog; 2890 return mEventViewerDialog;
2891} 2891}
2892void CalendarView::showEvent(Event *event) 2892void CalendarView::showEvent(Event *event)
2893{ 2893{
2894 getEventViewerDialog()->setEvent(event); 2894 getEventViewerDialog()->setEvent(event);
2895 getEventViewerDialog()->showMe(); 2895 getEventViewerDialog()->showMe();
2896} 2896}
2897 2897
2898void CalendarView::showTodo(Todo *event) 2898void CalendarView::showTodo(Todo *event)
2899{ 2899{
2900 getEventViewerDialog()->setTodo(event); 2900 getEventViewerDialog()->setTodo(event);
2901 getEventViewerDialog()->showMe(); 2901 getEventViewerDialog()->showMe();
2902} 2902}
2903void CalendarView::showJournal( Journal *jour ) 2903void CalendarView::showJournal( Journal *jour )
2904{ 2904{
2905 getEventViewerDialog()->setJournal(jour); 2905 getEventViewerDialog()->setJournal(jour);
2906 getEventViewerDialog()->showMe(); 2906 getEventViewerDialog()->showMe();
2907 2907
2908} 2908}
2909// void CalendarView::todoModified (Todo *event, int changed) 2909// void CalendarView::todoModified (Todo *event, int changed)
2910// { 2910// {
2911// // if (mDialogList.find (event) != mDialogList.end ()) { 2911// // if (mDialogList.find (event) != mDialogList.end ()) {
2912// // kdDebug() << "Todo modified and open" << endl; 2912// // kdDebug() << "Todo modified and open" << endl;
2913// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2913// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2914// // temp->modified (changed); 2914// // temp->modified (changed);
2915 2915
2916// // } 2916// // }
2917 2917
2918// mViewManager->updateView(); 2918// mViewManager->updateView();
2919// } 2919// }
2920 2920
2921void CalendarView::appointment_show() 2921void CalendarView::appointment_show()
2922{ 2922{
2923 Event *anEvent = 0; 2923 Event *anEvent = 0;
2924 2924
2925 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2925 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2926 2926
2927 if (mViewManager->currentView()->isEventView()) { 2927 if (mViewManager->currentView()->isEventView()) {
2928 if ( incidence && incidence->type() == "Event" ) { 2928 if ( incidence && incidence->type() == "Event" ) {
2929 anEvent = static_cast<Event *>(incidence); 2929 anEvent = static_cast<Event *>(incidence);
2930 } 2930 }
2931 } 2931 }
2932 2932
2933 if (!anEvent) { 2933 if (!anEvent) {
2934 KNotifyClient::beep(); 2934 KNotifyClient::beep();
2935 return; 2935 return;
2936 } 2936 }
2937 2937
2938 showEvent(anEvent); 2938 showEvent(anEvent);
2939} 2939}
2940 2940
2941void CalendarView::appointment_edit() 2941void CalendarView::appointment_edit()
2942{ 2942{
2943 Event *anEvent = 0; 2943 Event *anEvent = 0;
2944 2944
2945 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2945 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2946 2946
2947 if (mViewManager->currentView()->isEventView()) { 2947 if (mViewManager->currentView()->isEventView()) {
2948 if ( incidence && incidence->type() == "Event" ) { 2948 if ( incidence && incidence->type() == "Event" ) {
2949 anEvent = static_cast<Event *>(incidence); 2949 anEvent = static_cast<Event *>(incidence);
2950 } 2950 }
2951 } 2951 }
2952 2952
2953 if (!anEvent) { 2953 if (!anEvent) {
2954 KNotifyClient::beep(); 2954 KNotifyClient::beep();
2955 return; 2955 return;
2956 } 2956 }
2957 2957
2958 editEvent(anEvent); 2958 editEvent(anEvent);
2959} 2959}
2960 2960
2961void CalendarView::appointment_delete() 2961void CalendarView::appointment_delete()
2962{ 2962{
2963 Event *anEvent = 0; 2963 Event *anEvent = 0;
2964 2964
2965 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2965 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2966 2966
2967 if (mViewManager->currentView()->isEventView()) { 2967 if (mViewManager->currentView()->isEventView()) {
2968 if ( incidence && incidence->type() == "Event" ) { 2968 if ( incidence && incidence->type() == "Event" ) {
2969 anEvent = static_cast<Event *>(incidence); 2969 anEvent = static_cast<Event *>(incidence);
2970 } 2970 }
2971 } 2971 }
2972 2972
2973 if (!anEvent) { 2973 if (!anEvent) {
2974 KNotifyClient::beep(); 2974 KNotifyClient::beep();
2975 return; 2975 return;
2976 } 2976 }
2977 2977
2978 deleteEvent(anEvent); 2978 deleteEvent(anEvent);
2979} 2979}
2980 2980
2981void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2981void CalendarView::todo_resub( Todo * parent, Todo * sub )
2982{ 2982{
2983 if (!sub) return; 2983 if (!sub) return;
2984 if (!parent) return; 2984 if (!parent) return;
2985 if ( sub->relatedTo() ) 2985 if ( sub->relatedTo() )
2986 sub->relatedTo()->removeRelation(sub); 2986 sub->relatedTo()->removeRelation(sub);
2987 sub->setRelatedTo(parent); 2987 sub->setRelatedTo(parent);
2988 sub->setRelatedToUid(parent->uid()); 2988 sub->setRelatedToUid(parent->uid());
2989 parent->addRelation(sub); 2989 parent->addRelation(sub);
2990 sub->updated(); 2990 sub->updated();
2991 parent->updated(); 2991 parent->updated();
2992 setModified(true); 2992 setModified(true);
2993 updateView(); 2993 updateView();
2994} 2994}
2995void CalendarView::todo_unsub(Todo *anTodo ) 2995void CalendarView::todo_unsub(Todo *anTodo )
2996{ 2996{
2997 // Todo *anTodo = selectedTodo(); 2997 // Todo *anTodo = selectedTodo();
2998 if (!anTodo) return; 2998 if (!anTodo) return;
2999 if (!anTodo->relatedTo()) return; 2999 if (!anTodo->relatedTo()) return;
3000 anTodo->relatedTo()->removeRelation(anTodo); 3000 anTodo->relatedTo()->removeRelation(anTodo);
3001 anTodo->setRelatedTo(0); 3001 anTodo->setRelatedTo(0);
3002 anTodo->updated(); 3002 anTodo->updated();
3003 anTodo->setRelatedToUid(""); 3003 anTodo->setRelatedToUid("");
3004 setModified(true); 3004 setModified(true);
3005 updateView(); 3005 updateView();
3006} 3006}
3007 3007
3008void CalendarView::deleteTodo(Todo *todo) 3008void CalendarView::deleteTodo(Todo *todo)
3009{ 3009{
3010 if (!todo) { 3010 if (!todo) {
3011 KNotifyClient::beep(); 3011 KNotifyClient::beep();
3012 return; 3012 return;
3013 } 3013 }
3014 if (KOPrefs::instance()->mConfirm) { 3014 if (KOPrefs::instance()->mConfirm) {
3015 QString text = todo->summary().left(20); 3015 QString text = todo->summary().left(20);
3016 if (!todo->relations().isEmpty()) { 3016 if (!todo->relations().isEmpty()) {
3017 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3017 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3018 3018
3019 } 3019 }
3020 switch (msgItemDelete(text)) { 3020 switch (msgItemDelete(text)) {
3021 case KMessageBox::Continue: // OK 3021 case KMessageBox::Continue: // OK
3022 bool deleteT = false; 3022 bool deleteT = false;
3023 if (!todo->relations().isEmpty()) { 3023 if (!todo->relations().isEmpty()) {
3024 deleteT = removeCompletedSubTodos( todo ); 3024 deleteT = removeCompletedSubTodos( todo );
3025 } 3025 }
3026 // deleteT == true: todo already deleted in removeCompletedSubTodos 3026 // deleteT == true: todo already deleted in removeCompletedSubTodos
3027 if ( !deleteT ) { 3027 if ( !deleteT ) {
3028 checkExternalId( todo ); 3028 checkExternalId( todo );
3029 calendar()->deleteTodo(todo); 3029 calendar()->deleteTodo(todo);
3030 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3030 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3031 updateView(); 3031 updateView();
3032 } 3032 }
3033 break; 3033 break;
3034 } // switch 3034 } // switch
3035 } else { 3035 } else {
3036 checkExternalId( todo ); 3036 checkExternalId( todo );
3037 mCalendar->deleteTodo(todo); 3037 mCalendar->deleteTodo(todo);
3038 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3038 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3039 updateView(); 3039 updateView();
3040 } 3040 }
3041 3041
3042 emit updateSearchDialog(); 3042 emit updateSearchDialog();
3043} 3043}
3044void CalendarView::deleteJournal(Journal *jour) 3044void CalendarView::deleteJournal(Journal *jour)
3045{ 3045{
3046 if (!jour) { 3046 if (!jour) {
3047 KNotifyClient::beep(); 3047 KNotifyClient::beep();
3048 return; 3048 return;
3049 } 3049 }
3050 if (KOPrefs::instance()->mConfirm) { 3050 if (KOPrefs::instance()->mConfirm) {
3051 switch (msgItemDelete( jour->description().left(20))) { 3051 switch (msgItemDelete( jour->description().left(20))) {
3052 case KMessageBox::Continue: // OK 3052 case KMessageBox::Continue: // OK
3053 calendar()->deleteJournal(jour); 3053 calendar()->deleteJournal(jour);
3054 updateView(); 3054 updateView();
3055 break; 3055 break;
3056 } // switch 3056 } // switch
3057 } else { 3057 } else {
3058 calendar()->deleteJournal(jour);; 3058 calendar()->deleteJournal(jour);;
3059 updateView(); 3059 updateView();
3060 } 3060 }
3061 emit updateSearchDialog(); 3061 emit updateSearchDialog();
3062} 3062}
3063 3063
3064void CalendarView::deleteEvent(Event *anEvent) 3064void CalendarView::deleteEvent(Event *anEvent)
3065{ 3065{
3066 if (!anEvent) { 3066 if (!anEvent) {
3067 KNotifyClient::beep(); 3067 KNotifyClient::beep();
3068 return; 3068 return;
3069 } 3069 }
3070 3070
3071 if (anEvent->recurrence()->doesRecur()) { 3071 if (anEvent->recurrence()->doesRecur()) {
3072 QDate itemDate = mViewManager->currentSelectionDate(); 3072 QDate itemDate = mViewManager->currentSelectionDate();
3073 int km; 3073 int km;
3074 if (!itemDate.isValid()) { 3074 if (!itemDate.isValid()) {
3075 //kdDebug() << "Date Not Valid" << endl; 3075 //kdDebug() << "Date Not Valid" << endl;
3076 if (KOPrefs::instance()->mConfirm) { 3076 if (KOPrefs::instance()->mConfirm) {
3077 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3077 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3078 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3078 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3079 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3079 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3080 if ( km == KMessageBox::Continue ) 3080 if ( km == KMessageBox::Continue )
3081 km = KMessageBox::No; // No = all below 3081 km = KMessageBox::No; // No = all below
3082 } else 3082 } else
3083 km = KMessageBox::No; 3083 km = KMessageBox::No;
3084 } else { 3084 } else {
3085 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3085 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3086 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3086 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3087 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3087 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3088 i18n("KO/Pi Confirmation"),i18n("Current"), 3088 i18n("KO/Pi Confirmation"),i18n("Current"),
3089 i18n("All")); 3089 i18n("All"));
3090 } 3090 }
3091 switch(km) { 3091 switch(km) {
3092 3092
3093 case KMessageBox::No: // Continue // all 3093 case KMessageBox::No: // Continue // all
3094 //qDebug("KMessageBox::No "); 3094 //qDebug("KMessageBox::No ");
3095 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3095 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3096 schedule(Scheduler::Cancel,anEvent); 3096 schedule(Scheduler::Cancel,anEvent);
3097 3097
3098 checkExternalId( anEvent); 3098 checkExternalId( anEvent);
3099 mCalendar->deleteEvent(anEvent); 3099 mCalendar->deleteEvent(anEvent);
3100 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3100 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3101 break; 3101 break;
3102 3102
3103 // Disabled because it does not work 3103 // Disabled because it does not work
3104 //#if 0 3104 //#if 0
3105 case KMessageBox::Yes: // just this one 3105 case KMessageBox::Yes: // just this one
3106 //QDate qd = mNavigator->selectedDates().first(); 3106 //QDate qd = mNavigator->selectedDates().first();
3107 //if (!qd.isValid()) { 3107 //if (!qd.isValid()) {
3108 // kdDebug() << "no date selected, or invalid date" << endl; 3108 // kdDebug() << "no date selected, or invalid date" << endl;
3109 // KNotifyClient::beep(); 3109 // KNotifyClient::beep();
3110 // return; 3110 // return;
3111 //} 3111 //}
3112 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3112 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3113 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3113 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3114 anEvent->addExDate(itemDate); 3114 anEvent->addExDate(itemDate);
3115 int duration = anEvent->recurrence()->duration(); 3115 int duration = anEvent->recurrence()->duration();
3116 if ( duration > 0 ) { 3116 if ( duration > 0 ) {
3117 anEvent->recurrence()->setDuration( duration - 1 ); 3117 anEvent->recurrence()->setDuration( duration - 1 );
3118 } 3118 }
3119 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3119 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3120 } 3120 }
3121 break; 3121 break;
3122 //#endif 3122 //#endif
3123 } // switch 3123 } // switch
3124 } else { 3124 } else {
3125 if (KOPrefs::instance()->mConfirm) { 3125 if (KOPrefs::instance()->mConfirm) {
3126 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3126 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3127 i18n("\nAre you sure you want\nto delete this event?"), 3127 i18n("\nAre you sure you want\nto delete this event?"),
3128 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3128 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3129 case KMessageBox::Continue: // OK 3129 case KMessageBox::Continue: // OK
3130 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3130 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3131 schedule(Scheduler::Cancel,anEvent); 3131 schedule(Scheduler::Cancel,anEvent);
3132 checkExternalId( anEvent); 3132 checkExternalId( anEvent);
3133 mCalendar->deleteEvent(anEvent); 3133 mCalendar->deleteEvent(anEvent);
3134 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3134 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3135 break; 3135 break;
3136 } // switch 3136 } // switch
3137 } else { 3137 } else {
3138 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3138 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3139 schedule(Scheduler::Cancel,anEvent); 3139 schedule(Scheduler::Cancel,anEvent);
3140 checkExternalId( anEvent); 3140 checkExternalId( anEvent);
3141 mCalendar->deleteEvent(anEvent); 3141 mCalendar->deleteEvent(anEvent);
3142 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3142 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3143 } 3143 }
3144 } // if-else 3144 } // if-else
3145 emit updateSearchDialog(); 3145 emit updateSearchDialog();
3146} 3146}
3147 3147
3148bool CalendarView::deleteEvent(const QString &uid) 3148bool CalendarView::deleteEvent(const QString &uid)
3149{ 3149{
3150 Event *ev = mCalendar->event(uid); 3150 Event *ev = mCalendar->event(uid);
3151 if (ev) { 3151 if (ev) {
3152 deleteEvent(ev); 3152 deleteEvent(ev);
3153 return true; 3153 return true;
3154 } else { 3154 } else {
3155 return false; 3155 return false;
3156 } 3156 }
3157} 3157}
3158 3158
3159/*****************************************************************************/ 3159/*****************************************************************************/
3160 3160
3161void CalendarView::action_mail() 3161void CalendarView::action_mail()
3162{ 3162{
3163#ifndef KORG_NOMAIL 3163#ifndef KORG_NOMAIL
3164 KOMailClient mailClient; 3164 KOMailClient mailClient;
3165 3165
3166 Incidence *incidence = currentSelection(); 3166 Incidence *incidence = currentSelection();
3167 3167
3168 if (!incidence) { 3168 if (!incidence) {
3169 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3169 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3170 return; 3170 return;
3171 } 3171 }
3172 if(incidence->attendeeCount() == 0 ) { 3172 if(incidence->attendeeCount() == 0 ) {
3173 KMessageBox::sorry(this, 3173 KMessageBox::sorry(this,
3174 i18n("Can't generate mail:\nNo attendees defined.\n")); 3174 i18n("Can't generate mail:\nNo attendees defined.\n"));
3175 return; 3175 return;
3176 } 3176 }
3177 3177
3178 CalendarLocal cal_tmp; 3178 CalendarLocal cal_tmp;
3179 Event *event = 0; 3179 Event *event = 0;
3180 Event *ev = 0; 3180 Event *ev = 0;
3181 if ( incidence && incidence->type() == "Event" ) { 3181 if ( incidence && incidence->type() == "Event" ) {
3182 event = static_cast<Event *>(incidence); 3182 event = static_cast<Event *>(incidence);
3183 ev = new Event(*event); 3183 ev = new Event(*event);
3184 cal_tmp.addEvent(ev); 3184 cal_tmp.addEvent(ev);
3185 } 3185 }
3186 ICalFormat mForm(); 3186 ICalFormat mForm();
3187 QString attachment = mForm.toString( &cal_tmp ); 3187 QString attachment = mForm.toString( &cal_tmp );
3188 if (ev) delete(ev); 3188 if (ev) delete(ev);
3189 3189
3190 mailClient.mailAttendees(currentSelection(), attachment); 3190 mailClient.mailAttendees(currentSelection(), attachment);
3191 3191
3192#endif 3192#endif
3193 3193
3194#if 0 3194#if 0
3195 Event *anEvent = 0; 3195 Event *anEvent = 0;
3196 if (mViewManager->currentView()->isEventView()) { 3196 if (mViewManager->currentView()->isEventView()) {
3197 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3197 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3198 } 3198 }
3199 3199
3200 if (!anEvent) { 3200 if (!anEvent) {
3201 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3201 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3202 return; 3202 return;
3203 } 3203 }
3204 if(anEvent->attendeeCount() == 0 ) { 3204 if(anEvent->attendeeCount() == 0 ) {
3205 KMessageBox::sorry(this, 3205 KMessageBox::sorry(this,
3206 i18n("Can't generate mail:\nNo attendees defined.\n")); 3206 i18n("Can't generate mail:\nNo attendees defined.\n"));
3207 return; 3207 return;
3208 } 3208 }
3209 3209
3210 mailobject.emailEvent(anEvent); 3210 mailobject.emailEvent(anEvent);
3211#endif 3211#endif
3212} 3212}
3213 3213
3214 3214
3215void CalendarView::schedule_publish(Incidence *incidence) 3215void CalendarView::schedule_publish(Incidence *incidence)
3216{ 3216{
3217 Event *event = 0; 3217 Event *event = 0;
3218 Todo *todo = 0; 3218 Todo *todo = 0;
3219 3219
3220 if (incidence == 0) { 3220 if (incidence == 0) {
3221 incidence = mViewManager->currentView()->selectedIncidences().first(); 3221 incidence = mViewManager->currentView()->selectedIncidences().first();
3222 if (incidence == 0) { 3222 if (incidence == 0) {
3223 incidence = mTodoList->selectedIncidences().first(); 3223 incidence = mTodoList->selectedIncidences().first();
3224 } 3224 }
3225 } 3225 }
3226 if ( incidence && incidence->type() == "Event" ) { 3226 if ( incidence && incidence->type() == "Event" ) {
3227 event = static_cast<Event *>(incidence); 3227 event = static_cast<Event *>(incidence);
3228 } else { 3228 } else {
3229 if ( incidence && incidence->type() == "Todo" ) { 3229 if ( incidence && incidence->type() == "Todo" ) {
3230 todo = static_cast<Todo *>(incidence); 3230 todo = static_cast<Todo *>(incidence);
3231 } 3231 }
3232 } 3232 }
3233 3233
3234 if (!event && !todo) { 3234 if (!event && !todo) {
3235 KMessageBox::sorry(this,i18n("No event selected.")); 3235 KMessageBox::sorry(this,i18n("No event selected."));
3236 return; 3236 return;
3237 } 3237 }
3238 3238
3239 PublishDialog *publishdlg = new PublishDialog(); 3239 PublishDialog *publishdlg = new PublishDialog();
3240 if (incidence->attendeeCount()>0) { 3240 if (incidence->attendeeCount()>0) {
3241 QPtrList<Attendee> attendees = incidence->attendees(); 3241 QPtrList<Attendee> attendees = incidence->attendees();
3242 attendees.first(); 3242 attendees.first();
3243 while ( attendees.current()!=0 ) { 3243 while ( attendees.current()!=0 ) {
3244 publishdlg->addAttendee(attendees.current()); 3244 publishdlg->addAttendee(attendees.current());
3245 attendees.next(); 3245 attendees.next();
3246 } 3246 }
3247 } 3247 }
3248 bool send = true; 3248 bool send = true;
3249 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3249 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3250 if ( publishdlg->exec() != QDialog::Accepted ) 3250 if ( publishdlg->exec() != QDialog::Accepted )
3251 send = false; 3251 send = false;
3252 } 3252 }
3253 if ( send ) { 3253 if ( send ) {
3254 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3254 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3255 if ( event ) { 3255 if ( event ) {
3256 Event *ev = new Event(*event); 3256 Event *ev = new Event(*event);
3257 ev->registerObserver(0); 3257 ev->registerObserver(0);
3258 ev->clearAttendees(); 3258 ev->clearAttendees();
3259 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3259 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3260 delete(ev); 3260 delete(ev);
3261 } 3261 }
3262 } else { 3262 } else {
3263 if ( todo ) { 3263 if ( todo ) {
3264 Todo *ev = new Todo(*todo); 3264 Todo *ev = new Todo(*todo);
3265 ev->registerObserver(0); 3265 ev->registerObserver(0);
3266 ev->clearAttendees(); 3266 ev->clearAttendees();
3267 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3267 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3268 delete(ev); 3268 delete(ev);
3269 } 3269 }
3270 } 3270 }
3271 } 3271 }
3272 } 3272 }
3273 delete publishdlg; 3273 delete publishdlg;
3274} 3274}
3275 3275
3276void CalendarView::schedule_request(Incidence *incidence) 3276void CalendarView::schedule_request(Incidence *incidence)
3277{ 3277{
3278 schedule(Scheduler::Request,incidence); 3278 schedule(Scheduler::Request,incidence);
3279} 3279}
3280 3280
3281void CalendarView::schedule_refresh(Incidence *incidence) 3281void CalendarView::schedule_refresh(Incidence *incidence)
3282{ 3282{
3283 schedule(Scheduler::Refresh,incidence); 3283 schedule(Scheduler::Refresh,incidence);
3284} 3284}
3285 3285
3286void CalendarView::schedule_cancel(Incidence *incidence) 3286void CalendarView::schedule_cancel(Incidence *incidence)
3287{ 3287{
3288 schedule(Scheduler::Cancel,incidence); 3288 schedule(Scheduler::Cancel,incidence);
3289} 3289}
3290 3290
3291void CalendarView::schedule_add(Incidence *incidence) 3291void CalendarView::schedule_add(Incidence *incidence)
3292{ 3292{
3293 schedule(Scheduler::Add,incidence); 3293 schedule(Scheduler::Add,incidence);
3294} 3294}
3295 3295
3296void CalendarView::schedule_reply(Incidence *incidence) 3296void CalendarView::schedule_reply(Incidence *incidence)
3297{ 3297{
3298 schedule(Scheduler::Reply,incidence); 3298 schedule(Scheduler::Reply,incidence);
3299} 3299}
3300 3300
3301void CalendarView::schedule_counter(Incidence *incidence) 3301void CalendarView::schedule_counter(Incidence *incidence)
3302{ 3302{
3303 schedule(Scheduler::Counter,incidence); 3303 schedule(Scheduler::Counter,incidence);
3304} 3304}
3305 3305
3306void CalendarView::schedule_declinecounter(Incidence *incidence) 3306void CalendarView::schedule_declinecounter(Incidence *incidence)
3307{ 3307{
3308 schedule(Scheduler::Declinecounter,incidence); 3308 schedule(Scheduler::Declinecounter,incidence);
3309} 3309}
3310 3310
3311void CalendarView::schedule_publish_freebusy(int daysToPublish) 3311void CalendarView::schedule_publish_freebusy(int daysToPublish)
3312{ 3312{
3313 QDateTime start = QDateTime::currentDateTime(); 3313 QDateTime start = QDateTime::currentDateTime();
3314 QDateTime end = start.addDays(daysToPublish); 3314 QDateTime end = start.addDays(daysToPublish);
3315 3315
3316 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3316 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3317 freebusy->setOrganizer(KOPrefs::instance()->email()); 3317 freebusy->setOrganizer(KOPrefs::instance()->email());
3318 3318
3319 3319
3320 PublishDialog *publishdlg = new PublishDialog(); 3320 PublishDialog *publishdlg = new PublishDialog();
3321 if ( publishdlg->exec() == QDialog::Accepted ) { 3321 if ( publishdlg->exec() == QDialog::Accepted ) {
3322 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3322 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3323 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3323 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3324 delete(freebusy); 3324 delete(freebusy);
3325 } 3325 }
3326 } 3326 }
3327 delete publishdlg; 3327 delete publishdlg;
3328} 3328}
3329 3329
3330void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3330void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3331{ 3331{
3332 Event *event = 0; 3332 Event *event = 0;
3333 Todo *todo = 0; 3333 Todo *todo = 0;
3334 3334
3335 if (incidence == 0) { 3335 if (incidence == 0) {
3336 incidence = mViewManager->currentView()->selectedIncidences().first(); 3336 incidence = mViewManager->currentView()->selectedIncidences().first();
3337 if (incidence == 0) { 3337 if (incidence == 0) {
3338 incidence = mTodoList->selectedIncidences().first(); 3338 incidence = mTodoList->selectedIncidences().first();
3339 } 3339 }
3340 } 3340 }
3341 if ( incidence && incidence->type() == "Event" ) { 3341 if ( incidence && incidence->type() == "Event" ) {
3342 event = static_cast<Event *>(incidence); 3342 event = static_cast<Event *>(incidence);
3343 } 3343 }
3344 if ( incidence && incidence->type() == "Todo" ) { 3344 if ( incidence && incidence->type() == "Todo" ) {
3345 todo = static_cast<Todo *>(incidence); 3345 todo = static_cast<Todo *>(incidence);
3346 } 3346 }
3347 3347
3348 if (!event && !todo) { 3348 if (!event && !todo) {
3349 KMessageBox::sorry(this,i18n("No event selected.")); 3349 KMessageBox::sorry(this,i18n("No event selected."));
3350 return; 3350 return;
3351 } 3351 }
3352 3352
3353 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3353 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3354 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3354 KMessageBox::sorry(this,i18n("The event has no attendees."));
3355 return; 3355 return;
3356 } 3356 }
3357 3357
3358 Event *ev = 0; 3358 Event *ev = 0;
3359 if (event) ev = new Event(*event); 3359 if (event) ev = new Event(*event);
3360 Todo *to = 0; 3360 Todo *to = 0;
3361 if (todo) to = new Todo(*todo); 3361 if (todo) to = new Todo(*todo);
3362 3362
3363 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3363 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3364 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3364 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3365 if (!me) { 3365 if (!me) {
3366 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3366 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3367 return; 3367 return;
3368 } 3368 }
3369 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3369 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3370 StatusDialog *statdlg = new StatusDialog(this); 3370 StatusDialog *statdlg = new StatusDialog(this);
3371 if (!statdlg->exec()==QDialog::Accepted) return; 3371 if (!statdlg->exec()==QDialog::Accepted) return;
3372 me->setStatus( statdlg->status() ); 3372 me->setStatus( statdlg->status() );
3373 delete(statdlg); 3373 delete(statdlg);
3374 } 3374 }
3375 Attendee *menew = new Attendee(*me); 3375 Attendee *menew = new Attendee(*me);
3376 if (ev) { 3376 if (ev) {
3377 ev->clearAttendees(); 3377 ev->clearAttendees();
3378 ev->addAttendee(menew,false); 3378 ev->addAttendee(menew,false);
3379 } else { 3379 } else {
3380 if (to) { 3380 if (to) {
3381 todo->clearAttendees(); 3381 todo->clearAttendees();
3382 todo->addAttendee(menew,false); 3382 todo->addAttendee(menew,false);
3383 } 3383 }
3384 } 3384 }
3385 } 3385 }
3386 3386
3387 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3387 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3388 if (ev) { 3388 if (ev) {
3389 if ( !dlg->addMessage(ev,method) ) delete(ev); 3389 if ( !dlg->addMessage(ev,method) ) delete(ev);
3390 } else { 3390 } else {
3391 if (to) { 3391 if (to) {
3392 if ( !dlg->addMessage(to,method) ) delete(to); 3392 if ( !dlg->addMessage(to,method) ) delete(to);
3393 } 3393 }
3394 } 3394 }
3395} 3395}
3396 3396
3397void CalendarView::openAddressbook() 3397void CalendarView::openAddressbook()
3398{ 3398{
3399 KRun::runCommand("kaddressbook"); 3399 KRun::runCommand("kaddressbook");
3400} 3400}
3401 3401
3402void CalendarView::setModified(bool modified) 3402void CalendarView::setModified(bool modified)
3403{ 3403{
3404 if ( modified ) 3404 if ( modified )
3405 emit signalmodified(); 3405 emit signalmodified();
3406 if (mModified != modified) { 3406 if (mModified != modified) {
3407 mModified = modified; 3407 mModified = modified;
3408 emit modifiedChanged(mModified); 3408 emit modifiedChanged(mModified);
3409 } 3409 }
3410} 3410}
3411 3411
3412bool CalendarView::isReadOnly() 3412bool CalendarView::isReadOnly()
3413{ 3413{
3414 return mReadOnly; 3414 return mReadOnly;
3415} 3415}
3416 3416
3417void CalendarView::setReadOnly(bool readOnly) 3417void CalendarView::setReadOnly(bool readOnly)
3418{ 3418{
3419 if (mReadOnly != readOnly) { 3419 if (mReadOnly != readOnly) {
3420 mReadOnly = readOnly; 3420 mReadOnly = readOnly;
3421 emit readOnlyChanged(mReadOnly); 3421 emit readOnlyChanged(mReadOnly);
3422 } 3422 }
3423} 3423}
3424 3424
3425bool CalendarView::isModified() 3425bool CalendarView::isModified()
3426{ 3426{
3427 return mModified; 3427 return mModified;
3428} 3428}
3429 3429
3430void CalendarView::printSetup() 3430void CalendarView::printSetup()
3431{ 3431{
3432#ifndef KORG_NOPRINTER 3432#ifndef KORG_NOPRINTER
3433 createPrinter(); 3433 createPrinter();
3434 3434
3435 mCalPrinter->setupPrinter(); 3435 mCalPrinter->setupPrinter();
3436#endif 3436#endif
3437} 3437}
3438 3438
3439void CalendarView::print() 3439void CalendarView::print()
3440{ 3440{
3441#ifndef KORG_NOPRINTER 3441#ifndef KORG_NOPRINTER
3442 createPrinter(); 3442 createPrinter();
3443 3443
3444 DateList tmpDateList = mNavigator->selectedDates(); 3444 DateList tmpDateList = mNavigator->selectedDates();
3445 mCalPrinter->print(CalPrinter::Month, 3445 mCalPrinter->print(CalPrinter::Month,
3446 tmpDateList.first(), tmpDateList.last()); 3446 tmpDateList.first(), tmpDateList.last());
3447#endif 3447#endif
3448} 3448}
3449 3449
3450void CalendarView::printPreview() 3450void CalendarView::printPreview()
3451{ 3451{
3452#ifndef KORG_NOPRINTER 3452#ifndef KORG_NOPRINTER
3453 kdDebug() << "CalendarView::printPreview()" << endl; 3453 kdDebug() << "CalendarView::printPreview()" << endl;
3454 3454
3455 createPrinter(); 3455 createPrinter();
3456 3456
3457 DateList tmpDateList = mNavigator->selectedDates(); 3457 DateList tmpDateList = mNavigator->selectedDates();
3458 3458
3459 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3459 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3460 tmpDateList.last()); 3460 tmpDateList.last());
3461#endif 3461#endif
3462} 3462}
3463 3463
3464void CalendarView::exportICalendar() 3464void CalendarView::exportICalendar()
3465{ 3465{
3466 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3466 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3467 3467
3468 // Force correct extension 3468 // Force correct extension
3469 if (filename.right(4) != ".ics") filename += ".ics"; 3469 if (filename.right(4) != ".ics") filename += ".ics";
3470 3470
3471 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3471 FileStorage storage( mCalendar, filename, new ICalFormat() );
3472 storage.save(); 3472 storage.save();
3473} 3473}
3474 3474
3475bool CalendarView::exportVCalendar( QString filename ) 3475bool CalendarView::exportVCalendar( QString filename )
3476{ 3476{
3477 if (mCalendar->journals().count() > 0) { 3477 if (mCalendar->journals().count() > 0) {
3478 int result = KMessageBox::warningContinueCancel(this, 3478 int result = KMessageBox::warningContinueCancel(this,
3479 i18n("The journal entries can not be\nexported to a vCalendar file."), 3479 i18n("The journal entries can not be\nexported to a vCalendar file."),
3480 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3480 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3481 true); 3481 true);
3482 if (result != KMessageBox::Continue) return false; 3482 if (result != KMessageBox::Continue) return false;
3483 } 3483 }
3484 3484
3485 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3485 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3486 3486
3487 // Force correct extension 3487 // Force correct extension
3488 if (filename.right(4) != ".vcs") filename += ".vcs"; 3488 if (filename.right(4) != ".vcs") filename += ".vcs";
3489 3489
3490 FileStorage storage( mCalendar, filename, new VCalFormat ); 3490 FileStorage storage( mCalendar, filename, new VCalFormat );
3491 return storage.save(); 3491 return storage.save();
3492 3492
3493} 3493}
3494 3494
3495void CalendarView::eventUpdated(Incidence *) 3495void CalendarView::eventUpdated(Incidence *)
3496{ 3496{
3497 setModified(); 3497 setModified();
3498 // Don't call updateView here. The code, which has caused the update of the 3498 // Don't call updateView here. The code, which has caused the update of the
3499 // event is responsible for updating the view. 3499 // event is responsible for updating the view.
3500 // updateView(); 3500 // updateView();
3501} 3501}
3502 3502
3503void CalendarView::adaptNavigationUnits() 3503void CalendarView::adaptNavigationUnits()
3504{ 3504{
3505 if (mViewManager->currentView()->isEventView()) { 3505 if (mViewManager->currentView()->isEventView()) {
3506 int days = mViewManager->currentView()->currentDateCount(); 3506 int days = mViewManager->currentView()->currentDateCount();
3507 if (days == 1) { 3507 if (days == 1) {
3508 emit changeNavStringPrev(i18n("&Previous Day")); 3508 emit changeNavStringPrev(i18n("&Previous Day"));
3509 emit changeNavStringNext(i18n("&Next Day")); 3509 emit changeNavStringNext(i18n("&Next Day"));
3510 } else { 3510 } else {
3511 emit changeNavStringPrev(i18n("&Previous Week")); 3511 emit changeNavStringPrev(i18n("&Previous Week"));
3512 emit changeNavStringNext(i18n("&Next Week")); 3512 emit changeNavStringNext(i18n("&Next Week"));
3513 } 3513 }
3514 } 3514 }
3515} 3515}
3516 3516
3517void CalendarView::processMainViewSelection( Incidence *incidence ) 3517void CalendarView::processMainViewSelection( Incidence *incidence )
3518{ 3518{
3519 if ( incidence ) mTodoList->clearSelection(); 3519 if ( incidence ) mTodoList->clearSelection();
3520 processIncidenceSelection( incidence ); 3520 processIncidenceSelection( incidence );
3521} 3521}
3522 3522
3523void CalendarView::processTodoListSelection( Incidence *incidence ) 3523void CalendarView::processTodoListSelection( Incidence *incidence )
3524{ 3524{
3525 if ( incidence && mViewManager->currentView() ) { 3525 if ( incidence && mViewManager->currentView() ) {
3526 mViewManager->currentView()->clearSelection(); 3526 mViewManager->currentView()->clearSelection();
3527 } 3527 }
3528 processIncidenceSelection( incidence ); 3528 processIncidenceSelection( incidence );
3529} 3529}
3530 3530
3531void CalendarView::processIncidenceSelection( Incidence *incidence ) 3531void CalendarView::processIncidenceSelection( Incidence *incidence )
3532{ 3532{
3533 if ( incidence == mSelectedIncidence ) return; 3533 if ( incidence == mSelectedIncidence ) return;
3534 3534
3535 mSelectedIncidence = incidence; 3535 mSelectedIncidence = incidence;
3536 3536
3537 emit incidenceSelected( mSelectedIncidence ); 3537 emit incidenceSelected( mSelectedIncidence );
3538 3538
3539 if ( incidence && incidence->type() == "Event" ) { 3539 if ( incidence && incidence->type() == "Event" ) {
3540 Event *event = static_cast<Event *>( incidence ); 3540 Event *event = static_cast<Event *>( incidence );
3541 if ( event->organizer() == KOPrefs::instance()->email() ) { 3541 if ( event->organizer() == KOPrefs::instance()->email() ) {
3542 emit organizerEventsSelected( true ); 3542 emit organizerEventsSelected( true );
3543 } else { 3543 } else {
3544 emit organizerEventsSelected(false); 3544 emit organizerEventsSelected(false);
3545 } 3545 }
3546 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3546 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3547 KOPrefs::instance()->email() ) ) { 3547 KOPrefs::instance()->email() ) ) {
3548 emit groupEventsSelected( true ); 3548 emit groupEventsSelected( true );
3549 } else { 3549 } else {
3550 emit groupEventsSelected(false); 3550 emit groupEventsSelected(false);
3551 } 3551 }
3552 return; 3552 return;
3553 } else { 3553 } else {
3554 if ( incidence && incidence->type() == "Todo" ) { 3554 if ( incidence && incidence->type() == "Todo" ) {
3555 emit todoSelected( true ); 3555 emit todoSelected( true );
3556 Todo *event = static_cast<Todo *>( incidence ); 3556 Todo *event = static_cast<Todo *>( incidence );
3557 if ( event->organizer() == KOPrefs::instance()->email() ) { 3557 if ( event->organizer() == KOPrefs::instance()->email() ) {
3558 emit organizerEventsSelected( true ); 3558 emit organizerEventsSelected( true );
3559 } else { 3559 } else {
3560 emit organizerEventsSelected(false); 3560 emit organizerEventsSelected(false);
3561 } 3561 }
3562 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3562 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3563 KOPrefs::instance()->email() ) ) { 3563 KOPrefs::instance()->email() ) ) {
3564 emit groupEventsSelected( true ); 3564 emit groupEventsSelected( true );
3565 } else { 3565 } else {
3566 emit groupEventsSelected(false); 3566 emit groupEventsSelected(false);
3567 } 3567 }
3568 return; 3568 return;
3569 } else { 3569 } else {
3570 emit todoSelected( false ); 3570 emit todoSelected( false );
3571 emit organizerEventsSelected(false); 3571 emit organizerEventsSelected(false);
3572 emit groupEventsSelected(false); 3572 emit groupEventsSelected(false);
3573 } 3573 }
3574 return; 3574 return;
3575 } 3575 }
3576 3576
3577 /* if ( incidence && incidence->type() == "Todo" ) { 3577 /* if ( incidence && incidence->type() == "Todo" ) {
3578 emit todoSelected( true ); 3578 emit todoSelected( true );
3579 } else { 3579 } else {
3580 emit todoSelected( false ); 3580 emit todoSelected( false );
3581 }*/ 3581 }*/
3582} 3582}
3583 3583
3584 3584
3585void CalendarView::checkClipboard() 3585void CalendarView::checkClipboard()
3586{ 3586{
3587#ifndef KORG_NODND 3587#ifndef KORG_NODND
3588 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3588 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3589 emit pasteEnabled(true); 3589 emit pasteEnabled(true);
3590 } else { 3590 } else {
3591 emit pasteEnabled(false); 3591 emit pasteEnabled(false);
3592 } 3592 }
3593#endif 3593#endif
3594} 3594}
3595 3595
3596void CalendarView::showDates(const DateList &selectedDates) 3596void CalendarView::showDates(const DateList &selectedDates)
3597{ 3597{
3598 // kdDebug() << "CalendarView::selectDates()" << endl; 3598 // kdDebug() << "CalendarView::selectDates()" << endl;
3599 3599
3600 3600
3601 if ( !mBlockShowDates ) { 3601 if ( !mBlockShowDates ) {
3602 if ( mViewManager->currentView() ) { 3602 if ( mViewManager->currentView() ) {
3603 updateView( selectedDates.first(), selectedDates.last() ); 3603 updateView( selectedDates.first(), selectedDates.last() );
3604 } else { 3604 } else {
3605 mViewManager->showAgendaView(); 3605 mViewManager->showAgendaView();
3606 } 3606 }
3607 } 3607 }
3608 3608
3609 QDate date = selectedDates.first();
3610 if ( ! date.isValid() ) {
3611 topLevelWidget()->setCaption("");
3612 return;
3613 }
3614
3609 QString selDates; 3615 QString selDates;
3610 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3616 selDates = KGlobal::locale()->formatDate( date, true);
3611 if (selectedDates.first() < selectedDates.last() ) 3617 if (selectedDates.first() < selectedDates.last() )
3612 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3618 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3613 else { 3619 else {
3614 QString addString; 3620 QString addString;
3615 if ( selectedDates.first() == QDateTime::currentDateTime().date() ) 3621 if ( date == QDateTime::currentDateTime().date() )
3616 addString = i18n("Today"); 3622 addString = i18n("Today");
3617 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 3623 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3618 addString = i18n("Tomorrow"); 3624 addString = i18n("Tomorrow");
3619 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 3625 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3620 addString = i18n("Yesterday"); 3626 addString = i18n("Yesterday");
3621 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 3627 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3622 addString = i18n("Day before yesterday"); 3628 addString = i18n("Day before yesterday");
3623 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 3629 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3624 addString = i18n("Day after tomorrow"); 3630 addString = i18n("Day after tomorrow");
3625 if ( !addString.isEmpty() ) { 3631 if ( !addString.isEmpty() ) {
3626 topLevelWidget()->setCaption( addString+", " + selDates ); 3632 topLevelWidget()->setCaption( addString+", " + selDates );
3627 return; 3633 return;
3628 } 3634 }
3629 } 3635 }
3630 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3636 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3631 3637
3632} 3638}
3633 3639
3634QPtrList<CalFilter> CalendarView::filters() 3640QPtrList<CalFilter> CalendarView::filters()
3635{ 3641{
3636 return mFilters; 3642 return mFilters;
3637 3643
3638} 3644}
3639void CalendarView::editFilters() 3645void CalendarView::editFilters()
3640{ 3646{
3641 // kdDebug() << "CalendarView::editFilters()" << endl; 3647 // kdDebug() << "CalendarView::editFilters()" << endl;
3642 3648
3643 CalFilter *filter = mFilters.first(); 3649 CalFilter *filter = mFilters.first();
3644 while(filter) { 3650 while(filter) {
3645 kdDebug() << " Filter: " << filter->name() << endl; 3651 kdDebug() << " Filter: " << filter->name() << endl;
3646 filter = mFilters.next(); 3652 filter = mFilters.next();
3647 } 3653 }
3648 3654
3649 mDialogManager->showFilterEditDialog(&mFilters); 3655 mDialogManager->showFilterEditDialog(&mFilters);
3650} 3656}
3651void CalendarView::toggleFilter() 3657void CalendarView::toggleFilter()
3652{ 3658{
3653 showFilter(! mFilterView->isVisible()); 3659 showFilter(! mFilterView->isVisible());
3654} 3660}
3655 3661
3656KOFilterView *CalendarView::filterView() 3662KOFilterView *CalendarView::filterView()
3657{ 3663{
3658 return mFilterView; 3664 return mFilterView;
3659} 3665}
3660void CalendarView::selectFilter( int fil ) 3666void CalendarView::selectFilter( int fil )
3661{ 3667{
3662 mFilterView->setSelectedFilter( fil ); 3668 mFilterView->setSelectedFilter( fil );
3663} 3669}
3664void CalendarView::showFilter(bool visible) 3670void CalendarView::showFilter(bool visible)
3665{ 3671{
3666 if (visible) mFilterView->show(); 3672 if (visible) mFilterView->show();
3667 else mFilterView->hide(); 3673 else mFilterView->hide();
3668} 3674}
3669void CalendarView::toggleFilerEnabled( ) 3675void CalendarView::toggleFilerEnabled( )
3670{ 3676{
3671 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3677 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3672 if ( !mFilterView->filtersEnabled() ) 3678 if ( !mFilterView->filtersEnabled() )
3673 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3679 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3674 3680
3675} 3681}
3676void CalendarView::updateFilter() 3682void CalendarView::updateFilter()
3677{ 3683{
3678 CalFilter *filter = mFilterView->selectedFilter(); 3684 CalFilter *filter = mFilterView->selectedFilter();
3679 if (filter) { 3685 if (filter) {
3680 QString mess; 3686 QString mess;
3681 if (mFilterView->filtersEnabled()) { 3687 if (mFilterView->filtersEnabled()) {
3682 mess = i18n("Filter selected: ")+filter->name(); 3688 mess = i18n("Filter selected: ")+filter->name();
3683 filter->setEnabled(true); 3689 filter->setEnabled(true);
3684 } 3690 }
3685 else filter->setEnabled(false); 3691 else filter->setEnabled(false);
3686 mCalendar->setFilter(filter); 3692 mCalendar->setFilter(filter);
3687 updateView(); 3693 updateView();
3688 if ( !mess.isEmpty() ) 3694 if ( !mess.isEmpty() )
3689 topLevelWidget()->setCaption( mess ); 3695 topLevelWidget()->setCaption( mess );
3690 3696
3691 } 3697 }
3692} 3698}
3693 3699
3694void CalendarView::filterEdited() 3700void CalendarView::filterEdited()
3695{ 3701{
3696 mFilterView->updateFilters(); 3702 mFilterView->updateFilters();
3697 updateFilter(); 3703 updateFilter();
3698 writeSettings(); 3704 writeSettings();
3699} 3705}
3700 3706
3701 3707
3702void CalendarView::takeOverEvent() 3708void CalendarView::takeOverEvent()
3703{ 3709{
3704 Incidence *incidence = currentSelection(); 3710 Incidence *incidence = currentSelection();
3705 3711
3706 if (!incidence) return; 3712 if (!incidence) return;
3707 3713
3708 incidence->setOrganizer(KOPrefs::instance()->email()); 3714 incidence->setOrganizer(KOPrefs::instance()->email());
3709 incidence->recreate(); 3715 incidence->recreate();
3710 incidence->setReadOnly(false); 3716 incidence->setReadOnly(false);
3711 3717
3712 updateView(); 3718 updateView();
3713} 3719}
3714 3720
3715void CalendarView::takeOverCalendar() 3721void CalendarView::takeOverCalendar()
3716{ 3722{
3717 // TODO: Create Calendar::allIncidences() function and use it here 3723 // TODO: Create Calendar::allIncidences() function and use it here
3718 3724
3719 QPtrList<Event> events = mCalendar->events(); 3725 QPtrList<Event> events = mCalendar->events();
3720 for(uint i=0; i<events.count(); ++i) { 3726 for(uint i=0; i<events.count(); ++i) {
3721 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3727 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3722 events.at(i)->recreate(); 3728 events.at(i)->recreate();
3723 events.at(i)->setReadOnly(false); 3729 events.at(i)->setReadOnly(false);
3724 } 3730 }
3725 3731
3726 QPtrList<Todo> todos = mCalendar->todos(); 3732 QPtrList<Todo> todos = mCalendar->todos();
3727 for(uint i=0; i<todos.count(); ++i) { 3733 for(uint i=0; i<todos.count(); ++i) {
3728 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3734 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3729 todos.at(i)->recreate(); 3735 todos.at(i)->recreate();
3730 todos.at(i)->setReadOnly(false); 3736 todos.at(i)->setReadOnly(false);
3731 } 3737 }
3732 3738
3733 QPtrList<Journal> journals = mCalendar->journals(); 3739 QPtrList<Journal> journals = mCalendar->journals();
3734 for(uint i=0; i<journals.count(); ++i) { 3740 for(uint i=0; i<journals.count(); ++i) {
3735 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3741 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3736 journals.at(i)->recreate(); 3742 journals.at(i)->recreate();
3737 journals.at(i)->setReadOnly(false); 3743 journals.at(i)->setReadOnly(false);
3738 } 3744 }
3739 3745
3740 updateView(); 3746 updateView();
3741} 3747}
3742 3748
3743void CalendarView::showIntro() 3749void CalendarView::showIntro()
3744{ 3750{
3745 kdDebug() << "To be implemented." << endl; 3751 kdDebug() << "To be implemented." << endl;
3746} 3752}
3747 3753
3748QWidgetStack *CalendarView::viewStack() 3754QWidgetStack *CalendarView::viewStack()
3749{ 3755{
3750 return mRightFrame; 3756 return mRightFrame;
3751} 3757}
3752 3758
3753QWidget *CalendarView::leftFrame() 3759QWidget *CalendarView::leftFrame()
3754{ 3760{
3755 return ( QWidget *)mLeftFrame; 3761 return ( QWidget *)mLeftFrame;
3756} 3762}
3757 3763
3758DateNavigator *CalendarView::dateNavigator() 3764DateNavigator *CalendarView::dateNavigator()
3759{ 3765{
3760 return mNavigator; 3766 return mNavigator;
3761} 3767}
3762 3768
3763KDateNavigator* CalendarView::dateNavigatorWidget() 3769KDateNavigator* CalendarView::dateNavigatorWidget()
3764{ 3770{
3765 return mDateNavigator->navigatorView(); 3771 return mDateNavigator->navigatorView();
3766} 3772}
3767void CalendarView::toggleDateNavigatorWidget() 3773void CalendarView::toggleDateNavigatorWidget()
3768{ 3774{
3769 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3775 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3770 3776
3771 if (!KOPrefs::instance()->mShowDateNavigator ) 3777 if (!KOPrefs::instance()->mShowDateNavigator )
3772 mDateNavigator->hide(); 3778 mDateNavigator->hide();
3773 else 3779 else
3774 mDateNavigator->show(); 3780 mDateNavigator->show();
3775} 3781}
3776void CalendarView::addView(KOrg::BaseView *view) 3782void CalendarView::addView(KOrg::BaseView *view)
3777{ 3783{
3778 mViewManager->addView(view); 3784 mViewManager->addView(view);
3779} 3785}
3780 3786
3781void CalendarView::showView(KOrg::BaseView *view) 3787void CalendarView::showView(KOrg::BaseView *view)
3782{ 3788{
3783 mViewManager->showView(view, mLeftFrame->isVisible()); 3789 mViewManager->showView(view, mLeftFrame->isVisible());
3784} 3790}
3785 3791
3786Incidence *CalendarView::currentSelection() 3792Incidence *CalendarView::currentSelection()
3787{ 3793{
3788 return mViewManager->currentSelection(); 3794 return mViewManager->currentSelection();
3789} 3795}
3790void CalendarView::toggleAllDaySize() 3796void CalendarView::toggleAllDaySize()
3791{ 3797{
3792 /* 3798 /*
3793 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3799 if ( KOPrefs::instance()->mAllDaySize > 47 )
3794 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3800 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3795 else 3801 else
3796 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3802 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3797 */ 3803 */
3798 viewManager()->agendaView()->toggleAllDay(); 3804 viewManager()->agendaView()->toggleAllDay();
3799} 3805}
3800void CalendarView::toggleExpand() 3806void CalendarView::toggleExpand()
3801{ 3807{
3802 // if ( mLeftFrame->isHidden() ) { 3808 // if ( mLeftFrame->isHidden() ) {
3803 // mLeftFrame->show(); 3809 // mLeftFrame->show();
3804 // emit calendarViewExpanded( false ); 3810 // emit calendarViewExpanded( false );
3805 // } else { 3811 // } else {
3806 // mLeftFrame->hide(); 3812 // mLeftFrame->hide();
3807 // emit calendarViewExpanded( true ); 3813 // emit calendarViewExpanded( true );
3808 // } 3814 // }
3809 //qDebug(" CalendarView::toggleExpand()"); 3815 //qDebug(" CalendarView::toggleExpand()");
3810 globalFlagBlockAgenda = 1; 3816 globalFlagBlockAgenda = 1;
3811 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3817 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3812 globalFlagBlockAgenda = 5; 3818 globalFlagBlockAgenda = 5;
3813 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3819 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3814 //mViewManager->showView( 0, true ); 3820 //mViewManager->showView( 0, true );
3815} 3821}
3816 3822
3817void CalendarView::calendarModified( bool modified, Calendar * ) 3823void CalendarView::calendarModified( bool modified, Calendar * )
3818{ 3824{
3819 setModified( modified ); 3825 setModified( modified );
3820} 3826}
3821 3827
3822Todo *CalendarView::selectedTodo() 3828Todo *CalendarView::selectedTodo()
3823{ 3829{
3824 Incidence *incidence = currentSelection(); 3830 Incidence *incidence = currentSelection();
3825 if ( incidence && incidence->type() == "Todo" ) { 3831 if ( incidence && incidence->type() == "Todo" ) {
3826 return static_cast<Todo *>( incidence ); 3832 return static_cast<Todo *>( incidence );
3827 } 3833 }
3828 3834
3829 incidence = mTodoList->selectedIncidences().first(); 3835 incidence = mTodoList->selectedIncidences().first();
3830 if ( incidence && incidence->type() == "Todo" ) { 3836 if ( incidence && incidence->type() == "Todo" ) {
3831 return static_cast<Todo *>( incidence ); 3837 return static_cast<Todo *>( incidence );
3832 } 3838 }
3833 3839
3834 return 0; 3840 return 0;
3835} 3841}
3836 3842
3837void CalendarView::dialogClosing(Incidence *in) 3843void CalendarView::dialogClosing(Incidence *in)
3838{ 3844{
3839 // mDialogList.remove(in); 3845 // mDialogList.remove(in);
3840} 3846}
3841 3847
3842void CalendarView::showIncidence() 3848void CalendarView::showIncidence()
3843{ 3849{
3844 mViewerCallerIsSearchDialog = false; 3850 mViewerCallerIsSearchDialog = false;
3845 Incidence *incidence = currentSelection(); 3851 Incidence *incidence = currentSelection();
3846 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3852 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3847 if ( incidence ) { 3853 if ( incidence ) {
3848 ShowIncidenceVisitor v; 3854 ShowIncidenceVisitor v;
3849 v.act( incidence, this ); 3855 v.act( incidence, this );
3850 } 3856 }
3851} 3857}
3852void CalendarView::editIncidenceDescription() 3858void CalendarView::editIncidenceDescription()
3853{ 3859{
3854 mFlagEditDescription = true; 3860 mFlagEditDescription = true;
3855 editIncidence(); 3861 editIncidence();
3856 mFlagEditDescription = false; 3862 mFlagEditDescription = false;
3857} 3863}
3858void CalendarView::editIncidence() 3864void CalendarView::editIncidence()
3859{ 3865{
3860 // qDebug("editIncidence() "); 3866 // qDebug("editIncidence() ");
3861 Incidence *incidence = currentSelection(); 3867 Incidence *incidence = currentSelection();
3862 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3868 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3863 if ( incidence ) { 3869 if ( incidence ) {
3864 EditIncidenceVisitor v; 3870 EditIncidenceVisitor v;
3865 v.act( incidence, this ); 3871 v.act( incidence, this );
3866 } 3872 }
3867} 3873}
3868 3874
3869void CalendarView::deleteIncidence() 3875void CalendarView::deleteIncidence()
3870{ 3876{
3871 Incidence *incidence = currentSelection(); 3877 Incidence *incidence = currentSelection();
3872 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3878 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3873 if ( incidence ) { 3879 if ( incidence ) {
3874 deleteIncidence(incidence); 3880 deleteIncidence(incidence);
3875 } 3881 }
3876} 3882}
3877 3883
3878void CalendarView::showIncidence(Incidence *incidence) 3884void CalendarView::showIncidence(Incidence *incidence)
3879{ 3885{
3880 mViewerCallerIsSearchDialog = false; 3886 mViewerCallerIsSearchDialog = false;
3881 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 3887 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3882 if ( sender() && mDialogManager->getSearchDialog() ) { 3888 if ( sender() && mDialogManager->getSearchDialog() ) {
3883 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 3889 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3884 mViewerCallerIsSearchDialog = true; 3890 mViewerCallerIsSearchDialog = true;
3885 } 3891 }
3886 } 3892 }
3887 if ( incidence ) { 3893 if ( incidence ) {
3888 ShowIncidenceVisitor v; 3894 ShowIncidenceVisitor v;
3889 v.act( incidence, this ); 3895 v.act( incidence, this );
3890 } 3896 }
3891} 3897}
3892 3898
3893void CalendarView::editIncidence(Incidence *incidence) 3899void CalendarView::editIncidence(Incidence *incidence)
3894{ 3900{
3895 if ( incidence ) { 3901 if ( incidence ) {
3896 3902
3897 EditIncidenceVisitor v; 3903 EditIncidenceVisitor v;
3898 v.act( incidence, this ); 3904 v.act( incidence, this );
3899 3905
3900 } 3906 }
3901} 3907}
3902 3908
3903void CalendarView::deleteIncidence(Incidence *incidence) 3909void CalendarView::deleteIncidence(Incidence *incidence)
3904{ 3910{
3905 //qDebug(" CalendarView::deleteIncidence "); 3911 //qDebug(" CalendarView::deleteIncidence ");
3906 if ( incidence ) { 3912 if ( incidence ) {
3907 DeleteIncidenceVisitor v; 3913 DeleteIncidenceVisitor v;
3908 v.act( incidence, this ); 3914 v.act( incidence, this );
3909 } 3915 }
3910} 3916}
3911 3917
3912 3918
3913void CalendarView::lookForOutgoingMessages() 3919void CalendarView::lookForOutgoingMessages()
3914{ 3920{
3915 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3921 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3916 ogd->loadMessages(); 3922 ogd->loadMessages();
3917} 3923}
3918 3924
3919void CalendarView::lookForIncomingMessages() 3925void CalendarView::lookForIncomingMessages()
3920{ 3926{
3921 IncomingDialog *icd = mDialogManager->incomingDialog(); 3927 IncomingDialog *icd = mDialogManager->incomingDialog();
3922 icd->retrieve(); 3928 icd->retrieve();
3923} 3929}
3924 3930
3925bool CalendarView::removeCompletedSubTodos( Todo* t ) 3931bool CalendarView::removeCompletedSubTodos( Todo* t )
3926{ 3932{
3927 bool deleteTodo = true; 3933 bool deleteTodo = true;
3928 QPtrList<Incidence> subTodos; 3934 QPtrList<Incidence> subTodos;
3929 Incidence *aTodo; 3935 Incidence *aTodo;
3930 subTodos = t->relations(); 3936 subTodos = t->relations();
3931 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3937 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3932 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3938 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3933 deleteTodo = false; 3939 deleteTodo = false;
3934 } 3940 }
3935 if ( deleteTodo ) { 3941 if ( deleteTodo ) {
3936 if ( t->isCompleted() && !t->doesRecur()) { 3942 if ( t->isCompleted() && !t->doesRecur()) {
3937 checkExternalId( t ); 3943 checkExternalId( t );
3938 mCalendar->deleteTodo( t ); 3944 mCalendar->deleteTodo( t );
3939 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3945 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3940 } 3946 }
3941 else 3947 else
3942 deleteTodo = false; 3948 deleteTodo = false;
3943 } 3949 }
3944 return deleteTodo; 3950 return deleteTodo;
3945 3951
3946} 3952}
3947void CalendarView::purgeCompleted() 3953void CalendarView::purgeCompleted()
3948{ 3954{
3949 int result = KMessageBox::warningContinueCancel(this, 3955 int result = KMessageBox::warningContinueCancel(this,
3950 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3956 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3951 3957
3952 if (result == KMessageBox::Continue) { 3958 if (result == KMessageBox::Continue) {
3953 3959
3954 QPtrList<Todo> todoCal; 3960 QPtrList<Todo> todoCal;
3955 QPtrList<Todo> rootTodos; 3961 QPtrList<Todo> rootTodos;
3956 //QPtrList<Incidence> rel; 3962 //QPtrList<Incidence> rel;
3957 Todo *aTodo;//, *rTodo; 3963 Todo *aTodo;//, *rTodo;
3958 Incidence *rIncidence; 3964 Incidence *rIncidence;
3959 bool childDelete = false; 3965 bool childDelete = false;
3960 bool deletedOne = true; 3966 bool deletedOne = true;
3961 todoCal = calendar()->todos(); 3967 todoCal = calendar()->todos();
3962 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3968 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3963 if ( !aTodo->relatedTo() ) 3969 if ( !aTodo->relatedTo() )
3964 rootTodos.append( aTodo ); 3970 rootTodos.append( aTodo );
3965 } 3971 }
3966 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3972 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3967 removeCompletedSubTodos( aTodo ); 3973 removeCompletedSubTodos( aTodo );
3968 } 3974 }
3969 3975
3970 updateView(); 3976 updateView();
3971 } 3977 }
3972} 3978}
3973 3979
3974void CalendarView::slotCalendarChanged() 3980void CalendarView::slotCalendarChanged()
3975{ 3981{
3976 ; 3982 ;
3977} 3983}
3978 3984
3979void CalendarView::keyPressEvent ( QKeyEvent *e) 3985void CalendarView::keyPressEvent ( QKeyEvent *e)
3980{ 3986{
3981 //qDebug(" alendarView::keyPressEvent "); 3987 //qDebug(" alendarView::keyPressEvent ");
3982 e->ignore(); 3988 e->ignore();
3983} 3989}
3984 3990
3985 3991
3986bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3992bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3987{ 3993{
3988 // mSyncManager = manager; 3994 // mSyncManager = manager;
3989 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3995 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3990 qDebug("KO: SyncKDE request detected!"); 3996 qDebug("KO: SyncKDE request detected!");
3991 } 3997 }
3992 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3998 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3993 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3999 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3994 return syncCalendar( filename, mode ); 4000 return syncCalendar( filename, mode );
3995} 4001}
3996bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4002bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3997{ 4003{
3998 //mSyncManager = manager; 4004 //mSyncManager = manager;
3999 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4005 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4000 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4006 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4001 if ( resource == "sharp" ) 4007 if ( resource == "sharp" )
4002 syncExternal( 0 ); 4008 syncExternal( 0 );
4003 if ( resource == "phone" ) 4009 if ( resource == "phone" )
4004 syncExternal( 1 ); 4010 syncExternal( 1 );
4005 // pending setmodified 4011 // pending setmodified
4006 return true; 4012 return true;
4007} 4013}
4008void CalendarView::setSyncManager(KSyncManager* manager) 4014void CalendarView::setSyncManager(KSyncManager* manager)
4009{ 4015{
4010 mSyncManager = manager; 4016 mSyncManager = manager;
4011} 4017}
4012 4018
4013void CalendarView::removeSyncInfo( QString syncProfile) 4019void CalendarView::removeSyncInfo( QString syncProfile)
4014{ 4020{
4015 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4021 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4016 mCalendar->removeSyncInfo( syncProfile ); 4022 mCalendar->removeSyncInfo( syncProfile );
4017 4023
4018} 4024}
4019 4025
4020void CalendarView::undo_delete() 4026void CalendarView::undo_delete()
4021{ 4027{
4022 //qDebug("undo_delete() "); 4028 //qDebug("undo_delete() ");
4023 Incidence* undo = mCalendar->undoIncidence(); 4029 Incidence* undo = mCalendar->undoIncidence();
4024 if ( !undo ) { 4030 if ( !undo ) {
4025 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4031 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4026 i18n("KO/Pi")); 4032 i18n("KO/Pi"));
4027 return; 4033 return;
4028 } 4034 }
4029 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4035 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4030 i18n("\nAre you sure you want\nto restore this?"), 4036 i18n("\nAre you sure you want\nto restore this?"),
4031 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4037 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4032 mCalendar->undoDeleteIncidence(); 4038 mCalendar->undoDeleteIncidence();
4033 updateView(); 4039 updateView();
4034 } 4040 }
4035} 4041}
4036 4042
4037void CalendarView::slotViewerClosed() 4043void CalendarView::slotViewerClosed()
4038{ 4044{
4039 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4045 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4040} 4046}
4041 4047
4042void CalendarView::resetFocus() 4048void CalendarView::resetFocus()
4043{ 4049{
4044 if ( mViewerCallerIsSearchDialog ) { 4050 if ( mViewerCallerIsSearchDialog ) {
4045 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4051 if ( mDialogManager->getSearchDialog()->isVisible() ){
4046 mDialogManager->getSearchDialog()->raise(); 4052 mDialogManager->getSearchDialog()->raise();
4047 mDialogManager->getSearchDialog()->setActiveWindow(); 4053 mDialogManager->getSearchDialog()->setActiveWindow();
4048 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4054 mDialogManager->getSearchDialog()->listview()->resetFocus();
4049 } else 4055 } else
4050 mViewerCallerIsSearchDialog = false; 4056 mViewerCallerIsSearchDialog = false;
4051 } 4057 }
4052 if ( !mViewerCallerIsSearchDialog ) { 4058 if ( !mViewerCallerIsSearchDialog ) {
4053 //mViewManager->currentView()->setFocus(); 4059 //mViewManager->currentView()->setFocus();
4054 //qDebug("sssssssssssssssset focus "); 4060 //qDebug("sssssssssssssssset focus ");
4055 topLevelWidget()->raise(); 4061 topLevelWidget()->raise();
4056 setActiveWindow(); 4062 setActiveWindow();
4057 //setFocus(); 4063 //setFocus();
4058 } 4064 }
4059 mViewerCallerIsSearchDialog = false; 4065 mViewerCallerIsSearchDialog = false;
4060} 4066}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 7faf675..7d5cf72 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2113 +1,2126 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 70#include "koimportoldialog.h"
71#endif 71#endif
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75 75
76class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
77{ 77{
78 public: 78 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
81 { 81 {
82 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
86 QLabel *lab; 86 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
88 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
89 QHBox* temphb; 89 QHBox* temphb;
90 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
91 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
92 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
95 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
96 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
98 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
99 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
100 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
101 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
103 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
104 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
105 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
106 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
108 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
109 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
111 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
113 lay->addWidget( ok ); 113 lay->addWidget( ok );
114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
115 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
118 resize( 220, 240 ); 118 resize( 220, 240 );
119 qApp->processEvents(); 119 qApp->processEvents();
120 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
121 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
122 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
123 } 123 }
124 124
125public: 125public:
126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
127 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
128 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
129}; 129};
130 130
131int globalFlagBlockStartup; 131int globalFlagBlockStartup;
132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
133 QMainWindow( parent, name ) 133 QMainWindow( parent, name )
134{ 134{
135 135
136 mClosed = false; 136 mClosed = false;
137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
138 QString confFile = locateLocal("config","korganizerrc"); 138 QString confFile = locateLocal("config","korganizerrc");
139 QFileInfo finf ( confFile ); 139 QFileInfo finf ( confFile );
140 bool showWarning = !finf.exists(); 140 bool showWarning = !finf.exists();
141 setIcon(SmallIcon( "ko24" ) ); 141 setIcon(SmallIcon( "ko24" ) );
142 mBlockAtStartup = true; 142 mBlockAtStartup = true;
143 mFlagKeyPressed = false; 143 mFlagKeyPressed = false;
144 setCaption("KOrganizer/Pi"); 144 setCaption("KO/Pi");
145 KOPrefs *p = KOPrefs::instance(); 145 KOPrefs *p = KOPrefs::instance();
146 KPimGlobalPrefs::instance()->setGlobalConfig(); 146 KPimGlobalPrefs::instance()->setGlobalConfig();
147 if ( p->mHourSize > 22 ) 147 if ( p->mHourSize > 22 )
148 p->mHourSize = 22; 148 p->mHourSize = 22;
149 QMainWindow::ToolBarDock tbd; 149 QMainWindow::ToolBarDock tbd;
150 if ( p->mToolBarHor ) { 150 if ( p->mToolBarHor ) {
151 if ( p->mToolBarUp ) 151 if ( p->mToolBarUp )
152 tbd = Bottom; 152 tbd = Bottom;
153 else 153 else
154 tbd = Top; 154 tbd = Top;
155 } 155 }
156 else { 156 else {
157 if ( p->mToolBarUp ) 157 if ( p->mToolBarUp )
158 tbd = Right; 158 tbd = Right;
159 else 159 else
160 tbd = Left; 160 tbd = Left;
161 } 161 }
162 if ( KOPrefs::instance()->mUseAppColors ) 162 if ( KOPrefs::instance()->mUseAppColors )
163 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 163 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
164 globalFlagBlockStartup = 1; 164 globalFlagBlockStartup = 1;
165 iconToolBar = new QPEToolBar( this ); 165 iconToolBar = new QPEToolBar( this );
166 addToolBar (iconToolBar , tbd ); 166 addToolBar (iconToolBar , tbd );
167 mCalendarModifiedFlag = false; 167 mCalendarModifiedFlag = false;
168 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 168 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
169 splash->setAlignment ( AlignCenter ); 169 splash->setAlignment ( AlignCenter );
170 setCentralWidget( splash ); 170 setCentralWidget( splash );
171#ifndef DESKTOP_VERSION 171#ifndef DESKTOP_VERSION
172 showMaximized(); 172 showMaximized();
173#endif 173#endif
174 174
175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
176 setDefaultPreferences(); 176 setDefaultPreferences();
177 mCalendar = new CalendarLocal(); 177 mCalendar = new CalendarLocal();
178 mView = new CalendarView( mCalendar, this,"mCalendar " ); 178 mView = new CalendarView( mCalendar, this,"mCalendar " );
179 mView->hide(); 179 mView->hide();
180 //mView->resize(splash->size() ); 180 //mView->resize(splash->size() );
181 initActions(); 181 initActions();
182 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 182 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
183 mSyncManager->setBlockSave(false); 183 mSyncManager->setBlockSave(false);
184 mView->setSyncManager(mSyncManager); 184 mView->setSyncManager(mSyncManager);
185#ifndef DESKTOP_VERSION 185#ifndef DESKTOP_VERSION
186 iconToolBar->show(); 186 iconToolBar->show();
187 qApp->processEvents(); 187 qApp->processEvents();
188#endif 188#endif
189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
190 int vh = height() ; 190 int vh = height() ;
191 int vw = width(); 191 int vw = width();
192 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 192 //qDebug("Toolbar hei %d ",iconToolBar->height() );
193 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 193 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
194 vh -= iconToolBar->height(); 194 vh -= iconToolBar->height();
195 } else { 195 } else {
196 vw -= iconToolBar->height(); 196 vw -= iconToolBar->height();
197 } 197 }
198 //mView->setMaximumSize( splash->size() ); 198 //mView->setMaximumSize( splash->size() );
199 //mView->resize( splash->size() ); 199 //mView->resize( splash->size() );
200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
201 mView->readSettings(); 201 mView->readSettings();
202 bool newFile = false; 202 bool newFile = false;
203 if( !QFile::exists( defaultFileName() ) ) { 203 if( !QFile::exists( defaultFileName() ) ) {
204 QFileInfo finfo ( defaultFileName() ); 204 QFileInfo finfo ( defaultFileName() );
205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
206 qDebug("oldfile %s ", oldFile.latin1()); 206 qDebug("oldfile %s ", oldFile.latin1());
207 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 207 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
208 finfo.setFile( oldFile ); 208 finfo.setFile( oldFile );
209 if (finfo.exists() ) { 209 if (finfo.exists() ) {
210 KMessageBox::information( this, message); 210 KMessageBox::information( this, message);
211 mView->openCalendar( oldFile ); 211 mView->openCalendar( oldFile );
212 qApp->processEvents(); 212 qApp->processEvents();
213 } else { 213 } else {
214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
215 finfo.setFile( oldFile ); 215 finfo.setFile( oldFile );
216 if (finfo.exists() ) { 216 if (finfo.exists() ) {
217 KMessageBox::information( this, message); 217 KMessageBox::information( this, message);
218 mView->openCalendar( oldFile ); 218 mView->openCalendar( oldFile );
219 qApp->processEvents(); 219 qApp->processEvents();
220 } 220 }
221 } 221 }
222 mView->saveCalendar( defaultFileName() ); 222 mView->saveCalendar( defaultFileName() );
223 newFile = true; 223 newFile = true;
224 } 224 }
225 225
226 QTime neededSaveTime = QDateTime::currentDateTime().time(); 226 QTime neededSaveTime = QDateTime::currentDateTime().time();
227 mView->openCalendar( defaultFileName() ); 227 mView->openCalendar( defaultFileName() );
228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
229 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 229 qDebug("KO: Calendar loading time: %d ms",msNeeded );
230 230
231 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 231 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
232 KOPrefs::instance()->setAllDefaults(); 232 KOPrefs::instance()->setAllDefaults();
233 int count = mView->addCategories(); 233 int count = mView->addCategories();
234 } 234 }
235 processIncidenceSelection( 0 ); 235 processIncidenceSelection( 0 );
236 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 236 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
237 SLOT( processIncidenceSelection( Incidence * ) ) ); 237 SLOT( processIncidenceSelection( Incidence * ) ) );
238 connect( mView, SIGNAL( modifiedChanged( bool ) ), 238 connect( mView, SIGNAL( modifiedChanged( bool ) ),
239 SLOT( slotModifiedChanged( bool ) ) ); 239 SLOT( slotModifiedChanged( bool ) ) );
240 240
241 241
242 connect( mView, SIGNAL( tempDisableBR(bool) ), 242 connect( mView, SIGNAL( tempDisableBR(bool) ),
243 SLOT( disableBR(bool) ) ); 243 SLOT( disableBR(bool) ) );
244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
245 mView->setModified( false ); 245 mView->setModified( false );
246 mBlockAtStartup = false; 246 mBlockAtStartup = false;
247 mView->setModified( false ); 247 mView->setModified( false );
248 setCentralWidget( mView ); 248 setCentralWidget( mView );
249 globalFlagBlockStartup = 0; 249 globalFlagBlockStartup = 0;
250 mView->show(); 250 mView->show();
251 delete splash; 251 delete splash;
252 if ( newFile ) 252 if ( newFile )
253 mView->updateConfig(); 253 mView->updateConfig();
254 // qApp->processEvents(); 254 // qApp->processEvents();
255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
256 //fillSyncMenu(); 256 //fillSyncMenu();
257 257
258 258
259 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 259 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
260 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 260 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
261 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 261 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
262 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 262 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
263 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 263 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
264 mSyncManager->setDefaultFileName( sentSyncFile()); 264 mSyncManager->setDefaultFileName( sentSyncFile());
265 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 265 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
266 mSyncManager->fillSyncMenu(); 266 mSyncManager->fillSyncMenu();
267 267
268 268
269 269
270 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 270 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
271 if ( showWarning ) { 271 if ( showWarning ) {
272 KMessageBox::information( this, 272 KMessageBox::information( this,
273 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 273 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
274 qApp->processEvents(); 274 qApp->processEvents();
275 mView->dialogManager()->showSyncOptions(); 275 mView->dialogManager()->showSyncOptions();
276 } 276 }
277 277
278 //US listen for result adressed from Ka/Pi 278 //US listen for result adressed from Ka/Pi
279#ifndef DESKTOP_VERSION 279#ifndef DESKTOP_VERSION
280 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 280 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
281#endif 281#endif
282#ifndef DESKTOP_VERSION 282#ifndef DESKTOP_VERSION
283 infrared = 0; 283 infrared = 0;
284#endif 284#endif
285 updateWeek( mView->startDate() ); 285 updateWeek( mView->startDate() );
286 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 286 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
287 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 287 SLOT( updateWeekNum( const KCal::DateList & ) ) );
288 mBRdisabled = false; 288 mBRdisabled = false;
289 //toggleBeamReceive(); 289 //toggleBeamReceive();
290} 290}
291MainWindow::~MainWindow() 291MainWindow::~MainWindow()
292{ 292{
293 //qDebug("MainWindow::~MainWindow() "); 293 //qDebug("MainWindow::~MainWindow() ");
294 //save toolbar location 294 //save toolbar location
295 delete mCalendar; 295 delete mCalendar;
296 delete mSyncManager; 296 delete mSyncManager;
297#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
298 if ( infrared ) 298 if ( infrared )
299 delete infrared; 299 delete infrared;
300#endif 300#endif
301 301
302 302
303} 303}
304 304
305void MainWindow::disableBR(bool b) 305void MainWindow::disableBR(bool b)
306{ 306{
307#ifndef DESKTOP_VERSION 307#ifndef DESKTOP_VERSION
308 if ( b ) { 308 if ( b ) {
309 if ( infrared ) { 309 if ( infrared ) {
310 toggleBeamReceive(); 310 toggleBeamReceive();
311 mBRdisabled = true; 311 mBRdisabled = true;
312 } 312 }
313 mBRdisabled = true; 313 mBRdisabled = true;
314 } else { 314 } else {
315 if ( mBRdisabled ) { 315 if ( mBRdisabled ) {
316 mBRdisabled = false; 316 mBRdisabled = false;
317 //makes no sense,because other cal ap is probably running 317 //makes no sense,because other cal ap is probably running
318 // toggleBeamReceive(); 318 // toggleBeamReceive();
319 } 319 }
320 } 320 }
321#endif 321#endif
322 322
323} 323}
324bool MainWindow::beamReceiveEnabled() 324bool MainWindow::beamReceiveEnabled()
325{ 325{
326#ifndef DESKTOP_VERSION 326#ifndef DESKTOP_VERSION
327 return ( infrared != 0 ); 327 return ( infrared != 0 );
328#endif 328#endif
329 return false; 329 return false;
330} 330}
331 331
332void MainWindow::toggleBeamReceive() 332void MainWindow::toggleBeamReceive()
333{ 333{
334 if ( mBRdisabled ) 334 if ( mBRdisabled )
335 return; 335 return;
336#ifndef DESKTOP_VERSION 336#ifndef DESKTOP_VERSION
337 if ( infrared ) { 337 if ( infrared ) {
338 qDebug("disable BeamReceive "); 338 qDebug("disable BeamReceive ");
339 delete infrared; 339 delete infrared;
340 infrared = 0; 340 infrared = 0;
341 brAction->setOn(false); 341 brAction->setOn(false);
342 return; 342 return;
343 } 343 }
344 qDebug("enable BeamReceive "); 344 qDebug("enable BeamReceive ");
345 brAction->setOn(true); 345 brAction->setOn(true);
346 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 346 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
347 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 347 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
348#endif 348#endif
349} 349}
350void MainWindow::showMaximized () 350void MainWindow::showMaximized ()
351{ 351{
352#ifndef DESKTOP_VERSION 352#ifndef DESKTOP_VERSION
353 if ( ! globalFlagBlockStartup ) 353 if ( ! globalFlagBlockStartup )
354 if ( mClosed ) 354 if ( mClosed )
355 mView->goToday(); 355 mView->goToday();
356#endif 356#endif
357 QWidget::showMaximized () ; 357 QWidget::showMaximized () ;
358 mClosed = false; 358 mClosed = false;
359} 359}
360void MainWindow::closeEvent( QCloseEvent* ce ) 360void MainWindow::closeEvent( QCloseEvent* ce )
361{ 361{
362 362
363 363
364 364
365 if ( ! KOPrefs::instance()->mAskForQuit ) { 365 if ( ! KOPrefs::instance()->mAskForQuit ) {
366 saveOnClose(); 366 saveOnClose();
367 mClosed = true; 367 mClosed = true;
368 ce->accept(); 368 ce->accept();
369 return; 369 return;
370 370
371 } 371 }
372 372
373 switch( QMessageBox::information( this, "KO/Pi", 373 switch( QMessageBox::information( this, "KO/Pi",
374 i18n("Do you really want\nto close KO/Pi?"), 374 i18n("Do you really want\nto close KO/Pi?"),
375 i18n("Close"), i18n("No"), 375 i18n("Close"), i18n("No"),
376 0, 0 ) ) { 376 0, 0 ) ) {
377 case 0: 377 case 0:
378 saveOnClose(); 378 saveOnClose();
379 mClosed = true; 379 mClosed = true;
380 ce->accept(); 380 ce->accept();
381 break; 381 break;
382 case 1: 382 case 1:
383 ce->ignore(); 383 ce->ignore();
384 break; 384 break;
385 case 2: 385 case 2:
386 386
387 default: 387 default:
388 break; 388 break;
389 } 389 }
390 390
391 391
392} 392}
393 393
394void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 394void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
395{ 395{
396 QDataStream stream( data, IO_ReadOnly ); 396 QDataStream stream( data, IO_ReadOnly );
397 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 397 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
398 //QString datamess; 398 //QString datamess;
399 //qDebug("message "); 399 //qDebug("message ");
400 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 400 qDebug("KO: QCOP message received: %s ", cmsg.data() );
401 401
402 if ( cmsg == "setDocument(QString)" ) { 402 if ( cmsg == "setDocument(QString)" ) {
403 QDataStream stream( data, IO_ReadOnly ); 403 QDataStream stream( data, IO_ReadOnly );
404 QString fileName; 404 QString fileName;
405 stream >> fileName; 405 stream >> fileName;
406 //qDebug("filename %s ", fileName.latin1()); 406 //qDebug("filename %s ", fileName.latin1());
407 showMaximized(); 407 showMaximized();
408 raise(); 408 raise();
409 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 409 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
410 mSyncManager->slotSyncMenu( 1002 ); 410 mSyncManager->slotSyncMenu( 1002 );
411 return; 411 return;
412 } 412 }
413 413
414 if ( cmsg == "-writeFile" ) { 414 if ( cmsg == "-writeFile" ) {
415 // I made from the "-writeFile" an "-writeAlarm" 415 // I made from the "-writeFile" an "-writeAlarm"
416 mView->viewManager()->showWhatsNextView(); 416 mView->viewManager()->showWhatsNextView();
417 mCalendar->checkAlarmForIncidence( 0, true); 417 mCalendar->checkAlarmForIncidence( 0, true);
418 showMaximized(); 418 showMaximized();
419 raise(); 419 raise();
420 return; 420 return;
421 421
422 } 422 }
423 if ( cmsg == "-writeFileSilent" ) { 423 if ( cmsg == "-writeFileSilent" ) {
424 // I made from the "-writeFile" an "-writeAlarm" 424 // I made from the "-writeFile" an "-writeAlarm"
425 // mView->viewManager()->showWhatsNextView(); 425 // mView->viewManager()->showWhatsNextView();
426 mCalendar->checkAlarmForIncidence( 0, true); 426 mCalendar->checkAlarmForIncidence( 0, true);
427 //showMaximized(); 427 //showMaximized();
428 //raise(); 428 //raise();
429 hide(); 429 hide();
430 return; 430 return;
431 } 431 }
432 if ( cmsg == "-newCountdown" ) { 432 if ( cmsg == "-newCountdown" ) {
433 qDebug("newCountdown "); 433 qDebug("newCountdown ");
434 434
435 } 435 }
436 QString msg ; 436 QString msg ;
437 QString allmsg = cmsg; 437 QString allmsg = cmsg;
438 while ( allmsg.length() > 0 ) { 438 while ( allmsg.length() > 0 ) {
439 int nextC = allmsg.find( "-", 1 ); 439 int nextC = allmsg.find( "-", 1 );
440 if ( nextC == -1 ) { 440 if ( nextC == -1 ) {
441 msg = allmsg; 441 msg = allmsg;
442 allmsg = ""; 442 allmsg = "";
443 } else{ 443 } else{
444 msg = allmsg.left( nextC ); 444 msg = allmsg.left( nextC );
445 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 445 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
446 } 446 }
447 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 447 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
448 if ( msg == "-newEvent" ) { 448 if ( msg == "-newEvent" ) {
449 mView->newEvent(); 449 mView->newEvent();
450 } 450 }
451 if ( msg == "-newTodo" ) { 451 if ( msg == "-newTodo" ) {
452 mView->newTodo(); 452 mView->newTodo();
453 453
454 } 454 }
455 if ( msg == "-showWN" ) { 455 if ( msg == "-showWN" ) {
456 mView->viewManager()->showWhatsNextView(); 456 mView->viewManager()->showWhatsNextView();
457 } 457 }
458 if ( msg == "-showTodo" ) { 458 if ( msg == "-showTodo" ) {
459 mView->viewManager()->showTodoView(); 459 mView->viewManager()->showTodoView();
460 } 460 }
461 if ( msg == "-showList" ) { 461 if ( msg == "-showList" ) {
462 mView->viewManager()->showListView(); 462 mView->viewManager()->showListView();
463 } 463 }
464 else if ( msg == "-showDay" ) { 464 else if ( msg == "-showDay" ) {
465 mView->viewManager()->showDayView(); 465 mView->viewManager()->showDayView();
466 } 466 }
467 else if ( msg == "-showWWeek" ) { 467 else if ( msg == "-showWWeek" ) {
468 mView->viewManager()->showWorkWeekView(); 468 mView->viewManager()->showWorkWeekView();
469 } 469 }
470 else if ( msg == "-ringSync" ) { 470 else if ( msg == "-ringSync" ) {
471 mSyncManager->multiSync( false ); 471 mSyncManager->multiSync( false );
472 } 472 }
473 else if ( msg == "-showWeek" ) { 473 else if ( msg == "-showWeek" ) {
474 mView->viewManager()->showWeekView(); 474 mView->viewManager()->showWeekView();
475 } 475 }
476 else if ( msg == "-showTodo" ) { 476 else if ( msg == "-showTodo" ) {
477 mView->viewManager()->showTodoView(); 477 mView->viewManager()->showTodoView();
478 } 478 }
479 else if ( msg == "-showJournal" ) { 479 else if ( msg == "-showJournal" ) {
480 mView->dateNavigator()->selectDates( 1 ); 480 mView->dateNavigator()->selectDates( 1 );
481 mView->dateNavigator()->selectToday(); 481 mView->dateNavigator()->selectToday();
482 mView->viewManager()->showJournalView(); 482 mView->viewManager()->showJournalView();
483 } 483 }
484 else if ( msg == "-showKO" ) { 484 else if ( msg == "-showKO" ) {
485 mView->viewManager()->showNextXView(); 485 mView->viewManager()->showNextXView();
486 } 486 }
487 else if ( msg == "-showWNext" || msg == "nextView()" ) { 487 else if ( msg == "-showWNext" || msg == "nextView()" ) {
488 mView->viewManager()->showWhatsNextView(); 488 mView->viewManager()->showWhatsNextView();
489 } 489 }
490 else if ( msg == "-showNextXView" ) { 490 else if ( msg == "-showNextXView" ) {
491 mView->viewManager()->showNextXView(); 491 mView->viewManager()->showNextXView();
492 } 492 }
493 493
494 494
495 } 495 }
496 496
497 showMaximized(); 497 showMaximized();
498 raise(); 498 raise();
499} 499}
500 500
501QPixmap MainWindow::loadPixmap( QString name ) 501QPixmap MainWindow::loadPixmap( QString name )
502{ 502{
503 return SmallIcon( name ); 503 return SmallIcon( name );
504 504
505} 505}
506void MainWindow::initActions() 506void MainWindow::initActions()
507{ 507{
508 //KOPrefs::instance()->mShowFullMenu 508 //KOPrefs::instance()->mShowFullMenu
509 iconToolBar->clear(); 509 iconToolBar->clear();
510 KOPrefs *p = KOPrefs::instance(); 510 KOPrefs *p = KOPrefs::instance();
511 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 511 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
512 512
513 QPopupMenu *viewMenu = new QPopupMenu( this ); 513 QPopupMenu *viewMenu = new QPopupMenu( this );
514 QPopupMenu *actionMenu = new QPopupMenu( this ); 514 QPopupMenu *actionMenu = new QPopupMenu( this );
515 QPopupMenu *importMenu = new QPopupMenu( this ); 515 QPopupMenu *importMenu = new QPopupMenu( this );
516 QPopupMenu *importMenu_X = new QPopupMenu( this ); 516 QPopupMenu *importMenu_X = new QPopupMenu( this );
517 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 517 QPopupMenu *exportMenu_X = new QPopupMenu( this );
518 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 518 QPopupMenu *beamMenu_X = new QPopupMenu( this );
519 selectFilterMenu = new QPopupMenu( this ); 519 selectFilterMenu = new QPopupMenu( this );
520 selectFilterMenu->setCheckable( true ); 520 selectFilterMenu->setCheckable( true );
521 syncMenu = new QPopupMenu( this ); 521 syncMenu = new QPopupMenu( this );
522 configureAgendaMenu = new QPopupMenu( this ); 522 configureAgendaMenu = new QPopupMenu( this );
523 configureToolBarMenu = new QPopupMenu( this ); 523 configureToolBarMenu = new QPopupMenu( this );
524 QPopupMenu *helpMenu = new QPopupMenu( this ); 524 QPopupMenu *helpMenu = new QPopupMenu( this );
525 QIconSet icon; 525 QIconSet icon;
526 int pixWid = 22, pixHei = 22; 526 int pixWid = 22, pixHei = 22;
527 QString pathString = ""; 527 QString pathString = "";
528 if ( !p->mToolBarMiniIcons ) { 528 if ( !p->mToolBarMiniIcons ) {
529 if ( QApplication::desktop()->width() < 480 ) { 529 if ( QApplication::desktop()->width() < 480 ) {
530 pathString += "icons16/"; 530 pathString += "icons16/";
531 pixWid = 18; pixHei = 16; 531 pixWid = 18; pixHei = 16;
532 } 532 }
533 } else { 533 } else {
534 pathString += "iconsmini/"; 534 pathString += "iconsmini/";
535 pixWid = 18; pixHei = 16; 535 pixWid = 18; pixHei = 16;
536 } 536 }
537 if ( KOPrefs::instance()->mShowFullMenu ) { 537 if ( KOPrefs::instance()->mShowFullMenu ) {
538 QMenuBar *menuBar1; 538 QMenuBar *menuBar1;
539 menuBar1 = menuBar(); 539 menuBar1 = menuBar();
540 menuBar1->insertItem( i18n("File"), importMenu ); 540 menuBar1->insertItem( i18n("File"), importMenu );
541 menuBar1->insertItem( i18n("View"), viewMenu ); 541 menuBar1->insertItem( i18n("View"), viewMenu );
542 menuBar1->insertItem( i18n("Actions"), actionMenu ); 542 menuBar1->insertItem( i18n("Actions"), actionMenu );
543#ifdef DESKTOP_VERSION 543#ifdef DESKTOP_VERSION
544 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 544 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
545 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 545 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
546#else 546#else
547 menuBar1->insertItem( i18n("Sync"), syncMenu ); 547 menuBar1->insertItem( i18n("Sync"), syncMenu );
548 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 548 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
549#endif 549#endif
550 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 550 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
551 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 551 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
552 menuBar1->insertItem( i18n("Help"), helpMenu ); 552 menuBar1->insertItem( i18n("Help"), helpMenu );
553 } else { 553 } else {
554 QPEMenuBar *menuBar1; 554 QPEMenuBar *menuBar1;
555 menuBar1 = new QPEMenuBar( iconToolBar ); 555 menuBar1 = new QPEMenuBar( iconToolBar );
556 QPopupMenu *menuBar = new QPopupMenu( this ); 556 QPopupMenu *menuBar = new QPopupMenu( this );
557 icon = loadPixmap( pathString + "z_menu" ); 557 icon = loadPixmap( pathString + "z_menu" );
558 menuBar1->insertItem( icon.pixmap(), menuBar); 558 menuBar1->insertItem( icon.pixmap(), menuBar);
559 //menuBar1->insertItem( i18n("ME"), menuBar); 559 //menuBar1->insertItem( i18n("ME"), menuBar);
560 menuBar->insertItem( i18n("File"), importMenu ); 560 menuBar->insertItem( i18n("File"), importMenu );
561 menuBar->insertItem( i18n("View"), viewMenu ); 561 menuBar->insertItem( i18n("View"), viewMenu );
562 menuBar->insertItem( i18n("Actions"), actionMenu ); 562 menuBar->insertItem( i18n("Actions"), actionMenu );
563 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 563 menuBar->insertItem( i18n("Synchronize"), syncMenu );
564 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 564 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
565 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 565 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
566 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 566 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
567 menuBar->insertItem( i18n("Help"), helpMenu ); 567 menuBar->insertItem( i18n("Help"), helpMenu );
568 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 568 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
569 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 569 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
570 } 570 }
571 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 571 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
572 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 572 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
573 mWeekBgColor = iconToolBar->backgroundColor(); 573 mWeekBgColor = iconToolBar->backgroundColor();
574 mWeekPixmap.resize( pixWid , pixHei ); 574 mWeekPixmap.resize( pixWid , pixHei );
575 mWeekPixmap.fill( mWeekBgColor ); 575 mWeekPixmap.fill( mWeekBgColor );
576 icon = mWeekPixmap; 576 icon = mWeekPixmap;
577 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 577 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
578 if ( p-> mShowIconWeekNum ) 578 if ( p-> mShowIconWeekNum )
579 mWeekAction->addTo( iconToolBar ); 579 mWeekAction->addTo( iconToolBar );
580 mWeekFont = font(); 580 mWeekFont = font();
581 581
582 int fontPoint = mWeekFont.pointSize(); 582 int fontPoint = mWeekFont.pointSize();
583 QFontMetrics f( mWeekFont ); 583 QFontMetrics f( mWeekFont );
584 int fontWid = f.width( "30" ); 584 int fontWid = f.width( "30" );
585 while ( fontWid > pixWid ) { 585 while ( fontWid > pixWid ) {
586 --fontPoint; 586 --fontPoint;
587 mWeekFont.setPointSize( fontPoint ); 587 mWeekFont.setPointSize( fontPoint );
588 QFontMetrics f( mWeekFont ); 588 QFontMetrics f( mWeekFont );
589 fontWid = f.width( "30" ); 589 fontWid = f.width( "30" );
590 qDebug("dec-- "); 590 qDebug("dec-- ");
591 } 591 }
592 592
593 connect( mWeekAction, SIGNAL( activated() ), 593 connect( mWeekAction, SIGNAL( activated() ),
594 this, SLOT( weekAction() ) ); 594 this, SLOT( weekAction() ) );
595 595
596 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 596 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
597 597
598 //#endif 598 //#endif
599 // ****************** 599 // ******************
600 QAction *action; 600 QAction *action;
601 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 601 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
602 configureToolBarMenu->setCheckable( true ); 602 configureToolBarMenu->setCheckable( true );
603 603
604 604
605 configureAgendaMenu->setCheckable( true ); 605 configureAgendaMenu->setCheckable( true );
606 int iii ; 606 int iii ;
607 for ( iii = 1;iii<= 10 ;++iii ){ 607 for ( iii = 1;iii<= 10 ;++iii ){
608 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 608 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
609 } 609 }
610 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 610 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
611 611
612 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 612 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
613 this, SLOT( showConfigureAgenda( ) ) ); 613 this, SLOT( showConfigureAgenda( ) ) );
614 614
615 icon = loadPixmap( pathString + "configure" ); 615 icon = loadPixmap( pathString + "configure" );
616 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 616 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
617 action->addTo( actionMenu ); 617 action->addTo( actionMenu );
618 connect( action, SIGNAL( activated() ), 618 connect( action, SIGNAL( activated() ),
619 mView, SLOT( edit_options() ) ); 619 mView, SLOT( edit_options() ) );
620 actionMenu->insertSeparator(); 620 actionMenu->insertSeparator();
621 621
622 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 622 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
623 action->addTo( actionMenu ); 623 action->addTo( actionMenu );
624 connect( action, SIGNAL( activated() ), 624 connect( action, SIGNAL( activated() ),
625 mView, SLOT( undo_delete() ) ); 625 mView, SLOT( undo_delete() ) );
626 actionMenu->insertSeparator(); 626 actionMenu->insertSeparator();
627 627
628 icon = loadPixmap( pathString + "newevent" ); 628 icon = loadPixmap( pathString + "newevent" );
629 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 629 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
630 configureToolBarMenu->insertSeparator(); 630 configureToolBarMenu->insertSeparator();
631 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 631 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
632 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 632 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
633 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 633 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
634 ne_action->addTo( actionMenu ); 634 ne_action->addTo( actionMenu );
635 connect( ne_action, SIGNAL( activated() ), 635 connect( ne_action, SIGNAL( activated() ),
636 mView, SLOT( newEvent() ) ); 636 mView, SLOT( newEvent() ) );
637 icon = loadPixmap( pathString + "newtodo" ); 637 icon = loadPixmap( pathString + "newtodo" );
638 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 638 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
639 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 639 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
640 nt_action->addTo( actionMenu ); 640 nt_action->addTo( actionMenu );
641 connect( nt_action, SIGNAL( activated() ), 641 connect( nt_action, SIGNAL( activated() ),
642 mView, SLOT( newTodo() ) ); 642 mView, SLOT( newTodo() ) );
643 643
644 icon = loadPixmap( pathString + "today" ); 644 icon = loadPixmap( pathString + "today" );
645 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 645 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
646 today_action->addTo( viewMenu ); 646 today_action->addTo( viewMenu );
647 connect( today_action, SIGNAL( activated() ), 647 connect( today_action, SIGNAL( activated() ),
648 mView, SLOT( goToday() ) ); 648 mView, SLOT( goToday() ) );
649 viewMenu->insertSeparator(); 649 viewMenu->insertSeparator();
650 650
651 icon = loadPixmap( pathString + "navi" ); 651 icon = loadPixmap( pathString + "navi" );
652 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 652 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
653 action->addTo( viewMenu ); 653 action->addTo( viewMenu );
654 connect( action, SIGNAL( activated() ), 654 connect( action, SIGNAL( activated() ),
655 mView, SLOT( toggleDateNavigatorWidget() ) ); 655 mView, SLOT( toggleDateNavigatorWidget() ) );
656 mToggleNav = action ; 656 mToggleNav = action ;
657 icon = loadPixmap( pathString + "filter" ); 657 icon = loadPixmap( pathString + "filter" );
658 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 658 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
659 action->addTo( viewMenu ); 659 action->addTo( viewMenu );
660 connect( action, SIGNAL( activated() ), 660 connect( action, SIGNAL( activated() ),
661 mView, SLOT( toggleFilter() ) ); 661 mView, SLOT( toggleFilter() ) );
662 mToggleFilter = action; 662 mToggleFilter = action;
663 icon = loadPixmap( pathString + "allday" ); 663 icon = loadPixmap( pathString + "allday" );
664 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 664 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
665 action->addTo( viewMenu ); 665 action->addTo( viewMenu );
666 connect( action, SIGNAL( activated() ), 666 connect( action, SIGNAL( activated() ),
667 mView, SLOT( toggleAllDaySize() ) ); 667 mView, SLOT( toggleAllDaySize() ) );
668 mToggleAllday = action; 668 mToggleAllday = action;
669 669
670 670
671 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 671 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
672 mToggleNav, SLOT( setEnabled ( bool ) ) ); 672 mToggleNav, SLOT( setEnabled ( bool ) ) );
673 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 673 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
674 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 674 mToggleFilter, SLOT( setEnabled ( bool ) ) );
675 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 675 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
676 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 676 mToggleAllday, SLOT( setEnabled ( bool ) ) );
677 677
678 viewMenu->insertSeparator(); 678 viewMenu->insertSeparator();
679 icon = loadPixmap( pathString + "picker" ); 679 icon = loadPixmap( pathString + "picker" );
680 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 680 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
681 action->addTo( viewMenu ); 681 action->addTo( viewMenu );
682 connect( action, SIGNAL( activated() ), 682 connect( action, SIGNAL( activated() ),
683 mView, SLOT( showDatePicker() ) ); 683 mView, SLOT( showDatePicker() ) );
684 action->addTo( iconToolBar ); 684 action->addTo( iconToolBar );
685 viewMenu->insertSeparator(); 685 viewMenu->insertSeparator();
686 icon = loadPixmap( pathString + "list" ); 686 icon = loadPixmap( pathString + "list" );
687 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 687 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
688 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 688 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
689 showlist_action->addTo( viewMenu ); 689 showlist_action->addTo( viewMenu );
690 connect( showlist_action, SIGNAL( activated() ), 690 connect( showlist_action, SIGNAL( activated() ),
691 mView->viewManager(), SLOT( showListView() ) ); 691 mView->viewManager(), SLOT( showListView() ) );
692 692
693 693
694 icon = loadPixmap( pathString + "day" ); 694 icon = loadPixmap( pathString + "day" );
695 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 695 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
696 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 696 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
697 day1_action->addTo( viewMenu ); 697 day1_action->addTo( viewMenu );
698 // action->addTo( toolBar ); 698 // action->addTo( toolBar );
699 connect( day1_action, SIGNAL( activated() ), 699 connect( day1_action, SIGNAL( activated() ),
700 mView->viewManager(), SLOT( showDayView() ) ); 700 mView->viewManager(), SLOT( showDayView() ) );
701 701
702 icon = loadPixmap( pathString + "workweek" ); 702 icon = loadPixmap( pathString + "workweek" );
703 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 703 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
704 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 704 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
705 day5_action->addTo( viewMenu ); 705 day5_action->addTo( viewMenu );
706 connect( day5_action, SIGNAL( activated() ), 706 connect( day5_action, SIGNAL( activated() ),
707 mView->viewManager(), SLOT( showWorkWeekView() ) ); 707 mView->viewManager(), SLOT( showWorkWeekView() ) );
708 708
709 icon = loadPixmap( pathString + "week" ); 709 icon = loadPixmap( pathString + "week" );
710 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 710 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
711 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 711 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
712 day7_action->addTo( viewMenu ); 712 day7_action->addTo( viewMenu );
713 connect( day7_action, SIGNAL( activated() ), 713 connect( day7_action, SIGNAL( activated() ),
714 mView->viewManager(), SLOT( showWeekView() ) ); 714 mView->viewManager(), SLOT( showWeekView() ) );
715 715
716 icon = loadPixmap( pathString + "workweek2" ); 716 icon = loadPixmap( pathString + "workweek2" );
717 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 717 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
718 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 718 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
719 day6_action->addTo( viewMenu ); 719 day6_action->addTo( viewMenu );
720 connect( day6_action, SIGNAL( activated() ), 720 connect( day6_action, SIGNAL( activated() ),
721 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 721 mView->viewManager(), SLOT( showMonthViewWeek() ) );
722 722
723 icon = loadPixmap( pathString + "month" ); 723 icon = loadPixmap( pathString + "month" );
724 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 724 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
725 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 725 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
726 month_action->addTo( viewMenu ); 726 month_action->addTo( viewMenu );
727 connect( month_action, SIGNAL( activated() ), 727 connect( month_action, SIGNAL( activated() ),
728 mView->viewManager(), SLOT( showMonthView() ) ); 728 mView->viewManager(), SLOT( showMonthView() ) );
729 729
730 icon = loadPixmap( pathString + "todo" ); 730 icon = loadPixmap( pathString + "todo" );
731 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 731 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
732 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 732 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
733 todoview_action->addTo( viewMenu ); 733 todoview_action->addTo( viewMenu );
734 connect( todoview_action, SIGNAL( activated() ), 734 connect( todoview_action, SIGNAL( activated() ),
735 mView->viewManager(), SLOT( showTodoView() ) ); 735 mView->viewManager(), SLOT( showTodoView() ) );
736 736
737 icon = loadPixmap( pathString + "journal" ); 737 icon = loadPixmap( pathString + "journal" );
738 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 738 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
739 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 739 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
740 viewjournal_action->addTo( viewMenu ); 740 viewjournal_action->addTo( viewMenu );
741 connect( viewjournal_action, SIGNAL( activated() ), 741 connect( viewjournal_action, SIGNAL( activated() ),
742 mView->viewManager(), SLOT( showJournalView() ) ); 742 mView->viewManager(), SLOT( showJournalView() ) );
743 743
744 icon = loadPixmap( pathString + "xdays" ); 744 icon = loadPixmap( pathString + "xdays" );
745 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 745 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
746 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 746 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
747 xdays_action->addTo( viewMenu ); 747 xdays_action->addTo( viewMenu );
748 connect( xdays_action, SIGNAL( activated() ), 748 connect( xdays_action, SIGNAL( activated() ),
749 mView->viewManager(), SLOT( showNextXView() ) ); 749 mView->viewManager(), SLOT( showNextXView() ) );
750 750
751 icon = loadPixmap( pathString + "whatsnext" ); 751 icon = loadPixmap( pathString + "whatsnext" );
752 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 752 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
753 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 753 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
754 whatsnext_action->addTo( viewMenu ); 754 whatsnext_action->addTo( viewMenu );
755 connect( whatsnext_action, SIGNAL( activated() ), 755 connect( whatsnext_action, SIGNAL( activated() ),
756 mView->viewManager(), SLOT( showWhatsNextView() ) ); 756 mView->viewManager(), SLOT( showWhatsNextView() ) );
757 757
758#if 0 758#if 0
759 action = new QAction( "view_timespan", "Time Span", 0, this ); 759 action = new QAction( "view_timespan", "Time Span", 0, this );
760 action->addTo( viewMenu ); 760 action->addTo( viewMenu );
761 connect( action, SIGNAL( activated() ), 761 connect( action, SIGNAL( activated() ),
762 mView->viewManager(), SLOT( showTimeSpanView() ) ); 762 mView->viewManager(), SLOT( showTimeSpanView() ) );
763#endif 763#endif
764 764
765 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 765 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
766 this ); 766 this );
767 mNewSubTodoAction->addTo( actionMenu ); 767 mNewSubTodoAction->addTo( actionMenu );
768 connect( mNewSubTodoAction, SIGNAL( activated() ), 768 connect( mNewSubTodoAction, SIGNAL( activated() ),
769 mView, SLOT( newSubTodo() ) ); 769 mView, SLOT( newSubTodo() ) );
770 770
771 actionMenu->insertSeparator(); 771 actionMenu->insertSeparator();
772 772
773 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 773 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
774 mShowAction->addTo( actionMenu ); 774 mShowAction->addTo( actionMenu );
775 connect( mShowAction, SIGNAL( activated() ), 775 connect( mShowAction, SIGNAL( activated() ),
776 mView, SLOT( showIncidence() ) ); 776 mView, SLOT( showIncidence() ) );
777 777
778 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 778 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
779 mEditAction->addTo( actionMenu ); 779 mEditAction->addTo( actionMenu );
780 connect( mEditAction, SIGNAL( activated() ), 780 connect( mEditAction, SIGNAL( activated() ),
781 mView, SLOT( editIncidence() ) ); 781 mView, SLOT( editIncidence() ) );
782 782
783 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 783 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
784 mDeleteAction->addTo( actionMenu ); 784 mDeleteAction->addTo( actionMenu );
785 connect( mDeleteAction, SIGNAL( activated() ), 785 connect( mDeleteAction, SIGNAL( activated() ),
786 mView, SLOT( deleteIncidence() ) ); 786 mView, SLOT( deleteIncidence() ) );
787 787
788 788
789 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 789 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
790 mCloneAction->addTo( actionMenu ); 790 mCloneAction->addTo( actionMenu );
791 connect( mCloneAction, SIGNAL( activated() ), 791 connect( mCloneAction, SIGNAL( activated() ),
792 mView, SLOT( cloneIncidence() ) ); 792 mView, SLOT( cloneIncidence() ) );
793 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 793 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
794 mMoveAction->addTo( actionMenu ); 794 mMoveAction->addTo( actionMenu );
795 connect( mMoveAction, SIGNAL( activated() ), 795 connect( mMoveAction, SIGNAL( activated() ),
796 mView, SLOT( moveIncidence() ) ); 796 mView, SLOT( moveIncidence() ) );
797 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 797 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
798 mBeamAction->addTo( actionMenu ); 798 mBeamAction->addTo( actionMenu );
799 connect( mBeamAction, SIGNAL( activated() ), 799 connect( mBeamAction, SIGNAL( activated() ),
800 mView, SLOT( beamIncidence() ) ); 800 mView, SLOT( beamIncidence() ) );
801 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 801 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
802 mCancelAction->addTo( actionMenu ); 802 mCancelAction->addTo( actionMenu );
803 connect( mCancelAction, SIGNAL( activated() ), 803 connect( mCancelAction, SIGNAL( activated() ),
804 mView, SLOT( toggleCancelIncidence() ) ); 804 mView, SLOT( toggleCancelIncidence() ) );
805 805
806 actionMenu->insertSeparator(); 806 actionMenu->insertSeparator();
807 807
808 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 808 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
809 this ); 809 this );
810 action->addTo( actionMenu ); 810 action->addTo( actionMenu );
811 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 811 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
812 812
813 icon = loadPixmap( pathString + "search" ); 813 icon = loadPixmap( pathString + "search" );
814 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 814 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
815 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 815 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
816 search_action->addTo( actionMenu ); 816 search_action->addTo( actionMenu );
817 connect( search_action, SIGNAL( activated() ), 817 connect( search_action, SIGNAL( activated() ),
818 mView->dialogManager(), SLOT( showSearchDialog() ) ); 818 mView->dialogManager(), SLOT( showSearchDialog() ) );
819 819
820 820
821 821
822 if ( KOPrefs::instance()->mShowFullMenu ) { 822 if ( KOPrefs::instance()->mShowFullMenu ) {
823 actionMenu->insertSeparator(); 823 actionMenu->insertSeparator();
824 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 824 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
825 825
826 } 826 }
827 // actionMenu->insertSeparator(); 827 // actionMenu->insertSeparator();
828 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 828 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
829 this ); 829 this );
830 action->addTo( importMenu_X ); 830 action->addTo( importMenu_X );
831 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 831 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
832 action = new QAction( "import_quick", i18n("Import last file"), 0, 832 action = new QAction( "import_quick", i18n("Import last file"), 0,
833 this ); 833 this );
834 action->addTo( importMenu_X ); 834 action->addTo( importMenu_X );
835 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 835 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
836 importMenu_X->insertSeparator(); 836 importMenu_X->insertSeparator();
837 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 837 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
838 this ); 838 this );
839 action->addTo( importMenu_X ); 839 action->addTo( importMenu_X );
840 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 840 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
841 //#ifndef DESKTOP_VERSION 841 //#ifndef DESKTOP_VERSION
842 importMenu_X->insertSeparator(); 842 importMenu_X->insertSeparator();
843 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 843 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
844 this ); 844 this );
845 action->addTo( importMenu_X ); 845 action->addTo( importMenu_X );
846 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 846 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
847 //#else 847 //#else
848#ifdef _OL_IMPORT_ 848#ifdef _OL_IMPORT_
849 importMenu_X->insertSeparator(); 849 importMenu_X->insertSeparator();
850 action = new QAction( "import_ol", i18n("Import from OL"), 0, 850 action = new QAction( "import_ol", i18n("Import from OL"), 0,
851 this ); 851 this );
852 action->addTo( importMenu_X ); 852 action->addTo( importMenu_X );
853 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 853 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
854#endif 854#endif
855 //#endif 855 //#endif
856 856
857 //importMenu->insertSeparator(); 857 //importMenu->insertSeparator();
858 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 858 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
859 this ); 859 this );
860 action->addTo( importMenu ); 860 action->addTo( importMenu );
861 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 861 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
862 862
863 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 863 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
864 this ); 864 this );
865 action->addTo( importMenu ); 865 action->addTo( importMenu );
866 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 866 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
867 importMenu->insertSeparator(); 867 importMenu->insertSeparator();
868 importMenu->insertItem( i18n("Import"), importMenu_X ); 868 importMenu->insertItem( i18n("Import"), importMenu_X );
869 //importMenu->insertSeparator(); 869 //importMenu->insertSeparator();
870 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 870 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
871 this ); 871 this );
872 action->addTo( exportMenu_X ); 872 action->addTo( exportMenu_X );
873 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 873 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
874 874
875 875
876 //LR 876 //LR
877 QPopupMenu *ex2phone = new QPopupMenu( this ); 877 QPopupMenu *ex2phone = new QPopupMenu( this );
878 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 878 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
879 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 879 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
880 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 880 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
881 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 881 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
882 882
883 importMenu->insertItem( i18n("Export"), exportMenu_X ); 883 importMenu->insertItem( i18n("Export"), exportMenu_X );
884#ifndef DESKTOP_VERSION 884#ifndef DESKTOP_VERSION
885 //importMenu->insertSeparator(); 885 //importMenu->insertSeparator();
886 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 886 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
887 this ); 887 this );
888 brAction->addTo( beamMenu_X ); 888 brAction->addTo( beamMenu_X );
889 brAction->setToggleAction (true ) ; 889 brAction->setToggleAction (true ) ;
890 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 890 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
891 891
892 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 892 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
893 this ); 893 this );
894 action->addTo( beamMenu_X ); 894 action->addTo( beamMenu_X );
895 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 895 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
896 896
897 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 897 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
898 this ); 898 this );
899 action->addTo( beamMenu_X ); 899 action->addTo( beamMenu_X );
900 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 900 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
901 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 901 importMenu->insertItem( i18n("Beam"), beamMenu_X );
902#else 902#else
903 //importMenu->insertSeparator(); 903 //importMenu->insertSeparator();
904 icon = loadPixmap( pathString + "print" ); 904 icon = loadPixmap( pathString + "print" );
905 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 905 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
906 action->addTo( beamMenu_X ); 906 action->addTo( beamMenu_X );
907 connect( action, SIGNAL( activated() ), 907 connect( action, SIGNAL( activated() ),
908 this, SLOT( printCal() ) ); 908 this, SLOT( printCal() ) );
909 909
910 icon = loadPixmap( pathString + "print" ); 910 icon = loadPixmap( pathString + "print" );
911 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 911 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
912 action->addTo( beamMenu_X ); 912 action->addTo( beamMenu_X );
913 connect( action, SIGNAL( activated() ), 913 connect( action, SIGNAL( activated() ),
914 this, SLOT( printSel() ) ); 914 this, SLOT( printSel() ) );
915 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 915 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
916 action->addTo( beamMenu_X ); 916 action->addTo( beamMenu_X );
917 connect( action, SIGNAL( activated() ), 917 connect( action, SIGNAL( activated() ),
918 mView->viewManager(), SIGNAL( printWNV() ) ); 918 mView->viewManager(), SIGNAL( printWNV() ) );
919 importMenu->insertItem( i18n("Print"), beamMenu_X ); 919 importMenu->insertItem( i18n("Print"), beamMenu_X );
920#endif 920#endif
921 importMenu->insertSeparator(); 921 importMenu->insertSeparator();
922 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 922 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
923 this ); 923 this );
924 action->addTo( importMenu ); 924 action->addTo( importMenu );
925 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 925 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
926 importMenu->insertSeparator(); 926 importMenu->insertSeparator();
927 action = new QAction( "beam all", i18n("Save"), 0, 927 action = new QAction( "beam all", i18n("Save"), 0,
928 this ); 928 this );
929 action->addTo( importMenu ); 929 action->addTo( importMenu );
930 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 930 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
931 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 931 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
932 this ); 932 this );
933 action->addTo( importMenu ); 933 action->addTo( importMenu );
934 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 934 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
935 935
936 //menuBar->insertItem( "Configure",configureMenu ); 936 //menuBar->insertItem( "Configure",configureMenu );
937 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 937 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
938 icon = loadPixmap( "korganizer/korganizer" ); 938 icon = loadPixmap( "korganizer/korganizer" );
939 939
940 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 940 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
941 action->addTo( helpMenu ); 941 action->addTo( helpMenu );
942 connect( action, SIGNAL( activated() ), 942 connect( action, SIGNAL( activated() ),
943 SLOT( whatsNew() ) ); 943 SLOT( whatsNew() ) );
944 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 944 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
945 action->addTo( helpMenu ); 945 action->addTo( helpMenu );
946 connect( action, SIGNAL( activated() ), 946 connect( action, SIGNAL( activated() ),
947 SLOT( features() ) ); 947 SLOT( features() ) );
948 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 948 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
949 action->addTo( helpMenu ); 949 action->addTo( helpMenu );
950 connect( action, SIGNAL( activated() ), 950 connect( action, SIGNAL( activated() ),
951 SLOT( keyBindings() ) ); 951 SLOT( keyBindings() ) );
952 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 952 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
953 action->addTo( helpMenu ); 953 action->addTo( helpMenu );
954 connect( action, SIGNAL( activated() ), 954 connect( action, SIGNAL( activated() ),
955 SLOT( synchowto() ) ); 955 SLOT( synchowto() ) );
956 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 956 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
957 action->addTo( helpMenu ); 957 action->addTo( helpMenu );
958 connect( action, SIGNAL( activated() ), 958 connect( action, SIGNAL( activated() ),
959 SLOT( kdesynchowto() ) ); 959 SLOT( kdesynchowto() ) );
960 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 960 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
961 action->addTo( helpMenu ); 961 action->addTo( helpMenu );
962 connect( action, SIGNAL( activated() ), 962 connect( action, SIGNAL( activated() ),
963 SLOT( multisynchowto() ) ); 963 SLOT( multisynchowto() ) );
964 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 964 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
965 action->addTo( helpMenu ); 965 action->addTo( helpMenu );
966 connect( action, SIGNAL( activated() ), 966 connect( action, SIGNAL( activated() ),
967 SLOT( aboutAutoSaving() ) ); 967 SLOT( aboutAutoSaving() ) );
968 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 968 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
969 action->addTo( helpMenu ); 969 action->addTo( helpMenu );
970 connect( action, SIGNAL( activated() ), 970 connect( action, SIGNAL( activated() ),
971 SLOT( aboutKnownBugs() ) ); 971 SLOT( aboutKnownBugs() ) );
972 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 972 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
973 action->addTo( helpMenu ); 973 action->addTo( helpMenu );
974 connect( action, SIGNAL( activated() ), 974 connect( action, SIGNAL( activated() ),
975 SLOT( usertrans() ) ); 975 SLOT( usertrans() ) );
976 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 976 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
977 action->addTo( helpMenu ); 977 action->addTo( helpMenu );
978 connect( action, SIGNAL( activated() ), 978 connect( action, SIGNAL( activated() ),
979 SLOT( faq() ) ); 979 SLOT( faq() ) );
980 action = new QAction( "licence", i18n("Licence..."), 0, this ); 980 action = new QAction( "licence", i18n("Licence..."), 0, this );
981 action->addTo( helpMenu ); 981 action->addTo( helpMenu );
982 connect( action, SIGNAL( activated() ), 982 connect( action, SIGNAL( activated() ),
983 SLOT( licence() ) ); 983 SLOT( licence() ) );
984 action = new QAction( "about", i18n("About..."), 0, this ); 984 action = new QAction( "about", i18n("About..."), 0, this );
985 action->addTo( helpMenu ); 985 action->addTo( helpMenu );
986 connect( action, SIGNAL( activated() ), 986 connect( action, SIGNAL( activated() ),
987 SLOT( about() ) ); 987 SLOT( about() ) );
988 //menuBar->insertSeparator(); 988 //menuBar->insertSeparator();
989 989
990 // ****************************************************** 990 // ******************************************************
991 // menubar icons 991 // menubar icons
992 992
993 993
994 iconToolBar->setHorizontalStretchable (true ); 994 iconToolBar->setHorizontalStretchable (true );
995 //menuBar->insertItem( iconToolBar ); 995 //menuBar->insertItem( iconToolBar );
996 //xdays_action 996 //xdays_action
997 if (p-> mShowIconNewEvent) 997 if (p-> mShowIconNewEvent)
998 ne_action->addTo( iconToolBar ); 998 ne_action->addTo( iconToolBar );
999 if (p->mShowIconNewTodo ) 999 if (p->mShowIconNewTodo )
1000 nt_action->addTo( iconToolBar ); 1000 nt_action->addTo( iconToolBar );
1001 if (p-> mShowIconSearch) 1001 if (p-> mShowIconSearch)
1002 search_action->addTo( iconToolBar ); 1002 search_action->addTo( iconToolBar );
1003 if (p-> mShowIconWhatsThis) 1003 if (p-> mShowIconWhatsThis)
1004 QWhatsThis::whatsThisButton ( iconToolBar ); 1004 QWhatsThis::whatsThisButton ( iconToolBar );
1005 if (p-> mShowIconNext) 1005 if (p-> mShowIconNext)
1006 whatsnext_action->addTo( iconToolBar ); 1006 whatsnext_action->addTo( iconToolBar );
1007 if (p-> mShowIconNextDays) 1007 if (p-> mShowIconNextDays)
1008 xdays_action->addTo( iconToolBar ); 1008 xdays_action->addTo( iconToolBar );
1009 if (p-> mShowIconList) 1009 if (p-> mShowIconList)
1010 showlist_action->addTo( iconToolBar ); 1010 showlist_action->addTo( iconToolBar );
1011 if (p-> mShowIconDay1) 1011 if (p-> mShowIconDay1)
1012 day1_action->addTo( iconToolBar ); 1012 day1_action->addTo( iconToolBar );
1013 if (p-> mShowIconDay5) 1013 if (p-> mShowIconDay5)
1014 day5_action->addTo( iconToolBar ); 1014 day5_action->addTo( iconToolBar );
1015 if (p-> mShowIconDay7) 1015 if (p-> mShowIconDay7)
1016 day7_action->addTo( iconToolBar ); 1016 day7_action->addTo( iconToolBar );
1017 if (p-> mShowIconDay6) 1017 if (p-> mShowIconDay6)
1018 day6_action->addTo( iconToolBar ); 1018 day6_action->addTo( iconToolBar );
1019 if (p-> mShowIconMonth) 1019 if (p-> mShowIconMonth)
1020 month_action->addTo( iconToolBar ); 1020 month_action->addTo( iconToolBar );
1021 if (p-> mShowIconTodoview) 1021 if (p-> mShowIconTodoview)
1022 todoview_action->addTo( iconToolBar ); 1022 todoview_action->addTo( iconToolBar );
1023 if (p-> mShowIconJournal) 1023 if (p-> mShowIconJournal)
1024 viewjournal_action->addTo( iconToolBar ); 1024 viewjournal_action->addTo( iconToolBar );
1025 icon = loadPixmap( pathString + "2leftarrowB" ); 1025 icon = loadPixmap( pathString + "2leftarrowB" );
1026 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 1026 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
1027 if (p-> mShowIconBackFast) { 1027 if (p-> mShowIconBackFast) {
1028 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1028 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1029 connect( action, SIGNAL( activated() ), 1029 connect( action, SIGNAL( activated() ),
1030 mView, SLOT( goPreviousMonth() ) ); 1030 mView, SLOT( goPreviousMonth() ) );
1031 action->addTo( iconToolBar ); 1031 action->addTo( iconToolBar );
1032 } 1032 }
1033 icon = loadPixmap( pathString + "1leftarrowB" ); 1033 icon = loadPixmap( pathString + "1leftarrowB" );
1034 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 1034 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
1035 if (p-> mShowIconBack) { 1035 if (p-> mShowIconBack) {
1036 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1036 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1037 connect( action, SIGNAL( activated() ), 1037 connect( action, SIGNAL( activated() ),
1038 mView, SLOT( goPrevious() ) ); 1038 mView, SLOT( goPrevious() ) );
1039 action->addTo( iconToolBar ); 1039 action->addTo( iconToolBar );
1040 } 1040 }
1041 icon = loadPixmap( pathString + "today" ); 1041 icon = loadPixmap( pathString + "today" );
1042 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1042 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1043 if (p-> mShowIconToday) 1043 if (p-> mShowIconToday)
1044 today_action->addTo( iconToolBar ); 1044 today_action->addTo( iconToolBar );
1045 icon = loadPixmap( pathString + "1rightarrowB" ); 1045 icon = loadPixmap( pathString + "1rightarrowB" );
1046 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1046 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1047 if (p-> mShowIconForward) { 1047 if (p-> mShowIconForward) {
1048 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1048 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1049 connect( action, SIGNAL( activated() ), 1049 connect( action, SIGNAL( activated() ),
1050 mView, SLOT( goNext() ) ); 1050 mView, SLOT( goNext() ) );
1051 action->addTo( iconToolBar ); 1051 action->addTo( iconToolBar );
1052 } 1052 }
1053 icon = loadPixmap( pathString + "2rightarrowB" ); 1053 icon = loadPixmap( pathString + "2rightarrowB" );
1054 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1054 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1055 if (p-> mShowIconForwardFast) { 1055 if (p-> mShowIconForwardFast) {
1056 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1056 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1057 connect( action, SIGNAL( activated() ), 1057 connect( action, SIGNAL( activated() ),
1058 mView, SLOT( goNextMonth() ) ); 1058 mView, SLOT( goNextMonth() ) );
1059 action->addTo( iconToolBar ); 1059 action->addTo( iconToolBar );
1060 } 1060 }
1061 1061
1062 1062
1063 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 1063 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
1064 1064
1065 if (p-> mShowIconNewEvent) 1065 if (p-> mShowIconNewEvent)
1066 configureToolBarMenu->setItemChecked( 10, true ); 1066 configureToolBarMenu->setItemChecked( 10, true );
1067 if (p->mShowIconNewTodo ) 1067 if (p->mShowIconNewTodo )
1068 configureToolBarMenu->setItemChecked( 20, true ); 1068 configureToolBarMenu->setItemChecked( 20, true );
1069 if (p-> mShowIconSearch) 1069 if (p-> mShowIconSearch)
1070 configureToolBarMenu->setItemChecked( 120, true ); 1070 configureToolBarMenu->setItemChecked( 120, true );
1071 if (p-> mShowIconList) 1071 if (p-> mShowIconList)
1072 configureToolBarMenu->setItemChecked( 30, true ); 1072 configureToolBarMenu->setItemChecked( 30, true );
1073 if (p-> mShowIconDay1) 1073 if (p-> mShowIconDay1)
1074 configureToolBarMenu->setItemChecked( 40, true ); 1074 configureToolBarMenu->setItemChecked( 40, true );
1075 if (p-> mShowIconDay5) 1075 if (p-> mShowIconDay5)
1076 configureToolBarMenu->setItemChecked( 50, true ); 1076 configureToolBarMenu->setItemChecked( 50, true );
1077 if (p-> mShowIconDay6) 1077 if (p-> mShowIconDay6)
1078 configureToolBarMenu->setItemChecked( 75, true ); 1078 configureToolBarMenu->setItemChecked( 75, true );
1079 if (p-> mShowIconDay7) 1079 if (p-> mShowIconDay7)
1080 configureToolBarMenu->setItemChecked( 60, true ); 1080 configureToolBarMenu->setItemChecked( 60, true );
1081 if (p-> mShowIconMonth) 1081 if (p-> mShowIconMonth)
1082 configureToolBarMenu->setItemChecked( 70, true ); 1082 configureToolBarMenu->setItemChecked( 70, true );
1083 if (p-> mShowIconTodoview) 1083 if (p-> mShowIconTodoview)
1084 configureToolBarMenu->setItemChecked( 80, true ); 1084 configureToolBarMenu->setItemChecked( 80, true );
1085 if (p-> mShowIconBackFast) 1085 if (p-> mShowIconBackFast)
1086 configureToolBarMenu->setItemChecked( 200, true ); 1086 configureToolBarMenu->setItemChecked( 200, true );
1087 if (p-> mShowIconBack) 1087 if (p-> mShowIconBack)
1088 configureToolBarMenu->setItemChecked( 210, true ); 1088 configureToolBarMenu->setItemChecked( 210, true );
1089 if (p-> mShowIconToday) 1089 if (p-> mShowIconToday)
1090 configureToolBarMenu->setItemChecked( 130, true ); 1090 configureToolBarMenu->setItemChecked( 130, true );
1091 if (p-> mShowIconForward) 1091 if (p-> mShowIconForward)
1092 configureToolBarMenu->setItemChecked( 220, true ); 1092 configureToolBarMenu->setItemChecked( 220, true );
1093 if (p-> mShowIconForwardFast) 1093 if (p-> mShowIconForwardFast)
1094 configureToolBarMenu->setItemChecked( 230, true ); 1094 configureToolBarMenu->setItemChecked( 230, true );
1095 if (p-> mShowIconNextDays) 1095 if (p-> mShowIconNextDays)
1096 configureToolBarMenu->setItemChecked( 100, true ); 1096 configureToolBarMenu->setItemChecked( 100, true );
1097 if (p-> mShowIconNext) 1097 if (p-> mShowIconNext)
1098 configureToolBarMenu->setItemChecked( 110, true ); 1098 configureToolBarMenu->setItemChecked( 110, true );
1099 if (p-> mShowIconJournal) 1099 if (p-> mShowIconJournal)
1100 configureToolBarMenu->setItemChecked( 90, true ); 1100 configureToolBarMenu->setItemChecked( 90, true );
1101 if (p-> mShowIconWhatsThis) 1101 if (p-> mShowIconWhatsThis)
1102 configureToolBarMenu->setItemChecked( 300, true ); 1102 configureToolBarMenu->setItemChecked( 300, true );
1103 if (p-> mShowIconWeekNum) 1103 if (p-> mShowIconWeekNum)
1104 configureToolBarMenu->setItemChecked( 400, true ); 1104 configureToolBarMenu->setItemChecked( 400, true );
1105 QLabel* dummy = new QLabel( iconToolBar ); 1105 QLabel* dummy = new QLabel( iconToolBar );
1106 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1106 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1107 if (!p-> mShowIconStretch) 1107 if (!p-> mShowIconStretch)
1108 iconToolBar->setStretchableWidget ( dummy ) ; 1108 iconToolBar->setStretchableWidget ( dummy ) ;
1109 else 1109 else
1110 configureToolBarMenu->setItemChecked( 5, true ); 1110 configureToolBarMenu->setItemChecked( 5, true );
1111 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1111 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1112 configureAgenda( p->mHourSize ); 1112 configureAgenda( p->mHourSize );
1113 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1113 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1114} 1114}
1115 1115
1116void MainWindow::exportToPhone( int mode ) 1116void MainWindow::exportToPhone( int mode )
1117{ 1117{
1118 1118
1119 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1119 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1120 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1120 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1121 KOex2phonePrefs ex2phone; 1121 KOex2phonePrefs ex2phone;
1122 1122
1123 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1123 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1124 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1124 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1125 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1125 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1126 if ( mode == 1 ) 1126 if ( mode == 1 )
1127 ex2phone.setCaption(i18n("Export complete calendar")); 1127 ex2phone.setCaption(i18n("Export complete calendar"));
1128 if ( mode == 2 ) 1128 if ( mode == 2 )
1129 ex2phone.setCaption(i18n("Export filtered calendar")); 1129 ex2phone.setCaption(i18n("Export filtered calendar"));
1130 1130
1131 if ( !ex2phone.exec() ) { 1131 if ( !ex2phone.exec() ) {
1132 return; 1132 return;
1133 } 1133 }
1134 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1134 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1135 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1135 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1136 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1136 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1137 1137
1138 int inFuture = 0; 1138 int inFuture = 0;
1139 if ( ex2phone.mWriteBackFuture->isChecked() ) 1139 if ( ex2phone.mWriteBackFuture->isChecked() )
1140 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1140 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1141 QPtrList<Incidence> delSel; 1141 QPtrList<Incidence> delSel;
1142 if ( mode == 1 ) 1142 if ( mode == 1 )
1143 delSel = mCalendar->rawIncidences(); 1143 delSel = mCalendar->rawIncidences();
1144 if ( mode == 2 ) 1144 if ( mode == 2 )
1145 delSel = mCalendar->incidences(); 1145 delSel = mCalendar->incidences();
1146 CalendarLocal* cal = new CalendarLocal(); 1146 CalendarLocal* cal = new CalendarLocal();
1147 cal->setLocalTime(); 1147 cal->setLocalTime();
1148 Incidence *incidence = delSel.first(); 1148 Incidence *incidence = delSel.first();
1149 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1149 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1150 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1150 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1151 while ( incidence ) { 1151 while ( incidence ) {
1152 if ( incidence->type() != "Journal" ) { 1152 if ( incidence->type() != "Journal" ) {
1153 bool add = true; 1153 bool add = true;
1154 if ( inFuture ) { 1154 if ( inFuture ) {
1155 QDateTime dt; 1155 QDateTime dt;
1156 if ( incidence->type() == "Todo" ) { 1156 if ( incidence->type() == "Todo" ) {
1157 Todo * t = (Todo*)incidence; 1157 Todo * t = (Todo*)incidence;
1158 if ( t->hasDueDate() ) 1158 if ( t->hasDueDate() )
1159 dt = t->dtDue(); 1159 dt = t->dtDue();
1160 else 1160 else
1161 dt = cur.addSecs( 62 ); 1161 dt = cur.addSecs( 62 );
1162 } 1162 }
1163 else { 1163 else {
1164 bool ok; 1164 bool ok;
1165 dt = incidence->getNextOccurence( cur, &ok ); 1165 dt = incidence->getNextOccurence( cur, &ok );
1166 if ( !ok ) 1166 if ( !ok )
1167 dt = cur.addSecs( -62 ); 1167 dt = cur.addSecs( -62 );
1168 } 1168 }
1169 if ( dt < cur || dt > end ) { 1169 if ( dt < cur || dt > end ) {
1170 add = false; 1170 add = false;
1171 } 1171 }
1172 } 1172 }
1173 if ( add ) { 1173 if ( add ) {
1174 Incidence *in = incidence->clone(); 1174 Incidence *in = incidence->clone();
1175 cal->addIncidence( in ); 1175 cal->addIncidence( in );
1176 } 1176 }
1177 } 1177 }
1178 incidence = delSel.next(); 1178 incidence = delSel.next();
1179 } 1179 }
1180 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1180 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1181 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1181 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1182 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1182 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1183 1183
1184 setCaption( i18n("Writing to phone...")); 1184 setCaption( i18n("Writing to phone..."));
1185 if ( PhoneFormat::writeToPhone( cal ) ) 1185 if ( PhoneFormat::writeToPhone( cal ) )
1186 setCaption( i18n("Export to phone successful!")); 1186 setCaption( i18n("Export to phone successful!"));
1187 else 1187 else
1188 setCaption( i18n("Error exporting to phone!")); 1188 setCaption( i18n("Error exporting to phone!"));
1189 delete cal; 1189 delete cal;
1190} 1190}
1191 1191
1192 1192
1193void MainWindow::setDefaultPreferences() 1193void MainWindow::setDefaultPreferences()
1194{ 1194{
1195 KOPrefs *p = KOPrefs::instance(); 1195 KOPrefs *p = KOPrefs::instance();
1196 1196
1197 p->mCompactDialogs = true; 1197 p->mCompactDialogs = true;
1198 p->mConfirm = true; 1198 p->mConfirm = true;
1199 // p->mEnableQuickTodo = false; 1199 // p->mEnableQuickTodo = false;
1200 1200
1201} 1201}
1202 1202
1203QString MainWindow::resourcePath() 1203QString MainWindow::resourcePath()
1204{ 1204{
1205 return KGlobal::iconLoader()->iconPath(); 1205 return KGlobal::iconLoader()->iconPath();
1206} 1206}
1207 1207
1208void MainWindow::displayText( QString text ,QString cap ) 1208void MainWindow::displayText( QString text ,QString cap )
1209{ 1209{
1210 QDialog dia( this, "name", true ); ; 1210 QDialog dia( this, "name", true ); ;
1211 dia.setCaption( cap ); 1211 dia.setCaption( cap );
1212 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1212 QVBoxLayout* lay = new QVBoxLayout( &dia );
1213 lay->setSpacing( 3 ); 1213 lay->setSpacing( 3 );
1214 lay->setMargin( 3 ); 1214 lay->setMargin( 3 );
1215 QTextBrowser tb ( &dia ); 1215 QTextBrowser tb ( &dia );
1216 lay->addWidget( &tb ); 1216 lay->addWidget( &tb );
1217 tb.setText( text ); 1217 tb.setText( text );
1218#ifdef DESKTOP_VERSION 1218#ifdef DESKTOP_VERSION
1219 dia.resize( 640, 480); 1219 dia.resize( 640, 480);
1220#else 1220#else
1221 dia.showMaximized(); 1221 dia.showMaximized();
1222#endif 1222#endif
1223 dia.exec(); 1223 dia.exec();
1224} 1224}
1225 1225
1226void MainWindow::features() 1226void MainWindow::features()
1227{ 1227{
1228 1228
1229 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1229 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1230} 1230}
1231 1231
1232void MainWindow::usertrans() 1232void MainWindow::usertrans()
1233{ 1233{
1234 1234
1235 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1235 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1236} 1236}
1237 1237
1238void MainWindow::kdesynchowto() 1238void MainWindow::kdesynchowto()
1239{ 1239{
1240 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1240 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1241} 1241}
1242void MainWindow::multisynchowto() 1242void MainWindow::multisynchowto()
1243{ 1243{
1244 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1244 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1245} 1245}
1246void MainWindow::synchowto() 1246void MainWindow::synchowto()
1247{ 1247{
1248 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1248 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1249} 1249}
1250void MainWindow::faq() 1250void MainWindow::faq()
1251{ 1251{
1252 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1252 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1253 1253
1254} 1254}
1255void MainWindow::whatsNew() 1255void MainWindow::whatsNew()
1256{ 1256{
1257 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1257 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1258 1258
1259} 1259}
1260void MainWindow::licence() 1260void MainWindow::licence()
1261{ 1261{
1262 KApplication::showLicence(); 1262 KApplication::showLicence();
1263 1263
1264} 1264}
1265void MainWindow::about() 1265void MainWindow::about()
1266{ 1266{
1267 QString version; 1267 QString version;
1268#include <../version> 1268#include <../version>
1269 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1269 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1270 i18n("KOrganizer/Platform-independent\n") + 1270 i18n("KOrganizer/Platform-independent\n") +
1271 "(KO/Pi) " + version + " - " + 1271 "(KO/Pi) " + version + " - " +
1272 1272
1273#ifdef DESKTOP_VERSION 1273#ifdef DESKTOP_VERSION
1274 i18n("Desktop Edition\n") + 1274 i18n("Desktop Edition\n") +
1275#else 1275#else
1276 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1276 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1277#endif 1277#endif
1278 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1278 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1279} 1279}
1280void MainWindow::keyBindings() 1280void MainWindow::keyBindings()
1281{ 1281{
1282 QString cap = i18n("KO/Pi Keys + Colors"); 1282 QString cap = i18n("KO/Pi Keys + Colors");
1283 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1283 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1284 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1284 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1285 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1285 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1286 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1286 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1287 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1287 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1288 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1288 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1289 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1289 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1290 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1290 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1291 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1291 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1292 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1292 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1293 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1293 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1294 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1294 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1295 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1295 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1296 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1296 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1297 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1297 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1298 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1298 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1299 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1299 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1300 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1300 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1301 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1301 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1302 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1302 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1303 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1303 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1304 i18n("<p><h3>In agenda view:</h3></p>\n") + 1304 i18n("<p><h3>In agenda view:</h3></p>\n") +
1305 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1305 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1306 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1306 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1307 i18n("<p><h3>In todo view:</h3></p>\n") + 1307 i18n("<p><h3>In todo view:</h3></p>\n") +
1308 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1308 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1309 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1309 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1310 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1310 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1311 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1311 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1312 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1312 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1313 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1313 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1314 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1314 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1315 i18n("<p><h3>In list view:</h3></p>\n") + 1315 i18n("<p><h3>In list view:</h3></p>\n") +
1316 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1316 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1317 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1317 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1318 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1318 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1319 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1319 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1320 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1320 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1321 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1321 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1322 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1322 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1323 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1323 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1324 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1324 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1325 i18n("<p><b>E</b>: Edit item</p>\n") + 1325 i18n("<p><b>E</b>: Edit item</p>\n") +
1326 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1326 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1327 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1327 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1328 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1328 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1329 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1329 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1330 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1330 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1331 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1331 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1332 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1332 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1333 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1333 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1334 i18n("<p><b>White</b>: Item readonly</p>\n"); 1334 i18n("<p><b>White</b>: Item readonly</p>\n");
1335 displayText( text, cap); 1335 displayText( text, cap);
1336} 1336}
1337void MainWindow::aboutAutoSaving() 1337void MainWindow::aboutAutoSaving()
1338{ 1338{
1339 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1339 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1340 1340
1341 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1341 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1342 1342
1343} 1343}
1344void MainWindow::aboutKnownBugs() 1344void MainWindow::aboutKnownBugs()
1345{ 1345{
1346 QMessageBox* msg; 1346 QMessageBox* msg;
1347 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1347 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1348 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1348 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1349 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1349 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1350 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1350 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1351 i18n("\nor report them in the bugtracker on\n") + 1351 i18n("\nor report them in the bugtracker on\n") +
1352 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1352 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1353 QMessageBox::NoIcon, 1353 QMessageBox::NoIcon,
1354 QMessageBox::Ok, 1354 QMessageBox::Ok,
1355 QMessageBox::NoButton, 1355 QMessageBox::NoButton,
1356 QMessageBox::NoButton); 1356 QMessageBox::NoButton);
1357 msg->exec(); 1357 msg->exec();
1358 delete msg; 1358 delete msg;
1359 1359
1360} 1360}
1361 1361
1362QString MainWindow::defaultFileName() 1362QString MainWindow::defaultFileName()
1363{ 1363{
1364 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1364 return locateLocal( "data", "korganizer/mycalendar.ics" );
1365} 1365}
1366QString MainWindow::syncFileName() 1366QString MainWindow::syncFileName()
1367{ 1367{
1368#ifdef DESKTOP_VERSION 1368#ifdef DESKTOP_VERSION
1369 return locateLocal( "tmp", "synccalendar.ics" ); 1369 return locateLocal( "tmp", "synccalendar.ics" );
1370#else 1370#else
1371 return QString( "/tmp/synccalendar.ics" ); 1371 return QString( "/tmp/synccalendar.ics" );
1372#endif 1372#endif
1373} 1373}
1374void MainWindow::updateWeek(QDate seda) 1374void MainWindow::updateWeek(QDate seda)
1375{ 1375{
1376 int weekNum = 0; 1376 int weekNum = 0;
1377 QDate d = QDate ( seda.year(), 1,1); 1377 QDate d = QDate ( seda.year(), 1,1);
1378 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday 1378 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1379 if ( seda.addDays(6).year() != seda.year() ) { 1379 if ( seda.addDays(6).year() != seda.year() ) {
1380 if ( seda.year() != d.year() ) { 1380 if ( seda.year() != d.year() ) {
1381 if ( d.dayOfWeek() > 4 ) 1381 if ( d.dayOfWeek() > 4 )
1382 d = QDate ( seda.year(), 1,1); 1382 d = QDate ( seda.year(), 1,1);
1383 else 1383 else
1384 weekNum = 1; 1384 weekNum = 1;
1385 } else { 1385 } else {
1386 QDate dd( seda.year()+1, 1,1); 1386 QDate dd( seda.year()+1, 1,1);
1387 if ( dd.dayOfWeek() <= 4 ) 1387 if ( dd.dayOfWeek() <= 4 )
1388 weekNum = 1; 1388 weekNum = 1;
1389 } 1389 }
1390 } 1390 }
1391 if ( weekNum == 0 ){ 1391 if ( weekNum == 0 ){
1392 int dow = d.dayOfWeek(); 1392 int dow = d.dayOfWeek();
1393 if ( dow <= 4 ) 1393 if ( dow <= 4 )
1394 d = d.addDays( 1-dow ); 1394 d = d.addDays( 1-dow );
1395 else // 5,6,7 1395 else // 5,6,7
1396 d = d.addDays( 8-dow ); 1396 d = d.addDays( 8-dow );
1397 // we have the first week of the year.we are on monday 1397 // we have the first week of the year.we are on monday
1398 weekNum = d.daysTo( seda ) / 7 +1; 1398 weekNum = d.daysTo( seda ) / 7 +1;
1399 } 1399 }
1400 1400
1401 mWeekPixmap.fill( mWeekBgColor ); 1401 mWeekPixmap.fill( mWeekBgColor );
1402 QPainter p ( &mWeekPixmap ); 1402 QPainter p ( &mWeekPixmap );
1403 p.setFont( mWeekFont ); 1403 p.setFont( mWeekFont );
1404 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1404 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1405 p.end(); 1405 p.end();
1406 QIconSet icon3 ( mWeekPixmap ); 1406 QIconSet icon3 ( mWeekPixmap );
1407 mWeekAction->setIconSet ( icon3 ); 1407 mWeekAction->setIconSet ( icon3 );
1408 1408
1409} 1409}
1410void MainWindow::updateWeekNum(const DateList &selectedDates) 1410void MainWindow::updateWeekNum(const DateList &selectedDates)
1411{ 1411{
1412 updateWeek( selectedDates.first() ); 1412 updateWeek( selectedDates.first() );
1413} 1413}
1414void MainWindow::processIncidenceSelection( Incidence *incidence ) 1414void MainWindow::processIncidenceSelection( Incidence *incidence )
1415{ 1415{
1416 1416
1417 if ( !incidence ) { 1417 if ( !incidence ) {
1418 enableIncidenceActions( false ); 1418 enableIncidenceActions( false );
1419 1419
1420 mNewSubTodoAction->setEnabled( false ); 1420 mNewSubTodoAction->setEnabled( false );
1421 setCaptionToDates(); 1421 setCaptionToDates();
1422 return; 1422 return;
1423 1423
1424 } 1424 }
1425 1425
1426 //KGlobal::locale()->formatDateTime(nextA, true); 1426 //KGlobal::locale()->formatDateTime(nextA, true);
1427 QString startString = ""; 1427 QString startString = "";
1428 if ( incidence->type() != "Todo" ) { 1428 if ( incidence->type() != "Todo" ) {
1429 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1429 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1430 if ( incidence->doesFloat() ) { 1430 if ( incidence->doesFloat() ) {
1431 startString += ": "+incidence->dtStartDateStr( true ); 1431 startString += ": "+incidence->dtStartDateStr( true );
1432 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1432 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1433 1433
1434 } else { 1434 } else {
1435 startString = ": "+incidence->dtStartStr(true); 1435 startString = ": "+incidence->dtStartStr(true);
1436 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1436 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1437 1437
1438 } 1438 }
1439 1439
1440 } else { 1440 } else {
1441 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1441 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1442 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1442 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1443 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1443 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1444 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { 1444 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1445 bool ok; 1445 bool ok;
1446 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1446 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1447 if ( ok ) { 1447 if ( ok ) {
1448 int years = noc.date().year() - incidence->dtStart().date().year(); 1448 int years = noc.date().year() - incidence->dtStart().date().year();
1449 startString += i18n(" (%1 y.)"). arg( years ); 1449 startString += i18n(" (%1 y.)"). arg( years );
1450 } 1450 }
1451 } 1451 }
1452 else 1452 else
1453 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1453 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1454 } 1454 }
1455 1455
1456 } 1456 }
1457 else 1457 else
1458 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1458 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1459 if ( !incidence->location().isEmpty() ) 1459 if ( !incidence->location().isEmpty() )
1460 startString += " (" +incidence->location()+")"; 1460 startString += " (" +incidence->location()+")";
1461 setCaption( incidence->summary()+startString); 1461 setCaption( incidence->summary()+startString);
1462 1462
1463 enableIncidenceActions( true ); 1463 enableIncidenceActions( true );
1464 1464
1465 if ( incidence->type() == "Event" ) { 1465 if ( incidence->type() == "Event" ) {
1466 mShowAction->setText( i18n("Show Event...") ); 1466 mShowAction->setText( i18n("Show Event...") );
1467 mEditAction->setText( i18n("Edit Event...") ); 1467 mEditAction->setText( i18n("Edit Event...") );
1468 mDeleteAction->setText( i18n("Delete Event...") ); 1468 mDeleteAction->setText( i18n("Delete Event...") );
1469 1469
1470 mNewSubTodoAction->setEnabled( false ); 1470 mNewSubTodoAction->setEnabled( false );
1471 } else if ( incidence->type() == "Todo" ) { 1471 } else if ( incidence->type() == "Todo" ) {
1472 mShowAction->setText( i18n("Show Todo...") ); 1472 mShowAction->setText( i18n("Show Todo...") );
1473 mEditAction->setText( i18n("Edit Todo...") ); 1473 mEditAction->setText( i18n("Edit Todo...") );
1474 mDeleteAction->setText( i18n("Delete Todo...") ); 1474 mDeleteAction->setText( i18n("Delete Todo...") );
1475 1475
1476 mNewSubTodoAction->setEnabled( true ); 1476 mNewSubTodoAction->setEnabled( true );
1477 } else { 1477 } else {
1478 mShowAction->setText( i18n("Show...") ); 1478 mShowAction->setText( i18n("Show...") );
1479 mShowAction->setText( i18n("Edit...") ); 1479 mShowAction->setText( i18n("Edit...") );
1480 mShowAction->setText( i18n("Delete...") ); 1480 mShowAction->setText( i18n("Delete...") );
1481 1481
1482 mNewSubTodoAction->setEnabled( false ); 1482 mNewSubTodoAction->setEnabled( false );
1483 } 1483 }
1484} 1484}
1485 1485
1486void MainWindow::enableIncidenceActions( bool enabled ) 1486void MainWindow::enableIncidenceActions( bool enabled )
1487{ 1487{
1488 mShowAction->setEnabled( enabled ); 1488 mShowAction->setEnabled( enabled );
1489 mEditAction->setEnabled( enabled ); 1489 mEditAction->setEnabled( enabled );
1490 mDeleteAction->setEnabled( enabled ); 1490 mDeleteAction->setEnabled( enabled );
1491 1491
1492 mCloneAction->setEnabled( enabled ); 1492 mCloneAction->setEnabled( enabled );
1493 mMoveAction->setEnabled( enabled ); 1493 mMoveAction->setEnabled( enabled );
1494 mBeamAction->setEnabled( enabled ); 1494 mBeamAction->setEnabled( enabled );
1495 mCancelAction->setEnabled( enabled ); 1495 mCancelAction->setEnabled( enabled );
1496} 1496}
1497 1497
1498void MainWindow::importOL() 1498void MainWindow::importOL()
1499{ 1499{
1500#ifdef _OL_IMPORT_ 1500#ifdef _OL_IMPORT_
1501 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1501 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1502 id->exec(); 1502 id->exec();
1503 delete id; 1503 delete id;
1504 mView->updateView(); 1504 mView->updateView();
1505#endif 1505#endif
1506} 1506}
1507void MainWindow::importBday() 1507void MainWindow::importBday()
1508{ 1508{
1509 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1509 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1510 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1510 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1511 i18n("Import!"), i18n("Cancel"), 0, 1511 i18n("Import!"), i18n("Cancel"), 0,
1512 0, 1 ); 1512 0, 1 );
1513 if ( result == 0 ) { 1513 if ( result == 0 ) {
1514 mView->importBday(); 1514 mView->importBday();
1515 1515
1516 } 1516 }
1517 1517
1518 1518
1519} 1519}
1520void MainWindow::importQtopia() 1520void MainWindow::importQtopia()
1521{ 1521{
1522 //#ifndef DESKTOP_VERSION 1522 //#ifndef DESKTOP_VERSION
1523 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1523 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1524#ifdef DESKTOP_VERSION 1524#ifdef DESKTOP_VERSION
1525 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1525 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1526#endif 1526#endif
1527 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1527 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1528 i18n("Import!"), i18n("Cancel"), 0, 1528 i18n("Import!"), i18n("Cancel"), 0,
1529 0, 1 ); 1529 0, 1 );
1530 if ( result == 0 ) { 1530 if ( result == 0 ) {
1531#ifndef DESKTOP_VERSION 1531#ifndef DESKTOP_VERSION
1532 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1532 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1533 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1533 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1534 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1534 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1535#else 1535#else
1536 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1536 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1537 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1537 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1538 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1538 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1539#endif 1539#endif
1540 mView->importQtopia( categories, datebook, todolist ); 1540 mView->importQtopia( categories, datebook, todolist );
1541 } 1541 }
1542#if 0 1542#if 0
1543 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1543 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1544 i18n("Not supported \non desktop!\n"), 1544 i18n("Not supported \non desktop!\n"),
1545 i18n("Ok"), i18n("Cancel"), 0, 1545 i18n("Ok"), i18n("Cancel"), 0,
1546 0, 1 ); 1546 0, 1 );
1547 1547
1548#endif 1548#endif
1549} 1549}
1550 1550
1551void MainWindow::saveOnClose() 1551void MainWindow::saveOnClose()
1552{ 1552{
1553 KOPrefs *p = KOPrefs::instance(); 1553 KOPrefs *p = KOPrefs::instance();
1554 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1554 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1555 p->mToolBarUp = iconToolBar->x() > width()/2 || 1555 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1556 iconToolBar->y() > height()/2; 1556 iconToolBar->y() > height()/2;
1557 mView->writeSettings(); 1557 mView->writeSettings();
1558 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1558 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1559 save(); 1559 save();
1560} 1560}
1561void MainWindow::slotModifiedChanged( bool changed ) 1561void MainWindow::slotModifiedChanged( bool changed )
1562{ 1562{
1563 if ( mBlockAtStartup ) 1563 if ( mBlockAtStartup )
1564 return; 1564 return;
1565 1565
1566 int msec; 1566 int msec;
1567 // we store the changes after 1 minute, 1567 // we store the changes after 1 minute,
1568 // and for safety reasons after 10 minutes again 1568 // and for safety reasons after 10 minutes again
1569 if ( !mSyncManager->blockSave() ) 1569 if ( !mSyncManager->blockSave() )
1570 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1570 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1571 else 1571 else
1572 msec = 1000 * 600; 1572 msec = 1000 * 600;
1573 mSaveTimer.start( msec, true ); // 1 minute 1573 mSaveTimer.start( msec, true ); // 1 minute
1574 qDebug("KO: Saving File in %d secs!", msec/1000); 1574 qDebug("KO: Saving File in %d secs!", msec/1000);
1575 mCalendarModifiedFlag = true; 1575 mCalendarModifiedFlag = true;
1576} 1576}
1577void MainWindow::saveStopTimer() 1577void MainWindow::saveStopTimer()
1578{ 1578{
1579 mSaveTimer.stop(); 1579 mSaveTimer.stop();
1580 if (mSaveTimer.isActive() ) 1580 if (mSaveTimer.isActive() )
1581 qDebug("ti active "); 1581 qDebug("ti active ");
1582 else 1582 else
1583 qDebug("KO: Save timer stopped"); 1583 qDebug("KO: Save timer stopped");
1584} 1584}
1585void MainWindow::save() 1585void MainWindow::save()
1586{ 1586{
1587 if ( !mCalendarModifiedFlag ) { 1587 if ( !mCalendarModifiedFlag ) {
1588 qDebug("KO: Calendar not modified. Nothing saved."); 1588 qDebug("KO: Calendar not modified. Nothing saved.");
1589 return; 1589 return;
1590 } 1590 }
1591 if ( mSyncManager->blockSave() ) 1591 if ( mSyncManager->blockSave() )
1592 return; 1592 return;
1593 mSyncManager->setBlockSave(true); 1593 mSyncManager->setBlockSave(true);
1594 if ( mView->checkFileVersion( defaultFileName()) ) { 1594 if ( mView->checkFileVersion( defaultFileName()) ) {
1595 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1595 QTime neededSaveTime = QDateTime::currentDateTime().time();
1596 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1596 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1597 qDebug("KO: Start saving data to file!"); 1597 qDebug("KO: Start saving data to file!");
1598 mView->saveCalendar( defaultFileName() ); 1598 mView->saveCalendar( defaultFileName() );
1599 mCalendarModifiedFlag = false; 1599 mCalendarModifiedFlag = false;
1600 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1600 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1601 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1601 qDebug("KO: Needed %d ms for saving.",msNeeded );
1602 QString savemes; 1602 QString savemes;
1603 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1603 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1604 setCaption(savemes); 1604 setCaption(savemes);
1605 } else 1605 } else
1606 setCaption(i18n("Saving cancelled!")); 1606 setCaption(i18n("Saving cancelled!"));
1607 mSyncManager->setBlockSave( false ); 1607 mSyncManager->setBlockSave( false );
1608} 1608}
1609 1609
1610void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1610void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1611{ 1611{
1612 if ( !e->isAutoRepeat() ) { 1612 if ( !e->isAutoRepeat() ) {
1613 mFlagKeyPressed = false; 1613 mFlagKeyPressed = false;
1614 } 1614 }
1615} 1615}
1616void MainWindow::keyPressEvent ( QKeyEvent * e ) 1616void MainWindow::keyPressEvent ( QKeyEvent * e )
1617{ 1617{
1618 qApp->processEvents(); 1618 qApp->processEvents();
1619 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1619 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1620 e->ignore(); 1620 e->ignore();
1621 // qDebug(" ignore %d",e->isAutoRepeat() ); 1621 // qDebug(" ignore %d",e->isAutoRepeat() );
1622 return; 1622 return;
1623 } 1623 }
1624 if (! e->isAutoRepeat() ) 1624 if (! e->isAutoRepeat() )
1625 mFlagKeyPressed = true; 1625 mFlagKeyPressed = true;
1626 KOPrefs *p = KOPrefs::instance(); 1626 KOPrefs *p = KOPrefs::instance();
1627 bool showSelectedDates = false; 1627 bool showSelectedDates = false;
1628 int size; 1628 int size;
1629 int pro = 0; 1629 int pro = 0;
1630 //qDebug("MainWindow::keyPressEvent "); 1630 //qDebug("MainWindow::keyPressEvent ");
1631 switch ( e->key() ) { 1631 switch ( e->key() ) {
1632 case Qt::Key_Right: 1632 case Qt::Key_Right:
1633 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1633 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1634 mView->goNextMonth(); 1634 mView->goNextMonth();
1635 else 1635 else
1636 mView->goNext(); 1636 mView->goNext();
1637 showSelectedDates = true; 1637 showSelectedDates = true;
1638 break; 1638 break;
1639 case Qt::Key_Left: 1639 case Qt::Key_Left:
1640 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1640 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1641 mView->goPreviousMonth(); 1641 mView->goPreviousMonth();
1642 else 1642 else
1643 mView->goPrevious(); 1643 mView->goPrevious();
1644 showSelectedDates = true; 1644 showSelectedDates = true;
1645 break; 1645 break;
1646 case Qt::Key_Down: 1646 case Qt::Key_Down:
1647 mView->viewManager()->agendaView()->scrollOneHourDown(); 1647 mView->viewManager()->agendaView()->scrollOneHourDown();
1648 break; 1648 break;
1649 case Qt::Key_Up: 1649 case Qt::Key_Up:
1650 mView->viewManager()->agendaView()->scrollOneHourUp(); 1650 mView->viewManager()->agendaView()->scrollOneHourUp();
1651 break; 1651 break;
1652 case Qt::Key_K: 1652 case Qt::Key_K:
1653 mView->viewManager()->showMonthViewWeek(); 1653 mView->viewManager()->showMonthViewWeek();
1654 break; 1654 break;
1655 case Qt::Key_I: 1655 case Qt::Key_I:
1656 mView->showIncidence(); 1656 mView->showIncidence();
1657 break; 1657 break;
1658 case Qt::Key_Delete: 1658 case Qt::Key_Delete:
1659 case Qt::Key_Backspace: 1659 case Qt::Key_Backspace:
1660 mView->deleteIncidence(); 1660 mView->deleteIncidence();
1661 break; 1661 break;
1662 case Qt::Key_D: 1662 case Qt::Key_D:
1663 mView->viewManager()->showDayView(); 1663 mView->viewManager()->showDayView();
1664 showSelectedDates = true; 1664 showSelectedDates = true;
1665 break; 1665 break;
1666 case Qt::Key_O: 1666 case Qt::Key_O:
1667 mView->toggleFilerEnabled( ); 1667 mView->toggleFilerEnabled( );
1668 break; 1668 break;
1669 case Qt::Key_0: 1669 case Qt::Key_0:
1670 case Qt::Key_1: 1670 case Qt::Key_1:
1671 case Qt::Key_2: 1671 case Qt::Key_2:
1672 case Qt::Key_3: 1672 case Qt::Key_3:
1673 case Qt::Key_4: 1673 case Qt::Key_4:
1674 case Qt::Key_5: 1674 case Qt::Key_5:
1675 case Qt::Key_6: 1675 case Qt::Key_6:
1676 case Qt::Key_7: 1676 case Qt::Key_7:
1677 case Qt::Key_8: 1677 case Qt::Key_8:
1678 case Qt::Key_9: 1678 case Qt::Key_9:
1679 pro = e->key()-48; 1679 pro = e->key()-48;
1680 if ( pro == 0 ) 1680 if ( pro == 0 )
1681 pro = 10; 1681 pro = 10;
1682 if ( e->state() == Qt::ControlButton) 1682 if ( e->state() == Qt::ControlButton)
1683 pro += 10; 1683 pro += 10;
1684 break; 1684 break;
1685 case Qt::Key_M: 1685 case Qt::Key_M:
1686 mView->viewManager()->showMonthView(); 1686 mView->viewManager()->showMonthView();
1687 showSelectedDates = true; 1687 showSelectedDates = true;
1688 break; 1688 break;
1689 case Qt::Key_Insert: 1689 case Qt::Key_Insert:
1690 mView->newEvent(); 1690 mView->newEvent();
1691 break; 1691 break;
1692 case Qt::Key_S : 1692 case Qt::Key_S :
1693 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1693 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1694 mView->newSubTodo(); 1694 mView->newSubTodo();
1695 else 1695 else
1696 mView->dialogManager()->showSearchDialog(); 1696 mView->dialogManager()->showSearchDialog();
1697 break; 1697 break;
1698 case Qt::Key_Y : 1698 case Qt::Key_Y :
1699 case Qt::Key_Z : 1699 case Qt::Key_Z :
1700 mView->viewManager()->showWorkWeekView(); 1700 mView->viewManager()->showWorkWeekView();
1701 showSelectedDates = true; 1701 showSelectedDates = true;
1702 break; 1702 break;
1703 case Qt::Key_U : 1703 case Qt::Key_U :
1704 mView->viewManager()->showWeekView(); 1704 mView->viewManager()->showWeekView();
1705 showSelectedDates = true; 1705 showSelectedDates = true;
1706 break; 1706 break;
1707 case Qt::Key_H : 1707 case Qt::Key_H :
1708 keyBindings(); 1708 keyBindings();
1709 break; 1709 break;
1710 case Qt::Key_W: 1710 case Qt::Key_W:
1711 mView->viewManager()->showWhatsNextView(); 1711 mView->viewManager()->showWhatsNextView();
1712 break; 1712 break;
1713 case Qt::Key_L: 1713 case Qt::Key_L:
1714 mView->viewManager()->showListView(); 1714 mView->viewManager()->showListView();
1715 break; 1715 break;
1716 case Qt::Key_N: 1716 case Qt::Key_N:
1717 mView->viewManager()->showNextXView(); 1717 mView->viewManager()->showNextXView();
1718 showSelectedDates = true; 1718 showSelectedDates = true;
1719 break; 1719 break;
1720 case Qt::Key_V: 1720 case Qt::Key_V:
1721 mView->viewManager()->showTodoView(); 1721 mView->viewManager()->showTodoView();
1722 break; 1722 break;
1723 case Qt::Key_C: 1723 case Qt::Key_C:
1724 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1724 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1725 break; 1725 break;
1726 case Qt::Key_P: 1726 case Qt::Key_P:
1727 mView->showDatePicker( ); 1727 mView->showDatePicker( );
1728 break; 1728 break;
1729 case Qt::Key_F: 1729 case Qt::Key_F:
1730 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1730 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1731 mView->editFilters(); 1731 mView->editFilters();
1732 else 1732 else
1733 mView->toggleFilter(); 1733 mView->toggleFilter();
1734 break; 1734 break;
1735 case Qt::Key_X: 1735 case Qt::Key_X:
1736 mView->toggleDateNavigatorWidget(); 1736 mView->toggleDateNavigatorWidget();
1737 break; 1737 break;
1738 case Qt::Key_Space: 1738 case Qt::Key_Space:
1739 mView->toggleExpand(); 1739 mView->toggleExpand();
1740 break; 1740 break;
1741 case Qt::Key_A: 1741 case Qt::Key_A:
1742 mView->toggleAllDaySize(); 1742 mView->toggleAllDaySize();
1743 break; 1743 break;
1744 case Qt::Key_T: 1744 case Qt::Key_T:
1745 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1745 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1746 mView->newTodo(); 1746 mView->newTodo();
1747 else { 1747 else {
1748 mView->goToday(); 1748 mView->goToday();
1749 showSelectedDates = true; 1749 showSelectedDates = true;
1750 } 1750 }
1751 break; 1751 break;
1752 case Qt::Key_J: 1752 case Qt::Key_J:
1753 mView->viewManager()->showJournalView(); 1753 mView->viewManager()->showJournalView();
1754 break; 1754 break;
1755 case Qt::Key_B: 1755 case Qt::Key_B:
1756 mView->editIncidenceDescription();; 1756 mView->editIncidenceDescription();;
1757 break; 1757 break;
1758 // case Qt::Key_Return: 1758 // case Qt::Key_Return:
1759 case Qt::Key_E: 1759 case Qt::Key_E:
1760 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1760 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1761 mView->newEvent(); 1761 mView->newEvent();
1762 else 1762 else
1763 mView->editIncidence(); 1763 mView->editIncidence();
1764 break; 1764 break;
1765 case Qt::Key_Plus: 1765 case Qt::Key_Plus:
1766 size = p->mHourSize +2; 1766 size = p->mHourSize +2;
1767 if ( size <= 22 ) 1767 if ( size <= 22 )
1768 configureAgenda( size ); 1768 configureAgenda( size );
1769 break; 1769 break;
1770 case Qt::Key_Minus: 1770 case Qt::Key_Minus:
1771 size = p->mHourSize - 2; 1771 size = p->mHourSize - 2;
1772 if ( size >= 4 ) 1772 if ( size >= 4 )
1773 configureAgenda( size ); 1773 configureAgenda( size );
1774 break; 1774 break;
1775 1775
1776 1776
1777 default: 1777 default:
1778 e->ignore(); 1778 e->ignore();
1779 } 1779 }
1780 if ( pro > 0 ) { 1780 if ( pro > 0 ) {
1781 mView->selectFilter( pro-1 ); 1781 mView->selectFilter( pro-1 );
1782 } 1782 }
1783 if ( showSelectedDates ) { 1783 if ( showSelectedDates ) {
1784 ;// setCaptionToDates(); 1784 ;// setCaptionToDates();
1785 } 1785 }
1786 1786
1787} 1787}
1788 1788
1789void MainWindow::fillFilterMenu() 1789void MainWindow::fillFilterMenu()
1790{ 1790{
1791 selectFilterMenu->clear(); 1791 selectFilterMenu->clear();
1792 bool disable = false; 1792 bool disable = false;
1793 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 1793 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
1794 selectFilterMenu->insertSeparator(); 1794 selectFilterMenu->insertSeparator();
1795 if ( mView->filterView()->filtersEnabled() ) { 1795 if ( mView->filterView()->filtersEnabled() ) {
1796 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); 1796 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
1797 } 1797 }
1798 else { 1798 else {
1799 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); 1799 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
1800 disable = true; 1800 disable = true;
1801 } 1801 }
1802 selectFilterMenu->insertSeparator(); 1802 selectFilterMenu->insertSeparator();
1803 QPtrList<CalFilter> fili = mView->filters(); 1803 QPtrList<CalFilter> fili = mView->filters();
1804 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1804 CalFilter *curfilter = mView->filterView()->selectedFilter();
1805 CalFilter *filter = fili.first(); 1805 CalFilter *filter = fili.first();
1806 int iii = 2; 1806 int iii = 2;
1807 while(filter) { 1807 while(filter) {
1808 selectFilterMenu->insertItem( filter->name(), iii ); 1808 selectFilterMenu->insertItem( filter->name(), iii );
1809 if ( filter == curfilter) 1809 if ( filter == curfilter)
1810 selectFilterMenu->setItemChecked( iii, true ); 1810 selectFilterMenu->setItemChecked( iii, true );
1811 if ( disable ) 1811 if ( disable )
1812 selectFilterMenu->setItemEnabled( iii, false ); 1812 selectFilterMenu->setItemEnabled( iii, false );
1813 filter = fili.next(); 1813 filter = fili.next();
1814 ++iii; 1814 ++iii;
1815 } 1815 }
1816} 1816}
1817void MainWindow::selectFilter( int fil ) 1817void MainWindow::selectFilter( int fil )
1818{ 1818{
1819 if ( fil == 0 ) { 1819 if ( fil == 0 ) {
1820 mView->editFilters( ); 1820 mView->editFilters( );
1821 } else if ( fil == 1 ){ 1821 } else if ( fil == 1 ){
1822 mView->toggleFilerEnabled( ); 1822 mView->toggleFilerEnabled( );
1823 } else { 1823 } else {
1824 mView->selectFilter( fil-2 ); 1824 mView->selectFilter( fil-2 );
1825 } 1825 }
1826} 1826}
1827void MainWindow::configureToolBar( int item ) 1827void MainWindow::configureToolBar( int item )
1828{ 1828{
1829 1829
1830 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1830 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1831 KOPrefs *p = KOPrefs::instance(); 1831 KOPrefs *p = KOPrefs::instance();
1832 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1832 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1833 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1833 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1834 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1834 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1835 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1835 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1836 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1836 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1837 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1837 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1838 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1838 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1839 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 1839 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
1840 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1840 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1841 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1841 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1842 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1842 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1843 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1843 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1844 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1844 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1845 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1845 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1846 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1846 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1847 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1847 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1848 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1848 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1849 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1849 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1850 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1850 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1851 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1851 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1852 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 1852 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
1853 // initActions(); 1853 // initActions();
1854} 1854}
1855 1855void MainWindow::setCaption ( const QString & c )
1856{
1857 QString cap = c;
1858 cap.replace( QRegExp("\n"), " " );
1859 cap = cap.stripWhiteSpace();
1860 if ( cap.isEmpty() )
1861 cap = "KO/Pi";
1862 QWidget::setCaption( cap );
1863}
1856void MainWindow::setCaptionToDates() 1864void MainWindow::setCaptionToDates()
1857{ 1865{
1858 QString selDates; 1866 QString selDates;
1859 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1867 QDate date = mView->startDate();
1868 if ( ! date.isValid() ) {
1869 setCaption("");
1870 return;
1871 }
1872 selDates = KGlobal::locale()->formatDate( date, true);
1860 if (mView->startDate() < mView->endDate() ) 1873 if (mView->startDate() < mView->endDate() )
1861 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1874 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1862 else { 1875 else {
1863 QString addString; 1876 QString addString;
1864 if ( mView->startDate() == QDateTime::currentDateTime().date() ) 1877 if ( date == QDateTime::currentDateTime().date() )
1865 addString = i18n("Today"); 1878 addString = i18n("Today");
1866 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) 1879 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
1867 addString = i18n("Tomorrow"); 1880 addString = i18n("Tomorrow");
1868 if ( !addString.isEmpty() ) 1881 if ( !addString.isEmpty() )
1869 selDates = addString+", "+selDates ; 1882 selDates = addString+", "+selDates ;
1870 } 1883 }
1871 setCaption( i18n("Dates: ") + selDates ); 1884 setCaption( i18n("Dates: ") + selDates );
1872 1885
1873} 1886}
1874void MainWindow::showConfigureAgenda( ) 1887void MainWindow::showConfigureAgenda( )
1875{ 1888{
1876 int iii; 1889 int iii;
1877 for ( iii = 1;iii<= 10 ;++iii ){ 1890 for ( iii = 1;iii<= 10 ;++iii ){
1878 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 1891 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
1879 } 1892 }
1880 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 1893 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1881} 1894}
1882void MainWindow::configureAgenda( int item ) 1895void MainWindow::configureAgenda( int item )
1883{ 1896{
1884 if ( KOPrefs::instance()->mHourSize == item ) 1897 if ( KOPrefs::instance()->mHourSize == item )
1885 return; 1898 return;
1886 KOPrefs::instance()->mHourSize=item; 1899 KOPrefs::instance()->mHourSize=item;
1887 mView->viewManager()->agendaView()->updateConfig(); 1900 mView->viewManager()->agendaView()->updateConfig();
1888} 1901}
1889 1902
1890void MainWindow::saveCalendar() 1903void MainWindow::saveCalendar()
1891{ 1904{
1892 QString fn = KOPrefs::instance()->mLastSaveFile; 1905 QString fn = KOPrefs::instance()->mLastSaveFile;
1893 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1906 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1894 1907
1895 if ( fn == "" ) 1908 if ( fn == "" )
1896 return; 1909 return;
1897 QFileInfo info; 1910 QFileInfo info;
1898 info.setFile( fn ); 1911 info.setFile( fn );
1899 QString mes; 1912 QString mes;
1900 bool createbup = true; 1913 bool createbup = true;
1901 if ( info. exists() ) { 1914 if ( info. exists() ) {
1902 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1915 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1903 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1916 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1904 i18n("Overwrite!"), i18n("Cancel"), 0, 1917 i18n("Overwrite!"), i18n("Cancel"), 0,
1905 0, 1 ); 1918 0, 1 );
1906 if ( result != 0 ) { 1919 if ( result != 0 ) {
1907 createbup = false; 1920 createbup = false;
1908 } 1921 }
1909 } 1922 }
1910 if ( createbup ) { 1923 if ( createbup ) {
1911 mView->saveCalendar( fn ); 1924 mView->saveCalendar( fn );
1912 mes = i18n("KO/Pi:Saved %1").arg(fn); 1925 mes = i18n("KO/Pi:Saved %1").arg(fn);
1913 KOPrefs::instance()->mLastSaveFile = fn; 1926 KOPrefs::instance()->mLastSaveFile = fn;
1914 setCaption(mes); 1927 setCaption(mes);
1915 } 1928 }
1916} 1929}
1917void MainWindow::loadCalendar() 1930void MainWindow::loadCalendar()
1918{ 1931{
1919 1932
1920 QString fn = KOPrefs::instance()->mLastLoadFile; 1933 QString fn = KOPrefs::instance()->mLastLoadFile;
1921 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1934 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1922 1935
1923 if ( fn == "" ) 1936 if ( fn == "" )
1924 return; 1937 return;
1925 QFileInfo info; 1938 QFileInfo info;
1926 info.setFile( fn ); 1939 info.setFile( fn );
1927 QString mess; 1940 QString mess;
1928 bool loadbup = true; 1941 bool loadbup = true;
1929 if ( info. exists() ) { 1942 if ( info. exists() ) {
1930 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1943 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1931 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1944 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1932 mess, 1945 mess,
1933 i18n("Load!"), i18n("Cancel"), 0, 1946 i18n("Load!"), i18n("Cancel"), 0,
1934 0, 1 ); 1947 0, 1 );
1935 if ( result != 0 ) { 1948 if ( result != 0 ) {
1936 loadbup = false; 1949 loadbup = false;
1937 } 1950 }
1938 } else { 1951 } else {
1939 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1952 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1940 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1953 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1941 0, 1 ); 1954 0, 1 );
1942 1955
1943 return; 1956 return;
1944 } 1957 }
1945 if ( loadbup ) { 1958 if ( loadbup ) {
1946 mView->openCalendar( fn ); 1959 mView->openCalendar( fn );
1947 KOPrefs::instance()->mLastLoadFile = fn; 1960 KOPrefs::instance()->mLastLoadFile = fn;
1948 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1961 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1949 setCaption(mess); 1962 setCaption(mess);
1950 } 1963 }
1951 1964
1952} 1965}
1953void MainWindow::quickImportIcal() 1966void MainWindow::quickImportIcal()
1954{ 1967{
1955 importFile( KOPrefs::instance()->mLastImportFile, false ); 1968 importFile( KOPrefs::instance()->mLastImportFile, false );
1956} 1969}
1957void MainWindow::importFile( QString fn, bool quick ) 1970void MainWindow::importFile( QString fn, bool quick )
1958{ 1971{
1959 QFileInfo info; 1972 QFileInfo info;
1960 info.setFile( fn ); 1973 info.setFile( fn );
1961 QString mess; 1974 QString mess;
1962 bool loadbup = true; 1975 bool loadbup = true;
1963 if ( !info. exists() ) { 1976 if ( !info. exists() ) {
1964 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1977 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1965 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1978 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1966 mess ); 1979 mess );
1967 return; 1980 return;
1968 } 1981 }
1969 int result = 0; 1982 int result = 0;
1970 if ( !quick ) { 1983 if ( !quick ) {
1971 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1984 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1972 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1985 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1973 mess, 1986 mess,
1974 "Import", "Cancel", 0, 1987 "Import", "Cancel", 0,
1975 0, 1 ); 1988 0, 1 );
1976 } 1989 }
1977 if ( result == 0 ) { 1990 if ( result == 0 ) {
1978 if ( mView->openCalendar( fn, true )) { 1991 if ( mView->openCalendar( fn, true )) {
1979 KOPrefs::instance()->mLastImportFile = fn; 1992 KOPrefs::instance()->mLastImportFile = fn;
1980 setCaption(i18n("Imported file successfully")); 1993 setCaption(i18n("Imported file successfully"));
1981 } else { 1994 } else {
1982 setCaption(i18n("Error importing file")); 1995 setCaption(i18n("Error importing file"));
1983 } 1996 }
1984 } 1997 }
1985} 1998}
1986 1999
1987void MainWindow::importIcal() 2000void MainWindow::importIcal()
1988{ 2001{
1989 2002
1990 QString fn =KOPrefs::instance()->mLastImportFile; 2003 QString fn =KOPrefs::instance()->mLastImportFile;
1991 2004
1992 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2005 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1993 if ( fn == "" ) 2006 if ( fn == "" )
1994 return; 2007 return;
1995 importFile( fn, true ); 2008 importFile( fn, true );
1996 2009
1997} 2010}
1998 2011
1999void MainWindow::exportVCalendar() 2012void MainWindow::exportVCalendar()
2000{ 2013{
2001 QString fn = KOPrefs::instance()->mLastVcalFile; 2014 QString fn = KOPrefs::instance()->mLastVcalFile;
2002 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2015 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2003 if ( fn == "" ) 2016 if ( fn == "" )
2004 return; 2017 return;
2005 QFileInfo info; 2018 QFileInfo info;
2006 info.setFile( fn ); 2019 info.setFile( fn );
2007 QString mes; 2020 QString mes;
2008 bool createbup = true; 2021 bool createbup = true;
2009 if ( info. exists() ) { 2022 if ( info. exists() ) {
2010 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2023 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2011 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2024 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2012 i18n("Overwrite!"), i18n("Cancel"), 0, 2025 i18n("Overwrite!"), i18n("Cancel"), 0,
2013 0, 1 ); 2026 0, 1 );
2014 if ( result != 0 ) { 2027 if ( result != 0 ) {
2015 createbup = false; 2028 createbup = false;
2016 } 2029 }
2017 } 2030 }
2018 if ( createbup ) { 2031 if ( createbup ) {
2019 if ( mView->exportVCalendar( fn ) ) { 2032 if ( mView->exportVCalendar( fn ) ) {
2020 KOPrefs::instance()->mLastVcalFile = fn; 2033 KOPrefs::instance()->mLastVcalFile = fn;
2021 if ( fn.length() > 20 ) 2034 if ( fn.length() > 20 )
2022 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2035 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2023 else 2036 else
2024 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2037 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2025 setCaption(mes); 2038 setCaption(mes);
2026 } 2039 }
2027 } 2040 }
2028 2041
2029} 2042}
2030QString MainWindow::sentSyncFile() 2043QString MainWindow::sentSyncFile()
2031{ 2044{
2032#ifdef DESKTOP_VERSION 2045#ifdef DESKTOP_VERSION
2033 return locateLocal( "tmp", "copysynccal.ics" ); 2046 return locateLocal( "tmp", "copysynccal.ics" );
2034#else 2047#else
2035 return QString( "/tmp/copysynccal.ics" ); 2048 return QString( "/tmp/copysynccal.ics" );
2036#endif 2049#endif
2037} 2050}
2038 2051
2039void MainWindow::syncFileRequest() 2052void MainWindow::syncFileRequest()
2040{ 2053{
2041 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2054 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2042 mSyncManager->slotSyncMenu( 999 ); 2055 mSyncManager->slotSyncMenu( 999 );
2043 } 2056 }
2044 2057
2045 setCaption(i18n("Saving Data to temp file ..." )); 2058 setCaption(i18n("Saving Data to temp file ..." ));
2046 mView->saveCalendar( sentSyncFile() ); 2059 mView->saveCalendar( sentSyncFile() );
2047 setCaption(i18n("Data saved to temp file!" )); 2060 setCaption(i18n("Data saved to temp file!" ));
2048 2061
2049} 2062}
2050void MainWindow::getFile( bool success ) 2063void MainWindow::getFile( bool success )
2051{ 2064{
2052 if ( ! success ) { 2065 if ( ! success ) {
2053 setCaption( i18n("Error receiving file. Nothing changed!") ); 2066 setCaption( i18n("Error receiving file. Nothing changed!") );
2054 return; 2067 return;
2055 } 2068 }
2056 mView->openCalendar( sentSyncFile() ); 2069 mView->openCalendar( sentSyncFile() );
2057 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2070 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2058 mSyncManager->slotSyncMenu( 999 ); 2071 mSyncManager->slotSyncMenu( 999 );
2059 } 2072 }
2060 setCaption( i18n("Pi-Sync successful!") ); 2073 setCaption( i18n("Pi-Sync successful!") );
2061} 2074}
2062 2075
2063void MainWindow::printSel( ) 2076void MainWindow::printSel( )
2064{ 2077{
2065 mView->viewManager()->agendaView()->agenda()->printSelection(); 2078 mView->viewManager()->agendaView()->agenda()->printSelection();
2066} 2079}
2067 2080
2068void MainWindow::printCal() 2081void MainWindow::printCal()
2069{ 2082{
2070 mView->print();//mCp->showDialog(); 2083 mView->print();//mCp->showDialog();
2071} 2084}
2072 2085
2073 2086
2074#include "libkdepim/kdatepicker.h" 2087#include "libkdepim/kdatepicker.h"
2075#include <kdatetbl.h> 2088#include <kdatetbl.h>
2076void MainWindow::weekAction() 2089void MainWindow::weekAction()
2077{ 2090{
2078 int month; 2091 int month;
2079 KPopupFrame* popup = new KPopupFrame(this); 2092 KPopupFrame* popup = new KPopupFrame(this);
2080 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2093 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2081 // ----- 2094 // -----
2082 picker->resize(picker->sizeHint()); 2095 picker->resize(picker->sizeHint());
2083 popup->setMainWidget(picker); 2096 popup->setMainWidget(picker);
2084 picker->setFocus(); 2097 picker->setFocus();
2085 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2098 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2086 int x = 0; 2099 int x = 0;
2087 int y = iconToolBar->height(); 2100 int y = iconToolBar->height();
2088 int dX = 0; 2101 int dX = 0;
2089 int dY = 0; 2102 int dY = 0;
2090 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2103 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2091 if ( iconToolBar->y() > height()/2 ) { 2104 if ( iconToolBar->y() > height()/2 ) {
2092 dY = picker->sizeHint().height()+8; 2105 dY = picker->sizeHint().height()+8;
2093 y = 0; 2106 y = 0;
2094 } 2107 }
2095 } else { 2108 } else {
2096 if ( iconToolBar->x() > width()/2 ) { // right side 2109 if ( iconToolBar->x() > width()/2 ) { // right side
2097 x=0; 2110 x=0;
2098 dX= picker->sizeHint().width()+8; 2111 dX= picker->sizeHint().width()+8;
2099 y = 0; 2112 y = 0;
2100 } else { 2113 } else {
2101 x= iconToolBar->width(); 2114 x= iconToolBar->width();
2102 y = 0; 2115 y = 0;
2103 } 2116 }
2104 } 2117 }
2105 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2118 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2106 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2119 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2107 { 2120 {
2108 month = picker->getResult(); 2121 month = picker->getResult();
2109 emit selectWeek ( month ); 2122 emit selectWeek ( month );
2110 //qDebug("weekSelected %d ", month); 2123 //qDebug("weekSelected %d ", month);
2111 } 2124 }
2112 delete popup; 2125 delete popup;
2113} 2126}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 5808700..7604529 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,159 +1,160 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include "simplealarmclient.h" 13#include "simplealarmclient.h"
14#include <ksyncmanager.h> 14#include <ksyncmanager.h>
15#ifndef DESKTOP_VERSION 15#ifndef DESKTOP_VERSION
16#include <qcopchannel_qws.h> 16#include <qcopchannel_qws.h>
17#endif 17#endif
18class QAction; 18class QAction;
19class CalendarView; 19class CalendarView;
20class KSyncProfile; 20class KSyncProfile;
21#ifdef DESKTOP_VERSION 21#ifdef DESKTOP_VERSION
22 22
23#define QPEToolBar QToolBar 23#define QPEToolBar QToolBar
24#define QPEMenuBar QMenuBar 24#define QPEMenuBar QMenuBar
25#endif 25#endif
26class QPEToolBar; 26class QPEToolBar;
27 27
28 28
29namespace KCal { 29namespace KCal {
30class CalendarLocal; 30class CalendarLocal;
31} 31}
32 32
33class KOMenuBar : public QMenuBar 33class KOMenuBar : public QMenuBar
34{ 34{
35 public: 35 public:
36 KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;} 36 KOMenuBar( QWidget *parent=0 ): QMenuBar (parent ) {;}
37 QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );} 37 QSize sizeHint () const{ qDebug("sizejint ");return QSize ( 40,25 );}
38}; 38};
39 39
40using namespace KCal; 40using namespace KCal;
41 41
42class MainWindow : public QMainWindow 42class MainWindow : public QMainWindow
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 public: 45 public:
46 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 46 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
47 ~MainWindow(); 47 ~MainWindow();
48 bool beamReceiveEnabled(); 48 bool beamReceiveEnabled();
49 static QString defaultFileName(); 49 static QString defaultFileName();
50 static QString syncFileName(); 50 static QString syncFileName();
51 static QString resourcePath(); 51 static QString resourcePath();
52 public slots: 52 public slots:
53 void setCaption ( const QString & );
53 void updateWeekNum(const KCal::DateList &); 54 void updateWeekNum(const KCal::DateList &);
54 void updateWeek(QDate); 55 void updateWeek(QDate);
55 virtual void showMaximized (); 56 virtual void showMaximized ();
56 void configureAgenda( int ); 57 void configureAgenda( int );
57 void recieve( const QCString& msg, const QByteArray& data ); 58 void recieve( const QCString& msg, const QByteArray& data );
58 protected slots: 59 protected slots:
59 void setCaptionToDates(); 60 void setCaptionToDates();
60 void weekAction(); 61 void weekAction();
61 void about(); 62 void about();
62 void licence(); 63 void licence();
63 void faq(); 64 void faq();
64 void usertrans(); 65 void usertrans();
65 void features(); 66 void features();
66 void synchowto(); 67 void synchowto();
67 void kdesynchowto(); 68 void kdesynchowto();
68 void multisynchowto(); 69 void multisynchowto();
69 void whatsNew(); 70 void whatsNew();
70 void keyBindings(); 71 void keyBindings();
71 void aboutAutoSaving();; 72 void aboutAutoSaving();;
72 void aboutKnownBugs(); 73 void aboutKnownBugs();
73 74
74 void processIncidenceSelection( Incidence * ); 75 void processIncidenceSelection( Incidence * );
75 76
76 void importQtopia(); 77 void importQtopia();
77 void importBday(); 78 void importBday();
78 void importOL(); 79 void importOL();
79 void importIcal(); 80 void importIcal();
80 void importFile( QString, bool ); 81 void importFile( QString, bool );
81 void quickImportIcal(); 82 void quickImportIcal();
82 83
83 void slotModifiedChanged( bool ); 84 void slotModifiedChanged( bool );
84 85
85 void save(); 86 void save();
86 void saveStopTimer(); 87 void saveStopTimer();
87 void configureToolBar( int ); 88 void configureToolBar( int );
88 void printSel(); 89 void printSel();
89 void printCal(); 90 void printCal();
90 void saveCalendar(); 91 void saveCalendar();
91 void loadCalendar(); 92 void loadCalendar();
92 void exportVCalendar(); 93 void exportVCalendar();
93 void fillFilterMenu(); 94 void fillFilterMenu();
94 void selectFilter( int ); 95 void selectFilter( int );
95 void exportToPhone( int ); 96 void exportToPhone( int );
96 void toggleBeamReceive(); 97 void toggleBeamReceive();
97 void disableBR(bool); 98 void disableBR(bool);
98 signals: 99 signals:
99 void selectWeek ( int ); 100 void selectWeek ( int );
100 private slots: 101 private slots:
101 void showConfigureAgenda(); 102 void showConfigureAgenda();
102 void getFile( bool ); 103 void getFile( bool );
103 void syncFileRequest(); 104 void syncFileRequest();
104 105
105 protected: 106 protected:
106 QString sentSyncFile(); 107 QString sentSyncFile();
107 void displayText( QString, QString); 108 void displayText( QString, QString);
108 void enableIncidenceActions( bool ); 109 void enableIncidenceActions( bool );
109 110
110 private: 111 private:
111 bool mBRdisabled; 112 bool mBRdisabled;
112#ifndef DESKTOP_VERSION 113#ifndef DESKTOP_VERSION
113 QCopChannel* infrared; 114 QCopChannel* infrared;
114#endif 115#endif
115 QAction* brAction; 116 QAction* brAction;
116 KSyncManager* mSyncManager; 117 KSyncManager* mSyncManager;
117 bool mClosed; 118 bool mClosed;
118 void saveOnClose(); 119 void saveOnClose();
119 bool mFlagKeyPressed; 120 bool mFlagKeyPressed;
120 bool mBlockAtStartup; 121 bool mBlockAtStartup;
121 QPEToolBar *iconToolBar; 122 QPEToolBar *iconToolBar;
122 void initActions(); 123 void initActions();
123 void setDefaultPreferences(); 124 void setDefaultPreferences();
124 void keyPressEvent ( QKeyEvent * ) ; 125 void keyPressEvent ( QKeyEvent * ) ;
125 void keyReleaseEvent ( QKeyEvent * ) ; 126 void keyReleaseEvent ( QKeyEvent * ) ;
126 QPopupMenu *configureToolBarMenu; 127 QPopupMenu *configureToolBarMenu;
127 QPopupMenu *selectFilterMenu; 128 QPopupMenu *selectFilterMenu;
128 QPopupMenu *configureAgendaMenu, *syncMenu; 129 QPopupMenu *configureAgendaMenu, *syncMenu;
129 CalendarLocal *mCalendar; 130 CalendarLocal *mCalendar;
130 CalendarView *mView; 131 CalendarView *mView;
131 QAction *mNewSubTodoAction; 132 QAction *mNewSubTodoAction;
132 QAction *mWeekAction; 133 QAction *mWeekAction;
133 QFont mWeekFont; 134 QFont mWeekFont;
134 QPixmap mWeekPixmap; 135 QPixmap mWeekPixmap;
135 QColor mWeekBgColor; 136 QColor mWeekBgColor;
136 137
137 QAction *mShowAction; 138 QAction *mShowAction;
138 QAction *mEditAction; 139 QAction *mEditAction;
139 QAction *mDeleteAction; 140 QAction *mDeleteAction;
140 QAction *mCloneAction; 141 QAction *mCloneAction;
141 QAction *mMoveAction; 142 QAction *mMoveAction;
142 QAction *mBeamAction; 143 QAction *mBeamAction;
143 QAction *mCancelAction; 144 QAction *mCancelAction;
144 145
145 QAction *mToggleNav; 146 QAction *mToggleNav;
146 QAction *mToggleFilter; 147 QAction *mToggleFilter;
147 QAction *mToggleAllday; 148 QAction *mToggleAllday;
148 149
149 150
150 void closeEvent( QCloseEvent* ce ); 151 void closeEvent( QCloseEvent* ce );
151 SimpleAlarmClient mAlarmClient; 152 SimpleAlarmClient mAlarmClient;
152 QTimer mSaveTimer; 153 QTimer mSaveTimer;
153 //bool mBlockSaveFlag; 154 //bool mBlockSaveFlag;
154 bool mCalendarModifiedFlag; 155 bool mCalendarModifiedFlag;
155 QPixmap loadPixmap( QString ); 156 QPixmap loadPixmap( QString );
156}; 157};
157 158
158 159
159#endif 160#endif