-rw-r--r-- | korganizer/journalentry.cpp | 7 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kojournalview.h | 1 | ||||
-rw-r--r-- | korganizer/koviewmanager.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 6 |
5 files changed, 16 insertions, 5 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 395392c..3c01eeb 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -230,46 +230,47 @@ bool JournalEntry::eventFilter( QObject *o, QEvent *e ) QKeyEvent * k = (QKeyEvent *) e; if ( k->state() == Qt::ControlButton ) { k->ignore(); //return true; } } return QFrame::eventFilter( o, e ); // standard event processing } void JournalEntry::writeJournal() { if ( !visibleMode ) return; if (mEditor->text().isEmpty() && mTitle->text().isEmpty()) { if ( mJournal ) { Journal* j = mJournal; mJournal = 0; bool conf = KOPrefs::instance()->mConfirm; KOPrefs::instance()->mConfirm = false; emit deleteJournal(j); KOPrefs::instance()->mConfirm = conf; } return; } // kdDebug() << "JournalEntry::writeJournal()..." << endl; if (!mJournal) { mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); mCalendar->addJournal(mJournal); } - - mJournal->setDescription(mEditor->text()); - mJournal->setSummary(mTitle->text()); + if ( mJournal->description() != mEditor->text() ) + mJournal->setDescription(mEditor->text()); + if ( mJournal->summary() != mTitle->text() ) + mJournal->setSummary(mTitle->text()); } void JournalEntry::flushEntry() { writeJournal(); } void JournalEntry::keyPressEvent ( QKeyEvent * e ) { e->ignore(); } diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index b659d53..51ae0a0 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -89,65 +89,69 @@ JournalEntry* KOJournalView::getNewEntry() jEntries.append( Entry ); mTopLayout->addWidget(Entry); Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; return Entry; } QPtrList<Incidence> KOJournalView::selectedIncidences() { QPtrList<Incidence> eventList; return eventList; } void KOJournalView::updateConfig() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); mEntry = jEntries.next(); } } void KOJournalView::updateView() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); mEntry = jEntries.next(); } showDates( mDate, QDate() ); } - +void KOJournalView::checkModified() +{ + qDebug("checkmod "); + flushView(); +} void KOJournalView::flushView() { static bool ff = false; if ( ff ) return; ff = true; JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->flushEntry(); mEntry = jEntries.next(); } ff = false; } void KOJournalView::clearList() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->clear(); mEntry = jEntries.next(); } } void KOJournalView::newJournal() { //qDebug(" KOJournalView::newJournal()"); flushView(); Journal* mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); mCalendar->addJournal(mJournal); showDates( mDate, QDate() ); } void KOJournalView::showOnly ( Journal* j ) diff --git a/korganizer/kojournalview.h b/korganizer/kojournalview.h index 331bdfa..7fa94ae 100644 --- a/korganizer/kojournalview.h +++ b/korganizer/kojournalview.h @@ -21,59 +21,60 @@ without including the source code for Qt in the source distribution. */ #ifndef _KOJOURNALVIEW_H #define _KOJOURNALVIEW_H #include <korganizer/baseview.h> #include <qlayout.h> class JournalEntry; class QLabel; /** * This class provides a journal view. * @short View for Journal components. * @author Cornelius Schumacher <schumacher@kde.org> * @see KOBaseView */ class KOJournalView : public KOrg::BaseView { Q_OBJECT public: KOJournalView(Calendar *calendar, QWidget *parent = 0, const char *name = 0); ~KOJournalView(); virtual int currentDateCount(); void clearList(); virtual QPtrList<Incidence> selectedIncidences(); DateList selectedDates() {DateList q; return q;}; + void checkModified(); signals: void deleteJournal(Journal *); public slots: void showOnly ( Journal* ); void newJournal(); void updateView(); void flushView(); void updateConfig(); void showDates( const QDate &start, const QDate &end ); void showEvents(QPtrList<Event> eventList); void changeEventDisplay(Event *, int); private: void showList(QPtrList<Journal> jl); Calendar *mCalendar; JournalEntry* getNewEntry(); QPtrList<JournalEntry> jEntries; void keyPressEvent ( QKeyEvent * ) ; QBoxLayout *mTopLayout; QWidget *parWid; QLabel * mDateLabel; QDate mDate; }; #endif diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h index d5a8e3b..2e6aaed 100644 --- a/korganizer/koviewmanager.h +++ b/korganizer/koviewmanager.h @@ -48,64 +48,65 @@ class KOViewManager : public QObject { Q_OBJECT public: KOViewManager( CalendarView * ); virtual ~KOViewManager(); /** changes the view to be the currently selected view */ void showView(KOrg::BaseView *, bool fullScreen = false ); void updateWNview(); void readSettings(KConfig *config); void writeSettings(KConfig *config); bool showsNextDays(); /** Read which view was shown last from config file */ void readCurrentView(KConfig *); /** Write which view is currently shown to config file */ void writeCurrentView(KConfig *); KOrg::BaseView *currentView(); void setDocumentId( const QString & ); void updateView( const QDate &start, const QDate &end ); void clearAllViews(); void raiseCurrentView( bool fullScreen = false , bool updateView = false); void addView(KOrg::BaseView *); Incidence *currentSelection(); QDate currentSelectionDate(); KOAgendaView *agendaView() const { return mAgendaView; } + KOJournalView *journalView() const { return mJournalView; } signals: void printWNV(); void signalFullScreen( bool ); void signalAgendaView( bool ); public slots: void setDefaultCalendar(int); void slotprintWNV(); void showNextView(); void showMonth( const QDate & ); void showDateView( int, QDate ); void updateView(); void showWhatsNextView(); void showListView(); void showAgendaView( bool fullScreen = false ); void showDayView(); void showWorkWeekView(); void showWeekView(); void showNextXView(); void showMonthView(); void showMonthViewWeek(); void showTodoView(); void showJournalView(); void showTimeSpanView(); private: void resetDateSilent( QDate date , int days ); int flagResetViewChangeDate; QDate currentViewChangeDate; void createMonthView(); CalendarView *mMainView; diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index d8373a6..fb6d6ec 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -18,64 +18,65 @@ #include <qmap.h> #include <qwmatrix.h> #include <qtextbrowser.h> #include <qtextstream.h> #ifndef DESKTOP_VERSION #include <qpe/global.h> #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/resource.h> #include <qpe/qpeapplication.h> #include <qtopia/alarmserver.h> #include <qtopia/qcopenvelope_qws.h> #include <unistd.h> // for sleep #else #include <qmenubar.h> #include <qtoolbar.h> #include <qapplication.h> //#include <resource.h> #endif #include <libkcal/calendarlocal.h> #include <libkcal/todo.h> #include <libkcal/phoneformat.h> #include <libkdepim/ksyncprofile.h> #include <libkdepim/phoneaccess.h> #include <libkcal/kincidenceformatter.h> #include <libkdepim/kpimglobalprefs.h> #include "calendarview.h" #include "koviewmanager.h" #include "datenavigator.h" #include "koagendaview.h" +#include "kojournalview.h" #include "koagenda.h" #include "kodialogmanager.h" #include "kdialogbase.h" #include "kapplication.h" #include "kofilterview.h" #include "kstandarddirs.h" #include "koprefs.h" #include "kfiledialog.h" #include "koglobals.h" #include "kglobal.h" #include "ktoolbar.h" #include "klocale.h" #include "kconfig.h" #include "externalapphandler.h" #include <kglobalsettings.h> using namespace KCal; #ifndef _WIN32_ #include <unistd.h> #else #ifdef _OL_IMPORT_ #include "koimportoldialog.h" #endif #endif #include "mainwindow.h" class KOex2phonePrefs : public QDialog { public: KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) @@ -1805,129 +1806,132 @@ void MainWindow::saveOnClose() if ( p->mToolBarHorN ) p->mToolBarUpN = myP.y() > height()/2; else p->mToolBarUpN = myP.x() > width()/2 ; if ( filterToolBar ) { 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 - + if ( mView->viewManager()->journalView() ) + mView->viewManager()->journalView()->checkModified(); if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) save(); mView->writeSettings(); } void MainWindow::slotModifiedChanged( bool changed ) { if ( mBlockAtStartup ) return; int msec; // 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 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 ) { int retval = 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 ( mView->viewManager()->journalView() ) + mView->viewManager()->journalView()->checkModified(); if ( !mCalendarModifiedFlag ) { qDebug("KO: Calendar not modified. Nothing saved."); return; } if ( mSyncManager->blockSave() ) return; 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 = QDateTime::currentDateTime().time(); setCaption(i18n("KO/Pi:Saving Data to File ..." )); qDebug("KO: Start saving data to file!"); mView->saveCalendars(); mCalendarModifiedFlag = false; int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 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 ); setCaption(savemes); } else setCaption(i18n("Saving cancelled!")); mSyncManager->setBlockSave( false ); } void MainWindow::keyReleaseEvent ( QKeyEvent * e) |