summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-29 12:52:24 (UTC)
committer zautrix <zautrix>2005-06-29 12:52:24 (UTC)
commit4c19dcc4e5b45d9cf04c91af82f00b764b01e985 (patch) (unidiff)
treeb9b6b679c499207c06f74db090ead71bc175866d
parent0d4d5898a32f162dca010db329e02310a14629d5 (diff)
downloadkdepimpi-4c19dcc4e5b45d9cf04c91af82f00b764b01e985.zip
kdepimpi-4c19dcc4e5b45d9cf04c91af82f00b764b01e985.tar.gz
kdepimpi-4c19dcc4e5b45d9cf04c91af82f00b764b01e985.tar.bz2
fixesss
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/journalentry.cpp7
-rw-r--r--korganizer/koeventviewer.cpp12
2 files changed, 15 insertions, 4 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index 05bfd31..232ea58 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -3,279 +3,284 @@
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(); 72 int size = toggleJournal->sizeHint().height();
73 toggleJournal->setFixedSize( size * 2 /3 , size ); 73 toggleJournal->setFixedSize( size * 2 /3 , size );
74 new QLabel(i18n(" Title: "),vb); 74 new QLabel(i18n(" Title: "),vb);
75 mTitle = new KLineEdit ( vb ); 75 mTitle = new KLineEdit ( vb );
76 mTitleLabel = new QLabel(i18n("Title"),vb); 76 mTitleLabel = new QLabel(i18n("Title"),vb);
77 mTitleLabel->setMargin(0); 77 mTitleLabel->setMargin(0);
78 mTitleLabel->setAlignment(AlignCenter); 78 mTitleLabel->setAlignment(AlignCenter);
79 QPushButton * loadTemplate = new QPushButton( vb ); 79 QPushButton * loadTemplate = new QPushButton( vb );
80 QPushButton * saveTemplate = new QPushButton( vb ); 80 QPushButton * saveTemplate = new QPushButton( vb );
81 if ( QApplication::desktop()->width() < 321 ) 81 if ( QApplication::desktop()->width() < 321 )
82 icon = SmallIcon("fileexport16"); 82 icon = SmallIcon("fileexport16");
83 else 83 else
84 icon = SmallIcon("fileexport"); 84 icon = SmallIcon("fileexport");
85 saveTemplate->setIconSet (icon ) ; 85 saveTemplate->setIconSet (icon ) ;
86 //size = saveTemplate->sizeHint().height(); 86 //size = saveTemplate->sizeHint().height();
87 saveTemplate->setFixedSize( size, size ); 87 saveTemplate->setFixedSize( size, size );
88 if ( QApplication::desktop()->width() < 321 ) 88 if ( QApplication::desktop()->width() < 321 )
89 icon = SmallIcon("fileimport16"); 89 icon = SmallIcon("fileimport16");
90 else 90 else
91 icon = SmallIcon("fileimport"); 91 icon = SmallIcon("fileimport");
92 loadTemplate->setIconSet (icon ) ; 92 loadTemplate->setIconSet (icon ) ;
93 loadTemplate->setFixedSize( size, size ); 93 loadTemplate->setFixedSize( size, size );
94 mEditor = new KTextEdit(this); 94 mEditor = new KTextEdit(this);
95 connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); 95 connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty()));
96#ifndef DESKTOP_VERSION 96#ifndef DESKTOP_VERSION
97 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); 97 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
98#endif 98#endif
99 mEditor->setWordWrap( KTextEdit::WidgetWidth ); 99 mEditor->setWordWrap( KTextEdit::WidgetWidth );
100 QBoxLayout *topLayout = new QVBoxLayout(this); 100 QBoxLayout *topLayout = new QVBoxLayout(this);
101 topLayout->addWidget(vb); 101 topLayout->addWidget(vb);
102 topLayout->addWidget(mEditor); 102 topLayout->addWidget(mEditor);
103 mEditor->installEventFilter(this); 103 mEditor->installEventFilter(this);
104 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 104 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
105 connect( mTitle, SIGNAL( textChanged ( const QString & ) ), this , SLOT( setDirty() ) ); 105 connect( mTitle, SIGNAL( textChanged ( const QString & ) ), this , SLOT( setDirty() ) );
106 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 106 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
107 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); 107 connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) );
108} 108}
109 109
110JournalEntry::~JournalEntry() 110JournalEntry::~JournalEntry()
111{ 111{
112 //qDebug("JournalEntry::~JournalEntry() "); 112 //qDebug("JournalEntry::~JournalEntry() ");
113} 113}
114QSize JournalEntry::sizeHint() const 114QSize JournalEntry::sizeHint() const
115{ 115{
116 return QSize ( 240, heiHint ); 116 return QSize ( 240, heiHint );
117} 117}
118void JournalEntry::slotSaveTemplate() 118void JournalEntry::slotSaveTemplate()
119{ 119{
120 QString fileName =locateLocal( "templates", "journals" ); 120 QString fileName =locateLocal( "templates", "journals" );
121 QDir t_dir; 121 QDir t_dir;
122 if ( !t_dir.exists(fileName) ) 122 if ( !t_dir.exists(fileName) )
123 t_dir.mkdir ( fileName ); 123 t_dir.mkdir ( fileName );
124 fileName += "/journal"; 124 fileName += "/journal";
125 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); 125 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this );
126 if ( fileName.length() == 0 ) 126 if ( fileName.length() == 0 )
127 return; 127 return;
128 128
129 QFile fileIn( fileName ); 129 QFile fileIn( fileName );
130 if (!fileIn.open( IO_WriteOnly ) ) { 130 if (!fileIn.open( IO_WriteOnly ) ) {
131 KMessageBox::error( this, i18n("Error saving template file\n '%1'.") 131 KMessageBox::error( this, i18n("Error saving template file\n '%1'.")
132 .arg( fileName ) ); 132 .arg( fileName ) );
133 return; 133 return;
134 } 134 }
135 // QString text; 135 // QString text;
136 QTextStream tsIn( &fileIn ); 136 QTextStream tsIn( &fileIn );
137 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 137 tsIn.setCodec( QTextCodec::codecForName("utf8") );
138 tsIn << mEditor->text(); 138 tsIn << mEditor->text();
139 fileIn.close(); 139 fileIn.close();
140} 140}
141void JournalEntry::slotLoadTemplate() 141void JournalEntry::slotLoadTemplate()
142{ 142{
143 QString fileName =locateLocal( "templates", "journals" ); 143 QString fileName =locateLocal( "templates", "journals" );
144 QDir t_dir; 144 QDir t_dir;
145 if ( !t_dir.exists(fileName) ) 145 if ( !t_dir.exists(fileName) )
146 t_dir.mkdir ( fileName ); 146 t_dir.mkdir ( fileName );
147 fileName += "/journal"; 147 fileName += "/journal";
148 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); 148 fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this );
149 if ( fileName.length() == 0 ) 149 if ( fileName.length() == 0 )
150 return; 150 return;
151 QFile fileIn( fileName ); 151 QFile fileIn( fileName );
152 if (!fileIn.open( IO_ReadOnly ) ) { 152 if (!fileIn.open( IO_ReadOnly ) ) {
153 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 153 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
154 .arg( fileName ) ); 154 .arg( fileName ) );
155 return; 155 return;
156 } 156 }
157 QTextStream tsIn( &fileIn ); 157 QTextStream tsIn( &fileIn );
158 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 158 tsIn.setCodec( QTextCodec::codecForName("utf8") );
159 QString text = tsIn.read(); 159 QString text = tsIn.read();
160 fileIn.close(); 160 fileIn.close();
161 int line, col; 161 int line, col;
162 mEditor->getCursorPosition (& line, & col ); 162 mEditor->getCursorPosition (& line, & col );
163 mEditor-> insertAt ( text, line, col, true ); 163 mEditor-> insertAt ( text, line, col, true );
164 //mEditor->setIgnoreMark( true ); 164 //mEditor->setIgnoreMark( true );
165 setDirty(); 165 setDirty();
166} 166}
167void JournalEntry::setDate(const QDate &date) 167void JournalEntry::setDate(const QDate &date)
168{ 168{
169 showOnlyMode = false; 169 showOnlyMode = false;
170 mDate = date; 170 mDate = date;
171 writeJournal(); 171 writeJournal();
172 int id = mCalendar->defaultCalendar(); 172 int id = mCalendar->defaultCalendar();
173 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 173 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
174 mTitleLabel->setText( " (" + calname +")"); 174 mTitleLabel->setText( " (" + calname +")");
175} 175}
176 176
177void JournalEntry::toggleShowJournal() 177void JournalEntry::toggleShowJournal()
178{ 178{
179 flushEntry(); 179 flushEntry();
180 if ( showOnlyMode ) 180 if ( showOnlyMode )
181 emit showJournalOnly( 0 ); 181 emit showJournalOnly( 0 );
182 else 182 else
183 emit showJournalOnly( mJournal ); 183 emit showJournalOnly( mJournal );
184} 184}
185void JournalEntry::setShowOnly() 185void JournalEntry::setShowOnly()
186{ 186{
187 showOnlyMode = true; 187 showOnlyMode = true;
188 mEditor->setFocus(); 188 mEditor->setFocus();
189} 189}
190void JournalEntry::setJournal(Journal *journal) 190void JournalEntry::setJournal(Journal *journal)
191{ 191{
192 writeJournal(); 192 writeJournal();
193 193
194 mJournal = journal; 194 mJournal = journal;
195 mTitle->setText(mJournal->summary()); 195 if ( journal->isReadOnly() )
196 mTitle->setText(mJournal->summary()+" ("+i18n("readonly")+")");
197 else
198 mTitle->setText(mJournal->summary());
196 mEditor->setText(mJournal->description()); 199 mEditor->setText(mJournal->description());
200 mTitle->setReadOnly (journal->isReadOnly() );
201 mEditor->setReadOnly ( journal->isReadOnly() );
197 int id = mJournal->calID(); 202 int id = mJournal->calID();
198 203
199 QString calname = KOPrefs::instance()->getCalendar( id )->mName; 204 QString calname = KOPrefs::instance()->getCalendar( id )->mName;
200 mTitleLabel->setText( " (" + calname +")"); 205 mTitleLabel->setText( " (" + calname +")");
201 206
202 mDirty = false; 207 mDirty = false;
203} 208}
204 209
205Journal *JournalEntry::journal() const 210Journal *JournalEntry::journal() const
206{ 211{
207 return mJournal; 212 return mJournal;
208} 213}
209 214
210void JournalEntry::setDirty() 215void JournalEntry::setDirty()
211{ 216{
212 mDirty = true; 217 mDirty = true;
213 218
214// kdDebug() << "JournalEntry::setDirty()" << endl; 219// kdDebug() << "JournalEntry::setDirty()" << endl;
215} 220}
216 221
217void JournalEntry::clear() 222void JournalEntry::clear()
218{ 223{
219 mJournal = 0; 224 mJournal = 0;
220 mEditor->setText(""); 225 mEditor->setText("");
221} 226}
222 227
223bool JournalEntry::eventFilter( QObject *o, QEvent *e ) 228bool JournalEntry::eventFilter( QObject *o, QEvent *e )
224{ 229{
225// kdDebug() << "JournalEntry::event received " << e->type() << endl; 230// kdDebug() << "JournalEntry::event received " << e->type() << endl;
226 231
227 if ( e->type() == QEvent::FocusOut ) { 232 if ( e->type() == QEvent::FocusOut ) {
228 writeJournal(); 233 writeJournal();
229 } 234 }
230 if ( e->type() == QEvent::KeyPress ) { 235 if ( e->type() == QEvent::KeyPress ) {
231 QKeyEvent * k = (QKeyEvent *) e; 236 QKeyEvent * k = (QKeyEvent *) e;
232 if ( k->state() == Qt::ControlButton ) { 237 if ( k->state() == Qt::ControlButton ) {
233 k->ignore(); 238 k->ignore();
234 //return true; 239 //return true;
235 } 240 }
236 } 241 }
237 242
238 return QFrame::eventFilter( o, e ); // standard event processing 243 return QFrame::eventFilter( o, e ); // standard event processing
239} 244}
240 245
241void JournalEntry::writeJournal() 246void JournalEntry::writeJournal()
242{ 247{
243// kdDebug() << "JournalEntry::writeJournal()" << endl; 248// kdDebug() << "JournalEntry::writeJournal()" << endl;
244 if (!mDirty) return; 249 if (!mDirty) return;
245 250
246 if (mEditor->text().isEmpty()) { 251 if (mEditor->text().isEmpty()) {
247 if ( mJournal ) { 252 if ( mJournal ) {
248 mDirty = false; 253 mDirty = false;
249 bool conf = KOPrefs::instance()->mConfirm; 254 bool conf = KOPrefs::instance()->mConfirm;
250 KOPrefs::instance()->mConfirm = false; 255 KOPrefs::instance()->mConfirm = false;
251 emit deleteJournal(mJournal); 256 emit deleteJournal(mJournal);
252 KOPrefs::instance()->mConfirm = conf; 257 KOPrefs::instance()->mConfirm = conf;
253 mJournal = 0; 258 mJournal = 0;
254 } 259 }
255 return; 260 return;
256 } 261 }
257 262
258// kdDebug() << "JournalEntry::writeJournal()..." << endl; 263// kdDebug() << "JournalEntry::writeJournal()..." << endl;
259 264
260 if (!mJournal) { 265 if (!mJournal) {
261 mJournal = new Journal; 266 mJournal = new Journal;
262 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 267 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
263 mCalendar->addJournal(mJournal); 268 mCalendar->addJournal(mJournal);
264 } 269 }
265 270
266 mJournal->setDescription(mEditor->text()); 271 mJournal->setDescription(mEditor->text());
267 mJournal->setSummary(mTitle->text()); 272 mJournal->setSummary(mTitle->text());
268 mDirty = false; 273 mDirty = false;
269} 274}
270 275
271void JournalEntry::flushEntry() 276void JournalEntry::flushEntry()
272{ 277{
273 if (!mDirty) return; 278 if (!mDirty) return;
274 279
275 writeJournal(); 280 writeJournal();
276} 281}
277void JournalEntry::keyPressEvent ( QKeyEvent * e ) 282void JournalEntry::keyPressEvent ( QKeyEvent * e )
278{ 283{
279 e->ignore(); 284 e->ignore();
280 285
281} 286}
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index dcbb99f..8c1e5b2 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -510,294 +510,300 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
510 formatAttendees(event); 510 formatAttendees(event);
511 511
512 if ( KOPrefs::instance()->mEVshowCreated ) { 512 if ( KOPrefs::instance()->mEVshowCreated ) {
513 if(wideScreen ){ 513 if(wideScreen ){
514 514
515 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 515 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
516 516
517 } else { 517 } else {
518 addTag("p",i18n("<b>Created: ") +" </b>"); 518 addTag("p",i18n("<b>Created: ") +" </b>");
519 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 519 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
520 } 520 }
521 } 521 }
522 if ( KOPrefs::instance()->mEVshowChanged ) { 522 if ( KOPrefs::instance()->mEVshowChanged ) {
523 if(wideScreen ){ 523 if(wideScreen ){
524 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); 524 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
525 525
526 } else { 526 } else {
527 addTag("p",i18n("<b>Last modified: ") +" </b>"); 527 addTag("p",i18n("<b>Last modified: ") +" </b>");
528 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 528 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
529 } 529 }
530 } 530 }
531 if ( event->relatedTo() ) { 531 if ( event->relatedTo() ) {
532 addTag("b",i18n("Parent todo:<br>")); 532 addTag("b",i18n("Parent todo:<br>"));
533 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 533 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
534 } 534 }
535 QPtrList<Incidence> Relations = event->relations(); 535 QPtrList<Incidence> Relations = event->relations();
536 Incidence *to; 536 Incidence *to;
537 if ( Relations.first() ) 537 if ( Relations.first() )
538 addTag("b",i18n("Sub todos:<br>")); 538 addTag("b",i18n("Sub todos:<br>"));
539 for (to=Relations.first();to;to=Relations.next()) { 539 for (to=Relations.first();to;to=Relations.next()) {
540 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 540 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
541 541
542 } 542 }
543 543
544 if ( KOPrefs::instance()->mEVshowDetails ) { 544 if ( KOPrefs::instance()->mEVshowDetails ) {
545 if (!event->description().isEmpty()) { 545 if (!event->description().isEmpty()) {
546 addTag("p",i18n("<b>Details: </b>")); 546 addTag("p",i18n("<b>Details: </b>"));
547 addTag("p",deTag(event->description())); 547 addTag("p",deTag(event->description()));
548 } 548 }
549 } 549 }
550 setText(mText); 550 setText(mText);
551} 551}
552 552
553void KOEventViewer::formatCategories(Incidence *event) 553void KOEventViewer::formatCategories(Incidence *event)
554{ 554{
555 if (!event->categoriesStr().isEmpty()) { 555 if (!event->categoriesStr().isEmpty()) {
556 if (event->categories().count() == 1) { 556 if (event->categories().count() == 1) {
557 addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); 557 addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace());
558 } else { 558 } else {
559 addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; 559 addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ;
560 } 560 }
561 } 561 }
562} 562}
563void KOEventViewer::formatAttendees(Incidence *event) 563void KOEventViewer::formatAttendees(Incidence *event)
564{ 564{
565 QPtrList<Attendee> attendees = event->attendees(); 565 QPtrList<Attendee> attendees = event->attendees();
566 if (attendees.count()) { 566 if (attendees.count()) {
567 567
568 568
569 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 569 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
570 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 570 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
571 addTag("h3",i18n("Organizer")); 571 addTag("h3",i18n("Organizer"));
572 mText.append("<ul><li>"); 572 mText.append("<ul><li>");
573#ifndef KORG_NOKABC 573#ifndef KORG_NOKABC
574 574
575#ifdef DESKTOP_VERSION 575#ifdef DESKTOP_VERSION
576 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 576 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
577 KABC::Addressee::List addressList; 577 KABC::Addressee::List addressList;
578 addressList = add_book->findByEmail(event->organizer()); 578 addressList = add_book->findByEmail(event->organizer());
579 KABC::Addressee o = addressList.first(); 579 KABC::Addressee o = addressList.first();
580 if (!o.isEmpty() && addressList.size()<2) { 580 if (!o.isEmpty() && addressList.size()<2) {
581 mText += "<a href=\"uid:" + o.uid() + "\">"; 581 mText += "<a href=\"uid:" + o.uid() + "\">";
582 mText += o.formattedName(); 582 mText += o.formattedName();
583 mText += "</a>\n"; 583 mText += "</a>\n";
584 } else { 584 } else {
585 mText.append(event->organizer()); 585 mText.append(event->organizer());
586 } 586 }
587#else //DESKTOP_VERSION 587#else //DESKTOP_VERSION
588 mText += "<a href=\"uid:organizer\">"; 588 mText += "<a href=\"uid:organizer\">";
589 mText += event->organizer(); 589 mText += event->organizer();
590 mText += "</a>\n"; 590 mText += "</a>\n";
591#endif //DESKTOP_VERSION 591#endif //DESKTOP_VERSION
592 592
593 593
594#else 594#else
595 mText.append(event->organizer()); 595 mText.append(event->organizer());
596#endif 596#endif
597 597
598 if (iconPath) { 598 if (iconPath) {
599 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 599 mText += " <a href=\"mailto:" + event->organizer() + "\">";
600 mText += "<IMG src=\"" + iconPath + "\">"; 600 mText += "<IMG src=\"" + iconPath + "\">";
601 mText += "</a>\n"; 601 mText += "</a>\n";
602 } 602 }
603 mText.append("</li></ul>"); 603 mText.append("</li></ul>");
604 604
605 addTag("h3",i18n("Attendees")); 605 addTag("h3",i18n("Attendees"));
606 Attendee *a; 606 Attendee *a;
607 mText.append("<ul>"); 607 mText.append("<ul>");
608 int a_count = 0; 608 int a_count = 0;
609 int a_count_nr = 0; 609 int a_count_nr = 0;
610 610
611 for(a=attendees.first();a;a=attendees.next()) { 611 for(a=attendees.first();a;a=attendees.next()) {
612#ifndef KORG_NOKABC 612#ifndef KORG_NOKABC
613#ifdef DESKTOP_VERSION 613#ifdef DESKTOP_VERSION
614 if (a->name().isEmpty()) { 614 if (a->name().isEmpty()) {
615 addressList = add_book->findByEmail(a->email()); 615 addressList = add_book->findByEmail(a->email());
616 KABC::Addressee o = addressList.first(); 616 KABC::Addressee o = addressList.first();
617 if (!o.isEmpty() && addressList.size()<2) { 617 if (!o.isEmpty() && addressList.size()<2) {
618 mText += "<a href=\"uid:" + o.uid() + "\">"; 618 mText += "<a href=\"uid:" + o.uid() + "\">";
619 mText += o.formattedName(); 619 mText += o.formattedName();
620 mText += "</a>\n"; 620 mText += "</a>\n";
621 } else { 621 } else {
622 mText += "<li>"; 622 mText += "<li>";
623 mText.append(a->email()); 623 mText.append(a->email());
624 mText += "\n"; 624 mText += "\n";
625 } 625 }
626 } else { 626 } else {
627 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 627 mText += "<li><a href=\"uid:" + a->uid() + "\">";
628 if (!a->name().isEmpty()) mText += a->name(); 628 if (!a->name().isEmpty()) mText += a->name();
629 else mText += a->email(); 629 else mText += a->email();
630 mText += "</a>\n"; 630 mText += "</a>\n";
631 } 631 }
632#else //DESKTOP_VERSION 632#else //DESKTOP_VERSION
633 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 633 mText += "<li><a href=\"uid:" + a->uid() + "\">";
634 if (!a->name().isEmpty()) mText += a->name(); 634 if (!a->name().isEmpty()) mText += a->name();
635 else mText += a->email(); 635 else mText += a->email();
636 mText += "</a>\n"; 636 mText += "</a>\n";
637#endif //DESKTOP_VERSION 637#endif //DESKTOP_VERSION
638#else 638#else
639 //qDebug("nokabc "); 639 //qDebug("nokabc ");
640 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 640 mText += "<li><a href=\"uid:" + a->uid() + "\">";
641 if (!a->name().isEmpty()) mText += a->name(); 641 if (!a->name().isEmpty()) mText += a->name();
642 else mText += a->email(); 642 else mText += a->email();
643 mText += "</a>\n"; 643 mText += "</a>\n";
644#endif 644#endif
645 645
646 646
647 if (!a->email().isEmpty()) { 647 if (!a->email().isEmpty()) {
648 if (iconPath) { 648 if (iconPath) {
649 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 649 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
650 if ( a->RSVP() ) { 650 if ( a->RSVP() ) {
651 ++a_count_nr; 651 ++a_count_nr;
652 mText += "<IMG src=\"" + iconPath + "\">"; 652 mText += "<IMG src=\"" + iconPath + "\">";
653 } 653 }
654 else { 654 else {
655 ++a_count; 655 ++a_count;
656 mText += "<IMG src=\"" + NOiconPath + "\">"; 656 mText += "<IMG src=\"" + NOiconPath + "\">";
657 } 657 }
658 mText += "</a>\n"; 658 mText += "</a>\n";
659 } 659 }
660 } 660 }
661 if (a->status() != Attendee::NeedsAction ) 661 if (a->status() != Attendee::NeedsAction )
662 mText +="[" + a->statusStr() + "] "; 662 mText +="[" + a->statusStr() + "] ";
663 if (a->role() == Attendee::Chair ) 663 if (a->role() == Attendee::Chair )
664 mText +="(" + a->roleStr().left(1) + ".)"; 664 mText +="(" + a->roleStr().left(1) + ".)";
665 } 665 }
666 mText.append("</li></ul>"); 666 mText.append("</li></ul>");
667 if ( (a_count+a_count_nr) > 1 ) { 667 if ( (a_count+a_count_nr) > 1 ) {
668 mText += "<a href=\"mailto:ALL\">"; 668 mText += "<a href=\"mailto:ALL\">";
669 mText += i18n( "Mail to all" ); 669 mText += i18n( "Mail to all" );
670 mText += "</a> ( "; 670 mText += "</a> ( ";
671 mText += "<IMG src=\"" + iconPath + "\">"; 671 mText += "<IMG src=\"" + iconPath + "\">";
672 mText += i18n( " and " ); 672 mText += i18n( " and " );
673 mText += "<IMG src=\"" + NOiconPath + "\"> )"; 673 mText += "<IMG src=\"" + NOiconPath + "\"> )";
674 mText += "<br>\n"; 674 mText += "<br>\n";
675 675
676 676
677 } 677 }
678 if ( a_count_nr > 1 ) { 678 if ( a_count_nr > 1 ) {
679 mText += "<a href=\"mailto:RSVP\">"; 679 mText += "<a href=\"mailto:RSVP\">";
680 mText += i18n( "Mail to selected" ); 680 mText += i18n( "Mail to selected" );
681 mText += "</a> ( "; 681 mText += "</a> ( ";
682 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); 682 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath );
683 mText += "<br>\n"; 683 mText += "<br>\n";
684 } 684 }
685 } 685 }
686 686
687} 687}
688void KOEventViewer::appendJournal(Journal *jour, int mode ) 688void KOEventViewer::appendJournal(Journal *jour, int mode )
689{ 689{
690 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 690 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
691 if (mode == 0 ) { 691 if (mode == 0 ) {
692 addTag("h2",i18n("Journal from: ")); 692 addTag("h2",i18n("Journal from: "));
693 } 693 }
694 else { 694 else {
695 if ( mode == 1 ) { 695 if ( mode == 1 ) {
696 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 696 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
697 } else { 697 } else {
698 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 698 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
699 } 699 }
700 } 700 }
701 topLevelWidget()->setCaption("Journal Viewer"); 701 topLevelWidget()->setCaption("Journal Viewer");
702 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 702 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
703 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
704 if (!jour->summary().isEmpty()) { 703 if (!jour->summary().isEmpty()) {
705 addTag("p",i18n(" Title: ") + deTag(jour->summary())); 704 addTag("b",i18n(" Title: ") + deTag(jour->summary()));
706 } 705 }
706 formatReadOnly(jour);
707 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
708
707 if (!jour->description().isEmpty()) { 709 if (!jour->description().isEmpty()) {
708 addTag("p",deTag(jour->description())); 710 addTag("p",deTag(jour->description()));
709 } 711 }
710 setText(mText); 712 setText(mText);
711} 713}
712 714
713void KOEventViewer::formatReadOnly(Incidence *event) 715void KOEventViewer::formatReadOnly(Incidence *event)
714{ 716{
717 int id = event->calID();
718 if ( id > 1 ) {
719 addTag("p", i18n("Calendar:")+" " + KOPrefs::instance()->getCalendar( id )->mName );
720 }
715 if (event->isReadOnly()) { 721 if (event->isReadOnly()) {
716 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 722 addTag("p","<em>(" + i18n("read-only") + ")</em>");
717 } 723 }
718} 724}
719void KOEventViewer::setSyncMode( bool b ) 725void KOEventViewer::setSyncMode( bool b )
720{ 726{
721 mSyncMode = b; 727 mSyncMode = b;
722} 728}
723 729
724void KOEventViewer::setTodo(Todo *event, bool clearV ) 730void KOEventViewer::setTodo(Todo *event, bool clearV )
725{ 731{
726 if ( clearV ) 732 if ( clearV )
727 clearEvents(); 733 clearEvents();
728 if ( mSyncMode ) { 734 if ( mSyncMode ) {
729 if ( clearV ) 735 if ( clearV )
730 appendTodo(event,1 ); 736 appendTodo(event,1 );
731 else 737 else
732 appendTodo(event,2); 738 appendTodo(event,2);
733 } else 739 } else
734 appendTodo(event); 740 appendTodo(event);
735} 741}
736void KOEventViewer::setJournal(Journal *event, bool clearV ) 742void KOEventViewer::setJournal(Journal *event, bool clearV )
737{ 743{
738 if ( clearV ) 744 if ( clearV )
739 clearEvents(); 745 clearEvents();
740 if ( mSyncMode ) { 746 if ( mSyncMode ) {
741 if ( clearV ) 747 if ( clearV )
742 appendJournal(event, 1); 748 appendJournal(event, 1);
743 else 749 else
744 appendJournal(event, 2); 750 appendJournal(event, 2);
745 } else 751 } else
746 appendJournal(event); 752 appendJournal(event);
747} 753}
748 754
749void KOEventViewer::setEvent(Event *event) 755void KOEventViewer::setEvent(Event *event)
750{ 756{
751 clearEvents(); 757 clearEvents();
752 if ( mSyncMode ) 758 if ( mSyncMode )
753 appendEvent(event, 1); 759 appendEvent(event, 1);
754 else 760 else
755 appendEvent(event); 761 appendEvent(event);
756} 762}
757 763
758void KOEventViewer::addEvent(Event *event) 764void KOEventViewer::addEvent(Event *event)
759{ 765{
760 if ( mSyncMode ) 766 if ( mSyncMode )
761 appendEvent(event, 2); 767 appendEvent(event, 2);
762 else 768 else
763 appendEvent(event); 769 appendEvent(event);
764} 770}
765 771
766void KOEventViewer::clearEvents(bool now) 772void KOEventViewer::clearEvents(bool now)
767{ 773{
768 mText = ""; 774 mText = "";
769 if (now) setText(mText); 775 if (now) setText(mText);
770} 776}
771 777
772void KOEventViewer::addText(QString text) 778void KOEventViewer::addText(QString text)
773{ 779{
774 mText.append(text); 780 mText.append(text);
775 setText(mText); 781 setText(mText);
776} 782}
777QString KOEventViewer::deTag(QString text) 783QString KOEventViewer::deTag(QString text)
778{ 784{
779#if QT_VERSION >= 0x030000 785#if QT_VERSION >= 0x030000
780 text.replace( '<' , "&lt;" ); 786 text.replace( '<' , "&lt;" );
781 text.replace( '>' , "&gt;" ); 787 text.replace( '>' , "&gt;" );
782#else 788#else
783 if ( text.find ('<') >= 0 ) { 789 if ( text.find ('<') >= 0 ) {
784 text.replace( QRegExp("<") , "&lt;" ); 790 text.replace( QRegExp("<") , "&lt;" );
785 } 791 }
786 if ( text.find ('>') >= 0 ) { 792 if ( text.find ('>') >= 0 ) {
787 text.replace( QRegExp(">") , "&gt;" ); 793 text.replace( QRegExp(">") , "&gt;" );
788 } 794 }
789#endif 795#endif
790 return text; 796 return text;
791} 797}
792void KOEventViewer::keyPressEvent ( QKeyEvent * e ) 798void KOEventViewer::keyPressEvent ( QKeyEvent * e )
793{ 799{
794 switch ( e->key() ) { 800 switch ( e->key() ) {
795 case Qt::Key_Return: 801 case Qt::Key_Return:
796 case Qt::Key_Enter : 802 case Qt::Key_Enter :
797 e->ignore(); 803 e->ignore();
798 break; 804 break;
799 default: 805 default:
800 QTextBrowser::keyPressEvent ( e ); 806 QTextBrowser::keyPressEvent ( e );
801 break; 807 break;
802 } 808 }
803} 809}