summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp5
-rw-r--r--korganizer/koeventviewer.cpp4
2 files changed, 5 insertions, 4 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 493382d..a776cb6 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,464 +1,465 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp 4 Parts of the source code have been copied from kdpdatebutton.cpp
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source ode for Qt in the source distribution. 22 without including the source ode for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <libkcal/vcaldrag.h> 35#include <libkcal/vcaldrag.h>
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/dndfactory.h> 37#include <libkcal/dndfactory.h>
38#include <libkcal/calendarresources.h> 38#include <libkcal/calendarresources.h>
39#include <libkcal/resourcecalendar.h> 39#include <libkcal/resourcecalendar.h>
40#include <kresources/resourceselectdialog.h> 40#include <kresources/resourceselectdialog.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPLUGINS 44#ifndef KORG_NOPLUGINS
45#include "kocore.h" 45#include "kocore.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#include "koglobals.h" 48#include "koglobals.h"
49 49
50#include "kodaymatrix.h" 50#include "kodaymatrix.h"
51 51
52// ============================================================================ 52// ============================================================================
53// D Y N A M I C T I P 53// D Y N A M I C T I P
54// ============================================================================ 54// ============================================================================
55 55
56DynamicTip::DynamicTip( QWidget * parent ) 56DynamicTip::DynamicTip( QWidget * parent )
57 : QToolTip( parent ) 57 : QToolTip( parent )
58{ 58{
59 matrix = (KODayMatrix*)parent; 59 matrix = (KODayMatrix*)parent;
60} 60}
61 61
62class KODaymatrixWhatsThis :public QWhatsThis 62class KODaymatrixWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; 65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;};
66 ~KODaymatrixWhatsThis() { ; }; 66 ~KODaymatrixWhatsThis() { ; };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p ) 69 virtual QString text( const QPoint& p )
70 { 70 {
71 return _view->getWhatsThisText( p ) ; 71 return _view->getWhatsThisText( p ) ;
72 } 72 }
73private: 73private:
74 KODayMatrix * _view; 74 KODayMatrix * _view;
75}; 75};
76 76
77void DynamicTip::maybeTip( const QPoint &pos ) 77void DynamicTip::maybeTip( const QPoint &pos )
78{ 78{
79 //calculate which cell of the matrix the mouse is in 79 //calculate which cell of the matrix the mouse is in
80 QRect sz = matrix->frameRect(); 80 QRect sz = matrix->frameRect();
81 int dheight = sz.height()*7 / 42; 81 int dheight = sz.height()*7 / 42;
82 int dwidth = sz.width() / 7; 82 int dwidth = sz.width() / 7;
83 int row = pos.y()/dheight; 83 int row = pos.y()/dheight;
84 int col = pos.x()/dwidth; 84 int col = pos.x()/dwidth;
85 85
86 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 86 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
87 87
88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
89// col << "][" << row << "] => " <<(col+row*7) << endl; 89// col << "][" << row << "] => " <<(col+row*7) << endl;
90 90
91 //show holiday names only 91 //show holiday names only
92 QString str = matrix->getHolidayLabel(col+row*7); 92 QString str = matrix->getHolidayLabel(col+row*7);
93 if (str.isEmpty()) return; 93 if (str.isEmpty()) return;
94 tip(rct, str); 94 tip(rct, str);
95} 95}
96 96
97 97
98// ============================================================================ 98// ============================================================================
99// K O D A Y M A T R I X 99// K O D A Y M A T R I X
100// ============================================================================ 100// ============================================================================
101 101
102const int KODayMatrix::NOSELECTION = -1000; 102const int KODayMatrix::NOSELECTION = -1000;
103const int KODayMatrix::NUMDAYS = 42; 103const int KODayMatrix::NUMDAYS = 42;
104 104
105KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 105KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
106 : QFrame( parent, name ), mCalendar( 0 ) 106 : QFrame( parent, name ), mCalendar( 0 )
107 107
108#if 0 108#if 0
109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 109KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
110 QFrame(parent, name) 110 QFrame(parent, name)
111#endif 111#endif
112{ 112{
113 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); 113 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
114 mPendingUpdateBeforeRepaint = false; 114 mPendingUpdateBeforeRepaint = false;
115 mouseDown = false; 115 mouseDown = false;
116 // initialize dynamic arrays 116 // initialize dynamic arrays
117 bDays.resize ( NUMDAYS ); 117 bDays.resize ( NUMDAYS );
118 days = new QDate[NUMDAYS]; 118 days = new QDate[NUMDAYS];
119 daylbls = new QString[NUMDAYS]; 119 daylbls = new QString[NUMDAYS];
120 events = new int[NUMDAYS]; 120 events = new int[NUMDAYS];
121 mToolTip = new DynamicTip(this); 121 mToolTip = new DynamicTip(this);
122 122
123 // set default values used for drawing the matrix 123 // set default values used for drawing the matrix
124 mDefaultBackColor = palette().active().base(); 124 mDefaultBackColor = palette().active().base();
125 mDefaultTextColor = palette().active().foreground(); 125 mDefaultTextColor = palette().active().foreground();
126 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 126 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
127 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 127 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
128 mSelectedDaysColor = QColor("white"); 128 mSelectedDaysColor = QColor("white");
129 mTodayMarginWidth = 2; 129 mTodayMarginWidth = 2;
130 mSelEnd = mSelStart = NOSELECTION; 130 mSelEnd = mSelStart = NOSELECTION;
131 131
132 setAcceptDrops(true); 132 setAcceptDrops(true);
133 //setFont( QFont("Arial", 10) ); 133 //setFont( QFont("Arial", 10) );
134 134
135 mUpdateTimer = new QTimer( this ); 135 mUpdateTimer = new QTimer( this );
136 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 136 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
137 mRepaintTimer = new QTimer( this ); 137 mRepaintTimer = new QTimer( this );
138 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 138 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
139 mDayChanged = false; 139 mDayChanged = false;
140 updateView(); 140 updateView();
141} 141}
142QString KODayMatrix::getWhatsThisText( QPoint p ) 142QString KODayMatrix::getWhatsThisText( QPoint p )
143{ 143{
144 144
145 int tmp = getDayIndexFrom(p.x(), p.y()); 145 int tmp = getDayIndexFrom(p.x(), p.y());
146 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) 146 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar )
147 return QString(); 147 return QString();
148 QDate mDate = days[tmp]; 148 QDate mDate = days[tmp];
149 QPtrList<Event> eventlist = mCalendar->events(mDate); 149 QPtrList<Event> eventlist = mCalendar->events(mDate);
150 Event *event; 150 Event *event;
151 QStringList mToolTip; 151 QStringList mToolTip;
152 for(event=eventlist.first();event != 0;event=eventlist.next()) { 152 for(event=eventlist.first();event != 0;event=eventlist.next()) {
153 QString mToolTipText; 153 QString mToolTipText;
154 QString text; 154 QString text;
155 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 155 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
156 if (event->isMultiDay()) { 156 if (event->isMultiDay()) {
157 QString prefix = "<->";multiday = 2; 157 QString prefix = "<->";multiday = 2;
158 QString time; 158 QString time;
159 if ( event->doesRecur() ) { 159 if ( event->doesRecur() ) {
160 if ( event->recursOn( mDate) ) { 160 if ( event->recursOn( mDate) ) {
161 prefix ="->" ;multiday = 1; 161 prefix ="->" ;multiday = 1;
162 } 162 }
163 else { 163 else {
164 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 164 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
165 if ( event->recursOn( mDate.addDays( -days)) ) { 165 if ( event->recursOn( mDate.addDays( -days)) ) {
166 prefix ="<-" ;multiday = 3; 166 prefix ="<-" ;multiday = 3;
167 } 167 }
168 } 168 }
169 } else { 169 } else {
170 if (mDate == event->dtStart().date()) { 170 if (mDate == event->dtStart().date()) {
171 prefix ="->" ;multiday = 1; 171 prefix ="->" ;multiday = 1;
172 } else if (mDate == event->dtEnd().date()) { 172 } else if (mDate == event->dtEnd().date()) {
173 prefix ="<-" ;multiday = 3; 173 prefix ="<-" ;multiday = 3;
174 } 174 }
175 } 175 }
176 if ( !event->doesFloat() ) { 176 if ( !event->doesFloat() ) {
177 if ( mDate == event->dtStart().date () ) 177 if ( mDate == event->dtStart().date () )
178 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 178 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
179 else if ( mDate == event->dtEnd().date () ) 179 else if ( mDate == event->dtEnd().date () )
180 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 180 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
181 181
182 } 182 }
183 text = time + event->summary(); 183 text = time + event->summary();
184 mToolTipText += prefix + text; 184 mToolTipText += prefix + text;
185 } else { 185 } else {
186 if (event->doesFloat()) { 186 if (event->doesFloat()) {
187 text = event->summary(); 187 text = event->summary();
188 mToolTipText += text; 188 mToolTipText += text;
189 } 189 }
190 else { 190 else {
191 text = KGlobal::locale()->formatTime(event->dtStart().time()); 191 text = KGlobal::locale()->formatTime(event->dtStart().time());
192 text += " " + event->summary(); 192 text += " " + event->summary();
193 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 193 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
194 } 194 }
195 } 195 }
196 if ( !event->location().isEmpty() ) 196 if ( !event->location().isEmpty() )
197 mToolTipText += " (" + event->location() + ")"; 197 mToolTipText += " (" + event->location() + ")";
198#if QT_VERSION >= 0x030000 198#if QT_VERSION >= 0x030000
199 mToolTipText.replace( '<' , "&lt;" ); 199 mToolTipText.replace( '<' , "&lt;" );
200 mToolTipText.replace( '>' , "&gt;" ); 200 mToolTipText.replace( '>' , "&gt;" );
201#else 201#else
202 if ( mToolTipText.find ('<') > 0 ) { 202 if ( mToolTipText.find ('<') >= 0 ) {
203 mToolTipText.replace( QRegExp("<") , "&lt;" ); 203 mToolTipText.replace( QRegExp("<") , "&lt;" );
204 } 204 }
205 if ( mToolTipText.find ('>') > 0 ) { 205 if ( mToolTipText.find ('>') >= 0 ) {
206 mToolTipText.replace( QRegExp(">") , "&gt;" ); 206 mToolTipText.replace( QRegExp(">") , "&gt;" );
207 } 207 }
208#endif 208#endif
209 //qDebug("TTT: %s ", mToolTipText.latin1());
209 mToolTip.append( mToolTipText ); 210 mToolTip.append( mToolTipText );
210 } 211 }
211 mToolTip.sort(); 212 mToolTip.sort();
212 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); 213 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>");
213} 214}
214void KODayMatrix::setCalendar( Calendar *cal ) 215void KODayMatrix::setCalendar( Calendar *cal )
215{ 216{
216 mCalendar = cal; 217 mCalendar = cal;
217 218
218 setAcceptDrops( mCalendar ); 219 setAcceptDrops( mCalendar );
219 220
220 updateEvents(); 221 updateEvents();
221} 222}
222 223
223QColor KODayMatrix::getShadedColor(QColor color) 224QColor KODayMatrix::getShadedColor(QColor color)
224{ 225{
225 QColor shaded; 226 QColor shaded;
226 int h=0; 227 int h=0;
227 int s=0; 228 int s=0;
228 int v=0; 229 int v=0;
229 color.hsv(&h,&s,&v); 230 color.hsv(&h,&s,&v);
230 s = s/4; 231 s = s/4;
231 v = 192+v/4; 232 v = 192+v/4;
232 shaded.setHsv(h,s,v); 233 shaded.setHsv(h,s,v);
233 234
234 return shaded; 235 return shaded;
235} 236}
236 237
237KODayMatrix::~KODayMatrix() 238KODayMatrix::~KODayMatrix()
238{ 239{
239 // delete mKODaymatrixWhatsThis; 240 // delete mKODaymatrixWhatsThis;
240 delete [] days; 241 delete [] days;
241 delete [] daylbls; 242 delete [] daylbls;
242 delete [] events; 243 delete [] events;
243 delete mToolTip; 244 delete mToolTip;
244} 245}
245 246
246/* 247/*
247void KODayMatrix::setStartDate(QDate start) 248void KODayMatrix::setStartDate(QDate start)
248{ 249{
249 updateView(start); 250 updateView(start);
250} 251}
251*/ 252*/
252 253
253void KODayMatrix::addSelectedDaysTo(DateList& selDays) 254void KODayMatrix::addSelectedDaysTo(DateList& selDays)
254{ 255{
255 256
256 if (mSelStart == NOSELECTION) { 257 if (mSelStart == NOSELECTION) {
257 return; 258 return;
258 } 259 }
259 260
260 //cope with selection being out of matrix limits at top (< 0) 261 //cope with selection being out of matrix limits at top (< 0)
261 int i0 = mSelStart; 262 int i0 = mSelStart;
262 if (i0 < 0) { 263 if (i0 < 0) {
263 for (int i = i0; i < 0; i++) { 264 for (int i = i0; i < 0; i++) {
264 selDays.append(days[0].addDays(i)); 265 selDays.append(days[0].addDays(i));
265 } 266 }
266 i0 = 0; 267 i0 = 0;
267 } 268 }
268 269
269 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 270 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
270 if (mSelEnd > NUMDAYS-1) { 271 if (mSelEnd > NUMDAYS-1) {
271 for (int i = i0; i <= NUMDAYS-1; i++) { 272 for (int i = i0; i <= NUMDAYS-1; i++) {
272 selDays.append(days[i]); 273 selDays.append(days[i]);
273 } 274 }
274 for (int i = NUMDAYS; i < mSelEnd; i++) { 275 for (int i = NUMDAYS; i < mSelEnd; i++) {
275 selDays.append(days[0].addDays(i)); 276 selDays.append(days[0].addDays(i));
276 } 277 }
277 278
278 // apply normal routine to selection being entirely within matrix limits 279 // apply normal routine to selection being entirely within matrix limits
279 } else { 280 } else {
280 for (int i = i0; i <= mSelEnd; i++) { 281 for (int i = i0; i <= mSelEnd; i++) {
281 selDays.append(days[i]); 282 selDays.append(days[i]);
282 } 283 }
283 } 284 }
284} 285}
285 286
286void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 287void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
287{ 288{
288 mSelStart = startdate.daysTo(start); 289 mSelStart = startdate.daysTo(start);
289 if ( mSelStart < 0 ) 290 if ( mSelStart < 0 )
290 mSelStart = 0; 291 mSelStart = 0;
291 mSelEnd = startdate.daysTo(end); 292 mSelEnd = startdate.daysTo(end);
292 if ( mSelEnd < 0 ) 293 if ( mSelEnd < 0 )
293 clearSelection(); 294 clearSelection();
294} 295}
295void KODayMatrix::clearSelection() 296void KODayMatrix::clearSelection()
296{ 297{
297 mSelEnd = mSelStart = NOSELECTION; 298 mSelEnd = mSelStart = NOSELECTION;
298} 299}
299 300
300 301
301void KODayMatrix::recalculateToday() 302void KODayMatrix::recalculateToday()
302{ 303{
303 today = -1; 304 today = -1;
304 for (int i=0; i<NUMDAYS; i++) { 305 for (int i=0; i<NUMDAYS; i++) {
305 events[i] = 0; 306 events[i] = 0;
306 days[i] = startdate.addDays(i); 307 days[i] = startdate.addDays(i);
307 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 308 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
308 309
309 // if today is in the currently displayed month, hilight today 310 // if today is in the currently displayed month, hilight today
310 if (days[i].year() == QDate::currentDate().year() && 311 if (days[i].year() == QDate::currentDate().year() &&
311 days[i].month() == QDate::currentDate().month() && 312 days[i].month() == QDate::currentDate().month() &&
312 days[i].day() == QDate::currentDate().day()) { 313 days[i].day() == QDate::currentDate().day()) {
313 today = i; 314 today = i;
314 } 315 }
315 } 316 }
316 // qDebug(QString("Today is visible at %1.").arg(today)); 317 // qDebug(QString("Today is visible at %1.").arg(today));
317} 318}
318 319
319void KODayMatrix::updateView() 320void KODayMatrix::updateView()
320{ 321{
321 updateView(startdate); 322 updateView(startdate);
322} 323}
323void KODayMatrix::repaintViewTimed() 324void KODayMatrix::repaintViewTimed()
324{ 325{
325 mRepaintTimer->stop(); 326 mRepaintTimer->stop();
326 repaint(false); 327 repaint(false);
327} 328}
328void KODayMatrix::updateViewTimed() 329void KODayMatrix::updateViewTimed()
329{ 330{
330 mUpdateTimer->stop(); 331 mUpdateTimer->stop();
331 if ( !mCalendar ) { 332 if ( !mCalendar ) {
332 qDebug("NOT CAL "); 333 qDebug("NOT CAL ");
333 return; 334 return;
334 } 335 }
335 //qDebug("KODayMatrix::updateViewTimed "); 336 //qDebug("KODayMatrix::updateViewTimed ");
336 for(int i = 0; i < NUMDAYS; i++) { 337 for(int i = 0; i < NUMDAYS; i++) {
337 // if events are set for the day then remember to draw it bold 338 // if events are set for the day then remember to draw it bold
338 QPtrList<Event> eventlist = mCalendar->events(days[i]); 339 QPtrList<Event> eventlist = mCalendar->events(days[i]);
339 Event *event; 340 Event *event;
340 int numEvents = eventlist.count(); 341 int numEvents = eventlist.count();
341 QString holiStr = ""; 342 QString holiStr = "";
342 bDays.clearBit(i); 343 bDays.clearBit(i);
343 for(event=eventlist.first();event != 0;event=eventlist.next()) { 344 for(event=eventlist.first();event != 0;event=eventlist.next()) {
344 ushort recurType = event->recurrence()->doesRecur(); 345 ushort recurType = event->recurrence()->doesRecur();
345 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 346 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
346 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 347 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
347 numEvents--; 348 numEvents--;
348 } 349 }
349 if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { 350 if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) {
350 if ( !holiStr.isEmpty() ) 351 if ( !holiStr.isEmpty() )
351 holiStr += "\n"; 352 holiStr += "\n";
352 holiStr += event->summary(); 353 holiStr += event->summary();
353 if ( !event->location().isEmpty() ) 354 if ( !event->location().isEmpty() )
354 holiStr += " (" + event->location() + ")"; 355 holiStr += " (" + event->location() + ")";
355 } 356 }
356 if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { 357 if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) {
357 if ( !holiStr.isEmpty() ) 358 if ( !holiStr.isEmpty() )
358 holiStr += "\n"; 359 holiStr += "\n";
359 holiStr += i18n("Birthday") + ": "+event->summary(); 360 holiStr += i18n("Birthday") + ": "+event->summary();
360 if ( !event->location().isEmpty() ) 361 if ( !event->location().isEmpty() )
361 holiStr += " (" + event->location() + ")"; 362 holiStr += " (" + event->location() + ")";
362 bDays.setBit(i); 363 bDays.setBit(i);
363 } 364 }
364 } 365 }
365 events[i] = numEvents; 366 events[i] = numEvents;
366 //if it is a holy day then draw it red. Sundays are consider holidays, too 367 //if it is a holy day then draw it red. Sundays are consider holidays, too
367 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 368 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
368 !holiStr.isEmpty()) { 369 !holiStr.isEmpty()) {
369 mHolidays[i] = holiStr; 370 mHolidays[i] = holiStr;
370 } else { 371 } else {
371 mHolidays[i] = QString::null; 372 mHolidays[i] = QString::null;
372 } 373 }
373 } 374 }
374 if ( ! mPendingUpdateBeforeRepaint ) 375 if ( ! mPendingUpdateBeforeRepaint )
375 repaint(false); 376 repaint(false);
376} 377}
377void KODayMatrix::updateView(QDate actdate) 378void KODayMatrix::updateView(QDate actdate)
378{ 379{
379 380
380 if ( ! actdate.isValid() ) { 381 if ( ! actdate.isValid() ) {
381 //qDebug("date not valid "); 382 //qDebug("date not valid ");
382 return; 383 return;
383 } 384 }
384 mDayChanged = false; 385 mDayChanged = false;
385 //flag to indicate if the starting day of the matrix has changed by this call 386 //flag to indicate if the starting day of the matrix has changed by this call
386 //mDayChanged = false; 387 //mDayChanged = false;
387 // if a new startdate is to be set then apply Cornelius's calculation 388 // if a new startdate is to be set then apply Cornelius's calculation
388 // of the first day to be shown 389 // of the first day to be shown
389 if (actdate != startdate) { 390 if (actdate != startdate) {
390 // reset index of selection according to shift of starting date from startdate to actdate 391 // reset index of selection according to shift of starting date from startdate to actdate
391 if (mSelStart != NOSELECTION) { 392 if (mSelStart != NOSELECTION) {
392 int tmp = actdate.daysTo(startdate); 393 int tmp = actdate.daysTo(startdate);
393 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 394 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
394 // shift selection if new one would be visible at least partly ! 395 // shift selection if new one would be visible at least partly !
395 396
396 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 397 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
397 // nested if is required for next X display pushed from a different month - correction required 398 // nested if is required for next X display pushed from a different month - correction required
398 // otherwise, for month forward and backward, it must be avoided 399 // otherwise, for month forward and backward, it must be avoided
399 if( mSelStart > NUMDAYS || mSelStart < 0 ) 400 if( mSelStart > NUMDAYS || mSelStart < 0 )
400 mSelStart = mSelStart + tmp; 401 mSelStart = mSelStart + tmp;
401 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 402 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
402 mSelEnd = mSelEnd + tmp; 403 mSelEnd = mSelEnd + tmp;
403 } 404 }
404 } 405 }
405 startdate = actdate; 406 startdate = actdate;
406 mDayChanged = true; 407 mDayChanged = true;
407 recalculateToday(); 408 recalculateToday();
408 } 409 }
409 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 410 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
410 if ( !isVisible() ) { 411 if ( !isVisible() ) {
411 mPendingUpdateBeforeRepaint = true; 412 mPendingUpdateBeforeRepaint = true;
412 } else { 413 } else {
413#ifdef DESKTOP_VERSION 414#ifdef DESKTOP_VERSION
414 //mRepaintTimer->start( 100 ); 415 //mRepaintTimer->start( 100 );
415 mUpdateTimer->start( 100 ); 416 mUpdateTimer->start( 100 );
416#else 417#else
417 mRepaintTimer->start( 350 ); 418 mRepaintTimer->start( 350 );
418 mUpdateTimer->start( 1200 ); 419 mUpdateTimer->start( 1200 );
419#endif 420#endif
420 } 421 }
421} 422}
422void KODayMatrix::updateEvents() 423void KODayMatrix::updateEvents()
423{ 424{
424 if ( !mCalendar ) return; 425 if ( !mCalendar ) return;
425 426
426 for( int i = 0; i < NUMDAYS; i++ ) { 427 for( int i = 0; i < NUMDAYS; i++ ) {
427 // if events are set for the day then remember to draw it bold 428 // if events are set for the day then remember to draw it bold
428 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 429 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
429 int numEvents = eventlist.count(); 430 int numEvents = eventlist.count();
430 Event *event; 431 Event *event;
431 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 432 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
432 ushort recurType = event->doesRecur(); 433 ushort recurType = event->doesRecur();
433 434
434 if ( ( recurType == Recurrence::rDaily && 435 if ( ( recurType == Recurrence::rDaily &&
435 !KOPrefs::instance()->mDailyRecur ) || 436 !KOPrefs::instance()->mDailyRecur ) ||
436 ( recurType == Recurrence::rWeekly && 437 ( recurType == Recurrence::rWeekly &&
437 !KOPrefs::instance()->mWeeklyRecur ) ) { 438 !KOPrefs::instance()->mWeeklyRecur ) ) {
438 numEvents--; 439 numEvents--;
439 } 440 }
440 } 441 }
441 events[ i ] = numEvents; 442 events[ i ] = numEvents;
442 } 443 }
443} 444}
444 445
445const QDate& KODayMatrix::getDate(int offset) 446const QDate& KODayMatrix::getDate(int offset)
446{ 447{
447 if (offset < 0 || offset > NUMDAYS-1) { 448 if (offset < 0 || offset > NUMDAYS-1) {
448 qDebug("Wrong offset2 %d", offset); 449 qDebug("Wrong offset2 %d", offset);
449 return days[0]; 450 return days[0];
450 } 451 }
451 return days[offset]; 452 return days[offset];
452} 453}
453 454
454QString KODayMatrix::getHolidayLabel(int offset) 455QString KODayMatrix::getHolidayLabel(int offset)
455{ 456{
456 if (offset < 0 || offset > NUMDAYS-1) { 457 if (offset < 0 || offset > NUMDAYS-1) {
457 qDebug("Wrong offset1 %d", offset); 458 qDebug("Wrong offset1 %d", offset);
458 return QString(); 459 return QString();
459 } 460 }
460 return mHolidays[offset]; 461 return mHolidays[offset];
461} 462}
462 463
463int KODayMatrix::getDayIndexFrom(int x, int y) 464int KODayMatrix::getDayIndexFrom(int x, int y)
464{ 465{
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 135ca73..1508638 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -445,277 +445,277 @@ void KOEventViewer::appendTodo(Todo *event, int mode )
445 445
446 formatReadOnly(event); 446 formatReadOnly(event);
447 formatAttendees(event); 447 formatAttendees(event);
448 if ( event->relatedTo() ) { 448 if ( event->relatedTo() ) {
449 addTag("b",i18n("Parent todo:<br>")); 449 addTag("b",i18n("Parent todo:<br>"));
450 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 450 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
451 } 451 }
452 QPtrList<Incidence> Relations = event->relations(); 452 QPtrList<Incidence> Relations = event->relations();
453 Incidence *to; 453 Incidence *to;
454 if ( Relations.first() ) 454 if ( Relations.first() )
455 addTag("b",i18n("Sub todos:<br>")); 455 addTag("b",i18n("Sub todos:<br>"));
456 for (to=Relations.first();to;to=Relations.next()) { 456 for (to=Relations.first();to;to=Relations.next()) {
457 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 457 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
458 458
459 } 459 }
460 if ( KOPrefs::instance()->mEVshowCreated ) { 460 if ( KOPrefs::instance()->mEVshowCreated ) {
461 addTag("p",i18n("<b>Created: ") +" </b>"); 461 addTag("p",i18n("<b>Created: ") +" </b>");
462 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 462 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
463 463
464 } 464 }
465 if ( KOPrefs::instance()->mEVshowChanged ) { 465 if ( KOPrefs::instance()->mEVshowChanged ) {
466 addTag("p",i18n("<b>Last modified: ") +" </b>"); 466 addTag("p",i18n("<b>Last modified: ") +" </b>");
467 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 467 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
468 468
469 } 469 }
470 setText(mText); 470 setText(mText);
471} 471}
472 472
473void KOEventViewer::formatCategories(Incidence *event) 473void KOEventViewer::formatCategories(Incidence *event)
474{ 474{
475 if (!event->categoriesStr().isEmpty()) { 475 if (!event->categoriesStr().isEmpty()) {
476 if (event->categories().count() == 1) { 476 if (event->categories().count() == 1) {
477 addTag("h3",i18n("Category")); 477 addTag("h3",i18n("Category"));
478 } else { 478 } else {
479 addTag("h3",i18n("Categories")); 479 addTag("h3",i18n("Categories"));
480 } 480 }
481 addTag("p",event->categoriesStr()); 481 addTag("p",event->categoriesStr());
482 } 482 }
483} 483}
484void KOEventViewer::formatAttendees(Incidence *event) 484void KOEventViewer::formatAttendees(Incidence *event)
485{ 485{
486 QPtrList<Attendee> attendees = event->attendees(); 486 QPtrList<Attendee> attendees = event->attendees();
487 if (attendees.count()) { 487 if (attendees.count()) {
488 488
489 489
490 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 490 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
491 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 491 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
492 addTag("h3",i18n("Organizer")); 492 addTag("h3",i18n("Organizer"));
493 mText.append("<ul><li>"); 493 mText.append("<ul><li>");
494#ifndef KORG_NOKABC 494#ifndef KORG_NOKABC
495 495
496#ifdef DESKTOP_VERSION 496#ifdef DESKTOP_VERSION
497 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 497 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
498 KABC::Addressee::List addressList; 498 KABC::Addressee::List addressList;
499 addressList = add_book->findByEmail(event->organizer()); 499 addressList = add_book->findByEmail(event->organizer());
500 KABC::Addressee o = addressList.first(); 500 KABC::Addressee o = addressList.first();
501 if (!o.isEmpty() && addressList.size()<2) { 501 if (!o.isEmpty() && addressList.size()<2) {
502 mText += "<a href=\"uid:" + o.uid() + "\">"; 502 mText += "<a href=\"uid:" + o.uid() + "\">";
503 mText += o.formattedName(); 503 mText += o.formattedName();
504 mText += "</a>\n"; 504 mText += "</a>\n";
505 } else { 505 } else {
506 mText.append(event->organizer()); 506 mText.append(event->organizer());
507 } 507 }
508#else //DESKTOP_VERSION 508#else //DESKTOP_VERSION
509 mText += "<a href=\"uid:organizer\">"; 509 mText += "<a href=\"uid:organizer\">";
510 mText += event->organizer(); 510 mText += event->organizer();
511 mText += "</a>\n"; 511 mText += "</a>\n";
512#endif //DESKTOP_VERSION 512#endif //DESKTOP_VERSION
513 513
514 514
515#else 515#else
516 mText.append(event->organizer()); 516 mText.append(event->organizer());
517#endif 517#endif
518 518
519 if (iconPath) { 519 if (iconPath) {
520 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 520 mText += " <a href=\"mailto:" + event->organizer() + "\">";
521 mText += "<IMG src=\"" + iconPath + "\">"; 521 mText += "<IMG src=\"" + iconPath + "\">";
522 mText += "</a>\n"; 522 mText += "</a>\n";
523 } 523 }
524 mText.append("</li></ul>"); 524 mText.append("</li></ul>");
525 525
526 addTag("h3",i18n("Attendees")); 526 addTag("h3",i18n("Attendees"));
527 Attendee *a; 527 Attendee *a;
528 mText.append("<ul>"); 528 mText.append("<ul>");
529 int a_count = 0; 529 int a_count = 0;
530 int a_count_nr = 0; 530 int a_count_nr = 0;
531 531
532 for(a=attendees.first();a;a=attendees.next()) { 532 for(a=attendees.first();a;a=attendees.next()) {
533#ifndef KORG_NOKABC 533#ifndef KORG_NOKABC
534#ifdef DESKTOP_VERSION 534#ifdef DESKTOP_VERSION
535 if (a->name().isEmpty()) { 535 if (a->name().isEmpty()) {
536 addressList = add_book->findByEmail(a->email()); 536 addressList = add_book->findByEmail(a->email());
537 KABC::Addressee o = addressList.first(); 537 KABC::Addressee o = addressList.first();
538 if (!o.isEmpty() && addressList.size()<2) { 538 if (!o.isEmpty() && addressList.size()<2) {
539 mText += "<a href=\"uid:" + o.uid() + "\">"; 539 mText += "<a href=\"uid:" + o.uid() + "\">";
540 mText += o.formattedName(); 540 mText += o.formattedName();
541 mText += "</a>\n"; 541 mText += "</a>\n";
542 } else { 542 } else {
543 mText += "<li>"; 543 mText += "<li>";
544 mText.append(a->email()); 544 mText.append(a->email());
545 mText += "\n"; 545 mText += "\n";
546 } 546 }
547 } else { 547 } else {
548 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 548 mText += "<li><a href=\"uid:" + a->uid() + "\">";
549 if (!a->name().isEmpty()) mText += a->name(); 549 if (!a->name().isEmpty()) mText += a->name();
550 else mText += a->email(); 550 else mText += a->email();
551 mText += "</a>\n"; 551 mText += "</a>\n";
552 } 552 }
553#else //DESKTOP_VERSION 553#else //DESKTOP_VERSION
554 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 554 mText += "<li><a href=\"uid:" + a->uid() + "\">";
555 if (!a->name().isEmpty()) mText += a->name(); 555 if (!a->name().isEmpty()) mText += a->name();
556 else mText += a->email(); 556 else mText += a->email();
557 mText += "</a>\n"; 557 mText += "</a>\n";
558#endif //DESKTOP_VERSION 558#endif //DESKTOP_VERSION
559#else 559#else
560 //qDebug("nokabc "); 560 //qDebug("nokabc ");
561 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 561 mText += "<li><a href=\"uid:" + a->uid() + "\">";
562 if (!a->name().isEmpty()) mText += a->name(); 562 if (!a->name().isEmpty()) mText += a->name();
563 else mText += a->email(); 563 else mText += a->email();
564 mText += "</a>\n"; 564 mText += "</a>\n";
565#endif 565#endif
566 566
567 567
568 if (!a->email().isEmpty()) { 568 if (!a->email().isEmpty()) {
569 if (iconPath) { 569 if (iconPath) {
570 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 570 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
571 if ( a->RSVP() ) { 571 if ( a->RSVP() ) {
572 ++a_count_nr; 572 ++a_count_nr;
573 mText += "<IMG src=\"" + iconPath + "\">"; 573 mText += "<IMG src=\"" + iconPath + "\">";
574 } 574 }
575 else { 575 else {
576 ++a_count; 576 ++a_count;
577 mText += "<IMG src=\"" + NOiconPath + "\">"; 577 mText += "<IMG src=\"" + NOiconPath + "\">";
578 } 578 }
579 mText += "</a>\n"; 579 mText += "</a>\n";
580 } 580 }
581 } 581 }
582 if (a->status() != Attendee::NeedsAction ) 582 if (a->status() != Attendee::NeedsAction )
583 mText +="[" + a->statusStr() + "] "; 583 mText +="[" + a->statusStr() + "] ";
584 if (a->role() == Attendee::Chair ) 584 if (a->role() == Attendee::Chair )
585 mText +="(" + a->roleStr().left(1) + ".)"; 585 mText +="(" + a->roleStr().left(1) + ".)";
586 } 586 }
587 mText.append("</li></ul>"); 587 mText.append("</li></ul>");
588 if ( (a_count+a_count_nr) > 1 ) { 588 if ( (a_count+a_count_nr) > 1 ) {
589 mText += "<a href=\"mailto:ALL\">"; 589 mText += "<a href=\"mailto:ALL\">";
590 mText += i18n( "Mail to all" ); 590 mText += i18n( "Mail to all" );
591 mText += "</a> ( "; 591 mText += "</a> ( ";
592 mText += "<IMG src=\"" + iconPath + "\">"; 592 mText += "<IMG src=\"" + iconPath + "\">";
593 mText += i18n( " and " ); 593 mText += i18n( " and " );
594 mText += "<IMG src=\"" + NOiconPath + "\"> )"; 594 mText += "<IMG src=\"" + NOiconPath + "\"> )";
595 mText += "<br>\n"; 595 mText += "<br>\n";
596 596
597 597
598 } 598 }
599 if ( a_count_nr > 1 ) { 599 if ( a_count_nr > 1 ) {
600 mText += "<a href=\"mailto:RSVP\">"; 600 mText += "<a href=\"mailto:RSVP\">";
601 mText += i18n( "Mail to selected" ); 601 mText += i18n( "Mail to selected" );
602 mText += "</a> ( "; 602 mText += "</a> ( ";
603 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); 603 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath );
604 mText += "<br>\n"; 604 mText += "<br>\n";
605 } 605 }
606 } 606 }
607 607
608} 608}
609void KOEventViewer::appendJournal(Journal *jour, int mode ) 609void KOEventViewer::appendJournal(Journal *jour, int mode )
610{ 610{
611 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 611 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
612 if (mode == 0 ) { 612 if (mode == 0 ) {
613 addTag("h2",i18n("Journal from: ")); 613 addTag("h2",i18n("Journal from: "));
614 } 614 }
615 else { 615 else {
616 if ( mode == 1 ) { 616 if ( mode == 1 ) {
617 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 617 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
618 } else { 618 } else {
619 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 619 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
620 } 620 }
621 } 621 }
622 topLevelWidget()->setCaption("Journal Viewer"); 622 topLevelWidget()->setCaption("Journal Viewer");
623 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 623 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
624 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 624 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
625 if (!jour->description().isEmpty()) { 625 if (!jour->description().isEmpty()) {
626 addTag("p",deTag(jour->description())); 626 addTag("p",deTag(jour->description()));
627 } 627 }
628 setText(mText); 628 setText(mText);
629} 629}
630 630
631void KOEventViewer::formatReadOnly(Incidence *event) 631void KOEventViewer::formatReadOnly(Incidence *event)
632{ 632{
633 if (event->isReadOnly()) { 633 if (event->isReadOnly()) {
634 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 634 addTag("p","<em>(" + i18n("read-only") + ")</em>");
635 } 635 }
636} 636}
637void KOEventViewer::setSyncMode( bool b ) 637void KOEventViewer::setSyncMode( bool b )
638{ 638{
639 mSyncMode = b; 639 mSyncMode = b;
640} 640}
641 641
642void KOEventViewer::setTodo(Todo *event, bool clearV ) 642void KOEventViewer::setTodo(Todo *event, bool clearV )
643{ 643{
644 if ( clearV ) 644 if ( clearV )
645 clearEvents(); 645 clearEvents();
646 if ( mSyncMode ) { 646 if ( mSyncMode ) {
647 if ( clearV ) 647 if ( clearV )
648 appendTodo(event,1 ); 648 appendTodo(event,1 );
649 else 649 else
650 appendTodo(event,2); 650 appendTodo(event,2);
651 } else 651 } else
652 appendTodo(event); 652 appendTodo(event);
653} 653}
654void KOEventViewer::setJournal(Journal *event, bool clearV ) 654void KOEventViewer::setJournal(Journal *event, bool clearV )
655{ 655{
656 if ( clearV ) 656 if ( clearV )
657 clearEvents(); 657 clearEvents();
658 if ( mSyncMode ) { 658 if ( mSyncMode ) {
659 if ( clearV ) 659 if ( clearV )
660 appendJournal(event, 1); 660 appendJournal(event, 1);
661 else 661 else
662 appendJournal(event, 2); 662 appendJournal(event, 2);
663 } else 663 } else
664 appendJournal(event); 664 appendJournal(event);
665} 665}
666 666
667void KOEventViewer::setEvent(Event *event) 667void KOEventViewer::setEvent(Event *event)
668{ 668{
669 clearEvents(); 669 clearEvents();
670 if ( mSyncMode ) 670 if ( mSyncMode )
671 appendEvent(event, 1); 671 appendEvent(event, 1);
672 else 672 else
673 appendEvent(event); 673 appendEvent(event);
674} 674}
675 675
676void KOEventViewer::addEvent(Event *event) 676void KOEventViewer::addEvent(Event *event)
677{ 677{
678 if ( mSyncMode ) 678 if ( mSyncMode )
679 appendEvent(event, 2); 679 appendEvent(event, 2);
680 else 680 else
681 appendEvent(event); 681 appendEvent(event);
682} 682}
683 683
684void KOEventViewer::clearEvents(bool now) 684void KOEventViewer::clearEvents(bool now)
685{ 685{
686 mText = ""; 686 mText = "";
687 if (now) setText(mText); 687 if (now) setText(mText);
688} 688}
689 689
690void KOEventViewer::addText(QString text) 690void KOEventViewer::addText(QString text)
691{ 691{
692 mText.append(text); 692 mText.append(text);
693 setText(mText); 693 setText(mText);
694} 694}
695QString KOEventViewer::deTag(QString text) 695QString KOEventViewer::deTag(QString text)
696{ 696{
697#if QT_VERSION >= 0x030000 697#if QT_VERSION >= 0x030000
698 text.replace( '<' , "&lt;" ); 698 text.replace( '<' , "&lt;" );
699 text.replace( '>' , "&gt;" ); 699 text.replace( '>' , "&gt;" );
700#else 700#else
701 if ( text.find ('<') > 0 ) { 701 if ( text.find ('<') >= 0 ) {
702 text.replace( QRegExp("<") , "&lt;" ); 702 text.replace( QRegExp("<") , "&lt;" );
703 } 703 }
704 if ( text.find ('>') > 0 ) { 704 if ( text.find ('>') >= 0 ) {
705 text.replace( QRegExp(">") , "&gt;" ); 705 text.replace( QRegExp(">") , "&gt;" );
706 } 706 }
707#endif 707#endif
708 return text; 708 return text;
709} 709}
710void KOEventViewer::keyPressEvent ( QKeyEvent * e ) 710void KOEventViewer::keyPressEvent ( QKeyEvent * e )
711{ 711{
712 switch ( e->key() ) { 712 switch ( e->key() ) {
713 case Qt::Key_Return: 713 case Qt::Key_Return:
714 case Qt::Key_Enter : 714 case Qt::Key_Enter :
715 e->ignore(); 715 e->ignore();
716 break; 716 break;
717 default: 717 default:
718 QTextBrowser::keyPressEvent ( e ); 718 QTextBrowser::keyPressEvent ( e );
719 break; 719 break;
720 } 720 }
721} 721}