summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-06-26 13:45:09 (UTC)
committer zautrix <zautrix>2005-06-26 13:45:09 (UTC)
commitbb565390dd1c31929780df60e2bb06e9259f4d0b (patch) (unidiff)
tree3f9f8b72ba68958553e8b20f5061ab55ec7b50f1 /korganizer
parentd9255cd129d42abf08efc11ff9b29e831e05e803 (diff)
downloadkdepimpi-bb565390dd1c31929780df60e2bb06e9259f4d0b.zip
kdepimpi-bb565390dd1c31929780df60e2bb06e9259f4d0b.tar.gz
kdepimpi-bb565390dd1c31929780df60e2bb06e9259f4d0b.tar.bz2
fixxx
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp113
-rw-r--r--korganizer/mainwindow.h1
2 files changed, 57 insertions, 57 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 48320a5..b9d8742 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1024,29 +1024,30 @@ void MainWindow::initActions()
1024 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 1024 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
1025 //#else 1025 //#else
1026#ifdef _OL_IMPORT_ 1026#ifdef _OL_IMPORT_
1027 importMenu_X->insertSeparator(); 1027 importMenu_X->insertSeparator();
1028 action = new QAction( "import_ol", i18n("Import from OL"), 0, 1028 action = new QAction( "import_ol", i18n("Import from OL"), 0,
1029 this ); 1029 this );
1030 action->addTo( importMenu_X ); 1030 action->addTo( importMenu_X );
1031 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 1031 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
1032#endif 1032#endif
1033 //#endif 1033 //#endif
1034 1034
1035 //importMenu->insertSeparator(); 1035 //importMenu->insertSeparator();
1036#if 0
1036 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 1037 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
1037 this ); 1038 this );
1038 action->addTo( importMenu ); 1039 action->addTo( importMenu );
1039 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 1040 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
1040 1041#endif
1041 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 1042 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
1042 this ); 1043 this );
1043 action->addTo( importMenu ); 1044 action->addTo( importMenu );
1044 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1045 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1045 importMenu->insertSeparator(); 1046 importMenu->insertSeparator();
1046 importMenu->insertItem( i18n("Import"), importMenu_X ); 1047 importMenu->insertItem( i18n("Import"), importMenu_X );
1047 //importMenu->insertSeparator(); 1048 //importMenu->insertSeparator();
1048 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1049 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1049 this ); 1050 this );
1050 action->addTo( exportMenu_X ); 1051 action->addTo( exportMenu_X );
1051 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1052 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1052 1053
@@ -1836,70 +1837,79 @@ void MainWindow::slotModifiedChanged( bool changed )
1836 if ( !mSyncManager->blockSave() ) 1837 if ( !mSyncManager->blockSave() )
1837 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1838 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1838 else 1839 else
1839 msec = 1000 * 600; 1840 msec = 1000 * 600;
1840 mSaveTimer.start( msec, true ); // 1 minute 1841 mSaveTimer.start( msec, true ); // 1 minute
1841 qDebug("KO: Saving File in %d secs!", msec/1000); 1842 qDebug("KO: Saving File in %d secs!", msec/1000);
1842 mCalendarModifiedFlag = true; 1843 mCalendarModifiedFlag = true;
1843} 1844}
1844void MainWindow::saveStopTimer() 1845void MainWindow::saveStopTimer()
1845{ 1846{
1846 mSaveTimer.stop(); 1847 mSaveTimer.stop();
1847} 1848}
1849void MainWindow::backupAllFiles()
1850{
1851 QDate reference ( 2000,1,1);
1852 int daysTo = reference.daysTo ( QDate::currentDate() );
1853 setCaption(i18n("Creating backup ... please wait ..." ));
1854 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1855 // we need the file path, the backup dir and the number of bups as param
1856 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1857 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1858 bupDir = KGlobalSettings::backupDataDir();
1859 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1860 if ( retval == 0 ) {
1861 setCaption(i18n("Backup cancelled" ));
1862 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1863 // retval == 0 : backup skipped for today, try again tomorrow
1864 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1865 } else if ( retval == 1 ){
1866 qDebug("KO: Backup created.");
1867 // backup ok
1868 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1869 KopiCalendarFile * cal = calendars.first();
1870 cal = calendars.next();
1871 while ( cal ) {
1872 if ( !cal->mErrorOnLoad ) {
1873 int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1874 }
1875 cal = calendars.next();
1876 }
1877 KOPrefs::instance()->mLastBackupDate = daysTo;
1878 setCaption(i18n("Backup succesfully finished" ));
1879 } else if ( retval == 2 ){
1880 setCaption(i18n("Backup globally disabled" ));
1881 qDebug("KO: Backup globally cancelled.");
1882 // backup globally cancelled
1883 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1884 }
1885 // retval == 3: do nothing, try again later
1886}
1848void MainWindow::save() 1887void MainWindow::save()
1849{ 1888{
1850 if ( !mCalendarModifiedFlag ) { 1889 if ( !mCalendarModifiedFlag ) {
1851 qDebug("KO: Calendar not modified. Nothing saved."); 1890 qDebug("KO: Calendar not modified. Nothing saved.");
1852 return; 1891 return;
1853 } 1892 }
1854 if ( mSyncManager->blockSave() ) 1893 if ( mSyncManager->blockSave() )
1855 return; 1894 return;
1856 mSyncManager->setBlockSave(true); 1895 mSyncManager->setBlockSave(true);
1857 if ( mView->checkAllFileVersions() ) { 1896 if ( mView->checkAllFileVersions() ) {
1858 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1897 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1859 QDate reference ( 2000,1,1); 1898 QDate reference ( 2000,1,1);
1860 int daysTo = reference.daysTo ( QDate::currentDate() ); 1899 int daysTo = reference.daysTo ( QDate::currentDate() );
1861 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1900 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1862 setCaption(i18n("Creating backup ... please wait ..." )); 1901 backupAllFiles();
1863 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1864 // we need the file path, the backup dir and the number of bups as param
1865 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1866 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1867 bupDir = KGlobalSettings::backupDataDir();
1868 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1869 if ( retval == 0 ) {
1870 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1871 // retval == 0 : backup skipped for today, try again tomorrow
1872 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1873 } else if ( retval == 1 ){
1874 qDebug("KO: Backup created.");
1875 // backup ok
1876 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1877 KopiCalendarFile * cal = calendars.first();
1878 cal = calendars.next();
1879 while ( cal ) {
1880 if ( !cal->mErrorOnLoad ) {
1881 int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1882 }
1883 cal = calendars.next();
1884 }
1885 KOPrefs::instance()->mLastBackupDate = daysTo;
1886 } else if ( retval == 2 ){
1887 qDebug("KO: Backup globally cancelled.");
1888 // backup globally cancelled
1889 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1890 }
1891 // retval == 3: do nothing, try again later
1892 } 1902 }
1893 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1903 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1894 } 1904 }
1895 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1905 QTime neededSaveTime = QDateTime::currentDateTime().time();
1896 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1906 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1897 qDebug("KO: Start saving data to file!"); 1907 qDebug("KO: Start saving data to file!");
1898 mView->saveCalendars(); 1908 mView->saveCalendars();
1899 mCalendarModifiedFlag = false; 1909 mCalendarModifiedFlag = false;
1900 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1910 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1901 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1911 qDebug("KO: Needed %d ms for saving.",msNeeded );
1902 QString savemes; 1912 QString savemes;
1903 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1913 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1904 setCaption(savemes); 1914 setCaption(savemes);
1905 } else 1915 } else
@@ -2291,53 +2301,41 @@ void MainWindow::showConfigureAgenda( )
2291 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2301 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2292} 2302}
2293void MainWindow::configureAgenda( int item ) 2303void MainWindow::configureAgenda( int item )
2294{ 2304{
2295 if ( KOPrefs::instance()->mHourSize == item ) 2305 if ( KOPrefs::instance()->mHourSize == item )
2296 return; 2306 return;
2297 KOPrefs::instance()->mHourSize=item; 2307 KOPrefs::instance()->mHourSize=item;
2298 mView->viewManager()->agendaView()->updateConfig(); 2308 mView->viewManager()->agendaView()->updateConfig();
2299} 2309}
2300 2310
2301void MainWindow::saveCalendar() 2311void MainWindow::saveCalendar()
2302{ 2312{
2303 QString fn = KOPrefs::instance()->mLastSaveFile; 2313
2304 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 2314 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2305 2315 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2306 if ( fn == "" ) 2316 bupDir = KGlobalSettings::backupDataDir();
2307 return; 2317 bupDir = KGlobal::formatMessage ( bupDir, 0 );
2308 QFileInfo info; 2318 QString bupHint;
2309 info.setFile( fn ); 2319 if ( !KPimGlobalPrefs::instance()->mBackupEnabled )
2310 QString mes; 2320 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)");
2311 bool createbup = true; 2321 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return;
2312 if ( info. exists() ) { 2322 backupAllFiles();
2313 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
2314 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2315 i18n("Overwrite!"), i18n("Cancel"), 0,
2316 0, 1 );
2317 if ( result != 0 ) {
2318 createbup = false;
2319 }
2320 }
2321 if ( createbup ) {
2322 mView->saveCalendar( fn );
2323 mes = i18n("KO/Pi:Saved %1").arg(fn);
2324 KOPrefs::instance()->mLastSaveFile = fn;
2325 setCaption(mes);
2326 }
2327} 2323}
2328void MainWindow::loadCalendar() 2324void MainWindow::loadCalendar()
2329{ 2325{
2330 2326
2331 QString fn = KOPrefs::instance()->mLastLoadFile; 2327
2328#if 0
2329 QString fn = KOPrefs::instance()->mLastLoadFile;
2332 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2330 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2333 2331
2334 if ( fn == "" ) 2332 if ( fn == "" )
2335 return; 2333 return;
2336 QFileInfo info; 2334 QFileInfo info;
2337 info.setFile( fn ); 2335 info.setFile( fn );
2338 QString mess; 2336 QString mess;
2339 bool loadbup = true; 2337 bool loadbup = true;
2340 if ( info. exists() ) { 2338 if ( info. exists() ) {
2341 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2339 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2342 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2340 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2343 mess, 2341 mess,
@@ -2350,24 +2348,25 @@ void MainWindow::loadCalendar()
2350 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2348 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2351 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2349 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2352 0, 1 ); 2350 0, 1 );
2353 2351
2354 return; 2352 return;
2355 } 2353 }
2356 if ( loadbup ) { 2354 if ( loadbup ) {
2357 mView->openCalendar( fn ); 2355 mView->openCalendar( fn );
2358 KOPrefs::instance()->mLastLoadFile = fn; 2356 KOPrefs::instance()->mLastLoadFile = fn;
2359 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2357 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2360 setCaption(mess); 2358 setCaption(mess);
2361 } 2359 }
2360#endif
2362 2361
2363} 2362}
2364void MainWindow::quickImportIcal() 2363void MainWindow::quickImportIcal()
2365{ 2364{
2366 importFile( KOPrefs::instance()->mLastImportFile, false ); 2365 importFile( KOPrefs::instance()->mLastImportFile, false );
2367} 2366}
2368void MainWindow::importFile( QString fn, bool quick ) 2367void MainWindow::importFile( QString fn, bool quick )
2369{ 2368{
2370 QFileInfo info; 2369 QFileInfo info;
2371 info.setFile( fn ); 2370 info.setFile( fn );
2372 QString mess; 2371 QString mess;
2373 bool loadbup = true; 2372 bool loadbup = true;
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 9a8bc7f..c9817c3 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -72,24 +72,25 @@ class MainWindow : public QMainWindow
72 void processIncidenceSelection( Incidence * ); 72 void processIncidenceSelection( Incidence * );
73 73
74 void importQtopia(); 74 void importQtopia();
75 void importBday(); 75 void importBday();
76 void importOL(); 76 void importOL();
77 void importIcal(); 77 void importIcal();
78 void importFile( QString, bool ); 78 void importFile( QString, bool );
79 void quickImportIcal(); 79 void quickImportIcal();
80 80
81 void slotModifiedChanged( bool ); 81 void slotModifiedChanged( bool );
82 82
83 void save(); 83 void save();
84 void backupAllFiles();
84 void saveStopTimer(); 85 void saveStopTimer();
85 void configureToolBar( int ); 86 void configureToolBar( int );
86 void printSel(); 87 void printSel();
87 void printCal(); 88 void printCal();
88 void printListView(); 89 void printListView();
89 void saveCalendar(); 90 void saveCalendar();
90 void loadCalendar(); 91 void loadCalendar();
91 void exportVCalendar(); 92 void exportVCalendar();
92 void fillFilterMenu(); 93 void fillFilterMenu();
93 void fillFilterMenuTB(); 94 void fillFilterMenuTB();
94 void selectFilter( int ); 95 void selectFilter( int );
95 void fillFilterMenuPopup(); 96 void fillFilterMenuPopup();