summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-04 22:10:20 (UTC)
committer zautrix <zautrix>2004-10-04 22:10:20 (UTC)
commitc22811d11414872fc0525350a8a1afdae61be346 (patch) (unidiff)
treedaafa0c4333022d44dafb2945ba36ff58d5c45d1
parentf53ef630b9299ceae666e64da8ce022813795ed6 (diff)
downloadkdepimpi-c22811d11414872fc0525350a8a1afdae61be346.zip
kdepimpi-c22811d11414872fc0525350a8a1afdae61be346.tar.gz
kdepimpi-c22811d11414872fc0525350a8a1afdae61be346.tar.bz2
many sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp98
-rw-r--r--korganizer/mainwindow.h2
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
3 files changed, 33 insertions, 73 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index bce2a54..fe7e6d3 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2677 +1,2635 @@
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 <qmap.h> 16#include <qmap.h>
17#include <qwmatrix.h> 17#include <qwmatrix.h>
18#include <qtextbrowser.h> 18#include <qtextbrowser.h>
19#include <qtextstream.h> 19#include <qtextstream.h>
20#ifndef DESKTOP_VERSION 20#ifndef DESKTOP_VERSION
21#include <qpe/global.h> 21#include <qpe/global.h>
22#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
23#include <qpe/qpetoolbar.h> 23#include <qpe/qpetoolbar.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qtopia/alarmserver.h> 26#include <qtopia/alarmserver.h>
27#include <qtopia/qcopenvelope_qws.h> 27#include <qtopia/qcopenvelope_qws.h>
28#include <unistd.h> // for sleep 28#include <unistd.h> // for sleep
29#else 29#else
30#include <qmenubar.h> 30#include <qmenubar.h>
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <resource.h> 33//#include <resource.h>
34 34
35#endif 35#endif
36#include <libkcal/calendarlocal.h> 36#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 37#include <libkcal/todo.h>
38#include <libkdepim/ksyncprofile.h> 38#include <libkdepim/ksyncprofile.h>
39#include <libkcal/kincidenceformatter.h> 39#include <libkcal/kincidenceformatter.h>
40#include <libkdepim/kpimglobalprefs.h> 40#include <libkdepim/kpimglobalprefs.h>
41 41
42#include "calendarview.h" 42#include "calendarview.h"
43#include "koviewmanager.h" 43#include "koviewmanager.h"
44#include "datenavigator.h" 44#include "datenavigator.h"
45#include "koagendaview.h" 45#include "koagendaview.h"
46#include "koagenda.h" 46#include "koagenda.h"
47#include "kodialogmanager.h" 47#include "kodialogmanager.h"
48#include "kdialogbase.h" 48#include "kdialogbase.h"
49#include "kapplication.h" 49#include "kapplication.h"
50#include "kofilterview.h" 50#include "kofilterview.h"
51#include "kstandarddirs.h" 51#include "kstandarddirs.h"
52#include "koprefs.h" 52#include "koprefs.h"
53#include "kfiledialog.h" 53#include "kfiledialog.h"
54#include "koglobals.h" 54#include "koglobals.h"
55#include "kglobal.h" 55#include "kglobal.h"
56#include "klocale.h" 56#include "klocale.h"
57#include "kconfig.h" 57#include "kconfig.h"
58#include "simplealarmclient.h" 58#include "simplealarmclient.h"
59#include "externalapphandler.h" 59#include "externalapphandler.h"
60 60
61using namespace KCal; 61using namespace KCal;
62#ifndef _WIN32_ 62#ifndef _WIN32_
63#include <unistd.h> 63#include <unistd.h>
64#else 64#else
65#include "koimportoldialog.h" 65#include "koimportoldialog.h"
66#endif 66#endif
67#include "mainwindow.h" 67#include "mainwindow.h"
68 68
69int globalFlagBlockStartup; 69int globalFlagBlockStartup;
70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
71 QMainWindow( parent, name ) 71 QMainWindow( parent, name )
72{ 72{
73 mPassWordPiSync = "abc"; 73 mPassWordPiSync = "abc";
74#ifdef DESKTOP_VERSION 74#ifdef DESKTOP_VERSION
75 setFont( QFont("Arial"), 14 ); 75 setFont( QFont("Arial"), 14 );
76#endif 76#endif
77 mSyncActionDialog = 0; 77 mSyncActionDialog = 0;
78 mServerSocket = 0; 78 mServerSocket = 0;
79 mClosed = false; 79 mClosed = false;
80 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 80 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
81 QString confFile = locateLocal("config","korganizerrc"); 81 QString confFile = locateLocal("config","korganizerrc");
82 QFileInfo finf ( confFile ); 82 QFileInfo finf ( confFile );
83 bool showWarning = !finf.exists(); 83 bool showWarning = !finf.exists();
84 setIcon(SmallIcon( "ko24" ) ); 84 setIcon(SmallIcon( "ko24" ) );
85 mBlockAtStartup = true; 85 mBlockAtStartup = true;
86 mFlagKeyPressed = false; 86 mFlagKeyPressed = false;
87 setCaption("KOrganizer/Pi"); 87 setCaption("KOrganizer/Pi");
88 KOPrefs *p = KOPrefs::instance(); 88 KOPrefs *p = KOPrefs::instance();
89 KPimGlobalPrefs::instance()->setGlobalConfig(); 89 KPimGlobalPrefs::instance()->setGlobalConfig();
90 // if ( QApplication::desktop()->height() > 480 ) { 90 // if ( QApplication::desktop()->height() > 480 ) {
91// if ( p->mHourSize == 4 ) 91// if ( p->mHourSize == 4 )
92// p->mHourSize = 6; 92// p->mHourSize = 6;
93// } 93// }
94 if ( p->mHourSize > 18 ) 94 if ( p->mHourSize > 18 )
95 p->mHourSize = 18; 95 p->mHourSize = 18;
96 QMainWindow::ToolBarDock tbd; 96 QMainWindow::ToolBarDock tbd;
97 if ( p->mToolBarHor ) { 97 if ( p->mToolBarHor ) {
98 if ( p->mToolBarUp ) 98 if ( p->mToolBarUp )
99 tbd = Bottom; 99 tbd = Bottom;
100 else 100 else
101 tbd = Top; 101 tbd = Top;
102 } 102 }
103 else { 103 else {
104 if ( p->mToolBarUp ) 104 if ( p->mToolBarUp )
105 tbd = Right; 105 tbd = Right;
106 else 106 else
107 tbd = Left; 107 tbd = Left;
108 } 108 }
109 if ( KOPrefs::instance()->mUseAppColors ) 109 if ( KOPrefs::instance()->mUseAppColors )
110 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 110 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
111 globalFlagBlockStartup = 1; 111 globalFlagBlockStartup = 1;
112 iconToolBar = new QPEToolBar( this ); 112 iconToolBar = new QPEToolBar( this );
113 addToolBar (iconToolBar , tbd ); 113 addToolBar (iconToolBar , tbd );
114 mBlockSaveFlag = false; 114 mBlockSaveFlag = false;
115 mCalendarModifiedFlag = false; 115 mCalendarModifiedFlag = false;
116 116
117 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 117 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
118 splash->setAlignment ( AlignCenter ); 118 splash->setAlignment ( AlignCenter );
119 setCentralWidget( splash ); 119 setCentralWidget( splash );
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121 showMaximized(); 121 showMaximized();
122#endif 122#endif
123 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 123 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
124 setDefaultPreferences(); 124 setDefaultPreferences();
125 mCalendar = new CalendarLocal(); 125 mCalendar = new CalendarLocal();
126 mView = new CalendarView( mCalendar, this,"mCalendar " ); 126 mView = new CalendarView( mCalendar, this,"mCalendar " );
127 mView->hide(); 127 mView->hide();
128 //mView->resize(splash->size() ); 128 //mView->resize(splash->size() );
129 initActions(); 129 initActions();
130#ifndef DESKTOP_VERSION 130#ifndef DESKTOP_VERSION
131 iconToolBar->show(); 131 iconToolBar->show();
132 qApp->processEvents(); 132 qApp->processEvents();
133#endif 133#endif
134 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 134 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
135 int vh = height() ; 135 int vh = height() ;
136 int vw = width(); 136 int vw = width();
137 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 137 //qDebug("Toolbar hei %d ",iconToolBar->height() );
138 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 138 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
139 vh -= iconToolBar->height(); 139 vh -= iconToolBar->height();
140 } else { 140 } else {
141 vw -= iconToolBar->height(); 141 vw -= iconToolBar->height();
142 } 142 }
143 //mView->setMaximumSize( splash->size() ); 143 //mView->setMaximumSize( splash->size() );
144 //mView->resize( splash->size() ); 144 //mView->resize( splash->size() );
145 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 145 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
146 mView->readSettings(); 146 mView->readSettings();
147 bool oldOpened = false; 147 bool oldOpened = false;
148 bool newFile = false; 148 bool newFile = false;
149 if( !QFile::exists( defaultFileName() ) ) { 149 if( !QFile::exists( defaultFileName() ) ) {
150 QFileInfo finfo ( defaultFileName() ); 150 QFileInfo finfo ( defaultFileName() );
151 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 151 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
152 qDebug("oldfile %s ", oldFile.latin1()); 152 qDebug("oldfile %s ", oldFile.latin1());
153 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"; 153 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";
154 finfo.setFile( oldFile ); 154 finfo.setFile( oldFile );
155 if (finfo.exists() ) { 155 if (finfo.exists() ) {
156 KMessageBox::information( this, message); 156 KMessageBox::information( this, message);
157 mView->openCalendar( oldFile ); 157 mView->openCalendar( oldFile );
158 qApp->processEvents(); 158 qApp->processEvents();
159 } else { 159 } else {
160 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 160 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
161 finfo.setFile( oldFile ); 161 finfo.setFile( oldFile );
162 if (finfo.exists() ) { 162 if (finfo.exists() ) {
163 KMessageBox::information( this, message); 163 KMessageBox::information( this, message);
164 mView->openCalendar( oldFile ); 164 mView->openCalendar( oldFile );
165 qApp->processEvents(); 165 qApp->processEvents();
166 } 166 }
167 } 167 }
168 mView->saveCalendar( defaultFileName() ); 168 mView->saveCalendar( defaultFileName() );
169 newFile = true; 169 newFile = true;
170 } 170 }
171 171
172 QTime neededSaveTime = QDateTime::currentDateTime().time(); 172 QTime neededSaveTime = QDateTime::currentDateTime().time();
173 if ( ! oldOpened ) 173 if ( ! oldOpened )
174 mView->openCalendar( defaultFileName() ); 174 mView->openCalendar( defaultFileName() );
175 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 175 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
176 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 176 qDebug("KO: Calendar loading time: %d ms",msNeeded );
177 177
178 if ( KOPrefs::instance()->mLanguageChanged ) { 178 if ( KOPrefs::instance()->mLanguageChanged ) {
179 KOPrefs::instance()->setCategoryDefaults(); 179 KOPrefs::instance()->setCategoryDefaults();
180 int count = mView->addCategories(); 180 int count = mView->addCategories();
181 KOPrefs::instance()->mLanguageChanged = false; 181 KOPrefs::instance()->mLanguageChanged = false;
182 } 182 }
183 processIncidenceSelection( 0 ); 183 processIncidenceSelection( 0 );
184 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 184 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
185 SLOT( processIncidenceSelection( Incidence * ) ) ); 185 SLOT( processIncidenceSelection( Incidence * ) ) );
186 connect( mView, SIGNAL( modifiedChanged( bool ) ), 186 connect( mView, SIGNAL( modifiedChanged( bool ) ),
187 SLOT( slotModifiedChanged( bool ) ) ); 187 SLOT( slotModifiedChanged( bool ) ) );
188 188
189 189
190 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 190 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
191 mView->setModified( false ); 191 mView->setModified( false );
192 mBlockAtStartup = false; 192 mBlockAtStartup = false;
193 mView->setModified( false ); 193 mView->setModified( false );
194 setCentralWidget( mView ); 194 setCentralWidget( mView );
195 globalFlagBlockStartup = 0; 195 globalFlagBlockStartup = 0;
196 mView->show(); 196 mView->show();
197 delete splash; 197 delete splash;
198 if ( newFile ) 198 if ( newFile )
199 mView->updateConfig(); 199 mView->updateConfig();
200 // qApp->processEvents(); 200 // qApp->processEvents();
201 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 201 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
202 fillSyncMenu(); 202 fillSyncMenu();
203 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 203 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
204 if ( showWarning ) { 204 if ( showWarning ) {
205 KMessageBox::information( this, 205 KMessageBox::information( this,
206 "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"); 206 "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");
207 qApp->processEvents(); 207 qApp->processEvents();
208 mView->dialogManager()->showSyncOptions(); 208 mView->dialogManager()->showSyncOptions();
209 } 209 }
210 210
211 //US listen for result adressed from Ka/Pi 211 //US listen for result adressed from Ka/Pi
212#ifndef DESKTOP_VERSION 212#ifndef DESKTOP_VERSION
213 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 213 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
214#endif 214#endif
215} 215}
216MainWindow::~MainWindow() 216MainWindow::~MainWindow()
217{ 217{
218 //qDebug("MainWindow::~MainWindow() "); 218 //qDebug("MainWindow::~MainWindow() ");
219 //save toolbar location 219 //save toolbar location
220 delete mServerSocket; 220 delete mServerSocket;
221 delete mCalendar; 221 delete mCalendar;
222 delete KOPrefs::instance(); 222 delete KOPrefs::instance();
223 delete KIncidenceFormatter::instance(); 223 delete KIncidenceFormatter::instance();
224 224
225 225
226} 226}
227void MainWindow::showMaximized () 227void MainWindow::showMaximized ()
228{ 228{
229#ifndef DESKTOP_VERSION 229#ifndef DESKTOP_VERSION
230 if ( ! globalFlagBlockStartup ) 230 if ( ! globalFlagBlockStartup )
231 if ( mClosed ) 231 if ( mClosed )
232 mView->goToday(); 232 mView->goToday();
233#endif 233#endif
234 QWidget::showMaximized () ; 234 QWidget::showMaximized () ;
235 mClosed = false; 235 mClosed = false;
236} 236}
237void MainWindow::closeEvent( QCloseEvent* ce ) 237void MainWindow::closeEvent( QCloseEvent* ce )
238{ 238{
239 239
240 240
241 241
242 if ( ! KOPrefs::instance()->mAskForQuit ) { 242 if ( ! KOPrefs::instance()->mAskForQuit ) {
243 saveOnClose(); 243 saveOnClose();
244 mClosed = true; 244 mClosed = true;
245 ce->accept(); 245 ce->accept();
246 return; 246 return;
247 247
248 } 248 }
249 249
250 switch( QMessageBox::information( this, "KO/Pi", 250 switch( QMessageBox::information( this, "KO/Pi",
251 i18n("Do you really want\nto close KO/Pi?"), 251 i18n("Do you really want\nto close KO/Pi?"),
252 i18n("Close"), i18n("No"), 252 i18n("Close"), i18n("No"),
253 0, 0 ) ) { 253 0, 0 ) ) {
254 case 0: 254 case 0:
255 saveOnClose(); 255 saveOnClose();
256 mClosed = true; 256 mClosed = true;
257 ce->accept(); 257 ce->accept();
258 break; 258 break;
259 case 1: 259 case 1:
260 ce->ignore(); 260 ce->ignore();
261 break; 261 break;
262 case 2: 262 case 2:
263 263
264 default: 264 default:
265 break; 265 break;
266 } 266 }
267 267
268 268
269} 269}
270 270
271void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 271void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
272{ 272{
273 QDataStream stream( data, IO_ReadOnly ); 273 QDataStream stream( data, IO_ReadOnly );
274 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 274 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
275 //QString datamess; 275 //QString datamess;
276 //qDebug("message "); 276 //qDebug("message ");
277 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 277 qDebug("KO: QCOP message received: %s ", cmsg.data() );
278 278
279 if ( cmsg == "-writeFile" ) { 279 if ( cmsg == "-writeFile" ) {
280 // I made from the "-writeFile" an "-writeAlarm" 280 // I made from the "-writeFile" an "-writeAlarm"
281 mView->viewManager()->showWhatsNextView(); 281 mView->viewManager()->showWhatsNextView();
282 mCalendar->checkAlarmForIncidence( 0, true); 282 mCalendar->checkAlarmForIncidence( 0, true);
283 showMaximized(); 283 showMaximized();
284 raise(); 284 raise();
285 return; 285 return;
286 } 286 }
287 287
288 if ( cmsg == "-writeFile" ) { 288 if ( cmsg == "-writeFile" ) {
289 // I made from the "-writeFile" an "-writeAlarm" 289 // I made from the "-writeFile" an "-writeAlarm"
290 mView->viewManager()->showWhatsNextView(); 290 mView->viewManager()->showWhatsNextView();
291 mCalendar->checkAlarmForIncidence( 0, true); 291 mCalendar->checkAlarmForIncidence( 0, true);
292 showMaximized(); 292 showMaximized();
293 raise(); 293 raise();
294 return; 294 return;
295 295
296 } 296 }
297 if ( cmsg == "-writeFileSilent" ) { 297 if ( cmsg == "-writeFileSilent" ) {
298 // I made from the "-writeFile" an "-writeAlarm" 298 // I made from the "-writeFile" an "-writeAlarm"
299 // mView->viewManager()->showWhatsNextView(); 299 // mView->viewManager()->showWhatsNextView();
300 mCalendar->checkAlarmForIncidence( 0, true); 300 mCalendar->checkAlarmForIncidence( 0, true);
301 //showMaximized(); 301 //showMaximized();
302 //raise(); 302 //raise();
303 hide(); 303 hide();
304 return; 304 return;
305 } 305 }
306 if ( cmsg == "-newCountdown" ) { 306 if ( cmsg == "-newCountdown" ) {
307 qDebug("newCountdown "); 307 qDebug("newCountdown ");
308 308
309 } 309 }
310 QString msg ; 310 QString msg ;
311 QString allmsg = cmsg; 311 QString allmsg = cmsg;
312 while ( allmsg.length() > 0 ) { 312 while ( allmsg.length() > 0 ) {
313 int nextC = allmsg.find( "-", 1 ); 313 int nextC = allmsg.find( "-", 1 );
314 if ( nextC == -1 ) { 314 if ( nextC == -1 ) {
315 msg = allmsg; 315 msg = allmsg;
316 allmsg = ""; 316 allmsg = "";
317 } else{ 317 } else{
318 msg = allmsg.left( nextC ); 318 msg = allmsg.left( nextC );
319 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 319 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
320 } 320 }
321 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 321 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
322 if ( msg == "-newEvent" ) { 322 if ( msg == "-newEvent" ) {
323 mView->newEvent(); 323 mView->newEvent();
324 } 324 }
325 if ( msg == "-newTodo" ) { 325 if ( msg == "-newTodo" ) {
326 mView->newTodo(); 326 mView->newTodo();
327 327
328 } 328 }
329 if ( msg == "-showWN" ) { 329 if ( msg == "-showWN" ) {
330 mView->viewManager()->showWhatsNextView(); 330 mView->viewManager()->showWhatsNextView();
331 } 331 }
332 if ( msg == "-showTodo" ) { 332 if ( msg == "-showTodo" ) {
333 mView->viewManager()->showTodoView(); 333 mView->viewManager()->showTodoView();
334 } 334 }
335 if ( msg == "-showList" ) { 335 if ( msg == "-showList" ) {
336 mView->viewManager()->showListView(); 336 mView->viewManager()->showListView();
337 } 337 }
338 else if ( msg == "-showDay" ) { 338 else if ( msg == "-showDay" ) {
339 mView->viewManager()->showDayView(); 339 mView->viewManager()->showDayView();
340 } 340 }
341 else if ( msg == "-showWWeek" ) { 341 else if ( msg == "-showWWeek" ) {
342 mView->viewManager()->showWorkWeekView(); 342 mView->viewManager()->showWorkWeekView();
343 } 343 }
344 else if ( msg == "-ringSync" ) { 344 else if ( msg == "-ringSync" ) {
345 multiSync( false ); 345 multiSync( false );
346 } 346 }
347 else if ( msg == "-showWeek" ) { 347 else if ( msg == "-showWeek" ) {
348 mView->viewManager()->showWeekView(); 348 mView->viewManager()->showWeekView();
349 } 349 }
350 else if ( msg == "-showTodo" ) { 350 else if ( msg == "-showTodo" ) {
351 mView->viewManager()->showTodoView(); 351 mView->viewManager()->showTodoView();
352 } 352 }
353 else if ( msg == "-showJournal" ) { 353 else if ( msg == "-showJournal" ) {
354 mView->dateNavigator()->selectDates( 1 ); 354 mView->dateNavigator()->selectDates( 1 );
355 mView->dateNavigator()->selectToday(); 355 mView->dateNavigator()->selectToday();
356 mView->viewManager()->showJournalView(); 356 mView->viewManager()->showJournalView();
357 } 357 }
358 else if ( msg == "-showKO" ) { 358 else if ( msg == "-showKO" ) {
359 mView->viewManager()->showNextXView(); 359 mView->viewManager()->showNextXView();
360 } 360 }
361 else if ( msg == "-showWNext" || msg == "nextView()" ) { 361 else if ( msg == "-showWNext" || msg == "nextView()" ) {
362 mView->viewManager()->showWhatsNextView(); 362 mView->viewManager()->showWhatsNextView();
363 } 363 }
364 else if ( msg == "-showNextXView" ) { 364 else if ( msg == "-showNextXView" ) {
365 mView->viewManager()->showNextXView(); 365 mView->viewManager()->showNextXView();
366 } 366 }
367 367
368 368
369 } 369 }
370 370
371 showMaximized(); 371 showMaximized();
372 raise(); 372 raise();
373} 373}
374 374
375QPixmap MainWindow::loadPixmap( QString name ) 375QPixmap MainWindow::loadPixmap( QString name )
376{ 376{
377 return SmallIcon( name ); 377 return SmallIcon( name );
378 378
379} 379}
380void MainWindow::initActions() 380void MainWindow::initActions()
381{ 381{
382 //KOPrefs::instance()->mShowFullMenu 382 //KOPrefs::instance()->mShowFullMenu
383 iconToolBar->clear(); 383 iconToolBar->clear();
384 KOPrefs *p = KOPrefs::instance(); 384 KOPrefs *p = KOPrefs::instance();
385 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 385 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
386 386
387 QPopupMenu *viewMenu = new QPopupMenu( this ); 387 QPopupMenu *viewMenu = new QPopupMenu( this );
388 QPopupMenu *actionMenu = new QPopupMenu( this ); 388 QPopupMenu *actionMenu = new QPopupMenu( this );
389 QPopupMenu *importMenu = new QPopupMenu( this ); 389 QPopupMenu *importMenu = new QPopupMenu( this );
390 selectFilterMenu = new QPopupMenu( this ); 390 selectFilterMenu = new QPopupMenu( this );
391 selectFilterMenu->setCheckable( true ); 391 selectFilterMenu->setCheckable( true );
392 syncMenu = new QPopupMenu( this ); 392 syncMenu = new QPopupMenu( this );
393 configureAgendaMenu = new QPopupMenu( this ); 393 configureAgendaMenu = new QPopupMenu( this );
394 configureToolBarMenu = new QPopupMenu( this ); 394 configureToolBarMenu = new QPopupMenu( this );
395 QPopupMenu *helpMenu = new QPopupMenu( this ); 395 QPopupMenu *helpMenu = new QPopupMenu( this );
396 if ( KOPrefs::instance()->mShowFullMenu ) { 396 if ( KOPrefs::instance()->mShowFullMenu ) {
397 QMenuBar *menuBar1; 397 QMenuBar *menuBar1;
398 menuBar1 = menuBar(); 398 menuBar1 = menuBar();
399 menuBar1->insertItem( i18n("File"), importMenu ); 399 menuBar1->insertItem( i18n("File"), importMenu );
400 menuBar1->insertItem( i18n("View"), viewMenu ); 400 menuBar1->insertItem( i18n("View"), viewMenu );
401 menuBar1->insertItem( i18n("Actions"), actionMenu ); 401 menuBar1->insertItem( i18n("Actions"), actionMenu );
402 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 402 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
403 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 403 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
404 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 404 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
405 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 405 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
406 menuBar1->insertItem( i18n("Help"), helpMenu ); 406 menuBar1->insertItem( i18n("Help"), helpMenu );
407 } else { 407 } else {
408 QPEMenuBar *menuBar1; 408 QPEMenuBar *menuBar1;
409 menuBar1 = new QPEMenuBar( iconToolBar ); 409 menuBar1 = new QPEMenuBar( iconToolBar );
410 QPopupMenu *menuBar = new QPopupMenu( this ); 410 QPopupMenu *menuBar = new QPopupMenu( this );
411 menuBar1->insertItem( i18n("ME"), menuBar); 411 menuBar1->insertItem( i18n("ME"), menuBar);
412 menuBar->insertItem( i18n("File"), importMenu ); 412 menuBar->insertItem( i18n("File"), importMenu );
413 menuBar->insertItem( i18n("View"), viewMenu ); 413 menuBar->insertItem( i18n("View"), viewMenu );
414 menuBar->insertItem( i18n("Actions"), actionMenu ); 414 menuBar->insertItem( i18n("Actions"), actionMenu );
415 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 415 menuBar->insertItem( i18n("Synchronize"), syncMenu );
416 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 416 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
417 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 417 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
418 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 418 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
419 menuBar->insertItem( i18n("Help"), helpMenu ); 419 menuBar->insertItem( i18n("Help"), helpMenu );
420 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 420 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
421 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 421 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
422 } 422 }
423 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 423 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
424 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 424 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
425 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 425 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
426 426
427 // ****************** 427 // ******************
428 QAction *action; 428 QAction *action;
429 QIconSet icon; 429 QIconSet icon;
430 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 430 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
431 configureToolBarMenu->setCheckable( true ); 431 configureToolBarMenu->setCheckable( true );
432 432
433 QString pathString = ""; 433 QString pathString = "";
434 if ( !p->mToolBarMiniIcons ) { 434 if ( !p->mToolBarMiniIcons ) {
435 if ( QApplication::desktop()->width() < 480 ) 435 if ( QApplication::desktop()->width() < 480 )
436 pathString += "icons16/"; 436 pathString += "icons16/";
437 } else 437 } else
438 pathString += "iconsmini/"; 438 pathString += "iconsmini/";
439 configureAgendaMenu->setCheckable( true ); 439 configureAgendaMenu->setCheckable( true );
440 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 440 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
441 configureAgendaMenu->insertSeparator(); 441 configureAgendaMenu->insertSeparator();
442 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 442 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
443 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 443 configureAgendaMenu->insertItem(i18n("Small"), 6 );
444 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 444 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
445 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 445 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
446 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 446 configureAgendaMenu->insertItem(i18n("Large"), 12 );
447 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 447 configureAgendaMenu->insertItem(i18n("Big"), 14 );
448 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 448 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
449 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 449 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
450 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 450 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
451 451
452 icon = loadPixmap( pathString + "configure" ); 452 icon = loadPixmap( pathString + "configure" );
453 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 453 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
454 action->addTo( actionMenu ); 454 action->addTo( actionMenu );
455 connect( action, SIGNAL( activated() ), 455 connect( action, SIGNAL( activated() ),
456 mView, SLOT( edit_options() ) ); 456 mView, SLOT( edit_options() ) );
457 actionMenu->insertSeparator(); 457 actionMenu->insertSeparator();
458 icon = loadPixmap( pathString + "newevent" ); 458 icon = loadPixmap( pathString + "newevent" );
459 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 459 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
460 configureToolBarMenu->insertSeparator(); 460 configureToolBarMenu->insertSeparator();
461 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 461 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
462 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 462 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
463 ne_action->addTo( actionMenu ); 463 ne_action->addTo( actionMenu );
464 connect( ne_action, SIGNAL( activated() ), 464 connect( ne_action, SIGNAL( activated() ),
465 mView, SLOT( newEvent() ) ); 465 mView, SLOT( newEvent() ) );
466 icon = loadPixmap( pathString + "newtodo" ); 466 icon = loadPixmap( pathString + "newtodo" );
467 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 467 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
468 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 468 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
469 nt_action->addTo( actionMenu ); 469 nt_action->addTo( actionMenu );
470 connect( nt_action, SIGNAL( activated() ), 470 connect( nt_action, SIGNAL( activated() ),
471 mView, SLOT( newTodo() ) ); 471 mView, SLOT( newTodo() ) );
472 icon = loadPixmap( pathString + "navi" ); 472 icon = loadPixmap( pathString + "navi" );
473 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 473 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
474 action->addTo( viewMenu ); 474 action->addTo( viewMenu );
475 connect( action, SIGNAL( activated() ), 475 connect( action, SIGNAL( activated() ),
476 mView, SLOT( toggleDateNavigatorWidget() ) ); 476 mView, SLOT( toggleDateNavigatorWidget() ) );
477 icon = loadPixmap( pathString + "filter" ); 477 icon = loadPixmap( pathString + "filter" );
478 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 478 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
479 action->addTo( viewMenu ); 479 action->addTo( viewMenu );
480 connect( action, SIGNAL( activated() ), 480 connect( action, SIGNAL( activated() ),
481 mView, SLOT( toggleFilter() ) ); 481 mView, SLOT( toggleFilter() ) );
482 482
483 483
484 viewMenu->insertSeparator(); 484 viewMenu->insertSeparator();
485 icon = loadPixmap( pathString + "picker" ); 485 icon = loadPixmap( pathString + "picker" );
486 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 486 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
487 action->addTo( viewMenu ); 487 action->addTo( viewMenu );
488 connect( action, SIGNAL( activated() ), 488 connect( action, SIGNAL( activated() ),
489 mView, SLOT( showDatePicker() ) ); 489 mView, SLOT( showDatePicker() ) );
490 action->addTo( iconToolBar ); 490 action->addTo( iconToolBar );
491 viewMenu->insertSeparator(); 491 viewMenu->insertSeparator();
492 icon = loadPixmap( pathString + "list" ); 492 icon = loadPixmap( pathString + "list" );
493 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 493 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
494 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 494 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
495 showlist_action->addTo( viewMenu ); 495 showlist_action->addTo( viewMenu );
496 connect( showlist_action, SIGNAL( activated() ), 496 connect( showlist_action, SIGNAL( activated() ),
497 mView->viewManager(), SLOT( showListView() ) ); 497 mView->viewManager(), SLOT( showListView() ) );
498 498
499 499
500 icon = loadPixmap( pathString + "day" ); 500 icon = loadPixmap( pathString + "day" );
501 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 501 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
502 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 502 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
503 day1_action->addTo( viewMenu ); 503 day1_action->addTo( viewMenu );
504 // action->addTo( toolBar ); 504 // action->addTo( toolBar );
505 connect( day1_action, SIGNAL( activated() ), 505 connect( day1_action, SIGNAL( activated() ),
506 mView->viewManager(), SLOT( showDayView() ) ); 506 mView->viewManager(), SLOT( showDayView() ) );
507 507
508 icon = loadPixmap( pathString + "workweek" ); 508 icon = loadPixmap( pathString + "workweek" );
509 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 509 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
510 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 510 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
511 day5_action->addTo( viewMenu ); 511 day5_action->addTo( viewMenu );
512 connect( day5_action, SIGNAL( activated() ), 512 connect( day5_action, SIGNAL( activated() ),
513 mView->viewManager(), SLOT( showWorkWeekView() ) ); 513 mView->viewManager(), SLOT( showWorkWeekView() ) );
514 514
515 icon = loadPixmap( pathString + "week" ); 515 icon = loadPixmap( pathString + "week" );
516 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 516 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
517 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 517 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
518 day7_action->addTo( viewMenu ); 518 day7_action->addTo( viewMenu );
519 connect( day7_action, SIGNAL( activated() ), 519 connect( day7_action, SIGNAL( activated() ),
520 mView->viewManager(), SLOT( showWeekView() ) ); 520 mView->viewManager(), SLOT( showWeekView() ) );
521 521
522 icon = loadPixmap( pathString + "month" ); 522 icon = loadPixmap( pathString + "month" );
523 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 523 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
524 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 524 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
525 month_action->addTo( viewMenu ); 525 month_action->addTo( viewMenu );
526 connect( month_action, SIGNAL( activated() ), 526 connect( month_action, SIGNAL( activated() ),
527 mView->viewManager(), SLOT( showMonthView() ) ); 527 mView->viewManager(), SLOT( showMonthView() ) );
528 528
529 icon = loadPixmap( pathString + "todo" ); 529 icon = loadPixmap( pathString + "todo" );
530 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 530 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
531 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 531 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
532 todoview_action->addTo( viewMenu ); 532 todoview_action->addTo( viewMenu );
533 connect( todoview_action, SIGNAL( activated() ), 533 connect( todoview_action, SIGNAL( activated() ),
534 mView->viewManager(), SLOT( showTodoView() ) ); 534 mView->viewManager(), SLOT( showTodoView() ) );
535 535
536 icon = loadPixmap( pathString + "journal" ); 536 icon = loadPixmap( pathString + "journal" );
537 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 537 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
538 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 538 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
539 viewjournal_action->addTo( viewMenu ); 539 viewjournal_action->addTo( viewMenu );
540 connect( viewjournal_action, SIGNAL( activated() ), 540 connect( viewjournal_action, SIGNAL( activated() ),
541 mView->viewManager(), SLOT( showJournalView() ) ); 541 mView->viewManager(), SLOT( showJournalView() ) );
542 542
543 icon = loadPixmap( pathString + "xdays" ); 543 icon = loadPixmap( pathString + "xdays" );
544 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 544 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
545 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 545 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
546 xdays_action->addTo( viewMenu ); 546 xdays_action->addTo( viewMenu );
547 connect( xdays_action, SIGNAL( activated() ), 547 connect( xdays_action, SIGNAL( activated() ),
548 mView->viewManager(), SLOT( showNextXView() ) ); 548 mView->viewManager(), SLOT( showNextXView() ) );
549 549
550 icon = loadPixmap( pathString + "whatsnext" ); 550 icon = loadPixmap( pathString + "whatsnext" );
551 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 551 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
552 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 552 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
553 whatsnext_action->addTo( viewMenu ); 553 whatsnext_action->addTo( viewMenu );
554 connect( whatsnext_action, SIGNAL( activated() ), 554 connect( whatsnext_action, SIGNAL( activated() ),
555 mView->viewManager(), SLOT( showWhatsNextView() ) ); 555 mView->viewManager(), SLOT( showWhatsNextView() ) );
556 556
557#if 0 557#if 0
558 action = new QAction( "view_timespan", "Time Span", 0, this ); 558 action = new QAction( "view_timespan", "Time Span", 0, this );
559 action->addTo( viewMenu ); 559 action->addTo( viewMenu );
560 connect( action, SIGNAL( activated() ), 560 connect( action, SIGNAL( activated() ),
561 mView->viewManager(), SLOT( showTimeSpanView() ) ); 561 mView->viewManager(), SLOT( showTimeSpanView() ) );
562#endif 562#endif
563 563
564 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 564 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
565 this ); 565 this );
566 mNewSubTodoAction->addTo( actionMenu ); 566 mNewSubTodoAction->addTo( actionMenu );
567 connect( mNewSubTodoAction, SIGNAL( activated() ), 567 connect( mNewSubTodoAction, SIGNAL( activated() ),
568 mView, SLOT( newSubTodo() ) ); 568 mView, SLOT( newSubTodo() ) );
569 569
570 actionMenu->insertSeparator(); 570 actionMenu->insertSeparator();
571 571
572 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 572 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
573 mShowAction->addTo( actionMenu ); 573 mShowAction->addTo( actionMenu );
574 connect( mShowAction, SIGNAL( activated() ), 574 connect( mShowAction, SIGNAL( activated() ),
575 mView, SLOT( showIncidence() ) ); 575 mView, SLOT( showIncidence() ) );
576 576
577 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 577 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
578 mEditAction->addTo( actionMenu ); 578 mEditAction->addTo( actionMenu );
579 connect( mEditAction, SIGNAL( activated() ), 579 connect( mEditAction, SIGNAL( activated() ),
580 mView, SLOT( editIncidence() ) ); 580 mView, SLOT( editIncidence() ) );
581 581
582 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 582 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
583 mDeleteAction->addTo( actionMenu ); 583 mDeleteAction->addTo( actionMenu );
584 connect( mDeleteAction, SIGNAL( activated() ), 584 connect( mDeleteAction, SIGNAL( activated() ),
585 mView, SLOT( deleteIncidence() ) ); 585 mView, SLOT( deleteIncidence() ) );
586 586
587 actionMenu->insertSeparator(); 587 actionMenu->insertSeparator();
588 588
589 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 589 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
590 this ); 590 this );
591 action->addTo( actionMenu ); 591 action->addTo( actionMenu );
592 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 592 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
593 593
594 icon = loadPixmap( pathString + "search" ); 594 icon = loadPixmap( pathString + "search" );
595 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 595 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
596 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 596 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
597 search_action->addTo( actionMenu ); 597 search_action->addTo( actionMenu );
598 connect( search_action, SIGNAL( activated() ), 598 connect( search_action, SIGNAL( activated() ),
599 mView->dialogManager(), SLOT( showSearchDialog() ) ); 599 mView->dialogManager(), SLOT( showSearchDialog() ) );
600 600
601 icon = loadPixmap( pathString + "today" ); 601 icon = loadPixmap( pathString + "today" );
602 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 602 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
603 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 603 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
604 today_action->addTo( actionMenu ); 604 today_action->addTo( actionMenu );
605 connect( today_action, SIGNAL( activated() ), 605 connect( today_action, SIGNAL( activated() ),
606 mView, SLOT( goToday() ) ); 606 mView, SLOT( goToday() ) );
607 607
608 if ( KOPrefs::instance()->mShowFullMenu ) { 608 if ( KOPrefs::instance()->mShowFullMenu ) {
609 actionMenu->insertSeparator(); 609 actionMenu->insertSeparator();
610 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 610 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
611 611
612 } 612 }
613 // actionMenu->insertSeparator(); 613 // actionMenu->insertSeparator();
614 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 614 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
615 this ); 615 this );
616 action->addTo( importMenu ); 616 action->addTo( importMenu );
617 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 617 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
618 action = new QAction( "import_quick", i18n("Import last file"), 0, 618 action = new QAction( "import_quick", i18n("Import last file"), 0,
619 this ); 619 this );
620 action->addTo( importMenu ); 620 action->addTo( importMenu );
621 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 621 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
622 importMenu->insertSeparator(); 622 importMenu->insertSeparator();
623 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 623 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
624 this ); 624 this );
625 action->addTo( importMenu ); 625 action->addTo( importMenu );
626 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 626 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
627#ifndef DESKTOP_VERSION 627#ifndef DESKTOP_VERSION
628 importMenu->insertSeparator(); 628 importMenu->insertSeparator();
629 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 629 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
630 this ); 630 this );
631 action->addTo( importMenu ); 631 action->addTo( importMenu );
632 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 632 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
633#else 633#else
634#ifdef _WIN32_ 634#ifdef _WIN32_
635 importMenu->insertSeparator(); 635 importMenu->insertSeparator();
636 action = new QAction( "import_ol", i18n("Import from OL"), 0, 636 action = new QAction( "import_ol", i18n("Import from OL"), 0,
637 this ); 637 this );
638 action->addTo( importMenu ); 638 action->addTo( importMenu );
639 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 639 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
640#endif 640#endif
641#endif 641#endif
642 642
643 importMenu->insertSeparator(); 643 importMenu->insertSeparator();
644 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 644 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
645 this ); 645 this );
646 action->addTo( importMenu ); 646 action->addTo( importMenu );
647 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 647 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
648 648
649 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 649 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
650 this ); 650 this );
651 action->addTo( importMenu ); 651 action->addTo( importMenu );
652 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 652 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
653 653
654 importMenu->insertSeparator(); 654 importMenu->insertSeparator();
655 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 655 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
656 this ); 656 this );
657 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 657 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
658 importMenu->insertSeparator(); 658 importMenu->insertSeparator();
659 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 659 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
660 this ); 660 this );
661 action->addTo( importMenu ); 661 action->addTo( importMenu );
662 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 662 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
663#ifndef DESKTOP_VERSION 663#ifndef DESKTOP_VERSION
664 importMenu->insertSeparator(); 664 importMenu->insertSeparator();
665 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 665 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
666 this ); 666 this );
667 action->addTo( importMenu ); 667 action->addTo( importMenu );
668 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 668 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
669 669
670 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 670 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
671 this ); 671 this );
672 action->addTo( importMenu ); 672 action->addTo( importMenu );
673 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 673 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
674#else 674#else
675 importMenu->insertSeparator(); 675 importMenu->insertSeparator();
676 icon = loadPixmap( pathString + "print" ); 676 icon = loadPixmap( pathString + "print" );
677 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 677 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
678 action->addTo( importMenu ); 678 action->addTo( importMenu );
679 connect( action, SIGNAL( activated() ), 679 connect( action, SIGNAL( activated() ),
680 this, SLOT( printCal() ) ); 680 this, SLOT( printCal() ) );
681 681
682 icon = loadPixmap( pathString + "print" ); 682 icon = loadPixmap( pathString + "print" );
683 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 683 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
684 action->addTo( importMenu ); 684 action->addTo( importMenu );
685 connect( action, SIGNAL( activated() ), 685 connect( action, SIGNAL( activated() ),
686 this, SLOT( printSel() ) ); 686 this, SLOT( printSel() ) );
687#endif 687#endif
688 importMenu->insertSeparator(); 688 importMenu->insertSeparator();
689 action = new QAction( "beam all", i18n("Save"), 0, 689 action = new QAction( "beam all", i18n("Save"), 0,
690 this ); 690 this );
691 action->addTo( importMenu ); 691 action->addTo( importMenu );
692 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 692 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
693 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 693 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
694 this ); 694 this );
695 action->addTo( importMenu ); 695 action->addTo( importMenu );
696 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 696 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
697 697
698 //menuBar->insertItem( "Configure",configureMenu ); 698 //menuBar->insertItem( "Configure",configureMenu );
699 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 699 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
700 icon = loadPixmap( "korganizer/korganizer" ); 700 icon = loadPixmap( "korganizer/korganizer" );
701 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 701 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
702 action->addTo( helpMenu ); 702 action->addTo( helpMenu );
703 connect( action, SIGNAL( activated() ), 703 connect( action, SIGNAL( activated() ),
704 SLOT( keyBindings() ) ); 704 SLOT( keyBindings() ) );
705 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 705 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
706 action->addTo( helpMenu ); 706 action->addTo( helpMenu );
707 connect( action, SIGNAL( activated() ), 707 connect( action, SIGNAL( activated() ),
708 SLOT( features() ) ); 708 SLOT( features() ) );
709 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 709 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
710 action->addTo( helpMenu ); 710 action->addTo( helpMenu );
711 connect( action, SIGNAL( activated() ), 711 connect( action, SIGNAL( activated() ),
712 SLOT( aboutAutoSaving() ) ); 712 SLOT( aboutAutoSaving() ) );
713 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 713 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
714 action->addTo( helpMenu ); 714 action->addTo( helpMenu );
715 connect( action, SIGNAL( activated() ), 715 connect( action, SIGNAL( activated() ),
716 SLOT( aboutKnownBugs() ) ); 716 SLOT( aboutKnownBugs() ) );
717 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 717 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
718 action->addTo( helpMenu ); 718 action->addTo( helpMenu );
719 connect( action, SIGNAL( activated() ), 719 connect( action, SIGNAL( activated() ),
720 SLOT( usertrans() ) ); 720 SLOT( usertrans() ) );
721 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 721 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
722 action->addTo( helpMenu ); 722 action->addTo( helpMenu );
723 connect( action, SIGNAL( activated() ), 723 connect( action, SIGNAL( activated() ),
724 SLOT( synchowto() ) ); 724 SLOT( synchowto() ) );
725 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 725 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
726 action->addTo( helpMenu ); 726 action->addTo( helpMenu );
727 connect( action, SIGNAL( activated() ), 727 connect( action, SIGNAL( activated() ),
728 SLOT( whatsNew() ) ); 728 SLOT( whatsNew() ) );
729 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 729 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
730 action->addTo( helpMenu ); 730 action->addTo( helpMenu );
731 connect( action, SIGNAL( activated() ), 731 connect( action, SIGNAL( activated() ),
732 SLOT( faq() ) ); 732 SLOT( faq() ) );
733 733
734 734
735 action = new QAction( "about", i18n("About..."), 0, this ); 735 action = new QAction( "about", i18n("About..."), 0, this );
736 action->addTo( helpMenu ); 736 action->addTo( helpMenu );
737 connect( action, SIGNAL( activated() ), 737 connect( action, SIGNAL( activated() ),
738 SLOT( about() ) ); 738 SLOT( about() ) );
739 action = new QAction( "licence", i18n("Licence..."), 0, this ); 739 action = new QAction( "licence", i18n("Licence..."), 0, this );
740 action->addTo( helpMenu ); 740 action->addTo( helpMenu );
741 connect( action, SIGNAL( activated() ), 741 connect( action, SIGNAL( activated() ),
742 SLOT( licence() ) ); 742 SLOT( licence() ) );
743 //menuBar->insertSeparator(); 743 //menuBar->insertSeparator();
744 744
745 // ****************************************************** 745 // ******************************************************
746 // menubar icons 746 // menubar icons
747 747
748 748
749 iconToolBar->setHorizontalStretchable (true ); 749 iconToolBar->setHorizontalStretchable (true );
750 //menuBar->insertItem( iconToolBar ); 750 //menuBar->insertItem( iconToolBar );
751 //xdays_action 751 //xdays_action
752 if (p-> mShowIconNewEvent) 752 if (p-> mShowIconNewEvent)
753 ne_action->addTo( iconToolBar ); 753 ne_action->addTo( iconToolBar );
754 if (p->mShowIconNewTodo ) 754 if (p->mShowIconNewTodo )
755 nt_action->addTo( iconToolBar ); 755 nt_action->addTo( iconToolBar );
756 if (p-> mShowIconSearch) 756 if (p-> mShowIconSearch)
757 search_action->addTo( iconToolBar ); 757 search_action->addTo( iconToolBar );
758 if (p-> mShowIconNext) 758 if (p-> mShowIconNext)
759 whatsnext_action->addTo( iconToolBar ); 759 whatsnext_action->addTo( iconToolBar );
760 if (p-> mShowIconNextDays) 760 if (p-> mShowIconNextDays)
761 xdays_action->addTo( iconToolBar ); 761 xdays_action->addTo( iconToolBar );
762 if (p-> mShowIconList) 762 if (p-> mShowIconList)
763 showlist_action->addTo( iconToolBar ); 763 showlist_action->addTo( iconToolBar );
764 if (p-> mShowIconDay1) 764 if (p-> mShowIconDay1)
765 day1_action->addTo( iconToolBar ); 765 day1_action->addTo( iconToolBar );
766 if (p-> mShowIconDay5) 766 if (p-> mShowIconDay5)
767 day5_action->addTo( iconToolBar ); 767 day5_action->addTo( iconToolBar );
768 if (p-> mShowIconDay7) 768 if (p-> mShowIconDay7)
769 day7_action->addTo( iconToolBar ); 769 day7_action->addTo( iconToolBar );
770 if (p-> mShowIconMonth) 770 if (p-> mShowIconMonth)
771 month_action->addTo( iconToolBar ); 771 month_action->addTo( iconToolBar );
772 if (p-> mShowIconTodoview) 772 if (p-> mShowIconTodoview)
773 todoview_action->addTo( iconToolBar ); 773 todoview_action->addTo( iconToolBar );
774 if (p-> mShowIconJournal) 774 if (p-> mShowIconJournal)
775 viewjournal_action->addTo( iconToolBar ); 775 viewjournal_action->addTo( iconToolBar );
776 icon = loadPixmap( pathString + "2leftarrowB" ); 776 icon = loadPixmap( pathString + "2leftarrowB" );
777 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 777 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
778 if (p-> mShowIconBackFast) { 778 if (p-> mShowIconBackFast) {
779 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 779 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
780 connect( action, SIGNAL( activated() ), 780 connect( action, SIGNAL( activated() ),
781 mView, SLOT( goPreviousMonth() ) ); 781 mView, SLOT( goPreviousMonth() ) );
782 action->addTo( iconToolBar ); 782 action->addTo( iconToolBar );
783 } 783 }
784 icon = loadPixmap( pathString + "1leftarrowB" ); 784 icon = loadPixmap( pathString + "1leftarrowB" );
785 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 785 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
786 if (p-> mShowIconBack) { 786 if (p-> mShowIconBack) {
787 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 787 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
788 connect( action, SIGNAL( activated() ), 788 connect( action, SIGNAL( activated() ),
789 mView, SLOT( goPrevious() ) ); 789 mView, SLOT( goPrevious() ) );
790 action->addTo( iconToolBar ); 790 action->addTo( iconToolBar );
791 } 791 }
792 if (p-> mShowIconToday) 792 if (p-> mShowIconToday)
793 today_action->addTo( iconToolBar ); 793 today_action->addTo( iconToolBar );
794 icon = loadPixmap( pathString + "1rightarrowB" ); 794 icon = loadPixmap( pathString + "1rightarrowB" );
795 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 795 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
796 if (p-> mShowIconForward) { 796 if (p-> mShowIconForward) {
797 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 797 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
798 connect( action, SIGNAL( activated() ), 798 connect( action, SIGNAL( activated() ),
799 mView, SLOT( goNext() ) ); 799 mView, SLOT( goNext() ) );
800 action->addTo( iconToolBar ); 800 action->addTo( iconToolBar );
801 } 801 }
802 icon = loadPixmap( pathString + "2rightarrowB" ); 802 icon = loadPixmap( pathString + "2rightarrowB" );
803 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 803 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
804 if (p-> mShowIconForwardFast) { 804 if (p-> mShowIconForwardFast) {
805 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 805 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
806 connect( action, SIGNAL( activated() ), 806 connect( action, SIGNAL( activated() ),
807 mView, SLOT( goNextMonth() ) ); 807 mView, SLOT( goNextMonth() ) );
808 action->addTo( iconToolBar ); 808 action->addTo( iconToolBar );
809 } 809 }
810 810
811 811
812 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 812 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
813 813
814 if (p-> mShowIconNewEvent) 814 if (p-> mShowIconNewEvent)
815 configureToolBarMenu->setItemChecked( 10, true ); 815 configureToolBarMenu->setItemChecked( 10, true );
816 if (p->mShowIconNewTodo ) 816 if (p->mShowIconNewTodo )
817 configureToolBarMenu->setItemChecked( 20, true ); 817 configureToolBarMenu->setItemChecked( 20, true );
818 if (p-> mShowIconSearch) 818 if (p-> mShowIconSearch)
819 configureToolBarMenu->setItemChecked( 120, true ); 819 configureToolBarMenu->setItemChecked( 120, true );
820 if (p-> mShowIconList) 820 if (p-> mShowIconList)
821 configureToolBarMenu->setItemChecked( 30, true ); 821 configureToolBarMenu->setItemChecked( 30, true );
822 if (p-> mShowIconDay1) 822 if (p-> mShowIconDay1)
823 configureToolBarMenu->setItemChecked( 40, true ); 823 configureToolBarMenu->setItemChecked( 40, true );
824 if (p-> mShowIconDay5) 824 if (p-> mShowIconDay5)
825 configureToolBarMenu->setItemChecked( 50, true ); 825 configureToolBarMenu->setItemChecked( 50, true );
826 if (p-> mShowIconDay7) 826 if (p-> mShowIconDay7)
827 configureToolBarMenu->setItemChecked( 60, true ); 827 configureToolBarMenu->setItemChecked( 60, true );
828 if (p-> mShowIconMonth) 828 if (p-> mShowIconMonth)
829 configureToolBarMenu->setItemChecked( 70, true ); 829 configureToolBarMenu->setItemChecked( 70, true );
830 if (p-> mShowIconTodoview) 830 if (p-> mShowIconTodoview)
831 configureToolBarMenu->setItemChecked( 80, true ); 831 configureToolBarMenu->setItemChecked( 80, true );
832 if (p-> mShowIconBackFast) 832 if (p-> mShowIconBackFast)
833 configureToolBarMenu->setItemChecked( 200, true ); 833 configureToolBarMenu->setItemChecked( 200, true );
834 if (p-> mShowIconBack) 834 if (p-> mShowIconBack)
835 configureToolBarMenu->setItemChecked( 210, true ); 835 configureToolBarMenu->setItemChecked( 210, true );
836 if (p-> mShowIconToday) 836 if (p-> mShowIconToday)
837 configureToolBarMenu->setItemChecked( 130, true ); 837 configureToolBarMenu->setItemChecked( 130, true );
838 if (p-> mShowIconForward) 838 if (p-> mShowIconForward)
839 configureToolBarMenu->setItemChecked( 220, true ); 839 configureToolBarMenu->setItemChecked( 220, true );
840 if (p-> mShowIconForwardFast) 840 if (p-> mShowIconForwardFast)
841 configureToolBarMenu->setItemChecked( 230, true ); 841 configureToolBarMenu->setItemChecked( 230, true );
842 if (p-> mShowIconNextDays) 842 if (p-> mShowIconNextDays)
843 configureToolBarMenu->setItemChecked( 100, true ); 843 configureToolBarMenu->setItemChecked( 100, true );
844 if (p-> mShowIconNext) 844 if (p-> mShowIconNext)
845 configureToolBarMenu->setItemChecked( 110, true ); 845 configureToolBarMenu->setItemChecked( 110, true );
846 if (p-> mShowIconJournal) 846 if (p-> mShowIconJournal)
847 configureToolBarMenu->setItemChecked( 90, true ); 847 configureToolBarMenu->setItemChecked( 90, true );
848 if (p-> mShowIconWhatsThis) 848 if (p-> mShowIconWhatsThis)
849 configureToolBarMenu->setItemChecked( 300, true ); 849 configureToolBarMenu->setItemChecked( 300, true );
850 850
851 QLabel* dummy = new QLabel( iconToolBar ); 851 QLabel* dummy = new QLabel( iconToolBar );
852 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 852 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
853 if (!p-> mShowIconStretch) 853 if (!p-> mShowIconStretch)
854 iconToolBar->setStretchableWidget ( dummy ) ; 854 iconToolBar->setStretchableWidget ( dummy ) ;
855 else 855 else
856 configureToolBarMenu->setItemChecked( 5, true ); 856 configureToolBarMenu->setItemChecked( 5, true );
857 if (p-> mShowIconWhatsThis) 857 if (p-> mShowIconWhatsThis)
858 QWhatsThis::whatsThisButton ( iconToolBar ); 858 QWhatsThis::whatsThisButton ( iconToolBar );
859 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 859 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
860 configureAgenda( p->mHourSize ); 860 configureAgenda( p->mHourSize );
861 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 861 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
862} 862}
863void MainWindow::fillSyncMenu() 863void MainWindow::fillSyncMenu()
864{ 864{
865 if ( syncMenu->count() ) 865 if ( syncMenu->count() )
866 syncMenu->clear(); 866 syncMenu->clear();
867 syncMenu->insertItem( i18n("Configure..."), 0 ); 867 syncMenu->insertItem( i18n("Configure..."), 0 );
868 syncMenu->insertSeparator(); 868 syncMenu->insertSeparator();
869 if ( mServerSocket == 0 ) { 869 if ( mServerSocket == 0 ) {
870 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 870 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
871 } else { 871 } else {
872 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 872 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
873 } 873 }
874 syncMenu->insertSeparator(); 874 syncMenu->insertSeparator();
875 syncMenu->insertItem( i18n("New Pi-Sync!"), 4 );
876 syncMenu->insertItem( i18n("Quick Pi-Sync!"), 5 );
877 syncMenu->insertSeparator();
878 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 875 syncMenu->insertItem( i18n("Multiple sync"), 1 );
879 syncMenu->insertSeparator(); 876 syncMenu->insertSeparator();
880 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 877 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
881 config.setGroup("General"); 878 config.setGroup("General");
882 QStringList prof = config.readListEntry("SyncProfileNames"); 879 QStringList prof = config.readListEntry("SyncProfileNames");
883 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 880 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
884 if ( prof.count() < 3 ) { 881 if ( prof.count() < 3 ) {
885 prof.clear(); 882 prof.clear();
886 prof << i18n("Sharp_DTM"); 883 prof << i18n("Sharp_DTM");
887 prof << i18n("Local_file"); 884 prof << i18n("Local_file");
888 prof << i18n("Last_file"); 885 prof << i18n("Last_file");
889 KSyncProfile* temp = new KSyncProfile (); 886 KSyncProfile* temp = new KSyncProfile ();
890 temp->setName( prof[0] ); 887 temp->setName( prof[0] );
891 temp->writeConfig(&config); 888 temp->writeConfig(&config);
892 temp->setName( prof[1] ); 889 temp->setName( prof[1] );
893 temp->writeConfig(&config); 890 temp->writeConfig(&config);
894 temp->setName( prof[2] ); 891 temp->setName( prof[2] );
895 temp->writeConfig(&config); 892 temp->writeConfig(&config);
896 config.setGroup("General"); 893 config.setGroup("General");
897 config.writeEntry("SyncProfileNames",prof); 894 config.writeEntry("SyncProfileNames",prof);
898 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 895 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
899 config.sync(); 896 config.sync();
900 delete temp; 897 delete temp;
901 } 898 }
902 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 899 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
903 KOPrefs::instance()->mSyncProfileNames = prof; 900 KOPrefs::instance()->mSyncProfileNames = prof;
904 int i; 901 int i;
905 for ( i = 0; i < prof.count(); ++i ) { 902 for ( i = 0; i < prof.count(); ++i ) {
906 903
907 syncMenu->insertItem( prof[i], 1000+i ); 904 syncMenu->insertItem( prof[i], 1000+i );
908 if ( i == 2 ) 905 if ( i == 2 )
909 syncMenu->insertSeparator(); 906 syncMenu->insertSeparator();
910 } 907 }
911 QDir app_dir; 908 QDir app_dir;
912 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 909 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
913 syncMenu->setItemEnabled( false , 1000 ); 910 syncMenu->setItemEnabled( false , 1000 );
914 } 911 }
915 mView->setupExternSyncProfiles(); 912 mView->setupExternSyncProfiles();
916} 913}
917 914
918int MainWindow::ringSync() 915int MainWindow::ringSync()
919{ 916{
920 int syncedProfiles = 0; 917 int syncedProfiles = 0;
921 int i; 918 int i;
922 QTime timer; 919 QTime timer;
923 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 920 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
924 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 921 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
925 KSyncProfile* temp = new KSyncProfile (); 922 KSyncProfile* temp = new KSyncProfile ();
926 KOPrefs::instance()->mAskForPreferences = false; 923 KOPrefs::instance()->mAskForPreferences = false;
927 for ( i = 0; i < syncProfileNames.count(); ++i ) { 924 for ( i = 0; i < syncProfileNames.count(); ++i ) {
928 mCurrentSyncProfile = i; 925 mCurrentSyncProfile = i;
929 temp->setName(syncProfileNames[mCurrentSyncProfile]); 926 temp->setName(syncProfileNames[mCurrentSyncProfile]);
930 temp->readConfig(&config); 927 temp->readConfig(&config);
931 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 928 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
932 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 929 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
933 ++syncedProfiles; 930 ++syncedProfiles;
934 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 931 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
935 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 932 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
936 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 933 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
937 KOPrefs::instance()->mWriteBackInFuture = 0; 934 KOPrefs::instance()->mWriteBackInFuture = 0;
938 if ( temp->getWriteBackFuture() ) 935 if ( temp->getWriteBackFuture() )
939 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 936 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
940 KOPrefs::instance()->mShowSyncSummary = false; 937 KOPrefs::instance()->mShowSyncSummary = false;
941 mView->setSyncDevice(syncProfileNames[i] ); 938 mView->setSyncDevice(syncProfileNames[i] );
942 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 939 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
943 if ( i == 0 ) { 940 if ( i == 0 ) {
944 syncSharp(); 941 syncSharp();
945 } else { 942 } else {
946 if ( temp->getIsLocalFileSync() ) { 943 if ( temp->getIsLocalFileSync() ) {
947 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 944 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
948 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 945 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
949 } else { 946 } else {
950 if ( temp->getIsPhoneSync() ) { 947 if ( temp->getIsPhoneSync() ) {
951 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 948 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
952 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 949 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
953 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 950 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
954 syncPhone(); 951 syncPhone();
955 } else 952 } else if ( temp->getIsPiSync() ) {
953 mPassWordPiSync = temp->getRemotePw();
954 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
955 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
956 syncPi();
957 } else
956 syncRemote( temp, false ); 958 syncRemote( temp, false );
957 959
958 } 960 }
959 } 961 }
960 timer.start(); 962 timer.start();
961 setCaption(i18n("Multiple sync in progress ... please wait!") ); 963 setCaption(i18n("Multiple sync in progress ... please wait!") );
962 while ( timer.elapsed () < 2000 ) { 964 while ( timer.elapsed () < 2000 ) {
963 qApp->processEvents(); 965 qApp->processEvents();
964#ifndef _WIN32_ 966#ifndef _WIN32_
965 sleep (1); 967 sleep (1);
966#endif 968#endif
967 } 969 }
968 970
969 } 971 }
970 972
971 } 973 }
972 delete temp; 974 delete temp;
973 return syncedProfiles; 975 return syncedProfiles;
974} 976}
975 977
976void MainWindow::multiSync( bool askforPrefs ) 978void MainWindow::multiSync( bool askforPrefs )
977{ 979{
978 if (mBlockSaveFlag) 980 if (mBlockSaveFlag)
979 return; 981 return;
980 mBlockSaveFlag = true; 982 mBlockSaveFlag = true;
981 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 983 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
982 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 984 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
983 question, 985 question,
984 i18n("Yes"), i18n("No"), 986 i18n("Yes"), i18n("No"),
985 0, 0 ) != 0 ) { 987 0, 0 ) != 0 ) {
986 mBlockSaveFlag = false; 988 mBlockSaveFlag = false;
987 setCaption(i18n("Aborted! Nothing synced!")); 989 setCaption(i18n("Aborted! Nothing synced!"));
988 return; 990 return;
989 } 991 }
990 mView->setSyncDevice(i18n("Multiple profiles") ); 992 mView->setSyncDevice(i18n("Multiple profiles") );
991 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 993 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
992 if ( askforPrefs ) { 994 if ( askforPrefs ) {
993 mView->edit_sync_options(); 995 mView->edit_sync_options();
994 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 996 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
995 } 997 }
996 setCaption(i18n("Multiple sync started.") ); 998 setCaption(i18n("Multiple sync started.") );
997 qApp->processEvents(); 999 qApp->processEvents();
998 int num = ringSync() ; 1000 int num = ringSync() ;
999 if ( num > 1 ) 1001 if ( num > 1 )
1000 ringSync(); 1002 ringSync();
1001 mBlockSaveFlag = false; 1003 mBlockSaveFlag = false;
1002 if ( num ) 1004 if ( num )
1003 save(); 1005 save();
1004 if ( num ) 1006 if ( num )
1005 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1007 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
1006 else 1008 else
1007 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1009 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
1008 return; 1010 return;
1009} 1011}
1010void MainWindow::slotSyncMenu( int action ) 1012void MainWindow::slotSyncMenu( int action )
1011{ 1013{
1012 qDebug("syncaction %d ", action); 1014 qDebug("syncaction %d ", action);
1013 if ( action == 0 ) { 1015 if ( action == 0 ) {
1014 1016
1015 // seems to be a Qt2 event handling bug 1017 // seems to be a Qt2 event handling bug
1016 // syncmenu.clear causes a segfault at first time 1018 // syncmenu.clear causes a segfault at first time
1017 // when we call it after the main event loop, it is ok 1019 // when we call it after the main event loop, it is ok
1018 // same behaviour when calling OM/Pi via QCOP for the first time 1020 // same behaviour when calling OM/Pi via QCOP for the first time
1019 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1021 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1020 //confSync(); 1022 //confSync();
1021 1023
1022 return; 1024 return;
1023 } 1025 }
1024 if ( action == 1 ) { 1026 if ( action == 1 ) {
1025 multiSync( true ); 1027 multiSync( true );
1026 return; 1028 return;
1027 } 1029 }
1028 if ( action == 2 ) { 1030 if ( action == 2 ) {
1029 enableQuick(); 1031 enableQuick();
1030 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1032 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1031 return; 1033 return;
1032 } 1034 }
1033 if ( action == 3 ) { 1035 if ( action == 3 ) {
1034 delete mServerSocket; 1036 delete mServerSocket;
1035 mServerSocket = 0; 1037 mServerSocket = 0;
1036 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1038 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1037 return; 1039 return;
1038 } 1040 }
1039 if ( action == 4 ) {
1040 performQuick();
1041 return;
1042 }
1043 if ( action == 5 ) {
1044 performQuickQuick();
1045 return;
1046 }
1047 1041
1048 if (mBlockSaveFlag) 1042 if (mBlockSaveFlag)
1049 return; 1043 return;
1050 mBlockSaveFlag = true; 1044 mBlockSaveFlag = true;
1051 mCurrentSyncProfile = action - 1000 ; 1045 mCurrentSyncProfile = action - 1000 ;
1052 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1046 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1053 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1047 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1054 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1048 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1055 KSyncProfile* temp = new KSyncProfile (); 1049 KSyncProfile* temp = new KSyncProfile ();
1056 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1050 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1057 temp->readConfig(&config); 1051 temp->readConfig(&config);
1058 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1052 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1059 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1053 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1060 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1054 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1061 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1055 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1062 KOPrefs::instance()->mWriteBackInFuture = 0; 1056 KOPrefs::instance()->mWriteBackInFuture = 0;
1063 if ( temp->getWriteBackFuture() ) 1057 if ( temp->getWriteBackFuture() )
1064 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1058 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1065 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1059 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1066 if ( action == 1000 ) { 1060 if ( action == 1000 ) {
1067 syncSharp(); 1061 syncSharp();
1068 1062
1069 } else if ( action == 1001 ) { 1063 } else if ( action == 1001 ) {
1070 syncLocalFile(); 1064 syncLocalFile();
1071 1065
1072 } else if ( action == 1002 ) { 1066 } else if ( action == 1002 ) {
1073 quickSyncLocalFile(); 1067 quickSyncLocalFile();
1074 1068
1075 } else if ( action >= 1003 ) { 1069 } else if ( action >= 1003 ) {
1076 if ( temp->getIsLocalFileSync() ) { 1070 if ( temp->getIsLocalFileSync() ) {
1077 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1071 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1078 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1072 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1079 } else { 1073 } else {
1080 if ( temp->getIsPhoneSync() ) { 1074 if ( temp->getIsPhoneSync() ) {
1081 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1075 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1082 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1076 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1083 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1077 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1084 syncPhone(); 1078 syncPhone();
1085 } else 1079 } else if ( temp->getIsPiSync() ) {
1080 mPassWordPiSync = temp->getRemotePw();
1081 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1082 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1083 syncPi();
1084 } else
1086 syncRemote( temp ); 1085 syncRemote( temp );
1087 1086
1088 } 1087 }
1089 } 1088 }
1090 delete temp; 1089 delete temp;
1091 mBlockSaveFlag = false; 1090 mBlockSaveFlag = false;
1092} 1091}
1093void MainWindow::setDefaultPreferences() 1092void MainWindow::setDefaultPreferences()
1094{ 1093{
1095 KOPrefs *p = KOPrefs::instance(); 1094 KOPrefs *p = KOPrefs::instance();
1096 1095
1097 p->mCompactDialogs = true; 1096 p->mCompactDialogs = true;
1098 p->mConfirm = true; 1097 p->mConfirm = true;
1099 // p->mEnableQuickTodo = false; 1098 // p->mEnableQuickTodo = false;
1100} 1099}
1101 1100
1102QString MainWindow::resourcePath() 1101QString MainWindow::resourcePath()
1103{ 1102{
1104 return KGlobal::iconLoader()->iconPath(); 1103 return KGlobal::iconLoader()->iconPath();
1105} 1104}
1106 1105
1107void MainWindow::displayText( QString text ,QString cap ) 1106void MainWindow::displayText( QString text ,QString cap )
1108{ 1107{
1109 QDialog dia( this, "name", true ); ; 1108 QDialog dia( this, "name", true ); ;
1110 dia.setCaption( cap ); 1109 dia.setCaption( cap );
1111 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1110 QVBoxLayout* lay = new QVBoxLayout( &dia );
1112 lay->setSpacing( 3 ); 1111 lay->setSpacing( 3 );
1113 lay->setMargin( 3 ); 1112 lay->setMargin( 3 );
1114 QTextBrowser tb ( &dia ); 1113 QTextBrowser tb ( &dia );
1115 lay->addWidget( &tb ); 1114 lay->addWidget( &tb );
1116 tb.setText( text ); 1115 tb.setText( text );
1117#ifdef DESKTOP_VERSION 1116#ifdef DESKTOP_VERSION
1118 dia.resize( 640, 480); 1117 dia.resize( 640, 480);
1119#else 1118#else
1120 dia.showMaximized(); 1119 dia.showMaximized();
1121#endif 1120#endif
1122 dia.exec(); 1121 dia.exec();
1123} 1122}
1124void MainWindow::displayFile( QString fn, QString cap ) 1123void MainWindow::displayFile( QString fn, QString cap )
1125{ 1124{
1126 QString fileName = resourcePath() + fn; 1125 QString fileName = resourcePath() + fn;
1127 QString text; 1126 QString text;
1128 QFile file( fileName ); 1127 QFile file( fileName );
1129 if (!file.open( IO_ReadOnly ) ) { 1128 if (!file.open( IO_ReadOnly ) ) {
1130 return ; 1129 return ;
1131 1130
1132 } 1131 }
1133 QTextStream ts( &file ); 1132 QTextStream ts( &file );
1134 text = ts.read(); 1133 text = ts.read();
1135 file.close(); 1134 file.close();
1136 displayText( text, cap); 1135 displayText( text, cap);
1137} 1136}
1138void MainWindow::features() 1137void MainWindow::features()
1139{ 1138{
1140 1139
1141 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1140 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1142} 1141}
1143 1142
1144void MainWindow::usertrans() 1143void MainWindow::usertrans()
1145{ 1144{
1146 1145
1147 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1146 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1148} 1147}
1149 1148
1150void MainWindow::synchowto() 1149void MainWindow::synchowto()
1151{ 1150{
1152#if 0 1151#if 0
1153 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1152 QPtrList<Incidence> er = mCalendar->rawIncidences();
1154 Incidence* inR = er.first(); 1153 Incidence* inR = er.first();
1155 VCalFormat vf; 1154 VCalFormat vf;
1156 QString strout; 1155 QString strout;
1157 while ( inR ) { 1156 while ( inR ) {
1158 if ( inR->type() == "Todo" ) 1157 if ( inR->type() == "Todo" )
1159 strout = vf.todoToString( (Todo *) inR ); 1158 strout = vf.todoToString( (Todo *) inR );
1160 if ( inR->type() == "Event" ) 1159 if ( inR->type() == "Event" )
1161 strout = vf.eventToString( (Event *) inR ); 1160 strout = vf.eventToString( (Event *) inR );
1162 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1161 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1163 inR = er.next(); 1162 inR = er.next();
1164 } 1163 }
1165#endif 1164#endif
1166 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1165 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1167} 1166}
1168void MainWindow::faq() 1167void MainWindow::faq()
1169{ 1168{
1170 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1169 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1171 1170
1172} 1171}
1173void MainWindow::whatsNew() 1172void MainWindow::whatsNew()
1174{ 1173{
1175 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1174 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1176 1175
1177} 1176}
1178void MainWindow::licence() 1177void MainWindow::licence()
1179{ 1178{
1180 KApplication::showLicence(); 1179 KApplication::showLicence();
1181 1180
1182} 1181}
1183void MainWindow::about() 1182void MainWindow::about()
1184{ 1183{
1185 QString version; 1184 QString version;
1186#include <../version> 1185#include <../version>
1187 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1186 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1188 i18n("KOrganizer/Platform-independent\n") + 1187 i18n("KOrganizer/Platform-independent\n") +
1189 "(KO/Pi) " + version + " - " + 1188 "(KO/Pi) " + version + " - " +
1190 1189
1191#ifdef DESKTOP_VERSION 1190#ifdef DESKTOP_VERSION
1192 i18n("Desktop Edition\n") + 1191 i18n("Desktop Edition\n") +
1193#else 1192#else
1194 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1193 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1195#endif 1194#endif
1196 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") ); 1195 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") );
1197} 1196}
1198void MainWindow::keyBindings() 1197void MainWindow::keyBindings()
1199{ 1198{
1200 QString cap = i18n("Key bindings KOrganizer/Pi"); 1199 QString cap = i18n("Key bindings KOrganizer/Pi");
1201 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1200 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1202 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1201 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1203 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1202 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1204 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1203 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1205 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1204 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1206 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1205 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1207 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1206 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1208 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1207 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1209 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1208 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1210 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1209 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1211 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1210 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1212 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1211 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1213 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1212 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1214 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1213 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1215 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1214 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1216 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1215 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1217 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1216 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1218 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1217 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1219 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1218 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1220 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1219 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1221 i18n("<p><h3>In agenda view:</h3></p>\n") + 1220 i18n("<p><h3>In agenda view:</h3></p>\n") +
1222 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1221 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1223 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1222 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1224 i18n("<p><h3>In todo view:</h3></p>\n") + 1223 i18n("<p><h3>In todo view:</h3></p>\n") +
1225 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1224 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1226 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1225 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1227 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1226 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1228 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1227 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1229 i18n("<p><h3>In list view:</h3></p>\n") + 1228 i18n("<p><h3>In list view:</h3></p>\n") +
1230 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1229 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1231 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1230 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1232 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1231 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1233 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1232 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1234 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1233 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1235 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1234 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1236 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1235 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1237 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1236 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1238 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1237 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1239 i18n("<p><b>E</b>: Edit item</p>\n") + 1238 i18n("<p><b>E</b>: Edit item</p>\n") +
1240 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1239 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1241 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1240 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1242 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1241 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1243 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1242 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1244 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1243 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1245 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1244 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1246 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1245 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1247 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1246 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1248 i18n("<p><b>White</b>: Item readonly</p>\n"); 1247 i18n("<p><b>White</b>: Item readonly</p>\n");
1249 displayText( text, cap); 1248 displayText( text, cap);
1250 1249
1251} 1250}
1252void MainWindow::aboutAutoSaving() 1251void MainWindow::aboutAutoSaving()
1253{ 1252{
1254 QMessageBox* msg; 1253 QMessageBox* msg;
1255 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1254 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1256 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, 1255 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,
1257 QMessageBox::Ok, 1256 QMessageBox::Ok,
1258 QMessageBox::NoButton, 1257 QMessageBox::NoButton,
1259 QMessageBox::NoButton); 1258 QMessageBox::NoButton);
1260 msg->exec(); 1259 msg->exec();
1261 delete msg; 1260 delete msg;
1262 1261
1263 1262
1264} 1263}
1265void MainWindow::aboutKnownBugs() 1264void MainWindow::aboutKnownBugs()
1266{ 1265{
1267 QMessageBox* msg; 1266 QMessageBox* msg;
1268 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1267 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1269 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")+ 1268 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")+
1270 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1269 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1271 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1270 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1272 i18n("\nor report them in the bugtracker on\n") + 1271 i18n("\nor report them in the bugtracker on\n") +
1273 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1272 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1274 QMessageBox::NoIcon, 1273 QMessageBox::NoIcon,
1275 QMessageBox::Ok, 1274 QMessageBox::Ok,
1276 QMessageBox::NoButton, 1275 QMessageBox::NoButton,
1277 QMessageBox::NoButton); 1276 QMessageBox::NoButton);
1278 msg->exec(); 1277 msg->exec();
1279 delete msg; 1278 delete msg;
1280 1279
1281} 1280}
1282 1281
1283QString MainWindow::defaultFileName() 1282QString MainWindow::defaultFileName()
1284{ 1283{
1285 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1284 return locateLocal( "data", "korganizer/mycalendar.ics" );
1286} 1285}
1287 1286
1288void MainWindow::processIncidenceSelection( Incidence *incidence ) 1287void MainWindow::processIncidenceSelection( Incidence *incidence )
1289{ 1288{
1290 if ( !incidence ) { 1289 if ( !incidence ) {
1291 enableIncidenceActions( false ); 1290 enableIncidenceActions( false );
1292 1291
1293 mNewSubTodoAction->setEnabled( false ); 1292 mNewSubTodoAction->setEnabled( false );
1294 setCaptionToDates(); 1293 setCaptionToDates();
1295 return; 1294 return;
1296 1295
1297 } 1296 }
1298 1297
1299 //KGlobal::locale()->formatDateTime(nextA, true); 1298 //KGlobal::locale()->formatDateTime(nextA, true);
1300 QString startString = ""; 1299 QString startString = "";
1301 if ( incidence->type() != "Todo" ) { 1300 if ( incidence->type() != "Todo" ) {
1302 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1301 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1303 if ( incidence->doesFloat() ) { 1302 if ( incidence->doesFloat() ) {
1304 startString += ": "+incidence->dtStartDateStr( true ); 1303 startString += ": "+incidence->dtStartDateStr( true );
1305 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1304 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1306 1305
1307 } else { 1306 } else {
1308 startString = ": "+incidence->dtStartStr(true); 1307 startString = ": "+incidence->dtStartStr(true);
1309 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1308 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1310 1309
1311 } 1310 }
1312 1311
1313 } else { 1312 } else {
1314 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1313 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1315 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1314 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1316 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1315 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1317 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1316 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1318 } 1317 }
1319 1318
1320 } 1319 }
1321 else 1320 else
1322 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1321 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1323 if ( !incidence->location().isEmpty() ) 1322 if ( !incidence->location().isEmpty() )
1324 startString += " (" +incidence->location()+")"; 1323 startString += " (" +incidence->location()+")";
1325 setCaption( incidence->summary()+startString); 1324 setCaption( incidence->summary()+startString);
1326 1325
1327 enableIncidenceActions( true ); 1326 enableIncidenceActions( true );
1328 1327
1329 if ( incidence->type() == "Event" ) { 1328 if ( incidence->type() == "Event" ) {
1330 mShowAction->setText( i18n("Show Event...") ); 1329 mShowAction->setText( i18n("Show Event...") );
1331 mEditAction->setText( i18n("Edit Event...") ); 1330 mEditAction->setText( i18n("Edit Event...") );
1332 mDeleteAction->setText( i18n("Delete Event...") ); 1331 mDeleteAction->setText( i18n("Delete Event...") );
1333 1332
1334 mNewSubTodoAction->setEnabled( false ); 1333 mNewSubTodoAction->setEnabled( false );
1335 } else if ( incidence->type() == "Todo" ) { 1334 } else if ( incidence->type() == "Todo" ) {
1336 mShowAction->setText( i18n("Show Todo...") ); 1335 mShowAction->setText( i18n("Show Todo...") );
1337 mEditAction->setText( i18n("Edit Todo...") ); 1336 mEditAction->setText( i18n("Edit Todo...") );
1338 mDeleteAction->setText( i18n("Delete Todo...") ); 1337 mDeleteAction->setText( i18n("Delete Todo...") );
1339 1338
1340 mNewSubTodoAction->setEnabled( true ); 1339 mNewSubTodoAction->setEnabled( true );
1341 } else { 1340 } else {
1342 mShowAction->setText( i18n("Show...") ); 1341 mShowAction->setText( i18n("Show...") );
1343 mShowAction->setText( i18n("Edit...") ); 1342 mShowAction->setText( i18n("Edit...") );
1344 mShowAction->setText( i18n("Delete...") ); 1343 mShowAction->setText( i18n("Delete...") );
1345 1344
1346 mNewSubTodoAction->setEnabled( false ); 1345 mNewSubTodoAction->setEnabled( false );
1347 } 1346 }
1348} 1347}
1349 1348
1350void MainWindow::enableIncidenceActions( bool enabled ) 1349void MainWindow::enableIncidenceActions( bool enabled )
1351{ 1350{
1352 mShowAction->setEnabled( enabled ); 1351 mShowAction->setEnabled( enabled );
1353 mEditAction->setEnabled( enabled ); 1352 mEditAction->setEnabled( enabled );
1354 mDeleteAction->setEnabled( enabled ); 1353 mDeleteAction->setEnabled( enabled );
1355} 1354}
1356 1355
1357void MainWindow::importOL() 1356void MainWindow::importOL()
1358{ 1357{
1359#ifdef _WIN32_ 1358#ifdef _WIN32_
1360 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1359 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1361 id->exec(); 1360 id->exec();
1362 delete id; 1361 delete id;
1363 mView->updateView(); 1362 mView->updateView();
1364#endif 1363#endif
1365} 1364}
1366void MainWindow::importBday() 1365void MainWindow::importBday()
1367{ 1366{
1368 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1367 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1369 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1368 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1370 i18n("Import!"), i18n("Cancel"), 0, 1369 i18n("Import!"), i18n("Cancel"), 0,
1371 0, 1 ); 1370 0, 1 );
1372 if ( result == 0 ) { 1371 if ( result == 0 ) {
1373 mView->importBday(); 1372 mView->importBday();
1374 1373
1375 } 1374 }
1376 1375
1377 1376
1378} 1377}
1379void MainWindow::importQtopia() 1378void MainWindow::importQtopia()
1380{ 1379{
1381#ifndef DESKTOP_VERSION 1380#ifndef DESKTOP_VERSION
1382 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1381 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1383 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"), 1382 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"),
1384 i18n("Import!"), i18n("Cancel"), 0, 1383 i18n("Import!"), i18n("Cancel"), 0,
1385 0, 1 ); 1384 0, 1 );
1386 if ( result == 0 ) { 1385 if ( result == 0 ) {
1387 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1386 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1388 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1387 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1389 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1388 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1390 mView->importQtopia( categories, datebook, todolist ); 1389 mView->importQtopia( categories, datebook, todolist );
1391 } 1390 }
1392#else 1391#else
1393 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1392 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1394 i18n("Not supported \non desktop!\n"), 1393 i18n("Not supported \non desktop!\n"),
1395 i18n("Ok"), i18n("Cancel"), 0, 1394 i18n("Ok"), i18n("Cancel"), 0,
1396 0, 1 ); 1395 0, 1 );
1397 1396
1398#endif 1397#endif
1399} 1398}
1400 1399
1401void MainWindow::saveOnClose() 1400void MainWindow::saveOnClose()
1402{ 1401{
1403 KOPrefs *p = KOPrefs::instance(); 1402 KOPrefs *p = KOPrefs::instance();
1404 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1403 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1405 p->mToolBarUp = iconToolBar->x() > width()/2 || 1404 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1406 iconToolBar->y() > height()/2; 1405 iconToolBar->y() > height()/2;
1407 mView->writeSettings(); 1406 mView->writeSettings();
1408 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1407 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1409 save(); 1408 save();
1410} 1409}
1411void MainWindow::slotModifiedChanged( bool changed ) 1410void MainWindow::slotModifiedChanged( bool changed )
1412{ 1411{
1413 if ( mBlockAtStartup ) 1412 if ( mBlockAtStartup )
1414 return; 1413 return;
1415 int msec; 1414 int msec;
1416 // we store the changes after 1 minute, 1415 // we store the changes after 1 minute,
1417 // and for safety reasons after 10 minutes again 1416 // and for safety reasons after 10 minutes again
1418 if ( !mBlockSaveFlag ) 1417 if ( !mBlockSaveFlag )
1419 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1418 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1420 else 1419 else
1421 msec = 1000 * 600; 1420 msec = 1000 * 600;
1422 mSaveTimer.start( msec, true ); // 1 minute 1421 mSaveTimer.start( msec, true ); // 1 minute
1423 qDebug("KO: Saving File in %d secs!", msec/1000); 1422 qDebug("KO: Saving File in %d secs!", msec/1000);
1424 mCalendarModifiedFlag = true; 1423 mCalendarModifiedFlag = true;
1425} 1424}
1426void MainWindow::save() 1425void MainWindow::save()
1427{ 1426{
1428 if ( mBlockSaveFlag ) 1427 if ( mBlockSaveFlag )
1429 return; 1428 return;
1430 bool store = mBlockSaveFlag; 1429 bool store = mBlockSaveFlag;
1431 mBlockSaveFlag = true; 1430 mBlockSaveFlag = true;
1432 if ( mView->checkFileVersion( defaultFileName()) ) { 1431 if ( mView->checkFileVersion( defaultFileName()) ) {
1433 1432
1434 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1433 QTime neededSaveTime = QDateTime::currentDateTime().time();
1435 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1434 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1436 qDebug("KO: Start saving data to file!"); 1435 qDebug("KO: Start saving data to file!");
1437 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1436 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1438 mView->saveCalendar( defaultFileName() ); 1437 mView->saveCalendar( defaultFileName() );
1439 1438
1440 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1439 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1441 mView->watchSavedFile(); 1440 mView->watchSavedFile();
1442 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1441 qDebug("KO: Needed %d ms for saving.",msNeeded );
1443 QString savemes; 1442 QString savemes;
1444 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1443 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1445 setCaption(savemes); 1444 setCaption(savemes);
1446 } else 1445 } else
1447 setCaption(i18n("Saving cancelled!")); 1446 setCaption(i18n("Saving cancelled!"));
1448 mCalendarModifiedFlag = false; 1447 mCalendarModifiedFlag = false;
1449 mBlockSaveFlag = store; 1448 mBlockSaveFlag = store;
1450} 1449}
1451 1450
1452void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1451void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1453{ 1452{
1454 if ( !e->isAutoRepeat() ) { 1453 if ( !e->isAutoRepeat() ) {
1455 mFlagKeyPressed = false; 1454 mFlagKeyPressed = false;
1456 } 1455 }
1457} 1456}
1458void MainWindow::keyPressEvent ( QKeyEvent * e ) 1457void MainWindow::keyPressEvent ( QKeyEvent * e )
1459{ 1458{
1460 qApp->processEvents(); 1459 qApp->processEvents();
1461 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1460 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1462 e->ignore(); 1461 e->ignore();
1463 // qDebug(" ignore %d",e->isAutoRepeat() ); 1462 // qDebug(" ignore %d",e->isAutoRepeat() );
1464 return; 1463 return;
1465 } 1464 }
1466 if (! e->isAutoRepeat() ) 1465 if (! e->isAutoRepeat() )
1467 mFlagKeyPressed = true; 1466 mFlagKeyPressed = true;
1468 KOPrefs *p = KOPrefs::instance(); 1467 KOPrefs *p = KOPrefs::instance();
1469 bool showSelectedDates = false; 1468 bool showSelectedDates = false;
1470 int size; 1469 int size;
1471 int pro = 0; 1470 int pro = 0;
1472 //qDebug("MainWindow::keyPressEvent "); 1471 //qDebug("MainWindow::keyPressEvent ");
1473 switch ( e->key() ) { 1472 switch ( e->key() ) {
1474 case Qt::Key_Right: 1473 case Qt::Key_Right:
1475 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1474 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1476 mView->goNextMonth(); 1475 mView->goNextMonth();
1477 else 1476 else
1478 mView->goNext(); 1477 mView->goNext();
1479 showSelectedDates = true; 1478 showSelectedDates = true;
1480 break; 1479 break;
1481 case Qt::Key_Left: 1480 case Qt::Key_Left:
1482 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1481 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1483 mView->goPreviousMonth(); 1482 mView->goPreviousMonth();
1484 else 1483 else
1485 mView->goPrevious(); 1484 mView->goPrevious();
1486 showSelectedDates = true; 1485 showSelectedDates = true;
1487 break; 1486 break;
1488 case Qt::Key_Down: 1487 case Qt::Key_Down:
1489 mView->viewManager()->agendaView()->scrollOneHourDown(); 1488 mView->viewManager()->agendaView()->scrollOneHourDown();
1490 break; 1489 break;
1491 case Qt::Key_Up: 1490 case Qt::Key_Up:
1492 mView->viewManager()->agendaView()->scrollOneHourUp(); 1491 mView->viewManager()->agendaView()->scrollOneHourUp();
1493 break; 1492 break;
1494 case Qt::Key_I: 1493 case Qt::Key_I:
1495 mView->showIncidence(); 1494 mView->showIncidence();
1496 break; 1495 break;
1497 case Qt::Key_Delete: 1496 case Qt::Key_Delete:
1498 case Qt::Key_Backspace: 1497 case Qt::Key_Backspace:
1499 mView->deleteIncidence(); 1498 mView->deleteIncidence();
1500 break; 1499 break;
1501 case Qt::Key_D: 1500 case Qt::Key_D:
1502 mView->viewManager()->showDayView(); 1501 mView->viewManager()->showDayView();
1503 showSelectedDates = true; 1502 showSelectedDates = true;
1504 break; 1503 break;
1505 case Qt::Key_O: 1504 case Qt::Key_O:
1506 mView->toggleFilerEnabled( ); 1505 mView->toggleFilerEnabled( );
1507 break; 1506 break;
1508 case Qt::Key_0: 1507 case Qt::Key_0:
1509 case Qt::Key_1: 1508 case Qt::Key_1:
1510 case Qt::Key_2: 1509 case Qt::Key_2:
1511 case Qt::Key_3: 1510 case Qt::Key_3:
1512 case Qt::Key_4: 1511 case Qt::Key_4:
1513 case Qt::Key_5: 1512 case Qt::Key_5:
1514 case Qt::Key_6: 1513 case Qt::Key_6:
1515 case Qt::Key_7: 1514 case Qt::Key_7:
1516 case Qt::Key_8: 1515 case Qt::Key_8:
1517 case Qt::Key_9: 1516 case Qt::Key_9:
1518 pro = e->key()-48; 1517 pro = e->key()-48;
1519 if ( pro == 0 ) 1518 if ( pro == 0 )
1520 pro = 10; 1519 pro = 10;
1521 if ( e->state() == Qt::ControlButton) 1520 if ( e->state() == Qt::ControlButton)
1522 pro += 10; 1521 pro += 10;
1523 break; 1522 break;
1524 case Qt::Key_M: 1523 case Qt::Key_M:
1525 mView->viewManager()->showMonthView(); 1524 mView->viewManager()->showMonthView();
1526 showSelectedDates = true; 1525 showSelectedDates = true;
1527 break; 1526 break;
1528 case Qt::Key_Insert: 1527 case Qt::Key_Insert:
1529 mView->newEvent(); 1528 mView->newEvent();
1530 break; 1529 break;
1531 case Qt::Key_S : 1530 case Qt::Key_S :
1532 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1531 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1533 mView->newSubTodo(); 1532 mView->newSubTodo();
1534 else 1533 else
1535 mView->dialogManager()->showSearchDialog(); 1534 mView->dialogManager()->showSearchDialog();
1536 break; 1535 break;
1537 case Qt::Key_Y : 1536 case Qt::Key_Y :
1538 case Qt::Key_Z : 1537 case Qt::Key_Z :
1539 mView->viewManager()->showWorkWeekView(); 1538 mView->viewManager()->showWorkWeekView();
1540 showSelectedDates = true; 1539 showSelectedDates = true;
1541 break; 1540 break;
1542 case Qt::Key_U : 1541 case Qt::Key_U :
1543 mView->viewManager()->showWeekView(); 1542 mView->viewManager()->showWeekView();
1544 showSelectedDates = true; 1543 showSelectedDates = true;
1545 break; 1544 break;
1546 case Qt::Key_H : 1545 case Qt::Key_H :
1547 keyBindings(); 1546 keyBindings();
1548 break; 1547 break;
1549 case Qt::Key_W: 1548 case Qt::Key_W:
1550 mView->viewManager()->showWhatsNextView(); 1549 mView->viewManager()->showWhatsNextView();
1551 break; 1550 break;
1552 case Qt::Key_L: 1551 case Qt::Key_L:
1553 mView->viewManager()->showListView(); 1552 mView->viewManager()->showListView();
1554 break; 1553 break;
1555 case Qt::Key_N: 1554 case Qt::Key_N:
1556 mView->viewManager()->showNextXView(); 1555 mView->viewManager()->showNextXView();
1557 showSelectedDates = true; 1556 showSelectedDates = true;
1558 break; 1557 break;
1559 case Qt::Key_V: 1558 case Qt::Key_V:
1560 mView->viewManager()->showTodoView(); 1559 mView->viewManager()->showTodoView();
1561 break; 1560 break;
1562 case Qt::Key_C: 1561 case Qt::Key_C:
1563 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1562 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1564 break; 1563 break;
1565 case Qt::Key_P: 1564 case Qt::Key_P:
1566 mView->showDatePicker( ); 1565 mView->showDatePicker( );
1567 break; 1566 break;
1568 case Qt::Key_F: 1567 case Qt::Key_F:
1569 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1568 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1570 mView->editFilters(); 1569 mView->editFilters();
1571 else 1570 else
1572 mView->toggleFilter(); 1571 mView->toggleFilter();
1573 break; 1572 break;
1574 case Qt::Key_X: 1573 case Qt::Key_X:
1575 mView->toggleDateNavigatorWidget(); 1574 mView->toggleDateNavigatorWidget();
1576 break; 1575 break;
1577 case Qt::Key_Space: 1576 case Qt::Key_Space:
1578 mView->toggleExpand(); 1577 mView->toggleExpand();
1579 break; 1578 break;
1580 case Qt::Key_A: 1579 case Qt::Key_A:
1581 mView->toggleAllDaySize(); 1580 mView->toggleAllDaySize();
1582 break; 1581 break;
1583 case Qt::Key_T: 1582 case Qt::Key_T:
1584 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1583 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1585 mView->newTodo(); 1584 mView->newTodo();
1586 else { 1585 else {
1587 mView->goToday(); 1586 mView->goToday();
1588 showSelectedDates = true; 1587 showSelectedDates = true;
1589 } 1588 }
1590 break; 1589 break;
1591 case Qt::Key_J: 1590 case Qt::Key_J:
1592 mView->viewManager()->showJournalView(); 1591 mView->viewManager()->showJournalView();
1593 break; 1592 break;
1594 case Qt::Key_B: 1593 case Qt::Key_B:
1595 mView->editIncidenceDescription();; 1594 mView->editIncidenceDescription();;
1596 break; 1595 break;
1597 // case Qt::Key_Return: 1596 // case Qt::Key_Return:
1598 case Qt::Key_E: 1597 case Qt::Key_E:
1599 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1598 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1600 mView->newEvent(); 1599 mView->newEvent();
1601 else 1600 else
1602 mView->editIncidence(); 1601 mView->editIncidence();
1603 break; 1602 break;
1604 case Qt::Key_Plus: 1603 case Qt::Key_Plus:
1605 size = p->mHourSize +2; 1604 size = p->mHourSize +2;
1606 if ( size <= 18 ) 1605 if ( size <= 18 )
1607 configureAgenda( size ); 1606 configureAgenda( size );
1608 break; 1607 break;
1609 case Qt::Key_Minus: 1608 case Qt::Key_Minus:
1610 size = p->mHourSize - 2; 1609 size = p->mHourSize - 2;
1611 if ( size >= 4 ) 1610 if ( size >= 4 )
1612 configureAgenda( size ); 1611 configureAgenda( size );
1613 break; 1612 break;
1614 1613
1615 1614
1616 default: 1615 default:
1617 e->ignore(); 1616 e->ignore();
1618 } 1617 }
1619 if ( pro > 0 ) { 1618 if ( pro > 0 ) {
1620 mView->selectFilter( pro-1 ); 1619 mView->selectFilter( pro-1 );
1621 } 1620 }
1622 if ( showSelectedDates ) { 1621 if ( showSelectedDates ) {
1623 ;// setCaptionToDates(); 1622 ;// setCaptionToDates();
1624 } 1623 }
1625 1624
1626} 1625}
1627 1626
1628void MainWindow::fillFilterMenu() 1627void MainWindow::fillFilterMenu()
1629{ 1628{
1630 selectFilterMenu->clear(); 1629 selectFilterMenu->clear();
1631 bool disable = false; 1630 bool disable = false;
1632 if ( mView->filterView()->filtersEnabled() ) { 1631 if ( mView->filterView()->filtersEnabled() ) {
1633 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1632 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1634 } 1633 }
1635 else { 1634 else {
1636 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1635 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1637 disable = true; 1636 disable = true;
1638 } 1637 }
1639 selectFilterMenu->insertSeparator(); 1638 selectFilterMenu->insertSeparator();
1640 QPtrList<CalFilter> fili = mView->filters(); 1639 QPtrList<CalFilter> fili = mView->filters();
1641 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1640 CalFilter *curfilter = mView->filterView()->selectedFilter();
1642 CalFilter *filter = fili.first(); 1641 CalFilter *filter = fili.first();
1643 int iii = 1; 1642 int iii = 1;
1644 while(filter) { 1643 while(filter) {
1645 selectFilterMenu->insertItem( filter->name(), iii ); 1644 selectFilterMenu->insertItem( filter->name(), iii );
1646 if ( filter == curfilter) 1645 if ( filter == curfilter)
1647 selectFilterMenu->setItemChecked( iii, true ); 1646 selectFilterMenu->setItemChecked( iii, true );
1648 if ( disable ) 1647 if ( disable )
1649 selectFilterMenu->setItemEnabled( iii, false ); 1648 selectFilterMenu->setItemEnabled( iii, false );
1650 filter = fili.next(); 1649 filter = fili.next();
1651 ++iii; 1650 ++iii;
1652 } 1651 }
1653} 1652}
1654void MainWindow::selectFilter( int fil ) 1653void MainWindow::selectFilter( int fil )
1655{ 1654{
1656 if ( fil == 0 ) { 1655 if ( fil == 0 ) {
1657 mView->toggleFilerEnabled( ); 1656 mView->toggleFilerEnabled( );
1658 } else { 1657 } else {
1659 mView->selectFilter( fil-1 ); 1658 mView->selectFilter( fil-1 );
1660 } 1659 }
1661} 1660}
1662void MainWindow::configureToolBar( int item ) 1661void MainWindow::configureToolBar( int item )
1663{ 1662{
1664 1663
1665 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1664 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1666 KOPrefs *p = KOPrefs::instance(); 1665 KOPrefs *p = KOPrefs::instance();
1667 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1666 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1668 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1667 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1669 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1668 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1670 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1669 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1671 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1670 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1672 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1671 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1673 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1672 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1674 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1673 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1675 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1674 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1676 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1675 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1677 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1676 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1678 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1677 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1679 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1678 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1680 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1679 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1681 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1680 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1682 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1681 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1683 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1682 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1684 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1683 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1685 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1684 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1686 // initActions(); 1685 // initActions();
1687} 1686}
1688 1687
1689void MainWindow::setCaptionToDates() 1688void MainWindow::setCaptionToDates()
1690{ 1689{
1691 QString selDates; 1690 QString selDates;
1692 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1691 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1693 if (mView->startDate() < mView->endDate() ) 1692 if (mView->startDate() < mView->endDate() )
1694 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1693 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1695 setCaption( i18n("Dates: ") + selDates ); 1694 setCaption( i18n("Dates: ") + selDates );
1696 1695
1697} 1696}
1698// parameter item == 0: reinit 1697// parameter item == 0: reinit
1699void MainWindow::configureAgenda( int item ) 1698void MainWindow::configureAgenda( int item )
1700{ 1699{
1701 1700
1702 KOPrefs *p = KOPrefs::instance(); 1701 KOPrefs *p = KOPrefs::instance();
1703 1702
1704 int i; 1703 int i;
1705 if ( item == 1 ) { 1704 if ( item == 1 ) {
1706 mView->toggleAllDaySize(); 1705 mView->toggleAllDaySize();
1707 return; 1706 return;
1708 } 1707 }
1709 // do not allow 4 for widgets higher than 480 1708 // do not allow 4 for widgets higher than 480
1710 // if ( QApplication::desktop()->height() > 480 ) { 1709 // if ( QApplication::desktop()->height() > 480 ) {
1711// if ( item == 4 ) 1710// if ( item == 4 )
1712// item = 6; 1711// item = 6;
1713// } 1712// }
1714 for ( i = 4; i <= 18; i= i+2 ) 1713 for ( i = 4; i <= 18; i= i+2 )
1715 configureAgendaMenu->setItemChecked( i, false ); 1714 configureAgendaMenu->setItemChecked( i, false );
1716 configureAgendaMenu->setItemChecked( item, true ); 1715 configureAgendaMenu->setItemChecked( item, true );
1717 if ( p->mHourSize == item ) 1716 if ( p->mHourSize == item )
1718 return; 1717 return;
1719 p->mHourSize=item; 1718 p->mHourSize=item;
1720 mView->viewManager()->agendaView()->updateConfig(); 1719 mView->viewManager()->agendaView()->updateConfig();
1721} 1720}
1722 1721
1723void MainWindow::saveCalendar() 1722void MainWindow::saveCalendar()
1724{ 1723{
1725 QString fn = KOPrefs::instance()->mLastSaveFile; 1724 QString fn = KOPrefs::instance()->mLastSaveFile;
1726 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1725 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1727 1726
1728 if ( fn == "" ) 1727 if ( fn == "" )
1729 return; 1728 return;
1730 QFileInfo info; 1729 QFileInfo info;
1731 info.setFile( fn ); 1730 info.setFile( fn );
1732 QString mes; 1731 QString mes;
1733 bool createbup = true; 1732 bool createbup = true;
1734 if ( info. exists() ) { 1733 if ( info. exists() ) {
1735 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1734 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1736 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1735 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1737 i18n("Overwrite!"), i18n("Cancel"), 0, 1736 i18n("Overwrite!"), i18n("Cancel"), 0,
1738 0, 1 ); 1737 0, 1 );
1739 if ( result != 0 ) { 1738 if ( result != 0 ) {
1740 createbup = false; 1739 createbup = false;
1741 } 1740 }
1742 } 1741 }
1743 if ( createbup ) { 1742 if ( createbup ) {
1744 mView->saveCalendar( fn ); 1743 mView->saveCalendar( fn );
1745 mes = i18n("KO/Pi:Saved %1").arg(fn); 1744 mes = i18n("KO/Pi:Saved %1").arg(fn);
1746 KOPrefs::instance()->mLastSaveFile = fn; 1745 KOPrefs::instance()->mLastSaveFile = fn;
1747 setCaption(mes); 1746 setCaption(mes);
1748 } 1747 }
1749} 1748}
1750void MainWindow::loadCalendar() 1749void MainWindow::loadCalendar()
1751{ 1750{
1752 1751
1753 QString fn = KOPrefs::instance()->mLastLoadFile; 1752 QString fn = KOPrefs::instance()->mLastLoadFile;
1754 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1753 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1755 1754
1756 if ( fn == "" ) 1755 if ( fn == "" )
1757 return; 1756 return;
1758 QFileInfo info; 1757 QFileInfo info;
1759 info.setFile( fn ); 1758 info.setFile( fn );
1760 QString mess; 1759 QString mess;
1761 bool loadbup = true; 1760 bool loadbup = true;
1762 if ( info. exists() ) { 1761 if ( info. exists() ) {
1763 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1762 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1764 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1763 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1765 mess, 1764 mess,
1766 i18n("Load!"), i18n("Cancel"), 0, 1765 i18n("Load!"), i18n("Cancel"), 0,
1767 0, 1 ); 1766 0, 1 );
1768 if ( result != 0 ) { 1767 if ( result != 0 ) {
1769 loadbup = false; 1768 loadbup = false;
1770 } 1769 }
1771 } else { 1770 } else {
1772 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1771 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1773 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1772 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1774 0, 1 ); 1773 0, 1 );
1775 1774
1776 return; 1775 return;
1777 } 1776 }
1778 if ( loadbup ) { 1777 if ( loadbup ) {
1779 mView->openCalendar( fn ); 1778 mView->openCalendar( fn );
1780 KOPrefs::instance()->mLastLoadFile = fn; 1779 KOPrefs::instance()->mLastLoadFile = fn;
1781 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1780 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1782 setCaption(mess); 1781 setCaption(mess);
1783 } 1782 }
1784 1783
1785} 1784}
1786void MainWindow::quickImportIcal() 1785void MainWindow::quickImportIcal()
1787{ 1786{
1788 importFile( KOPrefs::instance()->mLastImportFile, false ); 1787 importFile( KOPrefs::instance()->mLastImportFile, false );
1789} 1788}
1790void MainWindow::importFile( QString fn, bool quick ) 1789void MainWindow::importFile( QString fn, bool quick )
1791{ 1790{
1792 QFileInfo info; 1791 QFileInfo info;
1793 info.setFile( fn ); 1792 info.setFile( fn );
1794 QString mess; 1793 QString mess;
1795 bool loadbup = true; 1794 bool loadbup = true;
1796 if ( !info. exists() ) { 1795 if ( !info. exists() ) {
1797 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1796 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1798 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1797 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1799 mess ); 1798 mess );
1800 return; 1799 return;
1801 } 1800 }
1802 int result = 0; 1801 int result = 0;
1803 if ( !quick ) { 1802 if ( !quick ) {
1804 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 )); 1803 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 ));
1805 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1804 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1806 mess, 1805 mess,
1807 "Import", "Cancel", 0, 1806 "Import", "Cancel", 0,
1808 0, 1 ); 1807 0, 1 );
1809 } 1808 }
1810 if ( result == 0 ) { 1809 if ( result == 0 ) {
1811 if ( mView->openCalendar( fn, true )) { 1810 if ( mView->openCalendar( fn, true )) {
1812 KOPrefs::instance()->mLastImportFile = fn; 1811 KOPrefs::instance()->mLastImportFile = fn;
1813 setCaption(i18n("Imported file successfully")); 1812 setCaption(i18n("Imported file successfully"));
1814 } else { 1813 } else {
1815 setCaption(i18n("Error importing file")); 1814 setCaption(i18n("Error importing file"));
1816 } 1815 }
1817 } 1816 }
1818} 1817}
1819 1818
1820void MainWindow::importIcal() 1819void MainWindow::importIcal()
1821{ 1820{
1822 1821
1823 QString fn =KOPrefs::instance()->mLastImportFile; 1822 QString fn =KOPrefs::instance()->mLastImportFile;
1824 1823
1825 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1824 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1826 if ( fn == "" ) 1825 if ( fn == "" )
1827 return; 1826 return;
1828 importFile( fn, true ); 1827 importFile( fn, true );
1829 1828
1830} 1829}
1831 1830
1832void MainWindow::exportVCalendar() 1831void MainWindow::exportVCalendar()
1833{ 1832{
1834 QString fn = KOPrefs::instance()->mLastVcalFile; 1833 QString fn = KOPrefs::instance()->mLastVcalFile;
1835 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1834 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1836 if ( fn == "" ) 1835 if ( fn == "" )
1837 return; 1836 return;
1838 QFileInfo info; 1837 QFileInfo info;
1839 info.setFile( fn ); 1838 info.setFile( fn );
1840 QString mes; 1839 QString mes;
1841 bool createbup = true; 1840 bool createbup = true;
1842 if ( info. exists() ) { 1841 if ( info. exists() ) {
1843 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1842 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1844 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1843 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1845 i18n("Overwrite!"), i18n("Cancel"), 0, 1844 i18n("Overwrite!"), i18n("Cancel"), 0,
1846 0, 1 ); 1845 0, 1 );
1847 if ( result != 0 ) { 1846 if ( result != 0 ) {
1848 createbup = false; 1847 createbup = false;
1849 } 1848 }
1850 } 1849 }
1851 if ( createbup ) { 1850 if ( createbup ) {
1852 if ( mView->exportVCalendar( fn ) ) { 1851 if ( mView->exportVCalendar( fn ) ) {
1853 KOPrefs::instance()->mLastVcalFile = fn; 1852 KOPrefs::instance()->mLastVcalFile = fn;
1854 if ( fn.length() > 20 ) 1853 if ( fn.length() > 20 )
1855 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1854 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1856 else 1855 else
1857 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1856 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1858 setCaption(mes); 1857 setCaption(mes);
1859 } 1858 }
1860 } 1859 }
1861 1860
1862} 1861}
1863QString MainWindow::getPassword( ) 1862QString MainWindow::getPassword( )
1864{ 1863{
1865 QString retfile = ""; 1864 QString retfile = "";
1866 QDialog dia ( this, "input-dialog", true ); 1865 QDialog dia ( this, "input-dialog", true );
1867 QLineEdit lab ( &dia ); 1866 QLineEdit lab ( &dia );
1868 lab.setEchoMode( QLineEdit::Password ); 1867 lab.setEchoMode( QLineEdit::Password );
1869 QVBoxLayout lay( &dia ); 1868 QVBoxLayout lay( &dia );
1870 lay.setMargin(7); 1869 lay.setMargin(7);
1871 lay.setSpacing(7); 1870 lay.setSpacing(7);
1872 lay.addWidget( &lab); 1871 lay.addWidget( &lab);
1873 dia.setFixedSize( 230,50 ); 1872 dia.setFixedSize( 230,50 );
1874 dia.setCaption( i18n("Enter password") ); 1873 dia.setCaption( i18n("Enter password") );
1875 QPushButton pb ( "OK", &dia); 1874 QPushButton pb ( "OK", &dia);
1876 lay.addWidget( &pb ); 1875 lay.addWidget( &pb );
1877 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1876 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1878 dia.show(); 1877 dia.show();
1879 int res = dia.exec(); 1878 int res = dia.exec();
1880 if ( res ) 1879 if ( res )
1881 retfile = lab.text(); 1880 retfile = lab.text();
1882 dia.hide(); 1881 dia.hide();
1883 qApp->processEvents(); 1882 qApp->processEvents();
1884 return retfile; 1883 return retfile;
1885 1884
1886} 1885}
1887 1886
1888void MainWindow::enableQuick() 1887void MainWindow::enableQuick()
1889{ 1888{
1890 QString passWordPiSync = "bhdrvmk"; 1889 QString passWordPiSync = "bhdrvmk";
1891 QString retfile = ""; 1890 QString retfile = "";
1892 QDialog dia ( this, "input-dialog", true ); 1891 QDialog dia ( this, "input-dialog", true );
1893 QLineEdit lab ( &dia ); 1892 QLineEdit lab ( &dia );
1894 QVBoxLayout lay( &dia ); 1893 QVBoxLayout lay( &dia );
1895 lab.setText( KOPrefs::instance()->mPassiveSyncPort ); 1894 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
1896 lay.setMargin(7); 1895 lay.setMargin(7);
1897 lay.setSpacing(7); 1896 lay.setSpacing(7);
1898 QLabel label ( i18n("Port number (Default: 9197)"), &dia ); 1897 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
1899 lay.addWidget( &label); 1898 lay.addWidget( &label);
1900 lay.addWidget( &lab); 1899 lay.addWidget( &lab);
1901 1900
1902 QLineEdit lepw ( &dia ); 1901 QLineEdit lepw ( &dia );
1903 lepw.setText( "abc" ); 1902 lepw.setText( "abc" );
1904 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 1903 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
1905 lay.addWidget( &label2); 1904 lay.addWidget( &label2);
1906 lay.addWidget( &lepw); 1905 lay.addWidget( &lepw);
1907 dia.setFixedSize( 230,80 ); 1906 dia.setFixedSize( 230,80 );
1908 dia.setCaption( i18n("Enter port for Pi-Sync") ); 1907 dia.setCaption( i18n("Enter port for Pi-Sync") );
1909 QPushButton pb ( "OK", &dia); 1908 QPushButton pb ( "OK", &dia);
1910 lay.addWidget( &pb ); 1909 lay.addWidget( &pb );
1911 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1910 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1912 dia.show(); 1911 dia.show();
1913 int res = dia.exec(); 1912 int res = dia.exec();
1914 if ( res ) 1913 if ( res )
1915 retfile = lab.text(); 1914 retfile = lab.text();
1916 else 1915 else
1917 return; 1916 return;
1918 dia.hide(); 1917 dia.hide();
1919 passWordPiSync = lepw.text(); 1918 passWordPiSync = lepw.text();
1920 qApp->processEvents(); 1919 qApp->processEvents();
1921 KOPrefs::instance()->mPassiveSyncPort = retfile; 1920 KOPrefs::instance()->mPassiveSyncPort = retfile;
1922 bool ok; 1921 bool ok;
1923 Q_UINT16 port = retfile.toUInt(&ok); 1922 Q_UINT16 port = retfile.toUInt(&ok);
1924 if ( ! ok ) { 1923 if ( ! ok ) {
1925 KMessageBox::information( this, i18n("No valid port")); 1924 KMessageBox::information( this, i18n("No valid port"));
1926 return; 1925 return;
1927 } 1926 }
1928 qDebug("port %d ", port); 1927 qDebug("port %d ", port);
1929 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); 1928 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 );
1930 mServerSocket->setFileName( defaultFileName() ); 1929 mServerSocket->setFileName( defaultFileName() );
1931 qDebug("connected "); 1930 qDebug("connected ");
1932 if ( !mServerSocket->ok() ) { 1931 if ( !mServerSocket->ok() ) {
1933 qWarning("Failed to bind to port %d", port); 1932 qWarning("Failed to bind to port %d", port);
1934 delete mServerSocket; 1933 delete mServerSocket;
1935 mServerSocket = 0; 1934 mServerSocket = 0;
1936 return; 1935 return;
1937 } 1936 }
1938 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); 1937 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
1939 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); 1938 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
1940 // connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) ); 1939 // connect( mServerSocket, SIGNAL ( sendFile(QSocket*) ), this, SLOT ( sendFile(QSocket*) ) );
1941 //connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) ); 1940 //connect( mServerSocket, SIGNAL ( getFile(QSocket*) ), this, SLOT ( getFile(QSocket*) ) );
1942} 1941}
1943 1942
1944void MainWindow::getFile( bool success ) 1943void MainWindow::getFile( bool success )
1945{ 1944{
1946 if ( ! success ) { 1945 if ( ! success ) {
1947 setCaption( i18n("Error receiving file. Nothing changed!") ); 1946 setCaption( i18n("Error receiving file. Nothing changed!") );
1948 return; 1947 return;
1949 } 1948 }
1950 // pending adjust time for watchSavedFile() 1949 // pending adjust time for watchSavedFile()
1951 //mView->watchSavedFile(); 1950 //mView->watchSavedFile();
1952 mView->openCalendar( defaultFileName() ); 1951 mView->openCalendar( defaultFileName() );
1953 setCaption( i18n("Pi-Sync successful!") ); 1952 setCaption( i18n("Pi-Sync successful!") );
1954 1953
1955} 1954}
1956 1955
1957 1956
1958void MainWindow::performQuick() 1957void MainWindow::syncPi()
1959{ 1958{
1960
1961 setCaption( i18n("Please input connection settings") );
1962 QString retfile = "";
1963 QDialog dia ( this, "input-dialog", true );
1964 QLineEdit lab ( &dia );
1965 QVBoxLayout lay( &dia );
1966 QLabel label ( i18n("IP address\n(Example: 192.168.0.40)"), &dia );
1967 lay.addWidget( &label);
1968 lab.setText( KOPrefs::instance()->mActiveSyncIP );
1969 lay.setMargin(7);
1970 lay.setSpacing(7);
1971 lay.addWidget( &lab);
1972 QLabel label2 ( i18n("Port number (Default: 9197)"), &dia );
1973 lay.addWidget( &label2);
1974 QLineEdit lab2 ( &dia );
1975 lab2.setText( KOPrefs::instance()->mActiveSyncPort );
1976 lay.addWidget( &lab2);
1977
1978 QLineEdit lepw ( &dia );
1979 lepw.setText( mPassWordPiSync );
1980 QLabel label3 ( i18n("Password to enable\naccess to remote:"), &dia );
1981 lay.addWidget( &label3);
1982 lay.addWidget( &lepw);
1983
1984 dia.setFixedSize( 230,200 );
1985 dia.setCaption( i18n("Enter port for Pi-Sync ") );
1986 QPushButton pb ( "OK", &dia);
1987 lay.addWidget( &pb );
1988 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1989 dia.show();
1990 int res = dia.exec();
1991 if ( !res ) {
1992 setCaption( i18n("Syncing cancelled!") );
1993 return;
1994 }
1995 mPassWordPiSync = lepw.text();
1996 dia.hide();
1997 KOPrefs::instance()->mActiveSyncPort = lab2.text();
1998 KOPrefs::instance()->mActiveSyncIP = lab.text();
1999 qApp->processEvents(); 1959 qApp->processEvents();
2000 performQuickQuick(); 1960 performQuickQuick();
2001} 1961}
2002 1962
2003void MainWindow::performQuickQuick() 1963void MainWindow::performQuickQuick()
2004{ 1964{
2005 // setCaption( i18n("") ); 1965 // setCaption( i18n("") );
2006 1966
2007 bool ok; 1967 bool ok;
2008 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 1968 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
2009 if ( ! ok ) { 1969 if ( ! ok ) {
2010 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1970 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
2011 return; 1971 return;
2012 } 1972 }
2013 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); 1973 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
2014 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocket(KCommandSocket*,bool)) ); 1974 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocket(KCommandSocket*,bool)) );
2015 setCaption( i18n("Sending request for remote file ...") ); 1975 setCaption( i18n("Sending request for remote file ...") );
2016 QString fileName; 1976 QString fileName;
2017#ifdef _WIN32_ 1977#ifdef _WIN32_
2018 fileName = defaultFileName() +"sync"; 1978 fileName = defaultFileName() +"sync";
2019#else 1979#else
2020 fileName = "/tmp/kopitempfile.ics"; 1980 fileName = "/tmp/kopitempfile.ics";
2021#endif 1981#endif
2022 commandSocket->readFile( fileName ); 1982 commandSocket->readFile( fileName );
2023} 1983}
2024void MainWindow::deleteCommandSocket(KCommandSocket*s, bool success) 1984void MainWindow::deleteCommandSocket(KCommandSocket*s, bool success)
2025{ 1985{
2026 if ( ! success ) { 1986 if ( ! success ) {
2027 setCaption( i18n("ERROR:Receiving remote file failed.") ); 1987 setCaption( i18n("ERROR:Receiving remote file failed.") );
2028 delete s; 1988 delete s;
2029 // pending : send stop 1989 // pending : send stop
2030 return; 1990 return;
2031 1991
2032 } 1992 }
2033 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1993 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
2034 qDebug("MainWindow::deleteCommandSocket "); 1994 qDebug("MainWindow::deleteCommandSocket ");
2035 delete s; 1995 delete s;
2036} 1996}
2037void MainWindow::deleteCommandSocketFinish(KCommandSocket* s, bool success ) 1997void MainWindow::deleteCommandSocketFinish(KCommandSocket* s, bool success )
2038{ 1998{
2039 if ( ! success ) { 1999 if ( ! success ) {
2040 setCaption( i18n("ERROR:Writing back file failed.") ); 2000 setCaption( i18n("ERROR:Writing back file failed.") );
2041 } else { 2001 } else {
2042 qDebug("Syncing succesful! "); 2002 qDebug("Syncing succesful! ");
2043 setCaption( i18n("Pi-Sync succesful!") ); 2003 setCaption( i18n("Pi-Sync succesful!") );
2044 } 2004 }
2045 qDebug("MainWindow::deleteCommandSocketFinish "); 2005 qDebug("MainWindow::deleteCommandSocketFinish ");
2046 delete s; 2006 delete s;
2047} 2007}
2048void MainWindow::readFileFromSocket() 2008void MainWindow::readFileFromSocket()
2049{ 2009{
2050 // mTimerCommandSocket->stop(); 2010 // mTimerCommandSocket->stop();
2051 setCaption( i18n("Receiving remote file ...") ); 2011 setCaption( i18n("Receiving remote file ...") );
2052 qDebug("MainWindow::readFileFromSocket() "); 2012 qDebug("MainWindow::readFileFromSocket() ");
2053 QString fileName; 2013 QString fileName;
2054#ifdef _WIN32_ 2014#ifdef _WIN32_
2055 fileName = defaultFileName() +"sync"; 2015 fileName = defaultFileName() +"sync";
2056#else 2016#else
2057 fileName = "/tmp/kopitempfile.ics"; 2017 fileName = "/tmp/kopitempfile.ics";
2058#endif 2018#endif
2059 2019
2060 setCaption( i18n("Remote file saved to temp file.") ); 2020 setCaption( i18n("Remote file saved to temp file.") );
2061 //mCommandSocket = 0; 2021 //mCommandSocket = 0;
2062 mCurrentSyncProfile = 2 ; // last file 2022 mCurrentSyncProfile = 2 ; // last file
2063 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 2023 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
2064 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 2024 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
2065 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2025 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2066 KSyncProfile* temp = new KSyncProfile (); 2026 KSyncProfile* temp = new KSyncProfile ();
2067 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2027 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2068 temp->readConfig(&config); 2028 temp->readConfig(&config);
2069 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2029 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2070 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2030 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2071 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2031 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2072 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2032 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2073 KOPrefs::instance()->mWriteBackInFuture = 0; 2033 KOPrefs::instance()->mWriteBackInFuture = 0;
2074 if ( temp->getWriteBackFuture() ) 2034 if ( temp->getWriteBackFuture() )
2075 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2035 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2076 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2036 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2077 delete temp; 2037 delete temp;
2078 setCaption( i18n("Remote file saved to temp file.") ); 2038 setCaption( i18n("Remote file saved to temp file.") );
2079 if ( ! syncWithFile( fileName , true ) ) { 2039 if ( ! syncWithFile( fileName , true ) ) {
2080 setCaption( i18n("Syncing failed.") ); 2040 setCaption( i18n("Syncing failed.") );
2081 qDebug("Syncing failed "); 2041 qDebug("Syncing failed ");
2082 return; 2042 return;
2083 } 2043 }
2084 2044
2085 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 2045 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2086 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocketFinish(KCommandSocket*,bool)) ); 2046 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, bool )), this, SLOT(deleteCommandSocketFinish(KCommandSocket*,bool)) );
2087 if ( KOPrefs::instance()->mWriteBackFile ) 2047 if ( KOPrefs::instance()->mWriteBackFile )
2088 commandSocket->writeFile( fileName ); 2048 commandSocket->writeFile( fileName );
2089 else 2049 else
2090 commandSocket->sendStop(); 2050 commandSocket->sendStop();
2091} 2051}
2092 2052
2093void MainWindow::syncLocalFile() 2053void MainWindow::syncLocalFile()
2094{ 2054{
2095 2055
2096 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2056 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2097 2057
2098 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2058 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2099 if ( fn == "" ) 2059 if ( fn == "" )
2100 return; 2060 return;
2101 //mView->setSyncDevice("local-file" ); 2061 //mView->setSyncDevice("local-file" );
2102 if ( syncWithFile( fn, false ) ) { 2062 if ( syncWithFile( fn, false ) ) {
2103 // Event* e = mView->getLastSyncEvent(); 2063 // Event* e = mView->getLastSyncEvent();
2104// e->setReadOnly( false ); 2064// e->setReadOnly( false );
2105// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2065// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2106// e->setReadOnly( true ); 2066// e->setReadOnly( true );
2107 } 2067 }
2108 2068
2109} 2069}
2110 2070
2111bool MainWindow::syncWithFile( QString fn , bool quick ) 2071bool MainWindow::syncWithFile( QString fn , bool quick )
2112{ 2072{
2113 bool ret = false; 2073 bool ret = false;
2114 QFileInfo info; 2074 QFileInfo info;
2115 info.setFile( fn ); 2075 info.setFile( fn );
2116 QString mess; 2076 QString mess;
2117 bool loadbup = true; 2077 bool loadbup = true;
2118 if ( !info. exists() ) { 2078 if ( !info. exists() ) {
2119 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2079 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2120 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2080 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2121 mess ); 2081 mess );
2122 return ret; 2082 return ret;
2123 } 2083 }
2124 int result = 0; 2084 int result = 0;
2125 if ( !quick ) { 2085 if ( !quick ) {
2126 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2086 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2127 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2087 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2128 mess, 2088 mess,
2129 i18n("Sync"), i18n("Cancel"), 0, 2089 i18n("Sync"), i18n("Cancel"), 0,
2130 0, 1 ); 2090 0, 1 );
2131 if ( result ) 2091 if ( result )
2132 return false; 2092 return false;
2133 } 2093 }
2134 if ( KOPrefs::instance()->mAskForPreferences ) 2094 if ( KOPrefs::instance()->mAskForPreferences )
2135 mView->edit_sync_options(); 2095 mView->edit_sync_options();
2136 if ( result == 0 ) { 2096 if ( result == 0 ) {
2137 //qDebug("Now sycing ... "); 2097 //qDebug("Now sycing ... ");
2138 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 2098 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
2139 setCaption( i18n("Synchronization successful") ); 2099 setCaption( i18n("Synchronization successful") );
2140 else 2100 else
2141 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2101 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2142 if ( ! quick ) 2102 if ( ! quick )
2143 KOPrefs::instance()->mLastSyncedLocalFile = fn; 2103 KOPrefs::instance()->mLastSyncedLocalFile = fn;
2144 slotModifiedChanged( true ); 2104 slotModifiedChanged( true );
2145 } 2105 }
2146 return ret; 2106 return ret;
2147} 2107}
2148void MainWindow::quickSyncLocalFile() 2108void MainWindow::quickSyncLocalFile()
2149{ 2109{
2150 //mView->setSyncDevice("local-file" ); 2110 //mView->setSyncDevice("local-file" );
2151 //qDebug("quickSyncLocalFile() "); 2111 //qDebug("quickSyncLocalFile() ");
2152 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2112 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2153 // Event* e = mView->getLastSyncEvent(); 2113 // Event* e = mView->getLastSyncEvent();
2154// e->setReadOnly( false ); 2114// e->setReadOnly( false );
2155// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2115// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2156// e->setReadOnly( true ); 2116// e->setReadOnly( true );
2157 2117
2158 } 2118 }
2159} 2119}
2160 2120
2161void MainWindow::confSync() 2121void MainWindow::confSync()
2162{ 2122{
2163 mView->confSync(); 2123 mView->confSync();
2164 fillSyncMenu(); 2124 fillSyncMenu();
2165} 2125}
2166void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 2126void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
2167{ 2127{
2168 QString question; 2128 QString question;
2169 if ( ask ) { 2129 if ( ask ) {
2170 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2130 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2171 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2131 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2172 question, 2132 question,
2173 i18n("Yes"), i18n("No"), 2133 i18n("Yes"), i18n("No"),
2174 0, 0 ) != 0 ) 2134 0, 0 ) != 0 )
2175 return; 2135 return;
2176 } 2136 }
2177 QString command = prof->getPreSyncCommand(); 2137 QString command = prof->getPreSyncCommand();
2178 int fi; 2138 int fi;
2179 if ( (fi = command.find("$PWD$")) > 0 ) { 2139 if ( (fi = command.find("$PWD$")) > 0 ) {
2180 QString pwd = getPassword(); 2140 QString pwd = getPassword();
2181 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2141 command = command.left( fi )+ pwd + command.mid( fi+5 );
2182 2142
2183 } 2143 }
2184 int maxlen = 30; 2144 int maxlen = 30;
2185 if ( QApplication::desktop()->width() > 320 ) 2145 if ( QApplication::desktop()->width() > 320 )
2186 maxlen += 25; 2146 maxlen += 25;
2187 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2147 setCaption ( i18n( "Copy remote file to local machine..." ) );
2188 int fileSize = 0; 2148 int fileSize = 0;
2189 int result = system ( command ); 2149 int result = system ( command );
2190 // 0 : okay 2150 // 0 : okay
2191 // 256: no such file or dir 2151 // 256: no such file or dir
2192 // 2152 //
2193 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2153 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2194 if ( result != 0 ) { 2154 if ( result != 0 ) {
2195 int len = maxlen; 2155 int len = maxlen;
2196 while ( len < command.length() ) { 2156 while ( len < command.length() ) {
2197 command.insert( len , "\n" ); 2157 command.insert( len , "\n" );
2198 len += maxlen +2; 2158 len += maxlen +2;
2199 } 2159 }
2200 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) ; 2160 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) ;
2201 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2161 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2202 question, 2162 question,
2203 i18n("Okay!")) ; 2163 i18n("Okay!")) ;
2204 setCaption ("KO/Pi"); 2164 setCaption ("KO/Pi");
2205 return; 2165 return;
2206 } 2166 }
2207 setCaption ( i18n( "Copying succeed." ) ); 2167 setCaption ( i18n( "Copying succeed." ) );
2208 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2168 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2209 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 2169 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
2210// Event* e = mView->getLastSyncEvent(); 2170// Event* e = mView->getLastSyncEvent();
2211// e->setReadOnly( false ); 2171// e->setReadOnly( false );
2212// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2172// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2213// e->setReadOnly( true ); 2173// e->setReadOnly( true );
2214 if ( KOPrefs::instance()->mWriteBackFile ) { 2174 if ( KOPrefs::instance()->mWriteBackFile ) {
2215 command = prof->getPostSyncCommand(); 2175 command = prof->getPostSyncCommand();
2216 int fi; 2176 int fi;
2217 if ( (fi = command.find("$PWD$")) > 0 ) { 2177 if ( (fi = command.find("$PWD$")) > 0 ) {
2218 QString pwd = getPassword(); 2178 QString pwd = getPassword();
2219 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2179 command = command.left( fi )+ pwd + command.mid( fi+5 );
2220 2180
2221 } 2181 }
2222 setCaption ( i18n( "Writing back file ..." ) ); 2182 setCaption ( i18n( "Writing back file ..." ) );
2223 result = system ( command ); 2183 result = system ( command );
2224 qDebug("KO: Writing back file result: %d ", result); 2184 qDebug("KO: Writing back file result: %d ", result);
2225 if ( result != 0 ) { 2185 if ( result != 0 ) {
2226 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2186 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2227 return; 2187 return;
2228 } else { 2188 } else {
2229 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2189 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2230 } 2190 }
2231 } 2191 }
2232 } 2192 }
2233 return; 2193 return;
2234} 2194}
2235void MainWindow::syncSSH() 2195void MainWindow::syncSSH()
2236{ 2196{
2237 // not used anymore 2197 // not used anymore
2238 QTime timer; 2198 QTime timer;
2239 timer.start(); 2199 timer.start();
2240 //qDebug("MainWindow::syncssh() "); 2200 //qDebug("MainWindow::syncssh() ");
2241 KOPrefs *p = KOPrefs::instance(); 2201 KOPrefs *p = KOPrefs::instance();
2242 QString localFile = p->mLocalTempFile; 2202 QString localFile = p->mLocalTempFile;
2243 QString remoteIP = p->mRemoteIP; 2203 QString remoteIP = p->mRemoteIP;
2244 QString remoteUser = p->mRemoteUser; 2204 QString remoteUser = p->mRemoteUser;
2245 QString remoteFile = p->mRemoteFile; 2205 QString remoteFile = p->mRemoteFile;
2246 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 2206 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
2247 remoteUser += ":" + p->mRemotePassWd; 2207 remoteUser += ":" + p->mRemotePassWd;
2248 2208
2249 QString question = i18n("Do you really want\nto remote sync?\n \n") + 2209 QString question = i18n("Do you really want\nto remote sync?\n \n") +
2250 i18n("IP: " ) +remoteIP +"\n" + 2210 i18n("IP: " ) +remoteIP +"\n" +
2251 i18n("User: " ) + remoteUser +"\n" ; 2211 i18n("User: " ) + remoteUser +"\n" ;
2252 int maxlen = 30; 2212 int maxlen = 30;
2253 if ( QApplication::desktop()->width() > 320 ) 2213 if ( QApplication::desktop()->width() > 320 )
2254 maxlen += 25; 2214 maxlen += 25;
2255 if ( remoteFile.length() > maxlen ) 2215 if ( remoteFile.length() > maxlen )
2256 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 2216 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2257 else 2217 else
2258 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 2218 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2259 if ( localFile.length() > maxlen ) 2219 if ( localFile.length() > maxlen )
2260 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 2220 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2261 else 2221 else
2262 question += i18n("Local temp file:\n " ) + localFile +"\n"; 2222 question += i18n("Local temp file:\n " ) + localFile +"\n";
2263 2223
2264 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2224 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2265 question, 2225 question,
2266 i18n("Yes"), i18n("No"), 2226 i18n("Yes"), i18n("No"),
2267 0, 0 ) != 0 ) 2227 0, 0 ) != 0 )
2268 return; 2228 return;
2269 // if ( !p->mUsePassWd ) { 2229 // if ( !p->mUsePassWd ) {
2270 // QString pass = getPassword(); 2230 // QString pass = getPassword();
2271 // if ( pass.length() > 0 ) 2231 // if ( pass.length() > 0 )
2272 // remoteUser += ":" + pass; 2232 // remoteUser += ":" + pass;
2273 // } 2233 // }
2274 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 2234 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2275 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2235 setCaption ( i18n( "Copy remote file to local machine..." ) );
2276 int fileSize = 0; 2236 int fileSize = 0;
2277 int result = system ( command ); 2237 int result = system ( command );
2278 // 0 : okay 2238 // 0 : okay
2279 // 256: no such file or dir 2239 // 256: no such file or dir
2280 // 2240 //
2281 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2241 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2282 if ( result != 0 ) { 2242 if ( result != 0 ) {
2283 int len = maxlen; 2243 int len = maxlen;
2284 while ( len < command.length() ) { 2244 while ( len < command.length() ) {
2285 command.insert( len , "\n" ); 2245 command.insert( len , "\n" );
2286 len += maxlen +2; 2246 len += maxlen +2;
2287 } 2247 }
2288 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) ; 2248 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) ;
2289 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2249 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2290 question, 2250 question,
2291 i18n("Okay!")) ; 2251 i18n("Okay!")) ;
2292 setCaption ("KO/Pi"); 2252 setCaption ("KO/Pi");
2293 return; 2253 return;
2294 } 2254 }
2295 2255
2296 2256
2297 setCaption ( i18n( "Copying succeed." ) ); 2257 setCaption ( i18n( "Copying succeed." ) );
2298 //mView->setSyncDevice("ssh-scp" ); 2258 //mView->setSyncDevice("ssh-scp" );
2299 if ( syncWithFile(localFile , true ) ) { 2259 if ( syncWithFile(localFile , true ) ) {
2300// Event* e = mView->getLastSyncEvent(); 2260// Event* e = mView->getLastSyncEvent();
2301// e->setReadOnly( false ); 2261// e->setReadOnly( false );
2302// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2262// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2303// e->setReadOnly( true ); 2263// e->setReadOnly( true );
2304 if ( KOPrefs::instance()->mWriteBackFile ) { 2264 if ( KOPrefs::instance()->mWriteBackFile ) {
2305 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2265 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2306 setCaption ( i18n( "Writing back file ..." ) ); 2266 setCaption ( i18n( "Writing back file ..." ) );
2307 result = system ( command ); 2267 result = system ( command );
2308 if ( result != 0 ) { 2268 if ( result != 0 ) {
2309 int len = maxlen; 2269 int len = maxlen;
2310 while ( len < command.length() ) { 2270 while ( len < command.length() ) {
2311 command.insert( len , "\n" ); 2271 command.insert( len , "\n" );
2312 len += maxlen +2; 2272 len += maxlen +2;
2313 } 2273 }
2314 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) ; 2274 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) ;
2315 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2275 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2316 question, 2276 question,
2317 i18n("Okay!")) ; 2277 i18n("Okay!")) ;
2318 setCaption ("KO/Pi"); 2278 setCaption ("KO/Pi");
2319 return; 2279 return;
2320 } else { 2280 } else {
2321 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2281 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2322 } 2282 }
2323 } 2283 }
2324 } 2284 }
2325 return; 2285 return;
2326#if 0 2286#if 0
2327 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2287 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2328 while ( timer.elapsed() < 5000 ) 2288 while ( timer.elapsed() < 5000 )
2329 qApp->processEvents(); 2289 qApp->processEvents();
2330 2290
2331 qDebug("MainWindow::merging) "); 2291 qDebug("MainWindow::merging) ");
2332 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2292 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2333 while ( mBlockSaveFlag ) 2293 while ( mBlockSaveFlag )
2334 qApp->processEvents(); 2294 qApp->processEvents();
2335 save(); 2295 save();
2336 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2296 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2337#endif 2297#endif
2338 2298
2339} 2299}
2340 2300
2341 2301
2342void MainWindow::syncSharp() 2302void MainWindow::syncSharp()
2343{ 2303{
2344 if ( mCalendarModifiedFlag ) 2304 if ( mCalendarModifiedFlag )
2345 save(); 2305 save();
2346 mView->syncSharp(); 2306 mView->syncSharp();
2347 slotModifiedChanged( true ); 2307 slotModifiedChanged( true );
2348 2308
2349} 2309}
2350void MainWindow::syncPhone() 2310void MainWindow::syncPhone()
2351{ 2311{
2352 if ( mCalendarModifiedFlag ) 2312 if ( mCalendarModifiedFlag )
2353 save(); 2313 save();
2354 mView->syncPhone(); 2314 mView->syncPhone();
2355 slotModifiedChanged( true ); 2315 slotModifiedChanged( true );
2356 2316
2357} 2317}
2358 2318
2359void MainWindow::printSel( ) 2319void MainWindow::printSel( )
2360{ 2320{
2361 mView->viewManager()->agendaView()->agenda()->printSelection(); 2321 mView->viewManager()->agendaView()->agenda()->printSelection();
2362} 2322}
2363 2323
2364void MainWindow::printCal() 2324void MainWindow::printCal()
2365{ 2325{
2366 mView->print();//mCp->showDialog(); 2326 mView->print();//mCp->showDialog();
2367} 2327}
2368 2328
2369 2329
2370 2330
2371KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 2331KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
2372{ 2332{
2373 mPassWord = pw; 2333 mPassWord = pw;
2374 mSocket = 0; 2334 mSocket = 0;
2375 mSyncActionDialog = 0; 2335 mSyncActionDialog = 0;
2376}; 2336};
2377 2337
2378void KServerSocket::newConnection ( int socket ) 2338void KServerSocket::newConnection ( int socket )
2379{ 2339{
2380 qDebug("KServerSocket:New connection %d ", socket); 2340 // qDebug("KServerSocket:New connection %d ", socket);
2381 if ( mSocket ) { 2341 if ( mSocket ) {
2382 qDebug("KServerSocket::newConnection Socket deleted! "); 2342 qDebug("KServerSocket::newConnection Socket deleted! ");
2383 delete mSocket; 2343 delete mSocket;
2384 mSocket = 0; 2344 mSocket = 0;
2385 } 2345 }
2386 mSocket = new QSocket( this ); 2346 mSocket = new QSocket( this );
2387 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 2347 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2388 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 2348 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2389 mSocket->setSocket( socket ); 2349 mSocket->setSocket( socket );
2390} 2350}
2391 2351
2392void KServerSocket::discardClient() 2352void KServerSocket::discardClient()
2393{ 2353{
2394 qDebug(" KServerSocket::discardClient()"); 2354 //qDebug(" KServerSocket::discardClient()");
2395 if ( mSocket ) { 2355 if ( mSocket ) {
2396 qDebug("delete ");
2397 delete mSocket; 2356 delete mSocket;
2398 mSocket = 0; 2357 mSocket = 0;
2399 } 2358 }
2400 //emit endConnect(); 2359 //emit endConnect();
2401} 2360}
2402void KServerSocket::readClient() 2361void KServerSocket::readClient()
2403{ 2362{
2404 if ( mSocket == 0 ) { 2363 if ( mSocket == 0 ) {
2405 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 2364 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2406 return; 2365 return;
2407 } 2366 }
2408 qDebug("KServerSocket readClient()"); 2367 //qDebug("KServerSocket readClient()");
2409 if ( mSocket->canReadLine() ) { 2368 if ( mSocket->canReadLine() ) {
2410 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); 2369 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
2411 qDebug("KServerSocket socket->canReadLine()");
2412 if ( tokens[0] == "GET" ) { 2370 if ( tokens[0] == "GET" ) {
2413 if ( tokens[1] == mPassWord ) 2371 if ( tokens[1] == mPassWord )
2414 //emit sendFile( mSocket ); 2372 //emit sendFile( mSocket );
2415 send_file(); 2373 send_file();
2416 else { 2374 else {
2417 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); 2375 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
2418 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2376 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2419 } 2377 }
2420 } 2378 }
2421 if ( tokens[0] == "PUT" ) { 2379 if ( tokens[0] == "PUT" ) {
2422 if ( tokens[1] == mPassWord ) 2380 if ( tokens[1] == mPassWord )
2423 //emit getFile( mSocket ); 2381 //emit getFile( mSocket );
2424 get_file(); 2382 get_file();
2425 else { 2383 else {
2426 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 2384 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
2427 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2385 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2428 } 2386 }
2429 } 2387 }
2430 if ( tokens[0] == "STOP" ) { 2388 if ( tokens[0] == "STOP" ) {
2431 //emit endConnect(); 2389 //emit endConnect();
2432 end_connect(); 2390 end_connect();
2433 } 2391 }
2434 } 2392 }
2435} 2393}
2436void KServerSocket::end_connect() 2394void KServerSocket::end_connect()
2437{ 2395{
2438 delete mSyncActionDialog; 2396 delete mSyncActionDialog;
2439 mSyncActionDialog = 0; 2397 mSyncActionDialog = 0;
2440} 2398}
2441void KServerSocket::send_file() 2399void KServerSocket::send_file()
2442{ 2400{
2443 qDebug("MainWindow::sendFile(QSocket* s) "); 2401 //qDebug("MainWindow::sendFile(QSocket* s) ");
2444 if ( mSyncActionDialog ) 2402 if ( mSyncActionDialog )
2445 delete mSyncActionDialog; 2403 delete mSyncActionDialog;
2446 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 2404 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
2447 mSyncActionDialog->setCaption(i18n("Received sync request")); 2405 mSyncActionDialog->setCaption(i18n("Received sync request"));
2448 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog ); 2406 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog );
2449 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 2407 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
2450 lay->addWidget( label); 2408 lay->addWidget( label);
2451 lay->setMargin(7); 2409 lay->setMargin(7);
2452 lay->setSpacing(7); 2410 lay->setSpacing(7);
2453 mSyncActionDialog->setFixedSize( 230, 120); 2411 mSyncActionDialog->setFixedSize( 230, 120);
2454 mSyncActionDialog->show(); 2412 mSyncActionDialog->show();
2455 qDebug("KSS::saving ... "); 2413 qDebug("KSS::saving ... ");
2456 emit saveFile(); 2414 emit saveFile();
2457 qApp->processEvents(); 2415 qApp->processEvents();
2458 QString fileName = mFileName; 2416 QString fileName = mFileName;
2459 QFile file( fileName ); 2417 QFile file( fileName );
2460 if (!file.open( IO_ReadOnly ) ) { 2418 if (!file.open( IO_ReadOnly ) ) {
2461 delete mSyncActionDialog; 2419 delete mSyncActionDialog;
2462 mSyncActionDialog = 0; 2420 mSyncActionDialog = 0;
2463 qDebug("KSS::error open file "); 2421 qDebug("KSS::error open file ");
2464 mSocket->close(); 2422 mSocket->close();
2465 if ( mSocket->state() == QSocket::Idle ) 2423 if ( mSocket->state() == QSocket::Idle )
2466 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2424 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2467 return ; 2425 return ;
2468 2426
2469 } 2427 }
2470 mSyncActionDialog->setCaption( i18n("Sending file...") ); 2428 mSyncActionDialog->setCaption( i18n("Sending file...") );
2471 QTextStream ts( &file ); 2429 QTextStream ts( &file );
2472 ts.setCodec( QTextCodec::codecForName("utf8") ); 2430 ts.setCodec( QTextCodec::codecForName("utf8") );
2473 QTextStream os( mSocket ); 2431 QTextStream os( mSocket );
2474 os.setCodec( QTextCodec::codecForName("utf8") ); 2432 os.setCodec( QTextCodec::codecForName("utf8") );
2475 //os.setEncoding( QTextStream::UnicodeUTF8 ); 2433 //os.setEncoding( QTextStream::UnicodeUTF8 );
2476 while ( ! ts.atEnd() ) { 2434 while ( ! ts.atEnd() ) {
2477 os << ts.readLine() << "\n"; 2435 os << ts.readLine() << "\n";
2478 } 2436 }
2479 //os << ts.read(); 2437 //os << ts.read();
2480 file.close(); 2438 file.close();
2481 mSyncActionDialog->setCaption( i18n("Waiting to get back synced file") ); 2439 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
2482 qDebug("file sent ");
2483 mSocket->close(); 2440 mSocket->close();
2484 if ( mSocket->state() == QSocket::Idle ) 2441 if ( mSocket->state() == QSocket::Idle )
2485 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2442 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2486} 2443}
2487void KServerSocket::get_file() 2444void KServerSocket::get_file()
2488{ 2445{
2489 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 2446 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
2490 2447
2491 piTime.start(); 2448 piTime.start();
2492 piFileString = ""; 2449 piFileString = "";
2493 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 2450 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
2494} 2451}
2495 2452
2496 2453
2497void KServerSocket::readBackFileFromSocket() 2454void KServerSocket::readBackFileFromSocket()
2498{ 2455{
2499 qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 2456 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
2500 while ( mSocket->canReadLine () ) { 2457 while ( mSocket->canReadLine () ) {
2501 piTime.restart(); 2458 piTime.restart();
2502 QString line = mSocket->readLine (); 2459 QString line = mSocket->readLine ();
2503 piFileString += line; 2460 piFileString += line;
2504 qDebug("readline: %s ", line.latin1()); 2461 //qDebug("readline: %s ", line.latin1());
2505 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 2462 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
2506 2463
2507 } 2464 }
2508 if ( piTime.elapsed () < 3000 ) { 2465 if ( piTime.elapsed () < 3000 ) {
2509 // wait for more 2466 // wait for more
2510 qDebug("waitformore "); 2467 //qDebug("waitformore ");
2511 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 2468 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
2512 return; 2469 return;
2513 } 2470 }
2514 QString fileName = mFileName; 2471 QString fileName = mFileName;
2515 QFile file ( fileName ); 2472 QFile file ( fileName );
2516 if (!file.open( IO_WriteOnly ) ) { 2473 if (!file.open( IO_WriteOnly ) ) {
2517 delete mSyncActionDialog; 2474 delete mSyncActionDialog;
2518 mSyncActionDialog = 0; 2475 mSyncActionDialog = 0;
2519 qDebug("error open cal file "); 2476 qDebug("error open cal file ");
2520 piFileString = ""; 2477 piFileString = "";
2521 emit file_received( false ); 2478 emit file_received( false );
2522 return ; 2479 return ;
2523 2480
2524 } 2481 }
2525 2482
2526 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2483 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2527 QTextStream ts ( &file ); 2484 QTextStream ts ( &file );
2528 ts.setCodec( QTextCodec::codecForName("utf8") ); 2485 ts.setCodec( QTextCodec::codecForName("utf8") );
2529 qDebug("finish ");
2530 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 2486 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
2531 ts << piFileString; 2487 ts << piFileString;
2532 mSocket->close(); 2488 mSocket->close();
2533 if ( mSocket->state() == QSocket::Idle ) 2489 if ( mSocket->state() == QSocket::Idle )
2534 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2490 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2535 file.close(); 2491 file.close();
2536 delete mSyncActionDialog; 2492 delete mSyncActionDialog;
2537 mSyncActionDialog = 0; 2493 mSyncActionDialog = 0;
2538 piFileString = ""; 2494 piFileString = "";
2539 emit file_received( true ); 2495 emit file_received( true );
2540 2496
2541} 2497}
2542 2498
2543KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 2499KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
2544{ 2500{
2545 mPassWord = password; 2501 mPassWord = password;
2546 mSocket = 0; 2502 mSocket = 0;
2547 mPort = port; 2503 mPort = port;
2548 mHost = host; 2504 mHost = host;
2549 2505
2550 mRetVal = false; 2506 mRetVal = false;
2551 mTimerSocket = new QTimer ( this ); 2507 mTimerSocket = new QTimer ( this );
2552 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 2508 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
2553} 2509}
2554void KCommandSocket::readFile( QString fn ) 2510void KCommandSocket::readFile( QString fn )
2555{ 2511{
2556 if ( !mSocket ) { 2512 if ( !mSocket ) {
2557 mSocket = new QSocket( this ); 2513 mSocket = new QSocket( this );
2558 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 2514 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
2559 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2515 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2560 } 2516 }
2561 mFileString = ""; 2517 mFileString = "";
2562 mFileName = fn; 2518 mFileName = fn;
2563 mFirst = true; 2519 mFirst = true;
2564 mSocket->connectToHost( mHost, mPort ); 2520 mSocket->connectToHost( mHost, mPort );
2565 QTextStream os( mSocket ); 2521 QTextStream os( mSocket );
2566 os.setEncoding( QTextStream::UnicodeUTF8 ); 2522 os.setEncoding( QTextStream::UnicodeUTF8 );
2567 os << "GET " << mPassWord << "\r\n"; 2523 os << "GET " << mPassWord << "\r\n";
2568 mTimerSocket->start( 10000 ); 2524 mTimerSocket->start( 10000 );
2569} 2525}
2570 2526
2571void KCommandSocket::writeFile( QString fileName ) 2527void KCommandSocket::writeFile( QString fileName )
2572{ 2528{
2573 QFile file2( fileName ); 2529 QFile file2( fileName );
2574 if (!file2.open( IO_ReadOnly ) ) { 2530 if (!file2.open( IO_ReadOnly ) ) {
2575 mRetVal= false; 2531 mRetVal= false;
2576 deleteSocket(); 2532 deleteSocket();
2577 return ; 2533 return ;
2578 2534
2579 } 2535 }
2580 if ( !mSocket ) { 2536 if ( !mSocket ) {
2581 mSocket = new QSocket( this ); 2537 mSocket = new QSocket( this );
2582 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2538 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2583 } 2539 }
2540 mSocket->connectToHost( mHost, mPort );
2584 QTextStream ts2( &file2 ); 2541 QTextStream ts2( &file2 );
2585 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2542 ts2.setCodec( QTextCodec::codecForName("utf8") );
2586 QTextStream os2( mSocket ); 2543 QTextStream os2( mSocket );
2587 os2.setCodec( QTextCodec::codecForName("utf8") ); 2544 os2.setCodec( QTextCodec::codecForName("utf8") );
2588 os2 << "PUT " << mPassWord << "\r\n";; 2545 os2 << "PUT " << mPassWord << "\r\n";;
2589 while ( ! ts2.atEnd() ) { 2546 while ( ! ts2.atEnd() ) {
2590 os2 << ts2.readLine() << "\n"; 2547 os2 << ts2.readLine() << "\n";
2591 } 2548 }
2549 mRetVal= true;
2592 mSocket->close(); 2550 mSocket->close();
2593 if ( mSocket->state() == QSocket::Idle ) 2551 if ( mSocket->state() == QSocket::Idle )
2594 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2552 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2595 file2.close(); 2553 file2.close();
2596} 2554}
2597 2555
2598void KCommandSocket::sendStop() 2556void KCommandSocket::sendStop()
2599{ 2557{
2600 if ( !mSocket ) { 2558 if ( !mSocket ) {
2601 mSocket = new QSocket( this ); 2559 mSocket = new QSocket( this );
2602 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2560 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2603 } 2561 }
2562 mSocket->connectToHost( mHost, mPort );
2604 QTextStream os2( mSocket ); 2563 QTextStream os2( mSocket );
2605 os2.setCodec( QTextCodec::codecForName("utf8") ); 2564 os2.setCodec( QTextCodec::codecForName("utf8") );
2606 os2 << "STOP\r\n"; 2565 os2 << "STOP\r\n";
2607 mRetVal= true; 2566 mRetVal= true;
2608 mSocket->close(); 2567 mSocket->close();
2609 if ( mSocket->state() == QSocket::Idle ) 2568 if ( mSocket->state() == QSocket::Idle )
2610 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2569 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2611} 2570}
2612 2571
2613void KCommandSocket::startReadFileFromSocket() 2572void KCommandSocket::startReadFileFromSocket()
2614{ 2573{
2615 if ( ! mFirst ) 2574 if ( ! mFirst )
2616 return; 2575 return;
2617 mFirst = false; 2576 mFirst = false;
2618 mTimerSocket->stop(); 2577 mTimerSocket->stop();
2619 mFileString = ""; 2578 mFileString = "";
2620 mTime.start(); 2579 mTime.start();
2621 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 2580 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
2622 2581
2623} 2582}
2624void KCommandSocket::readFileFromSocket() 2583void KCommandSocket::readFileFromSocket()
2625{ 2584{
2626 qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 2585 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
2627 while ( mSocket->canReadLine () ) { 2586 while ( mSocket->canReadLine () ) {
2628 mTime.restart(); 2587 mTime.restart();
2629 QString line = mSocket->readLine (); 2588 QString line = mSocket->readLine ();
2630 mFileString += line; 2589 mFileString += line;
2631 qDebug("readline: %s ", line.latin1()); 2590 //qDebug("readline: %s ", line.latin1());
2632 } 2591 }
2633 if ( mTime.elapsed () < 3000 ) { 2592 if ( mTime.elapsed () < 3000 ) {
2634 // wait for more 2593 // wait for more
2635 qDebug("waitformore "); 2594 //qDebug("waitformore ");
2636 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 2595 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
2637 return; 2596 return;
2638 } 2597 }
2639 QString fileName = mFileName; 2598 QString fileName = mFileName;
2640 QFile file ( fileName ); 2599 QFile file ( fileName );
2641 if (!file.open( IO_WriteOnly ) ) { 2600 if (!file.open( IO_WriteOnly ) ) {
2642 mFileString = ""; 2601 mFileString = "";
2643 mRetVal = false; 2602 mRetVal = false;
2644 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 2603 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2645 deleteSocket(); 2604 deleteSocket();
2646 return ; 2605 return ;
2647 2606
2648 } 2607 }
2649 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2608 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2650 QTextStream ts ( &file ); 2609 QTextStream ts ( &file );
2651 ts.setCodec( QTextCodec::codecForName("utf8") ); 2610 ts.setCodec( QTextCodec::codecForName("utf8") );
2652 qDebug("finish ");
2653 ts << mFileString; 2611 ts << mFileString;
2654 file.close(); 2612 file.close();
2655 mFileString = ""; 2613 mFileString = "";
2656 mRetVal = true; 2614 mRetVal = true;
2657 mSocket->close(); 2615 mSocket->close();
2658 // if state is not idle, deleteSocket(); is called via 2616 // if state is not idle, deleteSocket(); is called via
2659 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2617 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2660 if ( mSocket->state() == QSocket::Idle ) 2618 if ( mSocket->state() == QSocket::Idle )
2661 deleteSocket(); 2619 deleteSocket();
2662} 2620}
2663 2621
2664void KCommandSocket::deleteSocket() 2622void KCommandSocket::deleteSocket()
2665{ 2623{
2666 if ( mTimerSocket->isActive () ) { 2624 if ( mTimerSocket->isActive () ) {
2667 mTimerSocket->stop(); 2625 mTimerSocket->stop();
2668 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 2626 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
2669 mRetVal = false; 2627 mRetVal = false;
2670 } 2628 }
2671 qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 2629 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
2672 if ( mSocket) 2630 if ( mSocket)
2673 delete mSocket; 2631 delete mSocket;
2674 mSocket = 0; 2632 mSocket = 0;
2675 emit commandFinished( this, mRetVal ); 2633 emit commandFinished( this, mRetVal );
2676} 2634}
2677 2635
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 5a67765..f8b2334 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,209 +1,209 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qsocket.h> 8#include <qsocket.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include "simplealarmclient.h" 13#include "simplealarmclient.h"
14 14
15class QAction; 15class QAction;
16class CalendarView; 16class CalendarView;
17class KSyncProfile; 17class KSyncProfile;
18#ifdef DESKTOP_VERSION 18#ifdef DESKTOP_VERSION
19 19
20#define QPEToolBar QToolBar 20#define QPEToolBar QToolBar
21#define QPEMenuBar QMenuBar 21#define QPEMenuBar QMenuBar
22#endif 22#endif
23class QPEToolBar; 23class QPEToolBar;
24#include <qserversocket.h> 24#include <qserversocket.h>
25#include <qsocket.h> 25#include <qsocket.h>
26#include <qnetworkprotocol.h> 26#include <qnetworkprotocol.h>
27 27
28class KServerSocket : public QServerSocket 28class KServerSocket : public QServerSocket
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31 31
32public: 32public:
33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 33 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
34 34
35 void newConnection ( int socket ) ; 35 void newConnection ( int socket ) ;
36 void setFileName( QString fn ) {mFileName = fn;}; 36 void setFileName( QString fn ) {mFileName = fn;};
37 37
38signals: 38signals:
39 //void sendFile(QSocket*); 39 //void sendFile(QSocket*);
40 //void getFile(QSocket*); 40 //void getFile(QSocket*);
41 void file_received( bool ); 41 void file_received( bool );
42 //void file_sent(); 42 //void file_sent();
43 void saveFile(); 43 void saveFile();
44 void endConnect(); 44 void endConnect();
45private slots: 45private slots:
46 void discardClient(); 46 void discardClient();
47 void readClient(); 47 void readClient();
48 void readBackFileFromSocket(); 48 void readBackFileFromSocket();
49 private : 49 private :
50 void send_file(); 50 void send_file();
51 void get_file(); 51 void get_file();
52 void end_connect(); 52 void end_connect();
53 QDialog* mSyncActionDialog; 53 QDialog* mSyncActionDialog;
54 QSocket* mSocket; 54 QSocket* mSocket;
55 QString mPassWord; 55 QString mPassWord;
56 QString mFileName; 56 QString mFileName;
57 QTime piTime; 57 QTime piTime;
58 QString piFileString; 58 QString piFileString;
59}; 59};
60 60
61class KCommandSocket : public QObject 61class KCommandSocket : public QObject
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 64
65public: 65public:
66 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 66 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
67 void readFile( QString ); 67 void readFile( QString );
68 void writeFile( QString ); 68 void writeFile( QString );
69 void sendStop(); 69 void sendStop();
70 70
71 71
72signals: 72signals:
73 void commandFinished( KCommandSocket*, bool ); 73 void commandFinished( KCommandSocket*, bool );
74private slots: 74private slots:
75 void startReadFileFromSocket(); 75 void startReadFileFromSocket();
76 void readFileFromSocket(); 76 void readFileFromSocket();
77 void deleteSocket(); 77 void deleteSocket();
78 private : 78 private :
79 QSocket* mSocket; 79 QSocket* mSocket;
80 QString mPassWord; 80 QString mPassWord;
81 Q_UINT16 mPort; 81 Q_UINT16 mPort;
82 QString mHost; 82 QString mHost;
83 QString mFileName; 83 QString mFileName;
84 QTimer* mTimerSocket; 84 QTimer* mTimerSocket;
85 bool mRetVal; 85 bool mRetVal;
86 QTime mTime; 86 QTime mTime;
87 QString mFileString; 87 QString mFileString;
88 bool mFirst; 88 bool mFirst;
89}; 89};
90 90
91namespace KCal { 91namespace KCal {
92class CalendarLocal; 92class CalendarLocal;
93} 93}
94 94
95using namespace KCal; 95using namespace KCal;
96 96
97class MainWindow : public QMainWindow 97class MainWindow : public QMainWindow
98{ 98{
99 Q_OBJECT 99 Q_OBJECT
100 public: 100 public:
101 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 101 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
102 ~MainWindow(); 102 ~MainWindow();
103 public slots: 103 public slots:
104 virtual void showMaximized (); 104 virtual void showMaximized ();
105 void configureAgenda( int ); 105 void configureAgenda( int );
106 void recieve( const QCString& msg, const QByteArray& data ); 106 void recieve( const QCString& msg, const QByteArray& data );
107 static QString defaultFileName(); 107 static QString defaultFileName();
108 static QString resourcePath(); 108 static QString resourcePath();
109 protected slots: 109 protected slots:
110 void setCaptionToDates(); 110 void setCaptionToDates();
111 int ringSync(); 111 int ringSync();
112 void multiSync( bool askforPrefs = false ); 112 void multiSync( bool askforPrefs = false );
113 void about(); 113 void about();
114 void licence(); 114 void licence();
115 void faq(); 115 void faq();
116 void usertrans(); 116 void usertrans();
117 void features(); 117 void features();
118 void synchowto(); 118 void synchowto();
119 void whatsNew(); 119 void whatsNew();
120 void keyBindings(); 120 void keyBindings();
121 void aboutAutoSaving();; 121 void aboutAutoSaving();;
122 void aboutKnownBugs(); 122 void aboutKnownBugs();
123 123
124 void processIncidenceSelection( Incidence * ); 124 void processIncidenceSelection( Incidence * );
125 125
126 void importQtopia(); 126 void importQtopia();
127 void importBday(); 127 void importBday();
128 void importOL(); 128 void importOL();
129 void importIcal(); 129 void importIcal();
130 void importFile( QString, bool ); 130 void importFile( QString, bool );
131 void quickImportIcal(); 131 void quickImportIcal();
132 132
133 void slotModifiedChanged( bool ); 133 void slotModifiedChanged( bool );
134 134
135 void save(); 135 void save();
136 void configureToolBar( int ); 136 void configureToolBar( int );
137 void printSel(); 137 void printSel();
138 void printCal(); 138 void printCal();
139 void saveCalendar(); 139 void saveCalendar();
140 void loadCalendar(); 140 void loadCalendar();
141 void exportVCalendar(); 141 void exportVCalendar();
142 void fillFilterMenu(); 142 void fillFilterMenu();
143 void selectFilter( int ); 143 void selectFilter( int );
144 144
145 void slotSyncMenu( int ); 145 void slotSyncMenu( int );
146 void syncSSH(); 146 void syncSSH();
147 void confSync(); 147 void confSync();
148 void syncSharp(); 148 void syncSharp();
149 void syncPhone(); 149 void syncPhone();
150 void syncPi();
150 void syncLocalFile(); 151 void syncLocalFile();
151 bool syncWithFile( QString, bool ); 152 bool syncWithFile( QString, bool );
152 void quickSyncLocalFile(); 153 void quickSyncLocalFile();
153 154
154 155
155 protected: 156 protected:
156 void displayText( QString, QString); 157 void displayText( QString, QString);
157 void displayFile( QString, QString); 158 void displayFile( QString, QString);
158 159
159 void enableIncidenceActions( bool ); 160 void enableIncidenceActions( bool );
160 161
161 private slots: 162 private slots:
162 QSocket* piSocket; 163 QSocket* piSocket;
163 QString piFileString; 164 QString piFileString;
164 QTime piTime; 165 QTime piTime;
165 void deleteCommandSocket(KCommandSocket* s, bool success); 166 void deleteCommandSocket(KCommandSocket* s, bool success);
166 void deleteCommandSocketFinish(KCommandSocket* s, bool success); 167 void deleteCommandSocketFinish(KCommandSocket* s, bool success);
167 void fillSyncMenu(); 168 void fillSyncMenu();
168 void getFile( bool ); 169 void getFile( bool );
169 void readFileFromSocket(); 170 void readFileFromSocket();
170 private: 171 private:
171 //QTimer* mTimerCommandSocket; 172 //QTimer* mTimerCommandSocket;
172 QString mPassWordPiSync; 173 QString mPassWordPiSync;
173 KServerSocket * mServerSocket; 174 KServerSocket * mServerSocket;
174 bool mClosed; 175 bool mClosed;
175 void saveOnClose(); 176 void saveOnClose();
176 int mCurrentSyncProfile; 177 int mCurrentSyncProfile;
177 void enableQuick(); 178 void enableQuick();
178 void performQuick();
179 void performQuickQuick(); 179 void performQuickQuick();
180 void syncRemote( KSyncProfile* , bool ask = true); 180 void syncRemote( KSyncProfile* , bool ask = true);
181 bool mFlagKeyPressed; 181 bool mFlagKeyPressed;
182 bool mBlockAtStartup; 182 bool mBlockAtStartup;
183 QPEToolBar *iconToolBar; 183 QPEToolBar *iconToolBar;
184 void initActions(); 184 void initActions();
185 void setDefaultPreferences(); 185 void setDefaultPreferences();
186 void keyPressEvent ( QKeyEvent * ) ; 186 void keyPressEvent ( QKeyEvent * ) ;
187 void keyReleaseEvent ( QKeyEvent * ) ; 187 void keyReleaseEvent ( QKeyEvent * ) ;
188 QPopupMenu *configureToolBarMenu; 188 QPopupMenu *configureToolBarMenu;
189 QPopupMenu *selectFilterMenu; 189 QPopupMenu *selectFilterMenu;
190 QPopupMenu *configureAgendaMenu, *syncMenu; 190 QPopupMenu *configureAgendaMenu, *syncMenu;
191 CalendarLocal *mCalendar; 191 CalendarLocal *mCalendar;
192 CalendarView *mView; 192 CalendarView *mView;
193 QString getPassword(); 193 QString getPassword();
194 QAction *mNewSubTodoAction; 194 QAction *mNewSubTodoAction;
195 195
196 QAction *mShowAction; 196 QAction *mShowAction;
197 QAction *mEditAction; 197 QAction *mEditAction;
198 QAction *mDeleteAction; 198 QAction *mDeleteAction;
199 void closeEvent( QCloseEvent* ce ); 199 void closeEvent( QCloseEvent* ce );
200 SimpleAlarmClient mAlarmClient; 200 SimpleAlarmClient mAlarmClient;
201 QTimer mSaveTimer; 201 QTimer mSaveTimer;
202 bool mBlockSaveFlag; 202 bool mBlockSaveFlag;
203 bool mCalendarModifiedFlag; 203 bool mCalendarModifiedFlag;
204 QPixmap loadPixmap( QString ); 204 QPixmap loadPixmap( QString );
205 QDialog * mSyncActionDialog; 205 QDialog * mSyncActionDialog;
206}; 206};
207 207
208 208
209#endif 209#endif
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index f05c846..0caa27e 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,730 +1,732 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46 46
47#include <kcolorbutton.h> 47#include <kcolorbutton.h>
48#include <kdebug.h> 48#include <kdebug.h>
49#include <klocale.h> 49#include <klocale.h>
50#include <kglobal.h> 50#include <kglobal.h>
51#include <kfontdialog.h> 51#include <kfontdialog.h>
52#include <kmessagebox.h> 52#include <kmessagebox.h>
53#include <kcolordialog.h> 53#include <kcolordialog.h>
54#include <kiconloader.h> 54#include <kiconloader.h>
55#include <kemailsettings.h> 55#include <kemailsettings.h>
56#include <kstandarddirs.h> 56#include <kstandarddirs.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58#include <kmessagebox.h> 58#include <kmessagebox.h>
59 59
60//#include <kurlrequester.h> 60//#include <kurlrequester.h>
61#include <klineedit.h> 61#include <klineedit.h>
62#include "ksyncprofile.h" 62#include "ksyncprofile.h"
63 63
64 64
65//#include "koprefs.h" 65//#include "koprefs.h"
66 66
67#include "ksyncprefsdialog.h" 67#include "ksyncprefsdialog.h"
68//#include "koglobals.h" 68//#include "koglobals.h"
69 69
70 70
71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
72 KDialog(parent,name,true) 72 KDialog(parent,name,true)
73{ 73{
74 74
75 setCaption( i18n("Synchronization Preferences")); 75 setCaption( i18n("Synchronization Preferences"));
76 76
77 mSyncProfiles.setAutoDelete( true ); 77 mSyncProfiles.setAutoDelete( true );
78 setupSyncAlgTab(); 78 setupSyncAlgTab();
79} 79}
80 80
81 81
82KSyncPrefsDialog::~KSyncPrefsDialog() 82KSyncPrefsDialog::~KSyncPrefsDialog()
83{ 83{
84} 84}
85 85
86void KSyncPrefsDialog::setupSyncAlgTab() 86void KSyncPrefsDialog::setupSyncAlgTab()
87{ 87{
88 QLabel * lab; 88 QLabel * lab;
89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
90 QVBox * mainbox = new QVBox( this ); 90 QVBox * mainbox = new QVBox( this );
91 QScrollView* sv = new QScrollView( mainbox ); 91 QScrollView* sv = new QScrollView( mainbox );
92 QHBoxLayout * lay = new QHBoxLayout( this ); 92 QHBoxLayout * lay = new QHBoxLayout( this );
93 lay->addWidget( mainbox ); 93 lay->addWidget( mainbox );
94 QHBox * b_box = new QHBox( mainbox ); 94 QHBox * b_box = new QHBox( mainbox );
95 95
96 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 96 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
98 button = new QPushButton( i18n("Cancel"), b_box ); 98 button = new QPushButton( i18n("Cancel"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
100 //QBoxLayout * sl = new QVBoxLayout(this ); 100 //QBoxLayout * sl = new QVBoxLayout(this );
101 //sl->addWidget ( sv ); 101 //sl->addWidget ( sv );
102 sv->setResizePolicy ( QScrollView::AutoOneFit ); 102 sv->setResizePolicy ( QScrollView::AutoOneFit );
103 QFrame *topFrame = new QFrame ( sv ); 103 QFrame *topFrame = new QFrame ( sv );
104 sv->addChild( topFrame ); 104 sv->addChild( topFrame );
105 mSetupSyncAlgTab = topFrame; 105 mSetupSyncAlgTab = topFrame;
106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
107 topLayout->setSpacing(spacingHint()); 107 topLayout->setSpacing(spacingHint());
108 topLayout->setMargin(marginHint()); 108 topLayout->setMargin(marginHint());
109 109
110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
111 int iii = 0; 111 int iii = 0;
112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
113 //++iii; 113 //++iii;
114 114
115 mMyMachineName = new QLineEdit(topFrame); 115 mMyMachineName = new QLineEdit(topFrame);
116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
117 topLayout->addWidget(lab ,iii,0); 117 topLayout->addWidget(lab ,iii,0);
118 topLayout->addWidget(mMyMachineName,iii,1); 118 topLayout->addWidget(mMyMachineName,iii,1);
119 ++iii; 119 ++iii;
120 120
121 QHBox* buttonbox = new QHBox( topFrame); 121 QHBox* buttonbox = new QHBox( topFrame);
122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
123 ++iii; 123 ++iii;
124 button = new QPushButton( i18n("New profile"), buttonbox ); 124 button = new QPushButton( i18n("New profile"), buttonbox );
125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
126 126
127 button = new QPushButton( i18n("Clone profile"), buttonbox ); 127 button = new QPushButton( i18n("Clone profile"), buttonbox );
128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
129 129
130 button = new QPushButton( i18n("Delete profile"), buttonbox ); 130 button = new QPushButton( i18n("Delete profile"), buttonbox );
131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
132 132
133 mProfileBox = new QComboBox(topFrame); 133 mProfileBox = new QComboBox(topFrame);
134 mProfileBox->setEditable ( true ); 134 mProfileBox->setEditable ( true );
135 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); 135 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion);
136 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 136 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
137 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 137 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
138 138
139 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 139 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
140 topLayout->addWidget(lab ,iii,0); 140 topLayout->addWidget(lab ,iii,0);
141 topLayout->addWidget(mProfileBox, iii,1); 141 topLayout->addWidget(mProfileBox, iii,1);
142 ++iii; 142 ++iii;
143 143
144 mIncludeInRing = new QCheckBox( i18n("Include in multiple calendar sync"), topFrame ); 144 mIncludeInRing = new QCheckBox( i18n("Include in multiple calendar sync"), topFrame );
145 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); 145 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
146 ++iii; 146 ++iii;
147 mIncludeInRingAB = new QCheckBox( i18n("Include in multiple addressbook sync"), topFrame ); 147 mIncludeInRingAB = new QCheckBox( i18n("Include in multiple addressbook sync"), topFrame );
148 topLayout->addMultiCellWidget(mIncludeInRingAB, iii,iii,0,1); 148 topLayout->addMultiCellWidget(mIncludeInRingAB, iii,iii,0,1);
149 ++iii; 149 ++iii;
150 mIncludeInRingPWM = new QCheckBox( i18n("Include in multiple pwmanager sync"), topFrame ); 150 mIncludeInRingPWM = new QCheckBox( i18n("Include in multiple pwmanager sync"), topFrame );
151 topLayout->addMultiCellWidget(mIncludeInRingPWM, iii,iii,0,1); 151 topLayout->addMultiCellWidget(mIncludeInRingPWM, iii,iii,0,1);
152 ++iii; 152 ++iii;
153 153
154 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 154 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
155 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 155 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
156 ++iii; 156 ++iii;
157 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 157 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
158 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 158 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
159 ++iii; 159 ++iii;
160 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 160 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
161 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 161 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
162 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 162 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
163 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 163 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
164 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 164 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
165 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 165 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
166 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 166 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
167 167
168 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 168 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
169 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 169 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
170 ++iii; 170 ++iii;
171 171
172 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); 172 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
173 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 173 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
174 ++iii; 174 ++iii;
175 175
176 mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame ); 176 mWriteBackExisting= new QCheckBox( i18n("-- Write back (on remote) existing entries only"), topFrame );
177 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 177 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
178 ++iii; 178 ++iii;
179 179
180 mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame ); 180 mWriteBackFuture= new QCheckBox( i18n("-- Write back (calendar) entries in future only"), topFrame );
181 topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); 181 topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1);
182 ++iii; 182 ++iii;
183 topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0); 183 topLayout->addMultiCellWidget(new QLabel( i18n("---- Max. weeks in future: ") , topFrame ), iii,iii,0,0);
184 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame); 184 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, topFrame);
185 topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); 185 topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1);
186 ++iii; 186 ++iii;
187 187
188 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 188 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
189 gr = proGr; 189 gr = proGr;
190 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 190 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
191 ++iii; 191 ++iii;
192 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 192 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
193 mIsPi = new QRadioButton ( i18n("Quick Pi-Sync"), gr ); 193 mIsPi = new QRadioButton ( i18n("Pi-Sync ( direct Kx/Pi to Kx/Pi sync )"), gr );
194 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 194 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
195 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 195 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
196 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 196 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
197 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); 197 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
198 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 198 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
199 199
200 200
201 phoneWidget = new QVBox( topFrame); 201 phoneWidget = new QVBox( topFrame);
202 topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); 202 topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
203 ++iii; 203 ++iii;
204 mWriteContactToSIM= new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); 204 mWriteContactToSIM= new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
205 QHBox* temphb = new QHBox( phoneWidget ); 205 QHBox* temphb = new QHBox( phoneWidget );
206 new QLabel( i18n("I/O device: "), temphb ); 206 new QLabel( i18n("I/O device: "), temphb );
207 mPhoneDevice = new QLineEdit( temphb); 207 mPhoneDevice = new QLineEdit( temphb);
208 button = new QPushButton( i18n("Help..."), temphb ); 208 button = new QPushButton( i18n("Help..."), temphb );
209 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); 209 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
210 210
211 211
212 temphb = new QHBox( phoneWidget ); 212 temphb = new QHBox( phoneWidget );
213 new QLabel( i18n("Connection: "), temphb ); 213 new QLabel( i18n("Connection: "), temphb );
214 mPhoneConnection = new QLineEdit( temphb); 214 mPhoneConnection = new QLineEdit( temphb);
215 button = new QPushButton( i18n("Help..."), temphb ); 215 button = new QPushButton( i18n("Help..."), temphb );
216 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); 216 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
217 217
218 218
219 temphb = new QHBox( phoneWidget ); 219 temphb = new QHBox( phoneWidget );
220 new QLabel( i18n("Model(opt.): "), temphb ); 220 new QLabel( i18n("Model(opt.): "), temphb );
221 mPhoneModel = new QLineEdit( temphb); 221 mPhoneModel = new QLineEdit( temphb);
222 button = new QPushButton( i18n("Help..."), temphb ); 222 button = new QPushButton( i18n("Help..."), temphb );
223 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); 223 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
224 224
225 // *** local 225 // *** local
226 localFileWidget = new QVBox( topFrame); 226 localFileWidget = new QVBox( topFrame);
227 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 227 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
228 ++iii; 228 ++iii;
229 temphb = new QHBox( localFileWidget ); 229 temphb = new QHBox( localFileWidget );
230 230
231 lab = new QLabel( i18n("Local file Cal:"), temphb ); 231 lab = new QLabel( i18n("Local file Cal:"), temphb );
232 lab = new QLabel( i18n("Local file ABook:"), temphb ); 232 lab = new QLabel( i18n("Local file ABook:"), temphb );
233 lab = new QLabel( i18n("Local file PWMgr:"), temphb ); 233 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
234 temphb = new QHBox( localFileWidget ); 234 temphb = new QHBox( localFileWidget );
235 button = new QPushButton( i18n("Choose..."), temphb ); 235 button = new QPushButton( i18n("Choose..."), temphb );
236 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 236 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
237 button = new QPushButton( i18n("Choose..."), temphb ); 237 button = new QPushButton( i18n("Choose..."), temphb );
238 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); 238 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
239 button = new QPushButton( i18n("Choose..."), temphb ); 239 button = new QPushButton( i18n("Choose..."), temphb );
240 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); 240 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
241 temphb = new QHBox( localFileWidget ); 241 temphb = new QHBox( localFileWidget );
242 242
243 mRemoteFile = new QLineEdit( temphb); 243 mRemoteFile = new QLineEdit( temphb);
244 mRemoteFileAB = new QLineEdit( temphb); 244 mRemoteFileAB = new QLineEdit( temphb);
245 mRemoteFilePWM = new QLineEdit( temphb); 245 mRemoteFilePWM = new QLineEdit( temphb);
246 246
247 // *** remote 247 // *** remote
248 remoteFileWidget = new QVBox( topFrame); 248 remoteFileWidget = new QVBox( topFrame);
249 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 249 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
250 ++iii; 250 ++iii;
251 temphb = new QHBox( remoteFileWidget ); 251 temphb = new QHBox( remoteFileWidget );
252 new QLabel( i18n("Calendar:"), temphb); 252 new QLabel( i18n("Calendar:"), temphb);
253 new QLabel( i18n("AddressBook:"), temphb); 253 new QLabel( i18n("AddressBook:"), temphb);
254 new QLabel( i18n("PWManager:"), temphb); 254 new QLabel( i18n("PWManager:"), temphb);
255 255
256 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 256 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
257 temphb = new QHBox( remoteFileWidget ); 257 temphb = new QHBox( remoteFileWidget );
258 mRemotePrecommand = new QLineEdit(temphb); 258 mRemotePrecommand = new QLineEdit(temphb);
259 mRemotePrecommandAB = new QLineEdit(temphb); 259 mRemotePrecommandAB = new QLineEdit(temphb);
260 mRemotePrecommandPWM = new QLineEdit(temphb); 260 mRemotePrecommandPWM = new QLineEdit(temphb);
261 261
262 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 262 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
263 temphb = new QHBox( remoteFileWidget ); 263 temphb = new QHBox( remoteFileWidget );
264 mLocalTempFile = new QLineEdit(temphb); 264 mLocalTempFile = new QLineEdit(temphb);
265 mLocalTempFileAB = new QLineEdit(temphb); 265 mLocalTempFileAB = new QLineEdit(temphb);
266 mLocalTempFilePWM = new QLineEdit(temphb); 266 mLocalTempFilePWM = new QLineEdit(temphb);
267 267
268 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 268 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
269 temphb = new QHBox( remoteFileWidget ); 269 temphb = new QHBox( remoteFileWidget );
270 mRemotePostcommand = new QLineEdit(temphb ); 270 mRemotePostcommand = new QLineEdit(temphb );
271 mRemotePostcommandAB = new QLineEdit(temphb ); 271 mRemotePostcommandAB = new QLineEdit(temphb );
272 mRemotePostcommandPWM = new QLineEdit(temphb ); 272 mRemotePostcommandPWM = new QLineEdit(temphb );
273 273
274 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 274 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
275 temphb = new QHBox( remoteFileWidget ); 275 temphb = new QHBox( remoteFileWidget );
276 button = new QPushButton( i18n("ssh/scp"), temphb ); 276 button = new QPushButton( i18n("ssh/scp"), temphb );
277 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 277 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
278 button = new QPushButton( i18n("ftp"), temphb ); 278 button = new QPushButton( i18n("ftp"), temphb );
279 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 279 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
280 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 280 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
281 281
282 // *** pi-sync 282 // *** pi-sync
283 piWidget = new QVBox( topFrame); 283 piWidget = new QVBox( topFrame);
284 topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); 284 topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
285 ++iii; 285 ++iii;
286 temphb = new QHBox( piWidget ); 286 temphb = new QHBox( piWidget );
287 new QLabel( i18n("Calendar:"), temphb); 287 new QLabel( i18n("Calendar:"), temphb);
288 new QLabel( i18n("AddressBook:"), temphb); 288 new QLabel( i18n("AddressBook:"), temphb);
289 new QLabel( i18n("PWManager:"), temphb); 289 new QLabel( i18n("PWManager:"), temphb);
290 290
291 lab = new QLabel( i18n("Password for remote access:"), piWidget); 291 lab = new QLabel( i18n("Password for remote access:"), piWidget);
292 temphb = new QHBox( piWidget ); 292 temphb = new QHBox( piWidget );
293 mRemotePw = new QLineEdit(temphb); 293 mRemotePw = new QLineEdit(temphb);
294 mRemotePwAB = new QLineEdit(temphb); 294 mRemotePwAB = new QLineEdit(temphb);
295 mRemotePwPWM = new QLineEdit(temphb); 295 mRemotePwPWM = new QLineEdit(temphb);
296 296
297 lab = new QLabel( i18n("Remote IP address:"), piWidget); 297 lab = new QLabel( i18n("Remote IP address:"), piWidget);
298 temphb = new QHBox( piWidget ); 298 temphb = new QHBox( piWidget );
299 mRemoteIP = new QLineEdit(temphb); 299 mRemoteIP = new QLineEdit(temphb);
300 mRemoteIPAB = new QLineEdit(temphb); 300 mRemoteIPAB = new QLineEdit(temphb);
301 mRemoteIPPWM = new QLineEdit(temphb); 301 mRemoteIPPWM = new QLineEdit(temphb);
302 302
303 lab = new QLabel( i18n("Remote port number:"), piWidget); 303 lab = new QLabel( i18n("Remote port number:"), piWidget);
304 temphb = new QHBox( piWidget ); 304 temphb = new QHBox( piWidget );
305 mRemotePort = new QLineEdit(temphb); 305 mRemotePort = new QLineEdit(temphb);
306 mRemotePortAB = new QLineEdit(temphb); 306 mRemotePortAB = new QLineEdit(temphb);
307 mRemotePortPWM = new QLineEdit(temphb); 307 mRemotePortPWM = new QLineEdit(temphb);
308 308
309} 309}
310 310
311 311
312 312
313 313
314 314
315void KSyncPrefsDialog::slotOK() 315void KSyncPrefsDialog::slotOK()
316{ 316{
317 if ( mMyMachineName->text() == "undefined" ) { 317 if ( mMyMachineName->text() == "undefined" ) {
318 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 318 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
319 return; 319 return;
320 } 320 }
321 int i; 321 int i;
322 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 322 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
323 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 323 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
324 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 324 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
325 return; 325 return;
326 } 326 }
327 } 327 }
328 usrWriteConfig(); 328 usrWriteConfig();
329 QDialog::accept(); 329 QDialog::accept();
330} 330}
331void KSyncPrefsDialog::accept() 331void KSyncPrefsDialog::accept()
332{ 332{
333 slotOK(); 333 slotOK();
334} 334}
335void KSyncPrefsDialog::chooseFile() 335void KSyncPrefsDialog::chooseFile()
336{ 336{
337 QString fn = QDir::homeDirPath(); 337 QString fn = QDir::homeDirPath();
338 338
339 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 339 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
340 if ( fn == "" ) 340 if ( fn == "" )
341 return; 341 return;
342 mRemoteFile->setText( fn ); 342 mRemoteFile->setText( fn );
343} 343}
344 344
345void KSyncPrefsDialog::chooseFileAB() 345void KSyncPrefsDialog::chooseFileAB()
346{ 346{
347 QString fn = QDir::homeDirPath(); 347 QString fn = QDir::homeDirPath();
348 348
349 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 349 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
350 if ( fn == "" ) 350 if ( fn == "" )
351 return; 351 return;
352 mRemoteFileAB->setText( fn ); 352 mRemoteFileAB->setText( fn );
353} 353}
354 354
355void KSyncPrefsDialog::chooseFilePWM() 355void KSyncPrefsDialog::chooseFilePWM()
356{ 356{
357 QString fn = QDir::homeDirPath(); 357 QString fn = QDir::homeDirPath();
358 358
359 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 359 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
360 if ( fn == "" ) 360 if ( fn == "" )
361 return; 361 return;
362 mRemoteFilePWM->setText( fn ); 362 mRemoteFilePWM->setText( fn );
363} 363}
364 364
365void KSyncPrefsDialog::textChanged( const QString & s ) 365void KSyncPrefsDialog::textChanged( const QString & s )
366{ 366{
367 if ( mProfileBox->count() == 0 ) 367 if ( mProfileBox->count() == 0 )
368 return; 368 return;
369 if ( currentSelection < 3 ) { 369 if ( currentSelection < 3 ) {
370 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 370 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
371 mProfileBox->blockSignals( true ); 371 mProfileBox->blockSignals( true );
372 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 372 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
373 mProfileBox->blockSignals( false ); 373 mProfileBox->blockSignals( false );
374 return; 374 return;
375 } 375 }
376 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 376 //qDebug("cur i %d ",mProfileBox-> currentItem () );
377 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 377 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
378 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 378 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
379 prof->setName( s ); 379 prof->setName( s );
380 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 380 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
381} 381}
382void KSyncPrefsDialog::profileChanged( int item ) 382void KSyncPrefsDialog::profileChanged( int item )
383{ 383{
384 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 384 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
385 KSyncProfile* prof; 385 KSyncProfile* prof;
386 saveProfile(); 386 saveProfile();
387 currentSelection = item; 387 currentSelection = item;
388 prof = mSyncProfiles.at(item) ; 388 prof = mSyncProfiles.at(item) ;
389 389
390 mRemotePw->setText(prof->getRemotePw()); 390 mRemotePw->setText(prof->getRemotePw());
391 mRemoteIP->setText(prof->getRemoteIP()); 391 mRemoteIP->setText(prof->getRemoteIP());
392 mRemotePort->setText(prof->getRemotePort()); 392 mRemotePort->setText(prof->getRemotePort());
393 393
394 mRemotePwAB->setText(prof->getRemotePwAB()); 394 mRemotePwAB->setText(prof->getRemotePwAB());
395 mRemoteIPAB->setText(prof->getRemoteIPAB()); 395 mRemoteIPAB->setText(prof->getRemoteIPAB());
396 mRemotePortAB->setText(prof->getRemotePortAB()); 396 mRemotePortAB->setText(prof->getRemotePortAB());
397 397
398 mRemotePwPWM->setText(prof->getRemotePwPWM()); 398 mRemotePwPWM->setText(prof->getRemotePwPWM());
399 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 399 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
400 mRemotePortPWM->setText(prof->getRemotePortPWM()); 400 mRemotePortPWM->setText(prof->getRemotePortPWM());
401 401
402 mRemotePrecommand->setText(prof->getPreSyncCommand()); 402 mRemotePrecommand->setText(prof->getPreSyncCommand());
403 mRemotePostcommand->setText(prof->getPostSyncCommand()); 403 mRemotePostcommand->setText(prof->getPostSyncCommand());
404 mLocalTempFile->setText(prof->getLocalTempFile()); 404 mLocalTempFile->setText(prof->getLocalTempFile());
405 mRemoteFile->setText(prof->getRemoteFileName()) ; 405 mRemoteFile->setText(prof->getRemoteFileName()) ;
406 406
407 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 407 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
408 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 408 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
409 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 409 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
410 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 410 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
411 411
412 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 412 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
413 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 413 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
414 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 414 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
415 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 415 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
416 416
417 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 417 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
418 mPhoneDevice->setText(prof->getPhoneDevice()); 418 mPhoneDevice->setText(prof->getPhoneDevice());
419 mPhoneConnection->setText(prof->getPhoneConnection()); 419 mPhoneConnection->setText(prof->getPhoneConnection());
420 mPhoneModel->setText(prof->getPhoneModel()); 420 mPhoneModel->setText(prof->getPhoneModel());
421 421
422 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 422 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
423 mAskForPreferences->setChecked( prof->getAskForPreferences()); 423 mAskForPreferences->setChecked( prof->getAskForPreferences());
424 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 424 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
425 mWriteBackFile->setChecked( prof->getWriteBackFile()); 425 mWriteBackFile->setChecked( prof->getWriteBackFile());
426 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 426 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
427 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 427 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
428 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 428 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
429 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 429 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
430 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 430 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
431 431
432 switch ( prof->getSyncPrefs() ) { 432 switch ( prof->getSyncPrefs() ) {
433 case 0: 433 case 0:
434 loc->setChecked( true); 434 loc->setChecked( true);
435 break; 435 break;
436 case 1: 436 case 1:
437 rem->setChecked( true ); 437 rem->setChecked( true );
438 break; 438 break;
439 case 2: 439 case 2:
440 newest->setChecked( true); 440 newest->setChecked( true);
441 break; 441 break;
442 case 3: 442 case 3:
443 ask->setChecked( true); 443 ask->setChecked( true);
444 break; 444 break;
445 case 4: 445 case 4:
446 f_loc->setChecked( true); 446 f_loc->setChecked( true);
447 break; 447 break;
448 case 5: 448 case 5:
449 f_rem->setChecked( true); 449 f_rem->setChecked( true);
450 break; 450 break;
451 case 6: 451 case 6:
452 //both->setChecked( true); 452 //both->setChecked( true);
453 break; 453 break;
454 default: 454 default:
455 break; 455 break;
456 } 456 }
457 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 457 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
458 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 458 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
459 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() ); 459 mIsPi->setChecked(prof->getIsPiSync()) ;
460 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() );
460 proGr->setEnabled( item > 2 ); 461 proGr->setEnabled( item > 2 );
461 if ( item < 3 ) { 462 if ( item < 3 ) {
462 localFileWidget->hide(); 463 localFileWidget->hide();
463 remoteFileWidget->hide(); 464 remoteFileWidget->hide();
464 phoneWidget->hide(); 465 phoneWidget->hide();
465 piWidget->hide(); 466 piWidget->hide();
466 467
467 } else 468 } else
468 kindChanged( prof->getIsLocalFileSync() ); 469 kindChanged( prof->getIsLocalFileSync() );
469} 470}
470 471
471void KSyncPrefsDialog::fillSSH() 472void KSyncPrefsDialog::fillSSH()
472{ 473{
473 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 474 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
474 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 475 mLocalTempFile->setText("/tmp/mycalendar.ics" );
475 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 476 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
476 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 477 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
477 mLocalTempFileAB->setText("/tmp/std.vcf" ); 478 mLocalTempFileAB->setText("/tmp/std.vcf" );
478 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 479 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
479 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 480 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
480 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 481 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
481 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 482 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
482} 483}
483void KSyncPrefsDialog::fillFTP() 484void KSyncPrefsDialog::fillFTP()
484{ 485{
485 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 486 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
486 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 487 mLocalTempFile->setText("/tmp/mycalendar.ics" );
487 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 488 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
488 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 489 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
489 mLocalTempFileAB->setText("/tmp/std.vcf" ); 490 mLocalTempFileAB->setText("/tmp/std.vcf" );
490 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 491 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
491 492
492 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 493 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
493 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 494 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
494 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 495 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
495 496
496} 497}
497void KSyncPrefsDialog::kindChanged( bool b ) 498void KSyncPrefsDialog::kindChanged( bool b )
498{ 499{
499 500
500 if ( mIsLocal->isChecked () ) 501 if ( mIsLocal->isChecked () )
501 localFileWidget->show(); 502 localFileWidget->show();
502 else 503 else
503 localFileWidget->hide(); 504 localFileWidget->hide();
504 505
505 if ( mIsNotLocal->isChecked () ) 506 if ( mIsNotLocal->isChecked () )
506 remoteFileWidget->show(); 507 remoteFileWidget->show();
507 else 508 else
508 remoteFileWidget->hide(); 509 remoteFileWidget->hide();
509 510
510 if ( mIsPhone->isChecked () ) { 511 if ( mIsPhone->isChecked () ) {
511 phoneWidget->show(); 512 phoneWidget->show();
512 } 513 }
513 else { 514 else {
514 phoneWidget->hide(); 515 phoneWidget->hide();
515 } 516 }
516 if ( mIsPi->isChecked () ) { 517 if ( mIsPi->isChecked () ) {
517 piWidget->show(); 518 piWidget->show();
518 } 519 }
519 else { 520 else {
520 piWidget->hide(); 521 piWidget->hide();
521 } 522 }
522 523
523} 524}
524void KSyncPrefsDialog::deleteProfile() 525void KSyncPrefsDialog::deleteProfile()
525{ 526{
526 //qDebug("KSyncPrefsDialog::deleteProfile() "); 527 //qDebug("KSyncPrefsDialog::deleteProfile() ");
527 if ( currentSelection >= 0 ) { 528 if ( currentSelection >= 0 ) {
528 if ( currentSelection < 3 ) { 529 if ( currentSelection < 3 ) {
529 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 530 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
530 return; 531 return;
531 } 532 }
532 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 533 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
533 mSyncProfiles.remove( temp ); 534 mSyncProfiles.remove( temp );
534 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 535 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
535 insertProfiles(); 536 insertProfiles();
536 } 537 }
537} 538}
538 539
539void KSyncPrefsDialog::saveProfile() 540void KSyncPrefsDialog::saveProfile()
540{ 541{
541 KSyncProfile* prof; 542 KSyncProfile* prof;
542 if ( currentSelection >= 0 ) { 543 if ( currentSelection >= 0 ) {
543 prof = mSyncProfiles.at(currentSelection) ; 544 prof = mSyncProfiles.at(currentSelection) ;
544 545
545 prof->setRemotePw( mRemotePw->text()); 546 prof->setRemotePw( mRemotePw->text());
546 prof->setRemoteIP( mRemoteIP->text()); 547 prof->setRemoteIP( mRemoteIP->text());
547 prof->setRemotePort( mRemotePort->text()); 548 prof->setRemotePort( mRemotePort->text());
548 549
549 prof->setRemotePwAB( mRemotePwAB->text()); 550 prof->setRemotePwAB( mRemotePwAB->text());
550 prof->setRemoteIPAB( mRemoteIPAB->text()); 551 prof->setRemoteIPAB( mRemoteIPAB->text());
551 prof->setRemotePortAB( mRemotePortAB->text()); 552 prof->setRemotePortAB( mRemotePortAB->text());
552 553
553 prof->setRemotePwPWM( mRemotePwPWM->text()); 554 prof->setRemotePwPWM( mRemotePwPWM->text());
554 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 555 prof->setRemoteIPPWM( mRemoteIPPWM->text());
555 prof->setRemotePortPWM( mRemotePortPWM->text()); 556 prof->setRemotePortPWM( mRemotePortPWM->text());
556 557
557 prof->setPreSyncCommand( mRemotePrecommand->text()); 558 prof->setPreSyncCommand( mRemotePrecommand->text());
558 prof->setPostSyncCommand( mRemotePostcommand->text() ); 559 prof->setPostSyncCommand( mRemotePostcommand->text() );
559 prof->setLocalTempFile( mLocalTempFile->text()); 560 prof->setLocalTempFile( mLocalTempFile->text());
560 prof->setRemoteFileName( mRemoteFile->text() ); 561 prof->setRemoteFileName( mRemoteFile->text() );
561 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 562 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
562 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 563 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
563 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 564 prof->setLocalTempFileAB( mLocalTempFileAB->text());
564 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 565 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
565 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 566 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
566 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 567 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
567 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 568 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
568 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 569 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
569 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 570 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
570 prof->setAskForPreferences( mAskForPreferences->isChecked()); 571 prof->setAskForPreferences( mAskForPreferences->isChecked());
571 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 572 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
572 prof->setWriteBackFile( mWriteBackFile->isChecked()); 573 prof->setWriteBackFile( mWriteBackFile->isChecked());
573 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 574 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
574 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 575 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
575 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 576 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
576 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 577 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
577 prof->setSyncPrefs( syncprefs); 578 prof->setSyncPrefs( syncprefs);
578 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 579 prof->setIsLocalFileSync( mIsLocal->isChecked() );
579 prof->setIsPhoneSync( mIsPhone->isChecked() ); 580 prof->setIsPhoneSync( mIsPhone->isChecked() );
581 prof->setIsPiSync( mIsPi->isChecked() );
580 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 582 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
581 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 583 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
582 584
583 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 585 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
584 prof->setPhoneDevice( mPhoneDevice->text() ); 586 prof->setPhoneDevice( mPhoneDevice->text() );
585 prof->setPhoneConnection( mPhoneConnection->text() ); 587 prof->setPhoneConnection( mPhoneConnection->text() );
586 prof->setPhoneModel( mPhoneModel->text() ); 588 prof->setPhoneModel( mPhoneModel->text() );
587 589
588 } 590 }
589 591
590} 592}
591 593
592void KSyncPrefsDialog::insertProfiles() 594void KSyncPrefsDialog::insertProfiles()
593{ 595{
594 int curItem = mProfileBox->currentItem(); 596 int curItem = mProfileBox->currentItem();
595 mProfileBox->blockSignals( true ); 597 mProfileBox->blockSignals( true );
596 mProfileBox->clear(); 598 mProfileBox->clear();
597 mProfileBox->insertStringList (mSyncProfileNames ); 599 mProfileBox->insertStringList (mSyncProfileNames );
598 int item = mSyncProfileNames.count() -1; 600 int item = mSyncProfileNames.count() -1;
599 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 601 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
600 mProfileBox->setCurrentItem( curItem ); 602 mProfileBox->setCurrentItem( curItem );
601 else if ( item >= 0 ) { 603 else if ( item >= 0 ) {
602 mProfileBox->setCurrentItem( item ); 604 mProfileBox->setCurrentItem( item );
603 } 605 }
604 currentSelection = -1; 606 currentSelection = -1;
605 if ( mSyncProfileNames.count() > 0 ) { 607 if ( mSyncProfileNames.count() > 0 ) {
606 //qDebug(" profileChanged( mProfileBox->currentItem() "); 608 //qDebug(" profileChanged( mProfileBox->currentItem() ");
607 profileChanged( mProfileBox->currentItem() ); 609 profileChanged( mProfileBox->currentItem() );
608 currentSelection = mProfileBox->currentItem(); 610 currentSelection = mProfileBox->currentItem();
609 } 611 }
610 mProfileBox->blockSignals( false ); 612 mProfileBox->blockSignals( false );
611} 613}
612 614
613void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 615void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
614{ 616{
615 saveProfile(); 617 saveProfile();
616 mSyncProfiles.append( temp ); 618 mSyncProfiles.append( temp );
617 mSyncProfileNames << temp->getName(); 619 mSyncProfileNames << temp->getName();
618 insertProfiles(); 620 insertProfiles();
619 int last = mProfileBox->count() -1; 621 int last = mProfileBox->count() -1;
620 mProfileBox->blockSignals( true ); 622 mProfileBox->blockSignals( true );
621 mProfileBox->setCurrentItem( last ); 623 mProfileBox->setCurrentItem( last );
622 mProfileBox->blockSignals( false ); 624 mProfileBox->blockSignals( false );
623 profileChanged(last); 625 profileChanged(last);
624} 626}
625void KSyncPrefsDialog::newProfile() 627void KSyncPrefsDialog::newProfile()
626{ 628{
627 addProfile ( new KSyncProfile () ); 629 addProfile ( new KSyncProfile () );
628} 630}
629 631
630void KSyncPrefsDialog::cloneProfile() 632void KSyncPrefsDialog::cloneProfile()
631{ 633{
632 if ( currentSelection >= 0 ) 634 if ( currentSelection >= 0 )
633 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 635 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
634 else 636 else
635 newProfile(); 637 newProfile();
636} 638}
637 639
638void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 640void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
639{ 641{
640 mMyMachineName->setText( name ); 642 mMyMachineName->setText( name );
641 643
642} 644}
643QString KSyncPrefsDialog::getLocalMachineName ( ) 645QString KSyncPrefsDialog::getLocalMachineName ( )
644{ 646{
645 return mMyMachineName->text(); 647 return mMyMachineName->text();
646} 648}
647 649
648QStringList KSyncPrefsDialog::getSyncProfileNames() 650QStringList KSyncPrefsDialog::getSyncProfileNames()
649{ 651{
650 return mSyncProfileNames; 652 return mSyncProfileNames;
651} 653}
652void KSyncPrefsDialog::usrReadConfig() 654void KSyncPrefsDialog::usrReadConfig()
653{ 655{
654 //KConfig *config = KOGlobals::config(); 656 //KConfig *config = KOGlobals::config();
655 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 657 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
656 config.setGroup("General"); 658 config.setGroup("General");
657 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 659 mSyncProfileNames =config.readListEntry("SyncProfileNames");
658 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 660 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
659 int i; 661 int i;
660 KSyncProfile* temp ; 662 KSyncProfile* temp ;
661 mSyncProfiles.clear(); 663 mSyncProfiles.clear();
662 for ( i = 0; i < mSyncProfileNames.count();++i ) { 664 for ( i = 0; i < mSyncProfileNames.count();++i ) {
663 temp = new KSyncProfile (); 665 temp = new KSyncProfile ();
664 temp->setName( mSyncProfileNames[i] ); 666 temp->setName( mSyncProfileNames[i] );
665 temp->readConfig( &config ); 667 temp->readConfig( &config );
666 mSyncProfiles.append( temp ); 668 mSyncProfiles.append( temp );
667 } 669 }
668 insertProfiles(); 670 insertProfiles();
669 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 671 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
670} 672}
671 673
672 674
673void KSyncPrefsDialog::usrWriteConfig() 675void KSyncPrefsDialog::usrWriteConfig()
674{ 676{
675 saveProfile(); 677 saveProfile();
676 if ( currentSelection >= 0 ) 678 if ( currentSelection >= 0 )
677 profileChanged(currentSelection); 679 profileChanged(currentSelection);
678 //KConfig *config = KOGlobals::config(); 680 //KConfig *config = KOGlobals::config();
679 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 681 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
680 KSyncProfile* prof = mSyncProfiles.first(); 682 KSyncProfile* prof = mSyncProfiles.first();
681 QStringList externalSyncProfileNames; 683 QStringList externalSyncProfileNames;
682 externalSyncProfileNames.append("Sharp_DTM");; 684 externalSyncProfileNames.append("Sharp_DTM");;
683 while ( prof ) { 685 while ( prof ) {
684 prof->writeConfig(&config); 686 prof->writeConfig(&config);
685 if ( prof->getIsPhoneSync( ) ) 687 if ( prof->getIsPhoneSync( ) )
686 externalSyncProfileNames.append(prof->getName( ) ); 688 externalSyncProfileNames.append(prof->getName( ) );
687 prof = mSyncProfiles.next(); 689 prof = mSyncProfiles.next();
688 } 690 }
689 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 691 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
690 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 692 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
691 config.setGroup("General"); 693 config.setGroup("General");
692 config.writeEntry("SyncProfileNames",mSyncProfileNames); 694 config.writeEntry("SyncProfileNames",mSyncProfileNames);
693 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 695 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
694 config.writeEntry("LocalMachineName",mMyMachineName->text()); 696 config.writeEntry("LocalMachineName",mMyMachineName->text());
695 config.sync(); 697 config.sync();
696} 698}
697 699
698void KSyncPrefsDialog::helpDevice() 700void KSyncPrefsDialog::helpDevice()
699{ 701{
700 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 702 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
701#ifdef _WIN32_ 703#ifdef _WIN32_
702 hint += "Leave empty for Irda.\n" 704 hint += "Leave empty for Irda.\n"
703 "com1:\n(first serial port)\n" 705 "com1:\n(first serial port)\n"
704 "usb not supported\n" 706 "usb not supported\n"
705 "???\n(bluetooth device address)\n"; 707 "???\n(bluetooth device address)\n";
706 708
707#else 709#else
708 hint += "/dev/ircomm\n(Irda)\n" 710 hint += "/dev/ircomm\n(Irda)\n"
709 "/dev/ttyS0\n(first serial port)\n" 711 "/dev/ttyS0\n(first serial port)\n"
710 "/dev/ttyUSB0\n(first device usb port)\n" 712 "/dev/ttyUSB0\n(first device usb port)\n"
711 "???\n(bluetooth device address)\n"; 713 "???\n(bluetooth device address)\n";
712#endif 714#endif
713 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 715 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
714} 716}
715void KSyncPrefsDialog::helpModel() 717void KSyncPrefsDialog::helpModel()
716{ 718{
717 QString hint = i18n("Leave empty or\ninsert name of phone model:\n"); 719 QString hint = i18n("Leave empty or\ninsert name of phone model:\n");
718 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 720 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
719 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 721 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
720 722
721} 723}
722void KSyncPrefsDialog::helpConnection() 724void KSyncPrefsDialog::helpConnection()
723{ 725{
724 QString hint = i18n("Insert kind of connection,e.g.:\n"); 726 QString hint = i18n("Insert kind of connection,e.g.:\n");
725 hint += "irda | Nokia FBUS over infrared\n" 727 hint += "irda | Nokia FBUS over infrared\n"
726 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 728 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
727 "irdaobex | set also model as obex\n" 729 "irdaobex | set also model as obex\n"
728 "fbus | Nokia FBUS2 serial\n"; 730 "fbus | Nokia FBUS2 serial\n";
729 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 731 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
730} 732}