summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-21 17:43:18 (UTC)
committer zautrix <zautrix>2005-04-21 17:43:18 (UTC)
commitfd38343ef53c9b2a48208f747100579703cc1814 (patch) (unidiff)
tree2aeabdf01986d59d72044615b952a65b4d8ba292 /korganizer
parent0a13a3490ec3bf4735e3435f80f58fa7d50b4448 (diff)
downloadkdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.zip
kdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.tar.gz
kdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.tar.bz2
backup impl
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/mainwindow.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 68e5e5a..9ad0694 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -40,48 +40,49 @@
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 "externalapphandler.h" 63#include "externalapphandler.h"
64#include <kglobalsettings.h>
64 65
65using namespace KCal; 66using namespace KCal;
66#ifndef _WIN32_ 67#ifndef _WIN32_
67#include <unistd.h> 68#include <unistd.h>
68#else 69#else
69#ifdef _OL_IMPORT_ 70#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 71#include "koimportoldialog.h"
71#endif 72#endif
72#endif 73#endif
73#include "mainwindow.h" 74#include "mainwindow.h"
74 75
75 76
76class KOex2phonePrefs : public QDialog 77class KOex2phonePrefs : public QDialog
77{ 78{
78 public: 79 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 81 QDialog( parent, name, true )
81 { 82 {
82 setCaption( i18n("Export to phone options") ); 83 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 84 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 85 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 86 lay->setMargin( 3 );
86 QLabel *lab; 87 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
@@ -1780,48 +1781,77 @@ void MainWindow::slotModifiedChanged( bool changed )
1780 // we store the changes after 1 minute, 1781 // we store the changes after 1 minute,
1781 // and for safety reasons after 10 minutes again 1782 // and for safety reasons after 10 minutes again
1782 if ( !mSyncManager->blockSave() ) 1783 if ( !mSyncManager->blockSave() )
1783 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1784 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1784 else 1785 else
1785 msec = 1000 * 600; 1786 msec = 1000 * 600;
1786 mSaveTimer.start( msec, true ); // 1 minute 1787 mSaveTimer.start( msec, true ); // 1 minute
1787 qDebug("KO: Saving File in %d secs!", msec/1000); 1788 qDebug("KO: Saving File in %d secs!", msec/1000);
1788 mCalendarModifiedFlag = true; 1789 mCalendarModifiedFlag = true;
1789} 1790}
1790void MainWindow::saveStopTimer() 1791void MainWindow::saveStopTimer()
1791{ 1792{
1792 mSaveTimer.stop(); 1793 mSaveTimer.stop();
1793} 1794}
1794void MainWindow::save() 1795void MainWindow::save()
1795{ 1796{
1796 if ( !mCalendarModifiedFlag ) { 1797 if ( !mCalendarModifiedFlag ) {
1797 qDebug("KO: Calendar not modified. Nothing saved."); 1798 qDebug("KO: Calendar not modified. Nothing saved.");
1798 return; 1799 return;
1799 } 1800 }
1800 if ( mSyncManager->blockSave() ) 1801 if ( mSyncManager->blockSave() )
1801 return; 1802 return;
1802 mSyncManager->setBlockSave(true); 1803 mSyncManager->setBlockSave(true);
1803 if ( mView->checkFileVersion( defaultFileName()) ) { 1804 if ( mView->checkFileVersion( defaultFileName()) ) {
1805 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1806 QDate reference ( 2000,1,1);
1807 int daysTo = reference.daysTo ( QDate::currentDate() );
1808 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1809 setCaption(i18n("KO/Pi:Creating backup ... please wait ..." ));
1810 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1811 // we need the file path, the backup dir and the number of bups as param
1812 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1813 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1814 bupDir = KGlobalSettings::backupDataDir();
1815 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );//55;//call backup
1816 if ( retval == 0 ) {
1817 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1818 // retval == 0 : backup skipped for today, try again tomorrow
1819 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1820 } else if ( retval == 1 ){
1821 qDebug("KO: Backup created.");
1822 // backup ok
1823 KOPrefs::instance()->mLastBackupDate = daysTo;
1824
1825 } else if ( retval == 2 ){
1826 qDebug("KO: Backup globally cancelled.");
1827 // backup globally cancelled
1828 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1829 }
1830 // retval == 3: do nothing, try again later
1831 }
1832 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1833 }
1804 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1834 QTime neededSaveTime = QDateTime::currentDateTime().time();
1805 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1835 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1806 qDebug("KO: Start saving data to file!"); 1836 qDebug("KO: Start saving data to file!");
1807 mView->saveCalendar( defaultFileName() ); 1837 mView->saveCalendar( defaultFileName() );
1808 mCalendarModifiedFlag = false; 1838 mCalendarModifiedFlag = false;
1809 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1839 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1810 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1840 qDebug("KO: Needed %d ms for saving.",msNeeded );
1811 QString savemes; 1841 QString savemes;
1812 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1842 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1813 setCaption(savemes); 1843 setCaption(savemes);
1814 } else 1844 } else
1815 setCaption(i18n("Saving cancelled!")); 1845 setCaption(i18n("Saving cancelled!"));
1816 mSyncManager->setBlockSave( false ); 1846 mSyncManager->setBlockSave( false );
1817} 1847}
1818 1848
1819void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1849void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1820{ 1850{
1821 if ( !e->isAutoRepeat() ) { 1851 if ( !e->isAutoRepeat() ) {
1822 mFlagKeyPressed = false; 1852 mFlagKeyPressed = false;
1823 } 1853 }
1824} 1854}
1825void MainWindow::keyPressEvent ( QKeyEvent * e ) 1855void MainWindow::keyPressEvent ( QKeyEvent * e )
1826{ 1856{
1827 qApp->processEvents(); 1857 qApp->processEvents();