summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-06-13 20:42:10 (UTC)
committer zautrix <zautrix>2005-06-13 20:42:10 (UTC)
commitfe1114cea0321405b362d642912f1f72257c7cbd (patch) (side-by-side diff)
tree89f5cc1050a86c497fc406ebbea88669b6bea1a6 /korganizer
parent0000f74badd326f62620d818a5e5d9944e55bda0 (diff)
downloadkdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.zip
kdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.tar.gz
kdepimpi-fe1114cea0321405b362d642912f1f72257c7cbd.tar.bz2
fixxxx
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp45
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/kofilterview.cpp18
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp12
5 files changed, 68 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 6e60c56..b0be340 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1878,13 +1878,16 @@ void CalendarView::addCalendarId( int id )
addCalendar( cal );
}
bool CalendarView::addCalendar( KopiCalendarFile * cal )
{
-
- if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber ))
+ cal->mErrorOnLoad = false;
+ if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
+ cal->mLoadDt = QDateTime::currentDateTime();
return true;
+ }
qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
+ cal->mErrorOnLoad = true;
return false;
}
bool CalendarView::openCalendar(QString filename, bool merge)
{
@@ -1982,9 +1985,35 @@ void CalendarView::watchSavedFile()
return;
}
loadedFileVersion = dt;
}
-
+bool CalendarView::checkAllFileVersions()
+{
+ QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
+ KopiCalendarFile * cal = calendars.first();
+ mCalendar->setDefaultCalendar( 1 );
+ mCalendar->setDefaultCalendarEnabledOnly();
+ if ( !checkFileVersion(MainWindow::defaultFileName()))
+ return false;
+ cal = calendars.next();
+ QDateTime storeTemp = loadedFileVersion;
+ while ( cal ) {
+ if ( !cal->mErrorOnLoad ) {
+ mCalendar->setDefaultCalendar( cal->mCalNumber );
+ mCalendar->setDefaultCalendarEnabledOnly();
+ loadedFileVersion = cal->mLoadDt.addSecs( 15 );
+ if ( !checkFileVersion(cal->mFileName )) {
+ loadedFileVersion = storeTemp;
+ updateView();
+ return false;
+ }
+ }
+ cal = calendars.next();
+ }
+ loadedFileVersion = storeTemp;
+ updateView();
+ return true;
+}
bool CalendarView::checkFileVersion(QString fn)
{
QFileInfo finf ( fn );
if ( !finf.exists() )
@@ -1993,9 +2022,9 @@ bool CalendarView::checkFileVersion(QString fn)
//qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
//qDebug("file on disk version %s",dt.toString().latin1());
if ( dt <= loadedFileVersion )
return true;
- int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
+ int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
i18n("KO/Pi Warning"),i18n("Overwrite"),
i18n("Sync+save"));
if ( km == KMessageBox::Cancel )
@@ -2011,10 +2040,9 @@ bool CalendarView::checkFileVersion(QString fn)
mSyncManager->mShowSyncSummary = false;
syncCalendar( fn, 3 );
Event * e = getLastSyncEvent();
if ( e )
- deleteEvent ( e );
- updateView();
+ mCalendar->deleteEvent( e );
return true;
}
bool CalendarView::saveCalendars()
{
@@ -2024,12 +2052,13 @@ bool CalendarView::saveCalendars()
mCalendar->setDefaultCalendarEnabledOnly();
saveCalendar( MainWindow::defaultFileName() );
cal = calendars.next();
while ( cal ) {
- if ( !cal->isReadOnly ) {
+ if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
mCalendar->setDefaultCalendar( cal->mCalNumber );
mCalendar->setDefaultCalendarEnabledOnly();
- saveCalendar( cal->mFileName );
+ if ( saveCalendar( cal->mFileName ) )
+ cal->mLoadDt = QDateTime::currentDateTime();
}
cal = calendars.next();
}
restoreCalendarSettings();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index ec5b7ab..d836fee 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -509,8 +509,9 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
virtual void removeSyncInfo( QString syncProfile);
void setSyncManager(KSyncManager* manager);
void setLoadedFileVersion(QDateTime);
bool checkFileVersion(QString fn);
+ bool checkAllFileVersions();
bool checkFileChanged(QString fn);
Event* getLastSyncEvent();
/** Adapt navigation units correpsonding to step size of navigation of the
* current view.
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 361eec8..19d731f 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -230,9 +230,17 @@ void KOCalEditView::deleteCal( int id )
void KOCalEditView::infoCal( int id )
{
QString name = KOPrefs::instance()->getCalendar( id )->mName;
QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
- KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
+ if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
+ if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) {
+ emit calendarAdded( id );
+ readConfig();
+ emit needsUpdate();
+ }
+ }
+ else
+ KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
}
void KOCalEditView::readConfig()
{
@@ -293,12 +301,16 @@ void KOCalEditView::readConfig()
mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb );
cb->setChecked( kkf->isStandard );
cb->setNum( kkf->mCalNumber );
connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
+ if ( kkf->mErrorOnLoad )
+ cb->setEnabled( false );
cb = new KOCalCheckButton( mw );
mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb );
cb->setChecked( kkf->isEnabled );
cb->setNum( kkf->mCalNumber );
+ if ( kkf->mErrorOnLoad )
+ cb->setEnabled( false );
connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
KOCalButton* name = new KOCalButton( mw );
name->setNum( kkf->mCalNumber );
name->setText( kkf->mName );
@@ -308,13 +320,17 @@ void KOCalEditView::readConfig()
mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb );
cb->setChecked( kkf->isAlarmEnabled );
cb->setNum( kkf->mCalNumber );
connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
+ if ( kkf->mErrorOnLoad )
+ cb->setEnabled( false );
cb = new KOCalCheckButton( mw );
mainLayout->addWidget( cb,row,4 );mROB.append( cb );
cb->setChecked( kkf->isReadOnly );
cb->setNum( kkf->mCalNumber );
connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
+ if ( kkf->mErrorOnLoad )
+ cb->setEnabled( false );
KColorButton *colb = new KColorButton( mw );
mainLayout->addWidget( colb,row,5 );
colb->setID( kkf->mCalNumber );
colb->setColor( kkf->mDefaultColor );
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index f114d88..463fc33 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -55,17 +55,20 @@ class KopiCalendarFile : public QObject
mName = "Calendar";
mFileName = QDir::homeDirPath() + "/icalfile.ics";
mCalNumber = 0;
mDefaultColor = Qt::red;
+ mErrorOnLoad = false;
}
bool isStandard;
bool isEnabled;
bool isAlarmEnabled;
bool isReadOnly;
+ bool mErrorOnLoad;
QString mName;
QString mFileName;
int mCalNumber;
QColor mDefaultColor;
+ QDateTime mLoadDt;
};
class KOPrefs : public KPimPrefs
{
public:
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index f05ada5..472a978 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1823,9 +1823,9 @@ void MainWindow::save()
}
if ( mSyncManager->blockSave() )
return;
mSyncManager->setBlockSave(true);
- if ( mView->checkFileVersion( defaultFileName()) ) {
+ if ( mView->checkAllFileVersions() ) {
if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
QDate reference ( 2000,1,1);
int daysTo = reference.daysTo ( QDate::currentDate() );
if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
@@ -1842,10 +1842,18 @@ void MainWindow::save()
KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
} else if ( retval == 1 ){
qDebug("KO: Backup created.");
// backup ok
+ QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
+ KopiCalendarFile * cal = calendars.first();
+ cal = calendars.next();
+ while ( cal ) {
+ if ( !cal->mErrorOnLoad ) {
+ int retval = KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
+ }
+ cal = calendars.next();
+ }
KOPrefs::instance()->mLastBackupDate = daysTo;
-
} else if ( retval == 2 ){
qDebug("KO: Backup globally cancelled.");
// backup globally cancelled
KPimGlobalPrefs::instance()->mBackupEnabled = false;