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