summaryrefslogtreecommitdiffabout
path: root/korganizer/kojournalview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kojournalview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kojournalview.cpp110
1 files changed, 91 insertions, 19 deletions
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index bc16037..fae59d6 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -1,116 +1,188 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
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 <qlayout.h>
#include <qpopupmenu.h>
#include <klocale.h>
#include <kdebug.h>
#include "koprefs.h"
#include <libkcal/calendar.h>
#include "journalentry.h"
#include "kojournalview.h"
using namespace KOrg;
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()
{
}
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<Incidence> KOJournalView::selectedIncidences()
{
QPtrList<Incidence> eventList;
return eventList;
}
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<Journal> jl;
+ jl.append ( j );
+ showList( jl );
+ JournalEntry* mEntry = jEntries.first();
+ mEntry->setShowOnly();
+}
+void KOJournalView::showList(QPtrList<Journal> 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<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 );
}
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();
}
}