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