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