summaryrefslogtreecommitdiffabout
path: root/korganizer/mainwindow.cpp
Unidiff
Diffstat (limited to 'korganizer/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 8e5d108..95bef66 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -15,97 +15,96 @@
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "simplealarmclient.h"
64#include "externalapphandler.h" 63#include "externalapphandler.h"
65 64
66using namespace KCal; 65using namespace KCal;
67#ifndef _WIN32_ 66#ifndef _WIN32_
68#include <unistd.h> 67#include <unistd.h>
69#else 68#else
70#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
71#include "koimportoldialog.h" 70#include "koimportoldialog.h"
72#endif 71#endif
73#endif 72#endif
74#include "mainwindow.h" 73#include "mainwindow.h"
75 74
76 75
77class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
78{ 77{
79 public: 78 public:
80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
81 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
82 { 81 {
83 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
84 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
85 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
86 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
87 QLabel *lab; 86 QLabel *lab;
88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
89 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
90 QHBox* temphb; 89 QHBox* temphb;
91 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
92 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
93 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
96 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
97 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
99 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
100 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
101 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
102 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
104 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
105 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
@@ -240,97 +239,96 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
240 else 239 else
241 tbd = Left; 240 tbd = Left;
242 } 241 }
243 navigatorToolBar = new QPEToolBar( this ); 242 navigatorToolBar = new QPEToolBar( this );
244 addToolBar (navigatorToolBar , tbd ); 243 addToolBar (navigatorToolBar , tbd );
245 } 244 }
246 245
247 246
248 247
249 mCalendarModifiedFlag = false; 248 mCalendarModifiedFlag = false;
250 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 249 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
251 splash->setAlignment ( AlignCenter ); 250 splash->setAlignment ( AlignCenter );
252 setCentralWidget( splash ); 251 setCentralWidget( splash );
253#ifndef DESKTOP_VERSION 252#ifndef DESKTOP_VERSION
254 showMaximized(); 253 showMaximized();
255#endif 254#endif
256 255
257 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 256 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
258 setDefaultPreferences(); 257 setDefaultPreferences();
259 mCalendar = new CalendarLocal(); 258 mCalendar = new CalendarLocal();
260 mView = new CalendarView( mCalendar, this,"mCalendar " ); 259 mView = new CalendarView( mCalendar, this,"mCalendar " );
261 mView->hide(); 260 mView->hide();
262 //mView->resize(splash->size() ); 261 //mView->resize(splash->size() );
263 initActions(); 262 initActions();
264 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 263 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
265 mSyncManager->setBlockSave(false); 264 mSyncManager->setBlockSave(false);
266 mView->setSyncManager(mSyncManager); 265 mView->setSyncManager(mSyncManager);
267#ifndef DESKTOP_VERSION 266#ifndef DESKTOP_VERSION
268 iconToolBar->show(); 267 iconToolBar->show();
269 qApp->processEvents(); 268 qApp->processEvents();
270#endif 269#endif
271 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 270 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
272 int vh = height() ; 271 int vh = height() ;
273 int vw = width(); 272 int vw = width();
274 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 273 //qDebug("Toolbar hei %d ",iconToolBar->height() );
275 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 274 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
276 vh -= iconToolBar->height(); 275 vh -= iconToolBar->height();
277 } else { 276 } else {
278 vw -= iconToolBar->height(); 277 vw -= iconToolBar->height();
279 } 278 }
280 //mView->setMaximumSize( splash->size() ); 279 //mView->setMaximumSize( splash->size() );
281 //mView->resize( splash->size() ); 280 //mView->resize( splash->size() );
282 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 281 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
283 mView->readSettings(); 282 mView->readSettings();
284 bool newFile = false; 283 bool newFile = false;
285 if( !QFile::exists( defaultFileName() ) ) { 284 if( !QFile::exists( defaultFileName() ) ) {
286 QFileInfo finfo ( defaultFileName() ); 285 QFileInfo finfo ( defaultFileName() );
287 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 286 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
288 qDebug("oldfile %s ", oldFile.latin1());
289 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"; 287 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";
290 finfo.setFile( oldFile ); 288 finfo.setFile( oldFile );
291 if (finfo.exists() ) { 289 if (finfo.exists() ) {
292 KMessageBox::information( this, message); 290 KMessageBox::information( this, message);
293 mView->openCalendar( oldFile ); 291 mView->openCalendar( oldFile );
294 qApp->processEvents(); 292 qApp->processEvents();
295 } else { 293 } else {
296 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 294 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
297 finfo.setFile( oldFile ); 295 finfo.setFile( oldFile );
298 if (finfo.exists() ) { 296 if (finfo.exists() ) {
299 KMessageBox::information( this, message); 297 KMessageBox::information( this, message);
300 mView->openCalendar( oldFile ); 298 mView->openCalendar( oldFile );
301 qApp->processEvents(); 299 qApp->processEvents();
302 } 300 }
303 } 301 }
304 mView->saveCalendar( defaultFileName() ); 302 mView->saveCalendar( defaultFileName() );
305 newFile = true; 303 newFile = true;
306 } 304 }
307 305
308 QTime neededSaveTime = QDateTime::currentDateTime().time(); 306 QTime neededSaveTime = QDateTime::currentDateTime().time();
309 mView->openCalendar( defaultFileName() ); 307 mView->openCalendar( defaultFileName() );
310 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 308 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
311 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 309 qDebug("KO: Calendar loading time: %d ms",msNeeded );
312 310
313 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 311 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
314 KOPrefs::instance()->setAllDefaults(); 312 KOPrefs::instance()->setAllDefaults();
315 int count = mView->addCategories(); 313 int count = mView->addCategories();
316 } 314 }
317 processIncidenceSelection( 0 ); 315 processIncidenceSelection( 0 );
318 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 316 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
319 SLOT( processIncidenceSelection( Incidence * ) ) ); 317 SLOT( processIncidenceSelection( Incidence * ) ) );
320 connect( mView, SIGNAL( modifiedChanged( bool ) ), 318 connect( mView, SIGNAL( modifiedChanged( bool ) ),
321 SLOT( slotModifiedChanged( bool ) ) ); 319 SLOT( slotModifiedChanged( bool ) ) );
322 320
323 321
324 connect( mView, SIGNAL( tempDisableBR(bool) ), 322 connect( mView, SIGNAL( tempDisableBR(bool) ),
325 SLOT( disableBR(bool) ) ); 323 SLOT( disableBR(bool) ) );
326 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 324 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
327 mView->setModified( false ); 325 mView->setModified( false );
328 mBlockAtStartup = false; 326 mBlockAtStartup = false;
329 mView->setModified( false ); 327 mView->setModified( false );
330 setCentralWidget( mView ); 328 setCentralWidget( mView );
331 globalFlagBlockStartup = 0; 329 globalFlagBlockStartup = 0;
332 mView->show(); 330 mView->show();
333 delete splash; 331 delete splash;
334 if ( newFile ) 332 if ( newFile )
335 mView->updateConfig(); 333 mView->updateConfig();
336 // qApp->processEvents(); 334 // qApp->processEvents();
@@ -373,103 +371,103 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
373} 371}
374MainWindow::~MainWindow() 372MainWindow::~MainWindow()
375{ 373{
376 //qDebug("MainWindow::~MainWindow() "); 374 //qDebug("MainWindow::~MainWindow() ");
377 //save toolbar location 375 //save toolbar location
378 delete mCalendar; 376 delete mCalendar;
379 delete mSyncManager; 377 delete mSyncManager;
380#ifndef DESKTOP_VERSION 378#ifndef DESKTOP_VERSION
381 if ( infrared ) 379 if ( infrared )
382 delete infrared; 380 delete infrared;
383#endif 381#endif
384 382
385 383
386} 384}
387 385
388void MainWindow::disableBR(bool b) 386void MainWindow::disableBR(bool b)
389{ 387{
390#ifndef DESKTOP_VERSION 388#ifndef DESKTOP_VERSION
391 if ( b ) { 389 if ( b ) {
392 if ( infrared ) { 390 if ( infrared ) {
393 toggleBeamReceive(); 391 toggleBeamReceive();
394 mBRdisabled = true; 392 mBRdisabled = true;
395 } 393 }
396 mBRdisabled = true; 394 mBRdisabled = true;
397 } else { 395 } else {
398 if ( mBRdisabled ) { 396 if ( mBRdisabled ) {
399 mBRdisabled = false; 397 mBRdisabled = false;
400 //makes no sense,because other cal ap is probably running 398 //makes no sense,because other cal ap is probably running
401 // toggleBeamReceive(); 399 // toggleBeamReceive();
402 } 400 }
403 } 401 }
404#endif 402#endif
405 403
406} 404}
407bool MainWindow::beamReceiveEnabled() 405bool MainWindow::beamReceiveEnabled()
408{ 406{
409#ifndef DESKTOP_VERSION 407#ifndef DESKTOP_VERSION
410 return ( infrared != 0 ); 408 return ( infrared != 0 );
411#endif 409#endif
412 return false; 410 return false;
413} 411}
414 412
415void MainWindow::toggleBeamReceive() 413void MainWindow::toggleBeamReceive()
416{ 414{
417 if ( mBRdisabled ) 415 if ( mBRdisabled )
418 return; 416 return;
419#ifndef DESKTOP_VERSION 417#ifndef DESKTOP_VERSION
420 if ( infrared ) { 418 if ( infrared ) {
421 qDebug("disable BeamReceive "); 419 qDebug("KO: Disable BeamReceive ");
422 delete infrared; 420 delete infrared;
423 infrared = 0; 421 infrared = 0;
424 brAction->setOn(false); 422 brAction->setOn(false);
425 return; 423 return;
426 } 424 }
427 qDebug("enable BeamReceive "); 425 qDebug("KO: Enable BeamReceive ");
428 brAction->setOn(true); 426 brAction->setOn(true);
429 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 427 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
430 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 428 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
431#endif 429#endif
432} 430}
433void MainWindow::showMaximized () 431void MainWindow::showMaximized ()
434{ 432{
435#ifndef DESKTOP_VERSION 433#ifndef DESKTOP_VERSION
436 if ( ! globalFlagBlockStartup ) 434 if ( ! globalFlagBlockStartup )
437 if ( mClosed ) 435 if ( mClosed )
438 mView->goToday(); 436 mView->goToday();
439#endif 437#endif
440 QWidget::showMaximized () ; 438 QWidget::showMaximized () ;
441 mClosed = false; 439 mClosed = false;
442} 440}
443void MainWindow::closeEvent( QCloseEvent* ce ) 441void MainWindow::closeEvent( QCloseEvent* ce )
444{ 442{
445 443
446 444
447 445
448 if ( ! KOPrefs::instance()->mAskForQuit ) { 446 if ( ! KOPrefs::instance()->mAskForQuit ) {
449 saveOnClose(); 447 saveOnClose();
450 mClosed = true; 448 mClosed = true;
451 ce->accept(); 449 ce->accept();
452 return; 450 return;
453 451
454 } 452 }
455 453
456 switch( QMessageBox::information( this, "KO/Pi", 454 switch( QMessageBox::information( this, "KO/Pi",
457 i18n("Do you really want\nto close KO/Pi?"), 455 i18n("Do you really want\nto close KO/Pi?"),
458 i18n("Close"), i18n("No"), 456 i18n("Close"), i18n("No"),
459 0, 0 ) ) { 457 0, 0 ) ) {
460 case 0: 458 case 0:
461 saveOnClose(); 459 saveOnClose();
462 mClosed = true; 460 mClosed = true;
463 ce->accept(); 461 ce->accept();
464 break; 462 break;
465 case 1: 463 case 1:
466 ce->ignore(); 464 ce->ignore();
467 break; 465 break;
468 case 2: 466 case 2:
469 467
470 default: 468 default:
471 break; 469 break;
472 } 470 }
473 471
474 472
475} 473}