-rw-r--r-- | korganizer/journalentry.cpp | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 4751d40..56221dc 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -79,9 +79,9 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | |||
79 | new QLabel(" "+i18n("Title: "),vb); | 79 | new QLabel(" "+i18n("Title: "),vb); |
80 | mTitle = new KOLocationBox(TRUE, vb, 30); | 80 | mTitle = new KOLocationBox(TRUE, vb, 30); |
81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); | 81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding ,QSizePolicy::Fixed ,FALSE) ); |
82 | mTitleLabel = new QLabel(i18n("Title"),vb); | 82 | mCalendarBox = new QComboBox(vb); |
83 | mTitleLabel->setMargin(0); | 83 | //mTitleLabel->setMargin(0); |
84 | mTitleLabel->setAlignment(AlignCenter); | 84 | //mTitleLabel->setAlignment(AlignCenter); |
85 | QPushButton * loadTemplate = new QPushButton( vb ); | 85 | QPushButton * loadTemplate = new QPushButton( vb ); |
86 | QPushButton * saveTemplate = new QPushButton( vb ); | 86 | QPushButton * saveTemplate = new QPushButton( vb ); |
87 | if ( QApplication::desktop()->width() < 321 ) | 87 | if ( QApplication::desktop()->width() < 321 ) |
@@ -99,6 +99,7 @@ JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | |||
99 | saveTemplate->setFixedSize( size, size ); | 99 | saveTemplate->setFixedSize( size, size ); |
100 | toggleJournal->setFixedSize( size , size ); | 100 | toggleJournal->setFixedSize( size , size ); |
101 | mTitle->setMaximumHeight( size+4); | 101 | mTitle->setMaximumHeight( size+4); |
102 | mCalendarBox->setMaximumHeight( size+4); | ||
102 | mEditor = new KTextEdit(this); | 103 | mEditor = new KTextEdit(this); |
103 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
104 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 105 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
@@ -176,9 +177,34 @@ void JournalEntry::setDate(const QDate &date) | |||
176 | showOnlyMode = false; | 177 | showOnlyMode = false; |
177 | writeJournal(); | 178 | writeJournal(); |
178 | mDate = date; | 179 | mDate = date; |
179 | int id = mCalendar->defaultCalendar(); | 180 | fillCalendar( mCalendar->defaultCalendar() ); |
180 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; | 181 | } |
181 | mTitleLabel->setText( " (" + calname +")"); | 182 | void JournalEntry::fillCalendar( int setToID ) |
183 | { | ||
184 | mCalendarBox->clear(); | ||
185 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | ||
186 | int std = 0; | ||
187 | int count = 0; | ||
188 | while ( kkf ) { | ||
189 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { | ||
190 | if ( setToID ) { | ||
191 | if ( kkf->mCalNumber == setToID ) | ||
192 | std = count; | ||
193 | } else { | ||
194 | if ( kkf->isStandard ) { | ||
195 | std = count; | ||
196 | } | ||
197 | } | ||
198 | ++count; | ||
199 | mCalendarBox->insertItem( kkf->mName ); | ||
200 | } | ||
201 | kkf = KOPrefs::instance()->mCalendars.next(); | ||
202 | } | ||
203 | mCalendarBox->setCurrentItem( std ); | ||
204 | if ( KOPrefs::instance()->mCalendars.count() == 1 ) | ||
205 | mCalendarBox->hide(); | ||
206 | else | ||
207 | mCalendarBox->show(); | ||
182 | } | 208 | } |
183 | 209 | ||
184 | void JournalEntry::toggleShowJournal() | 210 | void JournalEntry::toggleShowJournal() |
@@ -206,9 +232,10 @@ void JournalEntry::setShowOnly() | |||
206 | else | 232 | else |
207 | mEditor->setFocus(); | 233 | mEditor->setFocus(); |
208 | } | 234 | } |
209 | void JournalEntry::setJournal(Journal *journal) | 235 | void JournalEntry::setJournal(Journal *journal, bool saveJournal ) |
210 | { | 236 | { |
211 | writeJournal(); | 237 | if ( saveJournal ) |
238 | writeJournal(); | ||
212 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 239 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
213 | 240 | ||
214 | mJournal = journal; | 241 | mJournal = journal; |
@@ -219,10 +246,7 @@ void JournalEntry::setJournal(Journal *journal) | |||
219 | mEditor->setText(mJournal->description()); | 246 | mEditor->setText(mJournal->description()); |
220 | mTitle->setEnabled (!journal->isReadOnly() ); | 247 | mTitle->setEnabled (!journal->isReadOnly() ); |
221 | mEditor->setReadOnly ( journal->isReadOnly() ); | 248 | mEditor->setReadOnly ( journal->isReadOnly() ); |
222 | int id = mJournal->calID(); | 249 | fillCalendar( mJournal->calID() ); |
223 | |||
224 | QString calname = KOPrefs::instance()->getCalendar( id )->mName; | ||
225 | mTitleLabel->setText( " (" + calname +")"); | ||
226 | } | 250 | } |
227 | 251 | ||
228 | Journal *JournalEntry::journal() const | 252 | Journal *JournalEntry::journal() const |
@@ -260,6 +284,7 @@ bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | |||
260 | void JournalEntry::writeJournal() | 284 | void JournalEntry::writeJournal() |
261 | { | 285 | { |
262 | if ( !visibleMode ) return; | 286 | if ( !visibleMode ) return; |
287 | if ( !mTitle->isEnabled() ) return; | ||
263 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { | 288 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { |
264 | if ( mJournal ) { | 289 | if ( mJournal ) { |
265 | Journal* j = mJournal; | 290 | Journal* j = mJournal; |
@@ -286,6 +311,10 @@ void JournalEntry::writeJournal() | |||
286 | mJournal->setSummary(mTitle->currentText()); | 311 | mJournal->setSummary(mTitle->currentText()); |
287 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); | 312 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); |
288 | } | 313 | } |
314 | int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); | ||
315 | if ( mJournal->calID() != id ) { | ||
316 | mJournal->setCalID( id ); | ||
317 | } | ||
289 | } | 318 | } |
290 | 319 | ||
291 | void JournalEntry::flushEntry() | 320 | void JournalEntry::flushEntry() |