author | zautrix <zautrix> | 2004-10-05 08:32:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 08:32:25 (UTC) |
commit | 701cd3c2b2b713c12797f5bda24c35d3a7889539 (patch) (side-by-side diff) | |
tree | 56d07b2f4a050fbc839ab6435b2266e8a52a08ba | |
parent | ad859d26b813101adab963f50e694961702561d9 (diff) | |
download | kdepimpi-701cd3c2b2b713c12797f5bda24c35d3a7889539.zip kdepimpi-701cd3c2b2b713c12797f5bda24c35d3a7889539.tar.gz kdepimpi-701cd3c2b2b713c12797f5bda24c35d3a7889539.tar.bz2 |
warning dialog fixes
-rw-r--r-- | korganizer/calendarview.cpp | 17 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 2 |
3 files changed, 16 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index fecc7e2..687943e 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1462,137 +1462,150 @@ bool CalendarView::importQtopia( const QString &categories, QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), question, i18n("Ok")) ; } delete calendar; updateView(); return syncOK; #endif } void CalendarView::setSyncEventsReadOnly() { Event * ev; QPtrList<Event> eL = mCalendar->rawEvents(); ev = eL.first(); while ( ev ) { if ( ev->uid().left(15) == QString("last-syncEvent-") ) ev->setReadOnly( true ); ev = eL.next(); } } bool CalendarView::openCalendar(QString filename, bool merge) { if (filename.isEmpty()) { return false; } if (!QFile::exists(filename)) { KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); return false; } globalFlagBlockAgenda = 1; if (!merge) mCalendar->close(); mStorage->setFileName( filename ); if ( mStorage->load() ) { if ( merge ) ;//setModified( true ); else { //setModified( true ); mViewManager->setDocumentId( filename ); mDialogManager->setDocumentId( filename ); mTodoList->setDocumentId( filename ); } globalFlagBlockAgenda = 2; // if ( getLastSyncEvent() ) // getLastSyncEvent()->setReadOnly( true ); mCalendar->reInitAlarmSettings(); setSyncEventsReadOnly(); updateUnmanagedViews(); updateView(); loadedFileVersion = QDateTime::currentDateTime(); if ( filename != MainWindow::defaultFileName() ) { saveCalendar( MainWindow::defaultFileName() ); watchSavedFile(); } return true; } else { // while failing to load, the calendar object could // have become partially populated. Clear it out. - if ( !merge ) mCalendar->close(); + if ( !merge ) { + mCalendar->close(); + mViewManager->setDocumentId( filename ); + mDialogManager->setDocumentId( filename ); + mTodoList->setDocumentId( filename ); + } - KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); + //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); + QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); globalFlagBlockAgenda = 2; + mCalendar->reInitAlarmSettings(); + setSyncEventsReadOnly(); + updateUnmanagedViews(); updateView(); } return false; } +void CalendarView::showOpenError() +{ + KMessageBox::error(this,i18n("Couldn't load calendar\n.")); +} void CalendarView::setLoadedFileVersion(QDateTime dt) { loadedFileVersion = dt; } bool CalendarView::checkFileChanged(QString fn) { QFileInfo finf ( fn ); if ( !finf.exists() ) return true; QDateTime dt = finf.lastModified (); if ( dt <= loadedFileVersion ) return false; return true; } void CalendarView::watchSavedFile() { QFileInfo finf ( MainWindow::defaultFileName()); if ( !finf.exists() ) return; QDateTime dt = finf.lastModified (); if ( dt < loadedFileVersion ) { QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); return; } loadedFileVersion = dt; } bool CalendarView::checkFileVersion(QString fn) { QFileInfo finf ( fn ); if ( !finf.exists() ) return true; QDateTime dt = finf.lastModified (); //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)) , i18n("KO/Pi Warning"),i18n("Overwrite"), i18n("Sync+save")); if ( km == KMessageBox::Cancel ) return false; if ( km == KMessageBox::Yes ) return true; setSyncDevice("deleteaftersync" ); KOPrefs::instance()->mAskForPreferences = true; KOPrefs::instance()->mSyncAlgoPrefs = 3; KOPrefs::instance()->mWriteBackFile = false; KOPrefs::instance()->mWriteBackExistingOnly = false; KOPrefs::instance()->mShowSyncSummary = false; syncCalendar( fn, 3 ); Event * e = getLastSyncEvent(); mCalendar->deleteEvent ( e ); updateView(); return true; } bool CalendarView::saveCalendar( QString filename ) { // Store back all unsaved data into calendar object diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 355bb84..cd54685 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -111,128 +111,129 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void addView(KOrg::BaseView *); void showView(KOrg::BaseView *); KOEventViewerDialog* getEventViewerDialog(); Incidence *currentSelection(); void setupExternSyncProfiles(); signals: /** This todo has been modified */ void todoModified(Todo *, int); /** when change is made to options dialog, the topwidget will catch this * and emit this signal which notifies all widgets which have registered * for notification to update their settings. */ void configChanged(); /** emitted when the topwidget is closing down, so that any attached child windows can also close. */ void closingDown(); /** emitted right before we die */ void closed(QWidget *); /** Emitted when state of modified flag changes */ void modifiedChanged(bool); void signalmodified(); /** Emitted when state of read-only flag changes */ void readOnlyChanged(bool); /** Emitted when the unit of navigation changes */ void changeNavStringPrev(const QString &); void changeNavStringNext(const QString &); /** Emitted when state of events selection has changed and user is organizer*/ void organizerEventsSelected(bool); /** Emitted when state of events selection has changed and user is attendee*/ void groupEventsSelected(bool); /** Emitted when an incidence gets selected. If the selection is cleared the signal is emitted with 0 as argument. */ void incidenceSelected( Incidence * ); /** Emitted, when a todoitem is selected or deselected. */ void todoSelected( bool ); /** Emitted, when clipboard content changes. Parameter indicates if paste is possible or not. */ void pasteEnabled(bool); /** Emitted, when the number of incoming messages has changed. */ void numIncomingChanged(int); /** Emitted, when the number of outgoing messages has changed. */ void numOutgoingChanged(int); /** Send status message, which can e.g. be displayed in the status bar. */ void statusMessage(const QString &); void calendarViewExpanded( bool ); void updateSearchDialog(); public slots: + void showOpenError(); void watchSavedFile(); void recheckTimerAlarm(); void checkNextTimerAlarm(); void addAlarm(const QDateTime &qdt, const QString ¬i ); void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); void removeAlarm(const QDateTime &qdt, const QString ¬i ); /** options dialog made a changed to the configuration. we catch this * and notify all widgets which need to update their configuration. */ void updateConfig(); /** Load calendar from file \a filename. If \a merge is true, load calendar into existing one, if it is false, clear calendar, before loading. Return true, if calendar could be successfully loaded. */ bool openCalendar(QString filename, bool merge=false); bool syncCalendar(QString filename,int mode = 0 ); /** Save calendar data to file. Return true if calendar could be successfully saved. */ bool saveCalendar(QString filename); /** Close calendar. Clear calendar data and reset views to display an empty calendar. */ void closeCalendar(); /** Archive old events of calendar */ void archiveCalendar(); void showIncidence(); void editIncidence(); void editIncidenceDescription(); void deleteIncidence(); /** create an editeventwin with supplied date/time, and if bool is true, * make the event take all day. */ void newEvent(QDateTime, QDateTime, bool allDay = false); void newEvent(QDateTime fh); void newEvent(QDate dt); /** create new event without having a date hint. Takes current date as default hint. */ void newEvent(); void newFloatingEvent(); /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ void showIncidence(Incidence *); /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ void editIncidence(Incidence *); /** Delete the supplied incidence. It calls the correct deleteXXX method*/ void deleteIncidence(Incidence *); void cloneIncidence(Incidence *); void cancelIncidence(Incidence *); /** Create an editor for the supplied event. */ void editEvent(Event *); /** Delete the supplied event. */ void deleteEvent(Event *); /** Delete the event with the given unique ID. Returns false, if event wasn't found. */ bool deleteEvent(const QString &uid); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 43ee2d7..7b666d1 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -83,155 +83,153 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : bool showWarning = !finf.exists(); setIcon(SmallIcon( "ko24" ) ); mBlockAtStartup = true; mFlagKeyPressed = false; setCaption("KOrganizer/Pi"); KOPrefs *p = KOPrefs::instance(); KPimGlobalPrefs::instance()->setGlobalConfig(); // if ( QApplication::desktop()->height() > 480 ) { // if ( p->mHourSize == 4 ) // p->mHourSize = 6; // } if ( p->mHourSize > 18 ) p->mHourSize = 18; QMainWindow::ToolBarDock tbd; if ( p->mToolBarHor ) { if ( p->mToolBarUp ) tbd = Bottom; else tbd = Top; } else { if ( p->mToolBarUp ) tbd = Right; else tbd = Left; } if ( KOPrefs::instance()->mUseAppColors ) QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); globalFlagBlockStartup = 1; iconToolBar = new QPEToolBar( this ); addToolBar (iconToolBar , tbd ); mBlockSaveFlag = false; mCalendarModifiedFlag = false; QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); splash->setAlignment ( AlignCenter ); setCentralWidget( splash ); #ifndef DESKTOP_VERSION showMaximized(); #endif //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); setDefaultPreferences(); mCalendar = new CalendarLocal(); mView = new CalendarView( mCalendar, this,"mCalendar " ); mView->hide(); //mView->resize(splash->size() ); initActions(); #ifndef DESKTOP_VERSION iconToolBar->show(); qApp->processEvents(); #endif //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); int vh = height() ; int vw = width(); //qDebug("Toolbar hei %d ",iconToolBar->height() ); if ( iconToolBar->orientation () == Qt:: Horizontal ) { vh -= iconToolBar->height(); } else { vw -= iconToolBar->height(); } //mView->setMaximumSize( splash->size() ); //mView->resize( splash->size() ); //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); mView->readSettings(); - bool oldOpened = false; bool newFile = false; if( !QFile::exists( defaultFileName() ) ) { QFileInfo finfo ( defaultFileName() ); QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); qDebug("oldfile %s ", oldFile.latin1()); QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; finfo.setFile( oldFile ); if (finfo.exists() ) { KMessageBox::information( this, message); mView->openCalendar( oldFile ); qApp->processEvents(); } else { oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); finfo.setFile( oldFile ); if (finfo.exists() ) { KMessageBox::information( this, message); mView->openCalendar( oldFile ); qApp->processEvents(); } } mView->saveCalendar( defaultFileName() ); newFile = true; } QTime neededSaveTime = QDateTime::currentDateTime().time(); - if ( ! oldOpened ) mView->openCalendar( defaultFileName() ); int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); qDebug("KO: Calendar loading time: %d ms",msNeeded ); if ( KOPrefs::instance()->mLanguageChanged ) { KOPrefs::instance()->setCategoryDefaults(); int count = mView->addCategories(); KOPrefs::instance()->mLanguageChanged = false; } processIncidenceSelection( 0 ); connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processIncidenceSelection( Incidence * ) ) ); connect( mView, SIGNAL( modifiedChanged( bool ) ), SLOT( slotModifiedChanged( bool ) ) ); connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); mView->setModified( false ); mBlockAtStartup = false; mView->setModified( false ); setCentralWidget( mView ); globalFlagBlockStartup = 0; mView->show(); delete splash; if ( newFile ) mView->updateConfig(); // qApp->processEvents(); //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); fillSyncMenu(); mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); if ( showWarning ) { KMessageBox::information( this, "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); qApp->processEvents(); mView->dialogManager()->showSyncOptions(); } //US listen for result adressed from Ka/Pi #ifndef DESKTOP_VERSION connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); #endif } MainWindow::~MainWindow() { //qDebug("MainWindow::~MainWindow() "); //save toolbar location delete mServerSocket; delete mCalendar; delete KOPrefs::instance(); delete KIncidenceFormatter::instance(); } void MainWindow::showMaximized () { #ifndef DESKTOP_VERSION if ( ! globalFlagBlockStartup ) if ( mClosed ) mView->goToday(); #endif QWidget::showMaximized () ; mClosed = false; } void MainWindow::closeEvent( QCloseEvent* ce ) |