author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /korganizer/mainwindow.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | korganizer/mainwindow.cpp | 1974 |
1 files changed, 1974 insertions, 0 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp new file mode 100644 index 0000000..40f2cf4 --- a/dev/null +++ b/korganizer/mainwindow.cpp | |||
@@ -0,0 +1,1974 @@ | |||
1 | #include <stdlib.h> | ||
2 | |||
3 | #include <qaction.h> | ||
4 | #include <qpopupmenu.h> | ||
5 | #include <qpainter.h> | ||
6 | #include <qwhatsthis.h> | ||
7 | #include <qmessagebox.h> | ||
8 | #include <qlineedit.h> | ||
9 | #include <qfile.h> | ||
10 | #include <qdir.h> | ||
11 | #include <qapp.h> | ||
12 | #include <qfileinfo.h> | ||
13 | #include <qlabel.h> | ||
14 | #include <qwmatrix.h> | ||
15 | #include <qtextbrowser.h> | ||
16 | #include <qtextstream.h> | ||
17 | #ifndef DESKTOP_VERSION | ||
18 | #include <qpe/global.h> | ||
19 | #include <qpe/qpemenubar.h> | ||
20 | #include <qpe/qpetoolbar.h> | ||
21 | #include <qpe/resource.h> | ||
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <qtopia/alarmserver.h> | ||
24 | #include <qtopia/qcopenvelope_qws.h> | ||
25 | #else | ||
26 | #include <qmenubar.h> | ||
27 | #include <qtoolbar.h> | ||
28 | #include <qapplication.h> | ||
29 | //#include <resource.h> | ||
30 | |||
31 | #endif | ||
32 | #include <libkcal/calendarlocal.h> | ||
33 | #include <libkcal/todo.h> | ||
34 | #include <libkdepim/ksyncprofile.h> | ||
35 | #include <libkdepim/kincidenceformatter.h> | ||
36 | |||
37 | #include "calendarview.h" | ||
38 | #include "koviewmanager.h" | ||
39 | #include "datenavigator.h" | ||
40 | #include "koagendaview.h" | ||
41 | #include "koagenda.h" | ||
42 | #include "kodialogmanager.h" | ||
43 | #include "kdialogbase.h" | ||
44 | #include "kstandarddirs.h" | ||
45 | #include "koprefs.h" | ||
46 | #include "kfiledialog.h" | ||
47 | #include "koglobals.h" | ||
48 | #include "kglobal.h" | ||
49 | #include "klocale.h" | ||
50 | #include "kconfig.h" | ||
51 | #include "simplealarmclient.h" | ||
52 | |||
53 | using namespace KCal; | ||
54 | #ifndef _WIN32_ | ||
55 | #include <unistd.h> | ||
56 | #endif | ||
57 | #include "mainwindow.h" | ||
58 | |||
59 | int globalFlagBlockStartup; | ||
60 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | ||
61 | QMainWindow( parent, name ) | ||
62 | { | ||
63 | |||
64 | #ifdef DESKTOP_VERSION | ||
65 | setFont( QFont("Arial"), 14 ); | ||
66 | #endif | ||
67 | |||
68 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | ||
69 | QString confFile = locateLocal("config","korganizerrc"); | ||
70 | QFileInfo finf ( confFile ); | ||
71 | bool showWarning = !finf.exists(); | ||
72 | setIcon(SmallIcon( "ko24" ) ); | ||
73 | mBlockAtStartup = true; | ||
74 | mFlagKeyPressed = false; | ||
75 | setCaption("KOrganizer/Pi"); | ||
76 | KOPrefs *p = KOPrefs::instance(); | ||
77 | // if ( QApplication::desktop()->height() > 480 ) { | ||
78 | // if ( p->mHourSize == 4 ) | ||
79 | // p->mHourSize = 6; | ||
80 | // } | ||
81 | if ( p->mHourSize > 18 ) | ||
82 | p->mHourSize = 18; | ||
83 | QMainWindow::ToolBarDock tbd; | ||
84 | if ( p->mToolBarHor ) { | ||
85 | if ( p->mToolBarUp ) | ||
86 | tbd = Bottom; | ||
87 | else | ||
88 | tbd = Top; | ||
89 | } | ||
90 | else { | ||
91 | if ( p->mToolBarUp ) | ||
92 | tbd = Right; | ||
93 | else | ||
94 | tbd = Left; | ||
95 | } | ||
96 | if ( KOPrefs::instance()->mUseAppColors ) | ||
97 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | ||
98 | globalFlagBlockStartup = 1; | ||
99 | iconToolBar = new QPEToolBar( this ); | ||
100 | addToolBar (iconToolBar , tbd ); | ||
101 | mBlockSaveFlag = false; | ||
102 | mCalendarModifiedFlag = false; | ||
103 | |||
104 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | ||
105 | splash->setAlignment ( AlignCenter ); | ||
106 | setCentralWidget( splash ); | ||
107 | #ifndef DESKTOP_VERSION | ||
108 | showMaximized(); | ||
109 | #endif | ||
110 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | ||
111 | setDefaultPreferences(); | ||
112 | mCalendar = new CalendarLocal(); | ||
113 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | ||
114 | mView->hide(); | ||
115 | //mView->resize(splash->size() ); | ||
116 | initActions(); | ||
117 | #ifndef DESKTOP_VERSION | ||
118 | iconToolBar->show(); | ||
119 | qApp->processEvents(); | ||
120 | #endif | ||
121 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | ||
122 | int vh = height() ; | ||
123 | int vw = width(); | ||
124 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | ||
125 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | ||
126 | vh -= iconToolBar->height(); | ||
127 | } else { | ||
128 | vw -= iconToolBar->height(); | ||
129 | } | ||
130 | //mView->setMaximumSize( splash->size() ); | ||
131 | //mView->resize( splash->size() ); | ||
132 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | ||
133 | mView->readSettings(); | ||
134 | bool oldOpened = false; | ||
135 | bool newFile = false; | ||
136 | if( !QFile::exists( defaultFileName() ) ) { | ||
137 | QFileInfo finfo ( defaultFileName() ); | ||
138 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | ||
139 | qDebug("oldfile %s ", oldFile.latin1()); | ||
140 | 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"; | ||
141 | finfo.setFile( oldFile ); | ||
142 | if (finfo.exists() ) { | ||
143 | KMessageBox::information( this, message); | ||
144 | mView->openCalendar( oldFile ); | ||
145 | qApp->processEvents(); | ||
146 | } else { | ||
147 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | ||
148 | finfo.setFile( oldFile ); | ||
149 | if (finfo.exists() ) { | ||
150 | KMessageBox::information( this, message); | ||
151 | mView->openCalendar( oldFile ); | ||
152 | qApp->processEvents(); | ||
153 | } | ||
154 | } | ||
155 | mView->saveCalendar( defaultFileName() ); | ||
156 | newFile = true; | ||
157 | } | ||
158 | |||
159 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | ||
160 | if ( ! oldOpened ) | ||
161 | mView->openCalendar( defaultFileName() ); | ||
162 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | ||
163 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | ||
164 | |||
165 | if ( KOPrefs::instance()->mLanguageChanged ) { | ||
166 | KOPrefs::instance()->setCategoryDefaults(); | ||
167 | int count = mView->addCategories(); | ||
168 | KOPrefs::instance()->mLanguageChanged = false; | ||
169 | } | ||
170 | processIncidenceSelection( 0 ); | ||
171 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | ||
172 | SLOT( processIncidenceSelection( Incidence * ) ) ); | ||
173 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | ||
174 | SLOT( slotModifiedChanged( bool ) ) ); | ||
175 | |||
176 | |||
177 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | ||
178 | mView->setModified( false ); | ||
179 | mBlockAtStartup = false; | ||
180 | mView->setModified( false ); | ||
181 | setCentralWidget( mView ); | ||
182 | globalFlagBlockStartup = 0; | ||
183 | mView->show(); | ||
184 | delete splash; | ||
185 | if ( newFile ) | ||
186 | mView->updateConfig(); | ||
187 | // qApp->processEvents(); | ||
188 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | ||
189 | fillSyncMenu(); | ||
190 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | ||
191 | if ( showWarning ) { | ||
192 | KMessageBox::information( this, | ||
193 | "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"); | ||
194 | qApp->processEvents(); | ||
195 | mView->dialogManager()->showSyncOptions(); | ||
196 | } | ||
197 | } | ||
198 | MainWindow::~MainWindow() | ||
199 | { | ||
200 | //qDebug("MainWindow::~MainWindow() "); | ||
201 | //save toolbar location | ||
202 | |||
203 | delete mCalendar; | ||
204 | delete KOPrefs::instance(); | ||
205 | delete KIncidenceFormatter::instance(); | ||
206 | |||
207 | |||
208 | } | ||
209 | void MainWindow::closeEvent( QCloseEvent* ce ) | ||
210 | { | ||
211 | |||
212 | |||
213 | |||
214 | if ( ! KOPrefs::instance()->mAskForQuit ) { | ||
215 | saveOnClose(); | ||
216 | ce->accept(); | ||
217 | return; | ||
218 | |||
219 | } | ||
220 | |||
221 | switch( QMessageBox::information( this, "KO/Pi", | ||
222 | i18n("Do you really want\nto close KO/Pi?"), | ||
223 | i18n("Close"), i18n("No"), | ||
224 | 0, 0 ) ) { | ||
225 | case 0: | ||
226 | saveOnClose(); | ||
227 | ce->accept(); | ||
228 | break; | ||
229 | case 1: | ||
230 | ce->ignore(); | ||
231 | break; | ||
232 | case 2: | ||
233 | |||
234 | default: | ||
235 | break; | ||
236 | } | ||
237 | |||
238 | |||
239 | } | ||
240 | |||
241 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | ||
242 | { | ||
243 | QDataStream stream( data, IO_ReadOnly ); | ||
244 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | ||
245 | //QString datamess; | ||
246 | //qDebug("message "); | ||
247 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | ||
248 | if ( cmsg == "-writeFile" ) { | ||
249 | // I made from the "-writeFile" an "-writeAlarm" | ||
250 | mView->viewManager()->showWhatsNextView(); | ||
251 | mCalendar->checkAlarmForIncidence( 0, true); | ||
252 | showMaximized(); | ||
253 | raise(); | ||
254 | return; | ||
255 | |||
256 | } | ||
257 | if ( cmsg == "-writeFileSilent" ) { | ||
258 | // I made from the "-writeFile" an "-writeAlarm" | ||
259 | // mView->viewManager()->showWhatsNextView(); | ||
260 | mCalendar->checkAlarmForIncidence( 0, true); | ||
261 | //showMaximized(); | ||
262 | //raise(); | ||
263 | hide(); | ||
264 | return; | ||
265 | } | ||
266 | if ( cmsg == "-newCountdown" ) { | ||
267 | qDebug("newCountdown "); | ||
268 | |||
269 | } | ||
270 | QString msg ; | ||
271 | QString allmsg = cmsg; | ||
272 | while ( allmsg.length() > 0 ) { | ||
273 | int nextC = allmsg.find( "-", 1 ); | ||
274 | if ( nextC == -1 ) { | ||
275 | msg = allmsg; | ||
276 | allmsg = ""; | ||
277 | } else{ | ||
278 | msg = allmsg.left( nextC ); | ||
279 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | ||
280 | } | ||
281 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | ||
282 | if ( msg == "-newEvent" ) { | ||
283 | mView->newEvent(); | ||
284 | } | ||
285 | if ( msg == "-newTodo" ) { | ||
286 | mView->newTodo(); | ||
287 | |||
288 | } | ||
289 | if ( msg == "-showWN" ) { | ||
290 | mView->viewManager()->showWhatsNextView(); | ||
291 | } | ||
292 | if ( msg == "-showTodo" ) { | ||
293 | mView->viewManager()->showTodoView(); | ||
294 | } | ||
295 | if ( msg == "-showList" ) { | ||
296 | mView->viewManager()->showListView(); | ||
297 | } | ||
298 | else if ( msg == "-showDay" ) { | ||
299 | mView->viewManager()->showDayView(); | ||
300 | } | ||
301 | else if ( msg == "-showWWeek" ) { | ||
302 | mView->viewManager()->showWorkWeekView(); | ||
303 | } | ||
304 | else if ( msg == "-ringSync" ) { | ||
305 | multiSync( false ); | ||
306 | } | ||
307 | else if ( msg == "-showWeek" ) { | ||
308 | mView->viewManager()->showWeekView(); | ||
309 | } | ||
310 | else if ( msg == "-showTodo" ) { | ||
311 | mView->viewManager()->showTodoView(); | ||
312 | } | ||
313 | else if ( msg == "-showJournal" ) { | ||
314 | mView->dateNavigator()->selectDates( 1 ); | ||
315 | mView->dateNavigator()->selectToday(); | ||
316 | mView->viewManager()->showJournalView(); | ||
317 | } | ||
318 | else if ( msg == "-showKO" ) { | ||
319 | mView->viewManager()->showNextXView(); | ||
320 | } | ||
321 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | ||
322 | mView->viewManager()->showWhatsNextView(); | ||
323 | } | ||
324 | else if ( msg == "-showNextXView" ) { | ||
325 | mView->viewManager()->showNextXView(); | ||
326 | } | ||
327 | |||
328 | |||
329 | } | ||
330 | |||
331 | showMaximized(); | ||
332 | raise(); | ||
333 | } | ||
334 | |||
335 | QPixmap MainWindow::loadPixmap( QString name ) | ||
336 | { | ||
337 | return SmallIcon( name ); | ||
338 | |||
339 | } | ||
340 | void MainWindow::initActions() | ||
341 | { | ||
342 | //KOPrefs::instance()->mShowFullMenu | ||
343 | iconToolBar->clear(); | ||
344 | KOPrefs *p = KOPrefs::instance(); | ||
345 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | ||
346 | |||
347 | QPopupMenu *viewMenu = new QPopupMenu( this ); | ||
348 | QPopupMenu *actionMenu = new QPopupMenu( this ); | ||
349 | QPopupMenu *importMenu = new QPopupMenu( this ); | ||
350 | |||
351 | syncMenu = new QPopupMenu( this ); | ||
352 | configureAgendaMenu = new QPopupMenu( this ); | ||
353 | configureToolBarMenu = new QPopupMenu( this ); | ||
354 | QPopupMenu *helpMenu = new QPopupMenu( this ); | ||
355 | if ( KOPrefs::instance()->mShowFullMenu ) { | ||
356 | QMenuBar *menuBar1; | ||
357 | menuBar1 = menuBar(); | ||
358 | menuBar1->insertItem( i18n("File"), importMenu ); | ||
359 | menuBar1->insertItem( i18n("View"), viewMenu ); | ||
360 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | ||
361 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | ||
362 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | ||
363 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | ||
364 | menuBar1->insertItem( i18n("Help"), helpMenu ); | ||
365 | } else { | ||
366 | QPEMenuBar *menuBar1; | ||
367 | menuBar1 = new QPEMenuBar( iconToolBar ); | ||
368 | QPopupMenu *menuBar = new QPopupMenu( this ); | ||
369 | menuBar1->insertItem( i18n("ME"), menuBar); | ||
370 | menuBar->insertItem( i18n("File"), importMenu ); | ||
371 | menuBar->insertItem( i18n("View"), viewMenu ); | ||
372 | menuBar->insertItem( i18n("Actions"), actionMenu ); | ||
373 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | ||
374 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | ||
375 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | ||
376 | menuBar->insertItem( i18n("Help"), helpMenu ); | ||
377 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | ||
378 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | ||
379 | } | ||
380 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | ||
381 | // ****************** | ||
382 | QAction *action; | ||
383 | QIconSet icon; | ||
384 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | ||
385 | configureToolBarMenu->setCheckable( true ); | ||
386 | |||
387 | QString pathString = ""; | ||
388 | if ( !p->mToolBarMiniIcons ) { | ||
389 | if ( QApplication::desktop()->width() < 480 ) | ||
390 | pathString += "icons16/"; | ||
391 | } else | ||
392 | pathString += "iconsmini/"; | ||
393 | configureAgendaMenu->setCheckable( true ); | ||
394 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | ||
395 | configureAgendaMenu->insertSeparator(); | ||
396 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | ||
397 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | ||
398 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | ||
399 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | ||
400 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | ||
401 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | ||
402 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | ||
403 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | ||
404 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | ||
405 | |||
406 | icon = loadPixmap( pathString + "configure" ); | ||
407 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | ||
408 | action->addTo( actionMenu ); | ||
409 | connect( action, SIGNAL( activated() ), | ||
410 | mView, SLOT( edit_options() ) ); | ||
411 | actionMenu->insertSeparator(); | ||
412 | icon = loadPixmap( pathString + "newevent" ); | ||
413 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | ||
414 | configureToolBarMenu->insertSeparator(); | ||
415 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | ||
416 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | ||
417 | ne_action->addTo( actionMenu ); | ||
418 | connect( ne_action, SIGNAL( activated() ), | ||
419 | mView, SLOT( newEvent() ) ); | ||
420 | icon = loadPixmap( pathString + "newtodo" ); | ||
421 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | ||
422 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | ||
423 | nt_action->addTo( actionMenu ); | ||
424 | connect( nt_action, SIGNAL( activated() ), | ||
425 | mView, SLOT( newTodo() ) ); | ||
426 | icon = loadPixmap( pathString + "navi" ); | ||
427 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | ||
428 | action->addTo( viewMenu ); | ||
429 | connect( action, SIGNAL( activated() ), | ||
430 | mView, SLOT( toggleDateNavigatorWidget() ) ); | ||
431 | icon = loadPixmap( pathString + "filter" ); | ||
432 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | ||
433 | action->addTo( viewMenu ); | ||
434 | connect( action, SIGNAL( activated() ), | ||
435 | mView, SLOT( toggleFilter() ) ); | ||
436 | |||
437 | |||
438 | viewMenu->insertSeparator(); | ||
439 | icon = loadPixmap( pathString + "picker" ); | ||
440 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | ||
441 | action->addTo( viewMenu ); | ||
442 | connect( action, SIGNAL( activated() ), | ||
443 | mView, SLOT( showDatePicker() ) ); | ||
444 | action->addTo( iconToolBar ); | ||
445 | viewMenu->insertSeparator(); | ||
446 | icon = loadPixmap( pathString + "list" ); | ||
447 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | ||
448 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | ||
449 | showlist_action->addTo( viewMenu ); | ||
450 | connect( showlist_action, SIGNAL( activated() ), | ||
451 | mView->viewManager(), SLOT( showListView() ) ); | ||
452 | |||
453 | |||
454 | icon = loadPixmap( pathString + "day" ); | ||
455 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | ||
456 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | ||
457 | day1_action->addTo( viewMenu ); | ||
458 | // action->addTo( toolBar ); | ||
459 | connect( day1_action, SIGNAL( activated() ), | ||
460 | mView->viewManager(), SLOT( showDayView() ) ); | ||
461 | |||
462 | icon = loadPixmap( pathString + "workweek" ); | ||
463 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | ||
464 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | ||
465 | day5_action->addTo( viewMenu ); | ||
466 | connect( day5_action, SIGNAL( activated() ), | ||
467 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | ||
468 | |||
469 | icon = loadPixmap( pathString + "week" ); | ||
470 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | ||
471 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | ||
472 | day7_action->addTo( viewMenu ); | ||
473 | connect( day7_action, SIGNAL( activated() ), | ||
474 | mView->viewManager(), SLOT( showWeekView() ) ); | ||
475 | |||
476 | icon = loadPixmap( pathString + "month" ); | ||
477 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | ||
478 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | ||
479 | month_action->addTo( viewMenu ); | ||
480 | connect( month_action, SIGNAL( activated() ), | ||
481 | mView->viewManager(), SLOT( showMonthView() ) ); | ||
482 | |||
483 | icon = loadPixmap( pathString + "todo" ); | ||
484 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | ||
485 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | ||
486 | todoview_action->addTo( viewMenu ); | ||
487 | connect( todoview_action, SIGNAL( activated() ), | ||
488 | mView->viewManager(), SLOT( showTodoView() ) ); | ||
489 | |||
490 | icon = loadPixmap( pathString + "journal" ); | ||
491 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | ||
492 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | ||
493 | viewjournal_action->addTo( viewMenu ); | ||
494 | connect( viewjournal_action, SIGNAL( activated() ), | ||
495 | mView->viewManager(), SLOT( showJournalView() ) ); | ||
496 | |||
497 | icon = loadPixmap( pathString + "xdays" ); | ||
498 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | ||
499 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | ||
500 | xdays_action->addTo( viewMenu ); | ||
501 | connect( xdays_action, SIGNAL( activated() ), | ||
502 | mView->viewManager(), SLOT( showNextXView() ) ); | ||
503 | |||
504 | icon = loadPixmap( pathString + "whatsnext" ); | ||
505 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | ||
506 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | ||
507 | whatsnext_action->addTo( viewMenu ); | ||
508 | connect( whatsnext_action, SIGNAL( activated() ), | ||
509 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | ||
510 | |||
511 | #if 0 | ||
512 | action = new QAction( "view_timespan", "Time Span", 0, this ); | ||
513 | action->addTo( viewMenu ); | ||
514 | connect( action, SIGNAL( activated() ), | ||
515 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | ||
516 | #endif | ||
517 | |||
518 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | ||
519 | this ); | ||
520 | mNewSubTodoAction->addTo( actionMenu ); | ||
521 | connect( mNewSubTodoAction, SIGNAL( activated() ), | ||
522 | mView, SLOT( newSubTodo() ) ); | ||
523 | |||
524 | actionMenu->insertSeparator(); | ||
525 | |||
526 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | ||
527 | mShowAction->addTo( actionMenu ); | ||
528 | connect( mShowAction, SIGNAL( activated() ), | ||
529 | mView, SLOT( showIncidence() ) ); | ||
530 | |||
531 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | ||
532 | mEditAction->addTo( actionMenu ); | ||
533 | connect( mEditAction, SIGNAL( activated() ), | ||
534 | mView, SLOT( editIncidence() ) ); | ||
535 | |||
536 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | ||
537 | mDeleteAction->addTo( actionMenu ); | ||
538 | connect( mDeleteAction, SIGNAL( activated() ), | ||
539 | mView, SLOT( deleteIncidence() ) ); | ||
540 | |||
541 | actionMenu->insertSeparator(); | ||
542 | |||
543 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | ||
544 | this ); | ||
545 | action->addTo( actionMenu ); | ||
546 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | ||
547 | |||
548 | icon = loadPixmap( pathString + "search" ); | ||
549 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | ||
550 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | ||
551 | search_action->addTo( actionMenu ); | ||
552 | connect( search_action, SIGNAL( activated() ), | ||
553 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | ||
554 | |||
555 | icon = loadPixmap( pathString + "today" ); | ||
556 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | ||
557 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | ||
558 | today_action->addTo( actionMenu ); | ||
559 | connect( today_action, SIGNAL( activated() ), | ||
560 | mView, SLOT( goToday() ) ); | ||
561 | |||
562 | if ( KOPrefs::instance()->mShowFullMenu ) { | ||
563 | actionMenu->insertSeparator(); | ||
564 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | ||
565 | |||
566 | } | ||
567 | // actionMenu->insertSeparator(); | ||
568 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | ||
569 | this ); | ||
570 | action->addTo( importMenu ); | ||
571 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | ||
572 | action = new QAction( "import_quick", i18n("Import last file"), 0, | ||
573 | this ); | ||
574 | action->addTo( importMenu ); | ||
575 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | ||
576 | importMenu->insertSeparator(); | ||
577 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | ||
578 | this ); | ||
579 | action->addTo( importMenu ); | ||
580 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | ||
581 | #ifndef DESKTOP_VERSION | ||
582 | importMenu->insertSeparator(); | ||
583 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | ||
584 | this ); | ||
585 | action->addTo( importMenu ); | ||
586 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | ||
587 | #endif | ||
588 | |||
589 | importMenu->insertSeparator(); | ||
590 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | ||
591 | this ); | ||
592 | action->addTo( importMenu ); | ||
593 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | ||
594 | |||
595 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | ||
596 | this ); | ||
597 | action->addTo( importMenu ); | ||
598 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | ||
599 | |||
600 | importMenu->insertSeparator(); | ||
601 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | ||
602 | this ); | ||
603 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | ||
604 | importMenu->insertSeparator(); | ||
605 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | ||
606 | this ); | ||
607 | action->addTo( importMenu ); | ||
608 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | ||
609 | #ifndef DESKTOP_VERSION | ||
610 | importMenu->insertSeparator(); | ||
611 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | ||
612 | this ); | ||
613 | action->addTo( importMenu ); | ||
614 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | ||
615 | |||
616 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | ||
617 | this ); | ||
618 | action->addTo( importMenu ); | ||
619 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | ||
620 | #else | ||
621 | importMenu->insertSeparator(); | ||
622 | icon = loadPixmap( pathString + "print" ); | ||
623 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | ||
624 | action->addTo( importMenu ); | ||
625 | connect( action, SIGNAL( activated() ), | ||
626 | this, SLOT( printCal() ) ); | ||
627 | |||
628 | icon = loadPixmap( pathString + "print" ); | ||
629 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | ||
630 | action->addTo( importMenu ); | ||
631 | connect( action, SIGNAL( activated() ), | ||
632 | this, SLOT( printSel() ) ); | ||
633 | #endif | ||
634 | importMenu->insertSeparator(); | ||
635 | action = new QAction( "beam all", i18n("Save"), 0, | ||
636 | this ); | ||
637 | action->addTo( importMenu ); | ||
638 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | ||
639 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | ||
640 | this ); | ||
641 | action->addTo( importMenu ); | ||
642 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | ||
643 | |||
644 | //menuBar->insertItem( "Configure",configureMenu ); | ||
645 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | ||
646 | icon = loadPixmap( "korganizer/korganizer" ); | ||
647 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | ||
648 | action->addTo( helpMenu ); | ||
649 | connect( action, SIGNAL( activated() ), | ||
650 | SLOT( keyBindings() ) ); | ||
651 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | ||
652 | action->addTo( helpMenu ); | ||
653 | connect( action, SIGNAL( activated() ), | ||
654 | SLOT( features() ) ); | ||
655 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | ||
656 | action->addTo( helpMenu ); | ||
657 | connect( action, SIGNAL( activated() ), | ||
658 | SLOT( aboutAutoSaving() ) ); | ||
659 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | ||
660 | action->addTo( helpMenu ); | ||
661 | connect( action, SIGNAL( activated() ), | ||
662 | SLOT( aboutKnownBugs() ) ); | ||
663 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | ||
664 | action->addTo( helpMenu ); | ||
665 | connect( action, SIGNAL( activated() ), | ||
666 | SLOT( usertrans() ) ); | ||
667 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | ||
668 | action->addTo( helpMenu ); | ||
669 | connect( action, SIGNAL( activated() ), | ||
670 | SLOT( synchowto() ) ); | ||
671 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | ||
672 | action->addTo( helpMenu ); | ||
673 | connect( action, SIGNAL( activated() ), | ||
674 | SLOT( whatsNew() ) ); | ||
675 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | ||
676 | action->addTo( helpMenu ); | ||
677 | connect( action, SIGNAL( activated() ), | ||
678 | SLOT( faq() ) ); | ||
679 | |||
680 | |||
681 | action = new QAction( "about", i18n("About..."), 0, this ); | ||
682 | action->addTo( helpMenu ); | ||
683 | connect( action, SIGNAL( activated() ), | ||
684 | SLOT( about() ) ); | ||
685 | //menuBar->insertSeparator(); | ||
686 | |||
687 | // ****************************************************** | ||
688 | // menubar icons | ||
689 | |||
690 | |||
691 | iconToolBar->setHorizontalStretchable (true ); | ||
692 | //menuBar->insertItem( iconToolBar ); | ||
693 | //xdays_action | ||
694 | if (p-> mShowIconNewEvent) | ||
695 | ne_action->addTo( iconToolBar ); | ||
696 | if (p->mShowIconNewTodo ) | ||
697 | nt_action->addTo( iconToolBar ); | ||
698 | if (p-> mShowIconSearch) | ||
699 | search_action->addTo( iconToolBar ); | ||
700 | if (p-> mShowIconNext) | ||
701 | whatsnext_action->addTo( iconToolBar ); | ||
702 | if (p-> mShowIconNextDays) | ||
703 | xdays_action->addTo( iconToolBar ); | ||
704 | if (p-> mShowIconList) | ||
705 | showlist_action->addTo( iconToolBar ); | ||
706 | if (p-> mShowIconDay1) | ||
707 | day1_action->addTo( iconToolBar ); | ||
708 | if (p-> mShowIconDay5) | ||
709 | day5_action->addTo( iconToolBar ); | ||
710 | if (p-> mShowIconDay7) | ||
711 | day7_action->addTo( iconToolBar ); | ||
712 | if (p-> mShowIconMonth) | ||
713 | month_action->addTo( iconToolBar ); | ||
714 | if (p-> mShowIconTodoview) | ||
715 | todoview_action->addTo( iconToolBar ); | ||
716 | if (p-> mShowIconJournal) | ||
717 | viewjournal_action->addTo( iconToolBar ); | ||
718 | icon = loadPixmap( pathString + "2leftarrowB" ); | ||
719 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | ||
720 | if (p-> mShowIconBackFast) { | ||
721 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | ||
722 | connect( action, SIGNAL( activated() ), | ||
723 | mView, SLOT( goPreviousMonth() ) ); | ||
724 | action->addTo( iconToolBar ); | ||
725 | } | ||
726 | icon = loadPixmap( pathString + "1leftarrowB" ); | ||
727 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | ||
728 | if (p-> mShowIconBack) { | ||
729 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | ||
730 | connect( action, SIGNAL( activated() ), | ||
731 | mView, SLOT( goPrevious() ) ); | ||
732 | action->addTo( iconToolBar ); | ||
733 | } | ||
734 | if (p-> mShowIconToday) | ||
735 | today_action->addTo( iconToolBar ); | ||
736 | icon = loadPixmap( pathString + "1rightarrowB" ); | ||
737 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | ||
738 | if (p-> mShowIconForward) { | ||
739 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | ||
740 | connect( action, SIGNAL( activated() ), | ||
741 | mView, SLOT( goNext() ) ); | ||
742 | action->addTo( iconToolBar ); | ||
743 | } | ||
744 | icon = loadPixmap( pathString + "2rightarrowB" ); | ||
745 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | ||
746 | if (p-> mShowIconForwardFast) { | ||
747 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | ||
748 | connect( action, SIGNAL( activated() ), | ||
749 | mView, SLOT( goNextMonth() ) ); | ||
750 | action->addTo( iconToolBar ); | ||
751 | } | ||
752 | |||
753 | |||
754 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | ||
755 | |||
756 | if (p-> mShowIconNewEvent) | ||
757 | configureToolBarMenu->setItemChecked( 10, true ); | ||
758 | if (p->mShowIconNewTodo ) | ||
759 | configureToolBarMenu->setItemChecked( 20, true ); | ||
760 | if (p-> mShowIconSearch) | ||
761 | configureToolBarMenu->setItemChecked( 120, true ); | ||
762 | if (p-> mShowIconList) | ||
763 | configureToolBarMenu->setItemChecked( 30, true ); | ||
764 | if (p-> mShowIconDay1) | ||
765 | configureToolBarMenu->setItemChecked( 40, true ); | ||
766 | if (p-> mShowIconDay5) | ||
767 | configureToolBarMenu->setItemChecked( 50, true ); | ||
768 | if (p-> mShowIconDay7) | ||
769 | configureToolBarMenu->setItemChecked( 60, true ); | ||
770 | if (p-> mShowIconMonth) | ||
771 | configureToolBarMenu->setItemChecked( 70, true ); | ||
772 | if (p-> mShowIconTodoview) | ||
773 | configureToolBarMenu->setItemChecked( 80, true ); | ||
774 | if (p-> mShowIconBackFast) | ||
775 | configureToolBarMenu->setItemChecked( 200, true ); | ||
776 | if (p-> mShowIconBack) | ||
777 | configureToolBarMenu->setItemChecked( 210, true ); | ||
778 | if (p-> mShowIconToday) | ||
779 | configureToolBarMenu->setItemChecked( 130, true ); | ||
780 | if (p-> mShowIconForward) | ||
781 | configureToolBarMenu->setItemChecked( 220, true ); | ||
782 | if (p-> mShowIconForwardFast) | ||
783 | configureToolBarMenu->setItemChecked( 230, true ); | ||
784 | if (p-> mShowIconNextDays) | ||
785 | configureToolBarMenu->setItemChecked( 100, true ); | ||
786 | if (p-> mShowIconNext) | ||
787 | configureToolBarMenu->setItemChecked( 110, true ); | ||
788 | if (p-> mShowIconJournal) | ||
789 | configureToolBarMenu->setItemChecked( 90, true ); | ||
790 | if (p-> mShowIconWhatsThis) | ||
791 | configureToolBarMenu->setItemChecked( 300, true ); | ||
792 | |||
793 | QLabel* dummy = new QLabel( iconToolBar ); | ||
794 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | ||
795 | if (!p-> mShowIconStretch) | ||
796 | iconToolBar->setStretchableWidget ( dummy ) ; | ||
797 | else | ||
798 | configureToolBarMenu->setItemChecked( 5, true ); | ||
799 | if (p-> mShowIconWhatsThis) | ||
800 | QWhatsThis::whatsThisButton ( iconToolBar ); | ||
801 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | ||
802 | configureAgenda( p->mHourSize ); | ||
803 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | ||
804 | } | ||
805 | void MainWindow::fillSyncMenu() | ||
806 | { | ||
807 | syncMenu->clear(); | ||
808 | syncMenu->insertItem( i18n("Configure..."), 0 ); | ||
809 | syncMenu->insertSeparator(); | ||
810 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | ||
811 | syncMenu->insertSeparator(); | ||
812 | |||
813 | QStringList prof = KOPrefs::instance()->mSyncProfileNames; | ||
814 | |||
815 | if ( prof.count() < 3 ) { | ||
816 | KConfig *config = KOGlobals::config(); | ||
817 | prof.clear(); | ||
818 | prof << i18n("Sharp-DTM"); | ||
819 | prof << i18n("Local file"); | ||
820 | prof << i18n("Last file"); | ||
821 | KSyncProfile* temp = new KSyncProfile (); | ||
822 | temp->setName( prof[0] ); | ||
823 | temp->writeConfig(config); | ||
824 | temp->setName( prof[1] ); | ||
825 | temp->writeConfig(config); | ||
826 | temp->setName( prof[2] ); | ||
827 | temp->writeConfig(config); | ||
828 | config->sync(); | ||
829 | delete temp; | ||
830 | KOPrefs::instance()->mSyncProfileNames = prof; | ||
831 | } | ||
832 | |||
833 | int i; | ||
834 | for ( i = 0; i < prof.count(); ++i ) { | ||
835 | |||
836 | syncMenu->insertItem( prof[i], 1000+i ); | ||
837 | if ( i == 2 ) | ||
838 | syncMenu->insertSeparator(); | ||
839 | } | ||
840 | QDir app_dir; | ||
841 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | ||
842 | syncMenu->setItemEnabled( false , 1000 ); | ||
843 | } | ||
844 | } | ||
845 | |||
846 | int MainWindow::ringSync() | ||
847 | { | ||
848 | int syncedProfiles = 0; | ||
849 | int i; | ||
850 | QTime timer; | ||
851 | KConfig *config = KOGlobals::config(); | ||
852 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | ||
853 | KSyncProfile* temp = new KSyncProfile (); | ||
854 | KOPrefs::instance()->mAskForPreferences = false; | ||
855 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | ||
856 | mCurrentSyncProfile = i; | ||
857 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | ||
858 | temp->readConfig(config); | ||
859 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | ||
860 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | ||
861 | ++syncedProfiles; | ||
862 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
863 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
864 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
865 | KOPrefs::instance()->mShowSyncSummary = false; | ||
866 | mView->setSyncDevice(syncProfileNames[i] ); | ||
867 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | ||
868 | if ( i == 0 ) { | ||
869 | syncSharp(); | ||
870 | } else { | ||
871 | if ( temp->getIsLocalFileSync() ) { | ||
872 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | ||
873 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | ||
874 | } else { | ||
875 | syncRemote( temp, false ); | ||
876 | |||
877 | } | ||
878 | } | ||
879 | timer.start(); | ||
880 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | ||
881 | while ( timer.elapsed () < 2000 ) { | ||
882 | qApp->processEvents(); | ||
883 | #ifndef _WIN32_ | ||
884 | sleep (1); | ||
885 | #endif | ||
886 | } | ||
887 | |||
888 | } | ||
889 | |||
890 | } | ||
891 | delete temp; | ||
892 | return syncedProfiles; | ||
893 | } | ||
894 | |||
895 | void MainWindow::multiSync( bool askforPrefs ) | ||
896 | { | ||
897 | if (mBlockSaveFlag) | ||
898 | return; | ||
899 | mBlockSaveFlag = true; | ||
900 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | ||
901 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
902 | question, | ||
903 | i18n("Yes"), i18n("No"), | ||
904 | 0, 0 ) != 0 ) { | ||
905 | mBlockSaveFlag = false; | ||
906 | setCaption(i18n("Aborted! Nothing synced!")); | ||
907 | return; | ||
908 | } | ||
909 | mView->setSyncDevice(i18n("Multiple profiles") ); | ||
910 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | ||
911 | if ( askforPrefs ) { | ||
912 | mView->edit_sync_options(); | ||
913 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | ||
914 | } | ||
915 | setCaption(i18n("Multiple sync started.") ); | ||
916 | qApp->processEvents(); | ||
917 | int num = ringSync() ; | ||
918 | if ( num > 1 ) | ||
919 | ringSync(); | ||
920 | mBlockSaveFlag = false; | ||
921 | if ( num ) | ||
922 | save(); | ||
923 | if ( num ) | ||
924 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | ||
925 | else | ||
926 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | ||
927 | return; | ||
928 | } | ||
929 | void MainWindow::slotSyncMenu( int action ) | ||
930 | { | ||
931 | //qDebug("syncaction %d ", action); | ||
932 | if ( action == 0 ) { | ||
933 | confSync(); | ||
934 | return; | ||
935 | } | ||
936 | if ( action == 1 ) { | ||
937 | multiSync( true ); | ||
938 | return; | ||
939 | } | ||
940 | |||
941 | if (mBlockSaveFlag) | ||
942 | return; | ||
943 | mBlockSaveFlag = true; | ||
944 | mCurrentSyncProfile = action - 1000 ; | ||
945 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | ||
946 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | ||
947 | KConfig *config = KOGlobals::config(); | ||
948 | KSyncProfile* temp = new KSyncProfile (); | ||
949 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
950 | temp->readConfig(config); | ||
951 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
952 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | ||
953 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
954 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
955 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | ||
956 | if ( action == 1000 ) { | ||
957 | syncSharp(); | ||
958 | |||
959 | } else if ( action == 1001 ) { | ||
960 | syncLocalFile(); | ||
961 | |||
962 | } else if ( action == 1002 ) { | ||
963 | quickSyncLocalFile(); | ||
964 | |||
965 | } else if ( action >= 1003 ) { | ||
966 | if ( temp->getIsLocalFileSync() ) { | ||
967 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | ||
968 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | ||
969 | } else { | ||
970 | syncRemote( temp ); | ||
971 | |||
972 | } | ||
973 | } | ||
974 | delete temp; | ||
975 | mBlockSaveFlag = false; | ||
976 | } | ||
977 | void MainWindow::setDefaultPreferences() | ||
978 | { | ||
979 | KOPrefs *p = KOPrefs::instance(); | ||
980 | |||
981 | p->mCompactDialogs = true; | ||
982 | p->mConfirm = true; | ||
983 | // p->mEnableQuickTodo = false; | ||
984 | } | ||
985 | |||
986 | QString MainWindow::resourcePath() | ||
987 | { | ||
988 | return KGlobal::iconLoader()->iconPath(); | ||
989 | } | ||
990 | |||
991 | void MainWindow::displayText( QString text ,QString cap ) | ||
992 | { | ||
993 | QDialog dia( this, "name", true ); ; | ||
994 | dia.setCaption( cap ); | ||
995 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | ||
996 | lay->setSpacing( 3 ); | ||
997 | lay->setMargin( 3 ); | ||
998 | QTextBrowser tb ( &dia ); | ||
999 | lay->addWidget( &tb ); | ||
1000 | tb.setText( text ); | ||
1001 | #ifdef DESKTOP_VERSION | ||
1002 | dia.resize( 640, 480); | ||
1003 | #else | ||
1004 | dia.showMaximized(); | ||
1005 | #endif | ||
1006 | dia.exec(); | ||
1007 | } | ||
1008 | void MainWindow::displayFile( QString fn, QString cap ) | ||
1009 | { | ||
1010 | QString fileName = resourcePath() + fn; | ||
1011 | QString text; | ||
1012 | QFile file( fileName ); | ||
1013 | if (!file.open( IO_ReadOnly ) ) { | ||
1014 | return ; | ||
1015 | |||
1016 | } | ||
1017 | QTextStream ts( &file ); | ||
1018 | text = ts.read(); | ||
1019 | file.close(); | ||
1020 | displayText( text, cap); | ||
1021 | } | ||
1022 | void MainWindow::features() | ||
1023 | { | ||
1024 | |||
1025 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | ||
1026 | } | ||
1027 | |||
1028 | void MainWindow::usertrans() | ||
1029 | { | ||
1030 | |||
1031 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | ||
1032 | } | ||
1033 | void MainWindow::synchowto() | ||
1034 | { | ||
1035 | |||
1036 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | ||
1037 | } | ||
1038 | void MainWindow::faq() | ||
1039 | { | ||
1040 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | ||
1041 | |||
1042 | } | ||
1043 | void MainWindow::whatsNew() | ||
1044 | { | ||
1045 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | ||
1046 | |||
1047 | } | ||
1048 | void MainWindow::about() | ||
1049 | { | ||
1050 | QString version; | ||
1051 | #include <../version> | ||
1052 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | ||
1053 | i18n("KOrganizer/Platform-independent\n") + | ||
1054 | "(KO/Pi) " + version + " - " + | ||
1055 | |||
1056 | #ifdef DESKTOP_VERSION | ||
1057 | i18n("Desktop Edition\n") + | ||
1058 | #else | ||
1059 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | ||
1060 | #endif | ||
1061 | 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") ); | ||
1062 | } | ||
1063 | void MainWindow::keyBindings() | ||
1064 | { | ||
1065 | QString cap = i18n("Key bindings KOrganizer/Pi"); | ||
1066 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | ||
1067 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | ||
1068 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | ||
1069 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | ||
1070 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | ||
1071 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | ||
1072 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | ||
1073 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | ||
1074 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | ||
1075 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | ||
1076 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | ||
1077 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | ||
1078 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | ||
1079 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | ||
1080 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | ||
1081 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | ||
1082 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | ||
1083 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | ||
1084 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | ||
1085 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | ||
1086 | i18n("<p><h3>In agenda view:</h3></p>\n") + | ||
1087 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | ||
1088 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | ||
1089 | i18n("<p><h3>In todo view:</h3></p>\n") + | ||
1090 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | ||
1091 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | ||
1092 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | ||
1093 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | ||
1094 | i18n("<p><h3>In list view:</h3></p>\n") + | ||
1095 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | ||
1096 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | ||
1097 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | ||
1098 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | ||
1099 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | ||
1100 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | ||
1101 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | ||
1102 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | ||
1103 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | ||
1104 | i18n("<p><b>E</b>: Edit item</p>\n") + | ||
1105 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | ||
1106 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | ||
1107 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | ||
1108 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | ||
1109 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | ||
1110 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | ||
1111 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | ||
1112 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | ||
1113 | i18n("<p><b>White</b>: Item readonly</p>\n"); | ||
1114 | displayText( text, cap); | ||
1115 | |||
1116 | } | ||
1117 | void MainWindow::aboutAutoSaving() | ||
1118 | { | ||
1119 | QMessageBox* msg; | ||
1120 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | ||
1121 | i18n("After changing something, the data is\nautomatically saved to the file\n~/Applications/korganizer/calendar/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, | ||
1122 | QMessageBox::Ok, | ||
1123 | QMessageBox::NoButton, | ||
1124 | QMessageBox::NoButton); | ||
1125 | msg->exec(); | ||
1126 | delete msg; | ||
1127 | |||
1128 | |||
1129 | } | ||
1130 | void MainWindow::aboutKnownBugs() | ||
1131 | { | ||
1132 | QMessageBox* msg; | ||
1133 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | ||
1134 | 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")+ | ||
1135 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | ||
1136 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | ||
1137 | i18n("\nor report them in the bugtracker on\n") + | ||
1138 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | ||
1139 | QMessageBox::NoIcon, | ||
1140 | QMessageBox::Ok, | ||
1141 | QMessageBox::NoButton, | ||
1142 | QMessageBox::NoButton); | ||
1143 | msg->exec(); | ||
1144 | delete msg; | ||
1145 | |||
1146 | } | ||
1147 | |||
1148 | QString MainWindow::defaultFileName() | ||
1149 | { | ||
1150 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | ||
1151 | } | ||
1152 | |||
1153 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | ||
1154 | { | ||
1155 | if ( !incidence ) { | ||
1156 | enableIncidenceActions( false ); | ||
1157 | |||
1158 | mNewSubTodoAction->setEnabled( false ); | ||
1159 | setCaptionToDates(); | ||
1160 | return; | ||
1161 | |||
1162 | } | ||
1163 | |||
1164 | //KGlobal::locale()->formatDateTime(nextA, true); | ||
1165 | QString startString = ""; | ||
1166 | if ( incidence->type() != "Todo" ) { | ||
1167 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | ||
1168 | if ( incidence->doesFloat() ) { | ||
1169 | startString += ": "+incidence->dtStartDateStr( true ); | ||
1170 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | ||
1171 | |||
1172 | } else { | ||
1173 | startString = ": "+incidence->dtStartStr(true); | ||
1174 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | ||
1175 | |||
1176 | } | ||
1177 | |||
1178 | } else { | ||
1179 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | ||
1180 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | ||
1181 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | ||
1182 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | ||
1183 | } | ||
1184 | |||
1185 | } | ||
1186 | else | ||
1187 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | ||
1188 | if ( !incidence->location().isEmpty() ) | ||
1189 | startString += " (" +incidence->location()+")"; | ||
1190 | setCaption( incidence->summary()+startString); | ||
1191 | |||
1192 | enableIncidenceActions( true ); | ||
1193 | |||
1194 | if ( incidence->type() == "Event" ) { | ||
1195 | mShowAction->setText( i18n("Show Event...") ); | ||
1196 | mEditAction->setText( i18n("Edit Event...") ); | ||
1197 | mDeleteAction->setText( i18n("Delete Event...") ); | ||
1198 | |||
1199 | mNewSubTodoAction->setEnabled( false ); | ||
1200 | } else if ( incidence->type() == "Todo" ) { | ||
1201 | mShowAction->setText( i18n("Show Todo...") ); | ||
1202 | mEditAction->setText( i18n("Edit Todo...") ); | ||
1203 | mDeleteAction->setText( i18n("Delete Todo...") ); | ||
1204 | |||
1205 | mNewSubTodoAction->setEnabled( true ); | ||
1206 | } else { | ||
1207 | mShowAction->setText( i18n("Show...") ); | ||
1208 | mShowAction->setText( i18n("Edit...") ); | ||
1209 | mShowAction->setText( i18n("Delete...") ); | ||
1210 | |||
1211 | mNewSubTodoAction->setEnabled( false ); | ||
1212 | } | ||
1213 | } | ||
1214 | |||
1215 | void MainWindow::enableIncidenceActions( bool enabled ) | ||
1216 | { | ||
1217 | mShowAction->setEnabled( enabled ); | ||
1218 | mEditAction->setEnabled( enabled ); | ||
1219 | mDeleteAction->setEnabled( enabled ); | ||
1220 | } | ||
1221 | |||
1222 | void MainWindow::importBday() | ||
1223 | { | ||
1224 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
1225 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | ||
1226 | i18n("Import!"), i18n("Cancel"), 0, | ||
1227 | 0, 1 ); | ||
1228 | if ( result == 0 ) { | ||
1229 | mView->importBday(); | ||
1230 | |||
1231 | } | ||
1232 | |||
1233 | |||
1234 | } | ||
1235 | void MainWindow::importQtopia() | ||
1236 | { | ||
1237 | #ifndef DESKTOP_VERSION | ||
1238 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
1239 | 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"), | ||
1240 | i18n("Import!"), i18n("Cancel"), 0, | ||
1241 | 0, 1 ); | ||
1242 | if ( result == 0 ) { | ||
1243 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | ||
1244 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | ||
1245 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | ||
1246 | mView->importQtopia( categories, datebook, todolist ); | ||
1247 | } | ||
1248 | #else | ||
1249 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
1250 | i18n("Not supported \non desktop!\n"), | ||
1251 | i18n("Ok"), i18n("Cancel"), 0, | ||
1252 | 0, 1 ); | ||
1253 | |||
1254 | #endif | ||
1255 | } | ||
1256 | |||
1257 | void MainWindow::saveOnClose() | ||
1258 | { | ||
1259 | KOPrefs *p = KOPrefs::instance(); | ||
1260 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | ||
1261 | p->mToolBarUp = iconToolBar->x() > width()/2 || | ||
1262 | iconToolBar->y() > height()/2; | ||
1263 | mView->writeSettings(); | ||
1264 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | ||
1265 | save(); | ||
1266 | } | ||
1267 | void MainWindow::slotModifiedChanged( bool changed ) | ||
1268 | { | ||
1269 | if ( mBlockAtStartup ) | ||
1270 | return; | ||
1271 | int msec; | ||
1272 | // we store the changes after 1 minute, | ||
1273 | // and for safety reasons after 10 minutes again | ||
1274 | if ( !mBlockSaveFlag ) | ||
1275 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | ||
1276 | else | ||
1277 | msec = 1000 * 600; | ||
1278 | mSaveTimer.start( msec, true ); // 1 minute | ||
1279 | qDebug("KO: Saving File in %d secs!", msec/1000); | ||
1280 | mCalendarModifiedFlag = true; | ||
1281 | } | ||
1282 | #include <qfileinfo.h> | ||
1283 | void MainWindow::save() | ||
1284 | { | ||
1285 | if ( mBlockSaveFlag ) | ||
1286 | return; | ||
1287 | bool store = mBlockSaveFlag; | ||
1288 | mBlockSaveFlag = true; | ||
1289 | if ( mView->checkFileVersion( defaultFileName()) ) { | ||
1290 | |||
1291 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | ||
1292 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | ||
1293 | qDebug("KO: Start saving data to file!"); | ||
1294 | mView->saveCalendar( defaultFileName() ); | ||
1295 | |||
1296 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | ||
1297 | mView->setLoadedFileVersion(QDateTime::currentDateTime()); | ||
1298 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | ||
1299 | QString savemes; | ||
1300 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | ||
1301 | setCaption(savemes); | ||
1302 | } else | ||
1303 | setCaption(i18n("Saving cancelled!")); | ||
1304 | mCalendarModifiedFlag = false; | ||
1305 | mBlockSaveFlag = store; | ||
1306 | } | ||
1307 | |||
1308 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | ||
1309 | { | ||
1310 | if ( !e->isAutoRepeat() ) { | ||
1311 | mFlagKeyPressed = false; | ||
1312 | } | ||
1313 | } | ||
1314 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | ||
1315 | { | ||
1316 | qApp->processEvents(); | ||
1317 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | ||
1318 | e->ignore(); | ||
1319 | // qDebug(" ignore %d",e->isAutoRepeat() ); | ||
1320 | return; | ||
1321 | } | ||
1322 | if (! e->isAutoRepeat() ) | ||
1323 | mFlagKeyPressed = true; | ||
1324 | KOPrefs *p = KOPrefs::instance(); | ||
1325 | bool showSelectedDates = false; | ||
1326 | int size; | ||
1327 | int pro = 0; | ||
1328 | //qDebug("MainWindow::keyPressEvent "); | ||
1329 | switch ( e->key() ) { | ||
1330 | case Qt::Key_Right: | ||
1331 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | ||
1332 | mView->goNextMonth(); | ||
1333 | else | ||
1334 | mView->goNext(); | ||
1335 | showSelectedDates = true; | ||
1336 | break; | ||
1337 | case Qt::Key_Left: | ||
1338 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | ||
1339 | mView->goPreviousMonth(); | ||
1340 | else | ||
1341 | mView->goPrevious(); | ||
1342 | showSelectedDates = true; | ||
1343 | break; | ||
1344 | case Qt::Key_Down: | ||
1345 | mView->viewManager()->agendaView()->scrollOneHourDown(); | ||
1346 | break; | ||
1347 | case Qt::Key_Up: | ||
1348 | mView->viewManager()->agendaView()->scrollOneHourUp(); | ||
1349 | break; | ||
1350 | case Qt::Key_I: | ||
1351 | mView->showIncidence(); | ||
1352 | break; | ||
1353 | case Qt::Key_Delete: | ||
1354 | case Qt::Key_Backspace: | ||
1355 | mView->deleteIncidence(); | ||
1356 | break; | ||
1357 | case Qt::Key_D: | ||
1358 | mView->viewManager()->showDayView(); | ||
1359 | showSelectedDates = true; | ||
1360 | break; | ||
1361 | case Qt::Key_O: | ||
1362 | mView->toggleFilerEnabled( ); | ||
1363 | break; | ||
1364 | case Qt::Key_0: | ||
1365 | case Qt::Key_1: | ||
1366 | case Qt::Key_2: | ||
1367 | case Qt::Key_3: | ||
1368 | case Qt::Key_4: | ||
1369 | case Qt::Key_5: | ||
1370 | case Qt::Key_6: | ||
1371 | case Qt::Key_7: | ||
1372 | case Qt::Key_8: | ||
1373 | case Qt::Key_9: | ||
1374 | pro = e->key()-48; | ||
1375 | if ( pro == 0 ) | ||
1376 | pro = 10; | ||
1377 | if ( e->state() == Qt::ControlButton) | ||
1378 | pro += 10; | ||
1379 | break; | ||
1380 | case Qt::Key_M: | ||
1381 | mView->viewManager()->showMonthView(); | ||
1382 | showSelectedDates = true; | ||
1383 | break; | ||
1384 | case Qt::Key_Insert: | ||
1385 | mView->newEvent(); | ||
1386 | break; | ||
1387 | case Qt::Key_S : | ||
1388 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | ||
1389 | mView->newSubTodo(); | ||
1390 | else | ||
1391 | mView->dialogManager()->showSearchDialog(); | ||
1392 | break; | ||
1393 | case Qt::Key_Y : | ||
1394 | case Qt::Key_Z : | ||
1395 | mView->viewManager()->showWorkWeekView(); | ||
1396 | showSelectedDates = true; | ||
1397 | break; | ||
1398 | case Qt::Key_U : | ||
1399 | mView->viewManager()->showWeekView(); | ||
1400 | showSelectedDates = true; | ||
1401 | break; | ||
1402 | case Qt::Key_H : | ||
1403 | keyBindings(); | ||
1404 | break; | ||
1405 | case Qt::Key_W: | ||
1406 | mView->viewManager()->showWhatsNextView(); | ||
1407 | break; | ||
1408 | case Qt::Key_L: | ||
1409 | mView->viewManager()->showListView(); | ||
1410 | break; | ||
1411 | case Qt::Key_N: | ||
1412 | mView->viewManager()->showNextXView(); | ||
1413 | showSelectedDates = true; | ||
1414 | break; | ||
1415 | case Qt::Key_V: | ||
1416 | mView->viewManager()->showTodoView(); | ||
1417 | break; | ||
1418 | case Qt::Key_C: | ||
1419 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | ||
1420 | break; | ||
1421 | case Qt::Key_P: | ||
1422 | mView->showDatePicker( ); | ||
1423 | break; | ||
1424 | case Qt::Key_F: | ||
1425 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | ||
1426 | mView->editFilters(); | ||
1427 | else | ||
1428 | mView->toggleFilter(); | ||
1429 | break; | ||
1430 | case Qt::Key_X: | ||
1431 | mView->toggleDateNavigatorWidget(); | ||
1432 | break; | ||
1433 | case Qt::Key_Space: | ||
1434 | mView->toggleExpand(); | ||
1435 | break; | ||
1436 | case Qt::Key_A: | ||
1437 | mView->toggleAllDaySize(); | ||
1438 | break; | ||
1439 | case Qt::Key_T: | ||
1440 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | ||
1441 | mView->newTodo(); | ||
1442 | else { | ||
1443 | mView->goToday(); | ||
1444 | showSelectedDates = true; | ||
1445 | } | ||
1446 | break; | ||
1447 | case Qt::Key_J: | ||
1448 | mView->viewManager()->showJournalView(); | ||
1449 | break; | ||
1450 | case Qt::Key_B: | ||
1451 | mView->editIncidenceDescription();; | ||
1452 | break; | ||
1453 | // case Qt::Key_Return: | ||
1454 | case Qt::Key_E: | ||
1455 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | ||
1456 | mView->newEvent(); | ||
1457 | else | ||
1458 | mView->editIncidence(); | ||
1459 | break; | ||
1460 | case Qt::Key_Plus: | ||
1461 | size = p->mHourSize +2; | ||
1462 | if ( size <= 18 ) | ||
1463 | configureAgenda( size ); | ||
1464 | break; | ||
1465 | case Qt::Key_Minus: | ||
1466 | size = p->mHourSize - 2; | ||
1467 | if ( size >= 4 ) | ||
1468 | configureAgenda( size ); | ||
1469 | break; | ||
1470 | |||
1471 | |||
1472 | default: | ||
1473 | e->ignore(); | ||
1474 | } | ||
1475 | if ( pro > 0 ) { | ||
1476 | mView->selectFilter( pro-1 ); | ||
1477 | } | ||
1478 | if ( showSelectedDates ) { | ||
1479 | ;// setCaptionToDates(); | ||
1480 | } | ||
1481 | |||
1482 | } | ||
1483 | |||
1484 | void MainWindow::configureToolBar( int item ) | ||
1485 | { | ||
1486 | |||
1487 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | ||
1488 | KOPrefs *p = KOPrefs::instance(); | ||
1489 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | ||
1490 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | ||
1491 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | ||
1492 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | ||
1493 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | ||
1494 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | ||
1495 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | ||
1496 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | ||
1497 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | ||
1498 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | ||
1499 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | ||
1500 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | ||
1501 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | ||
1502 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | ||
1503 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | ||
1504 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | ||
1505 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | ||
1506 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | ||
1507 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | ||
1508 | // initActions(); | ||
1509 | } | ||
1510 | |||
1511 | void MainWindow::setCaptionToDates() | ||
1512 | { | ||
1513 | QString selDates; | ||
1514 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | ||
1515 | if (mView->startDate() < mView->endDate() ) | ||
1516 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | ||
1517 | setCaption( i18n("Dates: ") + selDates ); | ||
1518 | |||
1519 | } | ||
1520 | // parameter item == 0: reinit | ||
1521 | void MainWindow::configureAgenda( int item ) | ||
1522 | { | ||
1523 | |||
1524 | KOPrefs *p = KOPrefs::instance(); | ||
1525 | |||
1526 | int i; | ||
1527 | if ( item == 1 ) { | ||
1528 | mView->toggleAllDaySize(); | ||
1529 | return; | ||
1530 | } | ||
1531 | // do not allow 4 for widgets higher than 480 | ||
1532 | // if ( QApplication::desktop()->height() > 480 ) { | ||
1533 | // if ( item == 4 ) | ||
1534 | // item = 6; | ||
1535 | // } | ||
1536 | for ( i = 4; i <= 18; i= i+2 ) | ||
1537 | configureAgendaMenu->setItemChecked( i, false ); | ||
1538 | configureAgendaMenu->setItemChecked( item, true ); | ||
1539 | if ( p->mHourSize == item ) | ||
1540 | return; | ||
1541 | p->mHourSize=item; | ||
1542 | mView->viewManager()->agendaView()->updateConfig(); | ||
1543 | } | ||
1544 | |||
1545 | void MainWindow::saveCalendar() | ||
1546 | { | ||
1547 | QString fn = KOPrefs::instance()->mLastSaveFile; | ||
1548 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | ||
1549 | |||
1550 | if ( fn == "" ) | ||
1551 | return; | ||
1552 | QFileInfo info; | ||
1553 | info.setFile( fn ); | ||
1554 | QString mes; | ||
1555 | bool createbup = true; | ||
1556 | if ( info. exists() ) { | ||
1557 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | ||
1558 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | ||
1559 | i18n("Overwrite!"), i18n("Cancel"), 0, | ||
1560 | 0, 1 ); | ||
1561 | if ( result != 0 ) { | ||
1562 | createbup = false; | ||
1563 | } | ||
1564 | } | ||
1565 | if ( createbup ) { | ||
1566 | mView->saveCalendar( fn ); | ||
1567 | mes = i18n("KO/Pi:Saved %1").arg(fn); | ||
1568 | KOPrefs::instance()->mLastSaveFile = fn; | ||
1569 | setCaption(mes); | ||
1570 | } | ||
1571 | } | ||
1572 | void MainWindow::loadCalendar() | ||
1573 | { | ||
1574 | |||
1575 | QString fn = KOPrefs::instance()->mLastLoadFile; | ||
1576 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | ||
1577 | |||
1578 | if ( fn == "" ) | ||
1579 | return; | ||
1580 | QFileInfo info; | ||
1581 | info.setFile( fn ); | ||
1582 | QString mess; | ||
1583 | bool loadbup = true; | ||
1584 | if ( info. exists() ) { | ||
1585 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | ||
1586 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | ||
1587 | mess, | ||
1588 | i18n("Load!"), i18n("Cancel"), 0, | ||
1589 | 0, 1 ); | ||
1590 | if ( result != 0 ) { | ||
1591 | loadbup = false; | ||
1592 | } | ||
1593 | } else { | ||
1594 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
1595 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | ||
1596 | 0, 1 ); | ||
1597 | |||
1598 | return; | ||
1599 | } | ||
1600 | if ( loadbup ) { | ||
1601 | mView->openCalendar( fn ); | ||
1602 | KOPrefs::instance()->mLastLoadFile = fn; | ||
1603 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | ||
1604 | setCaption(mess); | ||
1605 | } | ||
1606 | |||
1607 | } | ||
1608 | void MainWindow::quickImportIcal() | ||
1609 | { | ||
1610 | importFile( KOPrefs::instance()->mLastImportFile, false ); | ||
1611 | } | ||
1612 | void MainWindow::importFile( QString fn, bool quick ) | ||
1613 | { | ||
1614 | QFileInfo info; | ||
1615 | info.setFile( fn ); | ||
1616 | QString mess; | ||
1617 | bool loadbup = true; | ||
1618 | if ( !info. exists() ) { | ||
1619 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | ||
1620 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
1621 | mess ); | ||
1622 | return; | ||
1623 | } | ||
1624 | int result = 0; | ||
1625 | if ( !quick ) { | ||
1626 | 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 )); | ||
1627 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | ||
1628 | mess, | ||
1629 | "Import", "Cancel", 0, | ||
1630 | 0, 1 ); | ||
1631 | } | ||
1632 | if ( result == 0 ) { | ||
1633 | if ( mView->openCalendar( fn, true )) { | ||
1634 | KOPrefs::instance()->mLastImportFile = fn; | ||
1635 | setCaption(i18n("Imported file successfully")); | ||
1636 | } else { | ||
1637 | setCaption(i18n("Error importing file")); | ||
1638 | } | ||
1639 | } | ||
1640 | } | ||
1641 | |||
1642 | void MainWindow::importIcal() | ||
1643 | { | ||
1644 | |||
1645 | QString fn =KOPrefs::instance()->mLastImportFile; | ||
1646 | |||
1647 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | ||
1648 | if ( fn == "" ) | ||
1649 | return; | ||
1650 | importFile( fn, true ); | ||
1651 | |||
1652 | } | ||
1653 | |||
1654 | void MainWindow::exportVCalendar() | ||
1655 | { | ||
1656 | QString fn = KOPrefs::instance()->mLastVcalFile; | ||
1657 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | ||
1658 | if ( fn == "" ) | ||
1659 | return; | ||
1660 | QFileInfo info; | ||
1661 | info.setFile( fn ); | ||
1662 | QString mes; | ||
1663 | bool createbup = true; | ||
1664 | if ( info. exists() ) { | ||
1665 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | ||
1666 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | ||
1667 | i18n("Overwrite!"), i18n("Cancel"), 0, | ||
1668 | 0, 1 ); | ||
1669 | if ( result != 0 ) { | ||
1670 | createbup = false; | ||
1671 | } | ||
1672 | } | ||
1673 | if ( createbup ) { | ||
1674 | if ( mView->exportVCalendar( fn ) ) { | ||
1675 | KOPrefs::instance()->mLastVcalFile = fn; | ||
1676 | if ( fn.length() > 20 ) | ||
1677 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | ||
1678 | else | ||
1679 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | ||
1680 | setCaption(mes); | ||
1681 | } | ||
1682 | } | ||
1683 | |||
1684 | } | ||
1685 | #include <qpushbutton.h> | ||
1686 | QString MainWindow::getPassword( ) | ||
1687 | { | ||
1688 | QString retfile = ""; | ||
1689 | QDialog dia ( this, "input-dialog", true ); | ||
1690 | QLineEdit lab ( &dia ); | ||
1691 | lab.setEchoMode( QLineEdit::Password ); | ||
1692 | QVBoxLayout lay( &dia ); | ||
1693 | lay.setMargin(7); | ||
1694 | lay.setSpacing(7); | ||
1695 | lay.addWidget( &lab); | ||
1696 | dia.setFixedSize( 230,50 ); | ||
1697 | dia.setCaption( i18n("Enter password") ); | ||
1698 | QPushButton pb ( "OK", &dia); | ||
1699 | lay.addWidget( &pb ); | ||
1700 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
1701 | dia.show(); | ||
1702 | int res = dia.exec(); | ||
1703 | if ( res ) | ||
1704 | retfile = lab.text(); | ||
1705 | dia.hide(); | ||
1706 | qApp->processEvents(); | ||
1707 | return retfile; | ||
1708 | |||
1709 | } | ||
1710 | |||
1711 | void MainWindow::syncLocalFile() | ||
1712 | { | ||
1713 | |||
1714 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | ||
1715 | |||
1716 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | ||
1717 | if ( fn == "" ) | ||
1718 | return; | ||
1719 | //mView->setSyncDevice("local-file" ); | ||
1720 | if ( syncWithFile( fn, false ) ) { | ||
1721 | // Event* e = mView->getLastSyncEvent(); | ||
1722 | // e->setReadOnly( false ); | ||
1723 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | ||
1724 | // e->setReadOnly( true ); | ||
1725 | } | ||
1726 | |||
1727 | } | ||
1728 | |||
1729 | bool MainWindow::syncWithFile( QString fn , bool quick ) | ||
1730 | { | ||
1731 | bool ret = false; | ||
1732 | QFileInfo info; | ||
1733 | info.setFile( fn ); | ||
1734 | QString mess; | ||
1735 | bool loadbup = true; | ||
1736 | if ( !info. exists() ) { | ||
1737 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | ||
1738 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
1739 | mess ); | ||
1740 | return ret; | ||
1741 | } | ||
1742 | int result = 0; | ||
1743 | if ( !quick ) { | ||
1744 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | ||
1745 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
1746 | mess, | ||
1747 | i18n("Sync"), i18n("Cancel"), 0, | ||
1748 | 0, 1 ); | ||
1749 | if ( result ) | ||
1750 | return false; | ||
1751 | } | ||
1752 | if ( KOPrefs::instance()->mAskForPreferences ) | ||
1753 | mView->edit_sync_options(); | ||
1754 | if ( result == 0 ) { | ||
1755 | //qDebug("Now sycing ... "); | ||
1756 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | ||
1757 | setCaption( i18n("Synchronization successful") ); | ||
1758 | else | ||
1759 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | ||
1760 | if ( ! quick ) | ||
1761 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | ||
1762 | slotModifiedChanged( true ); | ||
1763 | } | ||
1764 | return ret; | ||
1765 | } | ||
1766 | void MainWindow::quickSyncLocalFile() | ||
1767 | { | ||
1768 | //mView->setSyncDevice("local-file" ); | ||
1769 | //qDebug("quickSyncLocalFile() "); | ||
1770 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | ||
1771 | // Event* e = mView->getLastSyncEvent(); | ||
1772 | // e->setReadOnly( false ); | ||
1773 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | ||
1774 | // e->setReadOnly( true ); | ||
1775 | |||
1776 | } | ||
1777 | } | ||
1778 | |||
1779 | void MainWindow::confSync() | ||
1780 | { | ||
1781 | mView->confSync(); | ||
1782 | fillSyncMenu(); | ||
1783 | mView->writeSettings(); | ||
1784 | |||
1785 | |||
1786 | } | ||
1787 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) | ||
1788 | { | ||
1789 | QString question; | ||
1790 | if ( ask ) { | ||
1791 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | ||
1792 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
1793 | question, | ||
1794 | i18n("Yes"), i18n("No"), | ||
1795 | 0, 0 ) != 0 ) | ||
1796 | return; | ||
1797 | } | ||
1798 | QString command = prof->getPreSyncCommand(); | ||
1799 | int fi; | ||
1800 | if ( (fi = command.find("$PWD$")) > 0 ) { | ||
1801 | QString pwd = getPassword(); | ||
1802 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | ||
1803 | |||
1804 | } | ||
1805 | int maxlen = 30; | ||
1806 | if ( QApplication::desktop()->width() > 320 ) | ||
1807 | maxlen += 25; | ||
1808 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | ||
1809 | int fileSize = 0; | ||
1810 | int result = system ( command ); | ||
1811 | // 0 : okay | ||
1812 | // 256: no such file or dir | ||
1813 | // | ||
1814 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | ||
1815 | if ( result != 0 ) { | ||
1816 | int len = maxlen; | ||
1817 | while ( len < command.length() ) { | ||
1818 | command.insert( len , "\n" ); | ||
1819 | len += maxlen +2; | ||
1820 | } | ||
1821 | 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) ; | ||
1822 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | ||
1823 | question, | ||
1824 | i18n("Okay!")) ; | ||
1825 | setCaption ("KO/Pi"); | ||
1826 | return; | ||
1827 | } | ||
1828 | setCaption ( i18n( "Copying succeed." ) ); | ||
1829 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | ||
1830 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | ||
1831 | // Event* e = mView->getLastSyncEvent(); | ||
1832 | // e->setReadOnly( false ); | ||
1833 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
1834 | // e->setReadOnly( true ); | ||
1835 | if ( KOPrefs::instance()->mWriteBackFile ) { | ||
1836 | command = prof->getPostSyncCommand(); | ||
1837 | setCaption ( i18n( "Writing back file ..." ) ); | ||
1838 | result = system ( command ); | ||
1839 | qDebug("KO: Writing back file result: %d ", result); | ||
1840 | if ( result != 0 ) { | ||
1841 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | ||
1842 | return; | ||
1843 | } else { | ||
1844 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | ||
1845 | } | ||
1846 | } | ||
1847 | } | ||
1848 | return; | ||
1849 | } | ||
1850 | void MainWindow::syncSSH() | ||
1851 | { | ||
1852 | // not used anymore | ||
1853 | QTime timer; | ||
1854 | timer.start(); | ||
1855 | //qDebug("MainWindow::syncssh() "); | ||
1856 | KOPrefs *p = KOPrefs::instance(); | ||
1857 | QString localFile = p->mLocalTempFile; | ||
1858 | QString remoteIP = p->mRemoteIP; | ||
1859 | QString remoteUser = p->mRemoteUser; | ||
1860 | QString remoteFile = p->mRemoteFile; | ||
1861 | if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) | ||
1862 | remoteUser += ":" + p->mRemotePassWd; | ||
1863 | |||
1864 | QString question = i18n("Do you really want\nto remote sync?\n \n") + | ||
1865 | i18n("IP: " ) +remoteIP +"\n" + | ||
1866 | i18n("User: " ) + remoteUser +"\n" ; | ||
1867 | int maxlen = 30; | ||
1868 | if ( QApplication::desktop()->width() > 320 ) | ||
1869 | maxlen += 25; | ||
1870 | if ( remoteFile.length() > maxlen ) | ||
1871 | question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; | ||
1872 | else | ||
1873 | question += i18n("Remote file:\n " ) + remoteFile +"\n"; | ||
1874 | if ( localFile.length() > maxlen ) | ||
1875 | question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; | ||
1876 | else | ||
1877 | question += i18n("Local temp file:\n " ) + localFile +"\n"; | ||
1878 | |||
1879 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
1880 | question, | ||
1881 | i18n("Yes"), i18n("No"), | ||
1882 | 0, 0 ) != 0 ) | ||
1883 | return; | ||
1884 | // if ( !p->mUsePassWd ) { | ||
1885 | // QString pass = getPassword(); | ||
1886 | // if ( pass.length() > 0 ) | ||
1887 | // remoteUser += ":" + pass; | ||
1888 | // } | ||
1889 | QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; | ||
1890 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | ||
1891 | int fileSize = 0; | ||
1892 | int result = system ( command ); | ||
1893 | // 0 : okay | ||
1894 | // 256: no such file or dir | ||
1895 | // | ||
1896 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | ||
1897 | if ( result != 0 ) { | ||
1898 | int len = maxlen; | ||
1899 | while ( len < command.length() ) { | ||
1900 | command.insert( len , "\n" ); | ||
1901 | len += maxlen +2; | ||
1902 | } | ||
1903 | 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) ; | ||
1904 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | ||
1905 | question, | ||
1906 | i18n("Okay!")) ; | ||
1907 | setCaption ("KO/Pi"); | ||
1908 | return; | ||
1909 | } | ||
1910 | |||
1911 | |||
1912 | setCaption ( i18n( "Copying succeed." ) ); | ||
1913 | //mView->setSyncDevice("ssh-scp" ); | ||
1914 | if ( syncWithFile(localFile , true ) ) { | ||
1915 | // Event* e = mView->getLastSyncEvent(); | ||
1916 | // e->setReadOnly( false ); | ||
1917 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
1918 | // e->setReadOnly( true ); | ||
1919 | if ( KOPrefs::instance()->mWriteBackFile ) { | ||
1920 | command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; | ||
1921 | setCaption ( i18n( "Writing back file ..." ) ); | ||
1922 | result = system ( command ); | ||
1923 | if ( result != 0 ) { | ||
1924 | int len = maxlen; | ||
1925 | while ( len < command.length() ) { | ||
1926 | command.insert( len , "\n" ); | ||
1927 | len += maxlen +2; | ||
1928 | } | ||
1929 | 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) ; | ||
1930 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | ||
1931 | question, | ||
1932 | i18n("Okay!")) ; | ||
1933 | setCaption ("KO/Pi"); | ||
1934 | return; | ||
1935 | } else { | ||
1936 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | ||
1937 | } | ||
1938 | } | ||
1939 | } | ||
1940 | return; | ||
1941 | #if 0 | ||
1942 | system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); | ||
1943 | while ( timer.elapsed() < 5000 ) | ||
1944 | qApp->processEvents(); | ||
1945 | |||
1946 | qDebug("MainWindow::merging) "); | ||
1947 | mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); | ||
1948 | while ( mBlockSaveFlag ) | ||
1949 | qApp->processEvents(); | ||
1950 | save(); | ||
1951 | system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); | ||
1952 | #endif | ||
1953 | |||
1954 | } | ||
1955 | |||
1956 | |||
1957 | void MainWindow::syncSharp() | ||
1958 | { | ||
1959 | if ( mCalendarModifiedFlag ) | ||
1960 | save(); | ||
1961 | mView->syncSharp(); | ||
1962 | slotModifiedChanged( true ); | ||
1963 | |||
1964 | } | ||
1965 | |||
1966 | void MainWindow::printSel( ) | ||
1967 | { | ||
1968 | mView->viewManager()->agendaView()->agenda()->printSelection(); | ||
1969 | } | ||
1970 | |||
1971 | void MainWindow::printCal() | ||
1972 | { | ||
1973 | mView->print();//mCp->showDialog(); | ||
1974 | } | ||