summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp19
-rw-r--r--korganizer/journalentry.h2
-rw-r--r--korganizer/kojournalview.cpp19
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
@@ -62,5 +62,5 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
mCalendar = calendar;
mJournal = 0;
-
+ visibleMode = true;
QHBox * vb = new QHBox ( this );
QPixmap iconp;
@@ -172,9 +172,13 @@ 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()
@@ -182,4 +186,5 @@ void JournalEntry::setShowOnly()
showOnlyMode = true;
mEditor->setFocus();
+ visibleMode = true;
}
void JournalEntry::setJournal(Journal *journal)
@@ -212,4 +217,5 @@ void JournalEntry::clear()
mJournal = 0;
mEditor->setText("");
+ mTitle->setText("");
}
@@ -234,12 +240,13 @@ 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
@@ -52,4 +52,5 @@ class JournalEntry : public QFrame {
void setShowOnly();
QSize sizeHint() const;
+ void setVisibleMode( bool b ) { visibleMode = b;}
protected slots:
@@ -68,4 +69,5 @@ class JournalEntry : public QFrame {
private:
+ bool visibleMode;
bool showOnlyMode;
Calendar *mCalendar;
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index cb9a2c0..b659d53 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -122,4 +122,7 @@ void KOJournalView::updateView()
void KOJournalView::flushView()
{
+ static bool ff = false;
+ if ( ff ) return;
+ ff = true;
JournalEntry* mEntry = jEntries.first();
while ( mEntry ) {
@@ -127,4 +130,5 @@ void KOJournalView::flushView()
mEntry = jEntries.next();
}
+ ff = false;
}
@@ -139,4 +143,5 @@ void KOJournalView::clearList()
void KOJournalView::newJournal()
{
+ //qDebug(" KOJournalView::newJournal()");
flushView();
Journal* mJournal = new Journal;
@@ -148,4 +153,5 @@ void KOJournalView::newJournal()
void KOJournalView::showOnly ( Journal* j )
{
+ //qDebug("showOnly %x ", j);
flushView();
if ( j == 0 ) {
@@ -161,4 +167,5 @@ void KOJournalView::showOnly ( Journal* j )
void KOJournalView::showList(QPtrList<Journal> jl)
{
+ //qDebug("KOJournalView::showList %d",jl.count() );
JournalEntry* mEntry = jEntries.first();
JournalEntry* firstEntry = mEntry;
@@ -169,11 +176,13 @@ void KOJournalView::showList(QPtrList<Journal> jl)
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();
}
@@ -183,8 +192,12 @@ void KOJournalView::showList(QPtrList<Journal> jl)
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();
}