summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp13
-rw-r--r--korganizer/calendarview.h3
-rw-r--r--korganizer/mainwindow.cpp69
-rw-r--r--korganizer/mainwindow.h5
4 files changed, 69 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 79fb727..2ba8528 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2544,12 +2544,13 @@ bool CalendarView::saveCalendars()
else
saveError += cal->mName + "\n";
}
cal = calendars.next();
}
restoreCalendarSettings();
+ //saveError = "test error";
if ( !saveError.isEmpty() ) {
saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
KMessageBox::error(this, saveError, i18n("Error saving data"));
return false;
}
return true;
@@ -4460,22 +4461,24 @@ void CalendarView::printPreview()
DateList tmpDateList = mNavigator->selectedDates();
mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
tmpDateList.last());
#endif
}
-
-void CalendarView::exportICalendar()
+bool CalendarView::exportICalendar( QString filename )
{
- QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
-
// Force correct extension
if (filename.right(4) != ".ics") filename += ".ics";
FileStorage storage( mCalendar, filename, new ICalFormat() );
- storage.save();
+ return storage.save();
+}
+
+bool CalendarView::exportICalendar()
+{
+ return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) );
}
bool CalendarView::exportVCalendar( QString filename )
{
if (mCalendar->journals().count() > 0) {
int result = KMessageBox::warningContinueCancel(this,
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index b223315..8670832 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -373,13 +373,14 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
*/
void print();
void printSetup();
void printPreview();
/** Export as iCalendar file */
- void exportICalendar();
+ bool exportICalendar();
+ bool exportICalendar( QString fn );
/** Export as vCalendar file */
bool exportVCalendar( QString fn);
/** pop up a dialog to show an existing appointment. */
void appointment_show();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2af605f..98d3e35 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -520,20 +520,39 @@ void MainWindow::showMaximized ()
if ( mClosed )
mView->goToday();
#endif
QWidget::showMaximized () ;
mClosed = false;
}
+
+bool MainWindow::askForQuitOnSaveError()
+{
+ bool retval = false;
+ switch( QMessageBox::information( this, "KO/Pi",
+ i18n("Error saving data") + "!\n" +
+ i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" +
+ i18n("Do you really want\nto close KO/Pi?"),
+ i18n(" Yes, close "), i18n("No"),
+ 0, 1 ) ) {
+ case 0:
+ retval = true;
+ break;
+ default:
+ break;
+ }
+ return retval;
+}
+
void MainWindow::closeEvent( QCloseEvent* ce )
{
if ( ! KOPrefs::instance()->mAskForQuit ) {
saveOnClose();
- if ( mCalendarModifiedFlag ) {
+ if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
ce->ignore();
return;
}
mClosed = true;
ce->accept();
return;
@@ -543,13 +562,13 @@ void MainWindow::closeEvent( QCloseEvent* ce )
switch( QMessageBox::information( this, "KO/Pi",
i18n("Do you really want\nto close KO/Pi?"),
i18n("Close"), i18n("No"),
0, 0 ) ) {
case 0:
saveOnClose();
- if ( mCalendarModifiedFlag ) {
+ if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
ce->ignore();
return;
}
mClosed = true;
ce->accept();
break;
@@ -1162,12 +1181,16 @@ void MainWindow::initActions()
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
importMenu->insertSeparator();
importMenu->insertItem( i18n("Import"), importMenu_X );
//importMenu->insertSeparator();
+ action = new QAction( "export ical", i18n("Export All Data"), 0,
+ this );
+ action->addTo( exportMenu_X );
+ connect( action, SIGNAL( activated() ), SLOT( exportICalendar() ) );
action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
this );
action->addTo( exportMenu_X );
connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
@@ -1964,13 +1987,13 @@ void MainWindow::slotModifiedChanged( bool )
// and for safety reasons after 10 minutes again
if ( !mSyncManager->blockSave() )
msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
else
msec = 1000 * 600;
mSaveTimer.start( msec, true ); // 1 minute
- mSaveTime.restart();
+ mSaveTimerStart = QDateTime::currentDateTime();
mSaveDelay = msec/1000;
qDebug("KO: Saving File in %d secs!", msec/1000);
mCalendarModifiedFlag = true;
}
void MainWindow::saveStopTimer()
{
@@ -2014,18 +2037,20 @@ void MainWindow::backupAllFiles()
}
// retval == 3: do nothing, try again later
}
void MainWindow::save()
{
if ( mSaveDelay ) {
- if ( mSaveDelay + 60 < mSaveTime.elapsed()/1000 ) {
- qDebug("KO: Save delay %d. Elapsed save time %d ", mSaveDelay, mSaveTime.elapsed()/1000 );
- qDebug("KO: Restarting save timer");
- int msec = 10000;
- mSaveTimer.start( msec, true ); // 1 minute
- mSaveTime.restart();
+ int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() );
+ if ( mSaveDelay < elapsed ) {
+ qDebug("KO: Pending save after wakeup from suspend detected.");
+ qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed );
+ qDebug("KO: Restarting save timer to save in 15 sec.");
+ int msec = 15000;
+ mSaveTimer.start( msec, true );
+ mSaveTimerStart = QDateTime::currentDateTime();
mSaveDelay = msec/1000;
return;
}
}
if ( mView->viewManager()->journalView() )
@@ -2572,17 +2597,21 @@ void MainWindow::importIcal()
fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
if ( fn == "" )
return;
importFile( fn, true );
}
-
-void MainWindow::exportVCalendar()
+void MainWindow::exportCalendar( bool iCalFormat )
{
QString fn = KOPrefs::instance()->mLastVcalFile;
- fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
+ if ( iCalFormat ) {
+ fn = QDir::homeDirPath()+"/kopiexport.ics";
+ fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this );
+ }
+ else
+ fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
if ( fn == "" )
return;
QFileInfo info;
info.setFile( fn );
QString mes;
bool createbup = true;
@@ -2593,23 +2622,35 @@ void MainWindow::exportVCalendar()
0, 1 );
if ( result != 0 ) {
createbup = false;
}
}
if ( createbup ) {
- if ( mView->exportVCalendar( fn ) ) {
- KOPrefs::instance()->mLastVcalFile = fn;
+ bool success = false;
+ if ( iCalFormat )
+ success = mView->exportICalendar( fn );
+ else
+ success = mView->exportVCalendar( fn );
+ if ( success ) {
if ( fn.length() > 20 )
mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
else
mes = i18n("KO/Pi:Exported to %1").arg(fn );
setCaption(mes);
}
}
}
+void MainWindow::exportICalendar()
+{
+ exportCalendar( true );
+}
+void MainWindow::exportVCalendar()
+{
+ exportCalendar( false );
+}
QString MainWindow::sentSyncFile()
{
#ifdef DESKTOP_VERSION
return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) );
#else
return QString( "/tmp/copysynccal.ics" );
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 657c0a8..71c069b 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -90,12 +90,14 @@ class MainWindow : public QMainWindow
void printSel();
void printCal();
void printListView();
void saveCalendar();
void loadCalendar();
void exportVCalendar();
+ void exportICalendar();
+ void exportCalendar( bool );
void fillFilterMenu();
void fillFilterMenuTB();
void selectFilter( int );
void fillFilterMenuPopup();
void selectFilterPopup( int );
void exportToPhone( int );
@@ -113,12 +115,13 @@ class MainWindow : public QMainWindow
protected:
int mFocusLoop;
void hideEvent ( QHideEvent * );
QString sentSyncFile();
void displayText( QString, QString);
void enableIncidenceActions( bool );
+ bool askForQuitOnSaveError();
private:
QCString mCStringMess;
QByteArray mByteData;
@@ -171,13 +174,13 @@ class MainWindow : public QMainWindow
QAction *mToggleFilter;
QAction *mToggleAllday;
QAction *actionFilterMenuTB;
void closeEvent( QCloseEvent* ce );
QTimer mSaveTimer;
- QTime mSaveTime;
+ QDateTime mSaveTimerStart;
int mSaveDelay;
//bool mBlockSaveFlag;
bool mCalendarModifiedFlag;
QPixmap loadPixmap( QString );
QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix;
};