summaryrefslogtreecommitdiffabout
path: root/korganizer/journalentry.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/journalentry.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index add874f..395392c 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -58,13 +58,13 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
QFrame(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 );
iconp = SmallIcon("1updownarrow");
toggleJournal->setPixmap (iconp ) ;
@@ -168,22 +168,27 @@ void JournalEntry::setDate(const QDate &date)
QString calname = KOPrefs::instance()->getCalendar( id )->mName;
mTitleLabel->setText( " (" + calname +")");
}
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();
mJournal = journal;
@@ -208,12 +213,13 @@ Journal *JournalEntry::journal() const
void JournalEntry::clear()
{
mJournal = 0;
mEditor->setText("");
+ mTitle->setText("");
}
bool JournalEntry::eventFilter( QObject *o, QEvent *e )
{
// kdDebug() << "JournalEntry::event received " << e->type() << endl;
@@ -230,20 +236,21 @@ bool JournalEntry::eventFilter( QObject *o, QEvent *e )
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(mJournal);
+ emit deleteJournal(j);
KOPrefs::instance()->mConfirm = conf;
- mJournal = 0;
}
return;
}
// kdDebug() << "JournalEntry::writeJournal()..." << endl;