-rw-r--r-- | korganizer/journalentry.cpp | 11 | ||||
-rw-r--r-- | korganizer/journalentry.h | 1 | ||||
-rw-r--r-- | korganizer/kojournalview.cpp | 10 |
3 files changed, 15 insertions, 7 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() 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; + if ( mTitle->text().isEmpty() ) + mTitle->setFocus(); + else mEditor->setFocus(); - visibleMode = true; } 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(""); } 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 @@ #include <qframe.h> #include <libkcal/calendar.h> class QLabel; class KTextEdit; class KLineEdit; using namespace KCal; class JournalEntry : public QFrame { Q_OBJECT public: JournalEntry(Calendar *,QWidget *parent); virtual ~JournalEntry(); void setJournal(Journal *); Journal *journal() const; void setDate(const QDate &); void clear(); void flushEntry(); void setShowOnly(); QSize sizeHint() const; void setVisibleMode( bool b ) { visibleMode = b;} protected slots: void slotSaveTemplate(); void slotLoadTemplate(); void toggleShowJournal(); + void setVisibleOn(); signals: void deleteJournal(Journal *); void newJournal(); void showJournalOnly( Journal * ); protected: bool eventFilter( QObject *o, QEvent *e ); void writeJournal(); private: bool visibleMode; bool showOnlyMode; Calendar *mCalendar; Journal *mJournal; QDate mDate; void keyPressEvent ( QKeyEvent * ) ; QLabel *mTitleLabel; KLineEdit * mTitle; KTextEdit *mEditor; int heiHint; }; #endif diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index 7a96aa5..6fa9b23 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -126,96 +126,96 @@ void KOJournalView::flushView() { static bool ff = false; if ( ff ) return; ff = true; JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->flushEntry(); mEntry = jEntries.next(); } ff = false; } void KOJournalView::clearList() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->clear(); mEntry = jEntries.next(); } } void KOJournalView::newJournal() { //qDebug(" KOJournalView::newJournal()"); flushView(); Journal* mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); mCalendar->addJournal(mJournal); showDates( mDate, QDate() ); } void KOJournalView::showOnly ( Journal* j ) { - //qDebug("showOnly %x ", j); + qDebug("showOnly %x ", j); flushView(); if ( j == 0 ) { showDates( mDate, QDate() ); return; } QPtrList<Journal> jl; jl.append ( j ); showList( jl ); JournalEntry* mEntry = jEntries.first(); mEntry->setShowOnly(); } void KOJournalView::showList(QPtrList<Journal> jl) { - //qDebug("KOJournalView::showList %d",jl.count() ); + qDebug("KOJournalView::showList %d",jl.count() ); JournalEntry* mEntry = jEntries.first(); JournalEntry* firstEntry = mEntry; int count = jl.count(); int iii = 0; while ( iii < count ) { if ( !mEntry ) { mEntry = getNewEntry(); - mEntry->show(); - mEntry->setVisibleMode( true ); mEntry->setDate(mDate); mEntry->setJournal(jl.at(iii)); + mEntry->setVisibleMode( true ); + mEntry->show(); mEntry = 0; } else { mEntry->setDate(mDate); mEntry->setJournal(jl.at(iii)); - mEntry->show(); mEntry->setVisibleMode( true ); + mEntry->show(); mEntry = jEntries.next(); } ++iii; } while ( mEntry ) { mEntry->setDate(mDate); mEntry->clear(); if ( mEntry != firstEntry ) { mEntry->hide(); mEntry->setVisibleMode( false ); } else { mEntry->setVisibleMode( true ); mEntry->show(); } mEntry = jEntries.next(); } } void KOJournalView::showDates(const QDate &start, const QDate &) { mDate = start; mDateLabel-> setText(KGlobal::locale()->formatDate(mDate)); QPtrList<Journal> jl = calendar()->journals4Date( start ); showList( jl ); } void KOJournalView::showEvents(QPtrList<Event>) { // After new creation of list view no events are selected. // emit incidenceSelected( 0 ); } |