From b7044dfc9516d546683973985555c481d59fc677 Mon Sep 17 00:00:00 2001 From: zautrix Date: Wed, 29 Jun 2005 10:36:31 +0000 Subject: journal fixxx --- (limited to 'korganizer/kojournalview.cpp') diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp index bc16037..fae59d6 100644 --- a/korganizer/kojournalview.cpp +++ b/korganizer/kojournalview.cpp @@ -42,11 +42,9 @@ KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, const char *name) : KOrg::BaseView(calendar, parent, name) { - mEntry = new JournalEntry(calendar,this); - mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); - QBoxLayout *topLayout = new QVBoxLayout(this); - topLayout->addWidget(mEntry); - connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; + mCalendar = calendar; + mTopLayout = new QVBoxLayout(this); + getNewEntry(); } KOJournalView::~KOJournalView() @@ -57,6 +55,17 @@ int KOJournalView::currentDateCount() { return 0; } +JournalEntry* KOJournalView::getNewEntry() +{ + JournalEntry* Entry = new JournalEntry(mCalendar,this); + jEntries.append( Entry ); + mTopLayout->addWidget(Entry); + Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); + connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; + connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; + connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; + return Entry; +} QPtrList KOJournalView::selectedIncidences() { @@ -66,33 +75,96 @@ QPtrList KOJournalView::selectedIncidences() } void KOJournalView::updateConfig() { - mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { + mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + mEntry = jEntries.next(); + } } void KOJournalView::updateView() -{ - mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); +{ + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { + mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); + mEntry = jEntries.next(); + } + showDates( mDate, QDate() ); } void KOJournalView::flushView() -{ - mEntry->flushEntry(); +{ + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { + mEntry->flushEntry(); + mEntry = jEntries.next(); + } } void KOJournalView::clearList() { - mEntry->clear(); + JournalEntry* mEntry = jEntries.first(); + while ( mEntry ) { + mEntry->clear(); + mEntry = jEntries.next(); + } } -void KOJournalView::showDates(const QDate &start, const QDate &) +void KOJournalView::newJournal() { -// kdDebug() << "KOJournalView::selectDates()" << endl; + Journal* mJournal = new Journal; + mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); + mCalendar->addJournal(mJournal); + showDates( mDate, QDate() ); +} - mEntry->setDate(start); +void KOJournalView::showOnly ( Journal* j ) +{ + if ( j == 0 ) { + showDates( mDate, QDate() ); + return; + } + QPtrList jl; + jl.append ( j ); + showList( jl ); + JournalEntry* mEntry = jEntries.first(); + mEntry->setShowOnly(); +} +void KOJournalView::showList(QPtrList jl) +{ + JournalEntry* mEntry = jEntries.first(); + JournalEntry* firstEntry = mEntry; + int count = jl.count(); + int iii = 0; + while ( iii < count ) { + if ( !mEntry ) { + mEntry = getNewEntry(); + mEntry->show(); + mEntry->setDate(mDate); + mEntry->setJournal(jl.at(iii)); + mEntry = 0; + } else { + mEntry->setDate(mDate); + mEntry->setJournal(jl.at(iii)); + mEntry->show(); + mEntry = jEntries.next(); + } + ++iii; + } + while ( mEntry ) { + mEntry->setDate(mDate); + mEntry->clear(); + if ( mEntry != firstEntry ) + mEntry->hide(); + else + mEntry->show(); + mEntry = jEntries.next(); + } +} - Journal *j = calendar()->journal(start); - if (j) mEntry->setJournal(j); - else mEntry->clear(); - -// emit incidenceSelected( 0 ); +void KOJournalView::showDates(const QDate &start, const QDate &) +{ + mDate = start; + QPtrList jl = calendar()->journals4Date( start ); + showList( jl ); } void KOJournalView::showEvents(QPtrList) -- cgit v0.9.0.2