summaryrefslogtreecommitdiffabout
path: root/korganizer/kojournalview.cpp
Unidiff
Diffstat (limited to 'korganizer/kojournalview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kojournalview.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index ff87ef4..cb9a2c0 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -1,217 +1,219 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24// 24//
25// View of Journal entries 25// View of Journal entries
26 26
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qscrollview.h> 28#include <qscrollview.h>
29#include <qpopupmenu.h> 29#include <qpopupmenu.h>
30#include <qhbox.h> 30#include <qhbox.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qpushbutton.h> 33#include <qpushbutton.h>
34#include <qapplication.h> 34#include <qapplication.h>
35 35
36#include <klocale.h> 36#include <klocale.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include "koprefs.h" 38#include "koprefs.h"
39#include <kglobal.h> 39#include <kglobal.h>
40 40
41#include <libkcal/calendar.h> 41#include <libkcal/calendar.h>
42 42
43#include "journalentry.h" 43#include "journalentry.h"
44 44
45#include "kojournalview.h" 45#include "kojournalview.h"
46using namespace KOrg; 46using namespace KOrg;
47 47
48KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, 48KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
49 const char *name) 49 const char *name)
50 : KOrg::BaseView(calendar, parent, name) 50 : KOrg::BaseView(calendar, parent, name)
51{ 51{
52 mCalendar = calendar; 52 mCalendar = calendar;
53 QScrollView * sv = new QScrollView( this ); 53 QScrollView * sv = new QScrollView( this );
54 QHBoxLayout * hbl = new QHBoxLayout( this ); 54 QHBoxLayout * hbl = new QHBoxLayout( this );
55 hbl->addWidget( sv ); 55 hbl->addWidget( sv );
56 parWid = new QWidget( sv->viewport() ); 56 parWid = new QWidget( sv->viewport() );
57 sv->addChild(parWid); 57 sv->addChild(parWid);
58 sv->setResizePolicy( QScrollView:: AutoOneFit ); 58 sv->setResizePolicy( QScrollView:: AutoOneFit );
59 mTopLayout = new QVBoxLayout(parWid); 59 mTopLayout = new QVBoxLayout(parWid);
60 QHBox * vb = new QHBox ( parWid ); 60 QHBox * vb = new QHBox ( parWid );
61 QPushButton * newJournal = new QPushButton( vb ); 61 QPushButton * newJournal = new QPushButton( vb );
62 QIconSet icon; 62 QPixmap icon;
63 if ( QApplication::desktop()->width() < 321 ) 63 if ( QApplication::desktop()->width() < 321 )
64 icon = SmallIcon("ko16old"); 64 icon = SmallIcon("ko16old");
65 else 65 else
66 icon = SmallIcon("ko24old"); 66 icon = SmallIcon("ko24old");
67 newJournal->setIconSet (icon ) ; 67 newJournal->setPixmap (icon ) ;
68 int size = newJournal->sizeHint().height(); 68 int size = newJournal->sizeHint().height();
69 newJournal->setFixedSize( size, size ); 69 newJournal->setFixedSize( size, size );
70 mDateLabel = new QLabel ( vb ); 70 mDateLabel = new QLabel ( vb );
71 mTopLayout->addWidget( vb ); 71 mTopLayout->addWidget( vb );
72 mDateLabel->setMargin(1); 72 mDateLabel->setMargin(1);
73 mDateLabel->setAlignment(AlignCenter); 73 mDateLabel->setAlignment(AlignCenter);
74 connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) ); 74 connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) );
75 getNewEntry(); 75 getNewEntry();
76} 76}
77 77
78KOJournalView::~KOJournalView() 78KOJournalView::~KOJournalView()
79{ 79{
80} 80}
81 81
82int KOJournalView::currentDateCount() 82int KOJournalView::currentDateCount()
83{ 83{
84 return 0; 84 return 0;
85} 85}
86JournalEntry* KOJournalView::getNewEntry() 86JournalEntry* KOJournalView::getNewEntry()
87{ 87{
88 JournalEntry* Entry = new JournalEntry(mCalendar,parWid); 88 JournalEntry* Entry = new JournalEntry(mCalendar,parWid);
89 jEntries.append( Entry ); 89 jEntries.append( Entry );
90 mTopLayout->addWidget(Entry); 90 mTopLayout->addWidget(Entry);
91 Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); 91 Entry->setFont ( KOPrefs::instance()->mJornalViewFont );
92 connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; 92 connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
93 connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; 93 connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ;
94 connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; 94 connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ;
95 return Entry; 95 return Entry;
96} 96}
97 97
98QPtrList<Incidence> KOJournalView::selectedIncidences() 98QPtrList<Incidence> KOJournalView::selectedIncidences()
99{ 99{
100 QPtrList<Incidence> eventList; 100 QPtrList<Incidence> eventList;
101 101
102 return eventList; 102 return eventList;
103} 103}
104void KOJournalView::updateConfig() 104void KOJournalView::updateConfig()
105{ 105{
106 JournalEntry* mEntry = jEntries.first(); 106 JournalEntry* mEntry = jEntries.first();
107 while ( mEntry ) { 107 while ( mEntry ) {
108 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 108 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
109 mEntry = jEntries.next(); 109 mEntry = jEntries.next();
110 } 110 }
111} 111}
112void KOJournalView::updateView() 112void KOJournalView::updateView()
113{ 113{
114 JournalEntry* mEntry = jEntries.first(); 114 JournalEntry* mEntry = jEntries.first();
115 while ( mEntry ) { 115 while ( mEntry ) {
116 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 116 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
117 mEntry = jEntries.next(); 117 mEntry = jEntries.next();
118 } 118 }
119 showDates( mDate, QDate() ); 119 showDates( mDate, QDate() );
120} 120}
121 121
122void KOJournalView::flushView() 122void KOJournalView::flushView()
123{ 123{
124 JournalEntry* mEntry = jEntries.first(); 124 JournalEntry* mEntry = jEntries.first();
125 while ( mEntry ) { 125 while ( mEntry ) {
126 mEntry->flushEntry(); 126 mEntry->flushEntry();
127 mEntry = jEntries.next(); 127 mEntry = jEntries.next();
128 } 128 }
129} 129}
130 130
131void KOJournalView::clearList() 131void KOJournalView::clearList()
132{ 132{
133 JournalEntry* mEntry = jEntries.first(); 133 JournalEntry* mEntry = jEntries.first();
134 while ( mEntry ) { 134 while ( mEntry ) {
135 mEntry->clear(); 135 mEntry->clear();
136 mEntry = jEntries.next(); 136 mEntry = jEntries.next();
137 } 137 }
138} 138}
139void KOJournalView::newJournal() 139void KOJournalView::newJournal()
140{ 140{
141 flushView();
141 Journal* mJournal = new Journal; 142 Journal* mJournal = new Journal;
142 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 143 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
143 mCalendar->addJournal(mJournal); 144 mCalendar->addJournal(mJournal);
144 showDates( mDate, QDate() ); 145 showDates( mDate, QDate() );
145} 146}
146 147
147void KOJournalView::showOnly ( Journal* j ) 148void KOJournalView::showOnly ( Journal* j )
148{ 149{
150 flushView();
149 if ( j == 0 ) { 151 if ( j == 0 ) {
150 showDates( mDate, QDate() ); 152 showDates( mDate, QDate() );
151 return; 153 return;
152 } 154 }
153 QPtrList<Journal> jl; 155 QPtrList<Journal> jl;
154 jl.append ( j ); 156 jl.append ( j );
155 showList( jl ); 157 showList( jl );
156 JournalEntry* mEntry = jEntries.first(); 158 JournalEntry* mEntry = jEntries.first();
157 mEntry->setShowOnly(); 159 mEntry->setShowOnly();
158} 160}
159void KOJournalView::showList(QPtrList<Journal> jl) 161void KOJournalView::showList(QPtrList<Journal> jl)
160{ 162{
161 JournalEntry* mEntry = jEntries.first(); 163 JournalEntry* mEntry = jEntries.first();
162 JournalEntry* firstEntry = mEntry; 164 JournalEntry* firstEntry = mEntry;
163 int count = jl.count(); 165 int count = jl.count();
164 int iii = 0; 166 int iii = 0;
165 while ( iii < count ) { 167 while ( iii < count ) {
166 if ( !mEntry ) { 168 if ( !mEntry ) {
167 mEntry = getNewEntry(); 169 mEntry = getNewEntry();
168 mEntry->show(); 170 mEntry->show();
169 mEntry->setDate(mDate); 171 mEntry->setDate(mDate);
170 mEntry->setJournal(jl.at(iii)); 172 mEntry->setJournal(jl.at(iii));
171 mEntry = 0; 173 mEntry = 0;
172 } else { 174 } else {
173 mEntry->setDate(mDate); 175 mEntry->setDate(mDate);
174 mEntry->setJournal(jl.at(iii)); 176 mEntry->setJournal(jl.at(iii));
175 mEntry->show(); 177 mEntry->show();
176 mEntry = jEntries.next(); 178 mEntry = jEntries.next();
177 } 179 }
178 ++iii; 180 ++iii;
179 } 181 }
180 while ( mEntry ) { 182 while ( mEntry ) {
181 mEntry->setDate(mDate); 183 mEntry->setDate(mDate);
182 mEntry->clear(); 184 mEntry->clear();
183 if ( mEntry != firstEntry ) 185 if ( mEntry != firstEntry )
184 mEntry->hide(); 186 mEntry->hide();
185 else 187 else
186 mEntry->show(); 188 mEntry->show();
187 mEntry = jEntries.next(); 189 mEntry = jEntries.next();
188 } 190 }
189} 191}
190 192
191void KOJournalView::showDates(const QDate &start, const QDate &) 193void KOJournalView::showDates(const QDate &start, const QDate &)
192{ 194{
193 mDate = start; 195 mDate = start;
194 mDateLabel-> setText(KGlobal::locale()->formatDate(mDate)); 196 mDateLabel-> setText(KGlobal::locale()->formatDate(mDate));
195 QPtrList<Journal> jl = calendar()->journals4Date( start ); 197 QPtrList<Journal> jl = calendar()->journals4Date( start );
196 showList( jl ); 198 showList( jl );
197} 199}
198 200
199void KOJournalView::showEvents(QPtrList<Event>) 201void KOJournalView::showEvents(QPtrList<Event>)
200{ 202{
201 // After new creation of list view no events are selected. 203 // After new creation of list view no events are selected.
202// emit incidenceSelected( 0 ); 204// emit incidenceSelected( 0 );
203} 205}
204 206
205void KOJournalView::changeEventDisplay(Event *, int /*action*/) 207void KOJournalView::changeEventDisplay(Event *, int /*action*/)
206{ 208{
207 updateView(); 209 updateView();
208} 210}
209 211
210void KOJournalView::keyPressEvent ( QKeyEvent * e ) 212void KOJournalView::keyPressEvent ( QKeyEvent * e )
211{ 213{
212 //qDebug("keyPressEven "); 214 //qDebug("keyPressEven ");
213 if ( e->state() == Qt::ControlButton ) { 215 if ( e->state() == Qt::ControlButton ) {
214 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) 216 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left )
215 e->ignore(); 217 e->ignore();
216 } 218 }
217} 219}