-rw-r--r-- | korganizer/journalentry.cpp | 19 | ||||
-rw-r--r-- | korganizer/journalentry.h | 2 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 19 |
3 files changed, 31 insertions, 9 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index add874f..395392c 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -60,9 +60,9 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : heiHint = QApplication::desktop()->height() / 5 ; showOnlyMode = false; mCalendar = calendar; mJournal = 0; - + visibleMode = true; QHBox * vb = new QHBox ( this ); QPixmap iconp; QPushButton * toggleJournal = new QPushButton( vb ); @@ -170,18 +170,23 @@ void JournalEntry::setDate(const QDate &date) } void JournalEntry::toggleShowJournal() { - flushEntry(); + 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) { writeJournal(); @@ -210,8 +215,9 @@ Journal *JournalEntry::journal() const void JournalEntry::clear() { mJournal = 0; mEditor->setText(""); + mTitle->setText(""); } bool JournalEntry::eventFilter( QObject *o, QEvent *e ) { @@ -232,16 +238,17 @@ 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 @@ -50,8 +50,9 @@ class JournalEntry : public QFrame { void flushEntry(); void setShowOnly(); QSize sizeHint() const; + void setVisibleMode( bool b ) { visibleMode = b;} protected slots: void slotSaveTemplate(); void slotLoadTemplate(); @@ -66,8 +67,9 @@ class JournalEntry : public QFrame { void writeJournal(); private: + bool visibleMode; bool showOnlyMode; Calendar *mCalendar; Journal *mJournal; QDate mDate; diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index cb9a2c0..b659d53 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -120,13 +120,17 @@ 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() { @@ -137,8 +141,9 @@ void KOJournalView::clearList() } } void KOJournalView::newJournal() { + //qDebug(" KOJournalView::newJournal()"); flushView(); Journal* mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); mCalendar->addJournal(mJournal); @@ -146,8 +151,9 @@ void KOJournalView::newJournal() } void KOJournalView::showOnly ( Journal* j ) { + //qDebug("showOnly %x ", j); flushView(); if ( j == 0 ) { showDates( mDate, QDate() ); return; @@ -159,34 +165,41 @@ void KOJournalView::showOnly ( Journal* j ) mEntry->setShowOnly(); } void KOJournalView::showList(QPtrList<Journal> jl) { + //qDebug("KOJournalView::showList %d",jl.count() ); JournalEntry* mEntry = jEntries.first(); JournalEntry* firstEntry = mEntry; int count = jl.count(); int iii = 0; while ( iii < count ) { if ( !mEntry ) { mEntry = getNewEntry(); mEntry->show(); + mEntry->setVisibleMode( true ); mEntry->setDate(mDate); mEntry->setJournal(jl.at(iii)); mEntry = 0; - } else { + } else { mEntry->setDate(mDate); mEntry->setJournal(jl.at(iii)); mEntry->show(); + mEntry->setVisibleMode( true ); mEntry = jEntries.next(); } ++iii; } 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(); } } |