-rw-r--r-- | korganizer/journalentry.cpp | 17 |
1 files changed, 12 insertions, 5 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; } |