summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (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
@@ -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;
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h
index f2db785..e98d018 100644
--- a/korganizer/journalentry.h
+++ b/korganizer/journalentry.h
@@ -48,12 +48,13 @@ class JournalEntry : public QFrame {
void clear();
void flushEntry();
void setShowOnly();
QSize sizeHint() const;
+ void setVisibleMode( bool b ) { visibleMode = b;}
protected slots:
void slotSaveTemplate();
void slotLoadTemplate();
void toggleShowJournal();
signals:
@@ -64,12 +65,13 @@ class JournalEntry : public QFrame {
protected:
bool eventFilter( QObject *o, QEvent *e );
void writeJournal();
private:
+ bool visibleMode;
bool showOnlyMode;
Calendar *mCalendar;
Journal *mJournal;
QDate mDate;
void keyPressEvent ( QKeyEvent * ) ;
QLabel *mTitleLabel;
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index cb9a2c0..b659d53 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -118,38 +118,44 @@ void KOJournalView::updateView()
}
showDates( mDate, QDate() );
}
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()
{
JournalEntry* mEntry = jEntries.first();
while ( mEntry ) {
mEntry->clear();
mEntry = jEntries.next();
}
}
void KOJournalView::newJournal()
{
+ //qDebug(" KOJournalView::newJournal()");
flushView();
Journal* mJournal = new Journal;
mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
mCalendar->addJournal(mJournal);
showDates( mDate, QDate() );
}
void KOJournalView::showOnly ( Journal* j )
{
+ //qDebug("showOnly %x ", j);
flushView();
if ( j == 0 ) {
showDates( mDate, QDate() );
return;
}
QPtrList<Journal> jl;
@@ -157,38 +163,45 @@ void KOJournalView::showOnly ( Journal* j )
showList( jl );
JournalEntry* mEntry = jEntries.first();
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();
}
}
void KOJournalView::showDates(const QDate &start, const QDate &)
{