summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-09 18:02:44 (UTC)
committer zautrix <zautrix>2004-08-09 18:02:44 (UTC)
commit4f05a9fcbb9e54184aef93883886aaf865104463 (patch) (unidiff)
treef5e94f7694b74dca3b11e1e74a94058a4526dafe
parente1909ade2188e53feee65089d5f2882563876c58 (diff)
downloadkdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.zip
kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.tar.gz
kdepimpi-4f05a9fcbb9e54184aef93883886aaf865104463.tar.bz2
more syncing
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp21
-rw-r--r--libkcal/phoneformat.cpp60
-rw-r--r--libkcal/phoneformat.h2
-rw-r--r--libkcal/vcalformat.cpp19
-rw-r--r--libkcal/vcalformat.h2
5 files changed, 52 insertions, 52 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index cce182a..6c0aa9b 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2069 +1,2088 @@
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 <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qapp.h> 11#include <qapp.h>
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qwmatrix.h> 14#include <qwmatrix.h>
15#include <qtextbrowser.h> 15#include <qtextbrowser.h>
16#include <qtextstream.h> 16#include <qtextstream.h>
17#ifndef DESKTOP_VERSION 17#ifndef DESKTOP_VERSION
18#include <qpe/global.h> 18#include <qpe/global.h>
19#include <qpe/qpemenubar.h> 19#include <qpe/qpemenubar.h>
20#include <qpe/qpetoolbar.h> 20#include <qpe/qpetoolbar.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qtopia/alarmserver.h> 23#include <qtopia/alarmserver.h>
24#include <qtopia/qcopenvelope_qws.h> 24#include <qtopia/qcopenvelope_qws.h>
25#else 25#else
26#include <qmenubar.h> 26#include <qmenubar.h>
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qapplication.h> 28#include <qapplication.h>
29//#include <resource.h> 29//#include <resource.h>
30 30
31#endif 31#endif
32#include <libkcal/calendarlocal.h> 32#include <libkcal/calendarlocal.h>
33#include <libkcal/todo.h> 33#include <libkcal/todo.h>
34#include <libkdepim/ksyncprofile.h> 34#include <libkdepim/ksyncprofile.h>
35#include <libkdepim/kincidenceformatter.h> 35#include <libkdepim/kincidenceformatter.h>
36 36
37#include "calendarview.h" 37#include "calendarview.h"
38#include "koviewmanager.h" 38#include "koviewmanager.h"
39#include "datenavigator.h" 39#include "datenavigator.h"
40#include "koagendaview.h" 40#include "koagendaview.h"
41#include "koagenda.h" 41#include "koagenda.h"
42#include "kodialogmanager.h" 42#include "kodialogmanager.h"
43#include "kdialogbase.h" 43#include "kdialogbase.h"
44#include "kapplication.h" 44#include "kapplication.h"
45#include "kofilterview.h" 45#include "kofilterview.h"
46#include "kstandarddirs.h" 46#include "kstandarddirs.h"
47#include "koprefs.h" 47#include "koprefs.h"
48#include "kfiledialog.h" 48#include "kfiledialog.h"
49#include "koglobals.h" 49#include "koglobals.h"
50#include "kglobal.h" 50#include "kglobal.h"
51#include "klocale.h" 51#include "klocale.h"
52#include "kconfig.h" 52#include "kconfig.h"
53#include "simplealarmclient.h" 53#include "simplealarmclient.h"
54using namespace KCal; 54using namespace KCal;
55#ifndef _WIN32_ 55#ifndef _WIN32_
56#include <unistd.h> 56#include <unistd.h>
57#else 57#else
58#include "koimportoldialog.h" 58#include "koimportoldialog.h"
59#endif 59#endif
60#include "mainwindow.h" 60#include "mainwindow.h"
61 61
62int globalFlagBlockStartup; 62int globalFlagBlockStartup;
63MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 63MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
64 QMainWindow( parent, name ) 64 QMainWindow( parent, name )
65{ 65{
66 66
67#ifdef DESKTOP_VERSION 67#ifdef DESKTOP_VERSION
68 setFont( QFont("Arial"), 14 ); 68 setFont( QFont("Arial"), 14 );
69#endif 69#endif
70 70
71 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 71 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
72 QString confFile = locateLocal("config","korganizerrc"); 72 QString confFile = locateLocal("config","korganizerrc");
73 QFileInfo finf ( confFile ); 73 QFileInfo finf ( confFile );
74 bool showWarning = !finf.exists(); 74 bool showWarning = !finf.exists();
75 setIcon(SmallIcon( "ko24" ) ); 75 setIcon(SmallIcon( "ko24" ) );
76 mBlockAtStartup = true; 76 mBlockAtStartup = true;
77 mFlagKeyPressed = false; 77 mFlagKeyPressed = false;
78 setCaption("KOrganizer/Pi"); 78 setCaption("KOrganizer/Pi");
79 KOPrefs *p = KOPrefs::instance(); 79 KOPrefs *p = KOPrefs::instance();
80 // if ( QApplication::desktop()->height() > 480 ) { 80 // if ( QApplication::desktop()->height() > 480 ) {
81// if ( p->mHourSize == 4 ) 81// if ( p->mHourSize == 4 )
82// p->mHourSize = 6; 82// p->mHourSize = 6;
83// } 83// }
84 if ( p->mHourSize > 18 ) 84 if ( p->mHourSize > 18 )
85 p->mHourSize = 18; 85 p->mHourSize = 18;
86 QMainWindow::ToolBarDock tbd; 86 QMainWindow::ToolBarDock tbd;
87 if ( p->mToolBarHor ) { 87 if ( p->mToolBarHor ) {
88 if ( p->mToolBarUp ) 88 if ( p->mToolBarUp )
89 tbd = Bottom; 89 tbd = Bottom;
90 else 90 else
91 tbd = Top; 91 tbd = Top;
92 } 92 }
93 else { 93 else {
94 if ( p->mToolBarUp ) 94 if ( p->mToolBarUp )
95 tbd = Right; 95 tbd = Right;
96 else 96 else
97 tbd = Left; 97 tbd = Left;
98 } 98 }
99 if ( KOPrefs::instance()->mUseAppColors ) 99 if ( KOPrefs::instance()->mUseAppColors )
100 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 100 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
101 globalFlagBlockStartup = 1; 101 globalFlagBlockStartup = 1;
102 iconToolBar = new QPEToolBar( this ); 102 iconToolBar = new QPEToolBar( this );
103 addToolBar (iconToolBar , tbd ); 103 addToolBar (iconToolBar , tbd );
104 mBlockSaveFlag = false; 104 mBlockSaveFlag = false;
105 mCalendarModifiedFlag = false; 105 mCalendarModifiedFlag = false;
106 106
107 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 107 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
108 splash->setAlignment ( AlignCenter ); 108 splash->setAlignment ( AlignCenter );
109 setCentralWidget( splash ); 109 setCentralWidget( splash );
110#ifndef DESKTOP_VERSION 110#ifndef DESKTOP_VERSION
111 showMaximized(); 111 showMaximized();
112#endif 112#endif
113 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 113 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
114 setDefaultPreferences(); 114 setDefaultPreferences();
115 mCalendar = new CalendarLocal(); 115 mCalendar = new CalendarLocal();
116 mView = new CalendarView( mCalendar, this,"mCalendar " ); 116 mView = new CalendarView( mCalendar, this,"mCalendar " );
117 mView->hide(); 117 mView->hide();
118 //mView->resize(splash->size() ); 118 //mView->resize(splash->size() );
119 initActions(); 119 initActions();
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121 iconToolBar->show(); 121 iconToolBar->show();
122 qApp->processEvents(); 122 qApp->processEvents();
123#endif 123#endif
124 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 124 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
125 int vh = height() ; 125 int vh = height() ;
126 int vw = width(); 126 int vw = width();
127 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 127 //qDebug("Toolbar hei %d ",iconToolBar->height() );
128 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 128 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
129 vh -= iconToolBar->height(); 129 vh -= iconToolBar->height();
130 } else { 130 } else {
131 vw -= iconToolBar->height(); 131 vw -= iconToolBar->height();
132 } 132 }
133 //mView->setMaximumSize( splash->size() ); 133 //mView->setMaximumSize( splash->size() );
134 //mView->resize( splash->size() ); 134 //mView->resize( splash->size() );
135 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 135 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
136 mView->readSettings(); 136 mView->readSettings();
137 bool oldOpened = false; 137 bool oldOpened = false;
138 bool newFile = false; 138 bool newFile = false;
139 if( !QFile::exists( defaultFileName() ) ) { 139 if( !QFile::exists( defaultFileName() ) ) {
140 QFileInfo finfo ( defaultFileName() ); 140 QFileInfo finfo ( defaultFileName() );
141 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 141 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
142 qDebug("oldfile %s ", oldFile.latin1()); 142 qDebug("oldfile %s ", oldFile.latin1());
143 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"; 143 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";
144 finfo.setFile( oldFile ); 144 finfo.setFile( oldFile );
145 if (finfo.exists() ) { 145 if (finfo.exists() ) {
146 KMessageBox::information( this, message); 146 KMessageBox::information( this, message);
147 mView->openCalendar( oldFile ); 147 mView->openCalendar( oldFile );
148 qApp->processEvents(); 148 qApp->processEvents();
149 } else { 149 } else {
150 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 150 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
151 finfo.setFile( oldFile ); 151 finfo.setFile( oldFile );
152 if (finfo.exists() ) { 152 if (finfo.exists() ) {
153 KMessageBox::information( this, message); 153 KMessageBox::information( this, message);
154 mView->openCalendar( oldFile ); 154 mView->openCalendar( oldFile );
155 qApp->processEvents(); 155 qApp->processEvents();
156 } 156 }
157 } 157 }
158 mView->saveCalendar( defaultFileName() ); 158 mView->saveCalendar( defaultFileName() );
159 newFile = true; 159 newFile = true;
160 } 160 }
161 161
162 QTime neededSaveTime = QDateTime::currentDateTime().time(); 162 QTime neededSaveTime = QDateTime::currentDateTime().time();
163 if ( ! oldOpened ) 163 if ( ! oldOpened )
164 mView->openCalendar( defaultFileName() ); 164 mView->openCalendar( defaultFileName() );
165 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 165 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
166 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 166 qDebug("KO: Calendar loading time: %d ms",msNeeded );
167 167
168 if ( KOPrefs::instance()->mLanguageChanged ) { 168 if ( KOPrefs::instance()->mLanguageChanged ) {
169 KOPrefs::instance()->setCategoryDefaults(); 169 KOPrefs::instance()->setCategoryDefaults();
170 int count = mView->addCategories(); 170 int count = mView->addCategories();
171 KOPrefs::instance()->mLanguageChanged = false; 171 KOPrefs::instance()->mLanguageChanged = false;
172 } 172 }
173 processIncidenceSelection( 0 ); 173 processIncidenceSelection( 0 );
174 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 174 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
175 SLOT( processIncidenceSelection( Incidence * ) ) ); 175 SLOT( processIncidenceSelection( Incidence * ) ) );
176 connect( mView, SIGNAL( modifiedChanged( bool ) ), 176 connect( mView, SIGNAL( modifiedChanged( bool ) ),
177 SLOT( slotModifiedChanged( bool ) ) ); 177 SLOT( slotModifiedChanged( bool ) ) );
178 178
179 179
180 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 180 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
181 mView->setModified( false ); 181 mView->setModified( false );
182 mBlockAtStartup = false; 182 mBlockAtStartup = false;
183 mView->setModified( false ); 183 mView->setModified( false );
184 setCentralWidget( mView ); 184 setCentralWidget( mView );
185 globalFlagBlockStartup = 0; 185 globalFlagBlockStartup = 0;
186 mView->show(); 186 mView->show();
187 delete splash; 187 delete splash;
188 if ( newFile ) 188 if ( newFile )
189 mView->updateConfig(); 189 mView->updateConfig();
190 // qApp->processEvents(); 190 // qApp->processEvents();
191 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 191 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
192 fillSyncMenu(); 192 fillSyncMenu();
193 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 193 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
194 if ( showWarning ) { 194 if ( showWarning ) {
195 KMessageBox::information( this, 195 KMessageBox::information( this,
196 "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"); 196 "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");
197 qApp->processEvents(); 197 qApp->processEvents();
198 mView->dialogManager()->showSyncOptions(); 198 mView->dialogManager()->showSyncOptions();
199 } 199 }
200} 200}
201MainWindow::~MainWindow() 201MainWindow::~MainWindow()
202{ 202{
203 //qDebug("MainWindow::~MainWindow() "); 203 //qDebug("MainWindow::~MainWindow() ");
204 //save toolbar location 204 //save toolbar location
205 205
206 delete mCalendar; 206 delete mCalendar;
207 delete KOPrefs::instance(); 207 delete KOPrefs::instance();
208 delete KIncidenceFormatter::instance(); 208 delete KIncidenceFormatter::instance();
209 209
210 210
211} 211}
212void MainWindow::closeEvent( QCloseEvent* ce ) 212void MainWindow::closeEvent( QCloseEvent* ce )
213{ 213{
214 214
215 215
216 216
217 if ( ! KOPrefs::instance()->mAskForQuit ) { 217 if ( ! KOPrefs::instance()->mAskForQuit ) {
218 saveOnClose(); 218 saveOnClose();
219 ce->accept(); 219 ce->accept();
220 return; 220 return;
221 221
222 } 222 }
223 223
224 switch( QMessageBox::information( this, "KO/Pi", 224 switch( QMessageBox::information( this, "KO/Pi",
225 i18n("Do you really want\nto close KO/Pi?"), 225 i18n("Do you really want\nto close KO/Pi?"),
226 i18n("Close"), i18n("No"), 226 i18n("Close"), i18n("No"),
227 0, 0 ) ) { 227 0, 0 ) ) {
228 case 0: 228 case 0:
229 saveOnClose(); 229 saveOnClose();
230 ce->accept(); 230 ce->accept();
231 break; 231 break;
232 case 1: 232 case 1:
233 ce->ignore(); 233 ce->ignore();
234 break; 234 break;
235 case 2: 235 case 2:
236 236
237 default: 237 default:
238 break; 238 break;
239 } 239 }
240 240
241 241
242} 242}
243 243
244void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 244void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
245{ 245{
246 QDataStream stream( data, IO_ReadOnly ); 246 QDataStream stream( data, IO_ReadOnly );
247 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 247 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
248 //QString datamess; 248 //QString datamess;
249 //qDebug("message "); 249 //qDebug("message ");
250 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 250 qDebug("KO: QCOP message received: %s ", cmsg.data() );
251 if ( cmsg == "-writeFile" ) { 251 if ( cmsg == "-writeFile" ) {
252 // I made from the "-writeFile" an "-writeAlarm" 252 // I made from the "-writeFile" an "-writeAlarm"
253 mView->viewManager()->showWhatsNextView(); 253 mView->viewManager()->showWhatsNextView();
254 mCalendar->checkAlarmForIncidence( 0, true); 254 mCalendar->checkAlarmForIncidence( 0, true);
255 showMaximized(); 255 showMaximized();
256 raise(); 256 raise();
257 return; 257 return;
258 258
259 } 259 }
260 if ( cmsg == "-writeFileSilent" ) { 260 if ( cmsg == "-writeFileSilent" ) {
261 // I made from the "-writeFile" an "-writeAlarm" 261 // I made from the "-writeFile" an "-writeAlarm"
262 // mView->viewManager()->showWhatsNextView(); 262 // mView->viewManager()->showWhatsNextView();
263 mCalendar->checkAlarmForIncidence( 0, true); 263 mCalendar->checkAlarmForIncidence( 0, true);
264 //showMaximized(); 264 //showMaximized();
265 //raise(); 265 //raise();
266 hide(); 266 hide();
267 return; 267 return;
268 } 268 }
269 if ( cmsg == "-newCountdown" ) { 269 if ( cmsg == "-newCountdown" ) {
270 qDebug("newCountdown "); 270 qDebug("newCountdown ");
271 271
272 } 272 }
273 QString msg ; 273 QString msg ;
274 QString allmsg = cmsg; 274 QString allmsg = cmsg;
275 while ( allmsg.length() > 0 ) { 275 while ( allmsg.length() > 0 ) {
276 int nextC = allmsg.find( "-", 1 ); 276 int nextC = allmsg.find( "-", 1 );
277 if ( nextC == -1 ) { 277 if ( nextC == -1 ) {
278 msg = allmsg; 278 msg = allmsg;
279 allmsg = ""; 279 allmsg = "";
280 } else{ 280 } else{
281 msg = allmsg.left( nextC ); 281 msg = allmsg.left( nextC );
282 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 282 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
283 } 283 }
284 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 284 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
285 if ( msg == "-newEvent" ) { 285 if ( msg == "-newEvent" ) {
286 mView->newEvent(); 286 mView->newEvent();
287 } 287 }
288 if ( msg == "-newTodo" ) { 288 if ( msg == "-newTodo" ) {
289 mView->newTodo(); 289 mView->newTodo();
290 290
291 } 291 }
292 if ( msg == "-showWN" ) { 292 if ( msg == "-showWN" ) {
293 mView->viewManager()->showWhatsNextView(); 293 mView->viewManager()->showWhatsNextView();
294 } 294 }
295 if ( msg == "-showTodo" ) { 295 if ( msg == "-showTodo" ) {
296 mView->viewManager()->showTodoView(); 296 mView->viewManager()->showTodoView();
297 } 297 }
298 if ( msg == "-showList" ) { 298 if ( msg == "-showList" ) {
299 mView->viewManager()->showListView(); 299 mView->viewManager()->showListView();
300 } 300 }
301 else if ( msg == "-showDay" ) { 301 else if ( msg == "-showDay" ) {
302 mView->viewManager()->showDayView(); 302 mView->viewManager()->showDayView();
303 } 303 }
304 else if ( msg == "-showWWeek" ) { 304 else if ( msg == "-showWWeek" ) {
305 mView->viewManager()->showWorkWeekView(); 305 mView->viewManager()->showWorkWeekView();
306 } 306 }
307 else if ( msg == "-ringSync" ) { 307 else if ( msg == "-ringSync" ) {
308 multiSync( false ); 308 multiSync( false );
309 } 309 }
310 else if ( msg == "-showWeek" ) { 310 else if ( msg == "-showWeek" ) {
311 mView->viewManager()->showWeekView(); 311 mView->viewManager()->showWeekView();
312 } 312 }
313 else if ( msg == "-showTodo" ) { 313 else if ( msg == "-showTodo" ) {
314 mView->viewManager()->showTodoView(); 314 mView->viewManager()->showTodoView();
315 } 315 }
316 else if ( msg == "-showJournal" ) { 316 else if ( msg == "-showJournal" ) {
317 mView->dateNavigator()->selectDates( 1 ); 317 mView->dateNavigator()->selectDates( 1 );
318 mView->dateNavigator()->selectToday(); 318 mView->dateNavigator()->selectToday();
319 mView->viewManager()->showJournalView(); 319 mView->viewManager()->showJournalView();
320 } 320 }
321 else if ( msg == "-showKO" ) { 321 else if ( msg == "-showKO" ) {
322 mView->viewManager()->showNextXView(); 322 mView->viewManager()->showNextXView();
323 } 323 }
324 else if ( msg == "-showWNext" || msg == "nextView()" ) { 324 else if ( msg == "-showWNext" || msg == "nextView()" ) {
325 mView->viewManager()->showWhatsNextView(); 325 mView->viewManager()->showWhatsNextView();
326 } 326 }
327 else if ( msg == "-showNextXView" ) { 327 else if ( msg == "-showNextXView" ) {
328 mView->viewManager()->showNextXView(); 328 mView->viewManager()->showNextXView();
329 } 329 }
330 330
331 331
332 } 332 }
333 333
334 showMaximized(); 334 showMaximized();
335 raise(); 335 raise();
336} 336}
337 337
338QPixmap MainWindow::loadPixmap( QString name ) 338QPixmap MainWindow::loadPixmap( QString name )
339{ 339{
340 return SmallIcon( name ); 340 return SmallIcon( name );
341 341
342} 342}
343void MainWindow::initActions() 343void MainWindow::initActions()
344{ 344{
345 //KOPrefs::instance()->mShowFullMenu 345 //KOPrefs::instance()->mShowFullMenu
346 iconToolBar->clear(); 346 iconToolBar->clear();
347 KOPrefs *p = KOPrefs::instance(); 347 KOPrefs *p = KOPrefs::instance();
348 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 348 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
349 349
350 QPopupMenu *viewMenu = new QPopupMenu( this ); 350 QPopupMenu *viewMenu = new QPopupMenu( this );
351 QPopupMenu *actionMenu = new QPopupMenu( this ); 351 QPopupMenu *actionMenu = new QPopupMenu( this );
352 QPopupMenu *importMenu = new QPopupMenu( this ); 352 QPopupMenu *importMenu = new QPopupMenu( this );
353 selectFilterMenu = new QPopupMenu( this ); 353 selectFilterMenu = new QPopupMenu( this );
354 selectFilterMenu->setCheckable( true ); 354 selectFilterMenu->setCheckable( true );
355 syncMenu = new QPopupMenu( this ); 355 syncMenu = new QPopupMenu( this );
356 configureAgendaMenu = new QPopupMenu( this ); 356 configureAgendaMenu = new QPopupMenu( this );
357 configureToolBarMenu = new QPopupMenu( this ); 357 configureToolBarMenu = new QPopupMenu( this );
358 QPopupMenu *helpMenu = new QPopupMenu( this ); 358 QPopupMenu *helpMenu = new QPopupMenu( this );
359 if ( KOPrefs::instance()->mShowFullMenu ) { 359 if ( KOPrefs::instance()->mShowFullMenu ) {
360 QMenuBar *menuBar1; 360 QMenuBar *menuBar1;
361 menuBar1 = menuBar(); 361 menuBar1 = menuBar();
362 menuBar1->insertItem( i18n("File"), importMenu ); 362 menuBar1->insertItem( i18n("File"), importMenu );
363 menuBar1->insertItem( i18n("View"), viewMenu ); 363 menuBar1->insertItem( i18n("View"), viewMenu );
364 menuBar1->insertItem( i18n("Actions"), actionMenu ); 364 menuBar1->insertItem( i18n("Actions"), actionMenu );
365 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 365 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
366 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 366 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
367 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 367 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
368 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 368 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
369 menuBar1->insertItem( i18n("Help"), helpMenu ); 369 menuBar1->insertItem( i18n("Help"), helpMenu );
370 } else { 370 } else {
371 QPEMenuBar *menuBar1; 371 QPEMenuBar *menuBar1;
372 menuBar1 = new QPEMenuBar( iconToolBar ); 372 menuBar1 = new QPEMenuBar( iconToolBar );
373 QPopupMenu *menuBar = new QPopupMenu( this ); 373 QPopupMenu *menuBar = new QPopupMenu( this );
374 menuBar1->insertItem( i18n("ME"), menuBar); 374 menuBar1->insertItem( i18n("ME"), menuBar);
375 menuBar->insertItem( i18n("File"), importMenu ); 375 menuBar->insertItem( i18n("File"), importMenu );
376 menuBar->insertItem( i18n("View"), viewMenu ); 376 menuBar->insertItem( i18n("View"), viewMenu );
377 menuBar->insertItem( i18n("Actions"), actionMenu ); 377 menuBar->insertItem( i18n("Actions"), actionMenu );
378 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 378 menuBar->insertItem( i18n("Synchronize"), syncMenu );
379 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 379 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
380 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 380 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
381 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 381 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
382 menuBar->insertItem( i18n("Help"), helpMenu ); 382 menuBar->insertItem( i18n("Help"), helpMenu );
383 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 383 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
384 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 384 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
385 } 385 }
386 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 386 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
387 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 387 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
388 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 388 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
389 389
390 // ****************** 390 // ******************
391 QAction *action; 391 QAction *action;
392 QIconSet icon; 392 QIconSet icon;
393 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 393 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
394 configureToolBarMenu->setCheckable( true ); 394 configureToolBarMenu->setCheckable( true );
395 395
396 QString pathString = ""; 396 QString pathString = "";
397 if ( !p->mToolBarMiniIcons ) { 397 if ( !p->mToolBarMiniIcons ) {
398 if ( QApplication::desktop()->width() < 480 ) 398 if ( QApplication::desktop()->width() < 480 )
399 pathString += "icons16/"; 399 pathString += "icons16/";
400 } else 400 } else
401 pathString += "iconsmini/"; 401 pathString += "iconsmini/";
402 configureAgendaMenu->setCheckable( true ); 402 configureAgendaMenu->setCheckable( true );
403 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 403 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
404 configureAgendaMenu->insertSeparator(); 404 configureAgendaMenu->insertSeparator();
405 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 405 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
406 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 406 configureAgendaMenu->insertItem(i18n("Small"), 6 );
407 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 407 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
408 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 408 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
409 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 409 configureAgendaMenu->insertItem(i18n("Large"), 12 );
410 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 410 configureAgendaMenu->insertItem(i18n("Big"), 14 );
411 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 411 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
412 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 412 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
413 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 413 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
414 414
415 icon = loadPixmap( pathString + "configure" ); 415 icon = loadPixmap( pathString + "configure" );
416 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 416 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
417 action->addTo( actionMenu ); 417 action->addTo( actionMenu );
418 connect( action, SIGNAL( activated() ), 418 connect( action, SIGNAL( activated() ),
419 mView, SLOT( edit_options() ) ); 419 mView, SLOT( edit_options() ) );
420 actionMenu->insertSeparator(); 420 actionMenu->insertSeparator();
421 icon = loadPixmap( pathString + "newevent" ); 421 icon = loadPixmap( pathString + "newevent" );
422 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 422 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
423 configureToolBarMenu->insertSeparator(); 423 configureToolBarMenu->insertSeparator();
424 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 424 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
425 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 425 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
426 ne_action->addTo( actionMenu ); 426 ne_action->addTo( actionMenu );
427 connect( ne_action, SIGNAL( activated() ), 427 connect( ne_action, SIGNAL( activated() ),
428 mView, SLOT( newEvent() ) ); 428 mView, SLOT( newEvent() ) );
429 icon = loadPixmap( pathString + "newtodo" ); 429 icon = loadPixmap( pathString + "newtodo" );
430 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 430 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
431 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 431 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
432 nt_action->addTo( actionMenu ); 432 nt_action->addTo( actionMenu );
433 connect( nt_action, SIGNAL( activated() ), 433 connect( nt_action, SIGNAL( activated() ),
434 mView, SLOT( newTodo() ) ); 434 mView, SLOT( newTodo() ) );
435 icon = loadPixmap( pathString + "navi" ); 435 icon = loadPixmap( pathString + "navi" );
436 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 436 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
437 action->addTo( viewMenu ); 437 action->addTo( viewMenu );
438 connect( action, SIGNAL( activated() ), 438 connect( action, SIGNAL( activated() ),
439 mView, SLOT( toggleDateNavigatorWidget() ) ); 439 mView, SLOT( toggleDateNavigatorWidget() ) );
440 icon = loadPixmap( pathString + "filter" ); 440 icon = loadPixmap( pathString + "filter" );
441 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 441 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
442 action->addTo( viewMenu ); 442 action->addTo( viewMenu );
443 connect( action, SIGNAL( activated() ), 443 connect( action, SIGNAL( activated() ),
444 mView, SLOT( toggleFilter() ) ); 444 mView, SLOT( toggleFilter() ) );
445 445
446 446
447 viewMenu->insertSeparator(); 447 viewMenu->insertSeparator();
448 icon = loadPixmap( pathString + "picker" ); 448 icon = loadPixmap( pathString + "picker" );
449 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 449 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
450 action->addTo( viewMenu ); 450 action->addTo( viewMenu );
451 connect( action, SIGNAL( activated() ), 451 connect( action, SIGNAL( activated() ),
452 mView, SLOT( showDatePicker() ) ); 452 mView, SLOT( showDatePicker() ) );
453 action->addTo( iconToolBar ); 453 action->addTo( iconToolBar );
454 viewMenu->insertSeparator(); 454 viewMenu->insertSeparator();
455 icon = loadPixmap( pathString + "list" ); 455 icon = loadPixmap( pathString + "list" );
456 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 456 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
457 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 457 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
458 showlist_action->addTo( viewMenu ); 458 showlist_action->addTo( viewMenu );
459 connect( showlist_action, SIGNAL( activated() ), 459 connect( showlist_action, SIGNAL( activated() ),
460 mView->viewManager(), SLOT( showListView() ) ); 460 mView->viewManager(), SLOT( showListView() ) );
461 461
462 462
463 icon = loadPixmap( pathString + "day" ); 463 icon = loadPixmap( pathString + "day" );
464 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 464 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
465 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 465 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
466 day1_action->addTo( viewMenu ); 466 day1_action->addTo( viewMenu );
467 // action->addTo( toolBar ); 467 // action->addTo( toolBar );
468 connect( day1_action, SIGNAL( activated() ), 468 connect( day1_action, SIGNAL( activated() ),
469 mView->viewManager(), SLOT( showDayView() ) ); 469 mView->viewManager(), SLOT( showDayView() ) );
470 470
471 icon = loadPixmap( pathString + "workweek" ); 471 icon = loadPixmap( pathString + "workweek" );
472 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 472 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
473 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 473 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
474 day5_action->addTo( viewMenu ); 474 day5_action->addTo( viewMenu );
475 connect( day5_action, SIGNAL( activated() ), 475 connect( day5_action, SIGNAL( activated() ),
476 mView->viewManager(), SLOT( showWorkWeekView() ) ); 476 mView->viewManager(), SLOT( showWorkWeekView() ) );
477 477
478 icon = loadPixmap( pathString + "week" ); 478 icon = loadPixmap( pathString + "week" );
479 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 479 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
480 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 480 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
481 day7_action->addTo( viewMenu ); 481 day7_action->addTo( viewMenu );
482 connect( day7_action, SIGNAL( activated() ), 482 connect( day7_action, SIGNAL( activated() ),
483 mView->viewManager(), SLOT( showWeekView() ) ); 483 mView->viewManager(), SLOT( showWeekView() ) );
484 484
485 icon = loadPixmap( pathString + "month" ); 485 icon = loadPixmap( pathString + "month" );
486 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 486 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
487 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 487 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
488 month_action->addTo( viewMenu ); 488 month_action->addTo( viewMenu );
489 connect( month_action, SIGNAL( activated() ), 489 connect( month_action, SIGNAL( activated() ),
490 mView->viewManager(), SLOT( showMonthView() ) ); 490 mView->viewManager(), SLOT( showMonthView() ) );
491 491
492 icon = loadPixmap( pathString + "todo" ); 492 icon = loadPixmap( pathString + "todo" );
493 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 493 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
494 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 494 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
495 todoview_action->addTo( viewMenu ); 495 todoview_action->addTo( viewMenu );
496 connect( todoview_action, SIGNAL( activated() ), 496 connect( todoview_action, SIGNAL( activated() ),
497 mView->viewManager(), SLOT( showTodoView() ) ); 497 mView->viewManager(), SLOT( showTodoView() ) );
498 498
499 icon = loadPixmap( pathString + "journal" ); 499 icon = loadPixmap( pathString + "journal" );
500 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 500 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
501 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 501 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
502 viewjournal_action->addTo( viewMenu ); 502 viewjournal_action->addTo( viewMenu );
503 connect( viewjournal_action, SIGNAL( activated() ), 503 connect( viewjournal_action, SIGNAL( activated() ),
504 mView->viewManager(), SLOT( showJournalView() ) ); 504 mView->viewManager(), SLOT( showJournalView() ) );
505 505
506 icon = loadPixmap( pathString + "xdays" ); 506 icon = loadPixmap( pathString + "xdays" );
507 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 507 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
508 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 508 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
509 xdays_action->addTo( viewMenu ); 509 xdays_action->addTo( viewMenu );
510 connect( xdays_action, SIGNAL( activated() ), 510 connect( xdays_action, SIGNAL( activated() ),
511 mView->viewManager(), SLOT( showNextXView() ) ); 511 mView->viewManager(), SLOT( showNextXView() ) );
512 512
513 icon = loadPixmap( pathString + "whatsnext" ); 513 icon = loadPixmap( pathString + "whatsnext" );
514 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 514 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
515 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 515 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
516 whatsnext_action->addTo( viewMenu ); 516 whatsnext_action->addTo( viewMenu );
517 connect( whatsnext_action, SIGNAL( activated() ), 517 connect( whatsnext_action, SIGNAL( activated() ),
518 mView->viewManager(), SLOT( showWhatsNextView() ) ); 518 mView->viewManager(), SLOT( showWhatsNextView() ) );
519 519
520#if 0 520#if 0
521 action = new QAction( "view_timespan", "Time Span", 0, this ); 521 action = new QAction( "view_timespan", "Time Span", 0, this );
522 action->addTo( viewMenu ); 522 action->addTo( viewMenu );
523 connect( action, SIGNAL( activated() ), 523 connect( action, SIGNAL( activated() ),
524 mView->viewManager(), SLOT( showTimeSpanView() ) ); 524 mView->viewManager(), SLOT( showTimeSpanView() ) );
525#endif 525#endif
526 526
527 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 527 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
528 this ); 528 this );
529 mNewSubTodoAction->addTo( actionMenu ); 529 mNewSubTodoAction->addTo( actionMenu );
530 connect( mNewSubTodoAction, SIGNAL( activated() ), 530 connect( mNewSubTodoAction, SIGNAL( activated() ),
531 mView, SLOT( newSubTodo() ) ); 531 mView, SLOT( newSubTodo() ) );
532 532
533 actionMenu->insertSeparator(); 533 actionMenu->insertSeparator();
534 534
535 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 535 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
536 mShowAction->addTo( actionMenu ); 536 mShowAction->addTo( actionMenu );
537 connect( mShowAction, SIGNAL( activated() ), 537 connect( mShowAction, SIGNAL( activated() ),
538 mView, SLOT( showIncidence() ) ); 538 mView, SLOT( showIncidence() ) );
539 539
540 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 540 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
541 mEditAction->addTo( actionMenu ); 541 mEditAction->addTo( actionMenu );
542 connect( mEditAction, SIGNAL( activated() ), 542 connect( mEditAction, SIGNAL( activated() ),
543 mView, SLOT( editIncidence() ) ); 543 mView, SLOT( editIncidence() ) );
544 544
545 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 545 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
546 mDeleteAction->addTo( actionMenu ); 546 mDeleteAction->addTo( actionMenu );
547 connect( mDeleteAction, SIGNAL( activated() ), 547 connect( mDeleteAction, SIGNAL( activated() ),
548 mView, SLOT( deleteIncidence() ) ); 548 mView, SLOT( deleteIncidence() ) );
549 549
550 actionMenu->insertSeparator(); 550 actionMenu->insertSeparator();
551 551
552 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 552 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
553 this ); 553 this );
554 action->addTo( actionMenu ); 554 action->addTo( actionMenu );
555 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 555 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
556 556
557 icon = loadPixmap( pathString + "search" ); 557 icon = loadPixmap( pathString + "search" );
558 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 558 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
559 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 559 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
560 search_action->addTo( actionMenu ); 560 search_action->addTo( actionMenu );
561 connect( search_action, SIGNAL( activated() ), 561 connect( search_action, SIGNAL( activated() ),
562 mView->dialogManager(), SLOT( showSearchDialog() ) ); 562 mView->dialogManager(), SLOT( showSearchDialog() ) );
563 563
564 icon = loadPixmap( pathString + "today" ); 564 icon = loadPixmap( pathString + "today" );
565 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 565 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
566 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 566 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
567 today_action->addTo( actionMenu ); 567 today_action->addTo( actionMenu );
568 connect( today_action, SIGNAL( activated() ), 568 connect( today_action, SIGNAL( activated() ),
569 mView, SLOT( goToday() ) ); 569 mView, SLOT( goToday() ) );
570 570
571 if ( KOPrefs::instance()->mShowFullMenu ) { 571 if ( KOPrefs::instance()->mShowFullMenu ) {
572 actionMenu->insertSeparator(); 572 actionMenu->insertSeparator();
573 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 573 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
574 574
575 } 575 }
576 // actionMenu->insertSeparator(); 576 // actionMenu->insertSeparator();
577 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 577 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
578 this ); 578 this );
579 action->addTo( importMenu ); 579 action->addTo( importMenu );
580 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 580 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
581 action = new QAction( "import_quick", i18n("Import last file"), 0, 581 action = new QAction( "import_quick", i18n("Import last file"), 0,
582 this ); 582 this );
583 action->addTo( importMenu ); 583 action->addTo( importMenu );
584 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 584 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
585 importMenu->insertSeparator(); 585 importMenu->insertSeparator();
586 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 586 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
587 this ); 587 this );
588 action->addTo( importMenu ); 588 action->addTo( importMenu );
589 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 589 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
590#ifndef DESKTOP_VERSION 590#ifndef DESKTOP_VERSION
591 importMenu->insertSeparator(); 591 importMenu->insertSeparator();
592 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 592 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
593 this ); 593 this );
594 action->addTo( importMenu ); 594 action->addTo( importMenu );
595 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 595 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
596#else 596#else
597#ifdef _WIN32_ 597#ifdef _WIN32_
598 importMenu->insertSeparator(); 598 importMenu->insertSeparator();
599 action = new QAction( "import_ol", i18n("Import from OL"), 0, 599 action = new QAction( "import_ol", i18n("Import from OL"), 0,
600 this ); 600 this );
601 action->addTo( importMenu ); 601 action->addTo( importMenu );
602 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 602 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
603#endif 603#endif
604#endif 604#endif
605 605
606 importMenu->insertSeparator(); 606 importMenu->insertSeparator();
607 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 607 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
608 this ); 608 this );
609 action->addTo( importMenu ); 609 action->addTo( importMenu );
610 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 610 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
611 611
612 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 612 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
613 this ); 613 this );
614 action->addTo( importMenu ); 614 action->addTo( importMenu );
615 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 615 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
616 616
617 importMenu->insertSeparator(); 617 importMenu->insertSeparator();
618 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 618 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
619 this ); 619 this );
620 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 620 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
621 importMenu->insertSeparator(); 621 importMenu->insertSeparator();
622 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 622 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
623 this ); 623 this );
624 action->addTo( importMenu ); 624 action->addTo( importMenu );
625 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 625 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
626#ifndef DESKTOP_VERSION 626#ifndef DESKTOP_VERSION
627 importMenu->insertSeparator(); 627 importMenu->insertSeparator();
628 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 628 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
629 this ); 629 this );
630 action->addTo( importMenu ); 630 action->addTo( importMenu );
631 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 631 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
632 632
633 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 633 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
634 this ); 634 this );
635 action->addTo( importMenu ); 635 action->addTo( importMenu );
636 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 636 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
637#else 637#else
638 importMenu->insertSeparator(); 638 importMenu->insertSeparator();
639 icon = loadPixmap( pathString + "print" ); 639 icon = loadPixmap( pathString + "print" );
640 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 640 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
641 action->addTo( importMenu ); 641 action->addTo( importMenu );
642 connect( action, SIGNAL( activated() ), 642 connect( action, SIGNAL( activated() ),
643 this, SLOT( printCal() ) ); 643 this, SLOT( printCal() ) );
644 644
645 icon = loadPixmap( pathString + "print" ); 645 icon = loadPixmap( pathString + "print" );
646 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 646 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
647 action->addTo( importMenu ); 647 action->addTo( importMenu );
648 connect( action, SIGNAL( activated() ), 648 connect( action, SIGNAL( activated() ),
649 this, SLOT( printSel() ) ); 649 this, SLOT( printSel() ) );
650#endif 650#endif
651 importMenu->insertSeparator(); 651 importMenu->insertSeparator();
652 action = new QAction( "beam all", i18n("Save"), 0, 652 action = new QAction( "beam all", i18n("Save"), 0,
653 this ); 653 this );
654 action->addTo( importMenu ); 654 action->addTo( importMenu );
655 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 655 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
656 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 656 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
657 this ); 657 this );
658 action->addTo( importMenu ); 658 action->addTo( importMenu );
659 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 659 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
660 660
661 //menuBar->insertItem( "Configure",configureMenu ); 661 //menuBar->insertItem( "Configure",configureMenu );
662 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 662 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
663 icon = loadPixmap( "korganizer/korganizer" ); 663 icon = loadPixmap( "korganizer/korganizer" );
664 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 664 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
665 action->addTo( helpMenu ); 665 action->addTo( helpMenu );
666 connect( action, SIGNAL( activated() ), 666 connect( action, SIGNAL( activated() ),
667 SLOT( keyBindings() ) ); 667 SLOT( keyBindings() ) );
668 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 668 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
669 action->addTo( helpMenu ); 669 action->addTo( helpMenu );
670 connect( action, SIGNAL( activated() ), 670 connect( action, SIGNAL( activated() ),
671 SLOT( features() ) ); 671 SLOT( features() ) );
672 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 672 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
673 action->addTo( helpMenu ); 673 action->addTo( helpMenu );
674 connect( action, SIGNAL( activated() ), 674 connect( action, SIGNAL( activated() ),
675 SLOT( aboutAutoSaving() ) ); 675 SLOT( aboutAutoSaving() ) );
676 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 676 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
677 action->addTo( helpMenu ); 677 action->addTo( helpMenu );
678 connect( action, SIGNAL( activated() ), 678 connect( action, SIGNAL( activated() ),
679 SLOT( aboutKnownBugs() ) ); 679 SLOT( aboutKnownBugs() ) );
680 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 680 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
681 action->addTo( helpMenu ); 681 action->addTo( helpMenu );
682 connect( action, SIGNAL( activated() ), 682 connect( action, SIGNAL( activated() ),
683 SLOT( usertrans() ) ); 683 SLOT( usertrans() ) );
684 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 684 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
685 action->addTo( helpMenu ); 685 action->addTo( helpMenu );
686 connect( action, SIGNAL( activated() ), 686 connect( action, SIGNAL( activated() ),
687 SLOT( synchowto() ) ); 687 SLOT( synchowto() ) );
688 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 688 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
689 action->addTo( helpMenu ); 689 action->addTo( helpMenu );
690 connect( action, SIGNAL( activated() ), 690 connect( action, SIGNAL( activated() ),
691 SLOT( whatsNew() ) ); 691 SLOT( whatsNew() ) );
692 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 692 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
693 action->addTo( helpMenu ); 693 action->addTo( helpMenu );
694 connect( action, SIGNAL( activated() ), 694 connect( action, SIGNAL( activated() ),
695 SLOT( faq() ) ); 695 SLOT( faq() ) );
696 696
697 697
698 action = new QAction( "about", i18n("About..."), 0, this ); 698 action = new QAction( "about", i18n("About..."), 0, this );
699 action->addTo( helpMenu ); 699 action->addTo( helpMenu );
700 connect( action, SIGNAL( activated() ), 700 connect( action, SIGNAL( activated() ),
701 SLOT( about() ) ); 701 SLOT( about() ) );
702 action = new QAction( "licence", i18n("Licence..."), 0, this ); 702 action = new QAction( "licence", i18n("Licence..."), 0, this );
703 action->addTo( helpMenu ); 703 action->addTo( helpMenu );
704 connect( action, SIGNAL( activated() ), 704 connect( action, SIGNAL( activated() ),
705 SLOT( licence() ) ); 705 SLOT( licence() ) );
706 //menuBar->insertSeparator(); 706 //menuBar->insertSeparator();
707 707
708 // ****************************************************** 708 // ******************************************************
709 // menubar icons 709 // menubar icons
710 710
711 711
712 iconToolBar->setHorizontalStretchable (true ); 712 iconToolBar->setHorizontalStretchable (true );
713 //menuBar->insertItem( iconToolBar ); 713 //menuBar->insertItem( iconToolBar );
714 //xdays_action 714 //xdays_action
715 if (p-> mShowIconNewEvent) 715 if (p-> mShowIconNewEvent)
716 ne_action->addTo( iconToolBar ); 716 ne_action->addTo( iconToolBar );
717 if (p->mShowIconNewTodo ) 717 if (p->mShowIconNewTodo )
718 nt_action->addTo( iconToolBar ); 718 nt_action->addTo( iconToolBar );
719 if (p-> mShowIconSearch) 719 if (p-> mShowIconSearch)
720 search_action->addTo( iconToolBar ); 720 search_action->addTo( iconToolBar );
721 if (p-> mShowIconNext) 721 if (p-> mShowIconNext)
722 whatsnext_action->addTo( iconToolBar ); 722 whatsnext_action->addTo( iconToolBar );
723 if (p-> mShowIconNextDays) 723 if (p-> mShowIconNextDays)
724 xdays_action->addTo( iconToolBar ); 724 xdays_action->addTo( iconToolBar );
725 if (p-> mShowIconList) 725 if (p-> mShowIconList)
726 showlist_action->addTo( iconToolBar ); 726 showlist_action->addTo( iconToolBar );
727 if (p-> mShowIconDay1) 727 if (p-> mShowIconDay1)
728 day1_action->addTo( iconToolBar ); 728 day1_action->addTo( iconToolBar );
729 if (p-> mShowIconDay5) 729 if (p-> mShowIconDay5)
730 day5_action->addTo( iconToolBar ); 730 day5_action->addTo( iconToolBar );
731 if (p-> mShowIconDay7) 731 if (p-> mShowIconDay7)
732 day7_action->addTo( iconToolBar ); 732 day7_action->addTo( iconToolBar );
733 if (p-> mShowIconMonth) 733 if (p-> mShowIconMonth)
734 month_action->addTo( iconToolBar ); 734 month_action->addTo( iconToolBar );
735 if (p-> mShowIconTodoview) 735 if (p-> mShowIconTodoview)
736 todoview_action->addTo( iconToolBar ); 736 todoview_action->addTo( iconToolBar );
737 if (p-> mShowIconJournal) 737 if (p-> mShowIconJournal)
738 viewjournal_action->addTo( iconToolBar ); 738 viewjournal_action->addTo( iconToolBar );
739 icon = loadPixmap( pathString + "2leftarrowB" ); 739 icon = loadPixmap( pathString + "2leftarrowB" );
740 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 740 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
741 if (p-> mShowIconBackFast) { 741 if (p-> mShowIconBackFast) {
742 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 742 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
743 connect( action, SIGNAL( activated() ), 743 connect( action, SIGNAL( activated() ),
744 mView, SLOT( goPreviousMonth() ) ); 744 mView, SLOT( goPreviousMonth() ) );
745 action->addTo( iconToolBar ); 745 action->addTo( iconToolBar );
746 } 746 }
747 icon = loadPixmap( pathString + "1leftarrowB" ); 747 icon = loadPixmap( pathString + "1leftarrowB" );
748 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 748 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
749 if (p-> mShowIconBack) { 749 if (p-> mShowIconBack) {
750 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 750 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
751 connect( action, SIGNAL( activated() ), 751 connect( action, SIGNAL( activated() ),
752 mView, SLOT( goPrevious() ) ); 752 mView, SLOT( goPrevious() ) );
753 action->addTo( iconToolBar ); 753 action->addTo( iconToolBar );
754 } 754 }
755 if (p-> mShowIconToday) 755 if (p-> mShowIconToday)
756 today_action->addTo( iconToolBar ); 756 today_action->addTo( iconToolBar );
757 icon = loadPixmap( pathString + "1rightarrowB" ); 757 icon = loadPixmap( pathString + "1rightarrowB" );
758 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 758 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
759 if (p-> mShowIconForward) { 759 if (p-> mShowIconForward) {
760 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 760 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
761 connect( action, SIGNAL( activated() ), 761 connect( action, SIGNAL( activated() ),
762 mView, SLOT( goNext() ) ); 762 mView, SLOT( goNext() ) );
763 action->addTo( iconToolBar ); 763 action->addTo( iconToolBar );
764 } 764 }
765 icon = loadPixmap( pathString + "2rightarrowB" ); 765 icon = loadPixmap( pathString + "2rightarrowB" );
766 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 766 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
767 if (p-> mShowIconForwardFast) { 767 if (p-> mShowIconForwardFast) {
768 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 768 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
769 connect( action, SIGNAL( activated() ), 769 connect( action, SIGNAL( activated() ),
770 mView, SLOT( goNextMonth() ) ); 770 mView, SLOT( goNextMonth() ) );
771 action->addTo( iconToolBar ); 771 action->addTo( iconToolBar );
772 } 772 }
773 773
774 774
775 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 775 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
776 776
777 if (p-> mShowIconNewEvent) 777 if (p-> mShowIconNewEvent)
778 configureToolBarMenu->setItemChecked( 10, true ); 778 configureToolBarMenu->setItemChecked( 10, true );
779 if (p->mShowIconNewTodo ) 779 if (p->mShowIconNewTodo )
780 configureToolBarMenu->setItemChecked( 20, true ); 780 configureToolBarMenu->setItemChecked( 20, true );
781 if (p-> mShowIconSearch) 781 if (p-> mShowIconSearch)
782 configureToolBarMenu->setItemChecked( 120, true ); 782 configureToolBarMenu->setItemChecked( 120, true );
783 if (p-> mShowIconList) 783 if (p-> mShowIconList)
784 configureToolBarMenu->setItemChecked( 30, true ); 784 configureToolBarMenu->setItemChecked( 30, true );
785 if (p-> mShowIconDay1) 785 if (p-> mShowIconDay1)
786 configureToolBarMenu->setItemChecked( 40, true ); 786 configureToolBarMenu->setItemChecked( 40, true );
787 if (p-> mShowIconDay5) 787 if (p-> mShowIconDay5)
788 configureToolBarMenu->setItemChecked( 50, true ); 788 configureToolBarMenu->setItemChecked( 50, true );
789 if (p-> mShowIconDay7) 789 if (p-> mShowIconDay7)
790 configureToolBarMenu->setItemChecked( 60, true ); 790 configureToolBarMenu->setItemChecked( 60, true );
791 if (p-> mShowIconMonth) 791 if (p-> mShowIconMonth)
792 configureToolBarMenu->setItemChecked( 70, true ); 792 configureToolBarMenu->setItemChecked( 70, true );
793 if (p-> mShowIconTodoview) 793 if (p-> mShowIconTodoview)
794 configureToolBarMenu->setItemChecked( 80, true ); 794 configureToolBarMenu->setItemChecked( 80, true );
795 if (p-> mShowIconBackFast) 795 if (p-> mShowIconBackFast)
796 configureToolBarMenu->setItemChecked( 200, true ); 796 configureToolBarMenu->setItemChecked( 200, true );
797 if (p-> mShowIconBack) 797 if (p-> mShowIconBack)
798 configureToolBarMenu->setItemChecked( 210, true ); 798 configureToolBarMenu->setItemChecked( 210, true );
799 if (p-> mShowIconToday) 799 if (p-> mShowIconToday)
800 configureToolBarMenu->setItemChecked( 130, true ); 800 configureToolBarMenu->setItemChecked( 130, true );
801 if (p-> mShowIconForward) 801 if (p-> mShowIconForward)
802 configureToolBarMenu->setItemChecked( 220, true ); 802 configureToolBarMenu->setItemChecked( 220, true );
803 if (p-> mShowIconForwardFast) 803 if (p-> mShowIconForwardFast)
804 configureToolBarMenu->setItemChecked( 230, true ); 804 configureToolBarMenu->setItemChecked( 230, true );
805 if (p-> mShowIconNextDays) 805 if (p-> mShowIconNextDays)
806 configureToolBarMenu->setItemChecked( 100, true ); 806 configureToolBarMenu->setItemChecked( 100, true );
807 if (p-> mShowIconNext) 807 if (p-> mShowIconNext)
808 configureToolBarMenu->setItemChecked( 110, true ); 808 configureToolBarMenu->setItemChecked( 110, true );
809 if (p-> mShowIconJournal) 809 if (p-> mShowIconJournal)
810 configureToolBarMenu->setItemChecked( 90, true ); 810 configureToolBarMenu->setItemChecked( 90, true );
811 if (p-> mShowIconWhatsThis) 811 if (p-> mShowIconWhatsThis)
812 configureToolBarMenu->setItemChecked( 300, true ); 812 configureToolBarMenu->setItemChecked( 300, true );
813 813
814 QLabel* dummy = new QLabel( iconToolBar ); 814 QLabel* dummy = new QLabel( iconToolBar );
815 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 815 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
816 if (!p-> mShowIconStretch) 816 if (!p-> mShowIconStretch)
817 iconToolBar->setStretchableWidget ( dummy ) ; 817 iconToolBar->setStretchableWidget ( dummy ) ;
818 else 818 else
819 configureToolBarMenu->setItemChecked( 5, true ); 819 configureToolBarMenu->setItemChecked( 5, true );
820 if (p-> mShowIconWhatsThis) 820 if (p-> mShowIconWhatsThis)
821 QWhatsThis::whatsThisButton ( iconToolBar ); 821 QWhatsThis::whatsThisButton ( iconToolBar );
822 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 822 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
823 configureAgenda( p->mHourSize ); 823 configureAgenda( p->mHourSize );
824 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 824 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
825} 825}
826void MainWindow::fillSyncMenu() 826void MainWindow::fillSyncMenu()
827{ 827{
828 syncMenu->clear(); 828 syncMenu->clear();
829 syncMenu->insertItem( i18n("Configure..."), 0 ); 829 syncMenu->insertItem( i18n("Configure..."), 0 );
830 syncMenu->insertSeparator(); 830 syncMenu->insertSeparator();
831 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 831 syncMenu->insertItem( i18n("Multiple sync"), 1 );
832 syncMenu->insertSeparator(); 832 syncMenu->insertSeparator();
833 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 833 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
834 config.setGroup("General"); 834 config.setGroup("General");
835 QStringList prof = config.readListEntry("SyncProfileNames"); 835 QStringList prof = config.readListEntry("SyncProfileNames");
836 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 836 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
837 if ( prof.count() < 3 ) { 837 if ( prof.count() < 3 ) {
838 prof.clear(); 838 prof.clear();
839 prof << i18n("Sharp_DTM"); 839 prof << i18n("Sharp_DTM");
840 prof << i18n("Local_file"); 840 prof << i18n("Local_file");
841 prof << i18n("Last_file"); 841 prof << i18n("Last_file");
842 KSyncProfile* temp = new KSyncProfile (); 842 KSyncProfile* temp = new KSyncProfile ();
843 temp->setName( prof[0] ); 843 temp->setName( prof[0] );
844 temp->writeConfig(&config); 844 temp->writeConfig(&config);
845 temp->setName( prof[1] ); 845 temp->setName( prof[1] );
846 temp->writeConfig(&config); 846 temp->writeConfig(&config);
847 temp->setName( prof[2] ); 847 temp->setName( prof[2] );
848 temp->writeConfig(&config); 848 temp->writeConfig(&config);
849 config.setGroup("General"); 849 config.setGroup("General");
850 config.writeEntry("SyncProfileNames",prof); 850 config.writeEntry("SyncProfileNames",prof);
851 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 851 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
852 config.sync(); 852 config.sync();
853 delete temp; 853 delete temp;
854 } 854 }
855 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 855 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
856 KOPrefs::instance()->mSyncProfileNames = prof; 856 KOPrefs::instance()->mSyncProfileNames = prof;
857 int i; 857 int i;
858 for ( i = 0; i < prof.count(); ++i ) { 858 for ( i = 0; i < prof.count(); ++i ) {
859 859
860 syncMenu->insertItem( prof[i], 1000+i ); 860 syncMenu->insertItem( prof[i], 1000+i );
861 if ( i == 2 ) 861 if ( i == 2 )
862 syncMenu->insertSeparator(); 862 syncMenu->insertSeparator();
863 } 863 }
864 QDir app_dir; 864 QDir app_dir;
865 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 865 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
866 syncMenu->setItemEnabled( false , 1000 ); 866 syncMenu->setItemEnabled( false , 1000 );
867 } 867 }
868 mView->setupExternSyncProfiles(); 868 mView->setupExternSyncProfiles();
869} 869}
870 870
871int MainWindow::ringSync() 871int MainWindow::ringSync()
872{ 872{
873 int syncedProfiles = 0; 873 int syncedProfiles = 0;
874 int i; 874 int i;
875 QTime timer; 875 QTime timer;
876 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 876 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
877 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 877 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
878 KSyncProfile* temp = new KSyncProfile (); 878 KSyncProfile* temp = new KSyncProfile ();
879 KOPrefs::instance()->mAskForPreferences = false; 879 KOPrefs::instance()->mAskForPreferences = false;
880 for ( i = 0; i < syncProfileNames.count(); ++i ) { 880 for ( i = 0; i < syncProfileNames.count(); ++i ) {
881 mCurrentSyncProfile = i; 881 mCurrentSyncProfile = i;
882 temp->setName(syncProfileNames[mCurrentSyncProfile]); 882 temp->setName(syncProfileNames[mCurrentSyncProfile]);
883 temp->readConfig(&config); 883 temp->readConfig(&config);
884 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 884 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
885 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 885 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
886 ++syncedProfiles; 886 ++syncedProfiles;
887 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 887 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
888 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 888 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
889 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 889 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
890 KOPrefs::instance()->mShowSyncSummary = false; 890 KOPrefs::instance()->mShowSyncSummary = false;
891 mView->setSyncDevice(syncProfileNames[i] ); 891 mView->setSyncDevice(syncProfileNames[i] );
892 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 892 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
893 if ( i == 0 ) { 893 if ( i == 0 ) {
894 syncSharp(); 894 syncSharp();
895 } else { 895 } else {
896 if ( temp->getIsLocalFileSync() ) { 896 if ( temp->getIsLocalFileSync() ) {
897 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 897 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
898 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 898 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
899 } else { 899 } else {
900 if ( temp->getIsPhoneSync() ) { 900 if ( temp->getIsPhoneSync() ) {
901 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 901 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
902 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 902 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
903 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 903 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
904 syncPhone(); 904 syncPhone();
905 } else 905 } else
906 syncRemote( temp, false ); 906 syncRemote( temp, false );
907 907
908 } 908 }
909 } 909 }
910 timer.start(); 910 timer.start();
911 setCaption(i18n("Multiple sync in progress ... please wait!") ); 911 setCaption(i18n("Multiple sync in progress ... please wait!") );
912 while ( timer.elapsed () < 2000 ) { 912 while ( timer.elapsed () < 2000 ) {
913 qApp->processEvents(); 913 qApp->processEvents();
914#ifndef _WIN32_ 914#ifndef _WIN32_
915 sleep (1); 915 sleep (1);
916#endif 916#endif
917 } 917 }
918 918
919 } 919 }
920 920
921 } 921 }
922 delete temp; 922 delete temp;
923 return syncedProfiles; 923 return syncedProfiles;
924} 924}
925 925
926void MainWindow::multiSync( bool askforPrefs ) 926void MainWindow::multiSync( bool askforPrefs )
927{ 927{
928 if (mBlockSaveFlag) 928 if (mBlockSaveFlag)
929 return; 929 return;
930 mBlockSaveFlag = true; 930 mBlockSaveFlag = true;
931 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 931 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
932 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 932 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
933 question, 933 question,
934 i18n("Yes"), i18n("No"), 934 i18n("Yes"), i18n("No"),
935 0, 0 ) != 0 ) { 935 0, 0 ) != 0 ) {
936 mBlockSaveFlag = false; 936 mBlockSaveFlag = false;
937 setCaption(i18n("Aborted! Nothing synced!")); 937 setCaption(i18n("Aborted! Nothing synced!"));
938 return; 938 return;
939 } 939 }
940 mView->setSyncDevice(i18n("Multiple profiles") ); 940 mView->setSyncDevice(i18n("Multiple profiles") );
941 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 941 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
942 if ( askforPrefs ) { 942 if ( askforPrefs ) {
943 mView->edit_sync_options(); 943 mView->edit_sync_options();
944 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 944 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
945 } 945 }
946 setCaption(i18n("Multiple sync started.") ); 946 setCaption(i18n("Multiple sync started.") );
947 qApp->processEvents(); 947 qApp->processEvents();
948 int num = ringSync() ; 948 int num = ringSync() ;
949 if ( num > 1 ) 949 if ( num > 1 )
950 ringSync(); 950 ringSync();
951 mBlockSaveFlag = false; 951 mBlockSaveFlag = false;
952 if ( num ) 952 if ( num )
953 save(); 953 save();
954 if ( num ) 954 if ( num )
955 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 955 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
956 else 956 else
957 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 957 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
958 return; 958 return;
959} 959}
960void MainWindow::slotSyncMenu( int action ) 960void MainWindow::slotSyncMenu( int action )
961{ 961{
962 //qDebug("syncaction %d ", action); 962 //qDebug("syncaction %d ", action);
963 if ( action == 0 ) { 963 if ( action == 0 ) {
964 964
965 confSync(); 965 confSync();
966 966
967 return; 967 return;
968 } 968 }
969 if ( action == 1 ) { 969 if ( action == 1 ) {
970 multiSync( true ); 970 multiSync( true );
971 return; 971 return;
972 } 972 }
973 973
974 if (mBlockSaveFlag) 974 if (mBlockSaveFlag)
975 return; 975 return;
976 mBlockSaveFlag = true; 976 mBlockSaveFlag = true;
977 mCurrentSyncProfile = action - 1000 ; 977 mCurrentSyncProfile = action - 1000 ;
978 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 978 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
979 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 979 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
980 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 980 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
981 KSyncProfile* temp = new KSyncProfile (); 981 KSyncProfile* temp = new KSyncProfile ();
982 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 982 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
983 temp->readConfig(&config); 983 temp->readConfig(&config);
984 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 984 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
985 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 985 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
986 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 986 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
987 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 987 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
988 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 988 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
989 if ( action == 1000 ) { 989 if ( action == 1000 ) {
990 syncSharp(); 990 syncSharp();
991 991
992 } else if ( action == 1001 ) { 992 } else if ( action == 1001 ) {
993 syncLocalFile(); 993 syncLocalFile();
994 994
995 } else if ( action == 1002 ) { 995 } else if ( action == 1002 ) {
996 quickSyncLocalFile(); 996 quickSyncLocalFile();
997 997
998 } else if ( action >= 1003 ) { 998 } else if ( action >= 1003 ) {
999 if ( temp->getIsLocalFileSync() ) { 999 if ( temp->getIsLocalFileSync() ) {
1000 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1000 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1001 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1001 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1002 } else { 1002 } else {
1003 if ( temp->getIsPhoneSync() ) { 1003 if ( temp->getIsPhoneSync() ) {
1004 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1004 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1005 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1005 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1006 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1006 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1007 syncPhone(); 1007 syncPhone();
1008 } else 1008 } else
1009 syncRemote( temp ); 1009 syncRemote( temp );
1010 1010
1011 } 1011 }
1012 } 1012 }
1013 delete temp; 1013 delete temp;
1014 mBlockSaveFlag = false; 1014 mBlockSaveFlag = false;
1015} 1015}
1016void MainWindow::setDefaultPreferences() 1016void MainWindow::setDefaultPreferences()
1017{ 1017{
1018 KOPrefs *p = KOPrefs::instance(); 1018 KOPrefs *p = KOPrefs::instance();
1019 1019
1020 p->mCompactDialogs = true; 1020 p->mCompactDialogs = true;
1021 p->mConfirm = true; 1021 p->mConfirm = true;
1022 // p->mEnableQuickTodo = false; 1022 // p->mEnableQuickTodo = false;
1023} 1023}
1024 1024
1025QString MainWindow::resourcePath() 1025QString MainWindow::resourcePath()
1026{ 1026{
1027 return KGlobal::iconLoader()->iconPath(); 1027 return KGlobal::iconLoader()->iconPath();
1028} 1028}
1029 1029
1030void MainWindow::displayText( QString text ,QString cap ) 1030void MainWindow::displayText( QString text ,QString cap )
1031{ 1031{
1032 QDialog dia( this, "name", true ); ; 1032 QDialog dia( this, "name", true ); ;
1033 dia.setCaption( cap ); 1033 dia.setCaption( cap );
1034 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1034 QVBoxLayout* lay = new QVBoxLayout( &dia );
1035 lay->setSpacing( 3 ); 1035 lay->setSpacing( 3 );
1036 lay->setMargin( 3 ); 1036 lay->setMargin( 3 );
1037 QTextBrowser tb ( &dia ); 1037 QTextBrowser tb ( &dia );
1038 lay->addWidget( &tb ); 1038 lay->addWidget( &tb );
1039 tb.setText( text ); 1039 tb.setText( text );
1040#ifdef DESKTOP_VERSION 1040#ifdef DESKTOP_VERSION
1041 dia.resize( 640, 480); 1041 dia.resize( 640, 480);
1042#else 1042#else
1043 dia.showMaximized(); 1043 dia.showMaximized();
1044#endif 1044#endif
1045 dia.exec(); 1045 dia.exec();
1046} 1046}
1047void MainWindow::displayFile( QString fn, QString cap ) 1047void MainWindow::displayFile( QString fn, QString cap )
1048{ 1048{
1049 QString fileName = resourcePath() + fn; 1049 QString fileName = resourcePath() + fn;
1050 QString text; 1050 QString text;
1051 QFile file( fileName ); 1051 QFile file( fileName );
1052 if (!file.open( IO_ReadOnly ) ) { 1052 if (!file.open( IO_ReadOnly ) ) {
1053 return ; 1053 return ;
1054 1054
1055 } 1055 }
1056 QTextStream ts( &file ); 1056 QTextStream ts( &file );
1057 text = ts.read(); 1057 text = ts.read();
1058 file.close(); 1058 file.close();
1059 displayText( text, cap); 1059 displayText( text, cap);
1060} 1060}
1061void MainWindow::features() 1061void MainWindow::features()
1062{ 1062{
1063 1063
1064 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1064 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1065} 1065}
1066 1066
1067void MainWindow::usertrans() 1067void MainWindow::usertrans()
1068{ 1068{
1069 1069
1070 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1070 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1071} 1071}
1072#if 0
1073#include <libkcal/vcalformat.h>
1074#include <libkcal/event.h>
1075#include <libkcal/todo.h>
1076#include <libkcal/incidence.h>
1077#endif
1072void MainWindow::synchowto() 1078void MainWindow::synchowto()
1073{ 1079{
1074 1080#if 0
1081 QPtrList<Incidence> er = mCalendar->rawIncidences();
1082 Incidence* inR = er.first();
1083 VCalFormat vf;
1084 QString strout;
1085 while ( inR ) {
1086 if ( inR->type() == "Todo" )
1087 strout = vf.todoToString( (Todo *) inR );
1088 if ( inR->type() == "Event" )
1089 strout = vf.eventToString( (Event *) inR );
1090 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1091 inR = er.next();
1092 }
1093#endif
1075 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1094 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1076} 1095}
1077void MainWindow::faq() 1096void MainWindow::faq()
1078{ 1097{
1079 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1098 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1080 1099
1081} 1100}
1082void MainWindow::whatsNew() 1101void MainWindow::whatsNew()
1083{ 1102{
1084 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1103 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1085 1104
1086} 1105}
1087void MainWindow::licence() 1106void MainWindow::licence()
1088{ 1107{
1089 KApplication::showLicence(); 1108 KApplication::showLicence();
1090 1109
1091} 1110}
1092void MainWindow::about() 1111void MainWindow::about()
1093{ 1112{
1094 QString version; 1113 QString version;
1095#include <../version> 1114#include <../version>
1096 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1115 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1097 i18n("KOrganizer/Platform-independent\n") + 1116 i18n("KOrganizer/Platform-independent\n") +
1098 "(KO/Pi) " + version + " - " + 1117 "(KO/Pi) " + version + " - " +
1099 1118
1100#ifdef DESKTOP_VERSION 1119#ifdef DESKTOP_VERSION
1101 i18n("Desktop Edition\n") + 1120 i18n("Desktop Edition\n") +
1102#else 1121#else
1103 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1122 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1104#endif 1123#endif
1105 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1124 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1106} 1125}
1107void MainWindow::keyBindings() 1126void MainWindow::keyBindings()
1108{ 1127{
1109 QString cap = i18n("Key bindings KOrganizer/Pi"); 1128 QString cap = i18n("Key bindings KOrganizer/Pi");
1110 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1129 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1111 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1130 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1112 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1131 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1113 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1132 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1114 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1133 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1115 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1134 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1116 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1135 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1117 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1136 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1118 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1137 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1119 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1138 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1120 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1139 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1121 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1140 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1122 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1141 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1123 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1142 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1124 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1143 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1125 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1144 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1126 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1145 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1127 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1146 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1128 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1147 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1129 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1148 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1130 i18n("<p><h3>In agenda view:</h3></p>\n") + 1149 i18n("<p><h3>In agenda view:</h3></p>\n") +
1131 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1150 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1132 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1151 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1133 i18n("<p><h3>In todo view:</h3></p>\n") + 1152 i18n("<p><h3>In todo view:</h3></p>\n") +
1134 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1153 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1135 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1154 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1136 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1155 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1137 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1156 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1138 i18n("<p><h3>In list view:</h3></p>\n") + 1157 i18n("<p><h3>In list view:</h3></p>\n") +
1139 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1158 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1140 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1159 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1141 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1160 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1142 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1161 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1143 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1162 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1144 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1163 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1145 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1164 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1146 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1165 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1147 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1166 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1148 i18n("<p><b>E</b>: Edit item</p>\n") + 1167 i18n("<p><b>E</b>: Edit item</p>\n") +
1149 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1168 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1150 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1169 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1151 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1170 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1152 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1171 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1153 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1172 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1154 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1173 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1155 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1174 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1156 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1175 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1157 i18n("<p><b>White</b>: Item readonly</p>\n"); 1176 i18n("<p><b>White</b>: Item readonly</p>\n");
1158 displayText( text, cap); 1177 displayText( text, cap);
1159 1178
1160} 1179}
1161void MainWindow::aboutAutoSaving() 1180void MainWindow::aboutAutoSaving()
1162{ 1181{
1163 QMessageBox* msg; 1182 QMessageBox* msg;
1164 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1183 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1165 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) 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"), QMessageBox::NoIcon, 1184 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) 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"), QMessageBox::NoIcon,
1166 QMessageBox::Ok, 1185 QMessageBox::Ok,
1167 QMessageBox::NoButton, 1186 QMessageBox::NoButton,
1168 QMessageBox::NoButton); 1187 QMessageBox::NoButton);
1169 msg->exec(); 1188 msg->exec();
1170 delete msg; 1189 delete msg;
1171 1190
1172 1191
1173} 1192}
1174void MainWindow::aboutKnownBugs() 1193void MainWindow::aboutKnownBugs()
1175{ 1194{
1176 QMessageBox* msg; 1195 QMessageBox* msg;
1177 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1196 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1178 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")+ 1197 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")+
1179 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1198 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1180 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1199 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1181 i18n("\nor report them in the bugtracker on\n") + 1200 i18n("\nor report them in the bugtracker on\n") +
1182 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1201 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1183 QMessageBox::NoIcon, 1202 QMessageBox::NoIcon,
1184 QMessageBox::Ok, 1203 QMessageBox::Ok,
1185 QMessageBox::NoButton, 1204 QMessageBox::NoButton,
1186 QMessageBox::NoButton); 1205 QMessageBox::NoButton);
1187 msg->exec(); 1206 msg->exec();
1188 delete msg; 1207 delete msg;
1189 1208
1190} 1209}
1191 1210
1192QString MainWindow::defaultFileName() 1211QString MainWindow::defaultFileName()
1193{ 1212{
1194 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1213 return locateLocal( "data", "korganizer/mycalendar.ics" );
1195} 1214}
1196 1215
1197void MainWindow::processIncidenceSelection( Incidence *incidence ) 1216void MainWindow::processIncidenceSelection( Incidence *incidence )
1198{ 1217{
1199 if ( !incidence ) { 1218 if ( !incidence ) {
1200 enableIncidenceActions( false ); 1219 enableIncidenceActions( false );
1201 1220
1202 mNewSubTodoAction->setEnabled( false ); 1221 mNewSubTodoAction->setEnabled( false );
1203 setCaptionToDates(); 1222 setCaptionToDates();
1204 return; 1223 return;
1205 1224
1206 } 1225 }
1207 1226
1208 //KGlobal::locale()->formatDateTime(nextA, true); 1227 //KGlobal::locale()->formatDateTime(nextA, true);
1209 QString startString = ""; 1228 QString startString = "";
1210 if ( incidence->type() != "Todo" ) { 1229 if ( incidence->type() != "Todo" ) {
1211 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1230 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1212 if ( incidence->doesFloat() ) { 1231 if ( incidence->doesFloat() ) {
1213 startString += ": "+incidence->dtStartDateStr( true ); 1232 startString += ": "+incidence->dtStartDateStr( true );
1214 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1233 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1215 1234
1216 } else { 1235 } else {
1217 startString = ": "+incidence->dtStartStr(true); 1236 startString = ": "+incidence->dtStartStr(true);
1218 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1237 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1219 1238
1220 } 1239 }
1221 1240
1222 } else { 1241 } else {
1223 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1242 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1224 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1243 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1225 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1244 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1226 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1245 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1227 } 1246 }
1228 1247
1229 } 1248 }
1230 else 1249 else
1231 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1250 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1232 if ( !incidence->location().isEmpty() ) 1251 if ( !incidence->location().isEmpty() )
1233 startString += " (" +incidence->location()+")"; 1252 startString += " (" +incidence->location()+")";
1234 setCaption( incidence->summary()+startString); 1253 setCaption( incidence->summary()+startString);
1235 1254
1236 enableIncidenceActions( true ); 1255 enableIncidenceActions( true );
1237 1256
1238 if ( incidence->type() == "Event" ) { 1257 if ( incidence->type() == "Event" ) {
1239 mShowAction->setText( i18n("Show Event...") ); 1258 mShowAction->setText( i18n("Show Event...") );
1240 mEditAction->setText( i18n("Edit Event...") ); 1259 mEditAction->setText( i18n("Edit Event...") );
1241 mDeleteAction->setText( i18n("Delete Event...") ); 1260 mDeleteAction->setText( i18n("Delete Event...") );
1242 1261
1243 mNewSubTodoAction->setEnabled( false ); 1262 mNewSubTodoAction->setEnabled( false );
1244 } else if ( incidence->type() == "Todo" ) { 1263 } else if ( incidence->type() == "Todo" ) {
1245 mShowAction->setText( i18n("Show Todo...") ); 1264 mShowAction->setText( i18n("Show Todo...") );
1246 mEditAction->setText( i18n("Edit Todo...") ); 1265 mEditAction->setText( i18n("Edit Todo...") );
1247 mDeleteAction->setText( i18n("Delete Todo...") ); 1266 mDeleteAction->setText( i18n("Delete Todo...") );
1248 1267
1249 mNewSubTodoAction->setEnabled( true ); 1268 mNewSubTodoAction->setEnabled( true );
1250 } else { 1269 } else {
1251 mShowAction->setText( i18n("Show...") ); 1270 mShowAction->setText( i18n("Show...") );
1252 mShowAction->setText( i18n("Edit...") ); 1271 mShowAction->setText( i18n("Edit...") );
1253 mShowAction->setText( i18n("Delete...") ); 1272 mShowAction->setText( i18n("Delete...") );
1254 1273
1255 mNewSubTodoAction->setEnabled( false ); 1274 mNewSubTodoAction->setEnabled( false );
1256 } 1275 }
1257} 1276}
1258 1277
1259void MainWindow::enableIncidenceActions( bool enabled ) 1278void MainWindow::enableIncidenceActions( bool enabled )
1260{ 1279{
1261 mShowAction->setEnabled( enabled ); 1280 mShowAction->setEnabled( enabled );
1262 mEditAction->setEnabled( enabled ); 1281 mEditAction->setEnabled( enabled );
1263 mDeleteAction->setEnabled( enabled ); 1282 mDeleteAction->setEnabled( enabled );
1264} 1283}
1265 1284
1266void MainWindow::importOL() 1285void MainWindow::importOL()
1267{ 1286{
1268#ifdef _WIN32_ 1287#ifdef _WIN32_
1269 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1288 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1270 id->exec(); 1289 id->exec();
1271 delete id; 1290 delete id;
1272 mView->updateView(); 1291 mView->updateView();
1273#endif 1292#endif
1274} 1293}
1275void MainWindow::importBday() 1294void MainWindow::importBday()
1276{ 1295{
1277 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1296 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1278 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1297 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1279 i18n("Import!"), i18n("Cancel"), 0, 1298 i18n("Import!"), i18n("Cancel"), 0,
1280 0, 1 ); 1299 0, 1 );
1281 if ( result == 0 ) { 1300 if ( result == 0 ) {
1282 mView->importBday(); 1301 mView->importBday();
1283 1302
1284 } 1303 }
1285 1304
1286 1305
1287} 1306}
1288void MainWindow::importQtopia() 1307void MainWindow::importQtopia()
1289{ 1308{
1290#ifndef DESKTOP_VERSION 1309#ifndef DESKTOP_VERSION
1291 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1310 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1292 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"), 1311 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"),
1293 i18n("Import!"), i18n("Cancel"), 0, 1312 i18n("Import!"), i18n("Cancel"), 0,
1294 0, 1 ); 1313 0, 1 );
1295 if ( result == 0 ) { 1314 if ( result == 0 ) {
1296 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1315 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1297 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1316 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1298 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1317 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1299 mView->importQtopia( categories, datebook, todolist ); 1318 mView->importQtopia( categories, datebook, todolist );
1300 } 1319 }
1301#else 1320#else
1302 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1321 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1303 i18n("Not supported \non desktop!\n"), 1322 i18n("Not supported \non desktop!\n"),
1304 i18n("Ok"), i18n("Cancel"), 0, 1323 i18n("Ok"), i18n("Cancel"), 0,
1305 0, 1 ); 1324 0, 1 );
1306 1325
1307#endif 1326#endif
1308} 1327}
1309 1328
1310void MainWindow::saveOnClose() 1329void MainWindow::saveOnClose()
1311{ 1330{
1312 KOPrefs *p = KOPrefs::instance(); 1331 KOPrefs *p = KOPrefs::instance();
1313 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1332 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1314 p->mToolBarUp = iconToolBar->x() > width()/2 || 1333 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1315 iconToolBar->y() > height()/2; 1334 iconToolBar->y() > height()/2;
1316 mView->writeSettings(); 1335 mView->writeSettings();
1317 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1336 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1318 save(); 1337 save();
1319} 1338}
1320void MainWindow::slotModifiedChanged( bool changed ) 1339void MainWindow::slotModifiedChanged( bool changed )
1321{ 1340{
1322 if ( mBlockAtStartup ) 1341 if ( mBlockAtStartup )
1323 return; 1342 return;
1324 int msec; 1343 int msec;
1325 // we store the changes after 1 minute, 1344 // we store the changes after 1 minute,
1326 // and for safety reasons after 10 minutes again 1345 // and for safety reasons after 10 minutes again
1327 if ( !mBlockSaveFlag ) 1346 if ( !mBlockSaveFlag )
1328 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1347 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1329 else 1348 else
1330 msec = 1000 * 600; 1349 msec = 1000 * 600;
1331 mSaveTimer.start( msec, true ); // 1 minute 1350 mSaveTimer.start( msec, true ); // 1 minute
1332 qDebug("KO: Saving File in %d secs!", msec/1000); 1351 qDebug("KO: Saving File in %d secs!", msec/1000);
1333 mCalendarModifiedFlag = true; 1352 mCalendarModifiedFlag = true;
1334} 1353}
1335#include <qfileinfo.h> 1354#include <qfileinfo.h>
1336void MainWindow::save() 1355void MainWindow::save()
1337{ 1356{
1338 if ( mBlockSaveFlag ) 1357 if ( mBlockSaveFlag )
1339 return; 1358 return;
1340 bool store = mBlockSaveFlag; 1359 bool store = mBlockSaveFlag;
1341 mBlockSaveFlag = true; 1360 mBlockSaveFlag = true;
1342 if ( mView->checkFileVersion( defaultFileName()) ) { 1361 if ( mView->checkFileVersion( defaultFileName()) ) {
1343 1362
1344 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1363 QTime neededSaveTime = QDateTime::currentDateTime().time();
1345 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1364 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1346 qDebug("KO: Start saving data to file!"); 1365 qDebug("KO: Start saving data to file!");
1347 mView->saveCalendar( defaultFileName() ); 1366 mView->saveCalendar( defaultFileName() );
1348 1367
1349 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1368 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1350 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1369 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1351 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1370 qDebug("KO: Needed %d ms for saving.",msNeeded );
1352 QString savemes; 1371 QString savemes;
1353 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1372 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1354 setCaption(savemes); 1373 setCaption(savemes);
1355 } else 1374 } else
1356 setCaption(i18n("Saving cancelled!")); 1375 setCaption(i18n("Saving cancelled!"));
1357 mCalendarModifiedFlag = false; 1376 mCalendarModifiedFlag = false;
1358 mBlockSaveFlag = store; 1377 mBlockSaveFlag = store;
1359} 1378}
1360 1379
1361void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1380void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1362{ 1381{
1363 if ( !e->isAutoRepeat() ) { 1382 if ( !e->isAutoRepeat() ) {
1364 mFlagKeyPressed = false; 1383 mFlagKeyPressed = false;
1365 } 1384 }
1366} 1385}
1367void MainWindow::keyPressEvent ( QKeyEvent * e ) 1386void MainWindow::keyPressEvent ( QKeyEvent * e )
1368{ 1387{
1369 qApp->processEvents(); 1388 qApp->processEvents();
1370 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1389 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1371 e->ignore(); 1390 e->ignore();
1372 // qDebug(" ignore %d",e->isAutoRepeat() ); 1391 // qDebug(" ignore %d",e->isAutoRepeat() );
1373 return; 1392 return;
1374 } 1393 }
1375 if (! e->isAutoRepeat() ) 1394 if (! e->isAutoRepeat() )
1376 mFlagKeyPressed = true; 1395 mFlagKeyPressed = true;
1377 KOPrefs *p = KOPrefs::instance(); 1396 KOPrefs *p = KOPrefs::instance();
1378 bool showSelectedDates = false; 1397 bool showSelectedDates = false;
1379 int size; 1398 int size;
1380 int pro = 0; 1399 int pro = 0;
1381 //qDebug("MainWindow::keyPressEvent "); 1400 //qDebug("MainWindow::keyPressEvent ");
1382 switch ( e->key() ) { 1401 switch ( e->key() ) {
1383 case Qt::Key_Right: 1402 case Qt::Key_Right:
1384 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1403 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1385 mView->goNextMonth(); 1404 mView->goNextMonth();
1386 else 1405 else
1387 mView->goNext(); 1406 mView->goNext();
1388 showSelectedDates = true; 1407 showSelectedDates = true;
1389 break; 1408 break;
1390 case Qt::Key_Left: 1409 case Qt::Key_Left:
1391 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1410 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1392 mView->goPreviousMonth(); 1411 mView->goPreviousMonth();
1393 else 1412 else
1394 mView->goPrevious(); 1413 mView->goPrevious();
1395 showSelectedDates = true; 1414 showSelectedDates = true;
1396 break; 1415 break;
1397 case Qt::Key_Down: 1416 case Qt::Key_Down:
1398 mView->viewManager()->agendaView()->scrollOneHourDown(); 1417 mView->viewManager()->agendaView()->scrollOneHourDown();
1399 break; 1418 break;
1400 case Qt::Key_Up: 1419 case Qt::Key_Up:
1401 mView->viewManager()->agendaView()->scrollOneHourUp(); 1420 mView->viewManager()->agendaView()->scrollOneHourUp();
1402 break; 1421 break;
1403 case Qt::Key_I: 1422 case Qt::Key_I:
1404 mView->showIncidence(); 1423 mView->showIncidence();
1405 break; 1424 break;
1406 case Qt::Key_Delete: 1425 case Qt::Key_Delete:
1407 case Qt::Key_Backspace: 1426 case Qt::Key_Backspace:
1408 mView->deleteIncidence(); 1427 mView->deleteIncidence();
1409 break; 1428 break;
1410 case Qt::Key_D: 1429 case Qt::Key_D:
1411 mView->viewManager()->showDayView(); 1430 mView->viewManager()->showDayView();
1412 showSelectedDates = true; 1431 showSelectedDates = true;
1413 break; 1432 break;
1414 case Qt::Key_O: 1433 case Qt::Key_O:
1415 mView->toggleFilerEnabled( ); 1434 mView->toggleFilerEnabled( );
1416 break; 1435 break;
1417 case Qt::Key_0: 1436 case Qt::Key_0:
1418 case Qt::Key_1: 1437 case Qt::Key_1:
1419 case Qt::Key_2: 1438 case Qt::Key_2:
1420 case Qt::Key_3: 1439 case Qt::Key_3:
1421 case Qt::Key_4: 1440 case Qt::Key_4:
1422 case Qt::Key_5: 1441 case Qt::Key_5:
1423 case Qt::Key_6: 1442 case Qt::Key_6:
1424 case Qt::Key_7: 1443 case Qt::Key_7:
1425 case Qt::Key_8: 1444 case Qt::Key_8:
1426 case Qt::Key_9: 1445 case Qt::Key_9:
1427 pro = e->key()-48; 1446 pro = e->key()-48;
1428 if ( pro == 0 ) 1447 if ( pro == 0 )
1429 pro = 10; 1448 pro = 10;
1430 if ( e->state() == Qt::ControlButton) 1449 if ( e->state() == Qt::ControlButton)
1431 pro += 10; 1450 pro += 10;
1432 break; 1451 break;
1433 case Qt::Key_M: 1452 case Qt::Key_M:
1434 mView->viewManager()->showMonthView(); 1453 mView->viewManager()->showMonthView();
1435 showSelectedDates = true; 1454 showSelectedDates = true;
1436 break; 1455 break;
1437 case Qt::Key_Insert: 1456 case Qt::Key_Insert:
1438 mView->newEvent(); 1457 mView->newEvent();
1439 break; 1458 break;
1440 case Qt::Key_S : 1459 case Qt::Key_S :
1441 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1460 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1442 mView->newSubTodo(); 1461 mView->newSubTodo();
1443 else 1462 else
1444 mView->dialogManager()->showSearchDialog(); 1463 mView->dialogManager()->showSearchDialog();
1445 break; 1464 break;
1446 case Qt::Key_Y : 1465 case Qt::Key_Y :
1447 case Qt::Key_Z : 1466 case Qt::Key_Z :
1448 mView->viewManager()->showWorkWeekView(); 1467 mView->viewManager()->showWorkWeekView();
1449 showSelectedDates = true; 1468 showSelectedDates = true;
1450 break; 1469 break;
1451 case Qt::Key_U : 1470 case Qt::Key_U :
1452 mView->viewManager()->showWeekView(); 1471 mView->viewManager()->showWeekView();
1453 showSelectedDates = true; 1472 showSelectedDates = true;
1454 break; 1473 break;
1455 case Qt::Key_H : 1474 case Qt::Key_H :
1456 keyBindings(); 1475 keyBindings();
1457 break; 1476 break;
1458 case Qt::Key_W: 1477 case Qt::Key_W:
1459 mView->viewManager()->showWhatsNextView(); 1478 mView->viewManager()->showWhatsNextView();
1460 break; 1479 break;
1461 case Qt::Key_L: 1480 case Qt::Key_L:
1462 mView->viewManager()->showListView(); 1481 mView->viewManager()->showListView();
1463 break; 1482 break;
1464 case Qt::Key_N: 1483 case Qt::Key_N:
1465 mView->viewManager()->showNextXView(); 1484 mView->viewManager()->showNextXView();
1466 showSelectedDates = true; 1485 showSelectedDates = true;
1467 break; 1486 break;
1468 case Qt::Key_V: 1487 case Qt::Key_V:
1469 mView->viewManager()->showTodoView(); 1488 mView->viewManager()->showTodoView();
1470 break; 1489 break;
1471 case Qt::Key_C: 1490 case Qt::Key_C:
1472 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1491 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1473 break; 1492 break;
1474 case Qt::Key_P: 1493 case Qt::Key_P:
1475 mView->showDatePicker( ); 1494 mView->showDatePicker( );
1476 break; 1495 break;
1477 case Qt::Key_F: 1496 case Qt::Key_F:
1478 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1497 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1479 mView->editFilters(); 1498 mView->editFilters();
1480 else 1499 else
1481 mView->toggleFilter(); 1500 mView->toggleFilter();
1482 break; 1501 break;
1483 case Qt::Key_X: 1502 case Qt::Key_X:
1484 mView->toggleDateNavigatorWidget(); 1503 mView->toggleDateNavigatorWidget();
1485 break; 1504 break;
1486 case Qt::Key_Space: 1505 case Qt::Key_Space:
1487 mView->toggleExpand(); 1506 mView->toggleExpand();
1488 break; 1507 break;
1489 case Qt::Key_A: 1508 case Qt::Key_A:
1490 mView->toggleAllDaySize(); 1509 mView->toggleAllDaySize();
1491 break; 1510 break;
1492 case Qt::Key_T: 1511 case Qt::Key_T:
1493 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1512 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1494 mView->newTodo(); 1513 mView->newTodo();
1495 else { 1514 else {
1496 mView->goToday(); 1515 mView->goToday();
1497 showSelectedDates = true; 1516 showSelectedDates = true;
1498 } 1517 }
1499 break; 1518 break;
1500 case Qt::Key_J: 1519 case Qt::Key_J:
1501 mView->viewManager()->showJournalView(); 1520 mView->viewManager()->showJournalView();
1502 break; 1521 break;
1503 case Qt::Key_B: 1522 case Qt::Key_B:
1504 mView->editIncidenceDescription();; 1523 mView->editIncidenceDescription();;
1505 break; 1524 break;
1506 // case Qt::Key_Return: 1525 // case Qt::Key_Return:
1507 case Qt::Key_E: 1526 case Qt::Key_E:
1508 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1527 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1509 mView->newEvent(); 1528 mView->newEvent();
1510 else 1529 else
1511 mView->editIncidence(); 1530 mView->editIncidence();
1512 break; 1531 break;
1513 case Qt::Key_Plus: 1532 case Qt::Key_Plus:
1514 size = p->mHourSize +2; 1533 size = p->mHourSize +2;
1515 if ( size <= 18 ) 1534 if ( size <= 18 )
1516 configureAgenda( size ); 1535 configureAgenda( size );
1517 break; 1536 break;
1518 case Qt::Key_Minus: 1537 case Qt::Key_Minus:
1519 size = p->mHourSize - 2; 1538 size = p->mHourSize - 2;
1520 if ( size >= 4 ) 1539 if ( size >= 4 )
1521 configureAgenda( size ); 1540 configureAgenda( size );
1522 break; 1541 break;
1523 1542
1524 1543
1525 default: 1544 default:
1526 e->ignore(); 1545 e->ignore();
1527 } 1546 }
1528 if ( pro > 0 ) { 1547 if ( pro > 0 ) {
1529 mView->selectFilter( pro-1 ); 1548 mView->selectFilter( pro-1 );
1530 } 1549 }
1531 if ( showSelectedDates ) { 1550 if ( showSelectedDates ) {
1532 ;// setCaptionToDates(); 1551 ;// setCaptionToDates();
1533 } 1552 }
1534 1553
1535} 1554}
1536 1555
1537void MainWindow::fillFilterMenu() 1556void MainWindow::fillFilterMenu()
1538{ 1557{
1539 selectFilterMenu->clear(); 1558 selectFilterMenu->clear();
1540 bool disable = false; 1559 bool disable = false;
1541 if ( mView->filterView()->filtersEnabled() ) { 1560 if ( mView->filterView()->filtersEnabled() ) {
1542 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1561 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1543 } 1562 }
1544 else { 1563 else {
1545 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1564 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1546 disable = true; 1565 disable = true;
1547 } 1566 }
1548 selectFilterMenu->insertSeparator(); 1567 selectFilterMenu->insertSeparator();
1549 QPtrList<CalFilter> fili = mView->filters(); 1568 QPtrList<CalFilter> fili = mView->filters();
1550 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1569 CalFilter *curfilter = mView->filterView()->selectedFilter();
1551 CalFilter *filter = fili.first(); 1570 CalFilter *filter = fili.first();
1552 int iii = 1; 1571 int iii = 1;
1553 while(filter) { 1572 while(filter) {
1554 selectFilterMenu->insertItem( filter->name(), iii ); 1573 selectFilterMenu->insertItem( filter->name(), iii );
1555 if ( filter == curfilter) 1574 if ( filter == curfilter)
1556 selectFilterMenu->setItemChecked( iii, true ); 1575 selectFilterMenu->setItemChecked( iii, true );
1557 if ( disable ) 1576 if ( disable )
1558 selectFilterMenu->setItemEnabled( iii, false ); 1577 selectFilterMenu->setItemEnabled( iii, false );
1559 filter = fili.next(); 1578 filter = fili.next();
1560 ++iii; 1579 ++iii;
1561 } 1580 }
1562} 1581}
1563void MainWindow::selectFilter( int fil ) 1582void MainWindow::selectFilter( int fil )
1564{ 1583{
1565 if ( fil == 0 ) { 1584 if ( fil == 0 ) {
1566 mView->toggleFilerEnabled( ); 1585 mView->toggleFilerEnabled( );
1567 } else { 1586 } else {
1568 mView->selectFilter( fil-1 ); 1587 mView->selectFilter( fil-1 );
1569 } 1588 }
1570} 1589}
1571void MainWindow::configureToolBar( int item ) 1590void MainWindow::configureToolBar( int item )
1572{ 1591{
1573 1592
1574 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1593 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1575 KOPrefs *p = KOPrefs::instance(); 1594 KOPrefs *p = KOPrefs::instance();
1576 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1595 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1577 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1596 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1578 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1597 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1579 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1598 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1580 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1599 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1581 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1600 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1582 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1601 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1583 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1602 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1584 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1603 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1585 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1604 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1586 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1605 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1587 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1606 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1588 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1607 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1589 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1608 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1590 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1609 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1591 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1610 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1592 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1611 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1593 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1612 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1594 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1613 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1595 // initActions(); 1614 // initActions();
1596} 1615}
1597 1616
1598void MainWindow::setCaptionToDates() 1617void MainWindow::setCaptionToDates()
1599{ 1618{
1600 QString selDates; 1619 QString selDates;
1601 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1620 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1602 if (mView->startDate() < mView->endDate() ) 1621 if (mView->startDate() < mView->endDate() )
1603 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1622 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1604 setCaption( i18n("Dates: ") + selDates ); 1623 setCaption( i18n("Dates: ") + selDates );
1605 1624
1606} 1625}
1607// parameter item == 0: reinit 1626// parameter item == 0: reinit
1608void MainWindow::configureAgenda( int item ) 1627void MainWindow::configureAgenda( int item )
1609{ 1628{
1610 1629
1611 KOPrefs *p = KOPrefs::instance(); 1630 KOPrefs *p = KOPrefs::instance();
1612 1631
1613 int i; 1632 int i;
1614 if ( item == 1 ) { 1633 if ( item == 1 ) {
1615 mView->toggleAllDaySize(); 1634 mView->toggleAllDaySize();
1616 return; 1635 return;
1617 } 1636 }
1618 // do not allow 4 for widgets higher than 480 1637 // do not allow 4 for widgets higher than 480
1619 // if ( QApplication::desktop()->height() > 480 ) { 1638 // if ( QApplication::desktop()->height() > 480 ) {
1620// if ( item == 4 ) 1639// if ( item == 4 )
1621// item = 6; 1640// item = 6;
1622// } 1641// }
1623 for ( i = 4; i <= 18; i= i+2 ) 1642 for ( i = 4; i <= 18; i= i+2 )
1624 configureAgendaMenu->setItemChecked( i, false ); 1643 configureAgendaMenu->setItemChecked( i, false );
1625 configureAgendaMenu->setItemChecked( item, true ); 1644 configureAgendaMenu->setItemChecked( item, true );
1626 if ( p->mHourSize == item ) 1645 if ( p->mHourSize == item )
1627 return; 1646 return;
1628 p->mHourSize=item; 1647 p->mHourSize=item;
1629 mView->viewManager()->agendaView()->updateConfig(); 1648 mView->viewManager()->agendaView()->updateConfig();
1630} 1649}
1631 1650
1632void MainWindow::saveCalendar() 1651void MainWindow::saveCalendar()
1633{ 1652{
1634 QString fn = KOPrefs::instance()->mLastSaveFile; 1653 QString fn = KOPrefs::instance()->mLastSaveFile;
1635 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1654 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1636 1655
1637 if ( fn == "" ) 1656 if ( fn == "" )
1638 return; 1657 return;
1639 QFileInfo info; 1658 QFileInfo info;
1640 info.setFile( fn ); 1659 info.setFile( fn );
1641 QString mes; 1660 QString mes;
1642 bool createbup = true; 1661 bool createbup = true;
1643 if ( info. exists() ) { 1662 if ( info. exists() ) {
1644 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1663 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1645 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1664 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1646 i18n("Overwrite!"), i18n("Cancel"), 0, 1665 i18n("Overwrite!"), i18n("Cancel"), 0,
1647 0, 1 ); 1666 0, 1 );
1648 if ( result != 0 ) { 1667 if ( result != 0 ) {
1649 createbup = false; 1668 createbup = false;
1650 } 1669 }
1651 } 1670 }
1652 if ( createbup ) { 1671 if ( createbup ) {
1653 mView->saveCalendar( fn ); 1672 mView->saveCalendar( fn );
1654 mes = i18n("KO/Pi:Saved %1").arg(fn); 1673 mes = i18n("KO/Pi:Saved %1").arg(fn);
1655 KOPrefs::instance()->mLastSaveFile = fn; 1674 KOPrefs::instance()->mLastSaveFile = fn;
1656 setCaption(mes); 1675 setCaption(mes);
1657 } 1676 }
1658} 1677}
1659void MainWindow::loadCalendar() 1678void MainWindow::loadCalendar()
1660{ 1679{
1661 1680
1662 QString fn = KOPrefs::instance()->mLastLoadFile; 1681 QString fn = KOPrefs::instance()->mLastLoadFile;
1663 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1682 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1664 1683
1665 if ( fn == "" ) 1684 if ( fn == "" )
1666 return; 1685 return;
1667 QFileInfo info; 1686 QFileInfo info;
1668 info.setFile( fn ); 1687 info.setFile( fn );
1669 QString mess; 1688 QString mess;
1670 bool loadbup = true; 1689 bool loadbup = true;
1671 if ( info. exists() ) { 1690 if ( info. exists() ) {
1672 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1691 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1673 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1692 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1674 mess, 1693 mess,
1675 i18n("Load!"), i18n("Cancel"), 0, 1694 i18n("Load!"), i18n("Cancel"), 0,
1676 0, 1 ); 1695 0, 1 );
1677 if ( result != 0 ) { 1696 if ( result != 0 ) {
1678 loadbup = false; 1697 loadbup = false;
1679 } 1698 }
1680 } else { 1699 } else {
1681 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1700 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1682 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1701 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1683 0, 1 ); 1702 0, 1 );
1684 1703
1685 return; 1704 return;
1686 } 1705 }
1687 if ( loadbup ) { 1706 if ( loadbup ) {
1688 mView->openCalendar( fn ); 1707 mView->openCalendar( fn );
1689 KOPrefs::instance()->mLastLoadFile = fn; 1708 KOPrefs::instance()->mLastLoadFile = fn;
1690 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1709 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1691 setCaption(mess); 1710 setCaption(mess);
1692 } 1711 }
1693 1712
1694} 1713}
1695void MainWindow::quickImportIcal() 1714void MainWindow::quickImportIcal()
1696{ 1715{
1697 importFile( KOPrefs::instance()->mLastImportFile, false ); 1716 importFile( KOPrefs::instance()->mLastImportFile, false );
1698} 1717}
1699void MainWindow::importFile( QString fn, bool quick ) 1718void MainWindow::importFile( QString fn, bool quick )
1700{ 1719{
1701 QFileInfo info; 1720 QFileInfo info;
1702 info.setFile( fn ); 1721 info.setFile( fn );
1703 QString mess; 1722 QString mess;
1704 bool loadbup = true; 1723 bool loadbup = true;
1705 if ( !info. exists() ) { 1724 if ( !info. exists() ) {
1706 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1725 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1707 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1726 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1708 mess ); 1727 mess );
1709 return; 1728 return;
1710 } 1729 }
1711 int result = 0; 1730 int result = 0;
1712 if ( !quick ) { 1731 if ( !quick ) {
1713 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 )); 1732 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 ));
1714 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1733 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1715 mess, 1734 mess,
1716 "Import", "Cancel", 0, 1735 "Import", "Cancel", 0,
1717 0, 1 ); 1736 0, 1 );
1718 } 1737 }
1719 if ( result == 0 ) { 1738 if ( result == 0 ) {
1720 if ( mView->openCalendar( fn, true )) { 1739 if ( mView->openCalendar( fn, true )) {
1721 KOPrefs::instance()->mLastImportFile = fn; 1740 KOPrefs::instance()->mLastImportFile = fn;
1722 setCaption(i18n("Imported file successfully")); 1741 setCaption(i18n("Imported file successfully"));
1723 } else { 1742 } else {
1724 setCaption(i18n("Error importing file")); 1743 setCaption(i18n("Error importing file"));
1725 } 1744 }
1726 } 1745 }
1727} 1746}
1728 1747
1729void MainWindow::importIcal() 1748void MainWindow::importIcal()
1730{ 1749{
1731 1750
1732 QString fn =KOPrefs::instance()->mLastImportFile; 1751 QString fn =KOPrefs::instance()->mLastImportFile;
1733 1752
1734 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1753 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1735 if ( fn == "" ) 1754 if ( fn == "" )
1736 return; 1755 return;
1737 importFile( fn, true ); 1756 importFile( fn, true );
1738 1757
1739} 1758}
1740 1759
1741void MainWindow::exportVCalendar() 1760void MainWindow::exportVCalendar()
1742{ 1761{
1743 QString fn = KOPrefs::instance()->mLastVcalFile; 1762 QString fn = KOPrefs::instance()->mLastVcalFile;
1744 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1763 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1745 if ( fn == "" ) 1764 if ( fn == "" )
1746 return; 1765 return;
1747 QFileInfo info; 1766 QFileInfo info;
1748 info.setFile( fn ); 1767 info.setFile( fn );
1749 QString mes; 1768 QString mes;
1750 bool createbup = true; 1769 bool createbup = true;
1751 if ( info. exists() ) { 1770 if ( info. exists() ) {
1752 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1771 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1753 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1772 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1754 i18n("Overwrite!"), i18n("Cancel"), 0, 1773 i18n("Overwrite!"), i18n("Cancel"), 0,
1755 0, 1 ); 1774 0, 1 );
1756 if ( result != 0 ) { 1775 if ( result != 0 ) {
1757 createbup = false; 1776 createbup = false;
1758 } 1777 }
1759 } 1778 }
1760 if ( createbup ) { 1779 if ( createbup ) {
1761 if ( mView->exportVCalendar( fn ) ) { 1780 if ( mView->exportVCalendar( fn ) ) {
1762 KOPrefs::instance()->mLastVcalFile = fn; 1781 KOPrefs::instance()->mLastVcalFile = fn;
1763 if ( fn.length() > 20 ) 1782 if ( fn.length() > 20 )
1764 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1783 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1765 else 1784 else
1766 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1785 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1767 setCaption(mes); 1786 setCaption(mes);
1768 } 1787 }
1769 } 1788 }
1770 1789
1771} 1790}
1772#include <qpushbutton.h> 1791#include <qpushbutton.h>
1773QString MainWindow::getPassword( ) 1792QString MainWindow::getPassword( )
1774{ 1793{
1775 QString retfile = ""; 1794 QString retfile = "";
1776 QDialog dia ( this, "input-dialog", true ); 1795 QDialog dia ( this, "input-dialog", true );
1777 QLineEdit lab ( &dia ); 1796 QLineEdit lab ( &dia );
1778 lab.setEchoMode( QLineEdit::Password ); 1797 lab.setEchoMode( QLineEdit::Password );
1779 QVBoxLayout lay( &dia ); 1798 QVBoxLayout lay( &dia );
1780 lay.setMargin(7); 1799 lay.setMargin(7);
1781 lay.setSpacing(7); 1800 lay.setSpacing(7);
1782 lay.addWidget( &lab); 1801 lay.addWidget( &lab);
1783 dia.setFixedSize( 230,50 ); 1802 dia.setFixedSize( 230,50 );
1784 dia.setCaption( i18n("Enter password") ); 1803 dia.setCaption( i18n("Enter password") );
1785 QPushButton pb ( "OK", &dia); 1804 QPushButton pb ( "OK", &dia);
1786 lay.addWidget( &pb ); 1805 lay.addWidget( &pb );
1787 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1806 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1788 dia.show(); 1807 dia.show();
1789 int res = dia.exec(); 1808 int res = dia.exec();
1790 if ( res ) 1809 if ( res )
1791 retfile = lab.text(); 1810 retfile = lab.text();
1792 dia.hide(); 1811 dia.hide();
1793 qApp->processEvents(); 1812 qApp->processEvents();
1794 return retfile; 1813 return retfile;
1795 1814
1796} 1815}
1797 1816
1798void MainWindow::syncLocalFile() 1817void MainWindow::syncLocalFile()
1799{ 1818{
1800 1819
1801 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1820 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1802 1821
1803 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1822 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1804 if ( fn == "" ) 1823 if ( fn == "" )
1805 return; 1824 return;
1806 //mView->setSyncDevice("local-file" ); 1825 //mView->setSyncDevice("local-file" );
1807 if ( syncWithFile( fn, false ) ) { 1826 if ( syncWithFile( fn, false ) ) {
1808 // Event* e = mView->getLastSyncEvent(); 1827 // Event* e = mView->getLastSyncEvent();
1809// e->setReadOnly( false ); 1828// e->setReadOnly( false );
1810// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1829// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1811// e->setReadOnly( true ); 1830// e->setReadOnly( true );
1812 } 1831 }
1813 1832
1814} 1833}
1815 1834
1816bool MainWindow::syncWithFile( QString fn , bool quick ) 1835bool MainWindow::syncWithFile( QString fn , bool quick )
1817{ 1836{
1818 bool ret = false; 1837 bool ret = false;
1819 QFileInfo info; 1838 QFileInfo info;
1820 info.setFile( fn ); 1839 info.setFile( fn );
1821 QString mess; 1840 QString mess;
1822 bool loadbup = true; 1841 bool loadbup = true;
1823 if ( !info. exists() ) { 1842 if ( !info. exists() ) {
1824 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1843 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1825 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1844 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1826 mess ); 1845 mess );
1827 return ret; 1846 return ret;
1828 } 1847 }
1829 int result = 0; 1848 int result = 0;
1830 if ( !quick ) { 1849 if ( !quick ) {
1831 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1850 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1832 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1851 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1833 mess, 1852 mess,
1834 i18n("Sync"), i18n("Cancel"), 0, 1853 i18n("Sync"), i18n("Cancel"), 0,
1835 0, 1 ); 1854 0, 1 );
1836 if ( result ) 1855 if ( result )
1837 return false; 1856 return false;
1838 } 1857 }
1839 if ( KOPrefs::instance()->mAskForPreferences ) 1858 if ( KOPrefs::instance()->mAskForPreferences )
1840 mView->edit_sync_options(); 1859 mView->edit_sync_options();
1841 if ( result == 0 ) { 1860 if ( result == 0 ) {
1842 //qDebug("Now sycing ... "); 1861 //qDebug("Now sycing ... ");
1843 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1862 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1844 setCaption( i18n("Synchronization successful") ); 1863 setCaption( i18n("Synchronization successful") );
1845 else 1864 else
1846 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1865 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1847 if ( ! quick ) 1866 if ( ! quick )
1848 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1867 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1849 slotModifiedChanged( true ); 1868 slotModifiedChanged( true );
1850 } 1869 }
1851 return ret; 1870 return ret;
1852} 1871}
1853void MainWindow::quickSyncLocalFile() 1872void MainWindow::quickSyncLocalFile()
1854{ 1873{
1855 //mView->setSyncDevice("local-file" ); 1874 //mView->setSyncDevice("local-file" );
1856 //qDebug("quickSyncLocalFile() "); 1875 //qDebug("quickSyncLocalFile() ");
1857 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1876 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1858 // Event* e = mView->getLastSyncEvent(); 1877 // Event* e = mView->getLastSyncEvent();
1859// e->setReadOnly( false ); 1878// e->setReadOnly( false );
1860// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1879// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1861// e->setReadOnly( true ); 1880// e->setReadOnly( true );
1862 1881
1863 } 1882 }
1864} 1883}
1865 1884
1866void MainWindow::confSync() 1885void MainWindow::confSync()
1867{ 1886{
1868 mView->confSync(); 1887 mView->confSync();
1869 fillSyncMenu(); 1888 fillSyncMenu();
1870 //mView->writeSettings(); 1889 //mView->writeSettings();
1871 1890
1872 1891
1873} 1892}
1874void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1893void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1875{ 1894{
1876 QString question; 1895 QString question;
1877 if ( ask ) { 1896 if ( ask ) {
1878 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1897 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1879 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1898 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1880 question, 1899 question,
1881 i18n("Yes"), i18n("No"), 1900 i18n("Yes"), i18n("No"),
1882 0, 0 ) != 0 ) 1901 0, 0 ) != 0 )
1883 return; 1902 return;
1884 } 1903 }
1885 QString command = prof->getPreSyncCommand(); 1904 QString command = prof->getPreSyncCommand();
1886 int fi; 1905 int fi;
1887 if ( (fi = command.find("$PWD$")) > 0 ) { 1906 if ( (fi = command.find("$PWD$")) > 0 ) {
1888 QString pwd = getPassword(); 1907 QString pwd = getPassword();
1889 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1908 command = command.left( fi )+ pwd + command.mid( fi+5 );
1890 1909
1891 } 1910 }
1892 int maxlen = 30; 1911 int maxlen = 30;
1893 if ( QApplication::desktop()->width() > 320 ) 1912 if ( QApplication::desktop()->width() > 320 )
1894 maxlen += 25; 1913 maxlen += 25;
1895 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1914 setCaption ( i18n( "Copy remote file to local machine..." ) );
1896 int fileSize = 0; 1915 int fileSize = 0;
1897 int result = system ( command ); 1916 int result = system ( command );
1898 // 0 : okay 1917 // 0 : okay
1899 // 256: no such file or dir 1918 // 256: no such file or dir
1900 // 1919 //
1901 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1920 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1902 if ( result != 0 ) { 1921 if ( result != 0 ) {
1903 int len = maxlen; 1922 int len = maxlen;
1904 while ( len < command.length() ) { 1923 while ( len < command.length() ) {
1905 command.insert( len , "\n" ); 1924 command.insert( len , "\n" );
1906 len += maxlen +2; 1925 len += maxlen +2;
1907 } 1926 }
1908 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 1927 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1909 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1928 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1910 question, 1929 question,
1911 i18n("Okay!")) ; 1930 i18n("Okay!")) ;
1912 setCaption ("KO/Pi"); 1931 setCaption ("KO/Pi");
1913 return; 1932 return;
1914 } 1933 }
1915 setCaption ( i18n( "Copying succeed." ) ); 1934 setCaption ( i18n( "Copying succeed." ) );
1916 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1935 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1917 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1936 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1918// Event* e = mView->getLastSyncEvent(); 1937// Event* e = mView->getLastSyncEvent();
1919// e->setReadOnly( false ); 1938// e->setReadOnly( false );
1920// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1939// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1921// e->setReadOnly( true ); 1940// e->setReadOnly( true );
1922 if ( KOPrefs::instance()->mWriteBackFile ) { 1941 if ( KOPrefs::instance()->mWriteBackFile ) {
1923 command = prof->getPostSyncCommand(); 1942 command = prof->getPostSyncCommand();
1924 setCaption ( i18n( "Writing back file ..." ) ); 1943 setCaption ( i18n( "Writing back file ..." ) );
1925 result = system ( command ); 1944 result = system ( command );
1926 qDebug("KO: Writing back file result: %d ", result); 1945 qDebug("KO: Writing back file result: %d ", result);
1927 if ( result != 0 ) { 1946 if ( result != 0 ) {
1928 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1947 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1929 return; 1948 return;
1930 } else { 1949 } else {
1931 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1950 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1932 } 1951 }
1933 } 1952 }
1934 } 1953 }
1935 return; 1954 return;
1936} 1955}
1937void MainWindow::syncSSH() 1956void MainWindow::syncSSH()
1938{ 1957{
1939 // not used anymore 1958 // not used anymore
1940 QTime timer; 1959 QTime timer;
1941 timer.start(); 1960 timer.start();
1942 //qDebug("MainWindow::syncssh() "); 1961 //qDebug("MainWindow::syncssh() ");
1943 KOPrefs *p = KOPrefs::instance(); 1962 KOPrefs *p = KOPrefs::instance();
1944 QString localFile = p->mLocalTempFile; 1963 QString localFile = p->mLocalTempFile;
1945 QString remoteIP = p->mRemoteIP; 1964 QString remoteIP = p->mRemoteIP;
1946 QString remoteUser = p->mRemoteUser; 1965 QString remoteUser = p->mRemoteUser;
1947 QString remoteFile = p->mRemoteFile; 1966 QString remoteFile = p->mRemoteFile;
1948 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 1967 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
1949 remoteUser += ":" + p->mRemotePassWd; 1968 remoteUser += ":" + p->mRemotePassWd;
1950 1969
1951 QString question = i18n("Do you really want\nto remote sync?\n \n") + 1970 QString question = i18n("Do you really want\nto remote sync?\n \n") +
1952 i18n("IP: " ) +remoteIP +"\n" + 1971 i18n("IP: " ) +remoteIP +"\n" +
1953 i18n("User: " ) + remoteUser +"\n" ; 1972 i18n("User: " ) + remoteUser +"\n" ;
1954 int maxlen = 30; 1973 int maxlen = 30;
1955 if ( QApplication::desktop()->width() > 320 ) 1974 if ( QApplication::desktop()->width() > 320 )
1956 maxlen += 25; 1975 maxlen += 25;
1957 if ( remoteFile.length() > maxlen ) 1976 if ( remoteFile.length() > maxlen )
1958 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 1977 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
1959 else 1978 else
1960 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 1979 question += i18n("Remote file:\n " ) + remoteFile +"\n";
1961 if ( localFile.length() > maxlen ) 1980 if ( localFile.length() > maxlen )
1962 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 1981 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
1963 else 1982 else
1964 question += i18n("Local temp file:\n " ) + localFile +"\n"; 1983 question += i18n("Local temp file:\n " ) + localFile +"\n";
1965 1984
1966 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1985 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1967 question, 1986 question,
1968 i18n("Yes"), i18n("No"), 1987 i18n("Yes"), i18n("No"),
1969 0, 0 ) != 0 ) 1988 0, 0 ) != 0 )
1970 return; 1989 return;
1971 // if ( !p->mUsePassWd ) { 1990 // if ( !p->mUsePassWd ) {
1972 // QString pass = getPassword(); 1991 // QString pass = getPassword();
1973 // if ( pass.length() > 0 ) 1992 // if ( pass.length() > 0 )
1974 // remoteUser += ":" + pass; 1993 // remoteUser += ":" + pass;
1975 // } 1994 // }
1976 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 1995 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
1977 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1996 setCaption ( i18n( "Copy remote file to local machine..." ) );
1978 int fileSize = 0; 1997 int fileSize = 0;
1979 int result = system ( command ); 1998 int result = system ( command );
1980 // 0 : okay 1999 // 0 : okay
1981 // 256: no such file or dir 2000 // 256: no such file or dir
1982 // 2001 //
1983 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2002 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1984 if ( result != 0 ) { 2003 if ( result != 0 ) {
1985 int len = maxlen; 2004 int len = maxlen;
1986 while ( len < command.length() ) { 2005 while ( len < command.length() ) {
1987 command.insert( len , "\n" ); 2006 command.insert( len , "\n" );
1988 len += maxlen +2; 2007 len += maxlen +2;
1989 } 2008 }
1990 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2009 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1991 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2010 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1992 question, 2011 question,
1993 i18n("Okay!")) ; 2012 i18n("Okay!")) ;
1994 setCaption ("KO/Pi"); 2013 setCaption ("KO/Pi");
1995 return; 2014 return;
1996 } 2015 }
1997 2016
1998 2017
1999 setCaption ( i18n( "Copying succeed." ) ); 2018 setCaption ( i18n( "Copying succeed." ) );
2000 //mView->setSyncDevice("ssh-scp" ); 2019 //mView->setSyncDevice("ssh-scp" );
2001 if ( syncWithFile(localFile , true ) ) { 2020 if ( syncWithFile(localFile , true ) ) {
2002// Event* e = mView->getLastSyncEvent(); 2021// Event* e = mView->getLastSyncEvent();
2003// e->setReadOnly( false ); 2022// e->setReadOnly( false );
2004// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2023// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2005// e->setReadOnly( true ); 2024// e->setReadOnly( true );
2006 if ( KOPrefs::instance()->mWriteBackFile ) { 2025 if ( KOPrefs::instance()->mWriteBackFile ) {
2007 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2026 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2008 setCaption ( i18n( "Writing back file ..." ) ); 2027 setCaption ( i18n( "Writing back file ..." ) );
2009 result = system ( command ); 2028 result = system ( command );
2010 if ( result != 0 ) { 2029 if ( result != 0 ) {
2011 int len = maxlen; 2030 int len = maxlen;
2012 while ( len < command.length() ) { 2031 while ( len < command.length() ) {
2013 command.insert( len , "\n" ); 2032 command.insert( len , "\n" );
2014 len += maxlen +2; 2033 len += maxlen +2;
2015 } 2034 }
2016 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2035 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2017 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2036 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2018 question, 2037 question,
2019 i18n("Okay!")) ; 2038 i18n("Okay!")) ;
2020 setCaption ("KO/Pi"); 2039 setCaption ("KO/Pi");
2021 return; 2040 return;
2022 } else { 2041 } else {
2023 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2042 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2024 } 2043 }
2025 } 2044 }
2026 } 2045 }
2027 return; 2046 return;
2028#if 0 2047#if 0
2029 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2048 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2030 while ( timer.elapsed() < 5000 ) 2049 while ( timer.elapsed() < 5000 )
2031 qApp->processEvents(); 2050 qApp->processEvents();
2032 2051
2033 qDebug("MainWindow::merging) "); 2052 qDebug("MainWindow::merging) ");
2034 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2053 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2035 while ( mBlockSaveFlag ) 2054 while ( mBlockSaveFlag )
2036 qApp->processEvents(); 2055 qApp->processEvents();
2037 save(); 2056 save();
2038 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2057 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2039#endif 2058#endif
2040 2059
2041} 2060}
2042 2061
2043 2062
2044void MainWindow::syncSharp() 2063void MainWindow::syncSharp()
2045{ 2064{
2046 if ( mCalendarModifiedFlag ) 2065 if ( mCalendarModifiedFlag )
2047 save(); 2066 save();
2048 mView->syncSharp(); 2067 mView->syncSharp();
2049 slotModifiedChanged( true ); 2068 slotModifiedChanged( true );
2050 2069
2051} 2070}
2052void MainWindow::syncPhone() 2071void MainWindow::syncPhone()
2053{ 2072{
2054 if ( mCalendarModifiedFlag ) 2073 if ( mCalendarModifiedFlag )
2055 save(); 2074 save();
2056 mView->syncPhone(); 2075 mView->syncPhone();
2057 slotModifiedChanged( true ); 2076 slotModifiedChanged( true );
2058 2077
2059} 2078}
2060 2079
2061void MainWindow::printSel( ) 2080void MainWindow::printSel( )
2062{ 2081{
2063 mView->viewManager()->agendaView()->agenda()->printSelection(); 2082 mView->viewManager()->agendaView()->agenda()->printSelection();
2064} 2083}
2065 2084
2066void MainWindow::printCal() 2085void MainWindow::printCal()
2067{ 2086{
2068 mView->print();//mCp->showDialog(); 2087 mView->print();//mCp->showDialog();
2069} 2088}
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 11c68c5..e6d4879 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,1308 +1,1266 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qxml.h> 32#include <qxml.h>
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38 38
39#include "calendar.h" 39#include "calendar.h"
40#include "alarm.h" 40#include "alarm.h"
41#include "recurrence.h" 41#include "recurrence.h"
42#include "calendarlocal.h" 42#include "calendarlocal.h"
43 43
44#include "phoneformat.h" 44#include "phoneformat.h"
45#include "syncdefines.h" 45#include "syncdefines.h"
46 46
47using namespace KCal; 47using namespace KCal;
48 48
49class PhoneParser : public QObject 49class PhoneParser : public QObject
50{ 50{
51public: 51public:
52 PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { 52 PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) {
53 ; 53 ;
54 } 54 }
55 bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) 55 bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s)
56 { 56 {
57 57
58 int id = ToDo->Location; 58 int id = ToDo->Location;
59 Todo *todo; 59 Todo *todo;
60 todo = existingCalendar->todo( mProfileName ,QString::number( id ) ); 60 todo = existingCalendar->todo( mProfileName ,QString::number( id ) );
61 if (todo ) 61 if (todo )
62 todo = (Todo *)todo->clone(); 62 todo = (Todo *)todo->clone();
63 else 63 else
64 todo = new Todo; 64 todo = new Todo;
65 todo->setID( mProfileName,QString::number( id ) ); 65 todo->setID( mProfileName,QString::number( id ) );
66 todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 66 todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
67 int priority; 67 int priority;
68 switch (ToDo->Priority) { 68 switch (ToDo->Priority) {
69 case GSM_Priority_Low : priority = 1; break; 69 case GSM_Priority_Low : priority = 1; break;
70 case GSM_Priority_Medium : priority = 3; break; 70 case GSM_Priority_Medium : priority = 3; break;
71 case GSM_Priority_High : priority = 5; break; 71 case GSM_Priority_High : priority = 5; break;
72 default :priority = 3 ;break; 72 default :priority = 3 ;break;
73 } 73 }
74 todo->setPriority( priority ); 74 todo->setPriority( priority );
75 GSM_Phone_Functions*Phone; 75 GSM_Phone_Functions*Phone;
76 Phone=s->Phone.Functions; 76 Phone=s->Phone.Functions;
77 int j; 77 int j;
78 GSM_DateTime* dtp; 78 GSM_DateTime* dtp;
79 bool alarm = false; 79 bool alarm = false;
80 QDateTime alarmDt; 80 QDateTime alarmDt;
81 GSM_Category Category; 81 GSM_Category Category;
82 int error; 82 int error;
83 for (j=0;j<ToDo->EntriesNum;j++) { 83 for (j=0;j<ToDo->EntriesNum;j++) {
84 84
85 //qDebug(" for todo %d",ToDo->Location ); 85 //qDebug(" for todo %d",ToDo->Location );
86 switch (ToDo->Entries[j].EntryType) { 86 switch (ToDo->Entries[j].EntryType) {
87 case TODO_END_DATETIME: 87 case TODO_END_DATETIME:
88 dtp = &ToDo->Entries[j].Date ; 88 dtp = &ToDo->Entries[j].Date ;
89 todo->setDtDue (fromGSM ( dtp )); 89 todo->setDtDue (fromGSM ( dtp ));
90 break; 90 break;
91 case TODO_COMPLETED: 91 case TODO_COMPLETED:
92 if ( ToDo->Entries[j].Number == 1 ) { 92 if ( ToDo->Entries[j].Number == 1 ) {
93 todo->setCompleted( true ); 93 todo->setCompleted( true );
94 } 94 }
95 else { 95 else {
96 todo->setCompleted( false ); 96 todo->setCompleted( false );
97 } 97 }
98 break; 98 break;
99 case TODO_ALARM_DATETIME: 99 case TODO_ALARM_DATETIME:
100 dtp = &ToDo->Entries[j].Date ; 100 dtp = &ToDo->Entries[j].Date ;
101 alarm = true; 101 alarm = true;
102 alarmDt = fromGSM ( dtp ); 102 alarmDt = fromGSM ( dtp );
103 break; 103 break;
104 case TODO_SILENT_ALARM_DATETIME: 104 case TODO_SILENT_ALARM_DATETIME:
105 dtp = &ToDo->Entries[j].Date ; 105 dtp = &ToDo->Entries[j].Date ;
106 alarm = true; 106 alarm = true;
107 alarmDt = fromGSM ( dtp ); 107 alarmDt = fromGSM ( dtp );
108 break; 108 break;
109 case TODO_TEXT: 109 case TODO_TEXT:
110 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); 110 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text ));
111 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); 111 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text )));
112 break; 112 break;
113 case TODO_PRIVATE: 113 case TODO_PRIVATE:
114 if ( ToDo->Entries[j].Number == 1 ) 114 if ( ToDo->Entries[j].Number == 1 )
115 todo->setSecrecy( Incidence::SecrecyPrivate ); 115 todo->setSecrecy( Incidence::SecrecyPrivate );
116 else 116 else
117 todo->setSecrecy( Incidence::SecrecyPublic ); 117 todo->setSecrecy( Incidence::SecrecyPublic );
118 break; 118 break;
119 case TODO_CATEGORY: 119 case TODO_CATEGORY:
120 Category.Location = ToDo->Entries[j].Number; 120 Category.Location = ToDo->Entries[j].Number;
121 Category.Type = Category_ToDo; 121 Category.Type = Category_ToDo;
122 error=Phone->GetCategory(s, &Category); 122 error=Phone->GetCategory(s, &Category);
123 if (error == ERR_NONE) { 123 if (error == ERR_NONE) {
124 QStringList cat = todo->categories(); 124 QStringList cat = todo->categories();
125 QString nCat = QString ( (const char*)Category.Name ); 125 QString nCat = QString ( (const char*)Category.Name );
126 if ( !nCat.isEmpty() ) 126 if ( !nCat.isEmpty() )
127 if ( !cat.contains( nCat )) { 127 if ( !cat.contains( nCat )) {
128 cat << nCat; 128 cat << nCat;
129 todo->setCategories( cat ); 129 todo->setCategories( cat );
130 } 130 }
131 } 131 }
132 break; 132 break;
133 case TODO_CONTACTID: 133 case TODO_CONTACTID:
134#if 0 134#if 0
135 // not supported 135 // not supported
136 entry.Location = ToDo->Entries[j].Number; 136 entry.Location = ToDo->Entries[j].Number;
137 entry.MemoryType = MEM_ME; 137 entry.MemoryType = MEM_ME;
138 error=Phone->GetMemory(s, &entry); 138 error=Phone->GetMemory(s, &entry);
139 if (error == ERR_NONE) { 139 if (error == ERR_NONE) {
140 name = GSM_PhonebookGetEntryName(&entry); 140 name = GSM_PhonebookGetEntryName(&entry);
141 if (name != NULL) { 141 if (name != NULL) {
142 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 142 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
143 } else { 143 } else {
144 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 144 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
145 } 145 }
146 } else { 146 } else {
147 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 147 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
148 } 148 }
149#endif 149#endif
150 break; 150 break;
151 case TODO_PHONE: 151 case TODO_PHONE:
152#if 0 152#if 0
153 // not supported 153 // not supported
154 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 154 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
155#endif 155#endif
156 break; 156 break;
157 } 157 }
158 } 158 }
159 QString alarmString = "na"; 159 QString alarmString = "na";
160 if ( alarm ) { 160 if ( alarm ) {
161 Alarm *alarm; 161 Alarm *alarm;
162 if ( todo->alarms().count() > 0 ) 162 if ( todo->alarms().count() > 0 )
163 alarm = todo->alarms().first(); 163 alarm = todo->alarms().first();
164 else { 164 else {
165 alarm = new Alarm( todo ); 165 alarm = new Alarm( todo );
166 todo->addAlarm( alarm ); 166 todo->addAlarm( alarm );
167 } 167 }
168 alarm->setType( Alarm::Audio ); 168 alarm->setType( Alarm::Audio );
169 alarm->setEnabled( true ); 169 alarm->setEnabled( true );
170 int alarmOffset = alarmDt.secsTo( todo->dtStart() ); 170 int alarmOffset = alarmDt.secsTo( todo->dtStart() );
171 alarm->setStartOffset( -alarmOffset ); 171 alarm->setStartOffset( -alarmOffset );
172 alarmString = QString::number( alarmOffset ); 172 alarmString = QString::number( alarmOffset );
173 } else { 173 } else {
174 Alarm *alarm; 174 Alarm *alarm;
175 if ( todo->alarms().count() > 0 ) { 175 if ( todo->alarms().count() > 0 ) {
176 alarm = todo->alarms().first(); 176 alarm = todo->alarms().first();
177 alarm->setType( Alarm::Audio ); 177 alarm->setType( Alarm::Audio );
178 alarm->setStartOffset( -60*15 ); 178 alarm->setStartOffset( -60*15 );
179 alarm->setEnabled( false ); 179 alarm->setEnabled( false );
180 } 180 }
181 } 181 }
182 // csum ***************************************** 182 // csum *****************************************
183 uint cSum; 183 uint cSum;
184 cSum = PhoneFormat::getCsumTodo( todo ); 184 cSum = PhoneFormat::getCsumTodo( todo );
185 todo->setCsum( mProfileName, QString::number( cSum )); 185 todo->setCsum( mProfileName, QString::number( cSum ));
186 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 186 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
187 mCalendar->addTodo( todo); 187 mCalendar->addTodo( todo);
188 188
189 return true; 189 return true;
190 } 190 }
191 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) 191 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note)
192 { 192 {
193 193
194 int id = Note->Location; 194 int id = Note->Location;
195 Event *event; 195 Event *event;
196 event = existingCalendar->event( mProfileName ,QString::number( id ) ); 196 event = existingCalendar->event( mProfileName ,QString::number( id ) );
197 if ( event ) 197 if ( event )
198 event = (Event*)event->clone(); 198 event = (Event*)event->clone();
199 else 199 else
200 event = new Event; 200 event = new Event;
201 event->setID( mProfileName,QString::number( id ) ); 201 event->setID( mProfileName,QString::number( id ) );
202 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 202 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
203 203
204 204
205 int i = 0; 205 int i = 0;
206 bool repeating = false; 206 bool repeating = false;
207 int repeat_dayofweek = -1; 207 int repeat_dayofweek = -1;
208 int repeat_day = -1; 208 int repeat_day = -1;
209 int repeat_weekofmonth = -1; 209 int repeat_weekofmonth = -1;
210 int repeat_month = -1; 210 int repeat_month = -1;
211 int repeat_frequency = -1; 211 int repeat_frequency = -1;
212 int rec_type = -1; 212 int rec_type = -1;
213 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 213 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
214 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 214 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
215 GSM_DateTime* dtp; 215 GSM_DateTime* dtp;
216 bool alarm = false; 216 bool alarm = false;
217 QDateTime alarmDt; 217 QDateTime alarmDt;
218 repeat_startdate.Day= 0; 218 repeat_startdate.Day= 0;
219 repeat_stopdate.Day = 0; 219 repeat_stopdate.Day = 0;
220 for (i=0;i<Note->EntriesNum;i++) { 220 for (i=0;i<Note->EntriesNum;i++) {
221 221
222 //qDebug(" for ev"); 222 //qDebug(" for ev");
223 switch (Note->Entries[i].EntryType) { 223 switch (Note->Entries[i].EntryType) {
224 case CAL_START_DATETIME: 224 case CAL_START_DATETIME:
225 dtp = &Note->Entries[i].Date ; 225 dtp = &Note->Entries[i].Date ;
226 if ( dtp->Hour > 24 ) { 226 if ( dtp->Hour > 24 ) {
227 event->setFloats( true ); 227 event->setFloats( true );
228 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 228 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
229 } else { 229 } else {
230 event->setDtStart (fromGSM ( dtp )); 230 event->setDtStart (fromGSM ( dtp ));
231 231
232 } 232 }
233 break; 233 break;
234 case CAL_END_DATETIME: 234 case CAL_END_DATETIME:
235 dtp = &Note->Entries[i].Date ; 235 dtp = &Note->Entries[i].Date ;
236 if ( dtp->Hour > 24 ) { 236 if ( dtp->Hour > 24 ) {
237 event->setFloats( true ); 237 event->setFloats( true );
238 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 238 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
239 } else { 239 } else {
240 event->setDtEnd (fromGSM ( dtp )); 240 event->setDtEnd (fromGSM ( dtp ));
241 } 241 }
242 break; 242 break;
243 case CAL_ALARM_DATETIME: 243 case CAL_ALARM_DATETIME:
244 dtp = &Note->Entries[i].Date ; 244 dtp = &Note->Entries[i].Date ;
245 alarm = true; 245 alarm = true;
246 alarmDt = fromGSM ( dtp ); 246 alarmDt = fromGSM ( dtp );
247 break; 247 break;
248 case CAL_SILENT_ALARM_DATETIME: 248 case CAL_SILENT_ALARM_DATETIME:
249 dtp = &Note->Entries[i].Date ; 249 dtp = &Note->Entries[i].Date ;
250 alarm = true; 250 alarm = true;
251 alarmDt = fromGSM ( dtp ); 251 alarmDt = fromGSM ( dtp );
252 break; 252 break;
253 case CAL_RECURRANCE: 253 case CAL_RECURRANCE:
254 rec_type = Note->Entries[i].Number; 254 rec_type = Note->Entries[i].Number;
255 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); 255 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
256 break; 256 break;
257 case CAL_TEXT: 257 case CAL_TEXT:
258 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); 258 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) );
259 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); 259 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text )));
260 break; 260 break;
261 case CAL_LOCATION: 261 case CAL_LOCATION:
262 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); 262 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) ));
263 break; 263 break;
264 case CAL_PHONE: 264 case CAL_PHONE:
265 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 265 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
266 break; 266 break;
267 case CAL_PRIVATE: 267 case CAL_PRIVATE:
268 if ( Note->Entries[i].Number == 1 ) 268 if ( Note->Entries[i].Number == 1 )
269 event->setSecrecy( Incidence::SecrecyPrivate ); 269 event->setSecrecy( Incidence::SecrecyPrivate );
270 else 270 else
271 event->setSecrecy( Incidence::SecrecyPublic ); 271 event->setSecrecy( Incidence::SecrecyPublic );
272 272
273 break; 273 break;
274 case CAL_CONTACTID: 274 case CAL_CONTACTID:
275#if 0 275#if 0
276 entry.Location = Note->Entries[i].Number; 276 entry.Location = Note->Entries[i].Number;
277 entry.MemoryType = MEM_ME; 277 entry.MemoryType = MEM_ME;
278 error=Phone->GetMemory(&s, &entry); 278 error=Phone->GetMemory(&s, &entry);
279 if (error == ERR_NONE) { 279 if (error == ERR_NONE) {
280 name = GSM_PhonebookGetEntryName(&entry); 280 name = GSM_PhonebookGetEntryName(&entry);
281 if (name != NULL) { 281 if (name != NULL) {
282 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); 282 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
283 } else { 283 } else {
284 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 284 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
285 } 285 }
286 } else { 286 } else {
287 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 287 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
288 } 288 }
289#endif 289#endif
290 break; 290 break;
291 case CAL_REPEAT_DAYOFWEEK: 291 case CAL_REPEAT_DAYOFWEEK:
292 repeat_dayofweek = Note->Entries[i].Number; 292 repeat_dayofweek = Note->Entries[i].Number;
293 repeating = true; 293 repeating = true;
294 break; 294 break;
295 case CAL_REPEAT_DAY: 295 case CAL_REPEAT_DAY:
296 repeat_day = Note->Entries[i].Number; 296 repeat_day = Note->Entries[i].Number;
297 repeating = true; 297 repeating = true;
298 break; 298 break;
299 case CAL_REPEAT_WEEKOFMONTH: 299 case CAL_REPEAT_WEEKOFMONTH:
300 repeat_weekofmonth = Note->Entries[i].Number; 300 repeat_weekofmonth = Note->Entries[i].Number;
301 repeating = true; 301 repeating = true;
302 break; 302 break;
303 case CAL_REPEAT_MONTH: 303 case CAL_REPEAT_MONTH:
304 repeat_month = Note->Entries[i].Number; 304 repeat_month = Note->Entries[i].Number;
305 repeating = true; 305 repeating = true;
306 break; 306 break;
307 case CAL_REPEAT_FREQUENCY: 307 case CAL_REPEAT_FREQUENCY:
308 repeat_frequency = Note->Entries[i].Number; 308 repeat_frequency = Note->Entries[i].Number;
309 repeating = true; 309 repeating = true;
310 break; 310 break;
311 case CAL_REPEAT_STARTDATE: 311 case CAL_REPEAT_STARTDATE:
312 repeat_startdate = Note->Entries[i].Date; 312 repeat_startdate = Note->Entries[i].Date;
313 repeating = true; 313 repeating = true;
314 break; 314 break;
315 case CAL_REPEAT_STOPDATE: 315 case CAL_REPEAT_STOPDATE:
316 repeat_stopdate = Note->Entries[i].Date; 316 repeat_stopdate = Note->Entries[i].Date;
317 repeating = true; 317 repeating = true;
318 break; 318 break;
319 } 319 }
320 } 320 }
321#if 0 321#if 0
322 event->setDescription( attList[4] ); 322 event->setDescription( attList[4] );
323 bool repeating = false; 323 bool repeating = false;
324 int repeat_dayofweek = -1; 324 int repeat_dayofweek = -1;
325 int repeat_day = -1; 325 int repeat_day = -1;
326 int repeat_weekofmonth = -1; 326 int repeat_weekofmonth = -1;
327 int repeat_month = -1; 327 int repeat_month = -1;
328 int repeat_frequency = -1; 328 int repeat_frequency = -1;
329 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 329 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
330 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 330 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
331 331
332#endif 332#endif
333 333
334 QString recurString = "no"; 334 QString recurString = "no";
335 if ( repeating && repeat_frequency != -1) { 335 if ( repeating && repeat_frequency != -1) {
336 recurString = "y"; 336 recurString = "y";
337 if ( repeat_dayofweek >= 0 ) 337 if ( repeat_dayofweek >= 0 )
338 recurString += "dow" + QString::number (repeat_dayofweek); 338 recurString += "dow" + QString::number (repeat_dayofweek);
339 if ( repeat_day >= 0 ) 339 if ( repeat_day >= 0 )
340 recurString += "d" + QString::number (repeat_day); 340 recurString += "d" + QString::number (repeat_day);
341 if ( repeat_weekofmonth >= 0 ) 341 if ( repeat_weekofmonth >= 0 )
342 recurString += "w" + QString::number (repeat_weekofmonth); 342 recurString += "w" + QString::number (repeat_weekofmonth);
343 if ( repeat_month >= 0 ) 343 if ( repeat_month >= 0 )
344 recurString += "m" + QString::number ( repeat_month ); 344 recurString += "m" + QString::number ( repeat_month );
345 if ( repeat_frequency >= 0 ) 345 if ( repeat_frequency >= 0 )
346 recurString += "f" + QString::number (repeat_frequency ); 346 recurString += "f" + QString::number (repeat_frequency );
347 347
348 int rtype = 0; 348 int rtype = 0;
349 // qDebug("recurs "); 349 // qDebug("recurs ");
350 QDate startDate, endDate; 350 QDate startDate, endDate;
351 if ( repeat_startdate.Day > 0 ) { 351 if ( repeat_startdate.Day > 0 ) {
352 startDate = datefromGSM ( &repeat_startdate ); 352 startDate = datefromGSM ( &repeat_startdate );
353 event->setDtStart(QDateTime ( startDate, event->dtStart().time())); 353 event->setDtStart(QDateTime ( startDate, event->dtStart().time()));
354 } else { 354 } else {
355 startDate = event->dtStart().date(); 355 startDate = event->dtStart().date();
356 } 356 }
357 int freq = repeat_frequency; 357 int freq = repeat_frequency;
358 bool hasEndDate = false; 358 bool hasEndDate = false;
359 if ( repeat_stopdate.Day > 0 ) { 359 if ( repeat_stopdate.Day > 0 ) {
360 endDate = datefromGSM ( &repeat_stopdate ); 360 endDate = datefromGSM ( &repeat_stopdate );
361 hasEndDate = true; 361 hasEndDate = true;
362 } 362 }
363 363
364 uint weekDaysNum = repeat_dayofweek ; 364 uint weekDaysNum = repeat_dayofweek ;
365 // 1 == monday, 7 == sunday 365 // 1 == monday, 7 == sunday
366 QBitArray weekDays( 7 ); 366 QBitArray weekDays( 7 );
367 int i; 367 int i;
368 int bb = 1; 368 int bb = 1;
369 for( i = 1; i <= 7; ++i ) { 369 for( i = 1; i <= 7; ++i ) {
370 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 370 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
371 bb = 2 << (i-1); 371 bb = 2 << (i-1);
372 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 372 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
373 } 373 }
374 // qDebug("next "); 374 // qDebug("next ");
375 int pos = 0; 375 int pos = 0;
376 Recurrence *r = event->recurrence(); 376 Recurrence *r = event->recurrence();
377 /* 377 /*
378 0 daily; 378 0 daily;
379 1 weekly;x 379 1 weekly;x
380 2 monthpos;x 380 2 monthpos;x
381 3 monthlyday; 381 3 monthlyday;
382 4 rYearlyMont 382 4 rYearlyMont
383 bool repeating = false; 383 bool repeating = false;
384 int repeat_dayofweek = -1; 384 int repeat_dayofweek = -1;
385 int repeat_day = -1; 385 int repeat_day = -1;
386 int repeat_weekofmonth = -1; 386 int repeat_weekofmonth = -1;
387 int repeat_month = -1; 387 int repeat_month = -1;
388 int repeat_frequency = -1; 388 int repeat_frequency = -1;
389 */ 389 */
390 int dayOfWeek = startDate.dayOfWeek(); 390 int dayOfWeek = startDate.dayOfWeek();
391 if ( repeat_weekofmonth >= 0 ) { 391 if ( repeat_weekofmonth >= 0 ) {
392 rtype = 2; // ************************ 2 MonthlyPos 392 rtype = 2; // ************************ 2 MonthlyPos
393 pos = repeat_weekofmonth; 393 pos = repeat_weekofmonth;
394 if ( repeat_dayofweek >= 0 ) 394 if ( repeat_dayofweek >= 0 )
395 dayOfWeek = repeat_dayofweek; 395 dayOfWeek = repeat_dayofweek;
396 if (repeat_month > 0) { 396 if (repeat_month > 0) {
397 if ( repeat_month != event->dtStart().date().month() ) { 397 if ( repeat_month != event->dtStart().date().month() ) {
398 QDate date (event->dtStart().date().year(),repeat_month,event->dtStart().date().day() ); 398 QDate date (event->dtStart().date().year(),repeat_month,event->dtStart().date().day() );
399 event->setDtStart(QDateTime ( date , event->dtStart().time()) ); 399 event->setDtStart(QDateTime ( date , event->dtStart().time()) );
400 } 400 }
401 if ( freq == 1 ) 401 if ( freq == 1 )
402 freq = 12; 402 freq = 12;
403 } 403 }
404 } else if ( repeat_dayofweek >= 0 ) { 404 } else if ( repeat_dayofweek >= 0 ) {
405 rtype = 1;// ************************ 1 Weekly 405 rtype = 1;// ************************ 1 Weekly
406 } else if ( repeat_day >= 0 ) { 406 } else if ( repeat_day >= 0 ) {
407 if ( repeat_month > 0) { 407 if ( repeat_month > 0) {
408 rtype = 4; 408 rtype = 4;
409 } else { 409 } else {
410 rtype = 3; 410 rtype = 3;
411 } 411 }
412 } else { 412 } else {
413 rtype = 0 ; 413 rtype = 0 ;
414 } 414 }
415 415
416 if ( rtype == 0 ) { 416 if ( rtype == 0 ) {
417 if ( hasEndDate ) r->setDaily( freq, endDate ); 417 if ( hasEndDate ) r->setDaily( freq, endDate );
418 else r->setDaily( freq, -1 ); 418 else r->setDaily( freq, -1 );
419 } else if ( rtype == 1 ) { 419 } else if ( rtype == 1 ) {
420 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 420 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
421 else r->setWeekly( freq, weekDays, -1 ); 421 else r->setWeekly( freq, weekDays, -1 );
422 } else if ( rtype == 3 ) { 422 } else if ( rtype == 3 ) {
423 if ( hasEndDate ) 423 if ( hasEndDate )
424 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 424 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
425 else 425 else
426 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 426 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
427 r->addMonthlyDay( startDate.day() ); 427 r->addMonthlyDay( startDate.day() );
428 } else if ( rtype == 2 ) { 428 } else if ( rtype == 2 ) {
429 if ( hasEndDate ) 429 if ( hasEndDate )
430 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 430 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
431 else 431 else
432 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 432 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
433 QBitArray days( 7 ); 433 QBitArray days( 7 );
434 days.fill( false ); 434 days.fill( false );
435 days.setBit( dayOfWeek - 1 ); 435 days.setBit( dayOfWeek - 1 );
436 r->addMonthlyPos( pos, days ); 436 r->addMonthlyPos( pos, days );
437 } else if ( rtype == 4 ) { 437 } else if ( rtype == 4 ) {
438 if ( hasEndDate ) 438 if ( hasEndDate )
439 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 439 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
440 else 440 else
441 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 441 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
442 r->addYearlyNum( startDate.month() ); 442 r->addYearlyNum( startDate.month() );
443 } 443 }
444 } else { 444 } else {
445 event->recurrence()->unsetRecurs(); 445 event->recurrence()->unsetRecurs();
446 } 446 }
447 447
448 QStringList categoryList; 448 QStringList categoryList;
449 categoryList << getCategory( Note ); 449 categoryList << getCategory( Note );
450 event->setCategories( categoryList ); 450 event->setCategories( categoryList );
451 // strange 0 semms to mean: alarm enabled 451 // strange 0 semms to mean: alarm enabled
452 if ( alarm ) { 452 if ( alarm ) {
453 Alarm *alarm; 453 Alarm *alarm;
454 if ( event->alarms().count() > 0 ) 454 if ( event->alarms().count() > 0 )
455 alarm = event->alarms().first(); 455 alarm = event->alarms().first();
456 else { 456 else {
457 alarm = new Alarm( event ); 457 alarm = new Alarm( event );
458 event->addAlarm( alarm ); 458 event->addAlarm( alarm );
459 } 459 }
460 alarm->setType( Alarm::Audio ); 460 alarm->setType( Alarm::Audio );
461 alarm->setEnabled( true ); 461 alarm->setEnabled( true );
462 int alarmOffset = alarmDt.secsTo( event->dtStart() ); 462 int alarmOffset = alarmDt.secsTo( event->dtStart() );
463 alarm->setStartOffset( -alarmOffset ); 463 alarm->setStartOffset( -alarmOffset );
464 } else { 464 } else {
465 Alarm *alarm; 465 Alarm *alarm;
466 if ( event->alarms().count() > 0 ) { 466 if ( event->alarms().count() > 0 ) {
467 alarm = event->alarms().first(); 467 alarm = event->alarms().first();
468 alarm->setType( Alarm::Audio ); 468 alarm->setType( Alarm::Audio );
469 alarm->setStartOffset( -60*15 ); 469 alarm->setStartOffset( -60*15 );
470 alarm->setEnabled( false ); 470 alarm->setEnabled( false );
471 } 471 }
472 } 472 }
473 // csum ***************************************** 473 // csum *****************************************
474 474
475 uint cSum; 475 uint cSum;
476 cSum = PhoneFormat::getCsumEvent( event ); 476 cSum = PhoneFormat::getCsumEvent( event );
477 event->setCsum( mProfileName, QString::number( cSum )); 477 event->setCsum( mProfileName, QString::number( cSum ));
478 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 478 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
479 mCalendar->addEvent( event); 479 mCalendar->addEvent( event);
480 480
481 return true; 481 return true;
482 } 482 }
483 483
484 484
485 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { 485 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) {
486 QDateTime dt; 486 QDateTime dt;
487 int y,m,t,h,min,sec; 487 int y,m,t,h,min,sec;
488 y = dtp->Year; 488 y = dtp->Year;
489 m = dtp->Month; 489 m = dtp->Month;
490 t = dtp->Day; 490 t = dtp->Day;
491 h = dtp->Hour; 491 h = dtp->Hour;
492 min = dtp->Minute; 492 min = dtp->Minute;
493 sec = dtp->Second; 493 sec = dtp->Second;
494 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 494 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
495 // dtp->Timezone: offset in hours 495 // dtp->Timezone: offset in hours
496 int offset = KGlobal::locale()->localTimeOffset( dt ); 496 int offset = KGlobal::locale()->localTimeOffset( dt );
497 if ( useTz ) 497 if ( useTz )
498 dt = dt.addSecs ( offset*60); 498 dt = dt.addSecs ( offset*60);
499 return dt; 499 return dt;
500 500
501 } 501 }
502 502
503 static QString dtToString( const QDateTime& dti, bool useTZ = false ) 503 static QString dtToString( const QDateTime& dti, bool useTZ = false )
504 { 504 {
505 QString datestr; 505 QString datestr;
506 QString timestr; 506 QString timestr;
507 int offset = KGlobal::locale()->localTimeOffset( dti ); 507 int offset = KGlobal::locale()->localTimeOffset( dti );
508 QDateTime dt; 508 QDateTime dt;
509 if (useTZ) 509 if (useTZ)
510 dt = dti.addSecs ( -(offset*60)); 510 dt = dti.addSecs ( -(offset*60));
511 else 511 else
512 dt = dti; 512 dt = dti;
513 if(dt.date().isValid()){ 513 if(dt.date().isValid()){
514 const QDate& date = dt.date(); 514 const QDate& date = dt.date();
515 datestr.sprintf("%04d%02d%02d", 515 datestr.sprintf("%04d%02d%02d",
516 date.year(), date.month(), date.day()); 516 date.year(), date.month(), date.day());
517 } 517 }
518 if(dt.time().isValid()){ 518 if(dt.time().isValid()){
519 const QTime& time = dt.time(); 519 const QTime& time = dt.time();
520 timestr.sprintf("T%02d%02d%02d", 520 timestr.sprintf("T%02d%02d%02d",
521 time.hour(), time.minute(), time.second()); 521 time.hour(), time.minute(), time.second());
522 } 522 }
523 return datestr + timestr; 523 return datestr + timestr;
524 } 524 }
525 QDate datefromGSM ( GSM_DateTime*dtp ) { 525 QDate datefromGSM ( GSM_DateTime*dtp ) {
526 return QDate ( dtp->Year, dtp->Month, dtp->Day ); 526 return QDate ( dtp->Year, dtp->Month, dtp->Day );
527 } 527 }
528 QString getCategory( GSM_CalendarEntry*Note) 528 QString getCategory( GSM_CalendarEntry*Note)
529 { 529 {
530 QString CATEGORY; 530 QString CATEGORY;
531 switch (Note->Type) { 531 switch (Note->Type) {
532 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; 532 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break;
533 case GSM_CAL_CALL : CATEGORY = QString("Call"); break; 533 case GSM_CAL_CALL : CATEGORY = QString("Call"); break;
534 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; 534 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break;
535 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; 535 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break;
536 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; 536 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break;
537 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; 537 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break;
538 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; 538 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
539 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; 539 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
540 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; 540 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
541 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; 541 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
542 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; 542 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
543 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; 543 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
544 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; 544 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
545 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; 545 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
546 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; 546 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
547 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; 547 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break;
548 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; 548 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break;
549 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; 549 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break;
550 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; 550 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break;
551 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; 551 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break;
552 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; 552 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break;
553 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; 553 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break;
554 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; 554 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break;
555 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; 555 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break;
556 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; 556 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break;
557 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; 557 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break;
558 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; 558 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break;
559 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; 559 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break;
560 default : CATEGORY = QString(""); 560 default : CATEGORY = QString("");
561 } 561 }
562 562
563 return CATEGORY; 563 return CATEGORY;
564 } 564 }
565 565
566protected: 566protected:
567private: 567private:
568 Calendar *mCalendar; 568 Calendar *mCalendar;
569 QString mProfileName ; 569 QString mProfileName ;
570}; 570};
571 571
572 572
573PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 573PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
574{ 574{
575 mProfileName = profileName; 575 mProfileName = profileName;
576 mDevice = device; 576 mDevice = device;
577 mConnection = connection; 577 mConnection = connection;
578 mModel = model; 578 mModel = model;
579} 579}
580 580
581PhoneFormat::~PhoneFormat() 581PhoneFormat::~PhoneFormat()
582{ 582{
583} 583}
584int PhoneFormat::initDevice(GSM_StateMachine *s) 584int PhoneFormat::initDevice(GSM_StateMachine *s)
585{ 585{
586 GSM_ReadConfig(NULL, &s->Config[0], 0); 586 GSM_ReadConfig(NULL, &s->Config[0], 0);
587 s->ConfigNum = 1; 587 s->ConfigNum = 1;
588 GSM_Config *cfg = &s->Config[0]; 588 GSM_Config *cfg = &s->Config[0];
589 if ( ! mConnection.isEmpty() ) { 589 if ( ! mConnection.isEmpty() ) {
590 cfg->Connection = strdup(mConnection.latin1()); 590 cfg->Connection = strdup(mConnection.latin1());
591 cfg->DefaultConnection = false; 591 cfg->DefaultConnection = false;
592 qDebug("Connection set %s ", cfg->Connection ); 592 qDebug("Connection set %s ", cfg->Connection );
593 593
594 } 594 }
595 if ( ! mDevice.isEmpty() ) { 595 if ( ! mDevice.isEmpty() ) {
596 cfg->Device = strdup(mDevice.latin1()); 596 cfg->Device = strdup(mDevice.latin1());
597 cfg->DefaultDevice = false; 597 cfg->DefaultDevice = false;
598 qDebug("Device set %s ", cfg->Device); 598 qDebug("Device set %s ", cfg->Device);
599 599
600 } 600 }
601 if ( ! mModel.isEmpty() ) { 601 if ( ! mModel.isEmpty() ) {
602 strcpy(cfg->Model,mModel.latin1() ); 602 strcpy(cfg->Model,mModel.latin1() );
603 cfg->DefaultModel = false; 603 cfg->DefaultModel = false;
604 qDebug("Model set %s ",cfg->Model ); 604 qDebug("Model set %s ",cfg->Model );
605 } 605 }
606 int error=GSM_InitConnection(s,3); 606 int error=GSM_InitConnection(s,3);
607 return error; 607 return error;
608} 608}
609ulong PhoneFormat::getCsumTodo( Todo* todo ) 609ulong PhoneFormat::getCsumTodo( Todo* todo )
610{ 610{
611 QStringList attList; 611 QStringList attList;
612 if ( todo->hasDueDate() ) 612 if ( todo->hasDueDate() )
613 attList << PhoneParser::dtToString ( todo->dtDue() ); 613 attList << PhoneParser::dtToString ( todo->dtDue() );
614 attList << todo->summary(); 614 attList << todo->summary();
615 QString completedString = "no"; 615 QString completedString = "no";
616 if ( todo->isCompleted() ) 616 if ( todo->isCompleted() )
617 completedString = "yes"; 617 completedString = "yes";
618 attList << completedString; 618 attList << completedString;
619 attList << QString::number( todo->priority() ); 619 attList << QString::number( todo->priority() );
620 QString alarmString = "na"; 620 QString alarmString = "na";
621 Alarm *alarm; 621 Alarm *alarm;
622 if ( todo->alarms().count() > 0 ) { 622 if ( todo->alarms().count() > 0 ) {
623 alarm = todo->alarms().first(); 623 alarm = todo->alarms().first();
624 if ( alarm->enabled() ) { 624 if ( alarm->enabled() ) {
625 alarmString = QString::number(alarm->startOffset().asSeconds() ); 625 alarmString = QString::number(alarm->startOffset().asSeconds() );
626 } 626 }
627 } 627 }
628 attList << alarmString; 628 attList << alarmString;
629 attList << todo->categoriesStr(); 629 attList << todo->categoriesStr();
630 attList << todo->secrecyStr(); 630 attList << todo->secrecyStr();
631 return PhoneFormat::getCsum(attList ); 631 return PhoneFormat::getCsum(attList );
632 632
633} 633}
634ulong PhoneFormat::getCsumEvent( Event* event ) 634ulong PhoneFormat::getCsumEvent( Event* event )
635{ 635{
636 QStringList attList; 636 QStringList attList;
637 attList << PhoneParser::dtToString ( event->dtStart() ); 637 attList << PhoneParser::dtToString ( event->dtStart() );
638 attList << PhoneParser::dtToString ( event->dtEnd() ); 638 attList << PhoneParser::dtToString ( event->dtEnd() );
639 attList << event->summary(); 639 attList << event->summary();
640 attList << event->location(); 640 attList << event->location();
641 QString alarmString = "na"; 641 QString alarmString = "na";
642 Alarm *alarm; 642 Alarm *alarm;
643 if ( event->alarms().count() > 0 ) { 643 if ( event->alarms().count() > 0 ) {
644 alarm = event->alarms().first(); 644 alarm = event->alarms().first();
645 if ( alarm->enabled() ) { 645 if ( alarm->enabled() ) {
646 alarmString = QString::number( alarm->startOffset().asSeconds() ); 646 alarmString = QString::number( alarm->startOffset().asSeconds() );
647 } 647 }
648 } 648 }
649 attList << alarmString; 649 attList << alarmString;
650 Recurrence* rec = event->recurrence(); 650 Recurrence* rec = event->recurrence();
651 QStringList list; 651 QStringList list;
652 bool writeEndDate = false; 652 bool writeEndDate = false;
653 switch ( rec->doesRecur() ) 653 switch ( rec->doesRecur() )
654 { 654 {
655 case Recurrence::rDaily: // 0 655 case Recurrence::rDaily: // 0
656 list.append( "0" ); 656 list.append( "0" );
657 list.append( QString::number( rec->frequency() ));//12 657 list.append( QString::number( rec->frequency() ));//12
658 list.append( "0" ); 658 list.append( "0" );
659 list.append( "0" ); 659 list.append( "0" );
660 writeEndDate = true; 660 writeEndDate = true;
661 break; 661 break;
662 case Recurrence::rWeekly:// 1 662 case Recurrence::rWeekly:// 1
663 list.append( "1" ); 663 list.append( "1" );
664 list.append( QString::number( rec->frequency()) );//12 664 list.append( QString::number( rec->frequency()) );//12
665 list.append( "0" ); 665 list.append( "0" );
666 { 666 {
667 int days = 0; 667 int days = 0;
668 QBitArray weekDays = rec->days(); 668 QBitArray weekDays = rec->days();
669 int i; 669 int i;
670 for( i = 1; i <= 7; ++i ) { 670 for( i = 1; i <= 7; ++i ) {
671 if ( weekDays[i-1] ) { 671 if ( weekDays[i-1] ) {
672 days += 1 << (i-1); 672 days += 1 << (i-1);
673 } 673 }
674 } 674 }
675 list.append( QString::number( days ) ); 675 list.append( QString::number( days ) );
676 } 676 }
677 //pending weekdays 677 //pending weekdays
678 writeEndDate = true; 678 writeEndDate = true;
679 679
680 break; 680 break;
681 case Recurrence::rMonthlyPos:// 2 681 case Recurrence::rMonthlyPos:// 2
682 list.append( "2" ); 682 list.append( "2" );
683 list.append( QString::number( rec->frequency()) );//12 683 list.append( QString::number( rec->frequency()) );//12
684 684
685 writeEndDate = true; 685 writeEndDate = true;
686 { 686 {
687 int count = 1; 687 int count = 1;
688 QPtrList<Recurrence::rMonthPos> rmp; 688 QPtrList<Recurrence::rMonthPos> rmp;
689 rmp = rec->monthPositions(); 689 rmp = rec->monthPositions();
690 if ( rmp.first()->negative ) 690 if ( rmp.first()->negative )
691 count = 5 - rmp.first()->rPos - 1; 691 count = 5 - rmp.first()->rPos - 1;
692 else 692 else
693 count = rmp.first()->rPos - 1; 693 count = rmp.first()->rPos - 1;
694 list.append( QString::number( count ) ); 694 list.append( QString::number( count ) );
695 695
696 } 696 }
697 697
698 list.append( "0" ); 698 list.append( "0" );
699 break; 699 break;
700 case Recurrence::rMonthlyDay:// 3 700 case Recurrence::rMonthlyDay:// 3
701 list.append( "3" ); 701 list.append( "3" );
702 list.append( QString::number( rec->frequency()) );//12 702 list.append( QString::number( rec->frequency()) );//12
703 list.append( "0" ); 703 list.append( "0" );
704 list.append( "0" ); 704 list.append( "0" );
705 writeEndDate = true; 705 writeEndDate = true;
706 break; 706 break;
707 case Recurrence::rYearlyMonth://4 707 case Recurrence::rYearlyMonth://4
708 list.append( "4" ); 708 list.append( "4" );
709 list.append( QString::number( rec->frequency()) );//12 709 list.append( QString::number( rec->frequency()) );//12
710 list.append( "0" ); 710 list.append( "0" );
711 list.append( "0" ); 711 list.append( "0" );
712 writeEndDate = true; 712 writeEndDate = true;
713 break; 713 break;
714 714
715 default: 715 default:
716 list.append( "255" ); 716 list.append( "255" );
717 list.append( QString() ); 717 list.append( QString() );
718 list.append( "0" ); 718 list.append( "0" );
719 list.append( QString() ); 719 list.append( QString() );
720 list.append( "0" ); 720 list.append( "0" );
721 list.append( "20991231T000000" ); 721 list.append( "20991231T000000" );
722 break; 722 break;
723 } 723 }
724 if ( writeEndDate ) { 724 if ( writeEndDate ) {
725 725
726 if ( rec->endDate().isValid() ) { // 15 + 16 726 if ( rec->endDate().isValid() ) { // 15 + 16
727 list.append( "1" ); 727 list.append( "1" );
728 list.append( PhoneParser::dtToString( rec->endDate()) ); 728 list.append( PhoneParser::dtToString( rec->endDate()) );
729 } else { 729 } else {
730 list.append( "0" ); 730 list.append( "0" );
731 list.append( "20991231T000000" ); 731 list.append( "20991231T000000" );
732 } 732 }
733 733
734 } 734 }
735 attList << list.join(""); 735 attList << list.join("");
736 attList << event->categoriesStr(); 736 attList << event->categoriesStr();
737 attList << event->secrecyStr(); 737 attList << event->secrecyStr();
738 return PhoneFormat::getCsum(attList ); 738 return PhoneFormat::getCsum(attList );
739} 739}
740ulong PhoneFormat::getCsum( const QStringList & attList) 740ulong PhoneFormat::getCsum( const QStringList & attList)
741{ 741{
742 int max = attList.count() -1; 742 int max = attList.count() -1;
743 ulong cSum = 0; 743 ulong cSum = 0;
744 int j,k,i; 744 int j,k,i;
745 int add; 745 int add;
746 for ( i = 1; i < max ; ++i ) { 746 for ( i = 1; i < max ; ++i ) {
747 QString s = attList[i]; 747 QString s = attList[i];
748 if ( ! s.isEmpty() ){ 748 if ( ! s.isEmpty() ){
749 j = s.length(); 749 j = s.length();
750 for ( k = 0; k < j; ++k ) { 750 for ( k = 0; k < j; ++k ) {
751 int mul = k +1; 751 int mul = k +1;
752 add = s[k].unicode (); 752 add = s[k].unicode ();
753 if ( k < 16 ) 753 if ( k < 16 )
754 mul = mul * mul; 754 mul = mul * mul;
755 add = add * mul *i*i*i; 755 add = add * mul *i*i*i;
756 cSum += add; 756 cSum += add;
757 } 757 }
758 } 758 }
759 } 759 }
760 return cSum; 760 return cSum;
761 761
762} 762}
763//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 763//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
764#include <stdlib.h> 764#include <stdlib.h>
765#define DEBUGMODE false 765#define DEBUGMODE false
766bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 766bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
767{ 767{
768 GSM_StateMachines; 768 GSM_StateMachines;
769 qDebug(" load "); 769 qDebug(" load ");
770 s.opened = false; 770 s.opened = false;
771 s.msg = NULL; 771 s.msg = NULL;
772 s.ConfigNum = 0; 772 s.ConfigNum = 0;
773 QLabel status ( i18n("Reading data. Opening device ..."), 0 ); 773 QLabel status ( i18n("Reading data. Opening device ..."), 0 );
774 int w = status.sizeHint().width()+20 ; 774 int w = status.sizeHint().width()+20 ;
775 if ( w < 200 ) w = 200; 775 if ( w < 200 ) w = 200;
776 int h = status.sizeHint().height()+20 ; 776 int h = status.sizeHint().height()+20 ;
777 int dw = QApplication::desktop()->width(); 777 int dw = QApplication::desktop()->width();
778 int dh = QApplication::desktop()->height(); 778 int dh = QApplication::desktop()->height();
779 status.setCaption(i18n("Reading Phone Data") ); 779 status.setCaption(i18n("Reading Phone Data") );
780 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 780 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
781 status.show(); 781 status.show();
782 status.raise(); 782 status.raise();
783 qApp->processEvents(); 783 qApp->processEvents();
784#if 0 784#if 0
785 static char*cp; 785 static char*cp;
786 static INI_Section *cfg = NULL; 786 static INI_Section *cfg = NULL;
787 cfg=GSM_FindGammuRC(); 787 cfg=GSM_FindGammuRC();
788 int i; 788 int i;
789 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 789 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
790 if (cfg!=NULL) { 790 if (cfg!=NULL) {
791 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); 791 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
792 if (cp) di.coding = cp; 792 if (cp) di.coding = cp;
793 793
794 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); 794 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
795 if (s.Config[i].Localize) { 795 if (s.Config[i].Localize) {
796 s.msg=INI_ReadFile(s.Config[i].Localize, true); 796 s.msg=INI_ReadFile(s.Config[i].Localize, true);
797 } else { 797 } else {
798#if !defined(WIN32) && defined(LOCALE_PATH) 798#if !defined(WIN32) && defined(LOCALE_PATH)
799 locale = setlocale(LC_MESSAGES, NULL); 799 locale = setlocale(LC_MESSAGES, NULL);
800 if (locale != NULL) { 800 if (locale != NULL) {
801 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 801 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
802 LOCALE_PATH, 802 LOCALE_PATH,
803 tolower(locale[0]), 803 tolower(locale[0]),
804 tolower(locale[1])); 804 tolower(locale[1]));
805 s.msg = INI_ReadFile(locale_file, true); 805 s.msg = INI_ReadFile(locale_file, true);
806 } 806 }
807#endif 807#endif
808 } 808 }
809 } 809 }
810 810
811 /* Wanted user specific configuration? */ 811 /* Wanted user specific configuration? */
812 812
813 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 813 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
814 814
815 s.ConfigNum++; 815 s.ConfigNum++;
816 816
817 /* We want to use only one file descriptor for global and state machine debug output */ 817 /* We want to use only one file descriptor for global and state machine debug output */
818 s.Config[i].UseGlobalDebugFile = true; 818 s.Config[i].UseGlobalDebugFile = true;
819 819
820 820
821 821
822 /* We wanted to read just user specified configuration. */ 822 /* We wanted to read just user specified configuration. */
823 {break;} 823 {break;}
824 } 824 }
825 825
826#endif 826#endif
827 int error=initDevice(&s); 827 int error=initDevice(&s);
828 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 828 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
829 if ( error != ERR_NONE ) 829 if ( error != ERR_NONE )
830 return false; 830 return false;
831 GSM_Phone_Functions*Phone; 831 GSM_Phone_Functions*Phone;
832 GSM_CalendarEntrynote; 832 GSM_CalendarEntrynote;
833 bool start = true; 833 bool start = true;
834 Phone=s.Phone.Functions; 834 Phone=s.Phone.Functions;
835 bool gshutdown = false; 835 bool gshutdown = false;
836 PhoneParser handler( calendar, mProfileName ); 836 PhoneParser handler( calendar, mProfileName );
837 int ccc = 0; 837 int ccc = 0;
838 QString message = i18n("Processing event # "); 838 QString message = i18n("Processing event # ");
839 int procCount = 0; 839 int procCount = 0;
840 qDebug("Debug: only 10 calender items are downloaded "); 840 qDebug("Debug: only 10 calender items are downloaded ");
841 while (!gshutdown && ccc++ < 10) { 841 while (!gshutdown && ccc++ < 10) {
842 status.setText ( message + QString::number ( ++procCount ) ); 842 status.setText ( message + QString::number ( ++procCount ) );
843 qApp->processEvents(); 843 qApp->processEvents();
844 qDebug("readEvent %d ", ccc); 844 qDebug("readEvent %d ", ccc);
845 error=Phone->GetNextCalendar(&s,&note,start); 845 error=Phone->GetNextCalendar(&s,&note,start);
846 if (error == ERR_EMPTY) break; 846 if (error == ERR_EMPTY) break;
847 start = false; 847 start = false;
848 handler.readEvent( existingCal, &note ); 848 handler.readEvent( existingCal, &note );
849 } 849 }
850 850
851 start = true; 851 start = true;
852 GSM_ToDoEntry ToDo; 852 GSM_ToDoEntry ToDo;
853 ccc = 0; 853 ccc = 0;
854 message = i18n("Processing todo # "); 854 message = i18n("Processing todo # ");
855 procCount = 0; 855 procCount = 0;
856 while (!gshutdown) { 856 while (!gshutdown) {
857 status.setText ( message + QString::number ( ++procCount ) ); 857 status.setText ( message + QString::number ( ++procCount ) );
858 qApp->processEvents(); 858 qApp->processEvents();
859 error = Phone->GetNextToDo(&s, &ToDo, start); 859 error = Phone->GetNextToDo(&s, &ToDo, start);
860 if (error == ERR_EMPTY) break; 860 if (error == ERR_EMPTY) break;
861 start = false; 861 start = false;
862 qDebug("ReadTodo %d ", ++ccc); 862 qDebug("ReadTodo %d ", ++ccc);
863 handler.readTodo( existingCal, &ToDo, &s); 863 handler.readTodo( existingCal, &ToDo, &s);
864 864
865 } 865 }
866 866
867 error=GSM_TerminateConnection(&s); 867 error=GSM_TerminateConnection(&s);
868 868
869 return true; 869 return true;
870} 870}
871void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note ) 871void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note )
872{ 872{
873 873 QString eText = vfconverter.eventToString( ev );
874 int pos = 0;
875 GSM_ToDoEntry dummy;
876 GSM_DecodeVCALENDAR_VTODO( (unsigned char*)eText.latin1(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo );
874} 877}
875void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsm ) 878void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsmTodo )
876{ 879{
877#if 0 880 QString tText = vfconverter.todoToString( todo );
878 QStringList list; 881 int pos = 0;
879 list.append( QString::number( todo->zaurusId() ) ); 882 GSM_CalendarEntry dummy;
880 list.append( todo->categories().join(",") ); 883 GSM_DecodeVCALENDAR_VTODO( (unsigned char*)tText.latin1(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo );
881
882 if ( todo->hasStartDate() ) {
883 list.append( dtToString( todo->dtStart()) );
884 } else
885 list.append( QString() );
886
887 if ( todo->hasDueDate() ) {
888 QTime tim;
889 if ( todo->doesFloat()) {
890 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
891 } else {
892 list.append( dtToString(todo->dtDue() ) );
893 }
894 } else
895 list.append( QString() );
896
897 if ( todo->isCompleted() ) {
898 list.append( dtToString( todo->completed()) );
899 list.append( "0" ); // yes 0 == completed
900 } else {
901 list.append( dtToString( todo->completed()) );
902 list.append( "1" );
903 }
904 list.append( QString::number( todo->priority() ));
905 if( ! todo->summary().isEmpty() )
906 list.append( todo->summary() );
907 else
908 list.append( "" );
909 if (! todo->description().isEmpty() )
910 list.append( todo->description() );
911 else
912 list.append( "" );
913 for(QStringList::Iterator it=list.begin();
914 it!=list.end(); ++it){
915 QString& s = (*it);
916 s.replace(QRegExp("\""), "\"\"");
917 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
918 s.prepend('\"');
919 s.append('\"');
920 } else if(s.isEmpty() && !s.isNull()){
921 s = "\"\"";
922 }
923 }
924 return list.join(",");
925#endif
926} 884}
927void PhoneFormat::afterSave( Incidence* inc) 885void PhoneFormat::afterSave( Incidence* inc)
928{ 886{
929 uint csum; 887 uint csum;
930 if ( inc->type() == "Event") 888 if ( inc->type() == "Event")
931 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 889 csum = PhoneFormat::getCsumEvent( (Event*) inc );
932 else 890 else
933 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 891 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
934 inc->setCsum( mProfileName, QString::number( csum )); 892 inc->setCsum( mProfileName, QString::number( csum ));
935 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 893 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
936 894
937} 895}
938bool PhoneFormat::save( Calendar *calendar) 896bool PhoneFormat::save( Calendar *calendar)
939{ 897{
940 GSM_StateMachines; 898 GSM_StateMachines;
941 qDebug(" save "); 899 qDebug(" save ");
942 s.opened = false; 900 s.opened = false;
943 s.msg = NULL; 901 s.msg = NULL;
944 s.ConfigNum = 0; 902 s.ConfigNum = 0;
945 QLabel status ( i18n("Writing data. Opening device ..."), 0 ); 903 QLabel status ( i18n("Writing data. Opening device ..."), 0 );
946 int w = status.sizeHint().width()+20 ; 904 int w = status.sizeHint().width()+20 ;
947 if ( w < 200 ) w = 200; 905 if ( w < 200 ) w = 200;
948 int h = status.sizeHint().height()+20 ; 906 int h = status.sizeHint().height()+20 ;
949 int dw = QApplication::desktop()->width(); 907 int dw = QApplication::desktop()->width();
950 int dh = QApplication::desktop()->height(); 908 int dh = QApplication::desktop()->height();
951 status.setCaption(i18n("Writing Phone Data") ); 909 status.setCaption(i18n("Writing Phone Data") );
952 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 910 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
953 status.show(); 911 status.show();
954 status.raise(); 912 status.raise();
955 qApp->processEvents(); 913 qApp->processEvents();
956 914
957 int error=initDevice(&s); 915 int error=initDevice(&s);
958 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 916 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
959 if ( error != ERR_NONE ) 917 if ( error != ERR_NONE )
960 return false; 918 return false;
961 GSM_Phone_Functions*Phone; 919 GSM_Phone_Functions*Phone;
962 GSM_CalendarEntryNote; 920 GSM_CalendarEntryNote;
963 bool start = true; 921 bool start = true;
964 Phone=s.Phone.Functions; 922 Phone=s.Phone.Functions;
965 bool gshutdown = false; 923 bool gshutdown = false;
966 QPtrList<Event> er = calendar->rawEvents(); 924 QPtrList<Event> er = calendar->rawEvents();
967 Event* ev = er.first(); 925 Event* ev = er.first();
968 QString message = i18n("Processing event # "); 926 QString message = i18n("Processing event # ");
969 int procCount = 0; 927 int procCount = 0;
970 while ( ev ) { 928 while ( ev ) {
971 //qDebug("i %d ", ++i); 929 //qDebug("i %d ", ++i);
972 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one 930 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one
973 931
974 status.setText ( message + QString::number ( ++procCount ) ); 932 status.setText ( message + QString::number ( ++procCount ) );
975 qApp->processEvents(); 933 qApp->processEvents();
976 event2GSM( ev, &Note ); 934 event2GSM( ev, &Note );
977 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 935 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
978 error = Phone->DeleteCalendar(&s, &Note); 936 error = Phone->DeleteCalendar(&s, &Note);
979 } 937 }
980 else if ( ev->getID(mProfileName).isEmpty() ) { // add new 938 else if ( ev->getID(mProfileName).isEmpty() ) { // add new
981 // we have to do this later after deleting 939 // we have to do this later after deleting
982 940
983 } 941 }
984 else { // change existing 942 else { // change existing
985 error = Phone->SetCalendar(&s, &Note); 943 error = Phone->SetCalendar(&s, &Note);
986 } 944 }
987 } 945 }
988 ev = er.next(); 946 ev = er.next();
989 } 947 }
990 ev = er.first(); 948 ev = er.first();
991 // pending get empty slots 949 // pending get empty slots
992 while ( ev ) { 950 while ( ev ) {
993 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { 951 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
994 if ( ev->getID(mProfileName).isEmpty() ) { 952 if ( ev->getID(mProfileName).isEmpty() ) {
995 status.setText ( message + QString::number ( ++procCount ) ); 953 status.setText ( message + QString::number ( ++procCount ) );
996 qApp->processEvents(); 954 qApp->processEvents();
997 //int newID ;//= pending 955 //int newID ;//= pending
998 //ev->setID(mProfileName, QString::number( newID )); 956 //ev->setID(mProfileName, QString::number( newID ));
999 event2GSM( ev, &Note ); 957 event2GSM( ev, &Note );
1000 Note.Location = 0; 958 Note.Location = 0;
1001 error = Phone->AddCalendar(&s, &Note); 959 error = Phone->AddCalendar(&s, &Note);
1002 ev->setID( mProfileName, QString::number( Note.Location ) ); 960 ev->setID( mProfileName, QString::number( Note.Location ) );
1003 qDebug("New Calendar. Location %d ",Note.Location ); 961 qDebug("New Calendar. Location %d ",Note.Location );
1004 afterSave( ev ); 962 afterSave( ev );
1005 } else { 963 } else {
1006 afterSave( ev ); // setting temp sync stat for changed items 964 afterSave( ev ); // setting temp sync stat for changed items
1007 } 965 }
1008 } 966 }
1009 ev = er.next(); 967 ev = er.next();
1010 } 968 }
1011 GSM_ToDoEntry ToDoEntry; 969 GSM_ToDoEntry ToDoEntry;
1012 QPtrList<Todo> tl = calendar->rawTodos(); 970 QPtrList<Todo> tl = calendar->rawTodos();
1013 Todo* to = tl.first(); 971 Todo* to = tl.first();
1014 972
1015 message = i18n("Processing todo # "); 973 message = i18n("Processing todo # ");
1016 procCount = 0; 974 procCount = 0;
1017 while ( to ) { 975 while ( to ) {
1018 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 976 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1019 status.setText ( message + QString::number ( ++procCount ) ); 977 status.setText ( message + QString::number ( ++procCount ) );
1020 qApp->processEvents(); 978 qApp->processEvents();
1021 todo2GSM( to, &ToDoEntry ); 979 todo2GSM( to, &ToDoEntry );
1022 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 980 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
1023 error=Phone->DeleteToDo(&s,&ToDoEntry); 981 error=Phone->DeleteToDo(&s,&ToDoEntry);
1024 } 982 }
1025 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new 983 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new
1026 ; 984 ;
1027 } 985 }
1028 else { // change existing 986 else { // change existing
1029 error=Phone->SetToDo(&s,&ToDoEntry); 987 error=Phone->SetToDo(&s,&ToDoEntry);
1030 } 988 }
1031 } 989 }
1032 to = tl.next(); 990 to = tl.next();
1033 } 991 }
1034 992
1035 // pending get empty slots 993 // pending get empty slots
1036 to = tl.first(); 994 to = tl.first();
1037 while ( to ) { 995 while ( to ) {
1038 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { 996 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1039 if ( to->getID(mProfileName).isEmpty() ) { 997 if ( to->getID(mProfileName).isEmpty() ) {
1040 status.setText ( message + QString::number ( ++procCount ) ); 998 status.setText ( message + QString::number ( ++procCount ) );
1041 qApp->processEvents(); 999 qApp->processEvents();
1042 //int newID ;//= pending 1000 //int newID ;//= pending
1043 //to->setID(mProfileName, QString::number( newID )); 1001 //to->setID(mProfileName, QString::number( newID ));
1044 todo2GSM( to, &ToDoEntry ); 1002 todo2GSM( to, &ToDoEntry );
1045 ToDoEntry.Location = 0; 1003 ToDoEntry.Location = 0;
1046 error=Phone->AddToDo(&s,&ToDoEntry); 1004 error=Phone->AddToDo(&s,&ToDoEntry);
1047 to->setID(mProfileName, QString::number( ToDoEntry.Location )); 1005 to->setID(mProfileName, QString::number( ToDoEntry.Location ));
1048 afterSave( to ); 1006 afterSave( to );
1049 qDebug("New Todo. Location %d ",ToDoEntry.Location ); 1007 qDebug("New Todo. Location %d ",ToDoEntry.Location );
1050 } else { 1008 } else {
1051 afterSave( to ); 1009 afterSave( to );
1052 } 1010 }
1053 } 1011 }
1054 to = tl.next(); 1012 to = tl.next();
1055 } 1013 }
1056 return true; 1014 return true;
1057} 1015}
1058QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) 1016QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ )
1059{ 1017{
1060 QString datestr; 1018 QString datestr;
1061 QString timestr; 1019 QString timestr;
1062 int offset = KGlobal::locale()->localTimeOffset( dti ); 1020 int offset = KGlobal::locale()->localTimeOffset( dti );
1063 QDateTime dt; 1021 QDateTime dt;
1064 if (useTZ) 1022 if (useTZ)
1065 dt = dti.addSecs ( -(offset*60)); 1023 dt = dti.addSecs ( -(offset*60));
1066 else 1024 else
1067 dt = dti; 1025 dt = dti;
1068 if(dt.date().isValid()){ 1026 if(dt.date().isValid()){
1069 const QDate& date = dt.date(); 1027 const QDate& date = dt.date();
1070 datestr.sprintf("%04d%02d%02d", 1028 datestr.sprintf("%04d%02d%02d",
1071 date.year(), date.month(), date.day()); 1029 date.year(), date.month(), date.day());
1072 } 1030 }
1073 if(dt.time().isValid()){ 1031 if(dt.time().isValid()){
1074 const QTime& time = dt.time(); 1032 const QTime& time = dt.time();
1075 timestr.sprintf("T%02d%02d%02d", 1033 timestr.sprintf("T%02d%02d%02d",
1076 time.hour(), time.minute(), time.second()); 1034 time.hour(), time.minute(), time.second());
1077 } 1035 }
1078 return datestr + timestr; 1036 return datestr + timestr;
1079} 1037}
1080QString PhoneFormat::getEventString( Event* event ) 1038QString PhoneFormat::getEventString( Event* event )
1081{ 1039{
1082#if 0 1040#if 0
1083 QStringList list; 1041 QStringList list;
1084 list.append( QString::number(event->zaurusId() ) ); 1042 list.append( QString::number(event->zaurusId() ) );
1085 list.append( event->categories().join(",") ); 1043 list.append( event->categories().join(",") );
1086 if ( !event->summary().isEmpty() ) 1044 if ( !event->summary().isEmpty() )
1087 list.append( event->summary() ); 1045 list.append( event->summary() );
1088 else 1046 else
1089 list.append("" ); 1047 list.append("" );
1090 if ( !event->location().isEmpty() ) 1048 if ( !event->location().isEmpty() )
1091 list.append( event->location() ); 1049 list.append( event->location() );
1092 else 1050 else
1093 list.append("" ); 1051 list.append("" );
1094 if ( !event->description().isEmpty() ) 1052 if ( !event->description().isEmpty() )
1095 list.append( event->description() ); 1053 list.append( event->description() );
1096 else 1054 else
1097 list.append( "" ); 1055 list.append( "" );
1098 if ( event->doesFloat () ) { 1056 if ( event->doesFloat () ) {
1099 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); 1057 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
1100 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 1058 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
1101 list.append( "1" ); 1059 list.append( "1" );
1102 1060
1103 } 1061 }
1104 else { 1062 else {
1105 list.append( dtToString( event->dtStart()) ); 1063 list.append( dtToString( event->dtStart()) );
1106 list.append( dtToString( event->dtEnd()) ); //6 1064 list.append( dtToString( event->dtEnd()) ); //6
1107 list.append( "0" ); 1065 list.append( "0" );
1108 } 1066 }
1109 bool noAlarm = true; 1067 bool noAlarm = true;
1110 if ( event->alarms().count() > 0 ) { 1068 if ( event->alarms().count() > 0 ) {
1111 Alarm * al = event->alarms().first(); 1069 Alarm * al = event->alarms().first();
1112 if ( al->enabled() ) { 1070 if ( al->enabled() ) {
1113 noAlarm = false; 1071 noAlarm = false;
1114 list.append( "0" ); // yes, 0 == alarm 1072 list.append( "0" ); // yes, 0 == alarm
1115 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); 1073 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
1116 if ( al->type() == Alarm::Audio ) 1074 if ( al->type() == Alarm::Audio )
1117 list.append( "1" ); // type audio 1075 list.append( "1" ); // type audio
1118 else 1076 else
1119 list.append( "0" ); // type silent 1077 list.append( "0" ); // type silent
1120 } 1078 }
1121 } 1079 }
1122 if ( noAlarm ) { 1080 if ( noAlarm ) {
1123 list.append( "1" ); // yes, 1 == no alarm 1081 list.append( "1" ); // yes, 1 == no alarm
1124 list.append( "0" ); // no alarm offset 1082 list.append( "0" ); // no alarm offset
1125 list.append( "1" ); // type 1083 list.append( "1" ); // type
1126 } 1084 }
1127 // next is: 11 1085 // next is: 11
1128 // next is: 11-16 are recurrence 1086 // next is: 11-16 are recurrence
1129 Recurrence* rec = event->recurrence(); 1087 Recurrence* rec = event->recurrence();
1130 1088
1131 bool writeEndDate = false; 1089 bool writeEndDate = false;
1132 switch ( rec->doesRecur() ) 1090 switch ( rec->doesRecur() )
1133 { 1091 {
1134 case Recurrence::rDaily: // 0 1092 case Recurrence::rDaily: // 0
1135 list.append( "0" ); 1093 list.append( "0" );
1136 list.append( QString::number( rec->frequency() ));//12 1094 list.append( QString::number( rec->frequency() ));//12
1137 list.append( "0" ); 1095 list.append( "0" );
1138 list.append( "0" ); 1096 list.append( "0" );
1139 writeEndDate = true; 1097 writeEndDate = true;
1140 break; 1098 break;
1141 case Recurrence::rWeekly:// 1 1099 case Recurrence::rWeekly:// 1
1142 list.append( "1" ); 1100 list.append( "1" );
1143 list.append( QString::number( rec->frequency()) );//12 1101 list.append( QString::number( rec->frequency()) );//12
1144 list.append( "0" ); 1102 list.append( "0" );
1145 { 1103 {
1146 int days = 0; 1104 int days = 0;
1147 QBitArray weekDays = rec->days(); 1105 QBitArray weekDays = rec->days();
1148 int i; 1106 int i;
1149 for( i = 1; i <= 7; ++i ) { 1107 for( i = 1; i <= 7; ++i ) {
1150 if ( weekDays[i-1] ) { 1108 if ( weekDays[i-1] ) {
1151 days += 1 << (i-1); 1109 days += 1 << (i-1);
1152 } 1110 }
1153 } 1111 }
1154 list.append( QString::number( days ) ); 1112 list.append( QString::number( days ) );
1155 } 1113 }
1156 //pending weekdays 1114 //pending weekdays
1157 writeEndDate = true; 1115 writeEndDate = true;
1158 1116
1159 break; 1117 break;
1160 case Recurrence::rMonthlyPos:// 2 1118 case Recurrence::rMonthlyPos:// 2
1161 list.append( "2" ); 1119 list.append( "2" );
1162 list.append( QString::number( rec->frequency()) );//12 1120 list.append( QString::number( rec->frequency()) );//12
1163 1121
1164 writeEndDate = true; 1122 writeEndDate = true;
1165 { 1123 {
1166 int count = 1; 1124 int count = 1;
1167 QPtrList<Recurrence::rMonthPos> rmp; 1125 QPtrList<Recurrence::rMonthPos> rmp;
1168 rmp = rec->monthPositions(); 1126 rmp = rec->monthPositions();
1169 if ( rmp.first()->negative ) 1127 if ( rmp.first()->negative )
1170 count = 5 - rmp.first()->rPos - 1; 1128 count = 5 - rmp.first()->rPos - 1;
1171 else 1129 else
1172 count = rmp.first()->rPos - 1; 1130 count = rmp.first()->rPos - 1;
1173 list.append( QString::number( count ) ); 1131 list.append( QString::number( count ) );
1174 1132
1175 } 1133 }
1176 1134
1177 list.append( "0" ); 1135 list.append( "0" );
1178 break; 1136 break;
1179 case Recurrence::rMonthlyDay:// 3 1137 case Recurrence::rMonthlyDay:// 3
1180 list.append( "3" ); 1138 list.append( "3" );
1181 list.append( QString::number( rec->frequency()) );//12 1139 list.append( QString::number( rec->frequency()) );//12
1182 list.append( "0" ); 1140 list.append( "0" );
1183 list.append( "0" ); 1141 list.append( "0" );
1184 writeEndDate = true; 1142 writeEndDate = true;
1185 break; 1143 break;
1186 case Recurrence::rYearlyMonth://4 1144 case Recurrence::rYearlyMonth://4
1187 list.append( "4" ); 1145 list.append( "4" );
1188 list.append( QString::number( rec->frequency()) );//12 1146 list.append( QString::number( rec->frequency()) );//12
1189 list.append( "0" ); 1147 list.append( "0" );
1190 list.append( "0" ); 1148 list.append( "0" );
1191 writeEndDate = true; 1149 writeEndDate = true;
1192 break; 1150 break;
1193 1151
1194 default: 1152 default:
1195 list.append( "255" ); 1153 list.append( "255" );
1196 list.append( QString() ); 1154 list.append( QString() );
1197 list.append( "0" ); 1155 list.append( "0" );
1198 list.append( QString() ); 1156 list.append( QString() );
1199 list.append( "0" ); 1157 list.append( "0" );
1200 list.append( "20991231T000000" ); 1158 list.append( "20991231T000000" );
1201 break; 1159 break;
1202 } 1160 }
1203 if ( writeEndDate ) { 1161 if ( writeEndDate ) {
1204 1162
1205 if ( rec->endDate().isValid() ) { // 15 + 16 1163 if ( rec->endDate().isValid() ) { // 15 + 16
1206 list.append( "1" ); 1164 list.append( "1" );
1207 list.append( dtToString( rec->endDate()) ); 1165 list.append( dtToString( rec->endDate()) );
1208 } else { 1166 } else {
1209 list.append( "0" ); 1167 list.append( "0" );
1210 list.append( "20991231T000000" ); 1168 list.append( "20991231T000000" );
1211 } 1169 }
1212 1170
1213 } 1171 }
1214 if ( event->doesFloat () ) { 1172 if ( event->doesFloat () ) {
1215 list.append( dtToString( event->dtStart(), false ).left( 8 )); 1173 list.append( dtToString( event->dtStart(), false ).left( 8 ));
1216 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 1174 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6
1217 1175
1218 } 1176 }
1219 else { 1177 else {
1220 list.append( QString() ); 1178 list.append( QString() );
1221 list.append( QString() ); 1179 list.append( QString() );
1222 1180
1223 } 1181 }
1224 if (event->dtStart().date() == event->dtEnd().date() ) 1182 if (event->dtStart().date() == event->dtEnd().date() )
1225 list.append( "0" ); 1183 list.append( "0" );
1226 else 1184 else
1227 list.append( "1" ); 1185 list.append( "1" );
1228 1186
1229 1187
1230 for(QStringList::Iterator it=list.begin(); 1188 for(QStringList::Iterator it=list.begin();
1231 it!=list.end(); ++it){ 1189 it!=list.end(); ++it){
1232 QString& s = (*it); 1190 QString& s = (*it);
1233 s.replace(QRegExp("\""), "\"\""); 1191 s.replace(QRegExp("\""), "\"\"");
1234 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 1192 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
1235 s.prepend('\"'); 1193 s.prepend('\"');
1236 s.append('\"'); 1194 s.append('\"');
1237 } else if(s.isEmpty() && !s.isNull()){ 1195 } else if(s.isEmpty() && !s.isNull()){
1238 s = "\"\""; 1196 s = "\"\"";
1239 } 1197 }
1240 } 1198 }
1241 return list.join(","); 1199 return list.join(",");
1242#endif 1200#endif
1243 return QString(); 1201 return QString();
1244 1202
1245} 1203}
1246QString PhoneFormat::getTodoString( Todo* todo ) 1204QString PhoneFormat::getTodoString( Todo* todo )
1247{ 1205{
1248#if 0 1206#if 0
1249 QStringList list; 1207 QStringList list;
1250 list.append( QString::number( todo->zaurusId() ) ); 1208 list.append( QString::number( todo->zaurusId() ) );
1251 list.append( todo->categories().join(",") ); 1209 list.append( todo->categories().join(",") );
1252 1210
1253 if ( todo->hasStartDate() ) { 1211 if ( todo->hasStartDate() ) {
1254 list.append( dtToString( todo->dtStart()) ); 1212 list.append( dtToString( todo->dtStart()) );
1255 } else 1213 } else
1256 list.append( QString() ); 1214 list.append( QString() );
1257 1215
1258 if ( todo->hasDueDate() ) { 1216 if ( todo->hasDueDate() ) {
1259 QTime tim; 1217 QTime tim;
1260 if ( todo->doesFloat()) { 1218 if ( todo->doesFloat()) {
1261 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; 1219 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
1262 } else { 1220 } else {
1263 list.append( dtToString(todo->dtDue() ) ); 1221 list.append( dtToString(todo->dtDue() ) );
1264 } 1222 }
1265 } else 1223 } else
1266 list.append( QString() ); 1224 list.append( QString() );
1267 1225
1268 if ( todo->isCompleted() ) { 1226 if ( todo->isCompleted() ) {
1269 list.append( dtToString( todo->completed()) ); 1227 list.append( dtToString( todo->completed()) );
1270 list.append( "0" ); // yes 0 == completed 1228 list.append( "0" ); // yes 0 == completed
1271 } else { 1229 } else {
1272 list.append( dtToString( todo->completed()) ); 1230 list.append( dtToString( todo->completed()) );
1273 list.append( "1" ); 1231 list.append( "1" );
1274 } 1232 }
1275 list.append( QString::number( todo->priority() )); 1233 list.append( QString::number( todo->priority() ));
1276 if( ! todo->summary().isEmpty() ) 1234 if( ! todo->summary().isEmpty() )
1277 list.append( todo->summary() ); 1235 list.append( todo->summary() );
1278 else 1236 else
1279 list.append( "" ); 1237 list.append( "" );
1280 if (! todo->description().isEmpty() ) 1238 if (! todo->description().isEmpty() )
1281 list.append( todo->description() ); 1239 list.append( todo->description() );
1282 else 1240 else
1283 list.append( "" ); 1241 list.append( "" );
1284 for(QStringList::Iterator it=list.begin(); 1242 for(QStringList::Iterator it=list.begin();
1285 it!=list.end(); ++it){ 1243 it!=list.end(); ++it){
1286 QString& s = (*it); 1244 QString& s = (*it);
1287 s.replace(QRegExp("\""), "\"\""); 1245 s.replace(QRegExp("\""), "\"\"");
1288 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ 1246 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
1289 s.prepend('\"'); 1247 s.prepend('\"');
1290 s.append('\"'); 1248 s.append('\"');
1291 } else if(s.isEmpty() && !s.isNull()){ 1249 } else if(s.isEmpty() && !s.isNull()){
1292 s = "\"\""; 1250 s = "\"\"";
1293 } 1251 }
1294 } 1252 }
1295 return list.join(","); 1253 return list.join(",");
1296#endif 1254#endif
1297 return QString(); 1255 return QString();
1298} 1256}
1299 1257
1300 1258
1301QString PhoneFormat::toString( Calendar * ) 1259QString PhoneFormat::toString( Calendar * )
1302{ 1260{
1303 return QString::null; 1261 return QString::null;
1304} 1262}
1305bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 1263bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
1306{ 1264{
1307 return false; 1265 return false;
1308} 1266}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 7b7dd04..33b2091 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,65 +1,67 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef PHONEFORMAT_H 21#ifndef PHONEFORMAT_H
22#define PHONEFORMAT_H 22#define PHONEFORMAT_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25 25
26#include "scheduler.h" 26#include "scheduler.h"
27 27
28#include "vcalformat.h"
28#include "calformat.h" 29#include "calformat.h"
29extern "C" { 30extern "C" {
30#include "../gammu/emb/common/gammu.h" 31#include "../gammu/emb/common/gammu.h"
31} 32}
32namespace KCal { 33namespace KCal {
33 34
34/** 35/**
35 This class implements the calendar format used by Phone. 36 This class implements the calendar format used by Phone.
36*/ 37*/
37 class Event; 38 class Event;
38 class Todo; 39 class Todo;
39class PhoneFormat : public QObject { 40class PhoneFormat : public QObject {
40 public: 41 public:
41 /** Create new iCalendar format. */ 42 /** Create new iCalendar format. */
42 PhoneFormat(QString profileName, QString device,QString connection, QString model); 43 PhoneFormat(QString profileName, QString device,QString connection, QString model);
43 virtual ~PhoneFormat(); 44 virtual ~PhoneFormat();
44 45
45 bool load( Calendar * ,Calendar * ); 46 bool load( Calendar * ,Calendar * );
46 bool save( Calendar * ); 47 bool save( Calendar * );
47 bool fromString( Calendar *, const QString & ); 48 bool fromString( Calendar *, const QString & );
48 QString toString( Calendar * ); 49 QString toString( Calendar * );
49 static ulong getCsum( const QStringList & ); 50 static ulong getCsum( const QStringList & );
50 static ulong getCsumTodo( Todo* to ); 51 static ulong getCsumTodo( Todo* to );
51 static ulong getCsumEvent( Event* ev ); 52 static ulong getCsumEvent( Event* ev );
52 private: 53 private:
54 VCalFormat vfconverter;
53 void event2GSM( Event* ev, GSM_CalendarEntry*Note ); 55 void event2GSM( Event* ev, GSM_CalendarEntry*Note );
54 void todo2GSM( Todo* ev, GSM_ToDoEntry *ToDo ); 56 void todo2GSM( Todo* ev, GSM_ToDoEntry *ToDo );
55 int initDevice(GSM_StateMachine *s); 57 int initDevice(GSM_StateMachine *s);
56 QString getEventString( Event* ); 58 QString getEventString( Event* );
57 QString getTodoString( Todo* ); 59 QString getTodoString( Todo* );
58 QString dtToGSM( const QDateTime& dt, bool useTZ = true ); 60 QString dtToGSM( const QDateTime& dt, bool useTZ = true );
59 QString mProfileName, mDevice, mConnection, mModel; 61 QString mProfileName, mDevice, mConnection, mModel;
60 void afterSave( Incidence* ); 62 void afterSave( Incidence* );
61}; 63};
62 64
63} 65}
64 66
65#endif 67#endif
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 72a781a..1167e58 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -1,1678 +1,1697 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brwon 3 Copyright (c) 1998 Preston Brwon
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qapplication.h> 22#include <qapplication.h>
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qclipboard.h> 27#include <qclipboard.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qfile.h> 29#include <qfile.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <klocale.h> 34#include <klocale.h>
35 35
36#include "vcc.h" 36#include "vcc.h"
37#include "vobject.h" 37#include "vobject.h"
38 38
39#include "vcaldrag.h" 39#include "vcaldrag.h"
40#include "calendar.h" 40#include "calendar.h"
41 41
42#include "vcalformat.h" 42#include "vcalformat.h"
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46VCalFormat::VCalFormat() 46VCalFormat::VCalFormat()
47{ 47{
48} 48}
49 49
50VCalFormat::~VCalFormat() 50VCalFormat::~VCalFormat()
51{ 51{
52} 52}
53 53
54bool VCalFormat::load(Calendar *calendar, const QString &fileName) 54bool VCalFormat::load(Calendar *calendar, const QString &fileName)
55{ 55{
56 mCalendar = calendar; 56 mCalendar = calendar;
57 57
58 clearException(); 58 clearException();
59 59
60 kdDebug(5800) << "VCalFormat::load() " << fileName << endl; 60 kdDebug(5800) << "VCalFormat::load() " << fileName << endl;
61 61
62 VObject *vcal = 0; 62 VObject *vcal = 0;
63 63
64 // this is not necessarily only 1 vcal. Could be many vcals, or include 64 // this is not necessarily only 1 vcal. Could be many vcals, or include
65 // a vcard... 65 // a vcard...
66 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); 66 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data()));
67 67
68 if (!vcal) { 68 if (!vcal) {
69 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); 69 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
70 return FALSE; 70 return FALSE;
71 } 71 }
72 72
73 // any other top-level calendar stuff should be added/initialized here 73 // any other top-level calendar stuff should be added/initialized here
74 74
75 // put all vobjects into their proper places 75 // put all vobjects into their proper places
76 populate(vcal); 76 populate(vcal);
77 77
78 // clean up from vcal API stuff 78 // clean up from vcal API stuff
79 cleanVObjects(vcal); 79 cleanVObjects(vcal);
80 cleanStrTbl(); 80 cleanStrTbl();
81 81
82 return true; 82 return true;
83} 83}
84 84
85 85
86bool VCalFormat::save(Calendar *calendar, const QString &fileName) 86bool VCalFormat::save(Calendar *calendar, const QString &fileName)
87{ 87{
88 mCalendar = calendar; 88 mCalendar = calendar;
89 89
90 QString tmpStr; 90 QString tmpStr;
91 VObject *vcal, *vo; 91 VObject *vcal, *vo;
92 92
93 kdDebug(5800) << "VCalFormat::save(): " << fileName << endl; 93 kdDebug(5800) << "VCalFormat::save(): " << fileName << endl;
94 94
95 vcal = newVObject(VCCalProp); 95 vcal = newVObject(VCCalProp);
96 96
97 // addPropValue(vcal,VCLocationProp, "0.0"); 97 // addPropValue(vcal,VCLocationProp, "0.0");
98 addPropValue(vcal,VCProdIdProp, productId()); 98 addPropValue(vcal,VCProdIdProp, productId());
99 tmpStr = mCalendar->getTimeZoneStr(); 99 tmpStr = mCalendar->getTimeZoneStr();
100 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); 100 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() );
101 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); 101 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit());
102 addPropValue(vcal,VCVersionProp, _VCAL_VERSION); 102 addPropValue(vcal,VCVersionProp, _VCAL_VERSION);
103 103
104 // TODO STUFF 104 // TODO STUFF
105 QPtrList<Todo> todoList = mCalendar->rawTodos(); 105 QPtrList<Todo> todoList = mCalendar->rawTodos();
106 QPtrListIterator<Todo> qlt(todoList); 106 QPtrListIterator<Todo> qlt(todoList);
107 for (; qlt.current(); ++qlt) { 107 for (; qlt.current(); ++qlt) {
108 vo = eventToVTodo(qlt.current()); 108 vo = eventToVTodo(qlt.current());
109 addVObjectProp(vcal, vo); 109 addVObjectProp(vcal, vo);
110 } 110 }
111 111
112 // EVENT STUFF 112 // EVENT STUFF
113 QPtrList<Event> events = mCalendar->rawEvents(); 113 QPtrList<Event> events = mCalendar->rawEvents();
114 Event *ev; 114 Event *ev;
115 for(ev=events.first();ev;ev=events.next()) { 115 for(ev=events.first();ev;ev=events.next()) {
116 vo = eventToVEvent(ev); 116 vo = eventToVEvent(ev);
117 addVObjectProp(vcal, vo); 117 addVObjectProp(vcal, vo);
118 } 118 }
119 119
120 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); 120 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal);
121 cleanVObjects(vcal); 121 cleanVObjects(vcal);
122 cleanStrTbl(); 122 cleanStrTbl();
123 123
124 if (QFile::exists(fileName)) { 124 if (QFile::exists(fileName)) {
125 kdDebug(5800) << "No error" << endl; 125 kdDebug(5800) << "No error" << endl;
126 return true; 126 return true;
127 } else { 127 } else {
128 kdDebug(5800) << "Error" << endl; 128 kdDebug(5800) << "Error" << endl;
129 return false; // error 129 return false; // error
130 } 130 }
131} 131}
132 132
133bool VCalFormat::fromString( Calendar *calendar, const QString &text ) 133bool VCalFormat::fromString( Calendar *calendar, const QString &text )
134{ 134{
135 // TODO: Factor out VCalFormat::fromString() 135 // TODO: Factor out VCalFormat::fromString()
136 136
137 QCString data = text.utf8(); 137 QCString data = text.utf8();
138 138
139 if ( !data.size() ) return false; 139 if ( !data.size() ) return false;
140 140
141 VObject *vcal = Parse_MIME( data.data(), data.size()); 141 VObject *vcal = Parse_MIME( data.data(), data.size());
142 if ( !vcal ) return false; 142 if ( !vcal ) return false;
143 143
144 VObjectIterator i; 144 VObjectIterator i;
145 VObject *curvo; 145 VObject *curvo;
146 initPropIterator( &i, vcal ); 146 initPropIterator( &i, vcal );
147 147
148 // we only take the first object. TODO: parse all incidences. 148 // we only take the first object. TODO: parse all incidences.
149 do { 149 do {
150 curvo = nextVObject( &i ); 150 curvo = nextVObject( &i );
151 } while ( strcmp( vObjectName( curvo ), VCEventProp ) && 151 } while ( strcmp( vObjectName( curvo ), VCEventProp ) &&
152 strcmp( vObjectName( curvo ), VCTodoProp ) ); 152 strcmp( vObjectName( curvo ), VCTodoProp ) );
153 153
154 if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { 154 if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) {
155 Event *event = VEventToEvent( curvo ); 155 Event *event = VEventToEvent( curvo );
156 calendar->addEvent( event ); 156 calendar->addEvent( event );
157 } else { 157 } else {
158 kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; 158 kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl;
159 deleteVObject( vcal ); 159 deleteVObject( vcal );
160 return false; 160 return false;
161 } 161 }
162 162
163 deleteVObject( vcal ); 163 deleteVObject( vcal );
164 164
165 return true; 165 return true;
166} 166}
167 167
168QString VCalFormat::eventToString( Event * event)
169{
170 if ( !event ) return QString::null;
171 VObject *vevent = eventToVEvent( event );
172 char *buf = writeMemVObject( 0, 0, vevent );
173 QString result( buf );
174 cleanVObject( vevent );
175 return result;
176}
177QString VCalFormat::todoToString( Todo * todo )
178{
179 if ( !todo ) return QString::null;
180 VObject *vevent = eventToVTodo( todo );
181 char *buf = writeMemVObject( 0, 0, vevent );
182 QString result( buf );
183 cleanVObject( vevent );
184 return result;
185}
186
168QString VCalFormat::toString( Calendar *calendar ) 187QString VCalFormat::toString( Calendar *calendar )
169{ 188{
170 // TODO: Factor out VCalFormat::asString() 189 // TODO: Factor out VCalFormat::asString()
171 190
172 VObject *vcal = newVObject(VCCalProp); 191 VObject *vcal = newVObject(VCCalProp);
173 192
174 addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); 193 addPropValue( vcal, VCProdIdProp, CalFormat::productId() );
175 QString tmpStr = mCalendar->getTimeZoneStr(); 194 QString tmpStr = mCalendar->getTimeZoneStr();
176 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); 195 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() );
177 addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); 196 addPropValue( vcal, VCVersionProp, _VCAL_VERSION );
178 197
179 // TODO: Use all data. 198 // TODO: Use all data.
180 QPtrList<Event> events = calendar->events(); 199 QPtrList<Event> events = calendar->events();
181 Event *event = events.first(); 200 Event *event = events.first();
182 if ( !event ) return QString::null; 201 if ( !event ) return QString::null;
183 202
184 VObject *vevent = eventToVEvent( event ); 203 VObject *vevent = eventToVEvent( event );
185 204
186 addVObjectProp( vcal, vevent ); 205 addVObjectProp( vcal, vevent );
187 206
188 char *buf = writeMemVObject( 0, 0, vcal ); 207 char *buf = writeMemVObject( 0, 0, vcal );
189 208
190 QString result( buf ); 209 QString result( buf );
191 210
192 cleanVObject( vcal ); 211 cleanVObject( vcal );
193 212
194 return result; 213 return result;
195} 214}
196 215
197VObject *VCalFormat::eventToVTodo(const Todo *anEvent) 216VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
198{ 217{
199 VObject *vtodo; 218 VObject *vtodo;
200 QString tmpStr; 219 QString tmpStr;
201 QStringList tmpStrList; 220 QStringList tmpStrList;
202 221
203 vtodo = newVObject(VCTodoProp); 222 vtodo = newVObject(VCTodoProp);
204 223
205 // due date 224 // due date
206 if (anEvent->hasDueDate()) { 225 if (anEvent->hasDueDate()) {
207 tmpStr = qDateTimeToISO(anEvent->dtDue(), 226 tmpStr = qDateTimeToISO(anEvent->dtDue(),
208 !anEvent->doesFloat()); 227 !anEvent->doesFloat());
209 addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); 228 addPropValue(vtodo, VCDueProp, tmpStr.local8Bit());
210 } 229 }
211 230
212 // start date 231 // start date
213 if (anEvent->hasStartDate()) { 232 if (anEvent->hasStartDate()) {
214 tmpStr = qDateTimeToISO(anEvent->dtStart(), 233 tmpStr = qDateTimeToISO(anEvent->dtStart(),
215 !anEvent->doesFloat()); 234 !anEvent->doesFloat());
216 addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); 235 addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit());
217 } 236 }
218 237
219 // creation date 238 // creation date
220 tmpStr = qDateTimeToISO(anEvent->created()); 239 tmpStr = qDateTimeToISO(anEvent->created());
221 addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); 240 addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit());
222 241
223 // unique id 242 // unique id
224 addPropValue(vtodo, VCUniqueStringProp, 243 addPropValue(vtodo, VCUniqueStringProp,
225 anEvent->uid().local8Bit()); 244 anEvent->uid().local8Bit());
226 245
227 // revision 246 // revision
228 tmpStr.sprintf("%i", anEvent->revision()); 247 tmpStr.sprintf("%i", anEvent->revision());
229 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); 248 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit());
230 249
231 // last modification date 250 // last modification date
232 tmpStr = qDateTimeToISO(anEvent->lastModified()); 251 tmpStr = qDateTimeToISO(anEvent->lastModified());
233 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); 252 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit());
234 253
235 // organizer stuff 254 // organizer stuff
236 tmpStr = "MAILTO:" + anEvent->organizer(); 255 tmpStr = "MAILTO:" + anEvent->organizer();
237 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); 256 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit());
238 257
239 // attendees 258 // attendees
240 if (anEvent->attendeeCount() != 0) { 259 if (anEvent->attendeeCount() != 0) {
241 QPtrList<Attendee> al = anEvent->attendees(); 260 QPtrList<Attendee> al = anEvent->attendees();
242 QPtrListIterator<Attendee> ai(al); 261 QPtrListIterator<Attendee> ai(al);
243 Attendee *curAttendee; 262 Attendee *curAttendee;
244 263
245 for (; ai.current(); ++ai) { 264 for (; ai.current(); ++ai) {
246 curAttendee = ai.current(); 265 curAttendee = ai.current();
247 if (!curAttendee->email().isEmpty() && 266 if (!curAttendee->email().isEmpty() &&
248 !curAttendee->name().isEmpty()) 267 !curAttendee->name().isEmpty())
249 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 268 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
250 curAttendee->email() + ">"; 269 curAttendee->email() + ">";
251 else if (curAttendee->name().isEmpty()) 270 else if (curAttendee->name().isEmpty())
252 tmpStr = "MAILTO: " + curAttendee->email(); 271 tmpStr = "MAILTO: " + curAttendee->email();
253 else if (curAttendee->email().isEmpty()) 272 else if (curAttendee->email().isEmpty())
254 tmpStr = "MAILTO: " + curAttendee->name(); 273 tmpStr = "MAILTO: " + curAttendee->name();
255 else if (curAttendee->name().isEmpty() && 274 else if (curAttendee->name().isEmpty() &&
256 curAttendee->email().isEmpty()) 275 curAttendee->email().isEmpty())
257 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 276 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
258 VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); 277 VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit());
259 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); 278 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
260 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 279 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
261 } 280 }
262 } 281 }
263 282
264 // description BL: 283 // description BL:
265 if (!anEvent->description().isEmpty()) { 284 if (!anEvent->description().isEmpty()) {
266 VObject *d = addPropValue(vtodo, VCDescriptionProp, 285 VObject *d = addPropValue(vtodo, VCDescriptionProp,
267 anEvent->description().local8Bit()); 286 anEvent->description().local8Bit());
268 if (anEvent->description().find('\n') != -1) 287 if (anEvent->description().find('\n') != -1)
269 addProp(d, VCQuotedPrintableProp); 288 addProp(d, VCQuotedPrintableProp);
270 } 289 }
271 290
272 // summary 291 // summary
273 if (!anEvent->summary().isEmpty()) 292 if (!anEvent->summary().isEmpty())
274 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); 293 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit());
275 294
276 if (!anEvent->location().isEmpty()) 295 if (!anEvent->location().isEmpty())
277 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); 296 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit());
278 297
279 // completed 298 // completed
280 // status 299 // status
281 // backward compatibility, KOrganizer used to interpret only these two values 300 // backward compatibility, KOrganizer used to interpret only these two values
282 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : 301 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" :
283 "NEEDS_ACTION"); 302 "NEEDS_ACTION");
284 // completion date 303 // completion date
285 if (anEvent->hasCompletedDate()) { 304 if (anEvent->hasCompletedDate()) {
286 tmpStr = qDateTimeToISO(anEvent->completed()); 305 tmpStr = qDateTimeToISO(anEvent->completed());
287 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); 306 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit());
288 } 307 }
289 308
290 // priority 309 // priority
291 tmpStr.sprintf("%i",anEvent->priority()); 310 tmpStr.sprintf("%i",anEvent->priority());
292 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); 311 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit());
293 312
294 // related event 313 // related event
295 if (anEvent->relatedTo()) { 314 if (anEvent->relatedTo()) {
296 addPropValue(vtodo, VCRelatedToProp, 315 addPropValue(vtodo, VCRelatedToProp,
297 anEvent->relatedTo()->uid().local8Bit()); 316 anEvent->relatedTo()->uid().local8Bit());
298 } 317 }
299 318
300 // categories 319 // categories
301 tmpStrList = anEvent->categories(); 320 tmpStrList = anEvent->categories();
302 tmpStr = ""; 321 tmpStr = "";
303 QString catStr; 322 QString catStr;
304 for ( QStringList::Iterator it = tmpStrList.begin(); 323 for ( QStringList::Iterator it = tmpStrList.begin();
305 it != tmpStrList.end(); 324 it != tmpStrList.end();
306 ++it ) { 325 ++it ) {
307 catStr = *it; 326 catStr = *it;
308 if (catStr[0] == ' ') 327 if (catStr[0] == ' ')
309 tmpStr += catStr.mid(1); 328 tmpStr += catStr.mid(1);
310 else 329 else
311 tmpStr += catStr; 330 tmpStr += catStr;
312 // this must be a ';' character as the vCalendar specification requires! 331 // this must be a ';' character as the vCalendar specification requires!
313 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 332 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
314 // read in. 333 // read in.
315 tmpStr += ";"; 334 tmpStr += ";";
316 } 335 }
317 if (!tmpStr.isEmpty()) { 336 if (!tmpStr.isEmpty()) {
318 tmpStr.truncate(tmpStr.length()-1); 337 tmpStr.truncate(tmpStr.length()-1);
319 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); 338 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit());
320 } 339 }
321 340
322 // alarm stuff 341 // alarm stuff
323 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; 342 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl;
324 QPtrList<Alarm> alarms = anEvent->alarms(); 343 QPtrList<Alarm> alarms = anEvent->alarms();
325 Alarm* alarm; 344 Alarm* alarm;
326 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 345 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
327 if (alarm->enabled()) { 346 if (alarm->enabled()) {
328 VObject *a = addProp(vtodo, VCDAlarmProp); 347 VObject *a = addProp(vtodo, VCDAlarmProp);
329 tmpStr = qDateTimeToISO(alarm->time()); 348 tmpStr = qDateTimeToISO(alarm->time());
330 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 349 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
331 addPropValue(a, VCRepeatCountProp, "1"); 350 addPropValue(a, VCRepeatCountProp, "1");
332 addPropValue(a, VCDisplayStringProp, "beep!"); 351 addPropValue(a, VCDisplayStringProp, "beep!");
333 if (alarm->type() == Alarm::Audio) { 352 if (alarm->type() == Alarm::Audio) {
334 a = addProp(vtodo, VCAAlarmProp); 353 a = addProp(vtodo, VCAAlarmProp);
335 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 354 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
336 addPropValue(a, VCRepeatCountProp, "1"); 355 addPropValue(a, VCRepeatCountProp, "1");
337 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 356 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
338 } 357 }
339 else if (alarm->type() == Alarm::Procedure) { 358 else if (alarm->type() == Alarm::Procedure) {
340 a = addProp(vtodo, VCPAlarmProp); 359 a = addProp(vtodo, VCPAlarmProp);
341 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 360 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
342 addPropValue(a, VCRepeatCountProp, "1"); 361 addPropValue(a, VCRepeatCountProp, "1");
343 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 362 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
344 } 363 }
345 } 364 }
346 } 365 }
347 366
348 if (anEvent->pilotId()) { 367 if (anEvent->pilotId()) {
349 // pilot sync stuff 368 // pilot sync stuff
350 tmpStr.sprintf("%i",anEvent->pilotId()); 369 tmpStr.sprintf("%i",anEvent->pilotId());
351 addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); 370 addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit());
352 tmpStr.sprintf("%i",anEvent->syncStatus()); 371 tmpStr.sprintf("%i",anEvent->syncStatus());
353 addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); 372 addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit());
354 } 373 }
355 374
356 return vtodo; 375 return vtodo;
357} 376}
358 377
359VObject* VCalFormat::eventToVEvent(const Event *anEvent) 378VObject* VCalFormat::eventToVEvent(const Event *anEvent)
360{ 379{
361 VObject *vevent; 380 VObject *vevent;
362 QString tmpStr; 381 QString tmpStr;
363 QStringList tmpStrList; 382 QStringList tmpStrList;
364 383
365 vevent = newVObject(VCEventProp); 384 vevent = newVObject(VCEventProp);
366 385
367 // start and end time 386 // start and end time
368 tmpStr = qDateTimeToISO(anEvent->dtStart(), 387 tmpStr = qDateTimeToISO(anEvent->dtStart(),
369 !anEvent->doesFloat()); 388 !anEvent->doesFloat());
370 addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); 389 addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit());
371 390
372 // events that have time associated but take up no time should 391 // events that have time associated but take up no time should
373 // not have both DTSTART and DTEND. 392 // not have both DTSTART and DTEND.
374 if (anEvent->dtStart() != anEvent->dtEnd()) { 393 if (anEvent->dtStart() != anEvent->dtEnd()) {
375 tmpStr = qDateTimeToISO(anEvent->dtEnd(), 394 tmpStr = qDateTimeToISO(anEvent->dtEnd(),
376 !anEvent->doesFloat()); 395 !anEvent->doesFloat());
377 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); 396 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit());
378 } 397 }
379 398
380 // creation date 399 // creation date
381 tmpStr = qDateTimeToISO(anEvent->created()); 400 tmpStr = qDateTimeToISO(anEvent->created());
382 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); 401 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit());
383 402
384 // unique id 403 // unique id
385 addPropValue(vevent, VCUniqueStringProp, 404 addPropValue(vevent, VCUniqueStringProp,
386 anEvent->uid().local8Bit()); 405 anEvent->uid().local8Bit());
387 406
388 // revision 407 // revision
389 tmpStr.sprintf("%i", anEvent->revision()); 408 tmpStr.sprintf("%i", anEvent->revision());
390 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); 409 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit());
391 410
392 // last modification date 411 // last modification date
393 tmpStr = qDateTimeToISO(anEvent->lastModified()); 412 tmpStr = qDateTimeToISO(anEvent->lastModified());
394 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); 413 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit());
395 414
396 // attendee and organizer stuff 415 // attendee and organizer stuff
397 tmpStr = "MAILTO:" + anEvent->organizer(); 416 tmpStr = "MAILTO:" + anEvent->organizer();
398 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); 417 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit());
399 418
400 if (anEvent->attendeeCount() != 0) { 419 if (anEvent->attendeeCount() != 0) {
401 QPtrList<Attendee> al = anEvent->attendees(); 420 QPtrList<Attendee> al = anEvent->attendees();
402 QPtrListIterator<Attendee> ai(al); 421 QPtrListIterator<Attendee> ai(al);
403 Attendee *curAttendee; 422 Attendee *curAttendee;
404 423
405 // TODO: Put this functionality into Attendee class 424 // TODO: Put this functionality into Attendee class
406 for (; ai.current(); ++ai) { 425 for (; ai.current(); ++ai) {
407 curAttendee = ai.current(); 426 curAttendee = ai.current();
408 if (!curAttendee->email().isEmpty() && 427 if (!curAttendee->email().isEmpty() &&
409 !curAttendee->name().isEmpty()) 428 !curAttendee->name().isEmpty())
410 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 429 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
411 curAttendee->email() + ">"; 430 curAttendee->email() + ">";
412 else if (curAttendee->name().isEmpty()) 431 else if (curAttendee->name().isEmpty())
413 tmpStr = "MAILTO: " + curAttendee->email(); 432 tmpStr = "MAILTO: " + curAttendee->email();
414 else if (curAttendee->email().isEmpty()) 433 else if (curAttendee->email().isEmpty())
415 tmpStr = "MAILTO: " + curAttendee->name(); 434 tmpStr = "MAILTO: " + curAttendee->name();
416 else if (curAttendee->name().isEmpty() && 435 else if (curAttendee->name().isEmpty() &&
417 curAttendee->email().isEmpty()) 436 curAttendee->email().isEmpty())
418 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 437 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
419 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); 438 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit());
420 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; 439 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");;
421 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 440 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
422 } 441 }
423 } 442 }
424 443
425 // recurrence rule stuff 444 // recurrence rule stuff
426 if (anEvent->recurrence()->doesRecur()) { 445 if (anEvent->recurrence()->doesRecur()) {
427 // some more variables 446 // some more variables
428 QPtrList<Recurrence::rMonthPos> tmpPositions; 447 QPtrList<Recurrence::rMonthPos> tmpPositions;
429 QPtrList<int> tmpDays; 448 QPtrList<int> tmpDays;
430 int *tmpDay; 449 int *tmpDay;
431 Recurrence::rMonthPos *tmpPos; 450 Recurrence::rMonthPos *tmpPos;
432 QString tmpStr2; 451 QString tmpStr2;
433 int i; 452 int i;
434 453
435 switch(anEvent->recurrence()->doesRecur()) { 454 switch(anEvent->recurrence()->doesRecur()) {
436 case Recurrence::rDaily: 455 case Recurrence::rDaily:
437 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); 456 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency());
438// if (anEvent->rDuration > 0) 457// if (anEvent->rDuration > 0)
439 //tmpStr += "#"; 458 //tmpStr += "#";
440 break; 459 break;
441 case Recurrence::rWeekly: 460 case Recurrence::rWeekly:
442 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); 461 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency());
443 for (i = 0; i < 7; i++) { 462 for (i = 0; i < 7; i++) {
444 if (anEvent->recurrence()->days().testBit(i)) 463 if (anEvent->recurrence()->days().testBit(i))
445 tmpStr += dayFromNum(i); 464 tmpStr += dayFromNum(i);
446 } 465 }
447 break; 466 break;
448 case Recurrence::rMonthlyPos: 467 case Recurrence::rMonthlyPos:
449 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); 468 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency());
450 // write out all rMonthPos's 469 // write out all rMonthPos's
451 tmpPositions = anEvent->recurrence()->monthPositions(); 470 tmpPositions = anEvent->recurrence()->monthPositions();
452 for (tmpPos = tmpPositions.first(); 471 for (tmpPos = tmpPositions.first();
453 tmpPos; 472 tmpPos;
454 tmpPos = tmpPositions.next()) { 473 tmpPos = tmpPositions.next()) {
455 474
456 tmpStr2.sprintf("%i", tmpPos->rPos); 475 tmpStr2.sprintf("%i", tmpPos->rPos);
457 if (tmpPos->negative) 476 if (tmpPos->negative)
458 tmpStr2 += "- "; 477 tmpStr2 += "- ";
459 else 478 else
460 tmpStr2 += "+ "; 479 tmpStr2 += "+ ";
461 tmpStr += tmpStr2; 480 tmpStr += tmpStr2;
462 for (i = 0; i < 7; i++) { 481 for (i = 0; i < 7; i++) {
463 if (tmpPos->rDays.testBit(i)) 482 if (tmpPos->rDays.testBit(i))
464 tmpStr += dayFromNum(i); 483 tmpStr += dayFromNum(i);
465 } 484 }
466 } // loop for all rMonthPos's 485 } // loop for all rMonthPos's
467 break; 486 break;
468 case Recurrence::rMonthlyDay: 487 case Recurrence::rMonthlyDay:
469 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); 488 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency());
470 // write out all rMonthDays; 489 // write out all rMonthDays;
471 tmpDays = anEvent->recurrence()->monthDays(); 490 tmpDays = anEvent->recurrence()->monthDays();
472 for (tmpDay = tmpDays.first(); 491 for (tmpDay = tmpDays.first();
473 tmpDay; 492 tmpDay;
474 tmpDay = tmpDays.next()) { 493 tmpDay = tmpDays.next()) {
475 tmpStr2.sprintf("%i ", *tmpDay); 494 tmpStr2.sprintf("%i ", *tmpDay);
476 tmpStr += tmpStr2; 495 tmpStr += tmpStr2;
477 } 496 }
478 break; 497 break;
479 case Recurrence::rYearlyMonth: 498 case Recurrence::rYearlyMonth:
480 tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); 499 tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency());
481 // write out all the rYearNums; 500 // write out all the rYearNums;
482 tmpDays = anEvent->recurrence()->yearNums(); 501 tmpDays = anEvent->recurrence()->yearNums();
483 for (tmpDay = tmpDays.first(); 502 for (tmpDay = tmpDays.first();
484 tmpDay; 503 tmpDay;
485 tmpDay = tmpDays.next()) { 504 tmpDay = tmpDays.next()) {
486 tmpStr2.sprintf("%i ", *tmpDay); 505 tmpStr2.sprintf("%i ", *tmpDay);
487 tmpStr += tmpStr2; 506 tmpStr += tmpStr2;
488 } 507 }
489 break; 508 break;
490 case Recurrence::rYearlyDay: 509 case Recurrence::rYearlyDay:
491 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); 510 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency());
492 // write out all the rYearNums; 511 // write out all the rYearNums;
493 tmpDays = anEvent->recurrence()->yearNums(); 512 tmpDays = anEvent->recurrence()->yearNums();
494 for (tmpDay = tmpDays.first(); 513 for (tmpDay = tmpDays.first();
495 tmpDay; 514 tmpDay;
496 tmpDay = tmpDays.next()) { 515 tmpDay = tmpDays.next()) {
497 tmpStr2.sprintf("%i ", *tmpDay); 516 tmpStr2.sprintf("%i ", *tmpDay);
498 tmpStr += tmpStr2; 517 tmpStr += tmpStr2;
499 } 518 }
500 break; 519 break;
501 default: 520 default:
502 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; 521 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl;
503 break; 522 break;
504 } // switch 523 } // switch
505 524
506 if (anEvent->recurrence()->duration() > 0) { 525 if (anEvent->recurrence()->duration() > 0) {
507 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); 526 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration());
508 tmpStr += tmpStr2; 527 tmpStr += tmpStr2;
509 } else if (anEvent->recurrence()->duration() == -1) { 528 } else if (anEvent->recurrence()->duration() == -1) {
510 tmpStr += "#0"; // defined as repeat forever 529 tmpStr += "#0"; // defined as repeat forever
511 } else { 530 } else {
512 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); 531 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE);
513 } 532 }
514 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); 533 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit());
515 534
516 } // event repeats 535 } // event repeats
517 536
518 // exceptions to recurrence 537 // exceptions to recurrence
519 DateList dateList = anEvent->exDates(); 538 DateList dateList = anEvent->exDates();
520 DateList::ConstIterator it; 539 DateList::ConstIterator it;
521 QString tmpStr2; 540 QString tmpStr2;
522 541
523 for (it = dateList.begin(); it != dateList.end(); ++it) { 542 for (it = dateList.begin(); it != dateList.end(); ++it) {
524 tmpStr = qDateToISO(*it) + ";"; 543 tmpStr = qDateToISO(*it) + ";";
525 tmpStr2 += tmpStr; 544 tmpStr2 += tmpStr;
526 } 545 }
527 if (!tmpStr2.isEmpty()) { 546 if (!tmpStr2.isEmpty()) {
528 tmpStr2.truncate(tmpStr2.length()-1); 547 tmpStr2.truncate(tmpStr2.length()-1);
529 addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); 548 addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit());
530 } 549 }
531 550
532 // description 551 // description
533 if (!anEvent->description().isEmpty()) { 552 if (!anEvent->description().isEmpty()) {
534 VObject *d = addPropValue(vevent, VCDescriptionProp, 553 VObject *d = addPropValue(vevent, VCDescriptionProp,
535 anEvent->description().local8Bit()); 554 anEvent->description().local8Bit());
536 if (anEvent->description().find('\n') != -1) 555 if (anEvent->description().find('\n') != -1)
537 addProp(d, VCQuotedPrintableProp); 556 addProp(d, VCQuotedPrintableProp);
538 } 557 }
539 558
540 // summary 559 // summary
541 if (!anEvent->summary().isEmpty()) 560 if (!anEvent->summary().isEmpty())
542 addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); 561 addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit());
543 562
544 if (!anEvent->location().isEmpty()) 563 if (!anEvent->location().isEmpty())
545 addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); 564 addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit());
546 565
547 // status 566 // status
548// TODO: define Event status 567// TODO: define Event status
549// addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); 568// addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit());
550 569
551 // secrecy 570 // secrecy
552 const char *text = 0; 571 const char *text = 0;
553 switch (anEvent->secrecy()) { 572 switch (anEvent->secrecy()) {
554 case Incidence::SecrecyPublic: 573 case Incidence::SecrecyPublic:
555 text = "PUBLIC"; 574 text = "PUBLIC";
556 break; 575 break;
557 case Incidence::SecrecyPrivate: 576 case Incidence::SecrecyPrivate:
558 text = "PRIVATE"; 577 text = "PRIVATE";
559 break; 578 break;
560 case Incidence::SecrecyConfidential: 579 case Incidence::SecrecyConfidential:
561 text = "CONFIDENTIAL"; 580 text = "CONFIDENTIAL";
562 break; 581 break;
563 } 582 }
564 if (text) { 583 if (text) {
565 addPropValue(vevent, VCClassProp, text); 584 addPropValue(vevent, VCClassProp, text);
566 } 585 }
567 586
568 // categories 587 // categories
569 tmpStrList = anEvent->categories(); 588 tmpStrList = anEvent->categories();
570 tmpStr = ""; 589 tmpStr = "";
571 QString catStr; 590 QString catStr;
572 for ( QStringList::Iterator it = tmpStrList.begin(); 591 for ( QStringList::Iterator it = tmpStrList.begin();
573 it != tmpStrList.end(); 592 it != tmpStrList.end();
574 ++it ) { 593 ++it ) {
575 catStr = *it; 594 catStr = *it;
576 if (catStr[0] == ' ') 595 if (catStr[0] == ' ')
577 tmpStr += catStr.mid(1); 596 tmpStr += catStr.mid(1);
578 else 597 else
579 tmpStr += catStr; 598 tmpStr += catStr;
580 // this must be a ';' character as the vCalendar specification requires! 599 // this must be a ';' character as the vCalendar specification requires!
581 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 600 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
582 // read in. 601 // read in.
583 tmpStr += ";"; 602 tmpStr += ";";
584 } 603 }
585 if (!tmpStr.isEmpty()) { 604 if (!tmpStr.isEmpty()) {
586 tmpStr.truncate(tmpStr.length()-1); 605 tmpStr.truncate(tmpStr.length()-1);
587 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); 606 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit());
588 } 607 }
589 608
590 // attachments 609 // attachments
591 // TODO: handle binary attachments! 610 // TODO: handle binary attachments!
592 QPtrList<Attachment> attachments = anEvent->attachments(); 611 QPtrList<Attachment> attachments = anEvent->attachments();
593 for ( Attachment *at = attachments.first(); at; at = attachments.next() ) 612 for ( Attachment *at = attachments.first(); at; at = attachments.next() )
594 addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); 613 addPropValue(vevent, VCAttachProp, at->uri().local8Bit());
595 614
596 // resources 615 // resources
597 tmpStrList = anEvent->resources(); 616 tmpStrList = anEvent->resources();
598 tmpStr = tmpStrList.join(";"); 617 tmpStr = tmpStrList.join(";");
599 if (!tmpStr.isEmpty()) 618 if (!tmpStr.isEmpty())
600 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); 619 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit());
601 620
602 // alarm stuff 621 // alarm stuff
603 QPtrList<Alarm> alarms = anEvent->alarms(); 622 QPtrList<Alarm> alarms = anEvent->alarms();
604 Alarm* alarm; 623 Alarm* alarm;
605 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 624 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
606 if (alarm->enabled()) { 625 if (alarm->enabled()) {
607 VObject *a = addProp(vevent, VCDAlarmProp); 626 VObject *a = addProp(vevent, VCDAlarmProp);
608 tmpStr = qDateTimeToISO(alarm->time()); 627 tmpStr = qDateTimeToISO(alarm->time());
609 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 628 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
610 addPropValue(a, VCRepeatCountProp, "1"); 629 addPropValue(a, VCRepeatCountProp, "1");
611 addPropValue(a, VCDisplayStringProp, "beep!"); 630 addPropValue(a, VCDisplayStringProp, "beep!");
612 if (alarm->type() == Alarm::Audio) { 631 if (alarm->type() == Alarm::Audio) {
613 a = addProp(vevent, VCAAlarmProp); 632 a = addProp(vevent, VCAAlarmProp);
614 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 633 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
615 addPropValue(a, VCRepeatCountProp, "1"); 634 addPropValue(a, VCRepeatCountProp, "1");
616 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 635 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
617 } 636 }
618 if (alarm->type() == Alarm::Procedure) { 637 if (alarm->type() == Alarm::Procedure) {
619 a = addProp(vevent, VCPAlarmProp); 638 a = addProp(vevent, VCPAlarmProp);
620 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 639 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
621 addPropValue(a, VCRepeatCountProp, "1"); 640 addPropValue(a, VCRepeatCountProp, "1");
622 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 641 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
623 } 642 }
624 } 643 }
625 } 644 }
626 645
627 // priority 646 // priority
628 tmpStr.sprintf("%i",anEvent->priority()); 647 tmpStr.sprintf("%i",anEvent->priority());
629 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); 648 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit());
630 649
631 // transparency 650 // transparency
632 tmpStr.sprintf("%i",anEvent->transparency()); 651 tmpStr.sprintf("%i",anEvent->transparency());
633 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); 652 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit());
634 653
635 // related event 654 // related event
636 if (anEvent->relatedTo()) { 655 if (anEvent->relatedTo()) {
637 addPropValue(vevent, VCRelatedToProp, 656 addPropValue(vevent, VCRelatedToProp,
638 anEvent->relatedTo()->uid().local8Bit()); 657 anEvent->relatedTo()->uid().local8Bit());
639 } 658 }
640 659
641 if (anEvent->pilotId()) { 660 if (anEvent->pilotId()) {
642 // pilot sync stuff 661 // pilot sync stuff
643 tmpStr.sprintf("%i",anEvent->pilotId()); 662 tmpStr.sprintf("%i",anEvent->pilotId());
644 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); 663 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit());
645 tmpStr.sprintf("%i",anEvent->syncStatus()); 664 tmpStr.sprintf("%i",anEvent->syncStatus());
646 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); 665 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit());
647 } 666 }
648 667
649 return vevent; 668 return vevent;
650} 669}
651 670
652Todo *VCalFormat::VTodoToEvent(VObject *vtodo) 671Todo *VCalFormat::VTodoToEvent(VObject *vtodo)
653{ 672{
654 VObject *vo; 673 VObject *vo;
655 VObjectIterator voi; 674 VObjectIterator voi;
656 char *s; 675 char *s;
657 676
658 Todo *anEvent = new Todo; 677 Todo *anEvent = new Todo;
659 678
660 // creation date 679 // creation date
661 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { 680 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) {
662 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 681 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
663 deleteStr(s); 682 deleteStr(s);
664 } 683 }
665 684
666 // unique id 685 // unique id
667 vo = isAPropertyOf(vtodo, VCUniqueStringProp); 686 vo = isAPropertyOf(vtodo, VCUniqueStringProp);
668 // while the UID property is preferred, it is not required. We'll use the 687 // while the UID property is preferred, it is not required. We'll use the
669 // default Event UID if none is given. 688 // default Event UID if none is given.
670 if (vo) { 689 if (vo) {
671 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); 690 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo)));
672 deleteStr(s); 691 deleteStr(s);
673 } 692 }
674 693
675 // last modification date 694 // last modification date
676 if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { 695 if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) {
677 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 696 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
678 deleteStr(s); 697 deleteStr(s);
679 } 698 }
680 else 699 else
681 anEvent->setLastModified(QDateTime(QDate::currentDate(), 700 anEvent->setLastModified(QDateTime(QDate::currentDate(),
682 QTime::currentTime())); 701 QTime::currentTime()));
683 702
684 // organizer 703 // organizer
685 // if our extension property for the event's ORGANIZER exists, add it. 704 // if our extension property for the event's ORGANIZER exists, add it.
686 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { 705 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) {
687 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); 706 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo)));
688 deleteStr(s); 707 deleteStr(s);
689 } else { 708 } else {
690 anEvent->setOrganizer(mCalendar->getEmail()); 709 anEvent->setOrganizer(mCalendar->getEmail());
691 } 710 }
692 711
693 // attendees. 712 // attendees.
694 initPropIterator(&voi, vtodo); 713 initPropIterator(&voi, vtodo);
695 while (moreIteration(&voi)) { 714 while (moreIteration(&voi)) {
696 vo = nextVObject(&voi); 715 vo = nextVObject(&voi);
697 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { 716 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) {
698 Attendee *a; 717 Attendee *a;
699 VObject *vp; 718 VObject *vp;
700 s = fakeCString(vObjectUStringZValue(vo)); 719 s = fakeCString(vObjectUStringZValue(vo));
701 QString tmpStr = QString::fromLocal8Bit(s); 720 QString tmpStr = QString::fromLocal8Bit(s);
702 deleteStr(s); 721 deleteStr(s);
703 tmpStr = tmpStr.simplifyWhiteSpace(); 722 tmpStr = tmpStr.simplifyWhiteSpace();
704 int emailPos1, emailPos2; 723 int emailPos1, emailPos2;
705 if ((emailPos1 = tmpStr.find('<')) > 0) { 724 if ((emailPos1 = tmpStr.find('<')) > 0) {
706 // both email address and name 725 // both email address and name
707 emailPos2 = tmpStr.findRev('>'); 726 emailPos2 = tmpStr.findRev('>');
708 a = new Attendee(tmpStr.left(emailPos1 - 1), 727 a = new Attendee(tmpStr.left(emailPos1 - 1),
709 tmpStr.mid(emailPos1 + 1, 728 tmpStr.mid(emailPos1 + 1,
710 emailPos2 - (emailPos1 + 1))); 729 emailPos2 - (emailPos1 + 1)));
711 } else if (tmpStr.find('@') > 0) { 730 } else if (tmpStr.find('@') > 0) {
712 // just an email address 731 // just an email address
713 a = new Attendee(0, tmpStr); 732 a = new Attendee(0, tmpStr);
714 } else { 733 } else {
715 // just a name 734 // just a name
716 QString email = tmpStr.replace( QRegExp(" "), "." ); 735 QString email = tmpStr.replace( QRegExp(" "), "." );
717 a = new Attendee(tmpStr,email); 736 a = new Attendee(tmpStr,email);
718 } 737 }
719 738
720 // is there an RSVP property? 739 // is there an RSVP property?
721 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) 740 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
722 a->setRSVP(vObjectStringZValue(vp)); 741 a->setRSVP(vObjectStringZValue(vp));
723 // is there a status property? 742 // is there a status property?
724 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) 743 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
725 a->setStatus(readStatus(vObjectStringZValue(vp))); 744 a->setStatus(readStatus(vObjectStringZValue(vp)));
726 // add the attendee 745 // add the attendee
727 anEvent->addAttendee(a); 746 anEvent->addAttendee(a);
728 } 747 }
729 } 748 }
730 749
731 // description for todo 750 // description for todo
732 if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { 751 if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) {
733 s = fakeCString(vObjectUStringZValue(vo)); 752 s = fakeCString(vObjectUStringZValue(vo));
734 anEvent->setDescription(QString::fromLocal8Bit(s)); 753 anEvent->setDescription(QString::fromLocal8Bit(s));
735 deleteStr(s); 754 deleteStr(s);
736 } 755 }
737 756
738 // summary 757 // summary
739 if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { 758 if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) {
740 s = fakeCString(vObjectUStringZValue(vo)); 759 s = fakeCString(vObjectUStringZValue(vo));
741 anEvent->setSummary(QString::fromLocal8Bit(s)); 760 anEvent->setSummary(QString::fromLocal8Bit(s));
742 deleteStr(s); 761 deleteStr(s);
743 } 762 }
744 if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { 763 if ((vo = isAPropertyOf(vtodo, VCLocationProp))) {
745 s = fakeCString(vObjectUStringZValue(vo)); 764 s = fakeCString(vObjectUStringZValue(vo));
746 anEvent->setLocation(QString::fromLocal8Bit(s)); 765 anEvent->setLocation(QString::fromLocal8Bit(s));
747 deleteStr(s); 766 deleteStr(s);
748 } 767 }
749 768
750 769
751 // completed 770 // completed
752 // was: status 771 // was: status
753 if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { 772 if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) {
754 s = fakeCString(vObjectUStringZValue(vo)); 773 s = fakeCString(vObjectUStringZValue(vo));
755 if (strcmp(s,"COMPLETED") == 0) { 774 if (strcmp(s,"COMPLETED") == 0) {
756 anEvent->setCompleted(true); 775 anEvent->setCompleted(true);
757 } else { 776 } else {
758 anEvent->setCompleted(false); 777 anEvent->setCompleted(false);
759 } 778 }
760 deleteStr(s); 779 deleteStr(s);
761 } 780 }
762 else 781 else
763 anEvent->setCompleted(false); 782 anEvent->setCompleted(false);
764 783
765 // completion date 784 // completion date
766 if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { 785 if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) {
767 anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 786 anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
768 deleteStr(s); 787 deleteStr(s);
769 } 788 }
770 789
771 // priority 790 // priority
772 if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { 791 if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) {
773 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 792 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo))));
774 deleteStr(s); 793 deleteStr(s);
775 } 794 }
776 795
777 // due date 796 // due date
778 if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { 797 if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) {
779 anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 798 anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
780 deleteStr(s); 799 deleteStr(s);
781 anEvent->setHasDueDate(true); 800 anEvent->setHasDueDate(true);
782 } else { 801 } else {
783 anEvent->setHasDueDate(false); 802 anEvent->setHasDueDate(false);
784 } 803 }
785 804
786 // start time 805 // start time
787 if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { 806 if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) {
788 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 807 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
789 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; 808 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl;
790 deleteStr(s); 809 deleteStr(s);
791 anEvent->setHasStartDate(true); 810 anEvent->setHasStartDate(true);
792 } else { 811 } else {
793 anEvent->setHasStartDate(false); 812 anEvent->setHasStartDate(false);
794 } 813 }
795 814
796 /* alarm stuff */ 815 /* alarm stuff */
797 //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; 816 //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl;
798 if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { 817 if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) {
799 Alarm* alarm = anEvent->newAlarm(); 818 Alarm* alarm = anEvent->newAlarm();
800 VObject *a; 819 VObject *a;
801 if ((a = isAPropertyOf(vo, VCRunTimeProp))) { 820 if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
802 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); 821 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a))));
803 deleteStr(s); 822 deleteStr(s);
804 } 823 }
805 alarm->setEnabled(true); 824 alarm->setEnabled(true);
806 if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { 825 if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) {
807 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { 826 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
808 s = fakeCString(vObjectUStringZValue(a)); 827 s = fakeCString(vObjectUStringZValue(a));
809 alarm->setProcedureAlarm(QFile::decodeName(s)); 828 alarm->setProcedureAlarm(QFile::decodeName(s));
810 deleteStr(s); 829 deleteStr(s);
811 } 830 }
812 } 831 }
813 if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { 832 if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) {
814 if ((a = isAPropertyOf(vo, VCAudioContentProp))) { 833 if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
815 s = fakeCString(vObjectUStringZValue(a)); 834 s = fakeCString(vObjectUStringZValue(a));
816 alarm->setAudioAlarm(QFile::decodeName(s)); 835 alarm->setAudioAlarm(QFile::decodeName(s));
817 deleteStr(s); 836 deleteStr(s);
818 } 837 }
819 } 838 }
820 } 839 }
821 840
822 // related todo 841 // related todo
823 if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { 842 if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) {
824 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); 843 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo)));
825 deleteStr(s); 844 deleteStr(s);
826 mTodosRelate.append(anEvent); 845 mTodosRelate.append(anEvent);
827 } 846 }
828 847
829 // categories 848 // categories
830 QStringList tmpStrList; 849 QStringList tmpStrList;
831 int index1 = 0; 850 int index1 = 0;
832 int index2 = 0; 851 int index2 = 0;
833 if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { 852 if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) {
834 s = fakeCString(vObjectUStringZValue(vo)); 853 s = fakeCString(vObjectUStringZValue(vo));
835 QString categories = QString::fromLocal8Bit(s); 854 QString categories = QString::fromLocal8Bit(s);
836 deleteStr(s); 855 deleteStr(s);
837 //const char* category; 856 //const char* category;
838 QString category; 857 QString category;
839 while ((index2 = categories.find(',', index1)) != -1) { 858 while ((index2 = categories.find(',', index1)) != -1) {
840 //category = (const char *) categories.mid(index1, (index2 - index1)); 859 //category = (const char *) categories.mid(index1, (index2 - index1));
841 category = categories.mid(index1, (index2 - index1)); 860 category = categories.mid(index1, (index2 - index1));
842 tmpStrList.append(category); 861 tmpStrList.append(category);
843 index1 = index2+1; 862 index1 = index2+1;
844 } 863 }
845 // get last category 864 // get last category
846 category = categories.mid(index1, (categories.length()-index1)); 865 category = categories.mid(index1, (categories.length()-index1));
847 tmpStrList.append(category); 866 tmpStrList.append(category);
848 anEvent->setCategories(tmpStrList); 867 anEvent->setCategories(tmpStrList);
849 } 868 }
850 869
851 /* PILOT SYNC STUFF */ 870 /* PILOT SYNC STUFF */
852 if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { 871 if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) {
853 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 872 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo))));
854 deleteStr(s); 873 deleteStr(s);
855 } 874 }
856 else 875 else
857 anEvent->setPilotId(0); 876 anEvent->setPilotId(0);
858 877
859 if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { 878 if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) {
860 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 879 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo))));
861 deleteStr(s); 880 deleteStr(s);
862 } 881 }
863 else 882 else
864 anEvent->setSyncStatus(Event::SYNCMOD); 883 anEvent->setSyncStatus(Event::SYNCMOD);
865 884
866 return anEvent; 885 return anEvent;
867} 886}
868 887
869Event* VCalFormat::VEventToEvent(VObject *vevent) 888Event* VCalFormat::VEventToEvent(VObject *vevent)
870{ 889{
871 VObject *vo; 890 VObject *vo;
872 VObjectIterator voi; 891 VObjectIterator voi;
873 char *s; 892 char *s;
874 893
875 Event *anEvent = new Event; 894 Event *anEvent = new Event;
876 895
877 // creation date 896 // creation date
878 if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { 897 if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) {
879 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 898 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
880 deleteStr(s); 899 deleteStr(s);
881 } 900 }
882 901
883 // unique id 902 // unique id
884 vo = isAPropertyOf(vevent, VCUniqueStringProp); 903 vo = isAPropertyOf(vevent, VCUniqueStringProp);
885 // while the UID property is preferred, it is not required. We'll use the 904 // while the UID property is preferred, it is not required. We'll use the
886 // default Event UID if none is given. 905 // default Event UID if none is given.
887 if (vo) { 906 if (vo) {
888 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); 907 anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo)));
889 deleteStr(s); 908 deleteStr(s);
890 } 909 }
891 910
892 // revision 911 // revision
893 // again NSCAL doesn't give us much to work with, so we improvise... 912 // again NSCAL doesn't give us much to work with, so we improvise...
894 if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { 913 if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) {
895 anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 914 anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo))));
896 deleteStr(s); 915 deleteStr(s);
897 } 916 }
898 else 917 else
899 anEvent->setRevision(0); 918 anEvent->setRevision(0);
900 919
901 // last modification date 920 // last modification date
902 if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { 921 if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) {
903 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 922 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
904 deleteStr(s); 923 deleteStr(s);
905 } 924 }
906 else 925 else
907 anEvent->setLastModified(QDateTime(QDate::currentDate(), 926 anEvent->setLastModified(QDateTime(QDate::currentDate(),
908 QTime::currentTime())); 927 QTime::currentTime()));
909 928
910 // organizer 929 // organizer
911 // if our extension property for the event's ORGANIZER exists, add it. 930 // if our extension property for the event's ORGANIZER exists, add it.
912 if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { 931 if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) {
913 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); 932 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo)));
914 deleteStr(s); 933 deleteStr(s);
915 } else { 934 } else {
916 anEvent->setOrganizer(mCalendar->getEmail()); 935 anEvent->setOrganizer(mCalendar->getEmail());
917 } 936 }
918 937
919 // deal with attendees. 938 // deal with attendees.
920 initPropIterator(&voi, vevent); 939 initPropIterator(&voi, vevent);
921 while (moreIteration(&voi)) { 940 while (moreIteration(&voi)) {
922 vo = nextVObject(&voi); 941 vo = nextVObject(&voi);
923 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { 942 if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) {
924 Attendee *a; 943 Attendee *a;
925 VObject *vp; 944 VObject *vp;
926 s = fakeCString(vObjectUStringZValue(vo)); 945 s = fakeCString(vObjectUStringZValue(vo));
927 QString tmpStr = QString::fromLocal8Bit(s); 946 QString tmpStr = QString::fromLocal8Bit(s);
928 deleteStr(s); 947 deleteStr(s);
929 tmpStr = tmpStr.simplifyWhiteSpace(); 948 tmpStr = tmpStr.simplifyWhiteSpace();
930 int emailPos1, emailPos2; 949 int emailPos1, emailPos2;
931 if ((emailPos1 = tmpStr.find('<')) > 0) { 950 if ((emailPos1 = tmpStr.find('<')) > 0) {
932 // both email address and name 951 // both email address and name
933 emailPos2 = tmpStr.findRev('>'); 952 emailPos2 = tmpStr.findRev('>');
934 a = new Attendee(tmpStr.left(emailPos1 - 1), 953 a = new Attendee(tmpStr.left(emailPos1 - 1),
935 tmpStr.mid(emailPos1 + 1, 954 tmpStr.mid(emailPos1 + 1,
936 emailPos2 - (emailPos1 + 1))); 955 emailPos2 - (emailPos1 + 1)));
937 } else if (tmpStr.find('@') > 0) { 956 } else if (tmpStr.find('@') > 0) {
938 // just an email address 957 // just an email address
939 a = new Attendee(0, tmpStr); 958 a = new Attendee(0, tmpStr);
940 } else { 959 } else {
941 // just a name 960 // just a name
942 QString email = tmpStr.replace( QRegExp(" "), "." ); 961 QString email = tmpStr.replace( QRegExp(" "), "." );
943 a = new Attendee(tmpStr,email); 962 a = new Attendee(tmpStr,email);
944 } 963 }
945 964
946 // is there an RSVP property? 965 // is there an RSVP property?
947 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) 966 if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
948 a->setRSVP(vObjectStringZValue(vp)); 967 a->setRSVP(vObjectStringZValue(vp));
949 // is there a status property? 968 // is there a status property?
950 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) 969 if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
951 a->setStatus(readStatus(vObjectStringZValue(vp))); 970 a->setStatus(readStatus(vObjectStringZValue(vp)));
952 // add the attendee 971 // add the attendee
953 anEvent->addAttendee(a); 972 anEvent->addAttendee(a);
954 } 973 }
955 } 974 }
956 975
957 // This isn't strictly true. An event that doesn't have a start time 976 // This isn't strictly true. An event that doesn't have a start time
958 // or an end time doesn't "float", it has an anchor in time but it doesn't 977 // or an end time doesn't "float", it has an anchor in time but it doesn't
959 // "take up" any time. 978 // "take up" any time.
960 /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || 979 /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) ||
961 (isAPropertyOf(vevent, VCDTendProp) == 0)) { 980 (isAPropertyOf(vevent, VCDTendProp) == 0)) {
962 anEvent->setFloats(TRUE); 981 anEvent->setFloats(TRUE);
963 } else { 982 } else {
964 }*/ 983 }*/
965 984
966 anEvent->setFloats(FALSE); 985 anEvent->setFloats(FALSE);
967 986
968 // start time 987 // start time
969 if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { 988 if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) {
970 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 989 anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
971 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; 990 // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl;
972 deleteStr(s); 991 deleteStr(s);
973 if (anEvent->dtStart().time().isNull()) 992 if (anEvent->dtStart().time().isNull())
974 anEvent->setFloats(TRUE); 993 anEvent->setFloats(TRUE);
975 } 994 }
976 995
977 // stop time 996 // stop time
978 if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { 997 if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) {
979 anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 998 anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
980 deleteStr(s); 999 deleteStr(s);
981 if (anEvent->dtEnd().time().isNull()) 1000 if (anEvent->dtEnd().time().isNull())
982 anEvent->setFloats(TRUE); 1001 anEvent->setFloats(TRUE);
983 } 1002 }
984 1003
985 // at this point, there should be at least a start or end time. 1004 // at this point, there should be at least a start or end time.
986 // fix up for events that take up no time but have a time associated 1005 // fix up for events that take up no time but have a time associated
987 if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) 1006 if (!(vo = isAPropertyOf(vevent, VCDTstartProp)))
988 anEvent->setDtStart(anEvent->dtEnd()); 1007 anEvent->setDtStart(anEvent->dtEnd());
989 if (!(vo = isAPropertyOf(vevent, VCDTendProp))) 1008 if (!(vo = isAPropertyOf(vevent, VCDTendProp)))
990 anEvent->setDtEnd(anEvent->dtStart()); 1009 anEvent->setDtEnd(anEvent->dtStart());
991 1010
992 /////////////////////////////////////////////////////////////////////////// 1011 ///////////////////////////////////////////////////////////////////////////
993 1012
994 // repeat stuff 1013 // repeat stuff
995 if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { 1014 if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) {
996 QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); 1015 QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo)));
997 deleteStr(s); 1016 deleteStr(s);
998 tmpStr.simplifyWhiteSpace(); 1017 tmpStr.simplifyWhiteSpace();
999 tmpStr = tmpStr.upper(); 1018 tmpStr = tmpStr.upper();
1000 1019
1001 /********************************* DAILY ******************************/ 1020 /********************************* DAILY ******************************/
1002 if (tmpStr.left(1) == "D") { 1021 if (tmpStr.left(1) == "D") {
1003 int index = tmpStr.find(' '); 1022 int index = tmpStr.find(' ');
1004 int rFreq = tmpStr.mid(1, (index-1)).toInt(); 1023 int rFreq = tmpStr.mid(1, (index-1)).toInt();
1005 index = tmpStr.findRev(' ') + 1; // advance to last field 1024 index = tmpStr.findRev(' ') + 1; // advance to last field
1006 if (tmpStr.mid(index,1) == "#") index++; 1025 if (tmpStr.mid(index,1) == "#") index++;
1007 if (tmpStr.find('T', index) != -1) { 1026 if (tmpStr.find('T', index) != -1) {
1008 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1027 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1009 anEvent->recurrence()->setDaily(rFreq, rEndDate); 1028 anEvent->recurrence()->setDaily(rFreq, rEndDate);
1010 } else { 1029 } else {
1011 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1030 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1012 if (rDuration == 0) // VEvents set this to 0 forever, we use -1 1031 if (rDuration == 0) // VEvents set this to 0 forever, we use -1
1013 anEvent->recurrence()->setDaily(rFreq, -1); 1032 anEvent->recurrence()->setDaily(rFreq, -1);
1014 else 1033 else
1015 anEvent->recurrence()->setDaily(rFreq, rDuration); 1034 anEvent->recurrence()->setDaily(rFreq, rDuration);
1016 } 1035 }
1017 } 1036 }
1018 /********************************* WEEKLY ******************************/ 1037 /********************************* WEEKLY ******************************/
1019 else if (tmpStr.left(1) == "W") { 1038 else if (tmpStr.left(1) == "W") {
1020 int index = tmpStr.find(' '); 1039 int index = tmpStr.find(' ');
1021 int last = tmpStr.findRev(' ') + 1; 1040 int last = tmpStr.findRev(' ') + 1;
1022 int rFreq = tmpStr.mid(1, (index-1)).toInt(); 1041 int rFreq = tmpStr.mid(1, (index-1)).toInt();
1023 index += 1; // advance to beginning of stuff after freq 1042 index += 1; // advance to beginning of stuff after freq
1024 QBitArray qba(7); 1043 QBitArray qba(7);
1025 QString dayStr; 1044 QString dayStr;
1026 if( index == last ) { 1045 if( index == last ) {
1027 // e.g. W1 #0 1046 // e.g. W1 #0
1028 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); 1047 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1);
1029 } 1048 }
1030 else { 1049 else {
1031 // e.g. W1 SU #0 1050 // e.g. W1 SU #0
1032 while (index < last) { 1051 while (index < last) {
1033 dayStr = tmpStr.mid(index, 3); 1052 dayStr = tmpStr.mid(index, 3);
1034 int dayNum = numFromDay(dayStr); 1053 int dayNum = numFromDay(dayStr);
1035 qba.setBit(dayNum); 1054 qba.setBit(dayNum);
1036 index += 3; // advance to next day, or possibly "#" 1055 index += 3; // advance to next day, or possibly "#"
1037 } 1056 }
1038 } 1057 }
1039 index = last; if (tmpStr.mid(index,1) == "#") index++; 1058 index = last; if (tmpStr.mid(index,1) == "#") index++;
1040 if (tmpStr.find('T', index) != -1) { 1059 if (tmpStr.find('T', index) != -1) {
1041 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1060 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1042 anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); 1061 anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate);
1043 } else { 1062 } else {
1044 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1063 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1045 if (rDuration == 0) 1064 if (rDuration == 0)
1046 anEvent->recurrence()->setWeekly(rFreq, qba, -1); 1065 anEvent->recurrence()->setWeekly(rFreq, qba, -1);
1047 else 1066 else
1048 anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); 1067 anEvent->recurrence()->setWeekly(rFreq, qba, rDuration);
1049 } 1068 }
1050 } 1069 }
1051 /**************************** MONTHLY-BY-POS ***************************/ 1070 /**************************** MONTHLY-BY-POS ***************************/
1052 else if (tmpStr.left(2) == "MP") { 1071 else if (tmpStr.left(2) == "MP") {
1053 int index = tmpStr.find(' '); 1072 int index = tmpStr.find(' ');
1054 int last = tmpStr.findRev(' ') + 1; 1073 int last = tmpStr.findRev(' ') + 1;
1055 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1074 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1056 index += 1; // advance to beginning of stuff after freq 1075 index += 1; // advance to beginning of stuff after freq
1057 QBitArray qba(7); 1076 QBitArray qba(7);
1058 short tmpPos; 1077 short tmpPos;
1059 if( index == last ) { 1078 if( index == last ) {
1060 // e.g. MP1 #0 1079 // e.g. MP1 #0
1061 tmpPos = anEvent->dtStart().date().day()/7 + 1; 1080 tmpPos = anEvent->dtStart().date().day()/7 + 1;
1062 if( tmpPos == 5 ) 1081 if( tmpPos == 5 )
1063 tmpPos = -1; 1082 tmpPos = -1;
1064 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); 1083 qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1);
1065 anEvent->recurrence()->addMonthlyPos(tmpPos, qba); 1084 anEvent->recurrence()->addMonthlyPos(tmpPos, qba);
1066 } 1085 }
1067 else { 1086 else {
1068 // e.g. MP1 1+ SU #0 1087 // e.g. MP1 1+ SU #0
1069 while (index < last) { 1088 while (index < last) {
1070 tmpPos = tmpStr.mid(index,1).toShort(); 1089 tmpPos = tmpStr.mid(index,1).toShort();
1071 index += 1; 1090 index += 1;
1072 if (tmpStr.mid(index,1) == "-") 1091 if (tmpStr.mid(index,1) == "-")
1073 // convert tmpPos to negative 1092 // convert tmpPos to negative
1074 tmpPos = 0 - tmpPos; 1093 tmpPos = 0 - tmpPos;
1075 index += 2; // advance to day(s) 1094 index += 2; // advance to day(s)
1076 while (numFromDay(tmpStr.mid(index,3)) >= 0) { 1095 while (numFromDay(tmpStr.mid(index,3)) >= 0) {
1077 int dayNum = numFromDay(tmpStr.mid(index,3)); 1096 int dayNum = numFromDay(tmpStr.mid(index,3));
1078 qba.setBit(dayNum); 1097 qba.setBit(dayNum);
1079 index += 3; // advance to next day, or possibly pos or "#" 1098 index += 3; // advance to next day, or possibly pos or "#"
1080 } 1099 }
1081 anEvent->recurrence()->addMonthlyPos(tmpPos, qba); 1100 anEvent->recurrence()->addMonthlyPos(tmpPos, qba);
1082 qba.detach(); 1101 qba.detach();
1083 qba.fill(FALSE); // clear out 1102 qba.fill(FALSE); // clear out
1084 } // while != "#" 1103 } // while != "#"
1085 } 1104 }
1086 index = last; if (tmpStr.mid(index,1) == "#") index++; 1105 index = last; if (tmpStr.mid(index,1) == "#") index++;
1087 if (tmpStr.find('T', index) != -1) { 1106 if (tmpStr.find('T', index) != -1) {
1088 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - 1107 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() -
1089 index))).date(); 1108 index))).date();
1090 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); 1109 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate);
1091 } else { 1110 } else {
1092 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1111 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1093 if (rDuration == 0) 1112 if (rDuration == 0)
1094 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); 1113 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1);
1095 else 1114 else
1096 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); 1115 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration);
1097 } 1116 }
1098 } 1117 }
1099 1118
1100 /**************************** MONTHLY-BY-DAY ***************************/ 1119 /**************************** MONTHLY-BY-DAY ***************************/
1101 else if (tmpStr.left(2) == "MD") { 1120 else if (tmpStr.left(2) == "MD") {
1102 int index = tmpStr.find(' '); 1121 int index = tmpStr.find(' ');
1103 int last = tmpStr.findRev(' ') + 1; 1122 int last = tmpStr.findRev(' ') + 1;
1104 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1123 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1105 index += 1; 1124 index += 1;
1106 short tmpDay; 1125 short tmpDay;
1107 if( index == last ) { 1126 if( index == last ) {
1108 // e.g. MD1 #0 1127 // e.g. MD1 #0
1109 tmpDay = anEvent->dtStart().date().day(); 1128 tmpDay = anEvent->dtStart().date().day();
1110 anEvent->recurrence()->addMonthlyDay(tmpDay); 1129 anEvent->recurrence()->addMonthlyDay(tmpDay);
1111 } 1130 }
1112 else { 1131 else {
1113 // e.g. MD1 3 #0 1132 // e.g. MD1 3 #0
1114 while (index < last) { 1133 while (index < last) {
1115 int index2 = tmpStr.find(' ', index); 1134 int index2 = tmpStr.find(' ', index);
1116 tmpDay = tmpStr.mid(index, (index2-index)).toShort(); 1135 tmpDay = tmpStr.mid(index, (index2-index)).toShort();
1117 index = index2-1; 1136 index = index2-1;
1118 if (tmpStr.mid(index, 1) == "-") 1137 if (tmpStr.mid(index, 1) == "-")
1119 tmpDay = 0 - tmpDay; 1138 tmpDay = 0 - tmpDay;
1120 index += 2; // advance the index; 1139 index += 2; // advance the index;
1121 anEvent->recurrence()->addMonthlyDay(tmpDay); 1140 anEvent->recurrence()->addMonthlyDay(tmpDay);
1122 } // while != # 1141 } // while != #
1123 } 1142 }
1124 index = last; if (tmpStr.mid(index,1) == "#") index++; 1143 index = last; if (tmpStr.mid(index,1) == "#") index++;
1125 if (tmpStr.find('T', index) != -1) { 1144 if (tmpStr.find('T', index) != -1) {
1126 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1145 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1127 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); 1146 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate);
1128 } else { 1147 } else {
1129 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1148 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1130 if (rDuration == 0) 1149 if (rDuration == 0)
1131 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); 1150 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1);
1132 else 1151 else
1133 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); 1152 anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration);
1134 } 1153 }
1135 } 1154 }
1136 1155
1137 /*********************** YEARLY-BY-MONTH *******************************/ 1156 /*********************** YEARLY-BY-MONTH *******************************/
1138 else if (tmpStr.left(2) == "YM") { 1157 else if (tmpStr.left(2) == "YM") {
1139 int index = tmpStr.find(' '); 1158 int index = tmpStr.find(' ');
1140 int last = tmpStr.findRev(' ') + 1; 1159 int last = tmpStr.findRev(' ') + 1;
1141 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1160 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1142 index += 1; 1161 index += 1;
1143 short tmpMonth; 1162 short tmpMonth;
1144 if( index == last ) { 1163 if( index == last ) {
1145 // e.g. YM1 #0 1164 // e.g. YM1 #0
1146 tmpMonth = anEvent->dtStart().date().month(); 1165 tmpMonth = anEvent->dtStart().date().month();
1147 anEvent->recurrence()->addYearlyNum(tmpMonth); 1166 anEvent->recurrence()->addYearlyNum(tmpMonth);
1148 } 1167 }
1149 else { 1168 else {
1150 // e.g. YM1 3 #0 1169 // e.g. YM1 3 #0
1151 while (index < last) { 1170 while (index < last) {
1152 int index2 = tmpStr.find(' ', index); 1171 int index2 = tmpStr.find(' ', index);
1153 tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); 1172 tmpMonth = tmpStr.mid(index, (index2-index)).toShort();
1154 index = index2+1; 1173 index = index2+1;
1155 anEvent->recurrence()->addYearlyNum(tmpMonth); 1174 anEvent->recurrence()->addYearlyNum(tmpMonth);
1156 } // while != # 1175 } // while != #
1157 } 1176 }
1158 index = last; if (tmpStr.mid(index,1) == "#") index++; 1177 index = last; if (tmpStr.mid(index,1) == "#") index++;
1159 if (tmpStr.find('T', index) != -1) { 1178 if (tmpStr.find('T', index) != -1) {
1160 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1179 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1161 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); 1180 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate);
1162 } else { 1181 } else {
1163 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1182 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1164 if (rDuration == 0) 1183 if (rDuration == 0)
1165 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); 1184 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1);
1166 else 1185 else
1167 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); 1186 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration);
1168 } 1187 }
1169 } 1188 }
1170 1189
1171 /*********************** YEARLY-BY-DAY *********************************/ 1190 /*********************** YEARLY-BY-DAY *********************************/
1172 else if (tmpStr.left(2) == "YD") { 1191 else if (tmpStr.left(2) == "YD") {
1173 int index = tmpStr.find(' '); 1192 int index = tmpStr.find(' ');
1174 int last = tmpStr.findRev(' ') + 1; 1193 int last = tmpStr.findRev(' ') + 1;
1175 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1194 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1176 index += 1; 1195 index += 1;
1177 short tmpDay; 1196 short tmpDay;
1178 if( index == last ) { 1197 if( index == last ) {
1179 // e.g. YD1 #0 1198 // e.g. YD1 #0
1180 tmpDay = anEvent->dtStart().date().dayOfYear(); 1199 tmpDay = anEvent->dtStart().date().dayOfYear();
1181 anEvent->recurrence()->addYearlyNum(tmpDay); 1200 anEvent->recurrence()->addYearlyNum(tmpDay);
1182 } 1201 }
1183 else { 1202 else {
1184 // e.g. YD1 123 #0 1203 // e.g. YD1 123 #0
1185 while (index < last) { 1204 while (index < last) {
1186 int index2 = tmpStr.find(' ', index); 1205 int index2 = tmpStr.find(' ', index);
1187 tmpDay = tmpStr.mid(index, (index2-index)).toShort(); 1206 tmpDay = tmpStr.mid(index, (index2-index)).toShort();
1188 index = index2+1; 1207 index = index2+1;
1189 anEvent->recurrence()->addYearlyNum(tmpDay); 1208 anEvent->recurrence()->addYearlyNum(tmpDay);
1190 } // while != # 1209 } // while != #
1191 } 1210 }
1192 index = last; if (tmpStr.mid(index,1) == "#") index++; 1211 index = last; if (tmpStr.mid(index,1) == "#") index++;
1193 if (tmpStr.find('T', index) != -1) { 1212 if (tmpStr.find('T', index) != -1) {
1194 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); 1213 QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date();
1195 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); 1214 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate);
1196 } else { 1215 } else {
1197 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1216 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1198 if (rDuration == 0) 1217 if (rDuration == 0)
1199 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); 1218 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1);
1200 else 1219 else
1201 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); 1220 anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration);
1202 } 1221 }
1203 } else { 1222 } else {
1204 kdDebug(5800) << "we don't understand this type of recurrence!" << endl; 1223 kdDebug(5800) << "we don't understand this type of recurrence!" << endl;
1205 } // if 1224 } // if
1206 } // repeats 1225 } // repeats
1207 1226
1208 1227
1209 // recurrence exceptions 1228 // recurrence exceptions
1210 if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { 1229 if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) {
1211 s = fakeCString(vObjectUStringZValue(vo)); 1230 s = fakeCString(vObjectUStringZValue(vo));
1212 QStringList exDates = QStringList::split(",",s); 1231 QStringList exDates = QStringList::split(",",s);
1213 QStringList::ConstIterator it; 1232 QStringList::ConstIterator it;
1214 for(it = exDates.begin(); it != exDates.end(); ++it ) { 1233 for(it = exDates.begin(); it != exDates.end(); ++it ) {
1215 anEvent->addExDate(ISOToQDate(*it)); 1234 anEvent->addExDate(ISOToQDate(*it));
1216 } 1235 }
1217 deleteStr(s); 1236 deleteStr(s);
1218 } 1237 }
1219 1238
1220 // summary 1239 // summary
1221 if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { 1240 if ((vo = isAPropertyOf(vevent, VCSummaryProp))) {
1222 s = fakeCString(vObjectUStringZValue(vo)); 1241 s = fakeCString(vObjectUStringZValue(vo));
1223 anEvent->setSummary(QString::fromLocal8Bit(s)); 1242 anEvent->setSummary(QString::fromLocal8Bit(s));
1224 deleteStr(s); 1243 deleteStr(s);
1225 } 1244 }
1226 if ((vo = isAPropertyOf(vevent, VCLocationProp))) { 1245 if ((vo = isAPropertyOf(vevent, VCLocationProp))) {
1227 s = fakeCString(vObjectUStringZValue(vo)); 1246 s = fakeCString(vObjectUStringZValue(vo));
1228 anEvent->setLocation(QString::fromLocal8Bit(s)); 1247 anEvent->setLocation(QString::fromLocal8Bit(s));
1229 deleteStr(s); 1248 deleteStr(s);
1230 } 1249 }
1231 1250
1232 // description 1251 // description
1233 if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { 1252 if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) {
1234 s = fakeCString(vObjectUStringZValue(vo)); 1253 s = fakeCString(vObjectUStringZValue(vo));
1235 if (!anEvent->description().isEmpty()) { 1254 if (!anEvent->description().isEmpty()) {
1236 anEvent->setDescription(anEvent->description() + "\n" + 1255 anEvent->setDescription(anEvent->description() + "\n" +
1237 QString::fromLocal8Bit(s)); 1256 QString::fromLocal8Bit(s));
1238 } else { 1257 } else {
1239 anEvent->setDescription(QString::fromLocal8Bit(s)); 1258 anEvent->setDescription(QString::fromLocal8Bit(s));
1240 } 1259 }
1241 deleteStr(s); 1260 deleteStr(s);
1242 } 1261 }
1243 1262
1244 // some stupid vCal exporters ignore the standard and use Description 1263 // some stupid vCal exporters ignore the standard and use Description
1245 // instead of Summary for the default field. Correct for this. 1264 // instead of Summary for the default field. Correct for this.
1246 if (anEvent->summary().isEmpty() && 1265 if (anEvent->summary().isEmpty() &&
1247 !(anEvent->description().isEmpty())) { 1266 !(anEvent->description().isEmpty())) {
1248 QString tmpStr = anEvent->description().simplifyWhiteSpace(); 1267 QString tmpStr = anEvent->description().simplifyWhiteSpace();
1249 anEvent->setDescription(""); 1268 anEvent->setDescription("");
1250 anEvent->setSummary(tmpStr); 1269 anEvent->setSummary(tmpStr);
1251 } 1270 }
1252 1271
1253#if 0 1272#if 0
1254 // status 1273 // status
1255 if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { 1274 if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) {
1256 QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); 1275 QString tmpStr(s = fakeCString(vObjectUStringZValue(vo)));
1257 deleteStr(s); 1276 deleteStr(s);
1258// TODO: Define Event status 1277// TODO: Define Event status
1259// anEvent->setStatus(tmpStr); 1278// anEvent->setStatus(tmpStr);
1260 } 1279 }
1261 else 1280 else
1262// anEvent->setStatus("NEEDS ACTION"); 1281// anEvent->setStatus("NEEDS ACTION");
1263#endif 1282#endif
1264 1283
1265 // secrecy 1284 // secrecy
1266 int secrecy = Incidence::SecrecyPublic; 1285 int secrecy = Incidence::SecrecyPublic;
1267 if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { 1286 if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) {
1268 s = fakeCString(vObjectUStringZValue(vo)); 1287 s = fakeCString(vObjectUStringZValue(vo));
1269 if (strcmp(s,"PRIVATE") == 0) { 1288 if (strcmp(s,"PRIVATE") == 0) {
1270 secrecy = Incidence::SecrecyPrivate; 1289 secrecy = Incidence::SecrecyPrivate;
1271 } else if (strcmp(s,"CONFIDENTIAL") == 0) { 1290 } else if (strcmp(s,"CONFIDENTIAL") == 0) {
1272 secrecy = Incidence::SecrecyConfidential; 1291 secrecy = Incidence::SecrecyConfidential;
1273 } 1292 }
1274 deleteStr(s); 1293 deleteStr(s);
1275 } 1294 }
1276 anEvent->setSecrecy(secrecy); 1295 anEvent->setSecrecy(secrecy);
1277 1296
1278 // categories 1297 // categories
1279 QStringList tmpStrList; 1298 QStringList tmpStrList;
1280 int index1 = 0; 1299 int index1 = 0;
1281 int index2 = 0; 1300 int index2 = 0;
1282 if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { 1301 if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) {
1283 s = fakeCString(vObjectUStringZValue(vo)); 1302 s = fakeCString(vObjectUStringZValue(vo));
1284 QString categories = QString::fromLocal8Bit(s); 1303 QString categories = QString::fromLocal8Bit(s);
1285 deleteStr(s); 1304 deleteStr(s);
1286 //const char* category; 1305 //const char* category;
1287 QString category; 1306 QString category;
1288 while ((index2 = categories.find(',', index1)) != -1) { 1307 while ((index2 = categories.find(',', index1)) != -1) {
1289 //category = (const char *) categories.mid(index1, (index2 - index1)); 1308 //category = (const char *) categories.mid(index1, (index2 - index1));
1290 category = categories.mid(index1, (index2 - index1)); 1309 category = categories.mid(index1, (index2 - index1));
1291 tmpStrList.append(category); 1310 tmpStrList.append(category);
1292 index1 = index2+1; 1311 index1 = index2+1;
1293 } 1312 }
1294 // get last category 1313 // get last category
1295 category = categories.mid(index1, (categories.length()-index1)); 1314 category = categories.mid(index1, (categories.length()-index1));
1296 tmpStrList.append(category); 1315 tmpStrList.append(category);
1297 anEvent->setCategories(tmpStrList); 1316 anEvent->setCategories(tmpStrList);
1298 } 1317 }
1299 1318
1300 // attachments 1319 // attachments
1301 tmpStrList.clear(); 1320 tmpStrList.clear();
1302 initPropIterator(&voi, vevent); 1321 initPropIterator(&voi, vevent);
1303 while (moreIteration(&voi)) { 1322 while (moreIteration(&voi)) {
1304 vo = nextVObject(&voi); 1323 vo = nextVObject(&voi);
1305 if (strcmp(vObjectName(vo), VCAttachProp) == 0) { 1324 if (strcmp(vObjectName(vo), VCAttachProp) == 0) {
1306 s = fakeCString(vObjectUStringZValue(vo)); 1325 s = fakeCString(vObjectUStringZValue(vo));
1307 anEvent->addAttachment(new Attachment(QString(s))); 1326 anEvent->addAttachment(new Attachment(QString(s)));
1308 deleteStr(s); 1327 deleteStr(s);
1309 } 1328 }
1310 } 1329 }
1311 1330
1312 // resources 1331 // resources
1313 if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { 1332 if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) {
1314 QString resources = (s = fakeCString(vObjectUStringZValue(vo))); 1333 QString resources = (s = fakeCString(vObjectUStringZValue(vo)));
1315 deleteStr(s); 1334 deleteStr(s);
1316 tmpStrList.clear(); 1335 tmpStrList.clear();
1317 index1 = 0; 1336 index1 = 0;
1318 index2 = 0; 1337 index2 = 0;
1319 QString resource; 1338 QString resource;
1320 while ((index2 = resources.find(';', index1)) != -1) { 1339 while ((index2 = resources.find(';', index1)) != -1) {
1321 resource = resources.mid(index1, (index2 - index1)); 1340 resource = resources.mid(index1, (index2 - index1));
1322 tmpStrList.append(resource); 1341 tmpStrList.append(resource);
1323 index1 = index2; 1342 index1 = index2;
1324 } 1343 }
1325 anEvent->setResources(tmpStrList); 1344 anEvent->setResources(tmpStrList);
1326 } 1345 }
1327 1346
1328 /* alarm stuff */ 1347 /* alarm stuff */
1329 if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { 1348 if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) {
1330 Alarm* alarm = anEvent->newAlarm(); 1349 Alarm* alarm = anEvent->newAlarm();
1331 VObject *a; 1350 VObject *a;
1332 if ((a = isAPropertyOf(vo, VCRunTimeProp))) { 1351 if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
1333 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); 1352 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a))));
1334 deleteStr(s); 1353 deleteStr(s);
1335 } 1354 }
1336 alarm->setEnabled(true); 1355 alarm->setEnabled(true);
1337 if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { 1356 if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) {
1338 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { 1357 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
1339 s = fakeCString(vObjectUStringZValue(a)); 1358 s = fakeCString(vObjectUStringZValue(a));
1340 alarm->setProcedureAlarm(QFile::decodeName(s)); 1359 alarm->setProcedureAlarm(QFile::decodeName(s));
1341 deleteStr(s); 1360 deleteStr(s);
1342 } 1361 }
1343 } 1362 }
1344 if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { 1363 if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) {
1345 if ((a = isAPropertyOf(vo, VCAudioContentProp))) { 1364 if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
1346 s = fakeCString(vObjectUStringZValue(a)); 1365 s = fakeCString(vObjectUStringZValue(a));
1347 alarm->setAudioAlarm(QFile::decodeName(s)); 1366 alarm->setAudioAlarm(QFile::decodeName(s));
1348 deleteStr(s); 1367 deleteStr(s);
1349 } 1368 }
1350 } 1369 }
1351 } 1370 }
1352 1371
1353 // priority 1372 // priority
1354 if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { 1373 if ((vo = isAPropertyOf(vevent, VCPriorityProp))) {
1355 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1374 anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1356 deleteStr(s); 1375 deleteStr(s);
1357 } 1376 }
1358 1377
1359 // transparency 1378 // transparency
1360 if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { 1379 if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) {
1361 int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); 1380 int i = atoi(s = fakeCString(vObjectUStringZValue(vo)));
1362 anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); 1381 anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque );
1363 deleteStr(s); 1382 deleteStr(s);
1364 } 1383 }
1365 1384
1366 // related event 1385 // related event
1367 if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { 1386 if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) {
1368 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); 1387 anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo)));
1369 deleteStr(s); 1388 deleteStr(s);
1370 mEventsRelate.append(anEvent); 1389 mEventsRelate.append(anEvent);
1371 } 1390 }
1372 1391
1373 /* PILOT SYNC STUFF */ 1392 /* PILOT SYNC STUFF */
1374 if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { 1393 if ((vo = isAPropertyOf(vevent, XPilotIdProp))) {
1375 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1394 anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1376 deleteStr(s); 1395 deleteStr(s);
1377 } 1396 }
1378 else 1397 else
1379 anEvent->setPilotId(0); 1398 anEvent->setPilotId(0);
1380 1399
1381 if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { 1400 if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) {
1382 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 1401 anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo))));
1383 deleteStr(s); 1402 deleteStr(s);
1384 } 1403 }
1385 else 1404 else
1386 anEvent->setSyncStatus(Event::SYNCMOD); 1405 anEvent->setSyncStatus(Event::SYNCMOD);
1387 1406
1388 return anEvent; 1407 return anEvent;
1389} 1408}
1390 1409
1391 1410
1392QString VCalFormat::qDateToISO(const QDate &qd) 1411QString VCalFormat::qDateToISO(const QDate &qd)
1393{ 1412{
1394 QString tmpStr; 1413 QString tmpStr;
1395 1414
1396 ASSERT(qd.isValid()); 1415 ASSERT(qd.isValid());
1397 1416
1398 tmpStr.sprintf("%.2d%.2d%.2d", 1417 tmpStr.sprintf("%.2d%.2d%.2d",
1399 qd.year(), qd.month(), qd.day()); 1418 qd.year(), qd.month(), qd.day());
1400 return tmpStr; 1419 return tmpStr;
1401 1420
1402} 1421}
1403 1422
1404QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) 1423QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu)
1405{ 1424{
1406 QString tmpStr; 1425 QString tmpStr;
1407 1426
1408 ASSERT(qdt.date().isValid()); 1427 ASSERT(qdt.date().isValid());
1409 ASSERT(qdt.time().isValid()); 1428 ASSERT(qdt.time().isValid());
1410 if (zulu) { 1429 if (zulu) {
1411 QDateTime tmpDT(qdt); 1430 QDateTime tmpDT(qdt);
1412 tmpDT = tmpDT.addSecs(60*(-mCalendar->getTimeZone())); // correct to GMT. 1431 tmpDT = tmpDT.addSecs(60*(-mCalendar->getTimeZone())); // correct to GMT.
1413 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", 1432 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ",
1414 tmpDT.date().year(), tmpDT.date().month(), 1433 tmpDT.date().year(), tmpDT.date().month(),
1415 tmpDT.date().day(), tmpDT.time().hour(), 1434 tmpDT.date().day(), tmpDT.time().hour(),
1416 tmpDT.time().minute(), tmpDT.time().second()); 1435 tmpDT.time().minute(), tmpDT.time().second());
1417 } else { 1436 } else {
1418 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", 1437 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d",
1419 qdt.date().year(), qdt.date().month(), 1438 qdt.date().year(), qdt.date().month(),
1420 qdt.date().day(), qdt.time().hour(), 1439 qdt.date().day(), qdt.time().hour(),
1421 qdt.time().minute(), qdt.time().second()); 1440 qdt.time().minute(), qdt.time().second());
1422 } 1441 }
1423 return tmpStr; 1442 return tmpStr;
1424} 1443}
1425 1444
1426QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) 1445QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr)
1427{ 1446{
1428 QDate tmpDate; 1447 QDate tmpDate;
1429 QTime tmpTime; 1448 QTime tmpTime;
1430 QString tmpStr; 1449 QString tmpStr;
1431 int year, month, day, hour, minute, second; 1450 int year, month, day, hour, minute, second;
1432 1451
1433 tmpStr = dtStr; 1452 tmpStr = dtStr;
1434 year = tmpStr.left(4).toInt(); 1453 year = tmpStr.left(4).toInt();
1435 month = tmpStr.mid(4,2).toInt(); 1454 month = tmpStr.mid(4,2).toInt();
1436 day = tmpStr.mid(6,2).toInt(); 1455 day = tmpStr.mid(6,2).toInt();
1437 hour = tmpStr.mid(9,2).toInt(); 1456 hour = tmpStr.mid(9,2).toInt();
1438 minute = tmpStr.mid(11,2).toInt(); 1457 minute = tmpStr.mid(11,2).toInt();
1439 second = tmpStr.mid(13,2).toInt(); 1458 second = tmpStr.mid(13,2).toInt();
1440 tmpDate.setYMD(year, month, day); 1459 tmpDate.setYMD(year, month, day);
1441 tmpTime.setHMS(hour, minute, second); 1460 tmpTime.setHMS(hour, minute, second);
1442 1461
1443 ASSERT(tmpDate.isValid()); 1462 ASSERT(tmpDate.isValid());
1444 ASSERT(tmpTime.isValid()); 1463 ASSERT(tmpTime.isValid());
1445 QDateTime tmpDT(tmpDate, tmpTime); 1464 QDateTime tmpDT(tmpDate, tmpTime);
1446 // correct for GMT if string is in Zulu format 1465 // correct for GMT if string is in Zulu format
1447 if (dtStr.at(dtStr.length()-1) == 'Z') 1466 if (dtStr.at(dtStr.length()-1) == 'Z')
1448 tmpDT = tmpDT.addSecs(60*mCalendar->getTimeZone()); 1467 tmpDT = tmpDT.addSecs(60*mCalendar->getTimeZone());
1449 return tmpDT; 1468 return tmpDT;
1450} 1469}
1451 1470
1452QDate VCalFormat::ISOToQDate(const QString &dateStr) 1471QDate VCalFormat::ISOToQDate(const QString &dateStr)
1453{ 1472{
1454 int year, month, day; 1473 int year, month, day;
1455 1474
1456 year = dateStr.left(4).toInt(); 1475 year = dateStr.left(4).toInt();
1457 month = dateStr.mid(4,2).toInt(); 1476 month = dateStr.mid(4,2).toInt();
1458 day = dateStr.mid(6,2).toInt(); 1477 day = dateStr.mid(6,2).toInt();
1459 1478
1460 return(QDate(year, month, day)); 1479 return(QDate(year, month, day));
1461} 1480}
1462 1481
1463// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. 1482// take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc.
1464// and break it down from it's tree-like format into the dictionary format 1483// and break it down from it's tree-like format into the dictionary format
1465// that is used internally in the VCalFormat. 1484// that is used internally in the VCalFormat.
1466void VCalFormat::populate(VObject *vcal) 1485void VCalFormat::populate(VObject *vcal)
1467{ 1486{
1468 // this function will populate the caldict dictionary and other event 1487 // this function will populate the caldict dictionary and other event
1469 // lists. It turns vevents into Events and then inserts them. 1488 // lists. It turns vevents into Events and then inserts them.
1470 1489
1471 VObjectIterator i; 1490 VObjectIterator i;
1472 VObject *curVO, *curVOProp; 1491 VObject *curVO, *curVOProp;
1473 Event *anEvent; 1492 Event *anEvent;
1474 1493
1475 if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { 1494 if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) {
1476 char *methodType = 0; 1495 char *methodType = 0;
1477 methodType = fakeCString(vObjectUStringZValue(curVO)); 1496 methodType = fakeCString(vObjectUStringZValue(curVO));
1478 kdDebug() << "This calendar is an iTIP transaction of type '" 1497 kdDebug() << "This calendar is an iTIP transaction of type '"
1479 << methodType << "'" << endl; 1498 << methodType << "'" << endl;
1480 delete methodType; 1499 delete methodType;
1481 } 1500 }
1482 1501
1483 // warn the user that we might have trouble reading non-known calendar. 1502 // warn the user that we might have trouble reading non-known calendar.
1484 if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { 1503 if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) {
1485 char *s = fakeCString(vObjectUStringZValue(curVO)); 1504 char *s = fakeCString(vObjectUStringZValue(curVO));
1486 if (strcmp(productId().local8Bit(), s) != 0) 1505 if (strcmp(productId().local8Bit(), s) != 0)
1487 kdDebug() << "This vCalendar file was not created by KOrganizer " 1506 kdDebug() << "This vCalendar file was not created by KOrganizer "
1488 "or any other product we support. Loading anyway..." << endl; 1507 "or any other product we support. Loading anyway..." << endl;
1489 mLoadedProductId = s; 1508 mLoadedProductId = s;
1490 deleteStr(s); 1509 deleteStr(s);
1491 } 1510 }
1492 1511
1493 // warn the user we might have trouble reading this unknown version. 1512 // warn the user we might have trouble reading this unknown version.
1494 if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { 1513 if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) {
1495 char *s = fakeCString(vObjectUStringZValue(curVO)); 1514 char *s = fakeCString(vObjectUStringZValue(curVO));
1496 if (strcmp(_VCAL_VERSION, s) != 0) 1515 if (strcmp(_VCAL_VERSION, s) != 0)
1497 kdDebug() << "This vCalendar file has version " << s 1516 kdDebug() << "This vCalendar file has version " << s
1498 << "We only support " << _VCAL_VERSION << endl; 1517 << "We only support " << _VCAL_VERSION << endl;
1499 deleteStr(s); 1518 deleteStr(s);
1500 } 1519 }
1501 1520
1502 // set the time zone 1521 // set the time zone
1503 if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { 1522 if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) {
1504 char *s = fakeCString(vObjectUStringZValue(curVO)); 1523 char *s = fakeCString(vObjectUStringZValue(curVO));
1505 mCalendar->setTimeZone(s); 1524 mCalendar->setTimeZone(s);
1506 deleteStr(s); 1525 deleteStr(s);
1507 } 1526 }
1508 1527
1509 1528
1510 // Store all events with a relatedTo property in a list for post-processing 1529 // Store all events with a relatedTo property in a list for post-processing
1511 mEventsRelate.clear(); 1530 mEventsRelate.clear();
1512 mTodosRelate.clear(); 1531 mTodosRelate.clear();
1513 1532
1514 initPropIterator(&i, vcal); 1533 initPropIterator(&i, vcal);
1515 1534
1516 // go through all the vobjects in the vcal 1535 // go through all the vobjects in the vcal
1517 while (moreIteration(&i)) { 1536 while (moreIteration(&i)) {
1518 curVO = nextVObject(&i); 1537 curVO = nextVObject(&i);
1519 1538
1520 /************************************************************************/ 1539 /************************************************************************/
1521 1540
1522 // now, check to see that the object is an event or todo. 1541 // now, check to see that the object is an event or todo.
1523 if (strcmp(vObjectName(curVO), VCEventProp) == 0) { 1542 if (strcmp(vObjectName(curVO), VCEventProp) == 0) {
1524 1543
1525 if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { 1544 if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) {
1526 char *s; 1545 char *s;
1527 s = fakeCString(vObjectUStringZValue(curVOProp)); 1546 s = fakeCString(vObjectUStringZValue(curVOProp));
1528 // check to see if event was deleted by the kpilot conduit 1547 // check to see if event was deleted by the kpilot conduit
1529 if (atoi(s) == Event::SYNCDEL) { 1548 if (atoi(s) == Event::SYNCDEL) {
1530 deleteStr(s); 1549 deleteStr(s);
1531 kdDebug(5800) << "skipping pilot-deleted event" << endl; 1550 kdDebug(5800) << "skipping pilot-deleted event" << endl;
1532 goto SKIP; 1551 goto SKIP;
1533 } 1552 }
1534 deleteStr(s); 1553 deleteStr(s);
1535 } 1554 }
1536 1555
1537 // this code checks to see if we are trying to read in an event 1556 // this code checks to see if we are trying to read in an event
1538 // that we already find to be in the calendar. If we find this 1557 // that we already find to be in the calendar. If we find this
1539 // to be the case, we skip the event. 1558 // to be the case, we skip the event.
1540 if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { 1559 if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) {
1541 char *s = fakeCString(vObjectUStringZValue(curVOProp)); 1560 char *s = fakeCString(vObjectUStringZValue(curVOProp));
1542 QString tmpStr(s); 1561 QString tmpStr(s);
1543 deleteStr(s); 1562 deleteStr(s);
1544 1563
1545 if (mCalendar->event(tmpStr)) { 1564 if (mCalendar->event(tmpStr)) {
1546 goto SKIP; 1565 goto SKIP;
1547 } 1566 }
1548 if (mCalendar->todo(tmpStr)) { 1567 if (mCalendar->todo(tmpStr)) {
1549 goto SKIP; 1568 goto SKIP;
1550 } 1569 }
1551 } 1570 }
1552 1571
1553 if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && 1572 if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) &&
1554 (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { 1573 (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) {
1555 kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; 1574 kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl;
1556 goto SKIP; 1575 goto SKIP;
1557 } 1576 }
1558 1577
1559 anEvent = VEventToEvent(curVO); 1578 anEvent = VEventToEvent(curVO);
1560 // we now use addEvent instead of insertEvent so that the 1579 // we now use addEvent instead of insertEvent so that the
1561 // signal/slot get connected. 1580 // signal/slot get connected.
1562 if (anEvent) { 1581 if (anEvent) {
1563 if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { 1582 if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) {
1564 kdDebug() << "VCalFormat::populate(): Event has invalid dates." 1583 kdDebug() << "VCalFormat::populate(): Event has invalid dates."
1565 << endl; 1584 << endl;
1566 } else { 1585 } else {
1567 mCalendar->addEvent(anEvent); 1586 mCalendar->addEvent(anEvent);
1568 } 1587 }
1569 } else { 1588 } else {
1570 // some sort of error must have occurred while in translation. 1589 // some sort of error must have occurred while in translation.
1571 goto SKIP; 1590 goto SKIP;
1572 } 1591 }
1573 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { 1592 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) {
1574 Todo *aTodo = VTodoToEvent(curVO); 1593 Todo *aTodo = VTodoToEvent(curVO);
1575 mCalendar->addTodo(aTodo); 1594 mCalendar->addTodo(aTodo);
1576 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || 1595 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) ||
1577 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || 1596 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) ||
1578 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { 1597 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) {
1579 // do nothing, we know these properties and we want to skip them. 1598 // do nothing, we know these properties and we want to skip them.
1580 // we have either already processed them or are ignoring them. 1599 // we have either already processed them or are ignoring them.
1581 ; 1600 ;
1582 } else { 1601 } else {
1583 kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; 1602 kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl;
1584 } 1603 }
1585 SKIP: 1604 SKIP:
1586 ; 1605 ;
1587 } // while 1606 } // while
1588 1607
1589 // Post-Process list of events with relations, put Event objects in relation 1608 // Post-Process list of events with relations, put Event objects in relation
1590 Event *ev; 1609 Event *ev;
1591 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { 1610 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) {
1592 ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); 1611 ev->setRelatedTo(mCalendar->event(ev->relatedToUid()));
1593 } 1612 }
1594 Todo *todo; 1613 Todo *todo;
1595 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { 1614 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) {
1596 todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); 1615 todo->setRelatedTo(mCalendar->todo(todo->relatedToUid()));
1597 } 1616 }
1598} 1617}
1599 1618
1600const char *VCalFormat::dayFromNum(int day) 1619const char *VCalFormat::dayFromNum(int day)
1601{ 1620{
1602 const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; 1621 const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " };
1603 1622
1604 return days[day]; 1623 return days[day];
1605} 1624}
1606 1625
1607int VCalFormat::numFromDay(const QString &day) 1626int VCalFormat::numFromDay(const QString &day)
1608{ 1627{
1609 if (day == "MO ") return 0; 1628 if (day == "MO ") return 0;
1610 if (day == "TU ") return 1; 1629 if (day == "TU ") return 1;
1611 if (day == "WE ") return 2; 1630 if (day == "WE ") return 2;
1612 if (day == "TH ") return 3; 1631 if (day == "TH ") return 3;
1613 if (day == "FR ") return 4; 1632 if (day == "FR ") return 4;
1614 if (day == "SA ") return 5; 1633 if (day == "SA ") return 5;
1615 if (day == "SU ") return 6; 1634 if (day == "SU ") return 6;
1616 1635
1617 return -1; // something bad happened. :) 1636 return -1; // something bad happened. :)
1618} 1637}
1619 1638
1620Attendee::PartStat VCalFormat::readStatus(const char *s) const 1639Attendee::PartStat VCalFormat::readStatus(const char *s) const
1621{ 1640{
1622 QString statStr = s; 1641 QString statStr = s;
1623 statStr = statStr.upper(); 1642 statStr = statStr.upper();
1624 Attendee::PartStat status; 1643 Attendee::PartStat status;
1625 1644
1626 if (statStr == "X-ACTION") 1645 if (statStr == "X-ACTION")
1627 status = Attendee::NeedsAction; 1646 status = Attendee::NeedsAction;
1628 else if (statStr == "NEEDS ACTION") 1647 else if (statStr == "NEEDS ACTION")
1629 status = Attendee::NeedsAction; 1648 status = Attendee::NeedsAction;
1630 else if (statStr== "ACCEPTED") 1649 else if (statStr== "ACCEPTED")
1631 status = Attendee::Accepted; 1650 status = Attendee::Accepted;
1632 else if (statStr== "SENT") 1651 else if (statStr== "SENT")
1633 status = Attendee::NeedsAction; 1652 status = Attendee::NeedsAction;
1634 else if (statStr== "TENTATIVE") 1653 else if (statStr== "TENTATIVE")
1635 status = Attendee::Tentative; 1654 status = Attendee::Tentative;
1636 else if (statStr== "CONFIRMED") 1655 else if (statStr== "CONFIRMED")
1637 status = Attendee::Accepted; 1656 status = Attendee::Accepted;
1638 else if (statStr== "DECLINED") 1657 else if (statStr== "DECLINED")
1639 status = Attendee::Declined; 1658 status = Attendee::Declined;
1640 else if (statStr== "COMPLETED") 1659 else if (statStr== "COMPLETED")
1641 status = Attendee::Completed; 1660 status = Attendee::Completed;
1642 else if (statStr== "DELEGATED") 1661 else if (statStr== "DELEGATED")
1643 status = Attendee::Delegated; 1662 status = Attendee::Delegated;
1644 else { 1663 else {
1645 kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; 1664 kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl;
1646 status = Attendee::NeedsAction; 1665 status = Attendee::NeedsAction;
1647 } 1666 }
1648 1667
1649 return status; 1668 return status;
1650} 1669}
1651 1670
1652QCString VCalFormat::writeStatus(Attendee::PartStat status) const 1671QCString VCalFormat::writeStatus(Attendee::PartStat status) const
1653{ 1672{
1654 switch(status) { 1673 switch(status) {
1655 default: 1674 default:
1656 case Attendee::NeedsAction: 1675 case Attendee::NeedsAction:
1657 return "NEEDS ACTION"; 1676 return "NEEDS ACTION";
1658 break; 1677 break;
1659 case Attendee::Accepted: 1678 case Attendee::Accepted:
1660 return "ACCEPTED"; 1679 return "ACCEPTED";
1661 break; 1680 break;
1662 case Attendee::Declined: 1681 case Attendee::Declined:
1663 return "DECLINED"; 1682 return "DECLINED";
1664 break; 1683 break;
1665 case Attendee::Tentative: 1684 case Attendee::Tentative:
1666 return "TENTATIVE"; 1685 return "TENTATIVE";
1667 break; 1686 break;
1668 case Attendee::Delegated: 1687 case Attendee::Delegated:
1669 return "DELEGATED"; 1688 return "DELEGATED";
1670 break; 1689 break;
1671 case Attendee::Completed: 1690 case Attendee::Completed:
1672 return "COMPLETED"; 1691 return "COMPLETED";
1673 break; 1692 break;
1674 case Attendee::InProcess: 1693 case Attendee::InProcess:
1675 return "NEEDS ACTION"; 1694 return "NEEDS ACTION";
1676 break; 1695 break;
1677 } 1696 }
1678} 1697}
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index d4cecbc..8490125 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -1,108 +1,110 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef _VCALFORMAT_H 22#ifndef _VCALFORMAT_H
23#define _VCALFORMAT_H 23#define _VCALFORMAT_H
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#define _VCAL_VERSION "1.0" 27#define _VCAL_VERSION "1.0"
28 28
29class VObject; 29class VObject;
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 This class implements the vCalendar format. It provides methods for 34 This class implements the vCalendar format. It provides methods for
35 loading/saving/converting vCalendar format data into the internal KOrganizer 35 loading/saving/converting vCalendar format data into the internal KOrganizer
36 representation as Calendar and Events. 36 representation as Calendar and Events.
37 37
38 @short vCalendar format implementation 38 @short vCalendar format implementation
39*/ 39*/
40class VCalFormat : public CalFormat { 40class VCalFormat : public CalFormat {
41 public: 41 public:
42 VCalFormat(); 42 VCalFormat();
43 virtual ~VCalFormat(); 43 virtual ~VCalFormat();
44 44
45 /** loads a calendar on disk in vCalendar format into the current calendar. 45 /** loads a calendar on disk in vCalendar format into the current calendar.
46 * any information already present is lost. Returns TRUE if successful, 46 * any information already present is lost. Returns TRUE if successful,
47 * else returns FALSE. 47 * else returns FALSE.
48 * @param fileName the name of the calendar on disk. 48 * @param fileName the name of the calendar on disk.
49 */ 49 */
50 bool load(Calendar *,const QString &fileName); 50 bool load(Calendar *,const QString &fileName);
51 /** writes out the calendar to disk in vCalendar format. Returns true if 51 /** writes out the calendar to disk in vCalendar format. Returns true if
52 * successful and false on error. 52 * successful and false on error.
53 * @param fileName the name of the file 53 * @param fileName the name of the file
54 */ 54 */
55 bool save(Calendar *,const QString &fileName); 55 bool save(Calendar *,const QString &fileName);
56 56
57 /** 57 /**
58 Parse string and populate calendar with that information. 58 Parse string and populate calendar with that information.
59 */ 59 */
60 bool fromString( Calendar *, const QString & ); 60 bool fromString( Calendar *, const QString & );
61 /** 61 /**
62 Return calendar information as string. 62 Return calendar information as string.
63 */ 63 */
64 QString toString( Calendar * ); 64 QString toString( Calendar * );
65 QString eventToString( Event * );
66 QString todoToString( Todo * );
65 67
66 protected: 68 protected:
67 /** translates a VObject of the TODO type into a Event */ 69 /** translates a VObject of the TODO type into a Event */
68 Todo *VTodoToEvent(VObject *vtodo); 70 Todo *VTodoToEvent(VObject *vtodo);
69 /** translates a VObject into a Event and returns a pointer to it. */ 71 /** translates a VObject into a Event and returns a pointer to it. */
70 Event *VEventToEvent(VObject *vevent); 72 Event *VEventToEvent(VObject *vevent);
71 /** translate a Event into a VTodo-type VObject and return pointer */ 73 /** translate a Event into a VTodo-type VObject and return pointer */
72 VObject *eventToVTodo(const Todo *anEvent); 74 VObject *eventToVTodo(const Todo *anEvent);
73 /** translate a Event into a VObject and returns a pointer to it. */ 75 /** translate a Event into a VObject and returns a pointer to it. */
74 VObject* eventToVEvent(const Event *anEvent); 76 VObject* eventToVEvent(const Event *anEvent);
75 77
76 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ 78 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */
77 QString qDateToISO(const QDate &); 79 QString qDateToISO(const QDate &);
78 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ 80 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */
79 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); 81 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE);
80 /** takes a string in the format YYYYMMDDTHHMMSS and returns a 82 /** takes a string in the format YYYYMMDDTHHMMSS and returns a
81 * valid QDateTime. */ 83 * valid QDateTime. */
82 QDateTime ISOToQDateTime(const QString & dtStr); 84 QDateTime ISOToQDateTime(const QString & dtStr);
83 /** takes a string in the format YYYYMMDD and returns a 85 /** takes a string in the format YYYYMMDD and returns a
84 * valid QDate. */ 86 * valid QDate. */
85 QDate ISOToQDate(const QString & dtStr); 87 QDate ISOToQDate(const QString & dtStr);
86 /** takes a vCalendar tree of VObjects, and puts all of them that have 88 /** takes a vCalendar tree of VObjects, and puts all of them that have
87 * the "event" property into the dictionary, todos in the todo-list, etc. */ 89 * the "event" property into the dictionary, todos in the todo-list, etc. */
88 void populate(VObject *vcal); 90 void populate(VObject *vcal);
89 91
90 /** takes a number 0 - 6 and returns the two letter string of that day, 92 /** takes a number 0 - 6 and returns the two letter string of that day,
91 * i.e. MO, TU, WE, etc. */ 93 * i.e. MO, TU, WE, etc. */
92 const char *dayFromNum(int day); 94 const char *dayFromNum(int day);
93 /** the reverse of the above function. */ 95 /** the reverse of the above function. */
94 int numFromDay(const QString &day); 96 int numFromDay(const QString &day);
95 97
96 Attendee::PartStat readStatus(const char *s) const; 98 Attendee::PartStat readStatus(const char *s) const;
97 QCString writeStatus(Attendee::PartStat status) const; 99 QCString writeStatus(Attendee::PartStat status) const;
98 100
99 private: 101 private:
100 Calendar *mCalendar; 102 Calendar *mCalendar;
101 103
102 QPtrList<Event> mEventsRelate; // events with relations 104 QPtrList<Event> mEventsRelate; // events with relations
103 QPtrList<Todo> mTodosRelate; // todos with relations 105 QPtrList<Todo> mTodosRelate; // todos with relations
104}; 106};
105 107
106} 108}
107 109
108#endif 110#endif