/* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ // // View of Journal entries #include #include #include #include #include "koprefs.h" #include #include "journalentry.h" #include "kojournalview.h" using namespace KOrg; KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, const char *name) : KOrg::BaseView(calendar, parent, name) { mCalendar = calendar; mTopLayout = new QVBoxLayout(this); getNewEntry(); } KOJournalView::~KOJournalView() { } 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() { QPtrList eventList; return eventList; } void KOJournalView::updateConfig() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); mEntry = jEntries.next(); } } void KOJournalView::updateView() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); mEntry = jEntries.next(); } showDates( mDate, QDate() ); } void KOJournalView::flushView() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->flushEntry(); mEntry = jEntries.next(); } } void KOJournalView::clearList() { JournalEntry* mEntry = jEntries.first(); while ( mEntry ) { mEntry->clear(); mEntry = jEntries.next(); } } void KOJournalView::newJournal() { Journal* mJournal = new Journal; mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); mCalendar->addJournal(mJournal); showDates( mDate, QDate() ); } 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(); } } void KOJournalView::showDates(const QDate &start, const QDate &) { mDate = start; QPtrList jl = calendar()->journals4Date( start ); showList( jl ); } void KOJournalView::showEvents(QPtrList) { // After new creation of list view no events are selected. // emit incidenceSelected( 0 ); } void KOJournalView::changeEventDisplay(Event *, int /*action*/) { updateView(); } void KOJournalView::keyPressEvent ( QKeyEvent * e ) { //qDebug("keyPressEven "); if ( e->state() == Qt::ControlButton ) { if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) e->ignore(); } }