summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koprefs.cpp6
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp134
-rw-r--r--korganizer/mainwindow.h1
-rw-r--r--libkcal/phoneformat.cpp68
-rw-r--r--libkcal/phoneformat.h2
6 files changed, 188 insertions, 26 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index c28da9a..716a125 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -32,96 +32,102 @@
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "koprefs.h" 46#include "koprefs.h"
47#include "mainwindow.h" 47#include "mainwindow.h"
48 48
49const char *germanwords[][2] = { 49const char *germanwords[][2] = {
50#include "wordsgerman.h" 50#include "wordsgerman.h"
51 "", "" 51 "", ""
52}; 52};
53 53
54KOPrefs *KOPrefs::mInstance = 0; 54KOPrefs *KOPrefs::mInstance = 0;
55static KStaticDeleter<KOPrefs> insd; 55static KStaticDeleter<KOPrefs> insd;
56 56
57KOPrefs::KOPrefs() : 57KOPrefs::KOPrefs() :
58 KPimPrefs("korganizerrc") 58 KPimPrefs("korganizerrc")
59{ 59{
60 mCategoryColors.setAutoDelete(true); 60 mCategoryColors.setAutoDelete(true);
61 mLocaleDict = 0; 61 mLocaleDict = 0;
62 fillMailDefaults(); 62 fillMailDefaults();
63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
64 QColor defaultHolidayColor = QColor(255,0,0); 64 QColor defaultHolidayColor = QColor(255,0,0);
65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
68 QColor defaultTodoDueTodayColor = QColor(255,220,100); 68 QColor defaultTodoDueTodayColor = QColor(255,220,100);
69 QColor defaultTodoOverdueColor = QColor(255,153,125); 69 QColor defaultTodoOverdueColor = QColor(255,153,125);
70 70
71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); 71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
72 mDefaultViewFont = QFont("helvetica",10); 72 mDefaultViewFont = QFont("helvetica",10);
73 mDefaultMonthViewFont = QFont("helvetica",8); 73 mDefaultMonthViewFont = QFont("helvetica",8);
74 mMarcusBainsFont= QFont("helvetica",10); 74 mMarcusBainsFont= QFont("helvetica",10);
75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); 75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
76 mEditBoxFont = QFont("helvetica",12); 76 mEditBoxFont = QFont("helvetica",12);
77 mJornalViewFont = QFont("helvetica",12); 77 mJornalViewFont = QFont("helvetica",12);
78 78
79 KPrefs::setCurrentGroup("General"); 79 KPrefs::setCurrentGroup("General");
80
81
82 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
83 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
84 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
85
80 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 86 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
81 87
82 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 88 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
83 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 89 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
84 addItemBool("ShowIconSearch",&mShowIconSearch,true); 90 addItemBool("ShowIconSearch",&mShowIconSearch,true);
85 addItemBool("ShowIconList",&mShowIconList,true); 91 addItemBool("ShowIconList",&mShowIconList,true);
86 addItemBool("ShowIconDay1",&mShowIconDay1,true); 92 addItemBool("ShowIconDay1",&mShowIconDay1,true);
87 addItemBool("ShowIconDay5",&mShowIconDay5,true); 93 addItemBool("ShowIconDay5",&mShowIconDay5,true);
88 addItemBool("ShowIconDay7",&mShowIconDay7,true); 94 addItemBool("ShowIconDay7",&mShowIconDay7,true);
89 addItemBool("ShowIconMonth",&mShowIconMonth,true); 95 addItemBool("ShowIconMonth",&mShowIconMonth,true);
90 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 96 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
91 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 97 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
92 addItemBool("ShowIconBack",&mShowIconBack,true); 98 addItemBool("ShowIconBack",&mShowIconBack,true);
93 addItemBool("ShowIconToday",&mShowIconToday,true); 99 addItemBool("ShowIconToday",&mShowIconToday,true);
94 addItemBool("ShowIconForward",&mShowIconForward,true); 100 addItemBool("ShowIconForward",&mShowIconForward,true);
95 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 101 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
96 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); 102 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
97 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 103 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
98 addItemBool("ShowIconNext",&mShowIconNext,true); 104 addItemBool("ShowIconNext",&mShowIconNext,true);
99 addItemBool("ShowIconJournal",&mShowIconJournal,true); 105 addItemBool("ShowIconJournal",&mShowIconJournal,true);
100 addItemBool("ShowIconStretch",&mShowIconStretch,true); 106 addItemBool("ShowIconStretch",&mShowIconStretch,true);
101 addItemBool("LanguageChanged",&mLanguageChanged,false); 107 addItemBool("LanguageChanged",&mLanguageChanged,false);
102 108
103 addItemBool("AskForQuit",&mAskForQuit,false); 109 addItemBool("AskForQuit",&mAskForQuit,false);
104 110
105#ifndef DESKTOP_VERSION 111#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 112 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 113#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 114 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 115#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 116 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 117 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
113 addItemInt("Whats Next Days",&mWhatsNextDays,3); 119 addItemInt("Whats Next Days",&mWhatsNextDays,3);
114 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
115 121
116 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
117 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 123 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
118 addItemInt("AllDay Size",&mAllDaySize,28); 124 addItemInt("AllDay Size",&mAllDaySize,28);
119 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 125 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
120 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 126 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
121 127
122 addItemStringList("LocationDefaults",&mLocationDefaults ); 128 addItemStringList("LocationDefaults",&mLocationDefaults );
123 addItemStringList("EventSummary User",&mEventSummaryUser); 129 addItemStringList("EventSummary User",&mEventSummaryUser);
124 addItemStringList("TodoSummary User",&mTodoSummaryUser); 130 addItemStringList("TodoSummary User",&mTodoSummaryUser);
125 131
126 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 132 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
127 addItemBool("Enable Project View",&mEnableProjectView,false); 133 addItemBool("Enable Project View",&mEnableProjectView,false);
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index d9ac851..a1ba8b3 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -165,96 +165,99 @@ class KOPrefs : public KPimPrefs
165 bool mLanguageChanged; 165 bool mLanguageChanged;
166 166
167 bool mCompactDialogs; 167 bool mCompactDialogs;
168 bool mVerticalScreen; 168 bool mVerticalScreen;
169 169
170 bool mShowIconNewTodo; 170 bool mShowIconNewTodo;
171 bool mShowIconNewEvent; 171 bool mShowIconNewEvent;
172 bool mShowIconSearch; 172 bool mShowIconSearch;
173 bool mShowIconList; 173 bool mShowIconList;
174 bool mShowIconDay1; 174 bool mShowIconDay1;
175 bool mShowIconDay5; 175 bool mShowIconDay5;
176 bool mShowIconDay7; 176 bool mShowIconDay7;
177 bool mShowIconMonth; 177 bool mShowIconMonth;
178 bool mShowIconTodoview; 178 bool mShowIconTodoview;
179 bool mShowIconBackFast; 179 bool mShowIconBackFast;
180 bool mShowIconBack; 180 bool mShowIconBack;
181 bool mShowIconToday; 181 bool mShowIconToday;
182 bool mShowIconForward; 182 bool mShowIconForward;
183 bool mShowIconForwardFast; 183 bool mShowIconForwardFast;
184 bool mShowIconWhatsThis; 184 bool mShowIconWhatsThis;
185 bool mShowIconNextDays; 185 bool mShowIconNextDays;
186 bool mShowIconNext; 186 bool mShowIconNext;
187 bool mShowIconJournal; 187 bool mShowIconJournal;
188 188
189 bool mShowIconStretch; 189 bool mShowIconStretch;
190 190
191 bool mToolBarHor; 191 bool mToolBarHor;
192 bool mToolBarUp; 192 bool mToolBarUp;
193 bool mToolBarMiniIcons; 193 bool mToolBarMiniIcons;
194 194
195 bool mAskForQuit; 195 bool mAskForQuit;
196 bool mUsePassWd; 196 bool mUsePassWd;
197 bool mWriteBackFile; 197 bool mWriteBackFile;
198 int mWriteBackInFuture; 198 int mWriteBackInFuture;
199 bool mAskForPreferences; 199 bool mAskForPreferences;
200 bool mShowSyncSummary; 200 bool mShowSyncSummary;
201 bool mShowSyncEvents; 201 bool mShowSyncEvents;
202 bool mShowTodoInAgenda; 202 bool mShowTodoInAgenda;
203 bool mWriteBackExistingOnly; 203 bool mWriteBackExistingOnly;
204 204
205 QString mRemoteIP; 205 QString mRemoteIP;
206 QString mRemoteUser; 206 QString mRemoteUser;
207 QString mRemotePassWd; 207 QString mRemotePassWd;
208 QString mRemoteFile; 208 QString mRemoteFile;
209 QString mLocalTempFile; 209 QString mLocalTempFile;
210 QString mPhoneDevice; 210 QString mPhoneDevice;
211 QString mPhoneConnection; 211 QString mPhoneConnection;
212 QString mPhoneModel; 212 QString mPhoneModel;
213 QString mEx2PhoneDevice;
214 QString mEx2PhoneConnection;
215 QString mEx2PhoneModel;
213 216
214 int mLastSyncTime; 217 int mLastSyncTime;
215 int mSyncAlgoPrefs; 218 int mSyncAlgoPrefs;
216 int mRingSyncAlgoPrefs; 219 int mRingSyncAlgoPrefs;
217 QStringList mSyncProfileNames; 220 QStringList mSyncProfileNames;
218 QStringList mExternSyncProfiles; 221 QStringList mExternSyncProfiles;
219 QString mLocalMachineName; 222 QString mLocalMachineName;
220 void setCategoryColor(QString cat,const QColor & color); 223 void setCategoryColor(QString cat,const QColor & color);
221 QColor *categoryColor(QString cat); 224 QColor *categoryColor(QString cat);
222 225
223 QString mArchiveFile; 226 QString mArchiveFile;
224 QString mHtmlExportFile; 227 QString mHtmlExportFile;
225 bool mHtmlWithSave; 228 bool mHtmlWithSave;
226 229
227 QStringList mSelectedPlugins; 230 QStringList mSelectedPlugins;
228 231
229 QString mLastImportFile; 232 QString mLastImportFile;
230 QString mLastVcalFile; 233 QString mLastVcalFile;
231 QString mLastSaveFile; 234 QString mLastSaveFile;
232 QString mLastLoadFile; 235 QString mLastLoadFile;
233 QString mLastSyncedLocalFile; 236 QString mLastSyncedLocalFile;
234 237
235 238
236 QString mDefaultAlarmFile; 239 QString mDefaultAlarmFile;
237 int mIMIPScheduler; 240 int mIMIPScheduler;
238 int mIMIPSend; 241 int mIMIPSend;
239 QStringList mAdditionalMails; 242 QStringList mAdditionalMails;
240 int mIMIPAutoRefresh; 243 int mIMIPAutoRefresh;
241 int mIMIPAutoInsertReply; 244 int mIMIPAutoInsertReply;
242 int mIMIPAutoInsertRequest; 245 int mIMIPAutoInsertRequest;
243 int mIMIPAutoFreeBusy; 246 int mIMIPAutoFreeBusy;
244 int mIMIPAutoFreeBusyReply; 247 int mIMIPAutoFreeBusyReply;
245 248
246 QStringList mTodoTemplates; 249 QStringList mTodoTemplates;
247 QStringList mEventTemplates; 250 QStringList mEventTemplates;
248 251
249 int mDestination; 252 int mDestination;
250 253
251 254
252 bool mEditOnDoubleClick; 255 bool mEditOnDoubleClick;
253 bool mViewChangeHoldFullscreen; 256 bool mViewChangeHoldFullscreen;
254 bool mViewChangeHoldNonFullscreen; 257 bool mViewChangeHoldNonFullscreen;
255 bool mCenterOnCurrentTime; 258 bool mCenterOnCurrentTime;
256 bool mSetTimeToDayStartAt; 259 bool mSetTimeToDayStartAt;
257 bool mHighlightCurrentDay; 260 bool mHighlightCurrentDay;
258 bool mUseHighlightLightColor; 261 bool mUseHighlightLightColor;
259 bool mListViewMonthTimespan; 262 bool mListViewMonthTimespan;
260 bool mWNViewShowsParents; 263 bool mWNViewShowsParents;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index de94b8c..ef73a78 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,116 +1,168 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h>
17#include <qcheckbox.h>
16#include <qmap.h> 18#include <qmap.h>
17#include <qwmatrix.h> 19#include <qwmatrix.h>
18#include <qtextbrowser.h> 20#include <qtextbrowser.h>
19#include <qtextstream.h> 21#include <qtextstream.h>
20#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
21#include <qpe/global.h> 23#include <qpe/global.h>
22#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
23#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
24#include <qpe/resource.h> 26#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
26#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
27#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
28#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
29#else 31#else
30#include <qmenubar.h> 32#include <qmenubar.h>
31#include <qtoolbar.h> 33#include <qtoolbar.h>
32#include <qapplication.h> 34#include <qapplication.h>
33//#include <resource.h> 35//#include <resource.h>
34 36
35#endif 37#endif
36#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h>
38#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
39#include <libkcal/kincidenceformatter.h> 42#include <libkcal/kincidenceformatter.h>
40#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
41 44
42#include "calendarview.h" 45#include "calendarview.h"
43#include "koviewmanager.h" 46#include "koviewmanager.h"
44#include "datenavigator.h" 47#include "datenavigator.h"
45#include "koagendaview.h" 48#include "koagendaview.h"
46#include "koagenda.h" 49#include "koagenda.h"
47#include "kodialogmanager.h" 50#include "kodialogmanager.h"
48#include "kdialogbase.h" 51#include "kdialogbase.h"
49#include "kapplication.h" 52#include "kapplication.h"
50#include "kofilterview.h" 53#include "kofilterview.h"
51#include "kstandarddirs.h" 54#include "kstandarddirs.h"
52#include "koprefs.h" 55#include "koprefs.h"
53#include "kfiledialog.h" 56#include "kfiledialog.h"
54#include "koglobals.h" 57#include "koglobals.h"
55#include "kglobal.h" 58#include "kglobal.h"
56#include "klocale.h" 59#include "klocale.h"
57#include "kconfig.h" 60#include "kconfig.h"
58#include "simplealarmclient.h" 61#include "simplealarmclient.h"
59#include "externalapphandler.h" 62#include "externalapphandler.h"
60 63
61using namespace KCal; 64using namespace KCal;
62#ifndef _WIN32_ 65#ifndef _WIN32_
63#include <unistd.h> 66#include <unistd.h>
64#else 67#else
65#include "koimportoldialog.h" 68#include "koimportoldialog.h"
66#endif 69#endif
67#include "mainwindow.h" 70#include "mainwindow.h"
68 71
72class KOex2phonePrefs : public QDialog
73{
74 public:
75 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
76 QDialog( parent, name, true )
77 {
78 setCaption( i18n("Export to phone options") );
79 QVBoxLayout* lay = new QVBoxLayout( this );
80 lay->setSpacing( 3 );
81 lay->setMargin( 3 );
82
83 lay->addWidget(new QLabel( i18n("Please read phone sync howto to\nknow more about the connection settings."), this ) );
84 QHBox* temphb;
85 temphb = new QHBox( this );
86 new QLabel( i18n("I/O device: "), temphb );
87 mPhoneDevice = new QLineEdit( temphb);
88 lay->addWidget( temphb );
89 temphb = new QHBox( this );
90 new QLabel( i18n("Connection: "), temphb );
91 mPhoneConnection = new QLineEdit( temphb);
92 lay->addWidget( temphb );
93 temphb = new QHBox( this );
94 new QLabel( i18n("Model(opt.): "), temphb );
95 mPhoneModel = new QLineEdit( temphb);
96 lay->addWidget( temphb );
97 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
98 mWriteBackFuture->setChecked( true );
99 lay->addWidget( mWriteBackFuture );
100 temphb = new QHBox( this );
101 new QLabel( i18n("Max. weeks in future: ") , temphb );
102 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
103 mWriteBackFutureWeeks->setValue( 8 );
104 lay->addWidget( temphb );
105 QPushButton * ok = new QPushButton( i18n("Export!"), this );
106 lay->addWidget( ok );
107 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
108 lay->addWidget( cancel );
109 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
110 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
111 resize( 220, 220 );
112
113 }
114
115public:
116 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
117 QCheckBox* mWriteBackFuture;
118 QSpinBox* mWriteBackFutureWeeks;
119};
120
69int globalFlagBlockStartup; 121int globalFlagBlockStartup;
70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 122MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
71 QMainWindow( parent, name ) 123 QMainWindow( parent, name )
72{ 124{
73 mPassWordPiSync = "abc"; 125 mPassWordPiSync = "abc";
74#ifdef DESKTOP_VERSION 126#ifdef DESKTOP_VERSION
75 setFont( QFont("Arial"), 14 ); 127 setFont( QFont("Arial"), 14 );
76#endif 128#endif
77 mSyncActionDialog = 0; 129 mSyncActionDialog = 0;
78 mServerSocket = 0; 130 mServerSocket = 0;
79 mClosed = false; 131 mClosed = false;
80 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 132 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
81 QString confFile = locateLocal("config","korganizerrc"); 133 QString confFile = locateLocal("config","korganizerrc");
82 QFileInfo finf ( confFile ); 134 QFileInfo finf ( confFile );
83 bool showWarning = !finf.exists(); 135 bool showWarning = !finf.exists();
84 setIcon(SmallIcon( "ko24" ) ); 136 setIcon(SmallIcon( "ko24" ) );
85 mBlockAtStartup = true; 137 mBlockAtStartup = true;
86 mFlagKeyPressed = false; 138 mFlagKeyPressed = false;
87 setCaption("KOrganizer/Pi"); 139 setCaption("KOrganizer/Pi");
88 KOPrefs *p = KOPrefs::instance(); 140 KOPrefs *p = KOPrefs::instance();
89 KPimGlobalPrefs::instance()->setGlobalConfig(); 141 KPimGlobalPrefs::instance()->setGlobalConfig();
90 // if ( QApplication::desktop()->height() > 480 ) { 142 // if ( QApplication::desktop()->height() > 480 ) {
91// if ( p->mHourSize == 4 ) 143// if ( p->mHourSize == 4 )
92// p->mHourSize = 6; 144// p->mHourSize = 6;
93// } 145// }
94 if ( p->mHourSize > 18 ) 146 if ( p->mHourSize > 18 )
95 p->mHourSize = 18; 147 p->mHourSize = 18;
96 QMainWindow::ToolBarDock tbd; 148 QMainWindow::ToolBarDock tbd;
97 if ( p->mToolBarHor ) { 149 if ( p->mToolBarHor ) {
98 if ( p->mToolBarUp ) 150 if ( p->mToolBarUp )
99 tbd = Bottom; 151 tbd = Bottom;
100 else 152 else
101 tbd = Top; 153 tbd = Top;
102 } 154 }
103 else { 155 else {
104 if ( p->mToolBarUp ) 156 if ( p->mToolBarUp )
105 tbd = Right; 157 tbd = Right;
106 else 158 else
107 tbd = Left; 159 tbd = Left;
108 } 160 }
109 if ( KOPrefs::instance()->mUseAppColors ) 161 if ( KOPrefs::instance()->mUseAppColors )
110 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 162 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
111 globalFlagBlockStartup = 1; 163 globalFlagBlockStartup = 1;
112 iconToolBar = new QPEToolBar( this ); 164 iconToolBar = new QPEToolBar( this );
113 addToolBar (iconToolBar , tbd ); 165 addToolBar (iconToolBar , tbd );
114 mBlockSaveFlag = false; 166 mBlockSaveFlag = false;
115 mCalendarModifiedFlag = false; 167 mCalendarModifiedFlag = false;
116 168
@@ -608,96 +660,105 @@ void MainWindow::initActions()
608 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 660 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
609 661
610 } 662 }
611 // actionMenu->insertSeparator(); 663 // actionMenu->insertSeparator();
612 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 664 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
613 this ); 665 this );
614 action->addTo( importMenu ); 666 action->addTo( importMenu );
615 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 667 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
616 action = new QAction( "import_quick", i18n("Import last file"), 0, 668 action = new QAction( "import_quick", i18n("Import last file"), 0,
617 this ); 669 this );
618 action->addTo( importMenu ); 670 action->addTo( importMenu );
619 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 671 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
620 importMenu->insertSeparator(); 672 importMenu->insertSeparator();
621 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 673 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
622 this ); 674 this );
623 action->addTo( importMenu ); 675 action->addTo( importMenu );
624 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 676 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
625#ifndef DESKTOP_VERSION 677#ifndef DESKTOP_VERSION
626 importMenu->insertSeparator(); 678 importMenu->insertSeparator();
627 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 679 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
628 this ); 680 this );
629 action->addTo( importMenu ); 681 action->addTo( importMenu );
630 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 682 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
631#else 683#else
632#ifdef _WIN32_ 684#ifdef _WIN32_
633 importMenu->insertSeparator(); 685 importMenu->insertSeparator();
634 action = new QAction( "import_ol", i18n("Import from OL"), 0, 686 action = new QAction( "import_ol", i18n("Import from OL"), 0,
635 this ); 687 this );
636 action->addTo( importMenu ); 688 action->addTo( importMenu );
637 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 689 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
638#endif 690#endif
639#endif 691#endif
640 692
641 importMenu->insertSeparator(); 693 importMenu->insertSeparator();
642 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 694 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
643 this ); 695 this );
644 action->addTo( importMenu ); 696 action->addTo( importMenu );
645 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 697 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
646 698
647 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 699 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
648 this ); 700 this );
649 action->addTo( importMenu ); 701 action->addTo( importMenu );
650 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 702 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
651 703
652 importMenu->insertSeparator(); 704 importMenu->insertSeparator();
653 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 705 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
654 this ); 706 this );
655 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 707 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
708
709
710 //LR
711 QPopupMenu *ex2phone = new QPopupMenu( this );
712 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
713 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
714 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
715 importMenu->insertItem( i18n("Export to phone"), ex2phone );
716
656 importMenu->insertSeparator(); 717 importMenu->insertSeparator();
657 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 718 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
658 this ); 719 this );
659 action->addTo( importMenu ); 720 action->addTo( importMenu );
660 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 721 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
661#ifndef DESKTOP_VERSION 722#ifndef DESKTOP_VERSION
662 importMenu->insertSeparator(); 723 importMenu->insertSeparator();
663 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 724 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
664 this ); 725 this );
665 action->addTo( importMenu ); 726 action->addTo( importMenu );
666 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 727 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
667 728
668 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 729 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
669 this ); 730 this );
670 action->addTo( importMenu ); 731 action->addTo( importMenu );
671 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 732 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
672#else 733#else
673 importMenu->insertSeparator(); 734 importMenu->insertSeparator();
674 icon = loadPixmap( pathString + "print" ); 735 icon = loadPixmap( pathString + "print" );
675 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 736 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
676 action->addTo( importMenu ); 737 action->addTo( importMenu );
677 connect( action, SIGNAL( activated() ), 738 connect( action, SIGNAL( activated() ),
678 this, SLOT( printCal() ) ); 739 this, SLOT( printCal() ) );
679 740
680 icon = loadPixmap( pathString + "print" ); 741 icon = loadPixmap( pathString + "print" );
681 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 742 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
682 action->addTo( importMenu ); 743 action->addTo( importMenu );
683 connect( action, SIGNAL( activated() ), 744 connect( action, SIGNAL( activated() ),
684 this, SLOT( printSel() ) ); 745 this, SLOT( printSel() ) );
685#endif 746#endif
686 importMenu->insertSeparator(); 747 importMenu->insertSeparator();
687 action = new QAction( "beam all", i18n("Save"), 0, 748 action = new QAction( "beam all", i18n("Save"), 0,
688 this ); 749 this );
689 action->addTo( importMenu ); 750 action->addTo( importMenu );
690 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 751 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
691 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 752 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
692 this ); 753 this );
693 action->addTo( importMenu ); 754 action->addTo( importMenu );
694 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 755 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
695 756
696 //menuBar->insertItem( "Configure",configureMenu ); 757 //menuBar->insertItem( "Configure",configureMenu );
697 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 758 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
698 icon = loadPixmap( "korganizer/korganizer" ); 759 icon = loadPixmap( "korganizer/korganizer" );
699 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 760 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
700 action->addTo( helpMenu ); 761 action->addTo( helpMenu );
701 connect( action, SIGNAL( activated() ), 762 connect( action, SIGNAL( activated() ),
702 SLOT( keyBindings() ) ); 763 SLOT( keyBindings() ) );
703 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 764 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
@@ -1042,103 +1103,176 @@ void MainWindow::slotSyncMenu( int action )
1042 mBlockSaveFlag = true; 1103 mBlockSaveFlag = true;
1043 mCurrentSyncProfile = action - 1000 ; 1104 mCurrentSyncProfile = action - 1000 ;
1044 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1105 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1045 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1106 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1046 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1047 KSyncProfile* temp = new KSyncProfile (); 1108 KSyncProfile* temp = new KSyncProfile ();
1048 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1109 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1049 temp->readConfig(&config); 1110 temp->readConfig(&config);
1050 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1111 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1051 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1112 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1052 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1113 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1053 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1114 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1054 KOPrefs::instance()->mWriteBackInFuture = 0; 1115 KOPrefs::instance()->mWriteBackInFuture = 0;
1055 if ( temp->getWriteBackFuture() ) 1116 if ( temp->getWriteBackFuture() )
1056 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1117 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1057 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1118 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1058 if ( action == 1000 ) { 1119 if ( action == 1000 ) {
1059 syncSharp(); 1120 syncSharp();
1060 1121
1061 } else if ( action == 1001 ) { 1122 } else if ( action == 1001 ) {
1062 syncLocalFile(); 1123 syncLocalFile();
1063 1124
1064 } else if ( action == 1002 ) { 1125 } else if ( action == 1002 ) {
1065 quickSyncLocalFile(); 1126 quickSyncLocalFile();
1066 1127
1067 } else if ( action >= 1003 ) { 1128 } else if ( action >= 1003 ) {
1068 if ( temp->getIsLocalFileSync() ) { 1129 if ( temp->getIsLocalFileSync() ) {
1069 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1130 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1070 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1131 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1071 } else { 1132 } else {
1072 if ( temp->getIsPhoneSync() ) { 1133 if ( temp->getIsPhoneSync() ) {
1073 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1134 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1074 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1135 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1075 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1136 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1076 syncPhone(); 1137 syncPhone();
1077 } else if ( temp->getIsPiSync() ) { 1138 } else if ( temp->getIsPiSync() ) {
1078 mPassWordPiSync = temp->getRemotePw(); 1139 mPassWordPiSync = temp->getRemotePw();
1079 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1140 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1080 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1141 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1081 syncPi(); 1142 syncPi();
1082 } else 1143 } else
1083 syncRemote( temp ); 1144 syncRemote( temp );
1084 1145
1085 } 1146 }
1086 } 1147 }
1087 delete temp; 1148 delete temp;
1088 mBlockSaveFlag = false; 1149 mBlockSaveFlag = false;
1089} 1150}
1151void MainWindow::exportToPhone( int mode )
1152{
1153
1154 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1155 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1156 KOex2phonePrefs ex2phone;
1157 ex2phone.mPhoneConnection->setText( KOPrefs::instance()->mEx2PhoneConnection );
1158 ex2phone.mPhoneDevice->setText( KOPrefs::instance()->mEx2PhoneDevice );
1159 ex2phone.mPhoneModel->setText( KOPrefs::instance()->mEx2PhoneModel );
1160
1161 if ( !ex2phone.exec() ) {
1162 return;
1163 }
1164 KOPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1165 KOPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1166 KOPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1167
1168 int inFuture = 0;
1169 if ( ex2phone.mWriteBackFuture->isChecked() )
1170 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1171 QPtrList<Incidence> delSel;
1172 if ( mode == 1 )
1173 delSel = mCalendar->rawIncidences();
1174 if ( mode == 2 )
1175 delSel = mCalendar->incidences();
1176 CalendarLocal* cal = new CalendarLocal();
1177 cal->setLocalTime();
1178 Incidence *incidence = delSel.first();
1179 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1180 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1181 while ( incidence ) {
1182 if ( incidence->type() != "journal" ) {
1183 bool add = true;
1184 if ( inFuture ) {
1185 QDateTime dt;
1186 if ( incidence->type() == "Todo" ) {
1187 Todo * t = (Todo*)incidence;
1188 if ( t->hasDueDate() )
1189 dt = t->dtDue();
1190 else
1191 dt = cur.addSecs( 62 );
1192 }
1193 else {
1194 bool ok;
1195 dt = incidence->getNextOccurence( cur, &ok );
1196 if ( !ok )
1197 dt = cur.addSecs( -62 );
1198 }
1199 if ( dt < cur || dt > end ) {
1200 add = false;
1201 }
1202 }
1203 if ( add ) {
1204 Incidence *in = incidence->clone();
1205 cal->addIncidence( in );
1206 }
1207 }
1208 incidence = delSel.next();
1209 }
1210 PhoneFormat::writeConfig( KOPrefs::instance()->mEx2PhoneDevice,
1211 KOPrefs::instance()->mEx2PhoneConnection,
1212 KOPrefs::instance()->mEx2PhoneModel );
1213
1214 setCaption( i18n("Writing to phone..."));
1215 if ( PhoneFormat::writeToPhone( cal ) )
1216 setCaption( i18n("Export to phone successful!"));
1217 else
1218 setCaption( i18n("Error exporting to phone!"));
1219 delete cal;
1220}
1221
1222
1090void MainWindow::setDefaultPreferences() 1223void MainWindow::setDefaultPreferences()
1091{ 1224{
1092 KOPrefs *p = KOPrefs::instance(); 1225 KOPrefs *p = KOPrefs::instance();
1093 1226
1094 p->mCompactDialogs = true; 1227 p->mCompactDialogs = true;
1095 p->mConfirm = true; 1228 p->mConfirm = true;
1096 // p->mEnableQuickTodo = false; 1229 // p->mEnableQuickTodo = false;
1230
1097} 1231}
1098 1232
1099QString MainWindow::resourcePath() 1233QString MainWindow::resourcePath()
1100{ 1234{
1101 return KGlobal::iconLoader()->iconPath(); 1235 return KGlobal::iconLoader()->iconPath();
1102} 1236}
1103 1237
1104void MainWindow::displayText( QString text ,QString cap ) 1238void MainWindow::displayText( QString text ,QString cap )
1105{ 1239{
1106 QDialog dia( this, "name", true ); ; 1240 QDialog dia( this, "name", true ); ;
1107 dia.setCaption( cap ); 1241 dia.setCaption( cap );
1108 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1242 QVBoxLayout* lay = new QVBoxLayout( &dia );
1109 lay->setSpacing( 3 ); 1243 lay->setSpacing( 3 );
1110 lay->setMargin( 3 ); 1244 lay->setMargin( 3 );
1111 QTextBrowser tb ( &dia ); 1245 QTextBrowser tb ( &dia );
1112 lay->addWidget( &tb ); 1246 lay->addWidget( &tb );
1113 tb.setText( text ); 1247 tb.setText( text );
1114#ifdef DESKTOP_VERSION 1248#ifdef DESKTOP_VERSION
1115 dia.resize( 640, 480); 1249 dia.resize( 640, 480);
1116#else 1250#else
1117 dia.showMaximized(); 1251 dia.showMaximized();
1118#endif 1252#endif
1119 dia.exec(); 1253 dia.exec();
1120} 1254}
1121void MainWindow::displayFile( QString fn, QString cap ) 1255void MainWindow::displayFile( QString fn, QString cap )
1122{ 1256{
1123 QString fileName = resourcePath() + fn; 1257 QString fileName = resourcePath() + fn;
1124 QString text; 1258 QString text;
1125 QFile file( fileName ); 1259 QFile file( fileName );
1126 if (!file.open( IO_ReadOnly ) ) { 1260 if (!file.open( IO_ReadOnly ) ) {
1127 return ; 1261 return ;
1128 1262
1129 } 1263 }
1130 QTextStream ts( &file ); 1264 QTextStream ts( &file );
1131 text = ts.read(); 1265 text = ts.read();
1132 file.close(); 1266 file.close();
1133 displayText( text, cap); 1267 displayText( text, cap);
1134} 1268}
1135void MainWindow::features() 1269void MainWindow::features()
1136{ 1270{
1137 1271
1138 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1272 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1139} 1273}
1140 1274
1141void MainWindow::usertrans() 1275void MainWindow::usertrans()
1142{ 1276{
1143 1277
1144 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1278 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 7b24b88..74c7f45 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -99,96 +99,97 @@ using namespace KCal;
99class MainWindow : public QMainWindow 99class MainWindow : public QMainWindow
100{ 100{
101 Q_OBJECT 101 Q_OBJECT
102 public: 102 public:
103 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 103 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
104 ~MainWindow(); 104 ~MainWindow();
105 public slots: 105 public slots:
106 virtual void showMaximized (); 106 virtual void showMaximized ();
107 void configureAgenda( int ); 107 void configureAgenda( int );
108 void recieve( const QCString& msg, const QByteArray& data ); 108 void recieve( const QCString& msg, const QByteArray& data );
109 static QString defaultFileName(); 109 static QString defaultFileName();
110 static QString syncFileName(); 110 static QString syncFileName();
111 static QString resourcePath(); 111 static QString resourcePath();
112 protected slots: 112 protected slots:
113 void setCaptionToDates(); 113 void setCaptionToDates();
114 int ringSync(); 114 int ringSync();
115 void multiSync( bool askforPrefs = false ); 115 void multiSync( bool askforPrefs = false );
116 void about(); 116 void about();
117 void licence(); 117 void licence();
118 void faq(); 118 void faq();
119 void usertrans(); 119 void usertrans();
120 void features(); 120 void features();
121 void synchowto(); 121 void synchowto();
122 void whatsNew(); 122 void whatsNew();
123 void keyBindings(); 123 void keyBindings();
124 void aboutAutoSaving();; 124 void aboutAutoSaving();;
125 void aboutKnownBugs(); 125 void aboutKnownBugs();
126 126
127 void processIncidenceSelection( Incidence * ); 127 void processIncidenceSelection( Incidence * );
128 128
129 void importQtopia(); 129 void importQtopia();
130 void importBday(); 130 void importBday();
131 void importOL(); 131 void importOL();
132 void importIcal(); 132 void importIcal();
133 void importFile( QString, bool ); 133 void importFile( QString, bool );
134 void quickImportIcal(); 134 void quickImportIcal();
135 135
136 void slotModifiedChanged( bool ); 136 void slotModifiedChanged( bool );
137 137
138 void save(); 138 void save();
139 void configureToolBar( int ); 139 void configureToolBar( int );
140 void printSel(); 140 void printSel();
141 void printCal(); 141 void printCal();
142 void saveCalendar(); 142 void saveCalendar();
143 void loadCalendar(); 143 void loadCalendar();
144 void exportVCalendar(); 144 void exportVCalendar();
145 void fillFilterMenu(); 145 void fillFilterMenu();
146 void selectFilter( int ); 146 void selectFilter( int );
147 void exportToPhone( int );
147 148
148 void slotSyncMenu( int ); 149 void slotSyncMenu( int );
149 void confSync(); 150 void confSync();
150 void syncSharp(); 151 void syncSharp();
151 void syncPhone(); 152 void syncPhone();
152 void syncPi(); 153 void syncPi();
153 void syncLocalFile(); 154 void syncLocalFile();
154 bool syncWithFile( QString, bool ); 155 bool syncWithFile( QString, bool );
155 void quickSyncLocalFile(); 156 void quickSyncLocalFile();
156 157
157 158
158 protected: 159 protected:
159 void displayText( QString, QString); 160 void displayText( QString, QString);
160 void displayFile( QString, QString); 161 void displayFile( QString, QString);
161 162
162 void enableIncidenceActions( bool ); 163 void enableIncidenceActions( bool );
163 164
164 private slots: 165 private slots:
165 QSocket* piSocket; 166 QSocket* piSocket;
166 QString piFileString; 167 QString piFileString;
167 QTime piTime; 168 QTime piTime;
168 void deleteCommandSocket(KCommandSocket* s, int state ); 169 void deleteCommandSocket(KCommandSocket* s, int state );
169 void fillSyncMenu(); 170 void fillSyncMenu();
170 void getFile( bool ); 171 void getFile( bool );
171 void readFileFromSocket(); 172 void readFileFromSocket();
172 private: 173 private:
173 //QTimer* mTimerCommandSocket; 174 //QTimer* mTimerCommandSocket;
174 QString mPassWordPiSync; 175 QString mPassWordPiSync;
175 KServerSocket * mServerSocket; 176 KServerSocket * mServerSocket;
176 bool mClosed; 177 bool mClosed;
177 void saveOnClose(); 178 void saveOnClose();
178 int mCurrentSyncProfile; 179 int mCurrentSyncProfile;
179 void enableQuick(); 180 void enableQuick();
180 void syncRemote( KSyncProfile* , bool ask = true); 181 void syncRemote( KSyncProfile* , bool ask = true);
181 bool mFlagKeyPressed; 182 bool mFlagKeyPressed;
182 bool mBlockAtStartup; 183 bool mBlockAtStartup;
183 QPEToolBar *iconToolBar; 184 QPEToolBar *iconToolBar;
184 void initActions(); 185 void initActions();
185 void setDefaultPreferences(); 186 void setDefaultPreferences();
186 void keyPressEvent ( QKeyEvent * ) ; 187 void keyPressEvent ( QKeyEvent * ) ;
187 void keyReleaseEvent ( QKeyEvent * ) ; 188 void keyReleaseEvent ( QKeyEvent * ) ;
188 QPopupMenu *configureToolBarMenu; 189 QPopupMenu *configureToolBarMenu;
189 QPopupMenu *selectFilterMenu; 190 QPopupMenu *selectFilterMenu;
190 QPopupMenu *configureAgendaMenu, *syncMenu; 191 QPopupMenu *configureAgendaMenu, *syncMenu;
191 CalendarLocal *mCalendar; 192 CalendarLocal *mCalendar;
192 CalendarView *mView; 193 CalendarView *mView;
193 QString getPassword(); 194 QString getPassword();
194 QAction *mNewSubTodoAction; 195 QAction *mNewSubTodoAction;
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 29c1ae6..b2a62b1 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -39,192 +39,200 @@
39 39
40#include "calendar.h" 40#include "calendar.h"
41#include "alarm.h" 41#include "alarm.h"
42#include "recurrence.h" 42#include "recurrence.h"
43#include "calendarlocal.h" 43#include "calendarlocal.h"
44 44
45#include "phoneformat.h" 45#include "phoneformat.h"
46#include "syncdefines.h" 46#include "syncdefines.h"
47 47
48using namespace KCal; 48using namespace KCal;
49class PhoneParser : public QObject 49class PhoneParser : public QObject
50{ 50{
51public: 51public:
52 PhoneParser( ) { 52 PhoneParser( ) {
53 ; 53 ;
54 } 54 }
55 55
56 static QString dtToString( const QDateTime& dti, bool useTZ = false ) 56 static QString dtToString( const QDateTime& dti, bool useTZ = false )
57 { 57 {
58 QString datestr; 58 QString datestr;
59 QString timestr; 59 QString timestr;
60 int offset = KGlobal::locale()->localTimeOffset( dti ); 60 int offset = KGlobal::locale()->localTimeOffset( dti );
61 QDateTime dt; 61 QDateTime dt;
62 if (useTZ) 62 if (useTZ)
63 dt = dti.addSecs ( -(offset*60)); 63 dt = dti.addSecs ( -(offset*60));
64 else 64 else
65 dt = dti; 65 dt = dti;
66 if(dt.date().isValid()){ 66 if(dt.date().isValid()){
67 const QDate& date = dt.date(); 67 const QDate& date = dt.date();
68 datestr.sprintf("%04d%02d%02d", 68 datestr.sprintf("%04d%02d%02d",
69 date.year(), date.month(), date.day()); 69 date.year(), date.month(), date.day());
70 } 70 }
71 if(dt.time().isValid()){ 71 if(dt.time().isValid()){
72 const QTime& time = dt.time(); 72 const QTime& time = dt.time();
73 timestr.sprintf("T%02d%02d%02d", 73 timestr.sprintf("T%02d%02d%02d",
74 time.hour(), time.minute(), time.second()); 74 time.hour(), time.minute(), time.second());
75 } 75 }
76 return datestr + timestr; 76 return datestr + timestr;
77 } 77 }
78 78
79 79
80}; 80};
81 81
82 82
83 83
84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
85{ 85{
86 mProfileName = profileName; 86 mProfileName = profileName;
87 87 writeConfig( device, connection, model );
88}
89
90PhoneFormat::~PhoneFormat()
91{
92}
93void PhoneFormat::writeConfig( QString device, QString connection, QString model )
94{
95#ifdef _WIN32_
96 QString fileName = qApp->applicationDirPath () +"\\gammurc";
97#else
88 QString fileName = QDir::homeDirPath() +"/.gammurc"; 98 QString fileName = QDir::homeDirPath() +"/.gammurc";
99#endif
89 //qDebug("save %d ", load ); 100 //qDebug("save %d ", load );
90 QString content; 101 QString content;
91 bool write = false; 102 bool write = false;
92 bool addPort = true, addConnection = true, addModel = true; 103 bool addPort = true, addConnection = true, addModel = true;
93 QFile file( fileName ); 104 QFile file( fileName );
94 if ( QFile::exists( fileName) ) { 105 if ( QFile::exists( fileName) ) {
95 if (!file.open( IO_ReadOnly ) ) { 106 if (!file.open( IO_ReadOnly ) ) {
96 qDebug("Error: cannot open %s ", fileName.latin1() ); 107 qDebug("Error: cannot open %s ", fileName.latin1() );
97 return; 108 return;
98 } 109 }
99 QString line; 110 QString line;
100 while ( file.readLine( line, 1024 ) > 0 ) { 111 while ( file.readLine( line, 1024 ) > 0 ) {
101 //qDebug("*%s* ", line.latin1() ); 112 //qDebug("*%s* ", line.latin1() );
102 if ( line.left(7 ) == "[gammu]" ) { 113 if ( line.left(7 ) == "[gammu]" ) {
103 ; 114 ;
104 } else 115 } else
105 if ( line.left(4 ) == "port" ) { 116 if ( line.left(4 ) == "port" ) {
106 if ( line == "port = " + device+"\n" ) { 117 if ( line == "port = " + device+"\n" ) {
107 content += line ; 118 content += line ;
108 addPort = false; 119 addPort = false;
109 //qDebug("port found" ); 120 //qDebug("port found" );
110 } 121 }
111 122
112 } else if ( line.left(5 ) == "model" ) { 123 } else if ( line.left(5 ) == "model" ) {
113 if ( line == "model = " + model +"\n") { 124 if ( line == "model = " + model +"\n") {
114 content += line ; 125 content += line ;
115 addModel = false; 126 addModel = false;
116 //qDebug("model found" ); 127 //qDebug("model found" );
117 } 128 }
118 129
119 } else if ( line.left( 10 ) == "connection" ) { 130 } else if ( line.left( 10 ) == "connection" ) {
120 if ( line == "connection = " + connection +"\n") { 131 if ( line == "connection = " + connection +"\n") {
121 addConnection = false; 132 addConnection = false;
122 content += line ; 133 content += line ;
123 //qDebug("con found" ); 134 //qDebug("con found" );
124 } 135 }
125 136
126 } else { 137 } else {
127 content += line ; 138 content += line ;
128 } 139 }
129 } 140 }
130 file.close(); 141 file.close();
131 } else { 142 } else {
132 if ( ! connection.isEmpty() ) { 143 if ( ! connection.isEmpty() ) {
133 addConnection = true; 144 addConnection = true;
134 } 145 }
135 if ( ! device.isEmpty() ) { 146 if ( ! device.isEmpty() ) {
136 addPort = true; 147 addPort = true;
137 148
138 } 149 }
139 if ( ! model.isEmpty() ) { 150 if ( ! model.isEmpty() ) {
140 addModel = true; 151 addModel = true;
141 } 152 }
142 } 153 }
143 154
144 if ( addConnection ) { 155 if ( addConnection ) {
145 if ( ! write ) 156 if ( ! write )
146 content += "[gammu]\n"; 157 content += "[gammu]\n";
147 write = true; 158 write = true;
148 content += "connection = "; 159 content += "connection = ";
149 content += connection; 160 content += connection;
150 content += "\n"; 161 content += "\n";
151 } 162 }
152 if ( addPort ) { 163 if ( addPort ) {
153 if ( ! write ) 164 if ( ! write )
154 content += "[gammu]\n"; 165 content += "[gammu]\n";
155 write = true; 166 write = true;
156 content += "port = "; 167 content += "port = ";
157 content += device; 168 content += device;
158 content += "\n"; 169 content += "\n";
159 170
160 } 171 }
161 if ( addModel ) { 172 if ( addModel ) {
162 if ( ! write ) 173 if ( ! write )
163 content += "[gammu]\n"; 174 content += "[gammu]\n";
164 write = true; 175 write = true;
165 content += "model = "; 176 content += "model = ";
166 content += model; 177 content += model;
167 content += "\n"; 178 content += "\n";
168 } 179 }
169 if ( write ) { 180 if ( write ) {
170 if (!file.open( IO_WriteOnly ) ) { 181 if (!file.open( IO_WriteOnly ) ) {
171 qDebug("Error: cannot write file %s ", fileName.latin1() ); 182 qDebug("Error: cannot write file %s ", fileName.latin1() );
172 return; 183 return;
173 } 184 }
174 qDebug("Writing file %s ", fileName.latin1() ); 185 qDebug("Writing file %s ", fileName.latin1() );
175 QTextStream ts( &file ); 186 QTextStream ts( &file );
176 ts << content ; 187 ts << content ;
177 file.close(); 188 file.close();
178 } 189 }
179}
180 190
181PhoneFormat::~PhoneFormat()
182{
183} 191}
184#if 0 192#if 0
185int PhoneFormat::initDevice(GSM_StateMachine *s) 193int PhoneFormat::initDevice(GSM_StateMachine *s)
186{ 194{
187 GSM_ReadConfig(NULL, &s->Config[0], 0); 195 GSM_ReadConfig(NULL, &s->Config[0], 0);
188 s->ConfigNum = 1; 196 s->ConfigNum = 1;
189 GSM_Config *cfg = &s->Config[0]; 197 GSM_Config *cfg = &s->Config[0];
190 if ( ! mConnection.isEmpty() ) { 198 if ( ! mConnection.isEmpty() ) {
191 cfg->Connection = strdup(mConnection.latin1()); 199 cfg->Connection = strdup(mConnection.latin1());
192 cfg->DefaultConnection = false; 200 cfg->DefaultConnection = false;
193 qDebug("Connection set %s ", cfg->Connection ); 201 qDebug("Connection set %s ", cfg->Connection );
194 202
195 } 203 }
196 if ( ! mDevice.isEmpty() ) { 204 if ( ! mDevice.isEmpty() ) {
197 cfg->Device = strdup(mDevice.latin1()); 205 cfg->Device = strdup(mDevice.latin1());
198 cfg->DefaultDevice = false; 206 cfg->DefaultDevice = false;
199 qDebug("Device set %s ", cfg->Device); 207 qDebug("Device set %s ", cfg->Device);
200 208
201 } 209 }
202 if ( ! mModel.isEmpty() ) { 210 if ( ! mModel.isEmpty() ) {
203 strcpy(cfg->Model,mModel.latin1() ); 211 strcpy(cfg->Model,mModel.latin1() );
204 cfg->DefaultModel = false; 212 cfg->DefaultModel = false;
205 qDebug("Model set %s ",cfg->Model ); 213 qDebug("Model set %s ",cfg->Model );
206 } 214 }
207 int error=GSM_InitConnection(s,3); 215 int error=GSM_InitConnection(s,3);
208 return error; 216 return error;
209} 217}
210#endif 218#endif
211ulong PhoneFormat::getCsumTodo( Todo* todo ) 219ulong PhoneFormat::getCsumTodo( Todo* todo )
212{ 220{
213 QStringList attList; 221 QStringList attList;
214 if ( todo->hasDueDate() ) 222 if ( todo->hasDueDate() )
215 attList << PhoneParser::dtToString ( todo->dtDue() ); 223 attList << PhoneParser::dtToString ( todo->dtDue() );
216 attList << todo->summary(); 224 attList << todo->summary();
217 QString completedString = "no"; 225 QString completedString = "no";
218 if ( todo->isCompleted() ) 226 if ( todo->isCompleted() )
219 completedString = "yes"; 227 completedString = "yes";
220 attList << completedString; 228 attList << completedString;
221 int prio = todo->priority(); 229 int prio = todo->priority();
222 if( prio == 2 ) prio = 1; 230 if( prio == 2 ) prio = 1;
223 if (prio == 4 ) prio = 5 ; 231 if (prio == 4 ) prio = 5 ;
224 attList << QString::number( prio ); 232 attList << QString::number( prio );
225 QString alarmString = "na"; 233 QString alarmString = "na";
226 Alarm *alarm; 234 Alarm *alarm;
227 if ( todo->alarms().count() > 0 ) { 235 if ( todo->alarms().count() > 0 ) {
228 alarm = todo->alarms().first(); 236 alarm = todo->alarms().first();
229 if ( alarm->enabled() ) { 237 if ( alarm->enabled() ) {
230 alarmString = QString::number(alarm->offset() ); 238 alarmString = QString::number(alarm->offset() );
@@ -524,159 +532,167 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
524 if ( a->hasTime() ) 532 if ( a->hasTime() )
525 b->setTime( a->time() ); 533 b->setTime( a->time() );
526 } 534 }
527 535
528 QStringList cat = to->categories(); 536 QStringList cat = to->categories();
529 QStringList catFrom = from->categories(); 537 QStringList catFrom = from->categories();
530 QString nCat; 538 QString nCat;
531 int iii; 539 int iii;
532 for ( iii = 0; iii < catFrom.count();++iii ) { 540 for ( iii = 0; iii < catFrom.count();++iii ) {
533 nCat = catFrom[iii]; 541 nCat = catFrom[iii];
534 if ( !nCat.isEmpty() ) 542 if ( !nCat.isEmpty() )
535 if ( !cat.contains( nCat )) { 543 if ( !cat.contains( nCat )) {
536 cat << nCat; 544 cat << nCat;
537 } 545 }
538 } 546 }
539 to->setCategories( cat ); 547 to->setCategories( cat );
540 if ( from->isCompleted() ) { 548 if ( from->isCompleted() ) {
541 to->setCompleted( true ); 549 to->setCompleted( true );
542 if( from->completed().isValid() ) 550 if( from->completed().isValid() )
543 to->setCompleted( from->completed() ); 551 to->setCompleted( from->completed() );
544 } else { 552 } else {
545 // set percentcomplete only, if to->isCompleted() 553 // set percentcomplete only, if to->isCompleted()
546 if ( to->isCompleted() ) 554 if ( to->isCompleted() )
547 to->setPercentComplete(from->percentComplete()); 555 to->setPercentComplete(from->percentComplete());
548 } 556 }
549 if( to->priority() == 2 && from->priority() == 1 ) 557 if( to->priority() == 2 && from->priority() == 1 )
550 ; //skip 558 ; //skip
551 else if (to->priority() == 4 && from->priority() == 5 ) 559 else if (to->priority() == 4 && from->priority() == 5 )
552 ; 560 ;
553 else 561 else
554 to->setPriority(from->priority()); 562 to->setPriority(from->priority());
555 563
556} 564}
557#include <qcstring.h> 565#include <qcstring.h>
558 566
559void PhoneFormat::afterSave( Incidence* inc) 567void PhoneFormat::afterSave( Incidence* inc)
560{ 568{
561 uint csum; 569 uint csum;
562 inc->removeID( mProfileName ); 570 inc->removeID( mProfileName );
563 if ( inc->type() == "Event") 571 if ( inc->type() == "Event")
564 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 572 csum = PhoneFormat::getCsumEvent( (Event*) inc );
565 else 573 else
566 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 574 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
567 inc->setCsum( mProfileName, QString::number( csum )); 575 inc->setCsum( mProfileName, QString::number( csum ));
568 576
569 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 577 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
570 578
571} 579}
580
581bool PhoneFormat::writeToPhone( Calendar * calendar)
582{
583#ifdef _WIN32_
584 QString fileName = locateLocal("tmp", "tempfile.vcs");
585#else
586 QString fileName = "/tmp/kdepimtemp.vcs";
587#endif
588
589 VCalFormat vfsave;
590 vfsave.setLocalTime ( true );
591 if ( ! vfsave.save( calendar, fileName ) )
592 return false;
593 // 4 call kammu
594#ifdef DESKTOP_VERSION
595 QString command ="./kammu --restore " + fileName ;
596#else
597 QString command ="kammu --restore " + fileName ;
598#endif
599 int ret;
600 while ( (ret = system ( command.latin1())) != 0 ) {
601 qDebug("Error S::command returned %d. asking users", ret);
602 int retval = KMessageBox::warningContinueCancel(0,
603 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone access"),i18n("Retry"),i18n("Cancel"));
604 if ( retval != KMessageBox::Continue )
605 return false;
606 }
607 return true;
608}
572bool PhoneFormat::save( Calendar *calendar) 609bool PhoneFormat::save( Calendar *calendar)
573{ 610{
574 QLabel status ( i18n(" Opening device ..."), 0 ); 611 QLabel status ( i18n(" Opening device ..."), 0 );
575 int w = status.sizeHint().width()+20 ; 612 int w = status.sizeHint().width()+20 ;
576 if ( w < 200 ) w = 230; 613 if ( w < 200 ) w = 230;
577 int h = status.sizeHint().height()+20 ; 614 int h = status.sizeHint().height()+20 ;
578 int dw = QApplication::desktop()->width(); 615 int dw = QApplication::desktop()->width();
579 int dh = QApplication::desktop()->height(); 616 int dh = QApplication::desktop()->height();
580 status.setCaption(i18n("Writing to phone...") ); 617 status.setCaption(i18n("Writing to phone...") );
581 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 618 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
582 status.show(); 619 status.show();
583 status.raise(); 620 status.raise();
584 qApp->processEvents(); 621 qApp->processEvents();
585 QString message; 622 QString message;
586#ifdef _WIN32_
587 QString fileName = locateLocal("tmp", "tempfile.vcs");
588#else
589 QString fileName = "/tmp/kdepimtemp.vcs";
590#endif
591 623
592 // 1 remove events which should be deleted 624 // 1 remove events which should be deleted
593 QPtrList<Event> er = calendar->rawEvents(); 625 QPtrList<Event> er = calendar->rawEvents();
594 Event* ev = er.first(); 626 Event* ev = er.first();
595 while ( ev ) { 627 while ( ev ) {
596 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 628 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
597 calendar->deleteEvent( ev ); 629 calendar->deleteEvent( ev );
598 } else { 630 } else {
599 631
600 } 632 }
601 ev = er.next(); 633 ev = er.next();
602 } 634 }
603 // 2 remove todos which should be deleted 635 // 2 remove todos which should be deleted
604 QPtrList<Todo> tl = calendar->rawTodos(); 636 QPtrList<Todo> tl = calendar->rawTodos();
605 Todo* to = tl.first(); 637 Todo* to = tl.first();
606 while ( to ) { 638 while ( to ) {
607 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 639 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
608 calendar->deleteTodo( to ); 640 calendar->deleteTodo( to );
609 } else { 641 } else {
610 if ( to->isCompleted()) { 642 if ( to->isCompleted()) {
611 calendar->deleteTodo( to ); 643 calendar->deleteTodo( to );
612 } 644 }
613 } 645 }
614 to = tl.next(); 646 to = tl.next();
615 } 647 }
616 // 3 save file 648 // 3 save file
617 VCalFormat vfsave; 649 if ( !writeToPhone( calendar ) )
618 vfsave.setLocalTime ( true );
619 if ( ! vfsave.save( calendar, fileName ) )
620 return false; 650 return false;
621 // 4 call kammu
622#ifdef DESKTOP_VERSION
623 QString command ="./kammu --restore " + fileName ;
624#else
625 QString command ="kammu --restore " + fileName ;
626#endif
627 int ret;
628 while ( (ret = system ( command.latin1())) != 0 ) {
629 qDebug("Error S::command returned %d. asking users", ret);
630 int retval = KMessageBox::warningContinueCancel(0,
631 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel"));
632 if ( retval != KMessageBox::Continue )
633 return false;
634 }
635 651
636 // 5 reread data 652 // 5 reread data
637 message = i18n(" Rereading all data ... "); 653 message = i18n(" Rereading all data ... ");
638 status.setText ( message ); 654 status.setText ( message );
639 qApp->processEvents(); 655 qApp->processEvents();
640 CalendarLocal* calendarTemp = new CalendarLocal(); 656 CalendarLocal* calendarTemp = new CalendarLocal();
641 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 657 calendarTemp->setTimeZoneId( calendar->timeZoneId());
642 if ( ! load( calendarTemp,calendar) ){ 658 if ( ! load( calendarTemp,calendar) ){
643 qDebug("error reloading calendar "); 659 qDebug("error reloading calendar ");
644 delete calendarTemp; 660 delete calendarTemp;
645 return false; 661 return false;
646 } 662 }
647 // 6 compare data 663 // 6 compare data
648 664
649//algo 6 compare event 665//algo 6 compare event
650 er = calendar->rawEvents(); 666 er = calendar->rawEvents();
651 ev = er.first(); 667 ev = er.first();
652 message = i18n(" Comparing event # "); 668 message = i18n(" Comparing event # ");
653 QPtrList<Event> er1 = calendarTemp->rawEvents(); 669 QPtrList<Event> er1 = calendarTemp->rawEvents();
654 Event* ev1; 670 Event* ev1;
655 int procCount = 0; 671 int procCount = 0;
656 while ( ev ) { 672 while ( ev ) {
657 //qDebug("event new ID %s",ev->summary().latin1()); 673 //qDebug("event new ID %s",ev->summary().latin1());
658 status.setText ( message + QString::number ( ++procCount ) ); 674 status.setText ( message + QString::number ( ++procCount ) );
659 qApp->processEvents(); 675 qApp->processEvents();
660 uint csum; 676 uint csum;
661 csum = PhoneFormat::getCsumEvent( ev ); 677 csum = PhoneFormat::getCsumEvent( ev );
662 QString cSum = QString::number( csum ); 678 QString cSum = QString::number( csum );
663 //ev->setCsum( mProfileName, cSum ); 679 //ev->setCsum( mProfileName, cSum );
664 //qDebug("Event cSum %s ", cSum.latin1()); 680 //qDebug("Event cSum %s ", cSum.latin1());
665 ev1 = er1.first(); 681 ev1 = er1.first();
666 while ( ev1 ) { 682 while ( ev1 ) {
667 if ( ev1->getCsum( mProfileName ) == cSum ) { 683 if ( ev1->getCsum( mProfileName ) == cSum ) {
668 er1.remove( ev1 ); 684 er1.remove( ev1 );
669 afterSave( ev ); 685 afterSave( ev );
670 ev->setID(mProfileName, ev1->getID(mProfileName) ); 686 ev->setID(mProfileName, ev1->getID(mProfileName) );
671 //qDebug("Event found on phone for %s ", ev->summary().latin1()); 687 //qDebug("Event found on phone for %s ", ev->summary().latin1());
672 688
673 break; 689 break;
674 } 690 }
675 ev1 = er1.next(); 691 ev1 = er1.next();
676 } 692 }
677 if ( ! ev1 ) { 693 if ( ! ev1 ) {
678 // ev->removeID(mProfileName); 694 // ev->removeID(mProfileName);
679 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 695 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
680 } 696 }
681 697
682 698
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 2d1ff79..61e8160 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -3,59 +3,61 @@
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 "vcalformat.h"
29#include "calformat.h" 29#include "calformat.h"
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 This class implements the calendar format used by Phone. 34 This class implements the calendar format used by Phone.
35*/ 35*/
36 class Event; 36 class Event;
37 class Todo; 37 class Todo;
38class PhoneFormat : public QObject { 38class PhoneFormat : public QObject {
39 public: 39 public:
40 /** Create new iCalendar format. */ 40 /** Create new iCalendar format. */
41 PhoneFormat(QString profileName, QString device,QString connection, QString model); 41 PhoneFormat(QString profileName, QString device,QString connection, QString model);
42 virtual ~PhoneFormat(); 42 virtual ~PhoneFormat();
43 43
44 bool load( Calendar * ,Calendar * ); 44 bool load( Calendar * ,Calendar * );
45 bool save( Calendar * ); 45 bool save( Calendar * );
46 bool fromString( Calendar *, const QString & ); 46 bool fromString( Calendar *, const QString & );
47 QString toString( Calendar * ); 47 QString toString( Calendar * );
48 static ulong getCsum( const QStringList & ); 48 static ulong getCsum( const QStringList & );
49 static ulong getCsumTodo( Todo* to ); 49 static ulong getCsumTodo( Todo* to );
50 static ulong getCsumEvent( Event* ev ); 50 static ulong getCsumEvent( Event* ev );
51 static void writeConfig( QString device,QString connection, QString model );
52 static bool writeToPhone( Calendar * );
51 private: 53 private:
52 void copyEvent( Event* to, Event* from ); 54 void copyEvent( Event* to, Event* from );
53 void copyTodo( Todo* to, Todo* from ); 55 void copyTodo( Todo* to, Todo* from );
54 //int initDevice(GSM_StateMachine *s); 56 //int initDevice(GSM_StateMachine *s);
55 QString mProfileName; 57 QString mProfileName;
56 void afterSave( Incidence* ); 58 void afterSave( Incidence* );
57}; 59};
58 60
59} 61}
60 62
61#endif 63#endif