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