Diffstat (limited to 'kaddressbook/old_mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/old_mainwindow.cpp | 1561 |
1 files changed, 1561 insertions, 0 deletions
diff --git a/kaddressbook/old_mainwindow.cpp b/kaddressbook/old_mainwindow.cpp new file mode 100644 index 0000000..0e886d9 --- a/dev/null +++ b/kaddressbook/old_mainwindow.cpp | |||
@@ -0,0 +1,1561 @@ | |||
1 | #include <qlabel.h> | ||
2 | #include <qapp.h> | ||
3 | #include <qmessagebox.h> | ||
4 | #include <qaction.h> | ||
5 | |||
6 | #include <kdebug.h>// defined kdDebug() | ||
7 | #include <klocale.h>// defines i18n (microkde) | ||
8 | |||
9 | #include "kabprefs.h" | ||
10 | |||
11 | #ifndef DESKTOP_VERSION | ||
12 | #include <qpe/qpetoolbar.h> | ||
13 | #include <qpe/qpemenubar.h> | ||
14 | #include <qpe/resource.h> | ||
15 | #else | ||
16 | #include <qtoolbar.h> | ||
17 | #include <qmenubar.h> | ||
18 | #include <resource.h> | ||
19 | #endif | ||
20 | |||
21 | /* | ||
22 | #include <stdlib.h> | ||
23 | |||
24 | #include <qaction.h> | ||
25 | #include <qpainter.h> | ||
26 | #include <qwhatsthis.h> | ||
27 | #include <qpopupmenu.h> | ||
28 | #include <qmessagebox.h> | ||
29 | #include <qlineedit.h> | ||
30 | #include <qfile.h> | ||
31 | #include <qfileinfo.h> | ||
32 | #include <qwmatrix.h> | ||
33 | #ifndef DESKTOP_VERSION | ||
34 | #include <qpe/global.h> | ||
35 | #include <qpe/qpemenubar.h> | ||
36 | #include <qpe/qpetoolbar.h> | ||
37 | #include <qpe/resource.h> | ||
38 | #include <qpe/qpeapplication.h> | ||
39 | #include <qtopia/alarmserver.h> | ||
40 | #include <qtopia/qcopenvelope_qws.h> | ||
41 | #else | ||
42 | #include <qtoolbar.h> | ||
43 | #include <qdir.h> | ||
44 | #include <qapplication.h> | ||
45 | //#include <resource.h> | ||
46 | #endif | ||
47 | |||
48 | #include <libkcal/calendarlocal.h> | ||
49 | #include <libkcal/todo.h> | ||
50 | |||
51 | //#include "calendarview.h" | ||
52 | //#include "koviewmanager.h" | ||
53 | //#include "koagendaview.h" | ||
54 | //#include "kodialogmanager.h" | ||
55 | //#include "kdialogbase.h" | ||
56 | //#include "koprefs.h" | ||
57 | //#include "kfiledialog.h" | ||
58 | //#include "koglobals.h" | ||
59 | |||
60 | //#include "kconfig.h" | ||
61 | //#include "simplealarmclient.h" | ||
62 | */ | ||
63 | //US using namespace KACore; | ||
64 | |||
65 | |||
66 | #include "mainwindow.h" | ||
67 | |||
68 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | ||
69 | QMainWindow( parent, name ) | ||
70 | { | ||
71 | |||
72 | #ifdef DESKTOP_VERSION | ||
73 | setFont( QFont("Arial"), 14 ); | ||
74 | #endif | ||
75 | // mBlockAtStartup = true; | ||
76 | kdDebug() << "MainWindow()::MainWindow()" << endl; | ||
77 | // mFlagKeyPressed = false; | ||
78 | setCaption("KAddressbook/Pi"); | ||
79 | |||
80 | KABPrefs *p = KABPrefs::instance(); | ||
81 | if ( QApplication::desktop()->height() > 480 ) { | ||
82 | //US if ( p->mHourSize == 4 ) | ||
83 | //US p->mHourSize = 6; | ||
84 | } | ||
85 | |||
86 | QMainWindow::ToolBarDock tbd; | ||
87 | if ( p->mToolBarHor ) { | ||
88 | if ( p->mToolBarUp ) | ||
89 | tbd = Bottom; | ||
90 | else | ||
91 | tbd = Top; | ||
92 | } | ||
93 | else { | ||
94 | if ( p->mToolBarUp ) | ||
95 | tbd = Right; | ||
96 | else | ||
97 | tbd = Left; | ||
98 | } | ||
99 | |||
100 | iconToolBar = new QPEToolBar( this ); | ||
101 | addToolBar (iconToolBar , tbd ); | ||
102 | |||
103 | /*US | ||
104 | mBlockSaveFlag = false; | ||
105 | mCalendarModifiedFlag = false; | ||
106 | */ | ||
107 | QLabel* splash = new QLabel(i18n("KA/Pi is starting ... "), this ); | ||
108 | splash->setAlignment ( AlignCenter ); | ||
109 | setCentralWidget( splash ); | ||
110 | #ifndef DESKTOP_VERSION | ||
111 | showMaximized(); | ||
112 | #endif | ||
113 | qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | ||
114 | // setDefaultPreferences(); | ||
115 | /* mCalendar = new CalendarLocal(); | ||
116 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | ||
117 | mView->hide(); | ||
118 | //mView->resize(splash->size() ); | ||
119 | */ | ||
120 | initActions(); | ||
121 | |||
122 | #ifndef DESKTOP_VERSION | ||
123 | //US iconToolBar->show(); | ||
124 | qApp->processEvents(); | ||
125 | #endif | ||
126 | qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | ||
127 | |||
128 | int vh = height() ; | ||
129 | int vw = width(); | ||
130 | qDebug("Toolbar hei %d ",iconToolBar->height() ); | ||
131 | /*US if ( iconToolBar->orientation () == Qt:: Horizontal ) { | ||
132 | vh -= iconToolBar->height(); | ||
133 | } else { | ||
134 | vw -= iconToolBar->height(); | ||
135 | } | ||
136 | */ | ||
137 | //mView->setMaximumSize( splash->size() ); | ||
138 | //mView->resize( splash->size() ); | ||
139 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | ||
140 | /* mView->readSettings(); | ||
141 | if( !QFile::exists( defaultFileName() ) ) { | ||
142 | mView->saveCalendar( defaultFileName() ); | ||
143 | } | ||
144 | mView->openCalendar( defaultFileName() ); | ||
145 | processIncidenceSelection( 0 ); | ||
146 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
147 | SLOT( processIncidenceSelection( Incidence * ) ) ); | ||
148 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | ||
149 | SLOT( slotModifiedChanged( bool ) ) ); | ||
150 | connect( mView, SIGNAL( signalmodified() ), | ||
151 | SLOT( checkAlarms( ) ) ); | ||
152 | |||
153 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | ||
154 | connect( &alarmTimer, SIGNAL( timeout() ), SLOT( writeAlarm() ) ); | ||
155 | mView->setModified( false ); | ||
156 | mBlockAtStartup = false; | ||
157 | mView->setModified( false ); | ||
158 | setCentralWidget( mView ); | ||
159 | mView->show(); | ||
160 | */ | ||
161 | delete splash; | ||
162 | |||
163 | qApp->processEvents(); | ||
164 | //US qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | ||
165 | |||
166 | } | ||
167 | MainWindow::~MainWindow() | ||
168 | { | ||
169 | qDebug("MainWindow::~MainWindow() "); | ||
170 | kdDebug() << "MainWindow()::~MainWindow()" << endl; | ||
171 | //save toolbar location | ||
172 | /* | ||
173 | KOPrefs *p = KOPrefs::instance(); | ||
174 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | ||
175 | p->mToolBarUp = iconToolBar->x() > width()/2 || | ||
176 | iconToolBar->y() > height()/2; | ||
177 | alarmTimer.stop(); | ||
178 | mView->writeSettings(); | ||
179 | writeAlarm(); | ||
180 | if ( mCalendarModifiedFlag ) | ||
181 | save(); | ||
182 | delete mCalendar; | ||
183 | */ | ||
184 | } | ||
185 | |||
186 | |||
187 | void MainWindow::closeEvent( QCloseEvent* ce ) | ||
188 | { | ||
189 | |||
190 | if ( ! KABPrefs::instance()->mAskForQuit ) { | ||
191 | |||
192 | ce->accept(); | ||
193 | return; | ||
194 | |||
195 | } | ||
196 | |||
197 | switch( QMessageBox::information( this, "KA/Pi", | ||
198 | i18n("Do you really want\nto close KA/Pi?"), | ||
199 | i18n("Close!"), i18n("No"), | ||
200 | 0, 0 ) ) { | ||
201 | case 0: | ||
202 | ce->accept(); | ||
203 | break; | ||
204 | case 1: | ||
205 | ce->ignore(); | ||
206 | break; | ||
207 | case 2: | ||
208 | |||
209 | default: | ||
210 | break; | ||
211 | } | ||
212 | |||
213 | |||
214 | } | ||
215 | |||
216 | |||
217 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | ||
218 | { | ||
219 | /* | ||
220 | QDataStream stream( data, IO_ReadOnly ); | ||
221 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | ||
222 | |||
223 | |||
224 | if ( cmsg == "-writeFile" ) { | ||
225 | mView->viewManager()->showWhatsNextView(); | ||
226 | save(); | ||
227 | setCaption( i18n("File written on AD request")); | ||
228 | showMaximized(); | ||
229 | raise(); | ||
230 | #ifndef DESKTOP_VERSION | ||
231 | QCopEnvelope e3("kosaved", "blabla"); | ||
232 | #endif | ||
233 | return; | ||
234 | |||
235 | } | ||
236 | if ( cmsg == "-newCountdown" ) { | ||
237 | qDebug("newCountdown "); | ||
238 | |||
239 | } | ||
240 | QString msg ;; | ||
241 | QString allmsg = cmsg; | ||
242 | while ( allmsg.length() > 0 ) { | ||
243 | int nextC = allmsg.find( "-", 1 ); | ||
244 | if ( nextC == -1 ) { | ||
245 | msg = allmsg; | ||
246 | allmsg = ""; | ||
247 | } else{ | ||
248 | msg = allmsg.left( nextC ); | ||
249 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | ||
250 | } | ||
251 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | ||
252 | if ( msg == "-newEvent" ) { | ||
253 | mView->newEvent(); | ||
254 | } | ||
255 | if ( msg == "-newTodo" ) { | ||
256 | mView->newTodo(); | ||
257 | |||
258 | } | ||
259 | if ( msg == "-showWN" ) { | ||
260 | mView->viewManager()->showWhatsNextView(); | ||
261 | } | ||
262 | if ( msg == "-showTodo" ) { | ||
263 | mView->viewManager()->showTodoView(); | ||
264 | } | ||
265 | if ( msg == "-showList" ) { | ||
266 | mView->viewManager()->showListView(); | ||
267 | } | ||
268 | else if ( msg == "-showDay" ) { | ||
269 | mView->viewManager()->showDayView(); | ||
270 | } | ||
271 | else if ( msg == "-showWWeek" ) { | ||
272 | mView->viewManager()->showWorkWeekView(); | ||
273 | } | ||
274 | else if ( msg == "-showWeek" ) { | ||
275 | mView->viewManager()->showWeekView(); | ||
276 | } | ||
277 | else if ( msg == "-showTodo" ) { | ||
278 | mView->viewManager()->showTodoView(); | ||
279 | } | ||
280 | else if ( msg == "-showJournal" ) { | ||
281 | mView->viewManager()->showJournalView(); | ||
282 | } | ||
283 | else if ( msg == "-showKO" ) { | ||
284 | mView->viewManager()->showNextXView(); | ||
285 | } | ||
286 | else if ( msg == "-showWNext" ) { | ||
287 | mView->viewManager()->showWhatsNextView(); | ||
288 | } | ||
289 | } | ||
290 | |||
291 | showMaximized(); | ||
292 | raise(); | ||
293 | */ | ||
294 | } | ||
295 | |||
296 | |||
297 | QPixmap MainWindow::loadPixmap( QString name ) | ||
298 | { | ||
299 | return KGlobal::iconLoader().loadPixmap( name ); | ||
300 | /*US use the advanced version of the iconloader | ||
301 | #ifdef DESKTOP_VERSION | ||
302 | QPixmap pixmapLoader; | ||
303 | QString file; | ||
304 | file = QDir::homeDirPath()+"/kaddressbook/pics/" + name+".png"; | ||
305 | //qDebug("pixmap name %s ", file.latin1()); | ||
306 | pixmapLoader.load( file ); | ||
307 | return pixmapLoader; | ||
308 | #else | ||
309 | return Resource::loadPixmap( name ); | ||
310 | #endif | ||
311 | */ | ||
312 | } | ||
313 | |||
314 | void MainWindow::initActions() | ||
315 | { | ||
316 | iconToolBar->clear(); | ||
317 | KABPrefs *p = KABPrefs::instance(); | ||
318 | QPEMenuBar *menuBar1 = new QPEMenuBar( iconToolBar ); | ||
319 | QPopupMenu *menuBar = new QPopupMenu( this ); | ||
320 | menuBar1->insertItem( "ME", menuBar); | ||
321 | QPopupMenu *fileMenu = new QPopupMenu( this ); | ||
322 | QPopupMenu *editMenu = new QPopupMenu( this ); | ||
323 | QPopupMenu *viewMenu = new QPopupMenu( this ); | ||
324 | QPopupMenu *settingsMenu = new QPopupMenu( this ); | ||
325 | QPopupMenu *importMenu = new QPopupMenu( this ); | ||
326 | |||
327 | menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | ||
328 | |||
329 | QIconSet icon; | ||
330 | |||
331 | |||
332 | icon = loadPixmap( pathString + "newtodo" ); | ||
333 | configureToolBarMenu->insertItem(icon, "New todo", 20 ); | ||
334 | QAction* nt_action = new QAction( "New Todo", icon, "New Todo...", 0, this ); | ||
335 | nt_action->addTo( actionMenu ); | ||
336 | connect( nt_action, SIGNAL( activated() ), | ||
337 | mView, SLOT( newTodo() ) ); | ||
338 | |||
339 | /* | ||
340 | QAction *action; | ||
341 | QIconSet icon; | ||
342 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | ||
343 | configureToolBarMenu = new QPopupMenu( this ); | ||
344 | configureToolBarMenu->setCheckable( true ); | ||
345 | #ifdef DESKTOP_VERSION | ||
346 | QString pathString = ""; | ||
347 | #else | ||
348 | QString pathString = "kaddressbook/"; | ||
349 | #endif | ||
350 | if ( QApplication::desktop()->width() < 480 ) | ||
351 | pathString += "icons16/"; | ||
352 | configureAgendaMenu = new QPopupMenu( menuBar ); | ||
353 | configureAgendaMenu->setCheckable( true ); | ||
354 | configureAgendaMenu->insertItem("Toggle Allday", 1 ); | ||
355 | configureAgendaMenu->insertSeparator(); | ||
356 | configureAgendaMenu->insertItem("Tiny", 4 ); | ||
357 | configureAgendaMenu->insertItem("Small", 6 ); | ||
358 | configureAgendaMenu->insertItem("Medium", 8 ); | ||
359 | configureAgendaMenu->insertItem("Normal", 10 ); | ||
360 | configureAgendaMenu->insertItem("Large", 12 ); | ||
361 | configureAgendaMenu->insertItem("Big", 14 ); | ||
362 | configureAgendaMenu->insertItem("Bigger", 16 ); | ||
363 | configureAgendaMenu->insertItem("Biggest", 18 ); | ||
364 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | ||
365 | icon = loadPixmap( pathString + "newevent" ); | ||
366 | icon = loadPixmap( pathString + "newevent" ); | ||
367 | configureToolBarMenu->insertItem("Stretched TB", 5 ); | ||
368 | configureToolBarMenu->insertSeparator(); | ||
369 | configureToolBarMenu->insertItem(icon, "New event", 10 ); | ||
370 | QAction* ne_action = new QAction( "New Event", icon, "New Event...", 0, this ); | ||
371 | ne_action->addTo( actionMenu ); | ||
372 | */ | ||
373 | /* | ||
374 | connect( ne_action, SIGNAL( activated() ), | ||
375 | mView, SLOT( newEvent() ) ); | ||
376 | icon = loadPixmap( pathString + "newtodo" ); | ||
377 | configureToolBarMenu->insertItem(icon, "New todo", 20 ); | ||
378 | QAction* nt_action = new QAction( "New Todo", icon, "New Todo...", 0, this ); | ||
379 | nt_action->addTo( actionMenu ); | ||
380 | connect( nt_action, SIGNAL( activated() ), | ||
381 | mView, SLOT( newTodo() ) ); | ||
382 | |||
383 | action = new QAction( "Toggle FilterView", QPixmap(), "Toggle FilterView", 0, this ); | ||
384 | action->addTo( viewMenu ); | ||
385 | connect( action, SIGNAL( activated() ), | ||
386 | mView, SLOT( toggleFilter() ) ); | ||
387 | |||
388 | viewMenu->insertSeparator(); | ||
389 | icon = loadPixmap( pathString + "picker" ); | ||
390 | action = new QAction( "Date Picker", icon, "Date Picker", 0, this ); | ||
391 | action->addTo( viewMenu ); | ||
392 | connect( action, SIGNAL( activated() ), | ||
393 | mView, SLOT( showDatePicker() ) ); | ||
394 | action->addTo( iconToolBar ); | ||
395 | viewMenu->insertSeparator(); | ||
396 | icon = loadPixmap( pathString + "list" ); | ||
397 | configureToolBarMenu->insertItem(icon, "Event list", 30 ); | ||
398 | QAction* showlist_action = new QAction( "List", icon, "List", 0, this ); | ||
399 | showlist_action->addTo( viewMenu ); | ||
400 | connect( showlist_action, SIGNAL( activated() ), | ||
401 | mView->viewManager(), SLOT( showListView() ) ); | ||
402 | |||
403 | |||
404 | icon = loadPixmap( pathString + "day" ); | ||
405 | configureToolBarMenu->insertItem(icon, "One day", 40 ); | ||
406 | QAction* day1_action = new QAction( "Day", icon, "Day", 0, this ); | ||
407 | day1_action->addTo( viewMenu ); | ||
408 | // action->addTo( toolBar ); | ||
409 | connect( day1_action, SIGNAL( activated() ), | ||
410 | mView->viewManager(), SLOT( showDayView() ) ); | ||
411 | |||
412 | icon = loadPixmap( pathString + "workweek" ); | ||
413 | configureToolBarMenu->insertItem(icon, "Work week", 50 ); | ||
414 | QAction* day5_action = new QAction( "Work Week", icon, "Work Week", 0, this ); | ||
415 | day5_action->addTo( viewMenu ); | ||
416 | connect( day5_action, SIGNAL( activated() ), | ||
417 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | ||
418 | |||
419 | icon = loadPixmap( pathString + "week" ); | ||
420 | configureToolBarMenu->insertItem(icon, "Week", 60 ); | ||
421 | QAction* day7_action = new QAction( "Week", icon, "Week", 0, this ); | ||
422 | day7_action->addTo( viewMenu ); | ||
423 | connect( day7_action, SIGNAL( activated() ), | ||
424 | mView->viewManager(), SLOT( showWeekView() ) ); | ||
425 | |||
426 | icon = loadPixmap( pathString + "month" ); | ||
427 | configureToolBarMenu->insertItem(icon, "Month", 70 ); | ||
428 | QAction* month_action = new QAction( "Month", icon, "Month", 0, this ); | ||
429 | month_action->addTo( viewMenu ); | ||
430 | connect( month_action, SIGNAL( activated() ), | ||
431 | mView->viewManager(), SLOT( showMonthView() ) ); | ||
432 | |||
433 | icon = loadPixmap( pathString + "todo" ); | ||
434 | configureToolBarMenu->insertItem(icon, "Todo list", 80 ); | ||
435 | QAction* todoview_action = new QAction( "Todo", icon, "Todo", 0, this ); | ||
436 | todoview_action->addTo( viewMenu ); | ||
437 | connect( todoview_action, SIGNAL( activated() ), | ||
438 | mView->viewManager(), SLOT( showTodoView() ) ); | ||
439 | |||
440 | icon = loadPixmap( pathString + "journal" ); | ||
441 | configureToolBarMenu->insertItem(icon, "Journal", 90 ); | ||
442 | QAction* viewjournal_action = new QAction( "Journal", icon, "Journal", 0, this ); | ||
443 | viewjournal_action->addTo( viewMenu ); | ||
444 | connect( viewjournal_action, SIGNAL( activated() ), | ||
445 | mView->viewManager(), SLOT( showJournalView() ) ); | ||
446 | |||
447 | icon = loadPixmap( pathString + "xdays" ); | ||
448 | configureToolBarMenu->insertItem(icon, "Next days", 100,4 ); | ||
449 | QAction* xdays_action = new QAction( "Next days", icon, "Next Days", 0, this ); | ||
450 | xdays_action->addTo( viewMenu ); | ||
451 | connect( xdays_action, SIGNAL( activated() ), | ||
452 | mView->viewManager(), SLOT( showNextXView() ) ); | ||
453 | |||
454 | icon = loadPixmap( pathString + "whatsnext" ); | ||
455 | configureToolBarMenu->insertItem(icon, "Whats next", 110, 4 ); | ||
456 | QAction* whatsnext_action = new QAction( "What's Next", icon, "What's Next", 0, this ); | ||
457 | whatsnext_action->addTo( viewMenu ); | ||
458 | connect( whatsnext_action, SIGNAL( activated() ), | ||
459 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | ||
460 | |||
461 | #if 0 | ||
462 | action = new QAction( "view_timespan", "Time Span", 0, this ); | ||
463 | action->addTo( viewMenu ); | ||
464 | connect( action, SIGNAL( activated() ), | ||
465 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | ||
466 | #endif | ||
467 | |||
468 | menuBar->insertItem( "View", viewMenu ); | ||
469 | |||
470 | |||
471 | #if 0 | ||
472 | QPopupMenu *navigationMenu = new QPopupMenu( menuBar ); | ||
473 | |||
474 | action = new QAction( "Go backward", "Go Backward", 0, navigationMenu ); | ||
475 | action->addTo( navigationMenu ); | ||
476 | connect( action, SIGNAL( activated() ), | ||
477 | mView, SLOT( goPrevious() ) ); | ||
478 | |||
479 | action = new QAction( "Go forward", "Go Forward", 0, navigationMenu ); | ||
480 | action->addTo( navigationMenu ); | ||
481 | connect( action, SIGNAL( activated() ), | ||
482 | mView, SLOT( goNext() ) ); | ||
483 | |||
484 | menuBar->insertItem( "Go", navigationMenu ); | ||
485 | #endif | ||
486 | |||
487 | |||
488 | |||
489 | |||
490 | |||
491 | |||
492 | mNewSubTodoAction = new QAction( "new_subtodo", "New Sub-Todo...", 0, | ||
493 | this ); | ||
494 | mNewSubTodoAction->addTo( actionMenu ); | ||
495 | connect( mNewSubTodoAction, SIGNAL( activated() ), | ||
496 | mView, SLOT( newSubTodo() ) ); | ||
497 | |||
498 | actionMenu->insertSeparator(); | ||
499 | |||
500 | mShowAction = new QAction( "show_incidence", "Show...", 0, this ); | ||
501 | mShowAction->addTo( actionMenu ); | ||
502 | connect( mShowAction, SIGNAL( activated() ), | ||
503 | mView, SLOT( showIncidence() ) ); | ||
504 | |||
505 | mEditAction = new QAction( "edit_incidence", "Edit...", 0, this ); | ||
506 | mEditAction->addTo( actionMenu ); | ||
507 | connect( mEditAction, SIGNAL( activated() ), | ||
508 | mView, SLOT( editIncidence() ) ); | ||
509 | |||
510 | mDeleteAction = new QAction( "delete_incidence", "Delete...", 0, this ); | ||
511 | mDeleteAction->addTo( actionMenu ); | ||
512 | connect( mDeleteAction, SIGNAL( activated() ), | ||
513 | mView, SLOT( deleteIncidence() ) ); | ||
514 | |||
515 | actionMenu->insertSeparator(); | ||
516 | |||
517 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | ||
518 | this ); | ||
519 | action->addTo( actionMenu ); | ||
520 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | ||
521 | |||
522 | icon = loadPixmap( pathString + "search" ); | ||
523 | QAction* search_action = new QAction( "search", icon, "Search...", 0, this ); | ||
524 | configureToolBarMenu->insertItem(icon, "Search", 120 , 4); | ||
525 | search_action->addTo( actionMenu ); | ||
526 | connect( search_action, SIGNAL( activated() ), | ||
527 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | ||
528 | |||
529 | icon = loadPixmap( pathString + "today" ); | ||
530 | configureToolBarMenu->insertItem(icon, "Today", 130); | ||
531 | QAction* today_action = new QAction( "Today", icon, "Go to Today", 0, this ); | ||
532 | today_action->addTo( actionMenu ); | ||
533 | connect( today_action, SIGNAL( activated() ), | ||
534 | mView, SLOT( goToday() ) ); | ||
535 | |||
536 | //#if 0 | ||
537 | actionMenu->insertSeparator(); | ||
538 | |||
539 | action = new QAction( "configure", "Configure...", 0, this ); | ||
540 | action->addTo( actionMenu ); | ||
541 | connect( action, SIGNAL( activated() ), | ||
542 | mView, SLOT( edit_options() ) ); | ||
543 | //#endif | ||
544 | |||
545 | // actionMenu->insertSeparator(); | ||
546 | action = new QAction( "import_qtopia", "Import (*.ics/*.vcs) file", 0, | ||
547 | this ); | ||
548 | action->addTo( importMenu ); | ||
549 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | ||
550 | action = new QAction( "import_quick", "Import last file", 0, | ||
551 | this ); | ||
552 | action->addTo( importMenu ); | ||
553 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | ||
554 | importMenu->insertSeparator(); | ||
555 | action = new QAction( "import_qtopia", "Import Opie/Qtopia Cal.", 0, | ||
556 | this ); | ||
557 | action->addTo( importMenu ); | ||
558 | importMenu->insertSeparator(); | ||
559 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | ||
560 | |||
561 | action = new QAction( "load_cal", "Load Calendar Backup", 0, | ||
562 | this ); | ||
563 | action->addTo( importMenu ); | ||
564 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | ||
565 | |||
566 | action = new QAction( "save_cal", "Save Calendar Backup", 0, | ||
567 | this ); | ||
568 | action->addTo( importMenu ); | ||
569 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | ||
570 | |||
571 | importMenu->insertSeparator(); | ||
572 | action = new QAction( "import_qtopia", "Export VCalendar", 0, | ||
573 | this ); | ||
574 | action->addTo( importMenu ); | ||
575 | connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | ||
576 | |||
577 | |||
578 | QPopupMenu *syncMenu = new QPopupMenu( this ); | ||
579 | action = new QAction( "syncssh", "Remote via ssh/scp(not implemented)", 0, | ||
580 | this ); | ||
581 | action->addTo( syncMenu ); | ||
582 | connect( action, SIGNAL( activated() ), SLOT( syncSSH() ) ); | ||
583 | action = new QAction( "synclocal", "With local file(not implemented)", 0, | ||
584 | this ); | ||
585 | action->addTo( syncMenu ); | ||
586 | connect( action, SIGNAL( activated() ), SLOT( syncLocalFile() ) ); | ||
587 | action = new QAction( "quicksynclocal", "With last file(not implemented)", 0, | ||
588 | this ); | ||
589 | action->addTo( syncMenu ); | ||
590 | connect( action, SIGNAL( activated() ), SLOT( quickSyncLocalFile() ) ); | ||
591 | |||
592 | menuBar->insertItem( "Actions", actionMenu ); | ||
593 | menuBar->insertItem( "Load/Save", importMenu ); | ||
594 | menuBar->insertItem( "Synchronize", syncMenu ); | ||
595 | //menuBar->insertItem( "Configure",configureMenu ); | ||
596 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | ||
597 | menuBar->insertItem( "AgendaSize",configureAgendaMenu ); | ||
598 | menuBar->insertItem( "Toolbar",configureToolBarMenu ); | ||
599 | QPopupMenu *helpMenu = new QPopupMenu( menuBar ); | ||
600 | icon = loadPixmap( "korganizer/korganizer" ); | ||
601 | action = new QAction( "Key bindings", "Key Bindings...", 0, this ); | ||
602 | action->addTo( helpMenu ); | ||
603 | connect( action, SIGNAL( activated() ), | ||
604 | SLOT( keyBindings() ) ); | ||
605 | action = new QAction( "Auto saving", "Auto saving...", 0, this ); | ||
606 | action->addTo( helpMenu ); | ||
607 | connect( action, SIGNAL( activated() ), | ||
608 | SLOT( aboutAutoSaving() ) ); | ||
609 | action = new QAction( "Problemd", "Known Problems...", 0,this ); | ||
610 | action->addTo( helpMenu ); | ||
611 | connect( action, SIGNAL( activated() ), | ||
612 | SLOT( aboutKnownBugs() ) ); | ||
613 | action = new QAction( "about", "About...", 0, this ); | ||
614 | action->addTo( helpMenu ); | ||
615 | connect( action, SIGNAL( activated() ), | ||
616 | SLOT( about() ) ); | ||
617 | menuBar->insertItem( "Help", helpMenu ); | ||
618 | */ | ||
619 | //menuBar->insertSeparator(); | ||
620 | |||
621 | // ****************************************************** | ||
622 | // menubar icons | ||
623 | |||
624 | |||
625 | iconToolBar->setHorizontalStretchable (true ); | ||
626 | //menuBar->insertItem( iconToolBar ); | ||
627 | //xdays_action | ||
628 | /* | ||
629 | if (p-> mShowIconNewEvent) | ||
630 | ne_action->addTo( iconToolBar ); | ||
631 | if (p->mShowIconNewTodo ) | ||
632 | nt_action->addTo( iconToolBar ); | ||
633 | if (p-> mShowIconSearch) | ||
634 | search_action->addTo( iconToolBar ); | ||
635 | if (p-> mShowIconNext) | ||
636 | whatsnext_action->addTo( iconToolBar ); | ||
637 | if (p-> mShowIconNextDays) | ||
638 | xdays_action->addTo( iconToolBar ); | ||
639 | if (p-> mShowIconList) | ||
640 | showlist_action->addTo( iconToolBar ); | ||
641 | if (p-> mShowIconDay1) | ||
642 | day1_action->addTo( iconToolBar ); | ||
643 | if (p-> mShowIconDay5) | ||
644 | day5_action->addTo( iconToolBar ); | ||
645 | if (p-> mShowIconDay7) | ||
646 | day7_action->addTo( iconToolBar ); | ||
647 | if (p-> mShowIconMonth) | ||
648 | month_action->addTo( iconToolBar ); | ||
649 | if (p-> mShowIconTodoview) | ||
650 | todoview_action->addTo( iconToolBar ); | ||
651 | if (p-> mShowIconJournal) | ||
652 | viewjournal_action->addTo( iconToolBar ); | ||
653 | icon = loadPixmap( pathString + "2leftarrowB" ); | ||
654 | configureToolBarMenu->insertItem(icon, "Prev. month", 200, 14); | ||
655 | if (p-> mShowIconBackFast) { | ||
656 | action = new QAction( "Prev month", icon, "Go Backward",0 , this ); | ||
657 | connect( action, SIGNAL( activated() ), | ||
658 | mView, SLOT( goPreviousMonth() ) ); | ||
659 | action->addTo( iconToolBar ); | ||
660 | } | ||
661 | icon = loadPixmap( pathString + "1leftarrowB" ); | ||
662 | configureToolBarMenu->insertItem(icon, "Go previous", 210,15); | ||
663 | if (p-> mShowIconBack) { | ||
664 | action = new QAction( "Go previous", icon, "Go Backward",0 , this ); | ||
665 | connect( action, SIGNAL( activated() ), | ||
666 | mView, SLOT( goPrevious() ) ); | ||
667 | action->addTo( iconToolBar ); | ||
668 | } | ||
669 | if (p-> mShowIconToday) | ||
670 | today_action->addTo( iconToolBar ); | ||
671 | icon = loadPixmap( pathString + "1rightarrowB" ); | ||
672 | configureToolBarMenu->insertItem(icon, "Go next", 220); | ||
673 | if (p-> mShowIconForward) { | ||
674 | action = new QAction( "Go next", icon, "Go Backward",0 , this ); | ||
675 | connect( action, SIGNAL( activated() ), | ||
676 | mView, SLOT( goNext() ) ); | ||
677 | action->addTo( iconToolBar ); | ||
678 | } | ||
679 | icon = loadPixmap( pathString + "2rightarrowB" ); | ||
680 | configureToolBarMenu->insertItem(icon, "Next month", 230); | ||
681 | if (p-> mShowIconForwardFast) { | ||
682 | action = new QAction( "Next month", icon, "Go Backward",0 , this ); | ||
683 | connect( action, SIGNAL( activated() ), | ||
684 | mView, SLOT( goNextMonth() ) ); | ||
685 | action->addTo( iconToolBar ); | ||
686 | } | ||
687 | */ | ||
688 | |||
689 | configureToolBarMenu->insertItem("WhatsThis", 300); | ||
690 | /* | ||
691 | if (p-> mShowIconNewEvent) | ||
692 | configureToolBarMenu->setItemChecked( 10, true ); | ||
693 | if (p->mShowIconNewTodo ) | ||
694 | configureToolBarMenu->setItemChecked( 20, true ); | ||
695 | if (p-> mShowIconSearch) | ||
696 | configureToolBarMenu->setItemChecked( 120, true ); | ||
697 | if (p-> mShowIconList) | ||
698 | configureToolBarMenu->setItemChecked( 30, true ); | ||
699 | if (p-> mShowIconDay1) | ||
700 | configureToolBarMenu->setItemChecked( 40, true ); | ||
701 | if (p-> mShowIconDay5) | ||
702 | configureToolBarMenu->setItemChecked( 50, true ); | ||
703 | if (p-> mShowIconDay7) | ||
704 | configureToolBarMenu->setItemChecked( 60, true ); | ||
705 | if (p-> mShowIconMonth) | ||
706 | configureToolBarMenu->setItemChecked( 70, true ); | ||
707 | if (p-> mShowIconTodoview) | ||
708 | configureToolBarMenu->setItemChecked( 80, true ); | ||
709 | if (p-> mShowIconBackFast) | ||
710 | configureToolBarMenu->setItemChecked( 200, true ); | ||
711 | if (p-> mShowIconBack) | ||
712 | configureToolBarMenu->setItemChecked( 210, true ); | ||
713 | if (p-> mShowIconToday) | ||
714 | configureToolBarMenu->setItemChecked( 130, true ); | ||
715 | if (p-> mShowIconForward) | ||
716 | configureToolBarMenu->setItemChecked( 220, true ); | ||
717 | if (p-> mShowIconForwardFast) | ||
718 | configureToolBarMenu->setItemChecked( 230, true ); | ||
719 | if (p-> mShowIconNextDays) | ||
720 | configureToolBarMenu->setItemChecked( 100, true ); | ||
721 | if (p-> mShowIconNext) | ||
722 | configureToolBarMenu->setItemChecked( 110, true ); | ||
723 | if (p-> mShowIconJournal) | ||
724 | configureToolBarMenu->setItemChecked( 90, true ); | ||
725 | if (p-> mShowIconWhatsThis) | ||
726 | configureToolBarMenu->setItemChecked( 300, true ); | ||
727 | |||
728 | QLabel* dummy = new QLabel( iconToolBar ); | ||
729 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | ||
730 | if (!p-> mShowIconStretch) | ||
731 | iconToolBar->setStretchableWidget ( dummy ) ; | ||
732 | else | ||
733 | configureToolBarMenu->setItemChecked( 5, true ); | ||
734 | if (p-> mShowIconWhatsThis) | ||
735 | QWhatsThis::whatsThisButton ( iconToolBar ); | ||
736 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | ||
737 | configureAgenda( p->mHourSize ); | ||
738 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | ||
739 | */ | ||
740 | } | ||
741 | /* | ||
742 | void MainWindow::setDefaultPreferences() | ||
743 | { | ||
744 | KOPrefs *p = KOPrefs::instance(); | ||
745 | |||
746 | p->mCompactDialogs = true; | ||
747 | p->mConfirm = true; | ||
748 | p->mEnableQuickTodo = false; | ||
749 | } | ||
750 | */ | ||
751 | void MainWindow::about() | ||
752 | { | ||
753 | QMessageBox::about( this, "About KOrganizer/Pi", | ||
754 | "KOrganizer/Platform-independent\n" | ||
755 | "(KO/Pi) 1.6.0e - " | ||
756 | #ifdef DESKTOP_VERSION | ||
757 | "Desktop Edition\n" | ||
758 | #else | ||
759 | "PDA-Edition\n" | ||
760 | "for: Zaurus 5500 / 7x0 / 8x0\n" | ||
761 | #endif | ||
762 | "(c) 2004 Lutz Rogowski\n" | ||
763 | "Email:lutz@pi-sync.net\n" | ||
764 | "KO/Pi is based on KOrganizer\n" | ||
765 | "(c) 2002,2003 Cornelius Schumacher\n" | ||
766 | "Email: schumacher@kde.org\n" | ||
767 | "KOrganizer/Pi is licensed\n" | ||
768 | "under the GPL.\n" | ||
769 | "KO/Pi can be compiled for\n" | ||
770 | "Linux, Zaurus-PDA and Windows\n" | ||
771 | "www.korganizer.org\n" ); | ||
772 | } | ||
773 | /* | ||
774 | void MainWindow::keyBindings() | ||
775 | { | ||
776 | QMessageBox* msg; | ||
777 | msg = new QMessageBox( "Key bindings KOrganizer/Pi", | ||
778 | "Space: Toggle Fullscreen | P: Date Picker\n" | ||
779 | "H: This dialog | I: Show info | S: Search\n" | ||
780 | "F: Toggle Filterview | 1-4: Select Filter\n" | ||
781 | "N: Show next days | W: Whats next\n " | ||
782 | "V: Todo view | L: Event list view\n" | ||
783 | "T: Goto today | T+<ctrl>: New Todo\n" | ||
784 | "E: Edit item | E+<ctrl>: New Event\n" | ||
785 | "5: Work week view | 7: Week view\n" | ||
786 | "D: One day view | M: Month view\n" | ||
787 | "+,- : Zoom in/out Agenda | A: Toggle Allday\n" | ||
788 | "<ctrl>+<up>/<down>: Scroll todo view\n" | ||
789 | "<right>,C: Next week | <right>+<ctrl>: Next month\n" | ||
790 | "<left>,X: Prev. week | <left>+<ctrl>: Prev. month\n" | ||
791 | "<del>,<backspace>: Delete sel. item\n", | ||
792 | QMessageBox::NoIcon, | ||
793 | QMessageBox::Ok, | ||
794 | QMessageBox::NoButton, | ||
795 | QMessageBox::NoButton ); | ||
796 | msg->exec(); | ||
797 | delete msg; | ||
798 | |||
799 | } | ||
800 | void MainWindow::aboutAutoSaving() | ||
801 | { | ||
802 | QMessageBox* msg; | ||
803 | msg = new QMessageBox( "Auto Saving in KOrganizer/Pi", | ||
804 | "After changing something, the data is\n" | ||
805 | "automatically saved to the file\n" | ||
806 | "~/Applications/korganizer/mycalendar.ics\n " | ||
807 | "after (configureable) one minute.\n" | ||
808 | "For safety reasons there is one autosaving\n" | ||
809 | "after 10 minutes (of idle time) again. The \n" | ||
810 | "data is saved automatically when closing KO/Pi\n" | ||
811 | "You can create a backup file \n" | ||
812 | "with: Load/Save - Save Calendar Backup\n", | ||
813 | QMessageBox::NoIcon, | ||
814 | QMessageBox::Ok, | ||
815 | QMessageBox::NoButton, | ||
816 | QMessageBox::NoButton); | ||
817 | msg->exec(); | ||
818 | delete msg; | ||
819 | |||
820 | |||
821 | } | ||
822 | void MainWindow::aboutKnownBugs() | ||
823 | { | ||
824 | QMessageBox* msg; | ||
825 | msg = new QMessageBox( "Known Problems in KOrganizer/Pi", | ||
826 | "1) The QWhatsThis help is not working.\n" | ||
827 | "There is only a black rectangle displayed\n" | ||
828 | "when clicking on an event.\n " | ||
829 | "2) Audio alarm is available!\n" | ||
830 | "as an additional small application\n" | ||
831 | "3) Syncing is missing.\n" | ||
832 | "Syncing via ssh/scp will be available in\n" | ||
833 | "KOrganizer/Pi 2.0\n" | ||
834 | "\n" | ||
835 | "Please report unexpected behaviour to\n" | ||
836 | "lutz@pi-sync.net\n", | ||
837 | QMessageBox::NoIcon, | ||
838 | QMessageBox::Ok, | ||
839 | QMessageBox::NoButton, | ||
840 | QMessageBox::NoButton); | ||
841 | msg->exec(); | ||
842 | delete msg; | ||
843 | |||
844 | } | ||
845 | |||
846 | QString MainWindow::defaultFileName() | ||
847 | { | ||
848 | #ifndef DESKTOP_VERSION | ||
849 | return Global::applicationFileName( "korganizer", "mycalendar.ics" ); | ||
850 | #else | ||
851 | // pending | ||
852 | QString file; | ||
853 | file = QDir::homeDirPath()+"/korganizer/mycalendar.ics"; | ||
854 | return QDir::convertSeparators( file ); | ||
855 | #endif | ||
856 | } | ||
857 | |||
858 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | ||
859 | { | ||
860 | if ( !incidence ) { | ||
861 | enableIncidenceActions( false ); | ||
862 | |||
863 | mNewSubTodoAction->setEnabled( false ); | ||
864 | setCaptionToDates(); | ||
865 | return; | ||
866 | |||
867 | } | ||
868 | |||
869 | QString startString = ""; | ||
870 | if ( incidence->type() != "Todo" ) { | ||
871 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | ||
872 | startString = ": "+incidence->dtStart().time().toString().left(5); | ||
873 | startString += " "+ incidence->dtStart().date().toString(); | ||
874 | startString += "-"+incidence->dtEnd().time().toString().left(5); | ||
875 | startString += " "+ incidence->dtEnd().date().toString(); | ||
876 | |||
877 | } else { | ||
878 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | ||
879 | startString = ": "+incidence->dtStart().time().toString().left(5)+"-"+incidence->dtEnd().time().toString().left(5); | ||
880 | startString +=" "+incidence->dtStart().date().toString(); | ||
881 | } | ||
882 | |||
883 | } | ||
884 | else | ||
885 | startString = ": (Prio "+QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +"\% completed"; | ||
886 | |||
887 | setCaption( incidence->summary()+startString); | ||
888 | |||
889 | enableIncidenceActions( true ); | ||
890 | |||
891 | if ( incidence->type() == "Event" ) { | ||
892 | mShowAction->setText( i18n("Show Event...") ); | ||
893 | mEditAction->setText( i18n("Edit Event...") ); | ||
894 | mDeleteAction->setText( i18n("Delete Event...") ); | ||
895 | |||
896 | mNewSubTodoAction->setEnabled( false ); | ||
897 | } else if ( incidence->type() == "Todo" ) { | ||
898 | mShowAction->setText( i18n("Show Todo...") ); | ||
899 | mEditAction->setText( i18n("Edit Todo...") ); | ||
900 | mDeleteAction->setText( i18n("Delete Todo...") ); | ||
901 | |||
902 | mNewSubTodoAction->setEnabled( true ); | ||
903 | } else { | ||
904 | mShowAction->setText( i18n("Show...") ); | ||
905 | mShowAction->setText( i18n("Edit...") ); | ||
906 | mShowAction->setText( i18n("Delete...") ); | ||
907 | |||
908 | mNewSubTodoAction->setEnabled( false ); | ||
909 | } | ||
910 | } | ||
911 | |||
912 | void MainWindow::enableIncidenceActions( bool enabled ) | ||
913 | { | ||
914 | mShowAction->setEnabled( enabled ); | ||
915 | mEditAction->setEnabled( enabled ); | ||
916 | mDeleteAction->setEnabled( enabled ); | ||
917 | } | ||
918 | |||
919 | void MainWindow::importQtopia() | ||
920 | { | ||
921 | #ifndef DESKTOP_VERSION | ||
922 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | ||
923 | "When importing a calendar twice\n" | ||
924 | "duplicated events will be ignored!\n" | ||
925 | "You can create a backup file with\n" | ||
926 | "Load/Save - Save Calendar Backup\n" | ||
927 | "to revert importing", | ||
928 | "Import!", "Cancel", 0, | ||
929 | 0, 1 ); | ||
930 | if ( result == 0 ) { | ||
931 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | ||
932 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | ||
933 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | ||
934 | mView->importQtopia( categories, datebook, todolist ); | ||
935 | } | ||
936 | #else | ||
937 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | ||
938 | "NOT SUPPORTED \n" | ||
939 | "ON DESKTOP!\n", | ||
940 | "OK", "Cancel", 0, | ||
941 | 0, 1 ); | ||
942 | |||
943 | #endif | ||
944 | } | ||
945 | void MainWindow::checkAlarms() | ||
946 | { | ||
947 | if ( mBlockAtStartup ) | ||
948 | return; | ||
949 | alarmTimer.start( 1000 * 3); | ||
950 | |||
951 | } | ||
952 | void MainWindow::slotModifiedChanged( bool changed ) | ||
953 | { | ||
954 | if ( mBlockAtStartup ) | ||
955 | return; | ||
956 | int msec; | ||
957 | // we store the changes after 1 minute, | ||
958 | // and for safety reasons after 10 minutes again | ||
959 | if ( !mBlockSaveFlag ) | ||
960 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | ||
961 | else | ||
962 | msec = 1000 * 600; | ||
963 | mSaveTimer.start( msec, true ); // 1 minute | ||
964 | qDebug("KO: Saving File in %d secs!", msec/1000); | ||
965 | mCalendarModifiedFlag = true; | ||
966 | } | ||
967 | void MainWindow::writeAlarm() | ||
968 | { | ||
969 | if ( mBlockAtStartup ) | ||
970 | return; | ||
971 | //QCopEnvelope e3("koalarm", "-showWN"); | ||
972 | QDateTime nextA ; | ||
973 | QDateTime reference ( QDate( 2000, 1, 1 ) ); | ||
974 | QString summary; | ||
975 | alarmTimer.stop(); | ||
976 | Calendar* cal = mView->calendar(); | ||
977 | if ( ! cal ){ | ||
978 | qDebug("KO: Calendar undefined. No alarm notification"); | ||
979 | return; | ||
980 | } | ||
981 | nextA = cal->nextAlarm( 720 ); | ||
982 | summary = cal->nextSummary(); | ||
983 | qDebug("KO: Next Alarm %s %s", nextA.toString().latin1(), summary.latin1()); | ||
984 | if ( nextA < QDateTime::currentDateTime().addDays( 720-1 ) ) { | ||
985 | KConfig *config = KOGlobals::config(); | ||
986 | config->setGroup("NextSystemAlarm"); | ||
987 | QString date, sum; | ||
988 | date = config->readEntry("TimeDateinSecs", "xxx"); | ||
989 | bool ok = false; | ||
990 | int shsecs = date.toInt(&ok ); | ||
991 | QDateTime scheduledAlarm; | ||
992 | QDateTime eventDateTime = cal->nextAlarmEvent(); | ||
993 | sum = config->readEntry("Summary", "sss"); | ||
994 | if ( ok ) { | ||
995 | scheduledAlarm = reference.addSecs( shsecs ); | ||
996 | //qDebug("sheduledAlarm %s ", scheduledAlarm.toString().latin1()); | ||
997 | if ( scheduledAlarm == nextA && sum == summary ) { | ||
998 | qDebug("KO: Same alarm time+summary - nothing to do! "); | ||
999 | return; | ||
1000 | } | ||
1001 | } | ||
1002 | if ( ok ) { | ||
1003 | // delete alarm from system | ||
1004 | //qDebug("delete Alarm %s ", scheduledAlarm.toString().latin1()); | ||
1005 | #ifndef DESKTOP_VERSION | ||
1006 | AlarmServer::deleteAlarm ( scheduledAlarm,"koalarm" , sum.latin1() ); | ||
1007 | #endif | ||
1008 | } | ||
1009 | // add new alarm to system | ||
1010 | qDebug("KO: Add Alarm: %s ", nextA.toString().latin1() ); | ||
1011 | #ifndef DESKTOP_VERSION | ||
1012 | AlarmServer::addAlarm ( nextA,"koalarm", summary.latin1() ); | ||
1013 | #endif | ||
1014 | // write new alarm to config file | ||
1015 | //qDebug("Entry %s %s ", date.latin1(), sum.latin1()); | ||
1016 | int secs = reference.secsTo( nextA ); | ||
1017 | //qDebug(" secs %d ", secs); | ||
1018 | setCaption( i18n("Next Alarm: ")+ nextA.toString() +"-"+summary ); | ||
1019 | config->writeEntry("TimeDateinSecs",QString::number ( secs )); | ||
1020 | config->writeEntry("Summary",summary); | ||
1021 | config->writeEntry("TimeDate",nextA.toString()); | ||
1022 | config->writeEntry("WriteDateTime",QDateTime::currentDateTime().toString()); | ||
1023 | config->writeEntry("EventStartDateTime",eventDateTime.toString()); | ||
1024 | config->writeEntry("SystemNotifyInSecs",QString::number (QDateTime::currentDateTime().secsTo( nextA ) )); | ||
1025 | config->sync(); | ||
1026 | |||
1027 | } | ||
1028 | } | ||
1029 | void MainWindow::save() | ||
1030 | { | ||
1031 | if ( mBlockSaveFlag ) | ||
1032 | return; | ||
1033 | |||
1034 | mBlockSaveFlag = true; | ||
1035 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | ||
1036 | setCaption("KO/Pi:Saving Data to File ..." ); | ||
1037 | qDebug("KO: Start saving data to file!"); | ||
1038 | mView->saveCalendar( defaultFileName() ); | ||
1039 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | ||
1040 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | ||
1041 | QString savemes; | ||
1042 | savemes.sprintf("KO/Pi:File Saved. Needed %d sec, %d ms",(msNeeded/1000)%100,msNeeded%1000 ); | ||
1043 | setCaption(savemes); | ||
1044 | mCalendarModifiedFlag = false; | ||
1045 | mBlockSaveFlag = false; | ||
1046 | } | ||
1047 | |||
1048 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | ||
1049 | { | ||
1050 | if ( !e->isAutoRepeat() ) { | ||
1051 | mFlagKeyPressed = false; | ||
1052 | } | ||
1053 | } | ||
1054 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | ||
1055 | { | ||
1056 | qApp->processEvents(); | ||
1057 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | ||
1058 | e->ignore(); | ||
1059 | // qDebug(" ignore %d",e->isAutoRepeat() ); | ||
1060 | return; | ||
1061 | } | ||
1062 | if (! e->isAutoRepeat() ) | ||
1063 | mFlagKeyPressed = true; | ||
1064 | KOPrefs *p = KOPrefs::instance(); | ||
1065 | bool showSelectedDates = false; | ||
1066 | int size; | ||
1067 | //qDebug("MainWindow::keyPressEvent "); | ||
1068 | switch ( e->key() ) { | ||
1069 | case Qt::Key_Right: | ||
1070 | if ( e->state() == Qt::ControlButton ) | ||
1071 | mView->goNextMonth(); | ||
1072 | else | ||
1073 | mView->goNext(); | ||
1074 | showSelectedDates = true; | ||
1075 | break; | ||
1076 | case Qt::Key_Left: | ||
1077 | if ( e->state() == Qt::ControlButton ) | ||
1078 | mView->goPreviousMonth(); | ||
1079 | else | ||
1080 | mView->goPrevious(); | ||
1081 | showSelectedDates = true; | ||
1082 | break; | ||
1083 | case Qt::Key_Down: | ||
1084 | mView->viewManager()->agendaView()->scrollOneHourDown(); | ||
1085 | break; | ||
1086 | case Qt::Key_Up: | ||
1087 | mView->viewManager()->agendaView()->scrollOneHourUp(); | ||
1088 | break; | ||
1089 | case Qt::Key_I: | ||
1090 | mView->showIncidence(); | ||
1091 | break; | ||
1092 | case Qt::Key_Delete: | ||
1093 | case Qt::Key_Backspace: | ||
1094 | mView->deleteIncidence(); | ||
1095 | break; | ||
1096 | case Qt::Key_D: | ||
1097 | mView->viewManager()->showDayView(); | ||
1098 | showSelectedDates = true; | ||
1099 | break; | ||
1100 | case Qt::Key_0: | ||
1101 | mView->toggleFilerEnabled( ); | ||
1102 | break; | ||
1103 | case Qt::Key_1: | ||
1104 | mView->selectFilter( 0 ); | ||
1105 | break; | ||
1106 | case Qt::Key_2: | ||
1107 | mView->selectFilter( 1 ); | ||
1108 | break; | ||
1109 | case Qt::Key_3: | ||
1110 | mView->selectFilter( 2 ); | ||
1111 | break; | ||
1112 | case Qt::Key_4: | ||
1113 | mView->selectFilter( 3 ); | ||
1114 | break; | ||
1115 | case Qt::Key_5: | ||
1116 | mView->viewManager()->showWorkWeekView(); | ||
1117 | showSelectedDates = true; | ||
1118 | break; | ||
1119 | case Qt::Key_7: | ||
1120 | mView->viewManager()->showWeekView(); | ||
1121 | showSelectedDates = true; | ||
1122 | break; | ||
1123 | case Qt::Key_M: | ||
1124 | mView->viewManager()->showMonthView(); | ||
1125 | showSelectedDates = true; | ||
1126 | break; | ||
1127 | case Qt::Key_Insert: | ||
1128 | mView->newEvent(); | ||
1129 | break; | ||
1130 | case Qt::Key_S : | ||
1131 | mView->dialogManager()->showSearchDialog(); | ||
1132 | break; | ||
1133 | case Qt::Key_H : | ||
1134 | keyBindings(); | ||
1135 | break; | ||
1136 | case Qt::Key_W: | ||
1137 | mView->viewManager()->showWhatsNextView(); | ||
1138 | break; | ||
1139 | case Qt::Key_L: | ||
1140 | mView->viewManager()->showListView(); | ||
1141 | break; | ||
1142 | case Qt::Key_N: | ||
1143 | mView->viewManager()->showNextXView(); | ||
1144 | showSelectedDates = true; | ||
1145 | break; | ||
1146 | case Qt::Key_V: | ||
1147 | mView->viewManager()->showTodoView(); | ||
1148 | break; | ||
1149 | case Qt::Key_C: | ||
1150 | mView->goNext(); | ||
1151 | showSelectedDates = true; | ||
1152 | break; | ||
1153 | case Qt::Key_P: | ||
1154 | mView->showDatePicker( ); | ||
1155 | break; | ||
1156 | case Qt::Key_F: | ||
1157 | mView->toggleFilter(); | ||
1158 | break; | ||
1159 | case Qt::Key_X: | ||
1160 | mView->goPrevious(); | ||
1161 | showSelectedDates = true; | ||
1162 | break; | ||
1163 | case Qt::Key_Space: | ||
1164 | mView->toggleExpand(); | ||
1165 | break; | ||
1166 | case Qt::Key_A: | ||
1167 | mView->toggleAllDaySize(); | ||
1168 | break; | ||
1169 | case Qt::Key_T: | ||
1170 | if ( e->state() == Qt::ControlButton ) | ||
1171 | mView->newTodo(); | ||
1172 | else { | ||
1173 | mView->goToday(); | ||
1174 | showSelectedDates = true; | ||
1175 | } | ||
1176 | break; | ||
1177 | case Qt::Key_J: | ||
1178 | mView->viewManager()->showJournalView(); | ||
1179 | break; | ||
1180 | case Qt::Key_Return: | ||
1181 | case Qt::Key_E: | ||
1182 | if ( e->state() == Qt::ControlButton ) | ||
1183 | mView->newEvent(); | ||
1184 | else | ||
1185 | mView->editIncidence(); | ||
1186 | break; | ||
1187 | case Qt::Key_Plus: | ||
1188 | size = p->mHourSize +2; | ||
1189 | if ( size <= 18 ) | ||
1190 | configureAgenda( size ); | ||
1191 | break; | ||
1192 | case Qt::Key_Minus: | ||
1193 | size = p->mHourSize - 2; | ||
1194 | if ( size >= 4 ) | ||
1195 | configureAgenda( size ); | ||
1196 | break; | ||
1197 | |||
1198 | |||
1199 | default: | ||
1200 | e->ignore(); | ||
1201 | } | ||
1202 | |||
1203 | if ( showSelectedDates ) { | ||
1204 | ;// setCaptionToDates(); | ||
1205 | } | ||
1206 | |||
1207 | } | ||
1208 | |||
1209 | void MainWindow::configureToolBar( int item ) | ||
1210 | { | ||
1211 | |||
1212 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | ||
1213 | KOPrefs *p = KOPrefs::instance(); | ||
1214 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | ||
1215 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | ||
1216 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | ||
1217 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | ||
1218 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | ||
1219 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | ||
1220 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | ||
1221 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | ||
1222 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | ||
1223 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | ||
1224 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | ||
1225 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | ||
1226 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | ||
1227 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | ||
1228 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | ||
1229 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | ||
1230 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | ||
1231 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | ||
1232 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | ||
1233 | initActions(); | ||
1234 | } | ||
1235 | |||
1236 | void MainWindow::setCaptionToDates() | ||
1237 | { | ||
1238 | QString selDates; | ||
1239 | selDates = mView->startDate().toString(); | ||
1240 | if (mView->startDate() < mView->endDate() ) | ||
1241 | selDates += " - " + mView->endDate().toString(); | ||
1242 | setCaption( "Dates: " + selDates ); | ||
1243 | |||
1244 | } | ||
1245 | // parameter item == 0: reinit | ||
1246 | void MainWindow::configureAgenda( int item ) | ||
1247 | { | ||
1248 | |||
1249 | KOPrefs *p = KOPrefs::instance(); | ||
1250 | |||
1251 | int i; | ||
1252 | if ( item == 1 ) { | ||
1253 | mView->toggleAllDaySize(); | ||
1254 | return; | ||
1255 | } | ||
1256 | // do not allow 4 for widgets higher than 480 | ||
1257 | if ( QApplication::desktop()->height() > 480 ) { | ||
1258 | if ( item == 4 ) | ||
1259 | item = 6; | ||
1260 | } | ||
1261 | for ( i = 4; i <= 18; i= i+2 ) | ||
1262 | configureAgendaMenu->setItemChecked( i, false ); | ||
1263 | configureAgendaMenu->setItemChecked( item, true ); | ||
1264 | if ( p->mHourSize == item ) | ||
1265 | return; | ||
1266 | p->mHourSize=item; | ||
1267 | mView->viewManager()->agendaView()->updateConfig(); | ||
1268 | } | ||
1269 | |||
1270 | void MainWindow::saveCalendar() | ||
1271 | { | ||
1272 | QString fn = KOPrefs::instance()->mLastSaveFile; | ||
1273 | fn = KFileDialog::getSaveFileName( fn, "Save backup filename", this ); | ||
1274 | |||
1275 | if ( fn == "" ) | ||
1276 | return; | ||
1277 | QFileInfo info; | ||
1278 | info.setFile( fn ); | ||
1279 | QString mes; | ||
1280 | bool createbup = true; | ||
1281 | if ( info. exists() ) { | ||
1282 | mes.sprintf( "Backup file\nalready exists!\nOld backup file from:\n%s\nOverwrite?\n",info.lastModified ().toString().latin1() ); | ||
1283 | int result = QMessageBox::warning( this, "KO/Pi: Warning!",mes, | ||
1284 | "Overwrite!", "Cancel", 0, | ||
1285 | 0, 1 ); | ||
1286 | if ( result != 0 ) { | ||
1287 | createbup = false; | ||
1288 | } | ||
1289 | } | ||
1290 | if ( createbup ) { | ||
1291 | mView->saveCalendar( fn ); | ||
1292 | mes.sprintf("KO/Pi:Saved %s",fn.latin1() ); | ||
1293 | KOPrefs::instance()->mLastSaveFile = fn; | ||
1294 | setCaption(mes); | ||
1295 | } | ||
1296 | } | ||
1297 | void MainWindow::loadCalendar() | ||
1298 | { | ||
1299 | |||
1300 | QString fn = KOPrefs::instance()->mLastLoadFile; | ||
1301 | fn = KFileDialog::getOpenFileName( fn, "Load backup filename", this ); | ||
1302 | |||
1303 | if ( fn == "" ) | ||
1304 | return; | ||
1305 | QFileInfo info; | ||
1306 | info.setFile( fn ); | ||
1307 | QString mess; | ||
1308 | bool loadbup = true; | ||
1309 | if ( info. exists() ) { | ||
1310 | mess.sprintf( "Backup file from:\n%s\nLoading backup\nfile will delete\nyour current Data!\n",info.lastModified ().toString().latin1() ); | ||
1311 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | ||
1312 | mess, | ||
1313 | "Load!", "Cancel", 0, | ||
1314 | 0, 1 ); | ||
1315 | if ( result != 0 ) { | ||
1316 | loadbup = false; | ||
1317 | } | ||
1318 | } else { | ||
1319 | QMessageBox::warning( this, "KO/Pi: Warning!", | ||
1320 | "Backup file\ndoes not exist!\n" | ||
1321 | "Nothing loaded!", 0, 0, | ||
1322 | 0, 1 ); | ||
1323 | |||
1324 | return; | ||
1325 | } | ||
1326 | if ( loadbup ) { | ||
1327 | mView->openCalendar( fn ); | ||
1328 | KOPrefs::instance()->mLastLoadFile = fn; | ||
1329 | mess.sprintf("KO/Pi:Loaded %s",fn.latin1() ); | ||
1330 | setCaption(mess); | ||
1331 | } | ||
1332 | |||
1333 | } | ||
1334 | void MainWindow::quickImportIcal() | ||
1335 | { | ||
1336 | importFile( KOPrefs::instance()->mLastImportFile, false ); | ||
1337 | } | ||
1338 | void MainWindow::importFile( QString fn, bool quick ) | ||
1339 | { | ||
1340 | QFileInfo info; | ||
1341 | info.setFile( fn ); | ||
1342 | QString mess; | ||
1343 | bool loadbup = true; | ||
1344 | if ( !info. exists() ) { | ||
1345 | mess= "Import file \n..."+fn.right( 30)+ "\ndoes not exist!\nNothing imported!\n"; | ||
1346 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | ||
1347 | mess ); | ||
1348 | return; | ||
1349 | } | ||
1350 | int result = 0; | ||
1351 | if ( !quick ) { | ||
1352 | mess.sprintf( "Import file \n..."+fn.right( 25)+"\nfrom:\n%s\nDuplicated entries\nwill not be imported!\n",info.lastModified ().toString().latin1() ); | ||
1353 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | ||
1354 | mess, | ||
1355 | "Import", "Cancel", 0, | ||
1356 | 0, 1 ); | ||
1357 | } | ||
1358 | if ( result == 0 ) { | ||
1359 | if ( mView->openCalendar( fn, true )) { | ||
1360 | KOPrefs::instance()->mLastImportFile = fn; | ||
1361 | setCaption(i18n(" ")); | ||
1362 | setCaption(i18n("Imported file successfully")); | ||
1363 | } else { | ||
1364 | setCaption(i18n("Error importing file")); | ||
1365 | } | ||
1366 | } | ||
1367 | } | ||
1368 | void MainWindow::importIcal() | ||
1369 | { | ||
1370 | |||
1371 | QString fn =KOPrefs::instance()->mLastImportFile; | ||
1372 | |||
1373 | fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this ); | ||
1374 | if ( fn == "" ) | ||
1375 | return; | ||
1376 | importFile( fn, true ); | ||
1377 | |||
1378 | } | ||
1379 | |||
1380 | void MainWindow::exportVCalendar() | ||
1381 | { | ||
1382 | QString fn = KOPrefs::instance()->mLastVcalFile; | ||
1383 | fn = KFileDialog::getSaveFileName( fn, "Export vcal filename(*.vcs)", this ); | ||
1384 | if ( fn == "" ) | ||
1385 | return; | ||
1386 | QFileInfo info; | ||
1387 | info.setFile( fn ); | ||
1388 | QString mes; | ||
1389 | bool createbup = true; | ||
1390 | if ( info. exists() ) { | ||
1391 | mes.sprintf( i18n("Save file\nalready exists!\nOld save file from:\n%s\nOverwrite?\n"),info.lastModified ().toString().latin1() ); | ||
1392 | int result = QMessageBox::warning( this, "KO/Pi: Warning!",mes, | ||
1393 | "Overwrite!", "Cancel", 0, | ||
1394 | 0, 1 ); | ||
1395 | if ( result != 0 ) { | ||
1396 | createbup = false; | ||
1397 | } | ||
1398 | } | ||
1399 | if ( createbup ) { | ||
1400 | if ( mView->exportVCalendar( fn ) ) { | ||
1401 | KOPrefs::instance()->mLastVcalFile = fn; | ||
1402 | if ( fn.length() > 20 ) | ||
1403 | mes.sprintf(i18n("KO/Pi:Exported to ...%s"),(fn.right(20)).latin1() ); | ||
1404 | else | ||
1405 | mes.sprintf(i18n("KO/Pi:Exported to %s"),fn.latin1() ); | ||
1406 | setCaption(mes); | ||
1407 | } | ||
1408 | } | ||
1409 | |||
1410 | } | ||
1411 | |||
1412 | QString MainWindow::getPassword( ) | ||
1413 | { | ||
1414 | QString retfile = ""; | ||
1415 | QDialog dia ( this, "input-dialog", true ); | ||
1416 | QLineEdit lab ( &dia ); | ||
1417 | lab.setEchoMode( QLineEdit::Password ); | ||
1418 | QVBoxLayout lay( &dia ); | ||
1419 | lay.setMargin(7); | ||
1420 | lay.setSpacing(7); | ||
1421 | lay.addWidget( &lab); | ||
1422 | dia.setFixedSize( 230,50 ); | ||
1423 | dia.setCaption( i18n("Input password") ); | ||
1424 | dia.show(); | ||
1425 | int res = dia.exec(); | ||
1426 | if ( res ) | ||
1427 | retfile = lab.text(); | ||
1428 | return retfile; | ||
1429 | |||
1430 | } | ||
1431 | #ifndef _WIN32_ | ||
1432 | #include <unistd.h> | ||
1433 | #endif | ||
1434 | void MainWindow::syncLocalFile() | ||
1435 | { | ||
1436 | |||
1437 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | ||
1438 | |||
1439 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | ||
1440 | if ( fn == "" ) | ||
1441 | return; | ||
1442 | syncWithFile( fn, false ); | ||
1443 | |||
1444 | } | ||
1445 | |||
1446 | void MainWindow::syncWithFile( QString fn , bool quick ) | ||
1447 | { | ||
1448 | QFileInfo info; | ||
1449 | info.setFile( fn ); | ||
1450 | QString mess; | ||
1451 | bool loadbup = true; | ||
1452 | if ( !info. exists() ) { | ||
1453 | mess.sprintf( i18n( "Sync file \n...%s\ndoes not exist!\nNothing synced!\n"),fn.right( 30).latin1() ); | ||
1454 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | ||
1455 | mess ); | ||
1456 | return; | ||
1457 | } | ||
1458 | int result = 0; | ||
1459 | if ( !quick ) { | ||
1460 | mess.sprintf( "Sync with file \n..."+fn.right( 25)+"\nfrom:\n%s\n",info.lastModified ().toString().latin1() ); | ||
1461 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
1462 | mess, | ||
1463 | i18n("Sync"), i18n("Cancel"), 0, | ||
1464 | 0, 1 ); | ||
1465 | } | ||
1466 | if ( KOPrefs::instance()->mAskForPreferences ) | ||
1467 | mView->edit_sync_options(); | ||
1468 | if ( result == 0 ) { | ||
1469 | qDebug("Now sycing ... "); | ||
1470 | mView->syncCalendar( fn, true ); | ||
1471 | if ( ! quick ) | ||
1472 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | ||
1473 | } | ||
1474 | |||
1475 | } | ||
1476 | |||
1477 | void MainWindow::quickSyncLocalFile() | ||
1478 | { | ||
1479 | qDebug("quickSyncLocalFile() "); | ||
1480 | syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ); | ||
1481 | } | ||
1482 | |||
1483 | void MainWindow::syncSSH() | ||
1484 | { | ||
1485 | QTime timer; | ||
1486 | timer.start(); | ||
1487 | qDebug("MainWindow::syncssh() "); | ||
1488 | KOPrefs *p = KOPrefs::instance(); | ||
1489 | QString localFile = p->mLocalTempFile; | ||
1490 | QString remoteIP = p->mRemoteIP; | ||
1491 | QString remoteUser = p->mRemoteUser; | ||
1492 | QString remoteFile = p->mRemoteFile; | ||
1493 | if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) | ||
1494 | remoteUser += ":" + p->mRemotePassWd; | ||
1495 | |||
1496 | QString question = i18n("Do you really want\nto remote sync?\n \n") + | ||
1497 | i18n("IP: " ) +remoteIP +"\n" + | ||
1498 | i18n("User: " ) + remoteUser +"\n" ; | ||
1499 | int maxlen = 30; | ||
1500 | if ( QApplication::desktop()->width() > 320 ) | ||
1501 | maxlen += 25; | ||
1502 | if ( remoteFile.length() > maxlen ) | ||
1503 | question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; | ||
1504 | else | ||
1505 | question += i18n("Remote file:\n " ) + remoteFile +"\n"; | ||
1506 | if ( localFile.length() > maxlen ) | ||
1507 | question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; | ||
1508 | else | ||
1509 | question += i18n("Local temp file:\n " ) + localFile +"\n"; | ||
1510 | |||
1511 | if ( QMessageBox::information( this, "KO/Pi Sync", | ||
1512 | question, | ||
1513 | i18n("Yes"), i18n("No"), | ||
1514 | 0, 0 ) != 0 ) | ||
1515 | return; | ||
1516 | if ( !p->mUsePassWd ) { | ||
1517 | QString pass = getPassword(); | ||
1518 | if ( pass.length() > 0 ) | ||
1519 | remoteUser += ":" + pass; | ||
1520 | } | ||
1521 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; | ||
1522 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | ||
1523 | int fileSize = 0; | ||
1524 | int result = system ( command ); | ||
1525 | // 0 : okay | ||
1526 | // 256: no such file or dir | ||
1527 | // | ||
1528 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | ||
1529 | if ( result != 0 ) { | ||
1530 | int len = maxlen; | ||
1531 | while ( len < command.length() ) { | ||
1532 | command.insert( len , "\n" ); | ||
1533 | len += maxlen +2; | ||
1534 | } | ||
1535 | question = i18n("Sorry, the copy command failed!\nCommand was:\n") + command + "\n \nTry command on console to get more\ndetailed info about the reason.\n"; | ||
1536 | QMessageBox::information( this, "KO/Pi Sync - ERROR", | ||
1537 | question, | ||
1538 | i18n("Okay!")) ; | ||
1539 | return; | ||
1540 | } | ||
1541 | |||
1542 | |||
1543 | setCaption ( i18n( "Copying succeed. Syncing not yet implemented" ) ); | ||
1544 | syncWithFile(localFile , true ); | ||
1545 | return; | ||
1546 | #if 0 | ||
1547 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); | ||
1548 | while ( timer.elapsed() < 5000 ) | ||
1549 | qApp->processEvents(); | ||
1550 | |||
1551 | qDebug("MainWindow::merging) "); | ||
1552 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); | ||
1553 | while ( mBlockSaveFlag ) | ||
1554 | qApp->processEvents(); | ||
1555 | save(); | ||
1556 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); | ||
1557 | #endif | ||
1558 | |||
1559 | } | ||
1560 | */ | ||
1561 | |||