author | zautrix <zautrix> | 2005-06-30 12:37:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-30 12:37:10 (UTC) |
commit | 4c19ba3345d1af263c02ebe564e56d9dec679347 (patch) (unidiff) | |
tree | 1ac48610c5545998670fa1c14592ef4e1981ce94 | |
parent | 13eb32c82e736b033435e596111b7b0f3fe75608 (diff) | |
download | kdepimpi-4c19ba3345d1af263c02ebe564e56d9dec679347.zip kdepimpi-4c19ba3345d1af263c02ebe564e56d9dec679347.tar.gz kdepimpi-4c19ba3345d1af263c02ebe564e56d9dec679347.tar.bz2 |
fixx
-rw-r--r-- | korganizer/journalentry.cpp | 13 | ||||
-rw-r--r-- | korganizer/journalentry.h | 1 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 12 |
3 files changed, 17 insertions, 9 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 9e2c902..ca8d5f7 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -133,88 +133,95 @@ void JournalEntry::slotSaveTemplate() | |||
133 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 133 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
134 | tsIn << mEditor->text(); | 134 | tsIn << mEditor->text(); |
135 | fileIn.close(); | 135 | fileIn.close(); |
136 | } | 136 | } |
137 | void JournalEntry::slotLoadTemplate() | 137 | void JournalEntry::slotLoadTemplate() |
138 | { | 138 | { |
139 | QString fileName =locateLocal( "templates", "journals" ); | 139 | QString fileName =locateLocal( "templates", "journals" ); |
140 | QDir t_dir; | 140 | QDir t_dir; |
141 | if ( !t_dir.exists(fileName) ) | 141 | if ( !t_dir.exists(fileName) ) |
142 | t_dir.mkdir ( fileName ); | 142 | t_dir.mkdir ( fileName ); |
143 | fileName += "/journal"; | 143 | fileName += "/journal"; |
144 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 144 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
145 | if ( fileName.length() == 0 ) | 145 | if ( fileName.length() == 0 ) |
146 | return; | 146 | return; |
147 | QFile fileIn( fileName ); | 147 | QFile fileIn( fileName ); |
148 | if (!fileIn.open( IO_ReadOnly ) ) { | 148 | if (!fileIn.open( IO_ReadOnly ) ) { |
149 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 149 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
150 | .arg( fileName ) ); | 150 | .arg( fileName ) ); |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | QTextStream tsIn( &fileIn ); | 153 | QTextStream tsIn( &fileIn ); |
154 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 154 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
155 | QString text = tsIn.read(); | 155 | QString text = tsIn.read(); |
156 | fileIn.close(); | 156 | fileIn.close(); |
157 | int line, col; | 157 | int line, col; |
158 | mEditor->getCursorPosition (& line, & col ); | 158 | mEditor->getCursorPosition (& line, & col ); |
159 | mEditor-> insertAt ( text, line, col, true ); | 159 | mEditor-> insertAt ( text, line, col, true ); |
160 | //mEditor->setIgnoreMark( true ); | 160 | //mEditor->setIgnoreMark( true ); |
161 | } | 161 | } |
162 | void JournalEntry::setDate(const QDate &date) | 162 | void JournalEntry::setDate(const QDate &date) |
163 | { | 163 | { |
164 | showOnlyMode = false; | 164 | showOnlyMode = false; |
165 | mDate = date; | ||
166 | writeJournal(); | 165 | writeJournal(); |
166 | mDate = date; | ||
167 | int id = mCalendar->defaultCalendar(); | 167 | int id = mCalendar->defaultCalendar(); |
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 | ||
172 | void JournalEntry::toggleShowJournal() | 172 | void JournalEntry::toggleShowJournal() |
173 | { | 173 | { |
174 | if (!mEditor->text().isEmpty() || !mTitle->text().isEmpty()) | 174 | if (!mEditor->text().isEmpty() || !mTitle->text().isEmpty()) |
175 | flushEntry(); | 175 | flushEntry(); |
176 | if ( showOnlyMode ) | 176 | if ( showOnlyMode ) |
177 | emit showJournalOnly( 0 ); | 177 | emit showJournalOnly( 0 ); |
178 | else { | 178 | else { |
179 | // we have to protect mJournal from deleting if mJournal has empty text | 179 | // we have to protect mJournal from deleting if mJournal has empty text |
180 | visibleMode = false; // set to true via :setShowOnly() | 180 | visibleMode = false; // set to true via :setShowOnly() |
181 | emit showJournalOnly( mJournal ); | 181 | emit showJournalOnly( mJournal ); |
182 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); | ||
182 | } | 183 | } |
183 | } | 184 | } |
185 | void JournalEntry::setVisibleOn() | ||
186 | { | ||
187 | visibleMode = true; | ||
188 | } | ||
184 | void JournalEntry::setShowOnly() | 189 | void JournalEntry::setShowOnly() |
185 | { | 190 | { |
186 | showOnlyMode = true; | 191 | showOnlyMode = true; |
187 | mEditor->setFocus(); | 192 | if ( mTitle->text().isEmpty() ) |
188 | visibleMode = true; | 193 | mTitle->setFocus(); |
194 | else | ||
195 | mEditor->setFocus(); | ||
189 | } | 196 | } |
190 | void JournalEntry::setJournal(Journal *journal) | 197 | void JournalEntry::setJournal(Journal *journal) |
191 | { | 198 | { |
192 | writeJournal(); | 199 | writeJournal(); |
193 | 200 | ||
194 | mJournal = journal; | 201 | mJournal = journal; |
195 | if ( journal->isReadOnly() ) | 202 | if ( journal->isReadOnly() ) |
196 | mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")"); | 203 | mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")"); |
197 | else | 204 | else |
198 | mTitle->setText(mJournal->summary()); | 205 | mTitle->setText(mJournal->summary()); |
199 | mEditor->setText(mJournal->description()); | 206 | mEditor->setText(mJournal->description()); |
200 | mTitle->setReadOnly (journal->isReadOnly() ); | 207 | mTitle->setReadOnly (journal->isReadOnly() ); |
201 | mEditor->setReadOnly ( journal->isReadOnly() ); | 208 | mEditor->setReadOnly ( journal->isReadOnly() ); |
202 | int id = mJournal->calID(); | 209 | int id = mJournal->calID(); |
203 | 210 | ||
204 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; | 211 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; |
205 | mTitleLabel->setText( " (" + calname +")"); | 212 | mTitleLabel->setText( " (" + calname +")"); |
206 | 213 | ||
207 | } | 214 | } |
208 | 215 | ||
209 | Journal *JournalEntry::journal() const | 216 | Journal *JournalEntry::journal() const |
210 | { | 217 | { |
211 | return mJournal; | 218 | return mJournal; |
212 | } | 219 | } |
213 | 220 | ||
214 | 221 | ||
215 | void JournalEntry::clear() | 222 | void JournalEntry::clear() |
216 | { | 223 | { |
217 | mJournal = 0; | 224 | mJournal = 0; |
218 | mEditor->setText(""); | 225 | mEditor->setText(""); |
219 | mTitle->setText(""); | 226 | mTitle->setText(""); |
220 | } | 227 | } |
diff --git a/korganizer/journalentry.h b/korganizer/journalentry.h index e98d018..cc9b5ef 100644 --- a/korganizer/journalentry.h +++ b/korganizer/journalentry.h | |||
@@ -28,56 +28,57 @@ | |||
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | class QLabel; | 32 | class QLabel; |
33 | class KTextEdit; | 33 | class KTextEdit; |
34 | class KLineEdit; | 34 | class KLineEdit; |
35 | 35 | ||
36 | using namespace KCal; | 36 | using namespace KCal; |
37 | 37 | ||
38 | class JournalEntry : public QFrame { | 38 | class JournalEntry : public QFrame { |
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | public: | 40 | public: |
41 | JournalEntry(Calendar *,QWidget *parent); | 41 | JournalEntry(Calendar *,QWidget *parent); |
42 | virtual ~JournalEntry(); | 42 | virtual ~JournalEntry(); |
43 | 43 | ||
44 | void setJournal(Journal *); | 44 | void setJournal(Journal *); |
45 | Journal *journal() const; | 45 | Journal *journal() const; |
46 | 46 | ||
47 | void setDate(const QDate &); | 47 | void setDate(const QDate &); |
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 | void setVisibleMode( bool b ) { visibleMode = b;} |
55 | 55 | ||
56 | protected slots: | 56 | protected slots: |
57 | void slotSaveTemplate(); | 57 | void slotSaveTemplate(); |
58 | void slotLoadTemplate(); | 58 | void slotLoadTemplate(); |
59 | void toggleShowJournal(); | 59 | void toggleShowJournal(); |
60 | void setVisibleOn(); | ||
60 | signals: | 61 | signals: |
61 | void deleteJournal(Journal *); | 62 | void deleteJournal(Journal *); |
62 | void newJournal(); | 63 | void newJournal(); |
63 | void showJournalOnly( Journal * ); | 64 | void showJournalOnly( Journal * ); |
64 | 65 | ||
65 | protected: | 66 | protected: |
66 | bool eventFilter( QObject *o, QEvent *e ); | 67 | bool eventFilter( QObject *o, QEvent *e ); |
67 | 68 | ||
68 | void writeJournal(); | 69 | void writeJournal(); |
69 | 70 | ||
70 | private: | 71 | private: |
71 | bool visibleMode; | 72 | bool visibleMode; |
72 | bool showOnlyMode; | 73 | bool showOnlyMode; |
73 | Calendar *mCalendar; | 74 | Calendar *mCalendar; |
74 | Journal *mJournal; | 75 | Journal *mJournal; |
75 | QDate mDate; | 76 | QDate mDate; |
76 | void keyPressEvent ( QKeyEvent * ) ; | 77 | void keyPressEvent ( QKeyEvent * ) ; |
77 | QLabel *mTitleLabel; | 78 | QLabel *mTitleLabel; |
78 | KLineEdit * mTitle; | 79 | KLineEdit * mTitle; |
79 | KTextEdit *mEditor; | 80 | KTextEdit *mEditor; |
80 | int heiHint; | 81 | int heiHint; |
81 | }; | 82 | }; |
82 | 83 | ||
83 | #endif | 84 | #endif |
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index 7a96aa5..6fa9b23 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp | |||
@@ -126,110 +126,110 @@ void KOJournalView::flushView() | |||
126 | { | 126 | { |
127 | static bool ff = false; | 127 | static bool ff = false; |
128 | if ( ff ) return; | 128 | if ( ff ) return; |
129 | ff = true; | 129 | ff = true; |
130 | JournalEntry* mEntry = jEntries.first(); | 130 | JournalEntry* mEntry = jEntries.first(); |
131 | while ( mEntry ) { | 131 | while ( mEntry ) { |
132 | mEntry->flushEntry(); | 132 | mEntry->flushEntry(); |
133 | mEntry = jEntries.next(); | 133 | mEntry = jEntries.next(); |
134 | } | 134 | } |
135 | ff = false; | 135 | ff = false; |
136 | } | 136 | } |
137 | 137 | ||
138 | void KOJournalView::clearList() | 138 | void KOJournalView::clearList() |
139 | { | 139 | { |
140 | JournalEntry* mEntry = jEntries.first(); | 140 | JournalEntry* mEntry = jEntries.first(); |
141 | while ( mEntry ) { | 141 | while ( mEntry ) { |
142 | mEntry->clear(); | 142 | mEntry->clear(); |
143 | mEntry = jEntries.next(); | 143 | mEntry = jEntries.next(); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | void KOJournalView::newJournal() | 146 | void KOJournalView::newJournal() |
147 | { | 147 | { |
148 | //qDebug(" KOJournalView::newJournal()"); | 148 | //qDebug(" KOJournalView::newJournal()"); |
149 | flushView(); | 149 | flushView(); |
150 | Journal* mJournal = new Journal; | 150 | Journal* mJournal = new Journal; |
151 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 151 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
152 | mCalendar->addJournal(mJournal); | 152 | mCalendar->addJournal(mJournal); |
153 | showDates( mDate, QDate() ); | 153 | showDates( mDate, QDate() ); |
154 | } | 154 | } |
155 | 155 | ||
156 | void KOJournalView::showOnly ( Journal* j ) | 156 | void KOJournalView::showOnly ( Journal* j ) |
157 | { | 157 | { |
158 | //qDebug("showOnly %x ", j); | 158 | qDebug("showOnly %x ", j); |
159 | flushView(); | 159 | flushView(); |
160 | if ( j == 0 ) { | 160 | if ( j == 0 ) { |
161 | showDates( mDate, QDate() ); | 161 | showDates( mDate, QDate() ); |
162 | return; | 162 | return; |
163 | } | 163 | } |
164 | QPtrList<Journal> jl; | 164 | QPtrList<Journal> jl; |
165 | jl.append ( j ); | 165 | jl.append ( j ); |
166 | showList( jl ); | 166 | showList( jl ); |
167 | JournalEntry* mEntry = jEntries.first(); | 167 | JournalEntry* mEntry = jEntries.first(); |
168 | mEntry->setShowOnly(); | 168 | mEntry->setShowOnly(); |
169 | } | 169 | } |
170 | void KOJournalView::showList(QPtrList<Journal> jl) | 170 | void KOJournalView::showList(QPtrList<Journal> jl) |
171 | { | 171 | { |
172 | //qDebug("KOJournalView::showList %d",jl.count() ); | 172 | qDebug("KOJournalView::showList %d",jl.count() ); |
173 | JournalEntry* mEntry = jEntries.first(); | 173 | JournalEntry* mEntry = jEntries.first(); |
174 | JournalEntry* firstEntry = mEntry; | 174 | JournalEntry* firstEntry = mEntry; |
175 | int count = jl.count(); | 175 | int count = jl.count(); |
176 | int iii = 0; | 176 | int iii = 0; |
177 | while ( iii < count ) { | 177 | while ( iii < count ) { |
178 | if ( !mEntry ) { | 178 | if ( !mEntry ) { |
179 | mEntry = getNewEntry(); | 179 | mEntry = getNewEntry(); |
180 | mEntry->show(); | ||
181 | mEntry->setVisibleMode( true ); | ||
182 | mEntry->setDate(mDate); | 180 | mEntry->setDate(mDate); |
183 | mEntry->setJournal(jl.at(iii)); | 181 | mEntry->setJournal(jl.at(iii)); |
182 | mEntry->setVisibleMode( true ); | ||
183 | mEntry->show(); | ||
184 | mEntry = 0; | 184 | mEntry = 0; |
185 | } else { | 185 | } else { |
186 | mEntry->setDate(mDate); | 186 | mEntry->setDate(mDate); |
187 | mEntry->setJournal(jl.at(iii)); | 187 | mEntry->setJournal(jl.at(iii)); |
188 | mEntry->show(); | ||
189 | mEntry->setVisibleMode( true ); | 188 | mEntry->setVisibleMode( true ); |
189 | mEntry->show(); | ||
190 | mEntry = jEntries.next(); | 190 | mEntry = jEntries.next(); |
191 | } | 191 | } |
192 | ++iii; | 192 | ++iii; |
193 | } | 193 | } |
194 | while ( mEntry ) { | 194 | while ( mEntry ) { |
195 | mEntry->setDate(mDate); | 195 | mEntry->setDate(mDate); |
196 | mEntry->clear(); | 196 | mEntry->clear(); |
197 | if ( mEntry != firstEntry ) { | 197 | if ( mEntry != firstEntry ) { |
198 | mEntry->hide(); | 198 | mEntry->hide(); |
199 | mEntry->setVisibleMode( false ); | 199 | mEntry->setVisibleMode( false ); |
200 | } | 200 | } |
201 | else { | 201 | else { |
202 | mEntry->setVisibleMode( true ); | 202 | mEntry->setVisibleMode( true ); |
203 | mEntry->show(); | 203 | mEntry->show(); |
204 | } | 204 | } |
205 | mEntry = jEntries.next(); | 205 | mEntry = jEntries.next(); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | void KOJournalView::showDates(const QDate &start, const QDate &) | 209 | void KOJournalView::showDates(const QDate &start, const QDate &) |
210 | { | 210 | { |
211 | mDate = start; | 211 | mDate = start; |
212 | mDateLabel-> setText(KGlobal::locale()->formatDate(mDate)); | 212 | mDateLabel->setText(KGlobal::locale()->formatDate(mDate)); |
213 | QPtrList<Journal> jl = calendar()->journals4Date( start ); | 213 | QPtrList<Journal> jl = calendar()->journals4Date( start ); |
214 | showList( jl ); | 214 | showList( jl ); |
215 | } | 215 | } |
216 | 216 | ||
217 | void KOJournalView::showEvents(QPtrList<Event>) | 217 | void KOJournalView::showEvents(QPtrList<Event>) |
218 | { | 218 | { |
219 | // After new creation of list view no events are selected. | 219 | // After new creation of list view no events are selected. |
220 | // emit incidenceSelected( 0 ); | 220 | // emit incidenceSelected( 0 ); |
221 | } | 221 | } |
222 | 222 | ||
223 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) | 223 | void KOJournalView::changeEventDisplay(Event *, int /*action*/) |
224 | { | 224 | { |
225 | updateView(); | 225 | updateView(); |
226 | } | 226 | } |
227 | 227 | ||
228 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) | 228 | void KOJournalView::keyPressEvent ( QKeyEvent * e ) |
229 | { | 229 | { |
230 | //qDebug("keyPressEven "); | 230 | //qDebug("keyPressEven "); |
231 | if ( e->state() == Qt::ControlButton ) { | 231 | if ( e->state() == Qt::ControlButton ) { |
232 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) | 232 | if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) |
233 | e->ignore(); | 233 | e->ignore(); |
234 | } | 234 | } |
235 | } | 235 | } |