summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-30 04:35:32 (UTC)
committer zautrix <zautrix>2005-06-30 04:35:32 (UTC)
commit63147898391dbeabca2dc8f48730b324c15a7498 (patch) (unidiff)
tree6f42b6fc1d95ee584d44deb50726e94c02f986e5
parent54dd512d3980381c2b02263462db03ae7c5a0264 (diff)
downloadkdepimpi-63147898391dbeabca2dc8f48730b324c15a7498.zip
kdepimpi-63147898391dbeabca2dc8f48730b324c15a7498.tar.gz
kdepimpi-63147898391dbeabca2dc8f48730b324c15a7498.tar.bz2
fixxi
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp7
-rw-r--r--korganizer/kojournalview.cpp2
2 files changed, 4 insertions, 5 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 232ea58..58863fe 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -1,285 +1,284 @@
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// Journal Entry 25// Journal Entry
26 26
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qvbox.h> 29#include <qvbox.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qtextcodec.h> 33#include <qtextcodec.h>
34#include <qpixmap.h> 34#include <qpixmap.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qapplication.h> 36#include <qapplication.h>
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <kglobal.h> 39#include <kglobal.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <ktextedit.h> 41#include <ktextedit.h>
42#include <kfiledialog.h> 42#include <kfiledialog.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44#include "koprefs.h" 44#include "koprefs.h"
45#include <klineedit.h> 45#include <klineedit.h>
46 46
47#include <libkcal/journal.h> 47#include <libkcal/journal.h>
48#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
49#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
50#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
51 51
52#include "journalentry.h" 52#include "journalentry.h"
53//#include "journalentry.moc" 53//#include "journalentry.moc"
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#endif 56#endif
57JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : 57JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
58 QFrame(parent) 58 QFrame(parent)
59{ 59{
60 heiHint = QApplication::desktop()->height() / 5 ; 60 heiHint = QApplication::desktop()->height() / 5 ;
61 showOnlyMode = false; 61 showOnlyMode = false;
62 mCalendar = calendar; 62 mCalendar = calendar;
63 mJournal = 0; 63 mJournal = 0;
64 mDirty = false; 64 mDirty = false;
65 65
66 QHBox * vb = new QHBox ( this ); 66 QHBox * vb = new QHBox ( this );
67 QIconSet icon; 67 QIconSet icon;
68 68
69 QPushButton * toggleJournal = new QPushButton( vb ); 69 QPushButton * toggleJournal = new QPushButton( vb );
70 icon = SmallIcon("1updownarrow"); 70 icon = SmallIcon("1updownarrow");
71 toggleJournal->setIconSet (icon ) ; 71 toggleJournal->setIconSet (icon ) ;
72 int size = toggleJournal->sizeHint().height();
73 toggleJournal->setFixedSize( size * 2 /3 , size );
74 new QLabel(i18n(" Title: "),vb); 72 new QLabel(i18n(" Title: "),vb);
75 mTitle = new KLineEdit ( vb ); 73 mTitle = new KLineEdit ( vb );
76 mTitleLabel = new QLabel(i18n("Title"),vb); 74 mTitleLabel = new QLabel(i18n("Title"),vb);
77 mTitleLabel->setMargin(0); 75 mTitleLabel->setMargin(0);
78 mTitleLabel->setAlignment(AlignCenter); 76 mTitleLabel->setAlignment(AlignCenter);
79 QPushButton * loadTemplate = new QPushButton( vb ); 77 QPushButton * loadTemplate = new QPushButton( vb );
80 QPushButton * saveTemplate = new QPushButton( vb ); 78 QPushButton * saveTemplate = new QPushButton( vb );
81 if ( QApplication::desktop()->width() < 321 ) 79 if ( QApplication::desktop()->width() < 321 )
82 icon = SmallIcon("fileexport16"); 80 icon = SmallIcon("fileexport16");
83 else 81 else
84 icon = SmallIcon("fileexport"); 82 icon = SmallIcon("fileexport");
85 saveTemplate->setIconSet (icon ) ; 83 saveTemplate->setIconSet (icon ) ;
86 //size = saveTemplate->sizeHint().height(); 84 int size = saveTemplate->sizeHint().height();
87 saveTemplate->setFixedSize( size, size );
88 if ( QApplication::desktop()->width() < 321 ) 85 if ( QApplication::desktop()->width() < 321 )
89 icon = SmallIcon("fileimport16"); 86 icon = SmallIcon("fileimport16");
90 else 87 else
91 icon = SmallIcon("fileimport"); 88 icon = SmallIcon("fileimport");
92 loadTemplate->setIconSet (icon ) ; 89 loadTemplate->setIconSet (icon ) ;
93 loadTemplate->setFixedSize( size, size ); 90 loadTemplate->setFixedSize( size, size );
91 saveTemplate->setFixedSize( size, size );
92 toggleJournal->setFixedSize( size , size );
94 mEditor = new KTextEdit(this); 93 mEditor = new KTextEdit(this);
95 connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); 94 connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty()));
96#ifndef DESKTOP_VERSION 95#ifndef DESKTOP_VERSION
97 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); 96 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
98#endif 97#endif
99 mEditor->setWordWrap( KTextEdit::WidgetWidth ); 98 mEditor->setWordWrap( KTextEdit::WidgetWidth );
100 QBoxLayout *topLayout = new QVBoxLayout(this); 99 QBoxLayout *topLayout = new QVBoxLayout(this);
101 topLayout->addWidget(vb); 100 topLayout->addWidget(vb);
102 topLayout->addWidget(mEditor); 101 topLayout->addWidget(mEditor);
103 mEditor->installEventFilter(this); 102 mEditor->installEventFilter(this);
104 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 103 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
105 connect( mTitle, SIGNAL( textChanged ( const QString & ) ), this , SLOT( setDirty() ) ); 104 connect( mTitle, SIGNAL( textChanged ( const QString & ) ), this , SLOT( setDirty() ) );
106 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 105 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
107 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); 106 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
108} 107}
109 108
110JournalEntry::~JournalEntry() 109JournalEntry::~JournalEntry()
111{ 110{
112 //qDebug("JournalEntry::~JournalEntry() "); 111 //qDebug("JournalEntry::~JournalEntry() ");
113} 112}
114QSize JournalEntry::sizeHint() const 113QSize JournalEntry::sizeHint() const
115{ 114{
116 return QSize ( 240, heiHint ); 115 return QSize ( 240, heiHint );
117} 116}
118void JournalEntry::slotSaveTemplate() 117void JournalEntry::slotSaveTemplate()
119{ 118{
120 QString fileName =locateLocal( "templates", "journals" ); 119 QString fileName =locateLocal( "templates", "journals" );
121 QDir t_dir; 120 QDir t_dir;
122 if ( !t_dir.exists(fileName) ) 121 if ( !t_dir.exists(fileName) )
123 t_dir.mkdir ( fileName ); 122 t_dir.mkdir ( fileName );
124 fileName += "/journal"; 123 fileName += "/journal";
125 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); 124 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this );
126 if ( fileName.length() == 0 ) 125 if ( fileName.length() == 0 )
127 return; 126 return;
128 127
129 QFile fileIn( fileName ); 128 QFile fileIn( fileName );
130 if (!fileIn.open( IO_WriteOnly ) ) { 129 if (!fileIn.open( IO_WriteOnly ) ) {
131 KMessageBox::error( this, i18n("Error saving template file\n '%1'.") 130 KMessageBox::error( this, i18n("Error saving template file\n '%1'.")
132 .arg( fileName ) ); 131 .arg( fileName ) );
133 return; 132 return;
134 } 133 }
135 // QString text; 134 // QString text;
136 QTextStream tsIn( &fileIn ); 135 QTextStream tsIn( &fileIn );
137 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 136 tsIn.setCodec( QTextCodec::codecForName("utf8") );
138 tsIn << mEditor->text(); 137 tsIn << mEditor->text();
139 fileIn.close(); 138 fileIn.close();
140} 139}
141void JournalEntry::slotLoadTemplate() 140void JournalEntry::slotLoadTemplate()
142{ 141{
143 QString fileName =locateLocal( "templates", "journals" ); 142 QString fileName =locateLocal( "templates", "journals" );
144 QDir t_dir; 143 QDir t_dir;
145 if ( !t_dir.exists(fileName) ) 144 if ( !t_dir.exists(fileName) )
146 t_dir.mkdir ( fileName ); 145 t_dir.mkdir ( fileName );
147 fileName += "/journal"; 146 fileName += "/journal";
148 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); 147 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this );
149 if ( fileName.length() == 0 ) 148 if ( fileName.length() == 0 )
150 return; 149 return;
151 QFile fileIn( fileName ); 150 QFile fileIn( fileName );
152 if (!fileIn.open( IO_ReadOnly ) ) { 151 if (!fileIn.open( IO_ReadOnly ) ) {
153 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 152 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
154 .arg( fileName ) ); 153 .arg( fileName ) );
155 return; 154 return;
156 } 155 }
157 QTextStream tsIn( &fileIn ); 156 QTextStream tsIn( &fileIn );
158 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 157 tsIn.setCodec( QTextCodec::codecForName("utf8") );
159 QString text = tsIn.read(); 158 QString text = tsIn.read();
160 fileIn.close(); 159 fileIn.close();
161 int line, col; 160 int line, col;
162 mEditor->getCursorPosition (& line, & col ); 161 mEditor->getCursorPosition (& line, & col );
163 mEditor-> insertAt ( text, line, col, true ); 162 mEditor-> insertAt ( text, line, col, true );
164 //mEditor->setIgnoreMark( true ); 163 //mEditor->setIgnoreMark( true );
165 setDirty(); 164 setDirty();
166} 165}
167void JournalEntry::setDate(const QDate &date) 166void JournalEntry::setDate(const QDate &date)
168{ 167{
169 showOnlyMode = false; 168 showOnlyMode = false;
170 mDate = date; 169 mDate = date;
171 writeJournal(); 170 writeJournal();
172 int id = mCalendar->defaultCalendar(); 171 int id = mCalendar->defaultCalendar();
173 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 172 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
174 mTitleLabel->setText( " (" + calname +")"); 173 mTitleLabel->setText( " (" + calname +")");
175} 174}
176 175
177void JournalEntry::toggleShowJournal() 176void JournalEntry::toggleShowJournal()
178{ 177{
179 flushEntry(); 178 flushEntry();
180 if ( showOnlyMode ) 179 if ( showOnlyMode )
181 emit showJournalOnly( 0 ); 180 emit showJournalOnly( 0 );
182 else 181 else
183 emit showJournalOnly( mJournal ); 182 emit showJournalOnly( mJournal );
184} 183}
185void JournalEntry::setShowOnly() 184void JournalEntry::setShowOnly()
186{ 185{
187 showOnlyMode = true; 186 showOnlyMode = true;
188 mEditor->setFocus(); 187 mEditor->setFocus();
189} 188}
190void JournalEntry::setJournal(Journal *journal) 189void JournalEntry::setJournal(Journal *journal)
191{ 190{
192 writeJournal(); 191 writeJournal();
193 192
194 mJournal = journal; 193 mJournal = journal;
195 if ( journal->isReadOnly() ) 194 if ( journal->isReadOnly() )
196 mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")"); 195 mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")");
197 else 196 else
198 mTitle->setText(mJournal->summary()); 197 mTitle->setText(mJournal->summary());
199 mEditor->setText(mJournal->description()); 198 mEditor->setText(mJournal->description());
200 mTitle->setReadOnly (journal->isReadOnly() ); 199 mTitle->setReadOnly (journal->isReadOnly() );
201 mEditor->setReadOnly ( journal->isReadOnly() ); 200 mEditor->setReadOnly ( journal->isReadOnly() );
202 int id = mJournal->calID(); 201 int id = mJournal->calID();
203 202
204 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 203 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
205 mTitleLabel->setText( " (" + calname +")"); 204 mTitleLabel->setText( " (" + calname +")");
206 205
207 mDirty = false; 206 mDirty = false;
208} 207}
209 208
210Journal *JournalEntry::journal() const 209Journal *JournalEntry::journal() const
211{ 210{
212 return mJournal; 211 return mJournal;
213} 212}
214 213
215void JournalEntry::setDirty() 214void JournalEntry::setDirty()
216{ 215{
217 mDirty = true; 216 mDirty = true;
218 217
219// kdDebug() << "JournalEntry::setDirty()" << endl; 218// kdDebug() << "JournalEntry::setDirty()" << endl;
220} 219}
221 220
222void JournalEntry::clear() 221void JournalEntry::clear()
223{ 222{
224 mJournal = 0; 223 mJournal = 0;
225 mEditor->setText(""); 224 mEditor->setText("");
226} 225}
227 226
228bool JournalEntry::eventFilter( QObject *o, QEvent *e ) 227bool JournalEntry::eventFilter( QObject *o, QEvent *e )
229{ 228{
230// kdDebug() << "JournalEntry::event received " << e->type() << endl; 229// kdDebug() << "JournalEntry::event received " << e->type() << endl;
231 230
232 if ( e->type() == QEvent::FocusOut ) { 231 if ( e->type() == QEvent::FocusOut ) {
233 writeJournal(); 232 writeJournal();
234 } 233 }
235 if ( e->type() == QEvent::KeyPress ) { 234 if ( e->type() == QEvent::KeyPress ) {
236 QKeyEvent * k = (QKeyEvent *) e; 235 QKeyEvent * k = (QKeyEvent *) e;
237 if ( k->state() == Qt::ControlButton ) { 236 if ( k->state() == Qt::ControlButton ) {
238 k->ignore(); 237 k->ignore();
239 //return true; 238 //return true;
240 } 239 }
241 } 240 }
242 241
243 return QFrame::eventFilter( o, e ); // standard event processing 242 return QFrame::eventFilter( o, e ); // standard event processing
244} 243}
245 244
246void JournalEntry::writeJournal() 245void JournalEntry::writeJournal()
247{ 246{
248// kdDebug() << "JournalEntry::writeJournal()" << endl; 247// kdDebug() << "JournalEntry::writeJournal()" << endl;
249 if (!mDirty) return; 248 if (!mDirty) return;
250 249
251 if (mEditor->text().isEmpty()) { 250 if (mEditor->text().isEmpty()) {
252 if ( mJournal ) { 251 if ( mJournal ) {
253 mDirty = false; 252 mDirty = false;
254 bool conf = KOPrefs::instance()->mConfirm; 253 bool conf = KOPrefs::instance()->mConfirm;
255 KOPrefs::instance()->mConfirm = false; 254 KOPrefs::instance()->mConfirm = false;
256 emit deleteJournal(mJournal); 255 emit deleteJournal(mJournal);
257 KOPrefs::instance()->mConfirm = conf; 256 KOPrefs::instance()->mConfirm = conf;
258 mJournal = 0; 257 mJournal = 0;
259 } 258 }
260 return; 259 return;
261 } 260 }
262 261
263// kdDebug() << "JournalEntry::writeJournal()..." << endl; 262// kdDebug() << "JournalEntry::writeJournal()..." << endl;
264 263
265 if (!mJournal) { 264 if (!mJournal) {
266 mJournal = new Journal; 265 mJournal = new Journal;
267 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 266 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
268 mCalendar->addJournal(mJournal); 267 mCalendar->addJournal(mJournal);
269 } 268 }
270 269
271 mJournal->setDescription(mEditor->text()); 270 mJournal->setDescription(mEditor->text());
272 mJournal->setSummary(mTitle->text()); 271 mJournal->setSummary(mTitle->text());
273 mDirty = false; 272 mDirty = false;
274} 273}
275 274
276void JournalEntry::flushEntry() 275void JournalEntry::flushEntry()
277{ 276{
278 if (!mDirty) return; 277 if (!mDirty) return;
279 278
280 writeJournal(); 279 writeJournal();
281} 280}
282void JournalEntry::keyPressEvent ( QKeyEvent * e ) 281void JournalEntry::keyPressEvent ( QKeyEvent * e )
283{ 282{
284 e->ignore(); 283 e->ignore();
285 284
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index 4fc9013..ff87ef4 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -1,217 +1,217 @@
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 QIconSet 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->setIconSet (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(2); 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 Journal* mJournal = new Journal; 141 Journal* mJournal = new Journal;
142 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 142 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
143 mCalendar->addJournal(mJournal); 143 mCalendar->addJournal(mJournal);
144 showDates( mDate, QDate() ); 144 showDates( mDate, QDate() );
145} 145}
146 146
147void KOJournalView::showOnly ( Journal* j ) 147void KOJournalView::showOnly ( Journal* j )
148{ 148{
149 if ( j == 0 ) { 149 if ( j == 0 ) {
150 showDates( mDate, QDate() ); 150 showDates( mDate, QDate() );
151 return; 151 return;
152 } 152 }
153 QPtrList<Journal> jl; 153 QPtrList<Journal> jl;
154 jl.append ( j ); 154 jl.append ( j );
155 showList( jl ); 155 showList( jl );
156 JournalEntry* mEntry = jEntries.first(); 156 JournalEntry* mEntry = jEntries.first();
157 mEntry->setShowOnly(); 157 mEntry->setShowOnly();
158} 158}
159void KOJournalView::showList(QPtrList<Journal> jl) 159void KOJournalView::showList(QPtrList<Journal> jl)
160{ 160{
161 JournalEntry* mEntry = jEntries.first(); 161 JournalEntry* mEntry = jEntries.first();
162 JournalEntry* firstEntry = mEntry; 162 JournalEntry* firstEntry = mEntry;
163 int count = jl.count(); 163 int count = jl.count();
164 int iii = 0; 164 int iii = 0;
165 while ( iii < count ) { 165 while ( iii < count ) {
166 if ( !mEntry ) { 166 if ( !mEntry ) {
167 mEntry = getNewEntry(); 167 mEntry = getNewEntry();
168 mEntry->show(); 168 mEntry->show();
169 mEntry->setDate(mDate); 169 mEntry->setDate(mDate);
170 mEntry->setJournal(jl.at(iii)); 170 mEntry->setJournal(jl.at(iii));
171 mEntry = 0; 171 mEntry = 0;
172 } else { 172 } else {
173 mEntry->setDate(mDate); 173 mEntry->setDate(mDate);
174 mEntry->setJournal(jl.at(iii)); 174 mEntry->setJournal(jl.at(iii));
175 mEntry->show(); 175 mEntry->show();
176 mEntry = jEntries.next(); 176 mEntry = jEntries.next();
177 } 177 }
178 ++iii; 178 ++iii;
179 } 179 }
180 while ( mEntry ) { 180 while ( mEntry ) {
181 mEntry->setDate(mDate); 181 mEntry->setDate(mDate);
182 mEntry->clear(); 182 mEntry->clear();
183 if ( mEntry != firstEntry ) 183 if ( mEntry != firstEntry )
184 mEntry->hide(); 184 mEntry->hide();
185 else 185 else
186 mEntry->show(); 186 mEntry->show();
187 mEntry = jEntries.next(); 187 mEntry = jEntries.next();
188 } 188 }
189} 189}
190 190
191void KOJournalView::showDates(const QDate &start, const QDate &) 191void KOJournalView::showDates(const QDate &start, const QDate &)
192{ 192{
193 mDate = start; 193 mDate = start;
194 mDateLabel-> setText(KGlobal::locale()->formatDate(mDate)); 194 mDateLabel-> setText(KGlobal::locale()->formatDate(mDate));
195 QPtrList<Journal> jl = calendar()->journals4Date( start ); 195 QPtrList<Journal> jl = calendar()->journals4Date( start );
196 showList( jl ); 196 showList( jl );
197} 197}
198 198
199void KOJournalView::showEvents(QPtrList<Event>) 199void KOJournalView::showEvents(QPtrList<Event>)
200{ 200{
201 // After new creation of list view no events are selected. 201 // After new creation of list view no events are selected.
202// emit incidenceSelected( 0 ); 202// emit incidenceSelected( 0 );
203} 203}
204 204
205void KOJournalView::changeEventDisplay(Event *, int /*action*/) 205void KOJournalView::changeEventDisplay(Event *, int /*action*/)
206{ 206{
207 updateView(); 207 updateView();
208} 208}
209 209
210void KOJournalView::keyPressEvent ( QKeyEvent * e ) 210void KOJournalView::keyPressEvent ( QKeyEvent * e )
211{ 211{
212 //qDebug("keyPressEven "); 212 //qDebug("keyPressEven ");
213 if ( e->state() == Qt::ControlButton ) { 213 if ( e->state() == Qt::ControlButton ) {
214 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) 214 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left )
215 e->ignore(); 215 e->ignore();
216 } 216 }
217} 217}