summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-09-18 13:50:46 (UTC)
committer zautrix <zautrix>2005-09-18 13:50:46 (UTC)
commitc6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5 (patch) (side-by-side diff)
tree94e7bdc361b68a3a569eebe14f66458b3795dd6a /korganizer
parente7cd095ea9e80e26c90cbc2d3bf36921b7541c19 (diff)
downloadkdepimpi-c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5.zip
kdepimpi-c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5.tar.gz
kdepimpi-c6e493d4e5b9eafcc3402c39e30c4283ce8cc8e5.tar.bz2
delay
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
@@ -2502,96 +2502,97 @@ bool CalendarView::checkFileVersion(QString fn)
QDateTime dt = finf.lastModified ();
//qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
//qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
if ( dt <= loadedFileVersion )
return true;
int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non 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(KGlobal::formatMessage(fn,0)).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 )
return false;
if ( km == KMessageBox::Yes )
return true;
setSyncDevice("deleteaftersync" );
mSyncManager->mAskForPreferences = true;
mSyncManager->mSyncAlgoPrefs = 3;
mSyncManager->mWriteBackFile = false;
mSyncManager->mWriteBackExistingOnly = false;
mSyncManager->mShowSyncSummary = false;
syncCalendar( fn, 3 );
Event * e = getLastSyncEvent();
if ( e )
mCalendar->deleteEvent( e );
return true;
}
bool CalendarView::saveCalendars()
{
QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
KopiCalendarFile * cal = calendars.first();
mCalendar->setDefaultCalendar( 1 );
mCalendar->setDefaultCalendarEnabledOnly();
QString saveError;
if ( !saveCalendar( MainWindow::defaultFileName() ) )
saveError = cal->mName +"\n";
cal = calendars.next();
while ( cal ) {
if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
mCalendar->setDefaultCalendar( cal->mCalNumber );
mCalendar->setDefaultCalendarEnabledOnly();
if ( saveCalendar( cal->mFileName ) )
cal->mLoadDt = QDateTime::currentDateTime();
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;
}
bool CalendarView::saveCalendar( QString filename )
{
// Store back all unsaved data into calendar object
// qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
if ( mViewManager->currentView() )
mViewManager->currentView()->flushView();
QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
mStorage->setSaveFormat( new ICalFormat() );
mStorage->setFileName( filename );
bool success;
success = mStorage->save();
if ( !success ) {
return false;
}
if ( filename == MainWindow::defaultFileName() ) {
setLoadedFileVersion( lfv );
watchSavedFile();
}
return true;
}
void CalendarView::closeCalendar()
{
// child windows no longer valid
clearAllViews();
emit closingDown();
mCalendar->close();
setModified(false);
updateView();
}
void CalendarView::archiveCalendar()
{
mDialogManager->showArchiveDialog();
}
@@ -4418,106 +4419,108 @@ void CalendarView::setReadOnly(bool readOnly)
bool CalendarView::isModified()
{
return mModified;
}
void CalendarView::slotprintSelInc()
{
if ( currentSelection() == 0 ) {
KMessageBox::sorry(this,i18n("There is nothing selected!"));
return;
}
showIncidence();
getEventViewerDialog()->print();
}
void CalendarView::printSetup()
{
#ifndef KORG_NOPRINTER
createPrinter();
mCalPrinter->setupPrinter();
#endif
}
void CalendarView::print()
{
#ifndef KORG_NOPRINTER
createPrinter();
DateList tmpDateList = mNavigator->selectedDates();
mCalPrinter->print(CalPrinter::Month,
tmpDateList.first(), tmpDateList.last());
#endif
}
void CalendarView::printPreview()
{
#ifndef KORG_NOPRINTER
kdDebug() << "CalendarView::printPreview()" << endl;
createPrinter();
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,
i18n("The journal entries can not be\nexported to a vCalendar file."),
i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
true);
if (result != KMessageBox::Continue) return false;
}
//QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
// Force correct extension
if (filename.right(4) != ".vcs") filename += ".vcs";
FileStorage storage( mCalendar, filename, new VCalFormat );
return storage.save();
}
void CalendarView::eventUpdated(Incidence *)
{
setModified();
// Don't call updateView here. The code, which has caused the update of the
// event is responsible for updating the view.
// updateView();
}
void CalendarView::adaptNavigationUnits()
{
if (mViewManager->currentView()->isEventView()) {
int days = mViewManager->currentView()->currentDateCount();
if (days == 1) {
emit changeNavStringPrev(i18n("&Previous Day"));
emit changeNavStringNext(i18n("&Next Day"));
} else {
emit changeNavStringPrev(i18n("&Previous Week"));
emit changeNavStringNext(i18n("&Next Week"));
}
}
}
void CalendarView::processMainViewSelection( Incidence *incidence )
{
if ( incidence ) mTodoList->clearSelection();
processIncidenceSelection( incidence );
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index b223315..8670832 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -331,97 +331,98 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
void writeFilterSettings(KConfig *config);
/** passes on the message that an event has changed to the currently
* activated view so that it can make appropriate display changes. */
void changeEventDisplay(Event *, int);
void changeIncidenceDisplay(Incidence *, int);
void changeTodoDisplay(Todo *, int);
void eventAdded(Event *);
void eventChanged(Event *);
void eventToBeDeleted(Event *);
void eventDeleted();
void todoAdded(Todo *);
void todoChanged(Todo *);
void todoToBeDeleted(Todo *);
void todoDeleted();
void updateView(const QDate &start, const QDate &end);
void updateView();
void clearAllViews();
/** Full update of visible todo views */
void updateTodoViews();
void updateUnmanagedViews();
/** cut the current appointment to the clipboard */
void edit_cut();
/** copy the current appointment(s) to the clipboard */
void edit_copy();
/** paste the current vobject(s) in the clipboard buffer into calendar */
void edit_paste();
/** edit viewing and configuration options. */
void edit_options();
void edit_global_options();
/**
Functions for printing, previewing a print, and setting up printing
parameters.
*/
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();
/**
* pop up an Appointment Dialog to edit an existing appointment. Get
* information on the appointment from the list of unique IDs that is
* currently in the View, called currIds.
*/
void appointment_edit();
/**
* pop up dialog confirming deletion of currently selected event in the
* View.
*/
void appointment_delete();
/** mails the currently selected event to a particular user as a vCalendar
attachment. */
void action_mail();
/* frees a subtodo from it's relation */
void todo_unsub( Todo * );
void todo_resub( Todo * parent, Todo * sub );
/** Take ownership of selected event. */
void takeOverEvent();
/** Take ownership of all events in calendar. */
void takeOverCalendar();
/** query whether or not the calendar is "dirty". */
bool isModified();
/** set the state of calendar. Modified means "dirty", i.e. needing a save. */
void setModified(bool modified=true);
/** query if the calendar is read-only. */
bool isReadOnly();
/** set state of calendar to read-only */
void setReadOnly(bool readOnly=true);
void eventUpdated(Incidence *);
/* iTIP scheduling actions */
void schedule_publish(Incidence *incidence = 0);
void schedule_request(Incidence *incidence = 0);
void schedule_refresh(Incidence *incidence = 0);
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2af605f..98d3e35 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -478,120 +478,139 @@ void MainWindow::disableBR(bool b)
}
mBRdisabled = true;
} else {
if ( mBRdisabled ) {
mBRdisabled = false;
//makes no sense,because other cal ap is probably running
// toggleBeamReceive();
}
}
#endif
}
bool MainWindow::beamReceiveEnabled()
{
#ifndef DESKTOP_VERSION
return ( infrared != 0 );
#endif
return false;
}
void MainWindow::toggleBeamReceive()
{
if ( mBRdisabled )
return;
#ifndef DESKTOP_VERSION
if ( infrared ) {
qDebug("KO: Disable BeamReceive ");
delete infrared;
infrared = 0;
brAction->setOn(false);
return;
}
qDebug("KO: Enable BeamReceive ");
brAction->setOn(true);
infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
#endif
}
void MainWindow::showMaximized ()
{
#ifndef DESKTOP_VERSION
if ( ! globalFlagBlockStartup )
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;
}
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;
case 1:
ce->ignore();
break;
case 2:
default:
break;
}
}
void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data )
{
qDebug("KO: QCOP start message received: %s ", cmsg.data() );
mCStringMess = cmsg;
mByteData = data;
}
void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
{
QDataStream stream( data, IO_ReadOnly );
// QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
//QString datamess;
//qDebug("message ");
qDebug("KO: QCOP message received: %s ", cmsg.data() );
if ( cmsg == "setDocument(QString)" ) {
QDataStream stream( data, IO_ReadOnly );
QString fileName;
stream >> fileName;
//qDebug("filename %s ", fileName.latin1());
showMaximized();
raise();
KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
mSyncManager->slotSyncMenu( 1002 );
return;
}
if ( cmsg == "-writeFile" ) {
// I made from the "-writeFile" an "-writeAlarm"
mView->viewManager()->showWhatsNextView();
mCalendar->checkAlarmForIncidence( 0, true);
showMaximized();
@@ -1120,96 +1139,100 @@ void MainWindow::initActions()
if ( KOPrefs::instance()->mShowFullMenu ) {
actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
}
// actionMenu->insertSeparator();
action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
this );
action->addTo( importMenu_X );
connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
action = new QAction( "import_quick", i18n("Import last file"), 0,
this );
action->addTo( importMenu_X );
connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
importMenu_X->insertSeparator();
action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
this );
action->addTo( importMenu_X );
connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
//#ifndef DESKTOP_VERSION
importMenu_X->insertSeparator();
action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
this );
action->addTo( importMenu_X );
connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
//#else
#ifdef _OL_IMPORT_
importMenu_X->insertSeparator();
action = new QAction( "import_ol", i18n("Import from OL"), 0,
this );
action->addTo( importMenu_X );
connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
#endif
//#endif
//importMenu->insertSeparator();
#if 0
action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
this );
action->addTo( importMenu );
connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
#endif
action = new QAction( "save_cal", i18n("Save Backup..."), 0,
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() ) );
//LR
QPopupMenu *ex2phone = new QPopupMenu( this );
ex2phone->insertItem(i18n("Complete calendar..."), 1 );
ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
importMenu->insertItem( i18n("Export"), exportMenu_X );
mPrintSelAction = 0;
#ifndef DESKTOP_VERSION
//importMenu->insertSeparator();
brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
this );
brAction->addTo( beamMenu_X );
brAction->setToggleAction (true ) ;
connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
this );
action->addTo( beamMenu_X );
connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
this );
action->addTo( beamMenu_X );
connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
importMenu->insertItem( i18n("Beam"), beamMenu_X );
#else
//importMenu->insertSeparator();
icon = loadPixmap( pathString + "print" );
action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
action->addTo( beamMenu_X );
connect( action, SIGNAL( activated() ),
this, SLOT( printCal() ) );
icon = loadPixmap( pathString + "week" );
action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
action->addTo( beamMenu_X );
connect( action, SIGNAL( activated() ),
this, SLOT( printSel() ) );
icon = loadPixmap( pathString + "whatsnext" );
action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
@@ -1922,152 +1945,154 @@ void MainWindow::saveOnClose()
myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
if ( p->mToolBarHorF )
p->mToolBarUpF = myP.y() > height()/2;
else
p->mToolBarUpF = myP.x() > width()/2 ;
}
#else
if ( p->mToolBarHor )
p->mToolBarUp = iconToolBar->y() > height()/2;
else
p->mToolBarUp = iconToolBar->x() > width()/2;
if ( p->mToolBarHorV )
p->mToolBarUpV = viewToolBar->y() > height()/2;
else
p->mToolBarUpV = viewToolBar->x() > width()/2 ;
if ( p->mToolBarHorN )
p->mToolBarUpN = navigatorToolBar->y() > height()/2;
else
p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
if ( filterToolBar ) {
if ( p->mToolBarHorF )
p->mToolBarUpF = filterToolBar->y() > height()/2;
else
p->mToolBarUpF = filterToolBar->x() > width()/2 ;
}
#endif
save();
mView->writeSettings();
mView->checkSuspendAlarm();
}
void MainWindow::slotModifiedChanged( bool )
{
if ( mBlockAtStartup )
return;
int msec;
if ( mCalendarModifiedFlag ) {
//qDebug(" MainWindow timer is running ");
return;
}
// we store the changes after 1 minute,
// 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()
{
mSaveTimer.stop();
}
void MainWindow::backupAllFiles()
{
QDate reference ( 2000,1,1);
int daysTo = reference.daysTo ( QDate::currentDate() );
setCaption(i18n("Creating backup ... please wait ..." ));
qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
// we need the file path, the backup dir and the number of bups as param
QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
bupDir = KGlobalSettings::backupDataDir();
int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
if ( retval == 0 ) {
setCaption(i18n("Backup cancelled" ));
qDebug("KO: Backup cancelled. Will try again tomorrow ");
// retval == 0 : backup skipped for today, try again tomorrow
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 ) {
KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
}
cal = calendars.next();
}
KOPrefs::instance()->mLastBackupDate = daysTo;
setCaption(i18n("Backup succesfully finished" ));
} else if ( retval == 2 ){
setCaption(i18n("Backup globally disabled" ));
qDebug("KO: Backup globally cancelled.");
// backup globally cancelled
KPimGlobalPrefs::instance()->mBackupEnabled = false;
}
// 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() )
mView->viewManager()->journalView()->checkModified();
if ( !mCalendarModifiedFlag ) {
qDebug("KO: Calendar not modified. Nothing saved.");
return;
}
if ( mSyncManager->blockSave() ) {
slotModifiedChanged( true );
return;
}
mSaveDelay = 0;
mSyncManager->setBlockSave(true);
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 ) {
backupAllFiles();
}
; // KPimGlobalPrefs::instance()->mLastBackupDate
}
QTime neededSaveTime;
neededSaveTime.start();
if ( !isMinimized () )
setCaption(i18n("KO/Pi:Saving Data to File ..." ));
qDebug("KO: Start saving data to file!");
if ( mView->saveCalendars() )
mCalendarModifiedFlag = false;
int msNeeded = neededSaveTime.elapsed();
qDebug("KO: Needed %d ms for saving.",msNeeded );
QString savemes;
savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
if ( !isMinimized () )
setCaption(savemes);
else
qDebug(savemes);
} else {
setCaption(i18n("Saving cancelled!"));
mCalendarModifiedFlag = false;
slotModifiedChanged( true );
}
mSyncManager->setBlockSave( false );
}
@@ -2530,128 +2555,144 @@ void MainWindow::loadCalendar()
#endif
}
void MainWindow::quickImportIcal()
{
importFile( KOPrefs::instance()->mLastImportFile, false );
}
void MainWindow::importFile( QString fn, bool quick )
{
QFileInfo info;
info.setFile( fn );
QString mess;
if ( !info. exists() ) {
mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
mess );
return;
}
int result = 0;
if ( !quick ) {
mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
result = QMessageBox::warning( this, "KO/Pi: Warning!",
mess,
"Import", "Cancel", 0,
0, 1 );
}
if ( result == 0 ) {
if ( mView->openCalendar( fn, true )) {
KOPrefs::instance()->mLastImportFile = fn;
setCaption(i18n("Imported file successfully"));
} else {
setCaption(i18n("Error importing file"));
}
mView->updateView();
}
}
void MainWindow::importIcal()
{
QString fn =KOPrefs::instance()->mLastImportFile;
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;
if ( info. exists() ) {
mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
i18n("Overwrite!"), i18n("Cancel"), 0,
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" );
#endif
}
void MainWindow::syncFileRequest()
{
while ( mSyncManager->blockSave() ) {
qApp->processEvents();
}
mSyncManager->setBlockSave(true);
if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
mSyncManager->slotSyncMenu( 999 );
}
setCaption(i18n("Saving Data to temp file ..." ));
mView->saveCalendar( sentSyncFile() );
setCaption(i18n("Data saved to temp file!" ));
mSyncManager->setBlockSave( false );
}
void MainWindow::getFile( bool success )
{
if ( ! success ) {
setCaption( i18n("Error receiving file. Nothing changed!") );
return;
}
mView->mergeFile( sentSyncFile() );
if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
mSyncManager->slotSyncMenu( 999 );
}
setCaption( i18n("Pi-Sync successful!") );
}
void MainWindow::printListView()
{
QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.");
KMessageBox::information( this, message);
}
void MainWindow::printSel( )
{
mView->viewManager()->agendaView()->agenda()->printSelection();
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 657c0a8..71c069b 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -48,139 +48,142 @@ class MainWindow : public QMainWindow
void updateWeek(QDate);
void updateFilterToolbar();
virtual void showMaximized ();
void configureAgenda( int );
void recieve( const QCString& msg, const QByteArray& data );
void receiveStart( const QCString& msg, const QByteArray& data );
protected slots:
void loadDataAfterStart();
void calHint();
void startMultiSync();
void setCaptionToDates();
void weekAction();
void about();
void licence();
void faq();
void usertrans();
void features();
void synchowto();
void storagehowto();
void timetrackinghowto();
void kdesynchowto();
void multisynchowto();
void whatsNew();
void keyBindings();
void aboutAutoSaving();;
void aboutKnownBugs();
void processIncidenceSelection( Incidence * );
void importQtopia();
void importBday();
void importOL();
void importIcal();
void importFile( QString, bool );
void quickImportIcal();
void slotModifiedChanged( bool );
void save();
void backupAllFiles();
void saveStopTimer();
void configureToolBar( int );
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 );
void toggleBeamReceive();
void disableBR(bool);
signals:
void selectWeek ( int );
private slots:
void slotResetFocus();
void slotResetFocusLoop();
void showConfigureAgenda();
void getFile( bool );
void syncFileRequest();
protected:
int mFocusLoop;
void hideEvent ( QHideEvent * );
QString sentSyncFile();
void displayText( QString, QString);
void enableIncidenceActions( bool );
+ bool askForQuitOnSaveError();
private:
QCString mCStringMess;
QByteArray mByteData;
//void setMenuBar( QMenuBar * );
bool mBRdisabled;
#ifndef DESKTOP_VERSION
QCopChannel* infrared;
#endif
QAction* brAction;
KSyncManager* mSyncManager;
bool mClosed;
void saveOnClose();
bool mFlagKeyPressed;
bool mBlockAtStartup;
KMenuBar *menuBar1;
QPEToolBar *iconToolBar;
QPEToolBar *viewToolBar;
QPEToolBar *navigatorToolBar;
QPEToolBar *filterToolBar;
KMenuBar *filterMenubar;
QPopupMenu * filterPopupMenu;
QPopupMenu * mCurrentItemMenu;
void initActions();
void setDefaultPreferences();
void resizeEvent( QResizeEvent* e);
void keyPressEvent ( QKeyEvent * ) ;
void keyReleaseEvent ( QKeyEvent * ) ;
QPopupMenu *configureToolBarMenu;
QPopupMenu *selectFilterMenu;
QPopupMenu *selectFilterMenuTB;
QPopupMenu *configureAgendaMenu, *syncMenu;
CalendarLocal *mCalendar;
CalendarView *mView;
QAction *mNewSubTodoAction;
QAction *mWeekAction;
QFont mWeekFont;
QPixmap mWeekPixmap;
QColor mWeekBgColor;
QAction *mShowAction;
QAction *mEditAction;
QAction *mDeleteAction;
QAction *mCloneAction;
QAction *mMoveAction;
QAction *mBeamAction;
QAction *mCancelAction;
QAction *mPrintSelAction;
QAction *mToggleNav;
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;
};
#endif