-rw-r--r-- | korganizer/journalentry.cpp | 17 | ||||
-rw-r--r-- | korganizer/journalentry.h | 2 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 17 |
3 files changed, 29 insertions, 7 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index add874f..395392c 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -61,7 +61,7 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : showOnlyMode = false; mCalendar = calendar; mJournal = 0; - + visibleMode = true; QHBox * vb = new QHBox ( this ); QPixmap iconp; @@ -171,16 +171,21 @@ void JournalEntry::setDate(const QDate &date) void JournalEntry::toggleShowJournal() { + if (!mEditor->text().isEmpty() || !mTitle->text().isEmpty()) flushEntry(); if ( showOnlyMode ) emit showJournalOnly( 0 ); - else + else { + // we have to protect mJournal from deleting if mJournal has empty text + visibleMode = false; // set to true via :setShowOnly() emit showJournalOnly( mJournal ); } +} void JournalEntry::setShowOnly() { showOnlyMode = true; mEditor->setFocus(); + visibleMode = true; } void JournalEntry::setJournal(Journal *journal) { @@ -211,6 +216,7 @@ void JournalEntry::clear() { mJournal = 0; mEditor->setText(""); + mTitle->setText(""); } bool JournalEntry::eventFilter( QObject *o, QEvent *e ) @@ -233,14 +239,15 @@ bool JournalEntry::eventFilter( QObject *o, QEvent *e ) 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(mJournal); + emit deleteJournal(j); KOPrefs::instance()->mConfirm = conf; - mJournal = 0; } return; } diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index f2db785..e98d018 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h @@ -51,6 +51,7 @@ class JournalEntry : public QFrame { void flushEntry(); void setShowOnly(); QSize sizeHint() const; + void setVisibleMode( bool b ) { visibleMode = b;} protected slots: void slotSaveTemplate(); @@ -67,6 +68,7 @@ class JournalEntry : public QFrame { void writeJournal(); private: + bool visibleMode; bool showOnlyMode; Calendar *mCalendar; Journal *mJournal; diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index cb9a2c0..b659d53 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -121,11 +121,15 @@ void KOJournalView::updateView() 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() @@ -138,6 +142,7 @@ void KOJournalView::clearList() } void KOJournalView::newJournal() { + //qDebug(" KOJournalView::newJournal()"); flushView(); Journal* mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); @@ -147,6 +152,7 @@ void KOJournalView::newJournal() void KOJournalView::showOnly ( Journal* j ) { + //qDebug("showOnly %x ", j); flushView(); if ( j == 0 ) { showDates( mDate, QDate() ); @@ -160,6 +166,7 @@ void KOJournalView::showOnly ( Journal* j ) } void KOJournalView::showList(QPtrList<Journal> jl) { + //qDebug("KOJournalView::showList %d",jl.count() ); JournalEntry* mEntry = jEntries.first(); JournalEntry* firstEntry = mEntry; int count = jl.count(); @@ -168,6 +175,7 @@ void KOJournalView::showList(QPtrList<Journal> jl) if ( !mEntry ) { mEntry = getNewEntry(); mEntry->show(); + mEntry->setVisibleMode( true ); mEntry->setDate(mDate); mEntry->setJournal(jl.at(iii)); mEntry = 0; @@ -175,6 +183,7 @@ void KOJournalView::showList(QPtrList<Journal> jl) mEntry->setDate(mDate); mEntry->setJournal(jl.at(iii)); mEntry->show(); + mEntry->setVisibleMode( true ); mEntry = jEntries.next(); } ++iii; @@ -182,10 +191,14 @@ void KOJournalView::showList(QPtrList<Journal> jl) while ( mEntry ) { mEntry->setDate(mDate); mEntry->clear(); - if ( mEntry != firstEntry ) + if ( mEntry != firstEntry ) { mEntry->hide(); - else + mEntry->setVisibleMode( false ); + } + else { + mEntry->setVisibleMode( true ); mEntry->show(); + } mEntry = jEntries.next(); } } |