-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 | |||
@@ -62,5 +62,5 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | |||
62 | mCalendar = calendar; | 62 | mCalendar = calendar; |
63 | mJournal = 0; | 63 | mJournal = 0; |
64 | 64 | visibleMode = true; | |
65 | QHBox * vb = new QHBox ( this ); | 65 | QHBox * vb = new QHBox ( this ); |
66 | QPixmap iconp; | 66 | QPixmap iconp; |
@@ -172,9 +172,13 @@ void JournalEntry::setDate(const QDate &date) | |||
172 | void JournalEntry::toggleShowJournal() | 172 | void JournalEntry::toggleShowJournal() |
173 | { | 173 | { |
174 | flushEntry(); | 174 | if (!mEditor->text().isEmpty() || !mTitle->text().isEmpty()) |
175 | flushEntry(); | ||
175 | if ( showOnlyMode ) | 176 | if ( showOnlyMode ) |
176 | emit showJournalOnly( 0 ); | 177 | emit showJournalOnly( 0 ); |
177 | else | 178 | else { |
179 | // we have to protect mJournal from deleting if mJournal has empty text | ||
180 | visibleMode = false; // set to true via :setShowOnly() | ||
178 | emit showJournalOnly( mJournal ); | 181 | emit showJournalOnly( mJournal ); |
182 | } | ||
179 | } | 183 | } |
180 | void JournalEntry::setShowOnly() | 184 | void JournalEntry::setShowOnly() |
@@ -182,4 +186,5 @@ void JournalEntry::setShowOnly() | |||
182 | showOnlyMode = true; | 186 | showOnlyMode = true; |
183 | mEditor->setFocus(); | 187 | mEditor->setFocus(); |
188 | visibleMode = true; | ||
184 | } | 189 | } |
185 | void JournalEntry::setJournal(Journal *journal) | 190 | void JournalEntry::setJournal(Journal *journal) |
@@ -212,4 +217,5 @@ void JournalEntry::clear() | |||
212 | mJournal = 0; | 217 | mJournal = 0; |
213 | mEditor->setText(""); | 218 | mEditor->setText(""); |
219 | mTitle->setText(""); | ||
214 | } | 220 | } |
215 | 221 | ||
@@ -234,12 +240,13 @@ bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | |||
234 | void JournalEntry::writeJournal() | 240 | void JournalEntry::writeJournal() |
235 | { | 241 | { |
236 | 242 | if ( !visibleMode ) return; | |
237 | if (mEditor->text().isEmpty() && mTitle->text().isEmpty()) { | 243 | if (mEditor->text().isEmpty() && mTitle->text().isEmpty()) { |
238 | if ( mJournal ) { | 244 | if ( mJournal ) { |
245 | Journal* j = mJournal; | ||
246 | mJournal = 0; | ||
239 | bool conf = KOPrefs::instance()->mConfirm; | 247 | bool conf = KOPrefs::instance()->mConfirm; |
240 | KOPrefs::instance()->mConfirm = false; | 248 | KOPrefs::instance()->mConfirm = false; |
241 | emit deleteJournal(mJournal); | 249 | emit deleteJournal(j); |
242 | KOPrefs::instance()->mConfirm = conf; | 250 | KOPrefs::instance()->mConfirm = conf; |
243 | mJournal = 0; | ||
244 | } | 251 | } |
245 | return; | 252 | 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 { | |||
52 | void setShowOnly(); | 52 | void setShowOnly(); |
53 | QSize sizeHint() const; | 53 | QSize sizeHint() const; |
54 | void setVisibleMode( bool b ) { visibleMode = b;} | ||
54 | 55 | ||
55 | protected slots: | 56 | protected slots: |
@@ -68,4 +69,5 @@ class JournalEntry : public QFrame { | |||
68 | 69 | ||
69 | private: | 70 | private: |
71 | bool visibleMode; | ||
70 | bool showOnlyMode; | 72 | bool showOnlyMode; |
71 | Calendar *mCalendar; | 73 | 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() | |||
122 | void KOJournalView::flushView() | 122 | void KOJournalView::flushView() |
123 | { | 123 | { |
124 | static bool ff = false; | ||
125 | if ( ff ) return; | ||
126 | ff = true; | ||
124 | JournalEntry* mEntry = jEntries.first(); | 127 | JournalEntry* mEntry = jEntries.first(); |
125 | while ( mEntry ) { | 128 | while ( mEntry ) { |
@@ -127,4 +130,5 @@ void KOJournalView::flushView() | |||
127 | mEntry = jEntries.next(); | 130 | mEntry = jEntries.next(); |
128 | } | 131 | } |
132 | ff = false; | ||
129 | } | 133 | } |
130 | 134 | ||
@@ -139,4 +143,5 @@ void KOJournalView::clearList() | |||
139 | void KOJournalView::newJournal() | 143 | void KOJournalView::newJournal() |
140 | { | 144 | { |
145 | //qDebug(" KOJournalView::newJournal()"); | ||
141 | flushView(); | 146 | flushView(); |
142 | Journal* mJournal = new Journal; | 147 | Journal* mJournal = new Journal; |
@@ -148,4 +153,5 @@ void KOJournalView::newJournal() | |||
148 | void KOJournalView::showOnly ( Journal* j ) | 153 | void KOJournalView::showOnly ( Journal* j ) |
149 | { | 154 | { |
155 | //qDebug("showOnly %x ", j); | ||
150 | flushView(); | 156 | flushView(); |
151 | if ( j == 0 ) { | 157 | if ( j == 0 ) { |
@@ -161,4 +167,5 @@ void KOJournalView::showOnly ( Journal* j ) | |||
161 | void KOJournalView::showList(QPtrList<Journal> jl) | 167 | void KOJournalView::showList(QPtrList<Journal> jl) |
162 | { | 168 | { |
169 | //qDebug("KOJournalView::showList %d",jl.count() ); | ||
163 | JournalEntry* mEntry = jEntries.first(); | 170 | JournalEntry* mEntry = jEntries.first(); |
164 | JournalEntry* firstEntry = mEntry; | 171 | JournalEntry* firstEntry = mEntry; |
@@ -169,11 +176,13 @@ void KOJournalView::showList(QPtrList<Journal> jl) | |||
169 | mEntry = getNewEntry(); | 176 | mEntry = getNewEntry(); |
170 | mEntry->show(); | 177 | mEntry->show(); |
178 | mEntry->setVisibleMode( true ); | ||
171 | mEntry->setDate(mDate); | 179 | mEntry->setDate(mDate); |
172 | mEntry->setJournal(jl.at(iii)); | 180 | mEntry->setJournal(jl.at(iii)); |
173 | mEntry = 0; | 181 | mEntry = 0; |
174 | } else { | 182 | } else { |
175 | mEntry->setDate(mDate); | 183 | mEntry->setDate(mDate); |
176 | mEntry->setJournal(jl.at(iii)); | 184 | mEntry->setJournal(jl.at(iii)); |
177 | mEntry->show(); | 185 | mEntry->show(); |
186 | mEntry->setVisibleMode( true ); | ||
178 | mEntry = jEntries.next(); | 187 | mEntry = jEntries.next(); |
179 | } | 188 | } |
@@ -183,8 +192,12 @@ void KOJournalView::showList(QPtrList<Journal> jl) | |||
183 | mEntry->setDate(mDate); | 192 | mEntry->setDate(mDate); |
184 | mEntry->clear(); | 193 | mEntry->clear(); |
185 | if ( mEntry != firstEntry ) | 194 | if ( mEntry != firstEntry ) { |
186 | mEntry->hide(); | 195 | mEntry->hide(); |
187 | else | 196 | mEntry->setVisibleMode( false ); |
197 | } | ||
198 | else { | ||
199 | mEntry->setVisibleMode( true ); | ||
188 | mEntry->show(); | 200 | mEntry->show(); |
201 | } | ||
189 | mEntry = jEntries.next(); | 202 | mEntry = jEntries.next(); |
190 | } | 203 | } |