summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-21 17:43:18 (UTC)
committer zautrix <zautrix>2005-04-21 17:43:18 (UTC)
commitfd38343ef53c9b2a48208f747100579703cc1814 (patch) (unidiff)
tree2aeabdf01986d59d72044615b952a65b4d8ba292
parent0a13a3490ec3bf4735e3435f80f58fa7d50b4448 (diff)
downloadkdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.zip
kdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.tar.gz
kdepimpi-fd38343ef53c9b2a48208f747100579703cc1814.tar.bz2
backup impl
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt13
-rw-r--r--korganizer/mainwindow.cpp30
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.cpp28
-rw-r--r--libkdepim/kpimglobalprefs.cpp6
-rw-r--r--libkdepim/kpimprefs.cpp3
-rw-r--r--libkdepim/kpimprefs.h1
-rw-r--r--microkde/kapplication.cpp120
-rw-r--r--microkde/kapplication.h1
8 files changed, 196 insertions, 6 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index fa18304..9e9a1a1 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -1340,21 +1340,34 @@
1340{ "Stop todo","Stoppe Todo" }, 1340{ "Stop todo","Stoppe Todo" },
1341{ "Todo is stopped","Todo ist gestoppt" }, 1341{ "Todo is stopped","Todo ist gestoppt" },
1342{ "Start todo","Starte Todo" }, 1342{ "Start todo","Starte Todo" },
1343{ "The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?","Das Todo\n%1\nist gestoppt.\nWollen Sie es auf\ngestartet setzen?" }, 1343{ "The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?","Das Todo\n%1\nist gestoppt.\nWollen Sie es auf\ngestartet setzen?" },
1344{ "The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?","Das Todo\n%1\nwird geklont!\nEs hat Untertodos!\nMöchten Sie alle\nUntertodos auch klonen?" }, 1344{ "The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?","Das Todo\n%1\nwird geklont!\nEs hat Untertodos!\nMöchten Sie alle\nUntertodos auch klonen?" },
1345{ "Todo has subtodos","Todo hat Untertodos" }, 1345{ "Todo has subtodos","Todo hat Untertodos" },
1346{ "Block popup until mouse button release","Sperre Popup bis Mausknopf losgelassen" }, 1346{ "Block popup until mouse button release","Sperre Popup bis Mausknopf losgelassen" },
1347{ "Colors","Farben" }, 1347{ "Colors","Farben" },
1348{ "Click on new parent item","Klicke auf neues Übertodo" }, 1348{ "Click on new parent item","Klicke auf neues Übertodo" },
1349{ "Reparenting aborted!","Übertodo setzen abgebrochen" }, 1349{ "Reparenting aborted!","Übertodo setzen abgebrochen" },
1350{ "Cannot move Todo to itself\nor a child of itself","Kann nicht Todo auf\nsich selbst oder\nein Untertodo verschieben" }, 1350{ "Cannot move Todo to itself\nor a child of itself","Kann nicht Todo auf\nsich selbst oder\nein Untertodo verschieben" },
1351{ "Recursive reparenting not possible!","Rekursives Verschieben nicht möglich" }, 1351{ "Recursive reparenting not possible!","Rekursives Verschieben nicht möglich" },
1352{ "Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)","Entferne alle erledigten Todos?\n(Erledigte wiederholende Todos\nwerden nicht gelöscht!)" }, 1352{ "Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)","Entferne alle erledigten Todos?\n(Erledigte wiederholende Todos\nwerden nicht gelöscht!)" },
1353{ "Alternating background of list views","Abwechselnder Hintergrund für Listen" }, 1353{ "Alternating background of list views","Abwechselnder Hintergrund für Listen" },
1354{ "times","Zeiten" }, 1354{ "times","Zeiten" },
1355{ "The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?","Das Todo\n%1\nhat Untertodos!\nMöchten Sie die Kategorien\nauch für alle Untertodos setzen?" }, 1355{ "The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?","Das Todo\n%1\nhat Untertodos!\nMöchten Sie die Kategorien\nauch für alle Untertodos setzen?" },
1356{ "Backup enabled","Backup angeschaltet" },
1357{ "Use standard backup dir","Standard Backupverzeichnis" },
1358{ "Number of Backups:","Anzahl der Backups" },
1359{ "Make backup every ","Mache ein Backup alle " },
1360{ " days"," Tage" },
1361{ "","" },
1362{ "","" },
1363{ "","" },
1364{ "","" },
1365{ "","" },
1366{ "","" },
1367{ "","" },
1368{ "","" },
1356{ "","" }, 1369{ "","" },
1357{ "","" }, 1370{ "","" },
1358{ "","" }, 1371{ "","" },
1359{ "","" }, 1372{ "","" },
1360{ "","" }, 1373{ "","" },
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 68e5e5a..9ad0694 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -48,32 +48,33 @@
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 ) :
@@ -1788,32 +1789,61 @@ void MainWindow::slotModifiedChanged( bool changed )
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)
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
index fbfbc45..93538ec 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
@@ -119,52 +119,61 @@ void KDEPIMConfigWidget::showTimeZoneTab()
119 tabWidget->setCurrentPage ( 3 ) ; 119 tabWidget->setCurrentPage ( 3 ) ;
120} 120}
121void KDEPIMConfigWidget::setupBackupTab() 121void KDEPIMConfigWidget::setupBackupTab()
122{ 122{
123 QVBox *colorPage = new QVBox( this ); 123 QVBox *colorPage = new QVBox( this );
124 tabWidget->addTab( colorPage, i18n( "Backup" ) ); 124 tabWidget->addTab( colorPage, i18n( "Backup" ) );
125 QWidget* topFrame = new QWidget( colorPage ); 125 QWidget* topFrame = new QWidget( colorPage );
126 QVBoxLayout *topLayout = new QVBoxLayout(topFrame); 126 QVBoxLayout *topLayout = new QVBoxLayout(topFrame);
127 KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"), 127 KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"),
128 &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame); 128 &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame);
129 topLayout->addWidget((QWidget*)sb->checkBox()); 129 topLayout->addWidget((QWidget*)sb->checkBox());
130 QWidget* bupFrame = new QWidget( topFrame ); 130 QWidget* bupFrame = new QWidget( topFrame );
131 topLayout->addWidget((bupFrame)); 131 topLayout->addWidget((bupFrame));
132 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) ); 132 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) );
133 QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame); 133 QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame);
134 sb = addWidBool(i18n("Use standard backup dir"), 134 sb = addWidBool(i18n("Use standard backup dir"),
135 &(KPimGlobalPrefs::instance()->mBackupEnabled),bupFrame); 135 &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame);
136 bupLayout->addWidget((QWidget*)sb->checkBox()); 136 bupLayout->addWidget((QWidget*)sb->checkBox());
137 mBackupUrl = new KURLRequester( bupFrame ); 137 mBackupUrl = new KURLRequester( bupFrame );
138 mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); 138 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
139 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) ); 139 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) );
140 bupLayout->addWidget( mBackupUrl ); 140 bupLayout->addWidget( mBackupUrl );
141 141
142 142 mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir );
143 bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled );
143 QHBox *dummy = new QHBox(bupFrame); 144 QHBox *dummy = new QHBox(bupFrame);
144 new QLabel(i18n("Number of Backups:"),dummy); 145 new QLabel(i18n("Number of Backups:"),dummy);
145 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy); 146 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy);
146 new QLabel(i18n(" "),dummy); 147 new QLabel(i18n(" "),dummy);
147 bupLayout->addWidget( dummy ); 148 bupLayout->addWidget( dummy );
148 149
149 dummy = new QHBox(bupFrame); 150 dummy = new QHBox(bupFrame);
150 new QLabel(i18n("Make backup every "),dummy); 151 new QLabel(i18n("Make backup every "),dummy);
151 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy); 152 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy);
152 new QLabel(i18n(" days"),dummy); 153 new QLabel(i18n(" days"),dummy);
153 new QLabel(i18n(" "),dummy); 154 new QLabel(i18n(" "),dummy);
154 bupLayout->addWidget( dummy ); 155 bupLayout->addWidget( dummy );
156 QString localKdeDir;
157 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
158 if ( ! localKdeDir.isEmpty() ) {
159 sb->checkBox()->setEnabled( false );
160 sb->checkBox()->setChecked( true );
161 mBackupUrl->setEnabled( false );
162 KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true;
163 }
155 164
156} 165}
157void KDEPIMConfigWidget::setupStoreTab() 166void KDEPIMConfigWidget::setupStoreTab()
158{ 167{
159 QVBox *colorPage = new QVBox( this ); 168 QVBox *colorPage = new QVBox( this );
160 tabWidget->addTab( colorPage, i18n( "Colors" ) ); 169 tabWidget->addTab( colorPage, i18n( "Colors" ) );
161 QWidget* cw = new QWidget( colorPage ); 170 QWidget* cw = new QWidget( colorPage );
162 KPrefsWidColor *holidayColor = 171 KPrefsWidColor *holidayColor =
163 addWidColor(i18n("Alternating background of list views"), 172 addWidColor(i18n("Alternating background of list views"),
164 &(KPimGlobalPrefs::instance()->mAlternateColor),cw); 173 &(KPimGlobalPrefs::instance()->mAlternateColor),cw);
165 QHBoxLayout *topLayout = new QHBoxLayout(cw); 174 QHBoxLayout *topLayout = new QHBoxLayout(cw);
166 topLayout->addWidget(holidayColor->label()); 175 topLayout->addWidget(holidayColor->label());
167 topLayout->addWidget( (QWidget* )holidayColor->button()); 176 topLayout->addWidget( (QWidget* )holidayColor->button());
168 177
169 178
170 QVBox *storePage = new QVBox( this ); 179 QVBox *storePage = new QVBox( this );
@@ -793,45 +802,49 @@ void KDEPIMConfigWidget::updateClientWidgets()
793 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 802 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
794 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 803 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
795 } 804 }
796 805
797 806
798 blockSignals( blocked ); 807 blockSignals( blocked );
799 808
800} 809}
801 810
802void KDEPIMConfigWidget::usrReadConfig() 811void KDEPIMConfigWidget::usrReadConfig()
803{ 812{
804 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 813 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
805 814
806 bool blocked = signalsBlocked(); 815 bool blocked = signalsBlocked();
807 blockSignals( true ); 816 blockSignals( true );
808 817
818 if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir )
819 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
820 else
821 mBackupUrl->setURL(prefs->mBackupDatadir);
822 mBackupNumbersSpin->setValue( prefs->mBackupNumbers );
823 mBackupDayCountSpin->setValue( prefs->mBackupDayCount);
824
809 QString dummy = prefs->mUserDateFormatLong; 825 QString dummy = prefs->mUserDateFormatLong;
810 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); 826 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
811 dummy = prefs->mUserDateFormatShort; 827 dummy = prefs->mUserDateFormatShort;
812 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); 828 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
813 829
814 QDate current ( 2001, 1,1); 830 QDate current ( 2001, 1,1);
815 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1)); 831 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1));
816 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1)); 832 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1));
817 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId)); 833 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId));
818 834
819
820
821
822 mEmailClient = prefs->mEmailClient; 835 mEmailClient = prefs->mEmailClient;
823 mEmailOtherChannel = prefs->mEmailOtherChannel; 836 mEmailOtherChannel = prefs->mEmailOtherChannel;
824 mEmailOtherMessage = prefs->mEmailOtherMessage; 837 mEmailOtherMessage = prefs->mEmailOtherMessage;
825 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; 838 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters;
826 mEmailOtherMessage2 = prefs->mEmailOtherMessage2; 839 mEmailOtherMessage2 = prefs->mEmailOtherMessage2;
827 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; 840 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2;
828 841
829 mPhoneClient = prefs->mPhoneClient; 842 mPhoneClient = prefs->mPhoneClient;
830 mPhoneOtherChannel = prefs->mPhoneOtherChannel; 843 mPhoneOtherChannel = prefs->mPhoneOtherChannel;
831 mPhoneOtherMessage = prefs->mPhoneOtherMessage; 844 mPhoneOtherMessage = prefs->mPhoneOtherMessage;
832 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; 845 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters;
833 846
834 mFaxClient = prefs->mFaxClient; 847 mFaxClient = prefs->mFaxClient;
835 mFaxOtherChannel = prefs->mFaxOtherChannel; 848 mFaxOtherChannel = prefs->mFaxOtherChannel;
836 mFaxOtherMessage = prefs->mFaxOtherMessage; 849 mFaxOtherMessage = prefs->mFaxOtherMessage;
837 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters; 850 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters;
@@ -853,32 +866,35 @@ void KDEPIMConfigWidget::usrReadConfig()
853 866
854 mCurrentApp = ExternalAppHandler::EMAIL; 867 mCurrentApp = ExternalAppHandler::EMAIL;
855 mCurrentClient = mEmailClient; 868 mCurrentClient = mEmailClient;
856 869
857 updateClientWidgets(); 870 updateClientWidgets();
858 871
859 blockSignals( blocked ); 872 blockSignals( blocked );
860 873
861} 874}
862 875
863void KDEPIMConfigWidget::usrWriteConfig() 876void KDEPIMConfigWidget::usrWriteConfig()
864{ 877{
865 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 878 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
866 879
867 saveEditFieldSettings(); 880 saveEditFieldSettings();
868 881
882 prefs->mBackupNumbers = mBackupNumbersSpin->value();
883 prefs->mBackupDayCount = mBackupDayCountSpin->value();
884 prefs->mBackupDatadir = mBackupUrl->url();
869 885
870 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); 886 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
871 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); 887 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
872 888
873 prefs->mTimeZoneId = mTimeZoneCombo->currentText(); 889 prefs->mTimeZoneId = mTimeZoneCombo->currentText();
874 QDate date; 890 QDate date;
875 date = mStartDateSavingEdit->date(); 891 date = mStartDateSavingEdit->date();
876 int sub = 0; 892 int sub = 0;
877 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 893 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
878 sub = 1; 894 sub = 1;
879 prefs->mDaylightsavingStart = date.dayOfYear()-sub; 895 prefs->mDaylightsavingStart = date.dayOfYear()-sub;
880 date = mEndDateSavingEdit->date(); 896 date = mEndDateSavingEdit->date();
881 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 897 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
882 sub = 1; 898 sub = 1;
883 else 899 else
884 sub = 0; 900 sub = 0;
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index 90321b2..9c28425 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -187,32 +187,38 @@ void KPimGlobalPrefs::setGlobalConfig()
187 } 187 }
188 } 188 }
189 189
190 KGlobal::locale()->setHore24Format( !mPreferredTime ); 190 KGlobal::locale()->setHore24Format( !mPreferredTime );
191 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); 191 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday );
192 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); 192 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate );
193 KGlobal::locale()->setLanguage( mPreferredLanguage ); 193 KGlobal::locale()->setLanguage( mPreferredLanguage );
194 QString dummy = mUserDateFormatLong; 194 QString dummy = mUserDateFormatLong;
195 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 195 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
196 dummy = mUserDateFormatShort; 196 dummy = mUserDateFormatShort;
197 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 197 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
198 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, 198 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving,
199 mDaylightsavingStart, 199 mDaylightsavingStart,
200 mDaylightsavingEnd ); 200 mDaylightsavingEnd );
201 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); 201 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min );
202 KGlobalSettings::setAlternateBackgroundColor(mAlternateColor); 202 KGlobalSettings::setAlternateBackgroundColor(mAlternateColor);
203 QString localKdeDir;
204 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
205 if ( ! localKdeDir.isEmpty() ) {
206 mBackupUseDefaultDir = true;
207 mBackupDatadir = KGlobalSettings::backupDataDir();
208 }
203 209
204} 210}
205KPimGlobalPrefs::~KPimGlobalPrefs() 211KPimGlobalPrefs::~KPimGlobalPrefs()
206{ 212{
207 if (sInstance == this) 213 if (sInstance == this)
208 sInstance = staticDeleterGP.setObject(0); 214 sInstance = staticDeleterGP.setObject(0);
209 else 215 else
210 qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); 216 qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?");
211 if ( mLocaleDict ) 217 if ( mLocaleDict )
212 delete mLocaleDict; 218 delete mLocaleDict;
213} 219}
214 220
215KPimGlobalPrefs *KPimGlobalPrefs::instance() 221KPimGlobalPrefs *KPimGlobalPrefs::instance()
216{ 222{
217 if ( !sInstance ) { 223 if ( !sInstance ) {
218 sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); 224 sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() );
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
index d68ccb6..714d1b7 100644
--- a/libkdepim/kpimprefs.cpp
+++ b/libkdepim/kpimprefs.cpp
@@ -37,32 +37,35 @@ $Id$
37 37
38KPimPrefs::KPimPrefs( const QString &name ) : 38KPimPrefs::KPimPrefs( const QString &name ) :
39 KPrefs( name ) 39 KPrefs( name )
40{ 40{
41#ifdef _WIN32_ 41#ifdef _WIN32_
42 QString hdp= locateLocal("data","korganizer")+"\\\\"; 42 QString hdp= locateLocal("data","korganizer")+"\\\\";
43#else 43#else
44 QString hdp= locateLocal("data","korganizer")+"/"; 44 QString hdp= locateLocal("data","korganizer")+"/";
45#endif 45#endif
46 setCurrentGroup("SyncOptions"); 46 setCurrentGroup("SyncOptions");
47 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); 47 addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
48 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); 48 addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
49 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); 49 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
50 addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false ); 50 addItemBool("PassiveSyncWithDesktop",&mPassiveSyncWithDesktop,false );
51 addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false ); 51 addItemBool("PassiveSyncAutoStart",&mPassiveSyncAutoStart,false );
52 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 52 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
53
54 setCurrentGroup("BackupDate");
55 addItemInt("LastBackupDate",&mLastBackupDate,0);
53} 56}
54 57
55KPimPrefs::~KPimPrefs() 58KPimPrefs::~KPimPrefs()
56{ 59{
57} 60}
58 61
59void KPimPrefs::usrSetDefaults() 62void KPimPrefs::usrSetDefaults()
60{ 63{
61 setCategoryDefaults(); 64 setCategoryDefaults();
62} 65}
63 66
64void KPimPrefs::usrReadConfig() 67void KPimPrefs::usrReadConfig()
65{ 68{
66 config()->setGroup("General"); 69 config()->setGroup("General");
67 mCustomCategories = config()->readListEntry("Custom Categories"); 70 mCustomCategories = config()->readListEntry("Custom Categories");
68 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 71 if (mCustomCategories.isEmpty()) setCategoryDefaults();
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index c177bd6..bf80042 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -48,26 +48,27 @@ class KPimPrefs : public KPrefs
48 48
49 /** Read preferences from config file */ 49 /** Read preferences from config file */
50 void usrReadConfig(); 50 void usrReadConfig();
51 51
52 /** Write preferences to config file */ 52 /** Write preferences to config file */
53 void usrWriteConfig(); 53 void usrWriteConfig();
54 54
55 55
56 public: 56 public:
57 QStringList mCustomCategories; 57 QStringList mCustomCategories;
58 QString mPassiveSyncPort; 58 QString mPassiveSyncPort;
59 QString mPassiveSyncPw; 59 QString mPassiveSyncPw;
60 bool mPassiveSyncWithDesktop; 60 bool mPassiveSyncWithDesktop;
61 bool mPassiveSyncAutoStart; 61 bool mPassiveSyncAutoStart;
62 int mRingSyncAlgoPrefs; 62 int mRingSyncAlgoPrefs;
63 QString mLastSyncedLocalFile; 63 QString mLastSyncedLocalFile;
64 int mLastBackupDate;
64 65
65 66
66 protected: 67 protected:
67 virtual void setCategoryDefaults(); 68 virtual void setCategoryDefaults();
68 69
69 70
70 71
71}; 72};
72 73
73#endif 74#endif
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index 80a83e0..539397b 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -111,16 +111,136 @@ void KApplication::showText(QString caption, QString text)
111 dia.setCaption( caption ); 111 dia.setCaption( caption );
112 QVBoxLayout* lay = new QVBoxLayout( &dia ); 112 QVBoxLayout* lay = new QVBoxLayout( &dia );
113 lay->setSpacing( 3 ); 113 lay->setSpacing( 3 );
114 lay->setMargin( 3 ); 114 lay->setMargin( 3 );
115 KTextEdit tb ( &dia ); 115 KTextEdit tb ( &dia );
116 tb.setWordWrap( QMultiLineEdit::WidgetWidth ); 116 tb.setWordWrap( QMultiLineEdit::WidgetWidth );
117 lay->addWidget( &tb ); 117 lay->addWidget( &tb );
118 tb.setText( text ); 118 tb.setText( text );
119#ifdef DESKTOP_VERSION 119#ifdef DESKTOP_VERSION
120 dia.resize( 640, 480); 120 dia.resize( 640, 480);
121#else 121#else
122 dia.showMaximized(); 122 dia.showMaximized();
123#endif 123#endif
124 dia.exec(); 124 dia.exec();
125 125
126} 126}
127
128#include <qlabel.h>
129#include <qpushbutton.h>
130#include <qlayout.h>
131#include <qdir.h>
132#include <qradiobutton.h>
133#include <qbuttongroup.h>
134#include "kglobal.h"
135#include "klocale.h"
136
137class KBackupPrefs : public QDialog
138{
139 public:
140 KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) :
141 QDialog( parent, name, true )
142 {
143 setCaption( i18n("Backup Failed!") );
144 QVBoxLayout* lay = new QVBoxLayout( this );
145 lay->setSpacing( 3 );
146 lay->setMargin( 3 );
147 QLabel * lab = new QLabel( message, this );
148 lay->addWidget( lab );
149 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Choose action"), this );
150 lay->addWidget( format );
151 format->setExclusive ( true ) ;
152 vcal = new QRadioButton(i18n("Try again now"), format );
153 tcal = new QRadioButton(i18n("Try again later"), format );
154 ical = new QRadioButton(i18n("Try again tomorrow"), format );
155 ocal = new QRadioButton(i18n("Disable backup"), format );
156 vcal->setChecked( true );
157 QPushButton * ok = new QPushButton( i18n("OK"), this );
158 lay->addWidget(ok );
159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
160 }
161
162 bool again() { return vcal->isChecked(); }
163 bool later() { return tcal->isChecked(); }
164 bool againTomorrow() { return ical->isChecked(); }
165private:
166 QRadioButton* vcal, *ical, *ocal, *tcal;
167};
168int KApplication::createBackup( QString fn, QString dp, int numBup )
169{
170 if ( numBup < 1) return 3;
171 int ret = 3;
172 qDebug("KApplication::createBackup %s --- %s --- %d", fn.latin1(), dp.latin1(), numBup);
173 QDir bupDir ( dp );
174 bool tryAgain = true;
175 while ( tryAgain ) {
176 if ( !bupDir.exists() ) {
177 KBackupPrefs noDir( i18n("<b>Backup directory does not exist: </b>") + dp.right(30));
178 if ( !noDir.exec() ) return 3;
179 if ( noDir.againTomorrow() ) {
180 return 0;
181 } else if ( noDir.later() ) {
182 return 3;
183 } else if ( !noDir.again() ) {
184 return 2;
185 }
186 } else {
187 tryAgain = false;
188 }
189 }
190 // we have a valid dir!
191 QStringList allFileList = bupDir.entryList(QDir::Files);
192 QFileInfo fileInfo ( fn );
193 QString fName = fileInfo.fileName ();
194 QStringList fileList;
195
196 int i;
197 for ( i = 0; i < allFileList.count(); ++i ) {
198 QString fi = allFileList[i];
199 if ( fi. find( fName ) > -1 )
200 fileList.append( fi );
201 }
202 qDebug("%d backup files exist ", fileList.count());
203 int count = fileList.count();
204 fileList.sort();
205 int remCount = 0;
206 while ( count >= numBup ) {
207 QString fnr = dp + "/"+fileList[remCount];
208 QFile::remove( fnr );
209 --count;
210 ++remCount;
211 }
212 QDateTime mRunStart = QDateTime::currentDateTime();
213 QString file = "%1%2%3-%4%5%6-";
214 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
215 file.replace ( QRegExp (" "), "0" );
216 file += fName ;
217 file = dp + "/"+file;
218 QString command;
219 int res = 0;
220#ifdef _WIN32_
221 command = "xcopy "+ fn+ " "+file;
222 command = QDir::convertSeparators( command );
223#else
224 command = "cp "+ fn+ " "+file;
225#endif
226 qDebug("command %s ",command.latin1() );
227 tryAgain = true;
228 while ( tryAgain ) {
229 res = system ( command.latin1() );
230 qDebug("copy result %d ", res);
231 if ( res != 0 ) {
232 KBackupPrefs noDir( i18n("<b>The backup copy command failed!</b>"));
233 if ( !noDir.exec() ) return 3;
234 if ( noDir.againTomorrow() ) {
235 return 0;
236 } else if ( noDir.later() ) {
237 return 3;
238 } else if ( !noDir.again() ) {
239 return 2;
240 }
241 } else {
242 tryAgain = false;
243 }
244 }
245 return 1;
246}
diff --git a/microkde/kapplication.h b/microkde/kapplication.h
index f7eb1ef..de5a084 100644
--- a/microkde/kapplication.h
+++ b/microkde/kapplication.h
@@ -12,20 +12,21 @@ class KApplication
12 public: 12 public:
13 static int random(); 13 static int random();
14 14
15//US 15//US
16 /** 16 /**
17 * Generates a random string. It operates in the range [A-Za-z0-9] 17 * Generates a random string. It operates in the range [A-Za-z0-9]
18 * @param length Generate a string of this length. 18 * @param length Generate a string of this length.
19 * @return the random string 19 * @return the random string
20 */ 20 */
21 static QString randomString(int length); 21 static QString randomString(int length);
22 static int execDialog( QDialog* ); 22 static int execDialog( QDialog* );
23 static void showLicence(); 23 static void showLicence();
24 static void testCoords( int* x, int* y, int* wid, int * hei ); 24 static void testCoords( int* x, int* y, int* wid, int * hei );
25 static void showFile(QString caption, QString file); 25 static void showFile(QString caption, QString file);
26 static void showText(QString caption, QString text); 26 static void showText(QString caption, QString text);
27 static bool convert2latin1(QString file); 27 static bool convert2latin1(QString file);
28 static int createBackup( QString fn, QString dp, int numBup );
28}; 29};
29 30
30 31
31#endif 32#endif