summaryrefslogtreecommitdiffabout
path: root/korganizer/kojournalview.cpp
Unidiff
Diffstat (limited to 'korganizer/kojournalview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kojournalview.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index 406df5a..51594ff 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -1,250 +1,256 @@
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 <q3scrollview.h>
29#include <qpopupmenu.h> 29#include <q3popupmenu.h>
30#include <qhbox.h> 30#include <q3hbox.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#include <QDesktopWidget>
36//Added by qt3to4:
37#include <QPixmap>
38#include <Q3PtrList>
39#include <QKeyEvent>
40#include <Q3VBoxLayout>
35 41
36#include <klocale.h> 42#include <klocale.h>
37#include <kdebug.h> 43#include <kdebug.h>
38#include "koprefs.h" 44#include "koprefs.h"
39#include <kglobal.h> 45#include <kglobal.h>
40#include <ktextedit.h> 46#include <ktextedit.h>
41 47
42#include <libkcal/calendar.h> 48#include <libkcal/calendar.h>
43 49
44#include "journalentry.h" 50#include "journalentry.h"
45 51
46#include "kojournalview.h" 52#include "kojournalview.h"
47using namespace KOrg; 53using namespace KOrg;
48 54
49KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, 55KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
50 const char *name) 56 const char *name)
51 : KOrg::BaseView(calendar, parent, name) 57 : KOrg::BaseView(calendar, parent, name)
52{ 58{
53 mCalendar = calendar; 59 mCalendar = calendar;
54 QHBox * vb = new QHBox ( this ); 60 Q3HBox * vb = new Q3HBox ( this );
55 QPushButton * newJournal = new QPushButton( vb ); 61 QPushButton * newJournal = new QPushButton( vb );
56 QPixmap icon; 62 QPixmap icon;
57 if ( QApplication::desktop()->width() < 321 ) 63 if ( QApplication::desktop()->width() < 321 )
58 icon = SmallIcon("ko16old"); 64 icon = SmallIcon("ko16old");
59 else 65 else
60 icon = SmallIcon("ko24old"); 66 icon = SmallIcon("ko24old");
61 newJournal->setPixmap (icon ) ; 67 newJournal->setPixmap (icon ) ;
62 int size = newJournal->sizeHint().height(); 68 int size = newJournal->sizeHint().height();
63 newJournal->setFixedSize( size, size ); 69 newJournal->setFixedSize( size, size );
64 mDateLabel = new QLabel ( vb ); 70 mDateLabel = new QLabel ( vb );
65 mDateLabel->setMargin(1); 71 mDateLabel->setMargin(1);
66 mDateLabel->setAlignment(AlignCenter); 72 mDateLabel->setAlignment(Qt::AlignCenter);
67 QScrollView * sv = new QScrollView( this ); 73 Q3ScrollView * sv = new Q3ScrollView( this );
68 QVBoxLayout * hbl = new QVBoxLayout( this ); 74 Q3VBoxLayout * hbl = new Q3VBoxLayout( this );
69 hbl->addWidget( vb ); 75 hbl->addWidget( vb );
70 hbl->addWidget( sv ); 76 hbl->addWidget( sv );
71 parWid = new QWidget( sv->viewport() ); 77 parWid = new QWidget( sv->viewport() );
72 sv->addChild(parWid); 78 sv->addChild(parWid);
73 sv->setResizePolicy( QScrollView:: AutoOneFit ); 79 sv->setResizePolicy( Q3ScrollView:: AutoOneFit );
74 mTopLayout = new QVBoxLayout(parWid); 80 mTopLayout = new Q3VBoxLayout(parWid);
75 connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) ); 81 connect( newJournal, SIGNAL( clicked() ), this , SLOT( newJournal() ) );
76 getNewEntry(); 82 getNewEntry();
77} 83}
78 84
79KOJournalView::~KOJournalView() 85KOJournalView::~KOJournalView()
80{ 86{
81} 87}
82 88
83int KOJournalView::currentDateCount() 89int KOJournalView::currentDateCount()
84{ 90{
85 return 0; 91 return 0;
86} 92}
87JournalEntry* KOJournalView::getNewEntry() 93JournalEntry* KOJournalView::getNewEntry()
88{ 94{
89 JournalEntry* Entry = new JournalEntry(mCalendar,parWid); 95 JournalEntry* Entry = new JournalEntry(mCalendar,parWid);
90 jEntries.append( Entry ); 96 jEntries.append( Entry );
91 mTopLayout->addWidget(Entry); 97 mTopLayout->addWidget(Entry);
92 Entry->setFont ( KOPrefs::instance()->mJornalViewFont ); 98 Entry->setFont ( KOPrefs::instance()->mJornalViewFont );
93 connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; 99 connect ( Entry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
94 connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ; 100 connect ( Entry,SIGNAL(newJournal() ),this ,SLOT(newJournal() ) ) ;
95 connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ; 101 connect ( Entry,SIGNAL(showJournalOnly( Journal * ) ),this ,SLOT(showOnly ( Journal* ) ) ) ;
96 return Entry; 102 return Entry;
97} 103}
98 104
99QPtrList<Incidence> KOJournalView::selectedIncidences() 105Q3PtrList<Incidence> KOJournalView::selectedIncidences()
100{ 106{
101 QPtrList<Incidence> eventList; 107 Q3PtrList<Incidence> eventList;
102 108
103 return eventList; 109 return eventList;
104} 110}
105void KOJournalView::updateConfig() 111void KOJournalView::updateConfig()
106{ 112{
107 JournalEntry* mEntry = jEntries.first(); 113 JournalEntry* mEntry = jEntries.first();
108 while ( mEntry ) { 114 while ( mEntry ) {
109 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 115 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
110 mEntry = jEntries.next(); 116 mEntry = jEntries.next();
111 } 117 }
112} 118}
113void KOJournalView::updateView() 119void KOJournalView::updateView()
114{ 120{
115 JournalEntry* mEntry = jEntries.first(); 121 JournalEntry* mEntry = jEntries.first();
116 while ( mEntry ) { 122 while ( mEntry ) {
117 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 123 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
118 mEntry = jEntries.next(); 124 mEntry = jEntries.next();
119 } 125 }
120 showDates( mDate, QDate() ); 126 showDates( mDate, QDate() );
121} 127}
122void KOJournalView::checkModified() 128void KOJournalView::checkModified()
123{ 129{
124 flushView(); 130 flushView();
125} 131}
126void KOJournalView::flushView() 132void KOJournalView::flushView()
127{ 133{
128 static bool ff = false; 134 static bool ff = false;
129 if ( ff ) return; 135 if ( ff ) return;
130 ff = true; 136 ff = true;
131 JournalEntry* mEntry = jEntries.first(); 137 JournalEntry* mEntry = jEntries.first();
132 while ( mEntry ) { 138 while ( mEntry ) {
133 mEntry->flushEntry(); 139 mEntry->flushEntry();
134 mEntry = jEntries.next(); 140 mEntry = jEntries.next();
135 } 141 }
136 ff = false; 142 ff = false;
137} 143}
138 144
139void KOJournalView::clearList() 145void KOJournalView::clearList()
140{ 146{
141 JournalEntry* mEntry = jEntries.first(); 147 JournalEntry* mEntry = jEntries.first();
142 while ( mEntry ) { 148 while ( mEntry ) {
143 mEntry->clear(); 149 mEntry->clear();
144 mEntry = jEntries.next(); 150 mEntry = jEntries.next();
145 } 151 }
146} 152}
147void KOJournalView::newJournal() 153void KOJournalView::newJournal()
148{ 154{
149 //qDebug(" KOJournalView::newJournal()"); 155 //qDebug(" KOJournalView::newJournal()");
150 flushView(); 156 flushView();
151 Journal* mJournal = new Journal; 157 Journal* mJournal = new Journal;
152 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 158 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
153 mCalendar->addJournal(mJournal); 159 mCalendar->addJournal(mJournal);
154 showDates( mDate, QDate() ); 160 showDates( mDate, QDate() );
155} 161}
156 162
157void KOJournalView::showOnly ( Journal* j ) 163void KOJournalView::showOnly ( Journal* j )
158{ 164{
159 //qDebug("showOnly %x ", j); 165 //qDebug("showOnly %x ", j);
160 flushView(); 166 flushView();
161 if ( j == 0 ) { 167 if ( j == 0 ) {
162 showDates( mDate, QDate() ); 168 showDates( mDate, QDate() );
163 return; 169 return;
164 } 170 }
165 QPtrList<Journal> jl; 171 Q3PtrList<Journal> jl;
166 jl.append ( j ); 172 jl.append ( j );
167 showList( jl ); 173 showList( jl );
168 JournalEntry* mEntry = jEntries.first(); 174 JournalEntry* mEntry = jEntries.first();
169 mEntry->setShowOnly(); 175 mEntry->setShowOnly();
170} 176}
171void KOJournalView::showList(QPtrList<Journal> jl) 177void KOJournalView::showList(Q3PtrList<Journal> jl)
172{ 178{
173 static bool ff = false; 179 static bool ff = false;
174 if ( ff ) return; 180 if ( ff ) return;
175 ff = true; 181 ff = true;
176 //qDebug("KOJournalView::showList %d",jl.count() ); 182 //qDebug("KOJournalView::showList %d",jl.count() );
177 JournalEntry* mEntry = jEntries.first(); 183 JournalEntry* mEntry = jEntries.first();
178 JournalEntry* firstEntry = mEntry; 184 JournalEntry* firstEntry = mEntry;
179 int count = jl.count(); 185 int count = jl.count();
180 int iii = 0; 186 int iii = 0;
181 QWidget* fw = qApp->focusWidget (); 187 QWidget* fw = qApp->focusWidget ();
182 while ( iii < count ) { 188 while ( iii < count ) {
183 if ( !mEntry ) { 189 if ( !mEntry ) {
184 mEntry = getNewEntry(); 190 mEntry = getNewEntry();
185 mEntry->setVisibleMode( true ); 191 mEntry->setVisibleMode( true );
186 mEntry->setDate(mDate); 192 mEntry->setDate(mDate);
187 mEntry->setJournal(jl.at(iii), false); 193 mEntry->setJournal(jl.at(iii), false);
188 mEntry->setVisibleMode( true ); 194 mEntry->setVisibleMode( true );
189 mEntry->show(); 195 mEntry->show();
190 mEntry = 0; 196 mEntry = 0;
191 } else { 197 } else {
192 int xxx = -1, yyy = -1; 198 int xxx = -1, yyy = -1;
193 if ( ((QWidget*) mEntry->editor() ) == fw ) { 199 if ( ((QWidget*) mEntry->editor() ) == fw ) {
194 mEntry->editor()->getCursorPosition( &xxx,&yyy); 200 mEntry->editor()->getCursorPosition( &xxx,&yyy);
195 } 201 }
196 mEntry->setVisibleMode( true ); 202 mEntry->setVisibleMode( true );
197 mEntry->setDate(mDate); 203 mEntry->setDate(mDate);
198 mEntry->setJournal(jl.at(iii), false); 204 mEntry->setJournal(jl.at(iii), false);
199 mEntry->setVisibleMode( true ); 205 mEntry->setVisibleMode( true );
200 mEntry->show(); 206 mEntry->show();
201 if ( xxx > -1 && yyy > -1 ) { 207 if ( xxx > -1 && yyy > -1 ) {
202 mEntry->editor()->setCursorPosition( xxx, yyy ); 208 mEntry->editor()->setCursorPosition( xxx, yyy );
203 } 209 }
204 mEntry = jEntries.next(); 210 mEntry = jEntries.next();
205 } 211 }
206 ++iii; 212 ++iii;
207 } 213 }
208 while ( mEntry ) { 214 while ( mEntry ) {
209 mEntry->setDate(mDate); 215 mEntry->setDate(mDate);
210 mEntry->clear(); 216 mEntry->clear();
211 if ( mEntry != firstEntry ) { 217 if ( mEntry != firstEntry ) {
212 mEntry->hide(); 218 mEntry->hide();
213 mEntry->setVisibleMode( false ); 219 mEntry->setVisibleMode( false );
214 } 220 }
215 else { 221 else {
216 mEntry->setVisibleMode( true ); 222 mEntry->setVisibleMode( true );
217 mEntry->show(); 223 mEntry->show();
218 } 224 }
219 mEntry = jEntries.next(); 225 mEntry = jEntries.next();
220 } 226 }
221 ff = false; 227 ff = false;
222} 228}
223 229
224void KOJournalView::showDates(const QDate &start, const QDate &) 230void KOJournalView::showDates(const QDate &start, const QDate &)
225{ 231{
226 mDate = start; 232 mDate = start;
227 mDateLabel->setText(KGlobal::locale()->formatDate(mDate)); 233 mDateLabel->setText(KGlobal::locale()->formatDate(mDate));
228 QPtrList<Journal> jl = calendar()->journals4Date( start ); 234 Q3PtrList<Journal> jl = calendar()->journals4Date( start );
229 showList( jl ); 235 showList( jl );
230} 236}
231 237
232void KOJournalView::showEvents(QPtrList<Event>) 238void KOJournalView::showEvents(Q3PtrList<Event>)
233{ 239{
234 // After new creation of list view no events are selected. 240 // After new creation of list view no events are selected.
235// emit incidenceSelected( 0 ); 241// emit incidenceSelected( 0 );
236} 242}
237 243
238void KOJournalView::changeEventDisplay(Event *, int /*action*/) 244void KOJournalView::changeEventDisplay(Event *, int /*action*/)
239{ 245{
240 updateView(); 246 updateView();
241} 247}
242 248
243void KOJournalView::keyPressEvent ( QKeyEvent * e ) 249void KOJournalView::keyPressEvent ( QKeyEvent * e )
244{ 250{
245 //qDebug("keyPressEven "); 251 //qDebug("keyPressEven ");
246 if ( e->state() == Qt::ControlButton ) { 252 if ( e->state() == Qt::ControlButton ) {
247 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) 253 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left )
248 e->ignore(); 254 e->ignore();
249 } 255 }
250} 256}