author | zautrix <zautrix> | 2005-06-30 12:37:10 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-30 12:37:10 (UTC) |
commit | 4c19ba3345d1af263c02ebe564e56d9dec679347 (patch) (side-by-side diff) | |
tree | 1ac48610c5545998670fa1c14592ef4e1981ce94 /korganizer/journalentry.cpp | |
parent | 13eb32c82e736b033435e596111b7b0f3fe75608 (diff) | |
download | kdepimpi-4c19ba3345d1af263c02ebe564e56d9dec679347.zip kdepimpi-4c19ba3345d1af263c02ebe564e56d9dec679347.tar.gz kdepimpi-4c19ba3345d1af263c02ebe564e56d9dec679347.tar.bz2 |
fixx
-rw-r--r-- | korganizer/journalentry.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 9e2c902..ca8d5f7 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp @@ -117,120 +117,127 @@ void JournalEntry::slotSaveTemplate() QDir t_dir; if ( !t_dir.exists(fileName) ) t_dir.mkdir ( fileName ); fileName += "/journal"; fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); if ( fileName.length() == 0 ) return; QFile fileIn( fileName ); if (!fileIn.open( IO_WriteOnly ) ) { KMessageBox::error( this, i18n("Error saving template file\n '%1'.") .arg( fileName ) ); return; } // QString text; QTextStream tsIn( &fileIn ); tsIn.setCodec( QTextCodec::codecForName("utf8") ); tsIn << mEditor->text(); fileIn.close(); } void JournalEntry::slotLoadTemplate() { QString fileName =locateLocal( "templates", "journals" ); QDir t_dir; if ( !t_dir.exists(fileName) ) t_dir.mkdir ( fileName ); fileName += "/journal"; fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); if ( fileName.length() == 0 ) return; QFile fileIn( fileName ); if (!fileIn.open( IO_ReadOnly ) ) { KMessageBox::error( this, i18n("Error loading template file\n '%1'.") .arg( fileName ) ); return; } QTextStream tsIn( &fileIn ); tsIn.setCodec( QTextCodec::codecForName("utf8") ); QString text = tsIn.read(); fileIn.close(); int line, col; mEditor->getCursorPosition (& line, & col ); mEditor-> insertAt ( text, line, col, true ); //mEditor->setIgnoreMark( true ); } void JournalEntry::setDate(const QDate &date) { showOnlyMode = false; - mDate = date; writeJournal(); + mDate = date; int id = mCalendar->defaultCalendar(); QString calname = KOPrefs::instance()->getCalendar( id )->mName; mTitleLabel->setText( " (" + calname +")"); } void JournalEntry::toggleShowJournal() { if (!mEditor->text().isEmpty() || !mTitle->text().isEmpty()) flushEntry(); if ( showOnlyMode ) emit showJournalOnly( 0 ); else { // we have to protect mJournal from deleting if mJournal has empty text visibleMode = false; // set to true via :setShowOnly() emit showJournalOnly( mJournal ); + //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); } } +void JournalEntry::setVisibleOn() +{ + visibleMode = true; +} void JournalEntry::setShowOnly() { showOnlyMode = true; - mEditor->setFocus(); - visibleMode = true; + if ( mTitle->text().isEmpty() ) + mTitle->setFocus(); + else + mEditor->setFocus(); } void JournalEntry::setJournal(Journal *journal) { writeJournal(); mJournal = journal; if ( journal->isReadOnly() ) mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")"); else mTitle->setText(mJournal->summary()); mEditor->setText(mJournal->description()); mTitle->setReadOnly (journal->isReadOnly() ); mEditor->setReadOnly ( journal->isReadOnly() ); int id = mJournal->calID(); QString calname = KOPrefs::instance()->getCalendar( id )->mName; mTitleLabel->setText( " (" + calname +")"); } Journal *JournalEntry::journal() const { return mJournal; } void JournalEntry::clear() { mJournal = 0; mEditor->setText(""); mTitle->setText(""); } bool JournalEntry::eventFilter( QObject *o, QEvent *e ) { // kdDebug() << "JournalEntry::event received " << e->type() << endl; if ( e->type() == QEvent::FocusOut ) { writeJournal(); } if ( e->type() == QEvent::KeyPress ) { QKeyEvent * k = (QKeyEvent *) e; if ( k->state() == Qt::ControlButton ) { k->ignore(); //return true; } } |