summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-30 06:35:25 (UTC)
committer zautrix <zautrix>2005-06-30 06:35:25 (UTC)
commit0fc571a7eadda739fd1a93d627e7129b9956c9f6 (patch) (unidiff)
tree60336a1e91259ab654e292dbe9938af4ecdf7a72
parentda264cf19c0183d6ea4e8dab6eabd40994e351c8 (diff)
downloadkdepimpi-0fc571a7eadda739fd1a93d627e7129b9956c9f6.zip
kdepimpi-0fc571a7eadda739fd1a93d627e7129b9956c9f6.tar.gz
kdepimpi-0fc571a7eadda739fd1a93d627e7129b9956c9f6.tar.bz2
fixes
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
@@ -58,13 +58,13 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
58 QFrame(parent) 58 QFrame(parent)
59{ 59{
60 heiHint = QApplication::desktop()->height() / 5 ; 60 heiHint = QApplication::desktop()->height() / 5 ;
61 showOnlyMode = false; 61 showOnlyMode = false;
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;
67 67
68 QPushButton * toggleJournal = new QPushButton( vb ); 68 QPushButton * toggleJournal = new QPushButton( vb );
69 iconp = SmallIcon("1updownarrow"); 69 iconp = SmallIcon("1updownarrow");
70 toggleJournal->setPixmap (iconp ) ; 70 toggleJournal->setPixmap (iconp ) ;
@@ -168,22 +168,27 @@ void JournalEntry::setDate(const QDate &date)
168 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 168 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
169 mTitleLabel->setText( " (" + calname +")"); 169 mTitleLabel->setText( " (" + calname +")");
170} 170}
171 171
172void JournalEntry::toggleShowJournal() 172void 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}
180void JournalEntry::setShowOnly() 184void JournalEntry::setShowOnly()
181{ 185{
182 showOnlyMode = true; 186 showOnlyMode = true;
183 mEditor->setFocus(); 187 mEditor->setFocus();
188 visibleMode = true;
184} 189}
185void JournalEntry::setJournal(Journal *journal) 190void JournalEntry::setJournal(Journal *journal)
186{ 191{
187 writeJournal(); 192 writeJournal();
188 193
189 mJournal = journal; 194 mJournal = journal;
@@ -208,12 +213,13 @@ Journal *JournalEntry::journal() const
208 213
209 214
210void JournalEntry::clear() 215void JournalEntry::clear()
211{ 216{
212 mJournal = 0; 217 mJournal = 0;
213 mEditor->setText(""); 218 mEditor->setText("");
219 mTitle->setText("");
214} 220}
215 221
216bool JournalEntry::eventFilter( QObject *o, QEvent *e ) 222bool JournalEntry::eventFilter( QObject *o, QEvent *e )
217{ 223{
218// kdDebug() << "JournalEntry::event received " << e->type() << endl; 224// kdDebug() << "JournalEntry::event received " << e->type() << endl;
219 225
@@ -230,20 +236,21 @@ bool JournalEntry::eventFilter( QObject *o, QEvent *e )
230 236
231 return QFrame::eventFilter( o, e ); // standard event processing 237 return QFrame::eventFilter( o, e ); // standard event processing
232} 238}
233 239
234void JournalEntry::writeJournal() 240void 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;
246 } 253 }
247 254
248// kdDebug() << "JournalEntry::writeJournal()..." << endl; 255// kdDebug() << "JournalEntry::writeJournal()..." << endl;
249 256
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 {
48 48
49 void clear(); 49 void clear();
50 50
51 void flushEntry(); 51 void flushEntry();
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:
56 void slotSaveTemplate(); 57 void slotSaveTemplate();
57 void slotLoadTemplate(); 58 void slotLoadTemplate();
58 void toggleShowJournal(); 59 void toggleShowJournal();
59 signals: 60 signals:
@@ -64,12 +65,13 @@ class JournalEntry : public QFrame {
64 protected: 65 protected:
65 bool eventFilter( QObject *o, QEvent *e ); 66 bool eventFilter( QObject *o, QEvent *e );
66 67
67 void writeJournal(); 68 void writeJournal();
68 69
69 private: 70 private:
71 bool visibleMode;
70 bool showOnlyMode; 72 bool showOnlyMode;
71 Calendar *mCalendar; 73 Calendar *mCalendar;
72 Journal *mJournal; 74 Journal *mJournal;
73 QDate mDate; 75 QDate mDate;
74 void keyPressEvent ( QKeyEvent * ) ; 76 void keyPressEvent ( QKeyEvent * ) ;
75 QLabel *mTitleLabel; 77 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()
118 } 118 }
119 showDates( mDate, QDate() ); 119 showDates( mDate, QDate() );
120} 120}
121 121
122void KOJournalView::flushView() 122void 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 ) {
126 mEntry->flushEntry(); 129 mEntry->flushEntry();
127 mEntry = jEntries.next(); 130 mEntry = jEntries.next();
128 } 131 }
132 ff = false;
129} 133}
130 134
131void KOJournalView::clearList() 135void KOJournalView::clearList()
132{ 136{
133 JournalEntry* mEntry = jEntries.first(); 137 JournalEntry* mEntry = jEntries.first();
134 while ( mEntry ) { 138 while ( mEntry ) {
135 mEntry->clear(); 139 mEntry->clear();
136 mEntry = jEntries.next(); 140 mEntry = jEntries.next();
137 } 141 }
138} 142}
139void KOJournalView::newJournal() 143void KOJournalView::newJournal()
140{ 144{
145 //qDebug(" KOJournalView::newJournal()");
141 flushView(); 146 flushView();
142 Journal* mJournal = new Journal; 147 Journal* mJournal = new Journal;
143 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 148 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
144 mCalendar->addJournal(mJournal); 149 mCalendar->addJournal(mJournal);
145 showDates( mDate, QDate() ); 150 showDates( mDate, QDate() );
146} 151}
147 152
148void KOJournalView::showOnly ( Journal* j ) 153void KOJournalView::showOnly ( Journal* j )
149{ 154{
155 //qDebug("showOnly %x ", j);
150 flushView(); 156 flushView();
151 if ( j == 0 ) { 157 if ( j == 0 ) {
152 showDates( mDate, QDate() ); 158 showDates( mDate, QDate() );
153 return; 159 return;
154 } 160 }
155 QPtrList<Journal> jl; 161 QPtrList<Journal> jl;
@@ -157,38 +163,45 @@ void KOJournalView::showOnly ( Journal* j )
157 showList( jl ); 163 showList( jl );
158 JournalEntry* mEntry = jEntries.first(); 164 JournalEntry* mEntry = jEntries.first();
159 mEntry->setShowOnly(); 165 mEntry->setShowOnly();
160} 166}
161void KOJournalView::showList(QPtrList<Journal> jl) 167void 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;
165 int count = jl.count(); 172 int count = jl.count();
166 int iii = 0; 173 int iii = 0;
167 while ( iii < count ) { 174 while ( iii < count ) {
168 if ( !mEntry ) { 175 if ( !mEntry ) {
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 }
180 ++iii; 189 ++iii;
181 } 190 }
182 while ( mEntry ) { 191 while ( mEntry ) {
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 }
191} 204}
192 205
193void KOJournalView::showDates(const QDate &start, const QDate &) 206void KOJournalView::showDates(const QDate &start, const QDate &)
194{ 207{