summaryrefslogtreecommitdiffabout
path: root/korganizer/mainwindow.cpp
Unidiff
Diffstat (limited to 'korganizer/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index b6ce7d5..b797d8c 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -89,114 +89,111 @@ class KOex2phonePrefs : public QDialog
89 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 89 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
90 lab->setAlignment (AlignHCenter ); 90 lab->setAlignment (AlignHCenter );
91 QHBox* temphb; 91 QHBox* temphb;
92 temphb = new QHBox( this ); 92 temphb = new QHBox( this );
93 new QLabel( i18n("I/O device: "), temphb ); 93 new QLabel( i18n("I/O device: "), temphb );
94 mPhoneDevice = new QLineEdit( temphb); 94 mPhoneDevice = new QLineEdit( temphb);
95 lay->addWidget( temphb ); 95 lay->addWidget( temphb );
96 temphb = new QHBox( this ); 96 temphb = new QHBox( this );
97 new QLabel( i18n("Connection: "), temphb ); 97 new QLabel( i18n("Connection: "), temphb );
98 mPhoneConnection = new QLineEdit( temphb); 98 mPhoneConnection = new QLineEdit( temphb);
99 lay->addWidget( temphb ); 99 lay->addWidget( temphb );
100 temphb = new QHBox( this ); 100 temphb = new QHBox( this );
101 new QLabel( i18n("Model(opt.): "), temphb ); 101 new QLabel( i18n("Model(opt.): "), temphb );
102 mPhoneModel = new QLineEdit( temphb); 102 mPhoneModel = new QLineEdit( temphb);
103 lay->addWidget( temphb ); 103 lay->addWidget( temphb );
104 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 104 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
105 mWriteBackFuture->setChecked( true ); 105 mWriteBackFuture->setChecked( true );
106 lay->addWidget( mWriteBackFuture ); 106 lay->addWidget( mWriteBackFuture );
107 temphb = new QHBox( this ); 107 temphb = new QHBox( this );
108 new QLabel( i18n("Max. weeks in future: ") , temphb ); 108 new QLabel( i18n("Max. weeks in future: ") , temphb );
109 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 109 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
110 mWriteBackFutureWeeks->setValue( 8 ); 110 mWriteBackFutureWeeks->setValue( 8 );
111 lay->addWidget( temphb ); 111 lay->addWidget( temphb );
112 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 112 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
113 lab->setAlignment (AlignHCenter ); 113 lab->setAlignment (AlignHCenter );
114 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 114 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
115 lay->addWidget( ok ); 115 lay->addWidget( ok );
116 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 116 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
117 lay->addWidget( cancel ); 117 lay->addWidget( cancel );
118 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 118 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
119 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 119 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
120 resize( 220, 240 ); 120 resize( 220, 240 );
121 qApp->processEvents(); 121 qApp->processEvents();
122 int dw = QApplication::desktop()->width(); 122 int dw = QApplication::desktop()->width();
123 int dh = QApplication::desktop()->height(); 123 int dh = QApplication::desktop()->height();
124 move( (dw-width())/2, (dh - height() )/2 ); 124 move( (dw-width())/2, (dh - height() )/2 );
125 } 125 }
126 126
127public: 127public:
128 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 128 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
129 QCheckBox* mWriteBackFuture; 129 QCheckBox* mWriteBackFuture;
130 QSpinBox* mWriteBackFutureWeeks; 130 QSpinBox* mWriteBackFutureWeeks;
131}; 131};
132 132
133QPixmap* sgListViewCompletedPix[6]; 133QPixmap* sgListViewCompletedPix[6];
134 134
135 135
136int globalFlagBlockStartup; 136int globalFlagBlockStartup;
137MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 137MainWindow::MainWindow( QWidget *parent, const char *name ) :
138 QMainWindow( parent, name ) 138 QMainWindow( parent, name )
139{ 139{
140 sgListViewCompletedPix[5] = &listviewPix; 140 sgListViewCompletedPix[5] = &listviewPix;
141 sgListViewCompletedPix[0] = &listviewPix0; 141 sgListViewCompletedPix[0] = &listviewPix0;
142 sgListViewCompletedPix[1] = &listviewPix20; 142 sgListViewCompletedPix[1] = &listviewPix20;
143 sgListViewCompletedPix[2] = &listviewPix40; 143 sgListViewCompletedPix[2] = &listviewPix40;
144 sgListViewCompletedPix[3] = &listviewPix60; 144 sgListViewCompletedPix[3] = &listviewPix60;
145 sgListViewCompletedPix[4] = &listviewPix80; 145 sgListViewCompletedPix[4] = &listviewPix80;
146 if ( sgListViewCompletedPix[5]->height() < 5 ) { 146 if ( sgListViewCompletedPix[5]->height() < 5 ) {
147 int size = 12; 147 //int size = 12;
148 sgListViewCompletedPix[5]->resize( 11, 11 ); 148 sgListViewCompletedPix[5]->resize( 11, 11 );
149 sgListViewCompletedPix[5]->fill( Qt::white ); 149 sgListViewCompletedPix[5]->fill( Qt::white );
150 QPainter p ( sgListViewCompletedPix[5] ); 150 QPainter p ( sgListViewCompletedPix[5] );
151 p.drawRect( 0,0,11,11); 151 p.drawRect( 0,0,11,11);
152 int half = size/2;
153 int heihei = size/2;
154 int x = 1;
155 p.drawLine ( 2, 5, 4 , 7 ) ; 152 p.drawLine ( 2, 5, 4 , 7 ) ;
156 p.drawLine ( 4 , 7 , 8, 3) ; 153 p.drawLine ( 4 , 7 , 8, 3) ;
157 int iii = 0; 154 int iii = 0;
158 for ( iii = 0; iii < 5; ++iii ) { 155 for ( iii = 0; iii < 5; ++iii ) {
159 sgListViewCompletedPix[iii]->resize( 11, 11 ); 156 sgListViewCompletedPix[iii]->resize( 11, 11 );
160 sgListViewCompletedPix[iii]->fill( Qt::white ); 157 sgListViewCompletedPix[iii]->fill( Qt::white );
161 QPainter p ( sgListViewCompletedPix[iii] ); 158 QPainter p ( sgListViewCompletedPix[iii] );
162 p.drawRect( 0,0,11,11); 159 p.drawRect( 0,0,11,11);
163 if ( iii ) 160 if ( iii )
164 p.fillRect( 1,1,iii*2,9,Qt::gray ); 161 p.fillRect( 1,1,iii*2,9,Qt::gray );
165 } 162 }
166 } 163 }
167 mClosed = false; 164 mClosed = false;
168 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 165 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
169 QString confFile = locateLocal("config","korganizerrc"); 166 QString confFile = locateLocal("config","korganizerrc");
170 QFileInfo finf ( confFile ); 167 QFileInfo finf ( confFile );
171 bool showWarning = !finf.exists(); 168 bool showWarning = !finf.exists();
172 setIcon(SmallIcon( "ko24" ) ); 169 setIcon(SmallIcon( "ko24" ) );
173 mBlockAtStartup = true; 170 mBlockAtStartup = true;
174 mFlagKeyPressed = false; 171 mFlagKeyPressed = false;
175 setCaption("KO/Pi"); 172 setCaption("KO/Pi");
176 KOPrefs *p = KOPrefs::instance(); 173 KOPrefs *p = KOPrefs::instance();
177 //KPimGlobalPrefs::instance()->setGlobalConfig(); 174 //KPimGlobalPrefs::instance()->setGlobalConfig();
178 p->mCurrentDisplayedView = 0; 175 p->mCurrentDisplayedView = 0;
179 if ( p->mHourSize > 22 ) 176 if ( p->mHourSize > 22 )
180 p->mHourSize = 22; 177 p->mHourSize = 22;
181 QMainWindow::ToolBarDock tbd; 178 QMainWindow::ToolBarDock tbd;
182 if ( p->mToolBarHor ) { 179 if ( p->mToolBarHor ) {
183 if ( p->mToolBarUp ) 180 if ( p->mToolBarUp )
184 tbd = Bottom; 181 tbd = Bottom;
185 else 182 else
186 tbd = Top; 183 tbd = Top;
187 } 184 }
188 else { 185 else {
189 if ( p->mToolBarUp ) 186 if ( p->mToolBarUp )
190 tbd = Right; 187 tbd = Right;
191 else 188 else
192 tbd = Left; 189 tbd = Left;
193 } 190 }
194 if ( KOPrefs::instance()->mUseAppColors ) 191 if ( KOPrefs::instance()->mUseAppColors )
195 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 192 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
196 globalFlagBlockStartup = 1; 193 globalFlagBlockStartup = 1;
197 iconToolBar = new QPEToolBar( this ); 194 iconToolBar = new QPEToolBar( this );
198 addToolBar (iconToolBar , tbd ); 195 addToolBar (iconToolBar , tbd );
199 196
200#ifdef DESKTOP_VERSION 197#ifdef DESKTOP_VERSION
201 if ( KOPrefs::instance()->mShowIconFilter ) 198 if ( KOPrefs::instance()->mShowIconFilter )
202#else 199#else
@@ -299,97 +296,96 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
299 mView->setSyncManager(mSyncManager); 296 mView->setSyncManager(mSyncManager);
300#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
301 iconToolBar->show(); 298 iconToolBar->show();
302 qApp->processEvents(); 299 qApp->processEvents();
303#endif 300#endif
304 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 301 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
305 int vh = height() ; 302 int vh = height() ;
306 int vw = width(); 303 int vw = width();
307 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 304 //qDebug("Toolbar hei %d ",iconToolBar->height() );
308 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 305 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
309 vh -= iconToolBar->height(); 306 vh -= iconToolBar->height();
310 } else { 307 } else {
311 vw -= iconToolBar->height(); 308 vw -= iconToolBar->height();
312 } 309 }
313 //mView->setMaximumSize( splash->size() ); 310 //mView->setMaximumSize( splash->size() );
314 //mView->resize( splash->size() ); 311 //mView->resize( splash->size() );
315 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 312 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
316 mView->readSettings(); 313 mView->readSettings();
317 bool newFile = false; 314 bool newFile = false;
318 if( !QFile::exists( defaultFileName() ) ) { 315 if( !QFile::exists( defaultFileName() ) ) {
319 QFileInfo finfo ( defaultFileName() ); 316 QFileInfo finfo ( defaultFileName() );
320 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 317 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
321 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"; 318 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";
322 finfo.setFile( oldFile ); 319 finfo.setFile( oldFile );
323 if (finfo.exists() ) { 320 if (finfo.exists() ) {
324 KMessageBox::information( this, message); 321 KMessageBox::information( this, message);
325 mView->openCalendar( oldFile ); 322 mView->openCalendar( oldFile );
326 qApp->processEvents(); 323 qApp->processEvents();
327 } else { 324 } else {
328 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 325 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
329 finfo.setFile( oldFile ); 326 finfo.setFile( oldFile );
330 if (finfo.exists() ) { 327 if (finfo.exists() ) {
331 KMessageBox::information( this, message); 328 KMessageBox::information( this, message);
332 mView->openCalendar( oldFile ); 329 mView->openCalendar( oldFile );
333 qApp->processEvents(); 330 qApp->processEvents();
334 } 331 }
335 } 332 }
336 mView->saveCalendar( defaultFileName() ); 333 mView->saveCalendar( defaultFileName() );
337 newFile = true; 334 newFile = true;
338 } 335 }
339 336
340 QTime neededSaveTime = QDateTime::currentDateTime().time(); 337 QTime neededSaveTime = QDateTime::currentDateTime().time();
341 mView->loadCalendars(); 338 mView->loadCalendars();
342 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 339 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
343 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 340 qDebug("KO: Calendar loading time: %d ms",msNeeded );
344 341
345 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 342 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
346 KOPrefs::instance()->setAllDefaults(); 343 KOPrefs::instance()->setAllDefaults();
347 int count = mView->addCategories();
348 } 344 }
349 processIncidenceSelection( 0 ); 345 processIncidenceSelection( 0 );
350 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 346 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
351 SLOT( processIncidenceSelection( Incidence * ) ) ); 347 SLOT( processIncidenceSelection( Incidence * ) ) );
352 connect( mView, SIGNAL( modifiedChanged( bool ) ), 348 connect( mView, SIGNAL( modifiedChanged( bool ) ),
353 SLOT( slotModifiedChanged( bool ) ) ); 349 SLOT( slotModifiedChanged( bool ) ) );
354 350
355 351
356 connect( mView, SIGNAL( tempDisableBR(bool) ), 352 connect( mView, SIGNAL( tempDisableBR(bool) ),
357 SLOT( disableBR(bool) ) ); 353 SLOT( disableBR(bool) ) );
358 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 354 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
359 mView->setModified( false ); 355 mView->setModified( false );
360 mBlockAtStartup = false; 356 mBlockAtStartup = false;
361 mView->setModified( false ); 357 mView->setModified( false );
362 setCentralWidget( mView ); 358 setCentralWidget( mView );
363 globalFlagBlockStartup = 0; 359 globalFlagBlockStartup = 0;
364 mView->show(); 360 mView->show();
365 delete splash; 361 delete splash;
366 if ( newFile ) 362 if ( newFile )
367 mView->updateConfig(); 363 mView->updateConfig();
368 // qApp->processEvents(); 364 // qApp->processEvents();
369 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 365 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
370 //fillSyncMenu(); 366 //fillSyncMenu();
371 367
372 368
373 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 369 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
374 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 370 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
375 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 371 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
376 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 372 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
377 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 373 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
378 mSyncManager->setDefaultFileName( sentSyncFile()); 374 mSyncManager->setDefaultFileName( sentSyncFile());
379 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 375 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
380 mSyncManager->fillSyncMenu(); 376 mSyncManager->fillSyncMenu();
381 377
382 378
383 379
384 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 380 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
385 if ( showWarning ) { 381 if ( showWarning ) {
386 KMessageBox::information( this, 382 KMessageBox::information( this,
387 "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"); 383 "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");
388 qApp->processEvents(); 384 qApp->processEvents();
389 mView->dialogManager()->showSyncOptions(); 385 mView->dialogManager()->showSyncOptions();
390 } 386 }
391 387
392 //US listen for result adressed from Ka/Pi 388 //US listen for result adressed from Ka/Pi
393#ifndef DESKTOP_VERSION 389#ifndef DESKTOP_VERSION
394 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 390 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
395#endif 391#endif
@@ -1810,145 +1806,145 @@ void MainWindow::saveOnClose()
1810 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1806 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1811 } 1807 }
1812#ifdef DESKTOP_VERSION 1808#ifdef DESKTOP_VERSION
1813 1809
1814 QPoint myP; 1810 QPoint myP;
1815 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1811 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1816 if ( p->mToolBarHor ) 1812 if ( p->mToolBarHor )
1817 p->mToolBarUp = myP.y() > height()/2; 1813 p->mToolBarUp = myP.y() > height()/2;
1818 else 1814 else
1819 p->mToolBarUp = myP.x() > width()/2; 1815 p->mToolBarUp = myP.x() > width()/2;
1820 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1816 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1821 if ( p->mToolBarHorV ) 1817 if ( p->mToolBarHorV )
1822 p->mToolBarUpV = myP.y() > height()/2; 1818 p->mToolBarUpV = myP.y() > height()/2;
1823 else 1819 else
1824 p->mToolBarUpV = myP.x() > width()/2 ; 1820 p->mToolBarUpV = myP.x() > width()/2 ;
1825 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1821 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1826 if ( p->mToolBarHorN ) 1822 if ( p->mToolBarHorN )
1827 p->mToolBarUpN = myP.y() > height()/2; 1823 p->mToolBarUpN = myP.y() > height()/2;
1828 else 1824 else
1829 p->mToolBarUpN = myP.x() > width()/2 ; 1825 p->mToolBarUpN = myP.x() > width()/2 ;
1830 if ( filterToolBar ) { 1826 if ( filterToolBar ) {
1831 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1827 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1832 if ( p->mToolBarHorF ) 1828 if ( p->mToolBarHorF )
1833 p->mToolBarUpF = myP.y() > height()/2; 1829 p->mToolBarUpF = myP.y() > height()/2;
1834 else 1830 else
1835 p->mToolBarUpF = myP.x() > width()/2 ; 1831 p->mToolBarUpF = myP.x() > width()/2 ;
1836 } 1832 }
1837#else 1833#else
1838 if ( p->mToolBarHor ) 1834 if ( p->mToolBarHor )
1839 p->mToolBarUp = iconToolBar->y() > height()/2; 1835 p->mToolBarUp = iconToolBar->y() > height()/2;
1840 else 1836 else
1841 p->mToolBarUp = iconToolBar->x() > width()/2; 1837 p->mToolBarUp = iconToolBar->x() > width()/2;
1842 if ( p->mToolBarHorV ) 1838 if ( p->mToolBarHorV )
1843 p->mToolBarUpV = viewToolBar->y() > height()/2; 1839 p->mToolBarUpV = viewToolBar->y() > height()/2;
1844 else 1840 else
1845 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1841 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1846 1842
1847 if ( p->mToolBarHorN ) 1843 if ( p->mToolBarHorN )
1848 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1844 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1849 else 1845 else
1850 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1846 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1851 if ( filterToolBar ) { 1847 if ( filterToolBar ) {
1852 if ( p->mToolBarHorF ) 1848 if ( p->mToolBarHorF )
1853 p->mToolBarUpF = filterToolBar->y() > height()/2; 1849 p->mToolBarUpF = filterToolBar->y() > height()/2;
1854 else 1850 else
1855 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1851 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1856 } 1852 }
1857#endif 1853#endif
1858
1859 save(); 1854 save();
1860 mView->writeSettings(); 1855 mView->writeSettings();
1856 mView->checkSuspendAlarm();
1861} 1857}
1862void MainWindow::slotModifiedChanged( bool changed ) 1858void MainWindow::slotModifiedChanged( bool )
1863{ 1859{
1864 if ( mBlockAtStartup ) 1860 if ( mBlockAtStartup )
1865 return; 1861 return;
1866 1862
1867 int msec; 1863 int msec;
1868 // we store the changes after 1 minute, 1864 // we store the changes after 1 minute,
1869 // and for safety reasons after 10 minutes again 1865 // and for safety reasons after 10 minutes again
1870 if ( !mSyncManager->blockSave() ) 1866 if ( !mSyncManager->blockSave() )
1871 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1867 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1872 else 1868 else
1873 msec = 1000 * 600; 1869 msec = 1000 * 600;
1874 mSaveTimer.start( msec, true ); // 1 minute 1870 mSaveTimer.start( msec, true ); // 1 minute
1875 qDebug("KO: Saving File in %d secs!", msec/1000); 1871 qDebug("KO: Saving File in %d secs!", msec/1000);
1876 mCalendarModifiedFlag = true; 1872 mCalendarModifiedFlag = true;
1877} 1873}
1878void MainWindow::saveStopTimer() 1874void MainWindow::saveStopTimer()
1879{ 1875{
1880 mSaveTimer.stop(); 1876 mSaveTimer.stop();
1881} 1877}
1882void MainWindow::backupAllFiles() 1878void MainWindow::backupAllFiles()
1883{ 1879{
1884 QDate reference ( 2000,1,1); 1880 QDate reference ( 2000,1,1);
1885 int daysTo = reference.daysTo ( QDate::currentDate() ); 1881 int daysTo = reference.daysTo ( QDate::currentDate() );
1886 setCaption(i18n("Creating backup ... please wait ..." )); 1882 setCaption(i18n("Creating backup ... please wait ..." ));
1887 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1883 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1888 // we need the file path, the backup dir and the number of bups as param 1884 // we need the file path, the backup dir and the number of bups as param
1889 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1885 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1890 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1886 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1891 bupDir = KGlobalSettings::backupDataDir(); 1887 bupDir = KGlobalSettings::backupDataDir();
1892 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1888 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1893 if ( retval == 0 ) { 1889 if ( retval == 0 ) {
1894 setCaption(i18n("Backup cancelled" )); 1890 setCaption(i18n("Backup cancelled" ));
1895 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1891 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1896 // retval == 0 : backup skipped for today, try again tomorrow 1892 // retval == 0 : backup skipped for today, try again tomorrow
1897 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1893 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1898 } else if ( retval == 1 ){ 1894 } else if ( retval == 1 ){
1899 qDebug("KO: Backup created."); 1895 qDebug("KO: Backup created.");
1900 // backup ok 1896 // backup ok
1901 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1897 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1902 KopiCalendarFile * cal = calendars.first(); 1898 KopiCalendarFile * cal = calendars.first();
1903 cal = calendars.next(); 1899 cal = calendars.next();
1904 while ( cal ) { 1900 while ( cal ) {
1905 if ( !cal->mErrorOnLoad ) { 1901 if ( !cal->mErrorOnLoad ) {
1906 int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1902 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1907 } 1903 }
1908 cal = calendars.next(); 1904 cal = calendars.next();
1909 } 1905 }
1910 KOPrefs::instance()->mLastBackupDate = daysTo; 1906 KOPrefs::instance()->mLastBackupDate = daysTo;
1911 setCaption(i18n("Backup succesfully finished" )); 1907 setCaption(i18n("Backup succesfully finished" ));
1912 } else if ( retval == 2 ){ 1908 } else if ( retval == 2 ){
1913 setCaption(i18n("Backup globally disabled" )); 1909 setCaption(i18n("Backup globally disabled" ));
1914 qDebug("KO: Backup globally cancelled."); 1910 qDebug("KO: Backup globally cancelled.");
1915 // backup globally cancelled 1911 // backup globally cancelled
1916 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1912 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1917 } 1913 }
1918 // retval == 3: do nothing, try again later 1914 // retval == 3: do nothing, try again later
1919} 1915}
1920void MainWindow::save() 1916void MainWindow::save()
1921{ 1917{
1922 if ( mView->viewManager()->journalView() ) 1918 if ( mView->viewManager()->journalView() )
1923 mView->viewManager()->journalView()->checkModified(); 1919 mView->viewManager()->journalView()->checkModified();
1924 if ( !mCalendarModifiedFlag ) { 1920 if ( !mCalendarModifiedFlag ) {
1925 qDebug("KO: Calendar not modified. Nothing saved."); 1921 qDebug("KO: Calendar not modified. Nothing saved.");
1926 return; 1922 return;
1927 } 1923 }
1928 if ( mSyncManager->blockSave() ) 1924 if ( mSyncManager->blockSave() )
1929 return; 1925 return;
1930 mSyncManager->setBlockSave(true); 1926 mSyncManager->setBlockSave(true);
1931 if ( mView->checkAllFileVersions() ) { 1927 if ( mView->checkAllFileVersions() ) {
1932 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1928 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1933 QDate reference ( 2000,1,1); 1929 QDate reference ( 2000,1,1);
1934 int daysTo = reference.daysTo ( QDate::currentDate() ); 1930 int daysTo = reference.daysTo ( QDate::currentDate() );
1935 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1931 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1936 backupAllFiles(); 1932 backupAllFiles();
1937 } 1933 }
1938 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1934 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1939 } 1935 }
1940 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1936 QTime neededSaveTime = QDateTime::currentDateTime().time();
1941 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1937 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1942 qDebug("KO: Start saving data to file!"); 1938 qDebug("KO: Start saving data to file!");
1943 mView->saveCalendars(); 1939 mView->saveCalendars();
1944 mCalendarModifiedFlag = false; 1940 mCalendarModifiedFlag = false;
1945 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1941 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1946 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1942 qDebug("KO: Needed %d ms for saving.",msNeeded );
1947 QString savemes; 1943 QString savemes;
1948 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1944 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1949 setCaption(savemes); 1945 setCaption(savemes);
1950 } else 1946 } else
1951 setCaption(i18n("Saving cancelled!")); 1947 setCaption(i18n("Saving cancelled!"));
1952 mSyncManager->setBlockSave( false ); 1948 mSyncManager->setBlockSave( false );
1953} 1949}
1954 1950
@@ -2363,100 +2359,99 @@ void MainWindow::saveCalendar()
2363void MainWindow::loadCalendar() 2359void MainWindow::loadCalendar()
2364{ 2360{
2365 2361
2366 2362
2367#if 0 2363#if 0
2368 QString fn = KOPrefs::instance()->mLastLoadFile; 2364 QString fn = KOPrefs::instance()->mLastLoadFile;
2369 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2365 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2370 2366
2371 if ( fn == "" ) 2367 if ( fn == "" )
2372 return; 2368 return;
2373 QFileInfo info; 2369 QFileInfo info;
2374 info.setFile( fn ); 2370 info.setFile( fn );
2375 QString mess; 2371 QString mess;
2376 bool loadbup = true; 2372 bool loadbup = true;
2377 if ( info. exists() ) { 2373 if ( info. exists() ) {
2378 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2374 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2379 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2375 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2380 mess, 2376 mess,
2381 i18n("Load!"), i18n("Cancel"), 0, 2377 i18n("Load!"), i18n("Cancel"), 0,
2382 0, 1 ); 2378 0, 1 );
2383 if ( result != 0 ) { 2379 if ( result != 0 ) {
2384 loadbup = false; 2380 loadbup = false;
2385 } 2381 }
2386 } else { 2382 } else {
2387 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2383 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2388 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2384 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2389 0, 1 ); 2385 0, 1 );
2390 2386
2391 return; 2387 return;
2392 } 2388 }
2393 if ( loadbup ) { 2389 if ( loadbup ) {
2394 mView->openCalendar( fn ); 2390 mView->openCalendar( fn );
2395 KOPrefs::instance()->mLastLoadFile = fn; 2391 KOPrefs::instance()->mLastLoadFile = fn;
2396 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2392 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2397 setCaption(mess); 2393 setCaption(mess);
2398 } 2394 }
2399#endif 2395#endif
2400 2396
2401} 2397}
2402void MainWindow::quickImportIcal() 2398void MainWindow::quickImportIcal()
2403{ 2399{
2404 importFile( KOPrefs::instance()->mLastImportFile, false ); 2400 importFile( KOPrefs::instance()->mLastImportFile, false );
2405} 2401}
2406void MainWindow::importFile( QString fn, bool quick ) 2402void MainWindow::importFile( QString fn, bool quick )
2407{ 2403{
2408 QFileInfo info; 2404 QFileInfo info;
2409 info.setFile( fn ); 2405 info.setFile( fn );
2410 QString mess; 2406 QString mess;
2411 bool loadbup = true;
2412 if ( !info. exists() ) { 2407 if ( !info. exists() ) {
2413 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2408 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2414 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2409 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2415 mess ); 2410 mess );
2416 return; 2411 return;
2417 } 2412 }
2418 int result = 0; 2413 int result = 0;
2419 if ( !quick ) { 2414 if ( !quick ) {
2420 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 )); 2415 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 ));
2421 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2416 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2422 mess, 2417 mess,
2423 "Import", "Cancel", 0, 2418 "Import", "Cancel", 0,
2424 0, 1 ); 2419 0, 1 );
2425 } 2420 }
2426 if ( result == 0 ) { 2421 if ( result == 0 ) {
2427 if ( mView->openCalendar( fn, true )) { 2422 if ( mView->openCalendar( fn, true )) {
2428 KOPrefs::instance()->mLastImportFile = fn; 2423 KOPrefs::instance()->mLastImportFile = fn;
2429 setCaption(i18n("Imported file successfully")); 2424 setCaption(i18n("Imported file successfully"));
2430 } else { 2425 } else {
2431 setCaption(i18n("Error importing file")); 2426 setCaption(i18n("Error importing file"));
2432 } 2427 }
2433 } 2428 }
2434} 2429}
2435 2430
2436void MainWindow::importIcal() 2431void MainWindow::importIcal()
2437{ 2432{
2438 2433
2439 QString fn =KOPrefs::instance()->mLastImportFile; 2434 QString fn =KOPrefs::instance()->mLastImportFile;
2440 2435
2441 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2436 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2442 if ( fn == "" ) 2437 if ( fn == "" )
2443 return; 2438 return;
2444 importFile( fn, true ); 2439 importFile( fn, true );
2445 2440
2446} 2441}
2447 2442
2448void MainWindow::exportVCalendar() 2443void MainWindow::exportVCalendar()
2449{ 2444{
2450 QString fn = KOPrefs::instance()->mLastVcalFile; 2445 QString fn = KOPrefs::instance()->mLastVcalFile;
2451 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2446 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2452 if ( fn == "" ) 2447 if ( fn == "" )
2453 return; 2448 return;
2454 QFileInfo info; 2449 QFileInfo info;
2455 info.setFile( fn ); 2450 info.setFile( fn );
2456 QString mes; 2451 QString mes;
2457 bool createbup = true; 2452 bool createbup = true;
2458 if ( info. exists() ) { 2453 if ( info. exists() ) {
2459 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2454 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2460 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2455 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2461 i18n("Overwrite!"), i18n("Cancel"), 0, 2456 i18n("Overwrite!"), i18n("Cancel"), 0,
2462 0, 1 ); 2457 0, 1 );