summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kowhatsnextview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 57623e6..d7ff9f2 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,763 +1,763 @@
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 19
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qtextcodec.h> 22#include <qtextcodec.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27#ifdef DESKTOP_VERSION 27#ifdef DESKTOP_VERSION
28#include <qpaintdevicemetrics.h> 28#include <qpaintdevicemetrics.h>
29#endif 29#endif
30#include <kglobal.h> 30#include <kglobal.h>
31#include <klocale.h> 31#include <klocale.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kmessagebox.h> 34#include <kmessagebox.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37 37
38#ifndef KORG_NOPRINTER 38#ifndef KORG_NOPRINTER
39#include "calprinter.h" 39#include "calprinter.h"
40#endif 40#endif
41#include "koglobals.h" 41#include "koglobals.h"
42#include "koprefs.h" 42#include "koprefs.h"
43#include "koeventviewerdialog.h" 43#include "koeventviewerdialog.h"
44#include <qstylesheet.h> 44#include <qstylesheet.h>
45#include "kowhatsnextview.h" 45#include "kowhatsnextview.h"
46using namespace KOrg; 46using namespace KOrg;
47 47
48void WhatsNextTextBrowser::setSource(const QString& n) 48void WhatsNextTextBrowser::setSource(const QString& n)
49{ 49{
50 50
51 if (n.startsWith("event:")) { 51 if (n.startsWith("event:")) {
52 emit showIncidence(n); 52 emit showIncidence(n);
53 return; 53 return;
54 } else if (n.startsWith("todo:")) { 54 } else if (n.startsWith("todo:")) {
55 emit showIncidence(n); 55 emit showIncidence(n);
56 return; 56 return;
57 } else { 57 } else {
58 QTextBrowser::setSource(n); 58 QTextBrowser::setSource(n);
59 } 59 }
60} 60}
61void WhatsNextTextBrowser::printMe() 61void WhatsNextTextBrowser::printMe()
62{ 62{
63#ifdef DESKTOP_VERSION 63#ifdef DESKTOP_VERSION
64 QPrinter printer; 64 QPrinter printer;
65 if (!printer.setup() ) 65 if (!printer.setup() )
66 return; 66 return;
67 QPainter p; 67 QPainter p;
68 p.begin ( &printer ); 68 p.begin ( &printer );
69 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 69 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
70 float dx, dy; 70 float dx, dy;
71 int wid = (m.width() * 9)/10; 71 int wid = (m.width() * 9)/10;
72 dx = (float) wid/(float)contentsWidth (); 72 dx = (float) wid/(float)contentsWidth ();
73 dy = (float)(m.height()) / (float)contentsHeight (); 73 dy = (float)(m.height()) / (float)contentsHeight ();
74 float scale; 74 float scale;
75 // scale to fit the width or height of the paper 75 // scale to fit the width or height of the paper
76 if ( dx < dy ) 76 if ( dx < dy )
77 scale = dx; 77 scale = dx;
78 else 78 else
79 scale = dy; 79 scale = dy;
80 p.translate( m.width()/10,0 ); 80 p.translate( m.width()/10,0 );
81 p.scale( scale, scale ); 81 p.scale( scale, scale );
82 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 82 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
83 p.end(); 83 p.end();
84#endif 84#endif
85} 85}
86 86
87KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 87KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
88 const char *name) 88 const char *name)
89 : KOrg::BaseView(calendar, parent, name) 89 : KOrg::BaseView(calendar, parent, name)
90{ 90{
91 // mDateLabel = 91 // mDateLabel =
92 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 92 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
93 // mDateLabel->setMargin(2); 93 // mDateLabel->setMargin(2);
94 // mDateLabel->setAlignment(AlignCenter); 94 // mDateLabel->setAlignment(AlignCenter);
95 setFont( KOPrefs::instance()->mWhatsNextFont ); 95 setFont( KOPrefs::instance()->mWhatsNextFont );
96 mView = new WhatsNextTextBrowser(this); 96 mView = new WhatsNextTextBrowser(this);
97 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 97 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
98 QStyleSheet* stsh = mView->styleSheet(); 98 QStyleSheet* stsh = mView->styleSheet();
99 QStyleSheetItem * style ; 99 QStyleSheetItem * style ;
100 style = stsh->item ("h2" ); 100 style = stsh->item ("h2" );
101 if ( style ) { 101 if ( style ) {
102 style->setMargin(QStyleSheetItem::MarginAll,0); 102 style->setMargin(QStyleSheetItem::MarginAll,0);
103 } 103 }
104 style = stsh->item ("h3" ); 104 style = stsh->item ("h3" );
105 if ( style ) { 105 if ( style ) {
106 style->setMargin(QStyleSheetItem::MarginAll,0); 106 style->setMargin(QStyleSheetItem::MarginAll,0);
107 } 107 }
108 mEventViewer = 0; 108 mEventViewer = 0;
109 109
110 QBoxLayout *topLayout = new QVBoxLayout(this); 110 QBoxLayout *topLayout = new QVBoxLayout(this);
111 // topLayout->addWidget(mDateLabel); 111 // topLayout->addWidget(mDateLabel);
112 topLayout->addWidget(mView); 112 topLayout->addWidget(mView);
113 mTimer = new QTimer( this ); 113 mTimer = new QTimer( this );
114 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); 114 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView()));
115 115
116 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 116 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
117 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 117 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
118} 118}
119 119
120KOWhatsNextView::~KOWhatsNextView() 120KOWhatsNextView::~KOWhatsNextView()
121{ 121{
122} 122}
123 123
124int KOWhatsNextView::maxDatesHint() 124int KOWhatsNextView::maxDatesHint()
125{ 125{
126 return 0; 126 return 0;
127} 127}
128 128
129int KOWhatsNextView::currentDateCount() 129int KOWhatsNextView::currentDateCount()
130{ 130{
131 return 0; 131 return 0;
132} 132}
133 133
134QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 134QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
135{ 135{
136 QPtrList<Incidence> eventList; 136 QPtrList<Incidence> eventList;
137 137
138 return eventList; 138 return eventList;
139} 139}
140 140
141void KOWhatsNextView::printMe() 141void KOWhatsNextView::printMe()
142{ 142{
143#ifdef DESKTOP_VERSION 143#ifdef DESKTOP_VERSION
144 mView->printMe(); 144 mView->printMe();
145#endif 145#endif
146} 146}
147void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 147void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
148 const QDate &td) 148 const QDate &td)
149{ 149{
150#ifndef KORG_NOPRINTER 150#ifndef KORG_NOPRINTER
151 calPrinter->preview(CalPrinter::Day, fd, td); 151 calPrinter->preview(CalPrinter::Day, fd, td);
152#endif 152#endif
153} 153}
154void KOWhatsNextView::updateConfig() 154void KOWhatsNextView::updateConfig()
155{ 155{
156 setFont( KOPrefs::instance()->mWhatsNextFont ); 156 setFont( KOPrefs::instance()->mWhatsNextFont );
157 updateView(); 157 updateView();
158 158
159} 159}
160void KOWhatsNextView::showEvent ( QShowEvent * e ) 160void KOWhatsNextView::showEvent ( QShowEvent * e )
161{ 161{
162 //qDebug("KOWhatsNextView::showEvent "); 162 //qDebug("KOWhatsNextView::showEvent ");
163 restartTimer(); 163 restartTimer();
164 QWidget::showEvent ( e ); 164 QWidget::showEvent ( e );
165} 165}
166void KOWhatsNextView::hideEvent ( QHideEvent * e) 166void KOWhatsNextView::hideEvent ( QHideEvent * e)
167{ 167{
168 //qDebug(" KOWhatsNextView::hideEvent"); 168 //qDebug(" KOWhatsNextView::hideEvent");
169 mTimer->stop(); 169 mTimer->stop();
170 QWidget::hideEvent ( e ); 170 QWidget::hideEvent ( e );
171} 171}
172void KOWhatsNextView::restartTimer() 172void KOWhatsNextView::restartTimer()
173{ 173{
174 //qDebug("KOWhatsNextView::restartTimer() "); 174 //qDebug("KOWhatsNextView::restartTimer() ");
175 mTimer->start( 300000 ); 175 mTimer->start( 300000 );
176 //mTimer->start( 5000 ); 176 //mTimer->start( 5000 );
177} 177}
178void KOWhatsNextView::updateView() 178void KOWhatsNextView::updateView()
179{ 179{
180 if ( mTimer->isActive() ) 180 if ( mTimer->isActive() )
181 restartTimer(); 181 restartTimer();
182 //qDebug("KOWhatsNextView::updateView() "); 182 //qDebug("KOWhatsNextView::updateView() ");
183 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 183 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
184 KIconLoader kil("korganizer"); 184 KIconLoader kil("korganizer");
185 QString ipath;// = new QString(); 185 QString ipath;// = new QString();
186 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 186 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
187 //<big><big><strong>" + date + "</strong></big></big>\n"; 187 //<big><big><strong>" + date + "</strong></big></big>\n";
188 mText = "<table width=\"100%\">\n"; 188 mText = "<table width=\"100%\">\n";
189 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 189 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
190#ifdef DESKTOP_VERSION 190#ifdef DESKTOP_VERSION
191 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 191 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
192#else 192#else
193 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 193 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
194#endif 194#endif
195 // mText += "<img src=\""; 195 // mText += "<img src=\"";
196 // mText += ipath; 196 // mText += ipath;
197 // mText += "\">"; 197 // mText += "\">";
198 mEventDate = QDate::currentDate(); 198 mEventDate = QDate::currentDate();
199#ifdef DESKTOP_VERSION 199#ifdef DESKTOP_VERSION
200 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 200 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
201#else 201#else
202 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 202 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
203#endif 203#endif
204 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 204 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
205 int iii; 205 int iii;
206 mTodos.clear(); 206 mTodos.clear();
207 QPtrList<Event> events; 207 QPtrList<Event> events;
208 QPtrList<Todo> todos = calendar()->todos(); 208 QPtrList<Todo> todos = calendar()->todos();
209 Todo * todo; 209 Todo * todo;
210 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 210 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
211 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 211 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
212 bool itemAdded = false; 212 bool itemAdded = false;
213 for ( iii = 0; iii < daysToShow; ++iii ) { 213 for ( iii = 0; iii < daysToShow; ++iii ) {
214 QString date; 214 QString date;
215 itemAdded = false; 215 itemAdded = false;
216 events = calendar()->events( mEventDate, true ); 216 events = calendar()->events( mEventDate, true );
217 217
218 if ( iii == 0 ) { // today !!! 218 if ( iii == 0 ) { // today !!!
219 todo = todos.first(); 219 todo = todos.first();
220 while(todo) { 220 while(todo) {
221 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 221 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
222 if ( ! itemAdded ) { 222 if ( ! itemAdded ) {
223 appendDay ( iii, mEventDate ); 223 appendDay ( iii, mEventDate );
224 //itemAdded = true; 224 //itemAdded = true;
225 225
226 } //bool reply=false, bool notRed = true, bool appendTable = false); 226 } //bool reply=false, bool notRed = true, bool appendTable = false);
227 appendEvent(todo, false, false, !itemAdded ); 227 appendEvent(todo, false, false, !itemAdded );
228 itemAdded = true; 228 itemAdded = true;
229 } 229 }
230 todo = todos.next(); 230 todo = todos.next();
231 } 231 }
232 } 232 }
233 233
234 234
235 if (events.count() > 0) { 235 if (events.count() > 0) {
236 // mText += "<p></p>"; 236 // mText += "<p></p>";
237 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 237 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
238 // mText += "<h2>"; 238 // mText += "<h2>";
239 //mText += " <img src=\""; 239 //mText += " <img src=\"";
240 //mText += ipath; 240 //mText += ipath;
241 //mText += "\">"; 241 //mText += "\">";
242 if ( ! itemAdded ) { 242 if ( ! itemAdded ) {
243 appendDay ( iii, mEventDate ); 243 appendDay ( iii, mEventDate );
244 244
245 } 245 }
246 // for first day (iii == 0) 246 // for first day (iii == 0)
247 // we may have syncevents, or events in the past, which maybe should not be diaplayed 247 // we may have syncevents, or events in the past, which maybe should not be diaplayed
248 // for that reason we cannot append <table> in appendDay () for iii == 0 248 // for that reason we cannot append <table> in appendDay () for iii == 0
249 // we must append it in the first successful call of appendEvent() 249 // we must append it in the first successful call of appendEvent()
250 Event *ev = events.first(); 250 Event *ev = events.first();
251 while(ev) { 251 while(ev) {
252 //qDebug("+++++event append %s", ev->summary().latin1()); 252 //qDebug("+++++event append %s", ev->summary().latin1());
253 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 253 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
254 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) 254 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) )
255 itemAdded = true; 255 itemAdded = true;
256 } 256 }
257 ev = events.next(); 257 ev = events.next();
258 } 258 }
259 259
260 //mText += "</table>\n"; 260 //mText += "</table>\n";
261 } 261 }
262 262
263 todo = todos.first(); 263 todo = todos.first();
264 while(todo) { 264 while(todo) {
265 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { 265 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
266 if ( ! itemAdded ) { 266 if ( ! itemAdded ) {
267 appendDay ( iii, mEventDate ); 267 appendDay ( iii, mEventDate );
268 //itemAdded = true; 268 //itemAdded = true;
269 } 269 }
270 appendEvent(todo, false , iii!= 0,!itemAdded); 270 appendEvent(todo, false , iii!= 0,!itemAdded);
271 itemAdded = true; 271 itemAdded = true;
272 } 272 }
273 todo = todos.next(); 273 todo = todos.next();
274 } 274 }
275 if ( !itemAdded && iii == 0 ) { 275 if ( !itemAdded && iii == 0 ) {
276 // appendDay ( iii, mEventDate ); 276 // appendDay ( iii, mEventDate );
277 //mText += "<table>"; 277 //mText += "<table>";
278 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; 278 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n";
279 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; 279 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n";
280 //mText +="</table>"; 280 //mText +="</table>";
281 } 281 }
282 if ( itemAdded ) 282 if ( itemAdded )
283 mText += "</table>\n"; 283 mText += "</table>\n";
284 mEventDate = mEventDate.addDays( 1 ); 284 mEventDate = mEventDate.addDays( 1 );
285 } 285 }
286 286
287 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; 287 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios;
288 if (todos.count() > 0 && topmostPrios > 0 ) { 288 if (todos.count() > 0 && topmostPrios > 0 ) {
289 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 289 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
290 // mText += "<h2>"; 290 // mText += "<h2>";
291 //<img src=\""; 291 //<img src=\"";
292 // mText += ipath; 292 // mText += ipath;
293 // mText += "\">"; 293 // mText += "\">";
294 // mText += i18n("Overdue To-Do:") + "</h2>\n"; 294 // mText += i18n("Overdue To-Do:") + "</h2>\n";
295 295
296 //mText += "<ul>\n"; 296 //mText += "<ul>\n";
297 bool gotone = false; 297 bool gotone = false;
298 int priority = 1; 298 int priority = 1;
299 int priosFound = 0; 299 int priosFound = 0;
300#ifdef DESKTOP_VERSION 300#ifdef DESKTOP_VERSION
301 mText +="<p></p>"; 301 mText +="<p></p>";
302#endif 302#endif
303 303
304 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; 304 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n";
305 mText += "<ul>\n"; 305 mText += "<ul>\n";
306 while (!gotone && priority<6) { 306 while (!gotone && priority<6) {
307 todo = todos.first(); 307 todo = todos.first();
308 while(todo) { 308 while(todo) {
309 if (!todo->isCompleted() && (todo->priority() == priority) ) { 309 if (!todo->isCompleted() && (todo->priority() == priority) ) {
310 if ( appendTodo(todo) ) 310 if ( appendTodo(todo) )
311 gotone = true; 311 gotone = true;
312 } 312 }
313 todo = todos.next(); 313 todo = todos.next();
314 } 314 }
315 if ( gotone ) { 315 if ( gotone ) {
316 gotone = false; 316 gotone = false;
317 ++priosFound; 317 ++priosFound;
318 if ( priosFound == topmostPrios ) 318 if ( priosFound == topmostPrios )
319 break; 319 break;
320 } 320 }
321 priority++; 321 priority++;
322 // kdDebug() << "adding the todos..." << endl; 322 // kdDebug() << "adding the todos..." << endl;
323 } 323 }
324 mText += "</ul>\n"; 324 mText += "</ul>\n";
325 } 325 }
326 326
327 int replys = 0; 327 int replys = 0;
328 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); 328 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6));
329 if (events.count() > 0) { 329 if (events.count() > 0) {
330 Event *ev = events.first(); 330 Event *ev = events.first();
331 while(ev) { 331 while(ev) {
332 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 332 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
333 if (me!=0) { 333 if (me!=0) {
334 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 334 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
335 if (replys == 0) { 335 if (replys == 0) {
336 mText += "<p></p>"; 336 mText += "<p></p>";
337 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 337 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
338 //mText += "<h2>"; 338 //mText += "<h2>";
339 //<img src=\""; 339 //<img src=\"";
340 // mText += ipath; 340 // mText += ipath;
341 // mText += "\">"; 341 // mText += "\">";
342 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 342 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
343 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 343 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
344 mText += "<table>\n"; 344 mText += "<table>\n";
345 } 345 }
346 replys++; 346 replys++;
347 appendEvent(ev,true); 347 appendEvent(ev,true);
348 } 348 }
349 } 349 }
350 ev = events.next(); 350 ev = events.next();
351 } 351 }
352 } 352 }
353 todos = calendar()->todos(); 353 todos = calendar()->todos();
354 if (todos.count() > 0) { 354 if (todos.count() > 0) {
355 Todo *to = todos.first(); 355 Todo *to = todos.first();
356 while(to) { 356 while(to) {
357 if ( !to->isCompleted() ){ 357 if ( !to->isCompleted() ){
358 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 358 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
359 if (me!=0) { 359 if (me!=0) {
360 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 360 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
361 if (replys == 0) { 361 if (replys == 0) {
362 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 362 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
363 mText += "<table>\n"; 363 mText += "<table>\n";
364 } 364 }
365 replys++; 365 replys++;
366 appendEvent(to, true); 366 appendEvent(to, true);
367 } 367 }
368 } 368 }
369 } 369 }
370 to = todos.next(); 370 to = todos.next();
371 } 371 }
372 } 372 }
373 if (replys > 0 ) mText += "</table>\n"; 373 if (replys > 0 ) mText += "</table>\n";
374 374
375 375
376 mText += "</td></tr>\n</table>\n"; 376 mText += "</td></tr>\n</table>\n";
377 377
378 mView->setText(mText); 378 mView->setText(mText);
379 mView->setFocus(); 379 mView->setFocus();
380 380
381 // QPixmap bPix = SmallIcon( "back" ); 381 // QPixmap bPix = SmallIcon( "back" );
382 // qDebug("xxxxxxxxxxxxxxxxxxxxx "); 382 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
383 // QWidget* test = new QWidget(); 383 // QWidget* test = new QWidget();
384 // test->setBackgroundMode(FixedPixmap ); 384 // test->setBackgroundMode(FixedPixmap );
385 // test->setBackgroundPixmap ( bPix ); 385 // test->setBackgroundPixmap ( bPix );
386 // test->resize( 300, 400 ); 386 // test->resize( 300, 400 );
387 // test->show(); 387 // test->show();
388 // mView->setBackgroundMode(FixedPixmap ); 388 // mView->setBackgroundMode(FixedPixmap );
389 // mView->setBackgroundPixmap ( bPix ); 389 // mView->setBackgroundPixmap ( bPix );
390 // qDebug("%s ",mText.latin1()); 390 // qDebug("%s ",mText.latin1());
391} 391}
392 392
393void KOWhatsNextView::appendDay( int i, QDate eventDate ) 393void KOWhatsNextView::appendDay( int i, QDate eventDate )
394{ 394{
395 QString date; 395 QString date;
396 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 396 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
397 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 397 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
398 if ( i == 0 ) { 398 if ( i == 0 ) {
399 //mText += "<table>\n"; 399 //mText += "<table>\n";
400 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 400 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
401 } 401 }
402 else if ( i == 1 ) 402 else if ( i == 1 )
403 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 403 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
404 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 404 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
405 mText += "<h2>" + date + "</h2>\n"; 405 mText += "<h2>" + date + "</h2>\n";
406 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 406 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
407 mText += "<table>\n"; 407 mText += "<table>\n";
408 408
409 409
410 410
411 } else { 411 } else {
412 if ( i == 0 ) { 412 if ( i == 0 ) {
413 //mText += "<table>\n"; 413 //mText += "<table>\n";
414 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 414 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
415 } 415 }
416 416
417#ifdef DESKTOP_VERSION 417#ifdef DESKTOP_VERSION
418 else if ( i == 1 ) { 418 else if ( i == 1 ) {
419 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 419 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
420 } 420 }
421 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 421 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
422#else 422#else
423 else if ( i == 1 ) { 423 else if ( i == 1 ) {
424 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 424 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
425 } 425 }
426 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 426 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
427 427
428#endif 428#endif
429 mText += "<h2>" + date + "</h2>\n"; 429 mText += "<h2>" + date + "</h2>\n";
430 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 430 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
431 mText += "<table>\n"; 431 mText += "<table>\n";
432 } 432 }
433} 433}
434 434
435 435
436void KOWhatsNextView::showDates(const QDate &, const QDate &) 436void KOWhatsNextView::showDates(const QDate &, const QDate &)
437{ 437{
438 updateView(); 438 updateView();
439} 439}
440 440
441void KOWhatsNextView::showEvents(QPtrList<Event>) 441void KOWhatsNextView::showEvents(QPtrList<Event>)
442{ 442{
443} 443}
444 444
445void KOWhatsNextView::changeEventDisplay(Event *, int action) 445void KOWhatsNextView::changeEventDisplay(Event *, int action)
446{ 446{
447 switch(action) { 447 switch(action) {
448 case KOGlobals::EVENTADDED: 448 case KOGlobals::EVENTADDED:
449 updateView(); 449 updateView();
450 break; 450 break;
451 case KOGlobals::EVENTEDITED: 451 case KOGlobals::EVENTEDITED:
452 updateView(); 452 updateView();
453 break; 453 break;
454 case KOGlobals::EVENTDELETED: 454 case KOGlobals::EVENTDELETED:
455 updateView(); 455 updateView();
456 break; 456 break;
457 default: 457 default:
458 updateView(); 458 updateView();
459 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 459 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
460 } 460 }
461} 461}
462 462
463bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) 463bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable )
464{ 464{
465 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) 465 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") )
466 return false; 466 return false;
467 QDateTime cdt = QDateTime::currentDateTime(); 467 QDateTime cdt = QDateTime::currentDateTime();
468 QDateTime noc; 468 QDateTime noc;
469 QString tempText; 469 QString tempText;
470 if ( appendTable && !notRed ) { 470 if ( appendTable && !notRed ) {
471 tempText = "<table>"; 471 tempText = "<table>";
472 } 472 }
473 bool ok = true; 473 bool ok = true;
474 if ( reply ) { 474 if ( reply ) {
475 noc = ev->getNextOccurence( cdt, &ok ); 475 noc = ev->getNextOccurence( cdt, &ok );
476 if (! ok && ev->type() == "Event") 476 if (! ok && ev->type() == "Event")
477 return false; 477 return false;
478 } 478 }
479 bool bDay = false; 479 bool bDay = false;
480 if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) 480 if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) )
481 bDay = true; 481 bDay = true;
482 tempText += "<tr><td><b>"; 482 tempText += "<tr><td><b>";
483 if (ev->type()=="Event") { 483 if (ev->type()=="Event") {
484 if (reply) { 484 if (reply) {
485 if (!ev->doesFloat()) 485 if (!ev->doesFloat())
486 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; 486 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": ";
487 else 487 else
488 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 488 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
489 489
490 } else { 490 } else {
491 if (!ev->doesFloat()) { 491 if (!ev->doesFloat()) {
492 Event *event = static_cast<Event *>(ev); 492 Event *event = static_cast<Event *>(ev);
493 QDateTime st,end; 493 QDateTime st,end;
494 if ( event->recurrence()->doesRecur() ) { 494 if ( event->recurrence()->doesRecur() ) {
495 QDate recDate= mEventDate; 495 QDate recDate= mEventDate;
496 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 496 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
497 while ( ! event->recursOn( recDate ) ) { 497 while ( ! event->recursOn( recDate ) ) {
498 recDate = recDate.addDays( -1 ); 498 recDate = recDate.addDays( -1 );
499 499
500 } 500 }
501 st = QDateTime ( recDate, event->dtStart().time() ); 501 st = QDateTime ( recDate, event->dtStart().time() );
502 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 502 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
503 } 503 }
504 else { 504 else {
505 st = event->dtStart(); 505 st = event->dtStart();
506 end = event->dtEnd(); 506 end = event->dtEnd();
507 } 507 }
508 508
509 509
510 QString dateText; 510 QString dateText;
511 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 511 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
512 if ( st.date() < mEventDate ) 512 if ( st.date() < mEventDate )
513 dateText = "++:++-"; 513 dateText = "++:++-";
514 else 514 else
515 dateText = event->dtStartTimeStr() + "-"; 515 dateText = event->dtStartTimeStr() + "-";
516 if ( end.date() > mEventDate ) 516 if ( end.date() > mEventDate )
517 dateText += "++:++"; 517 dateText += "++:++";
518 else 518 else
519 dateText += event->dtEndTimeStr(); 519 dateText += event->dtEndTimeStr();
520 if ( notRed ) 520 if ( notRed )
521 tempText += dateText; 521 tempText += dateText;
522 else { 522 else {
523 if ( end < cdt ) { 523 if ( end < cdt ) {
524 if ( !KOPrefs::instance()->mWNViewShowsPast ) 524 if ( !KOPrefs::instance()->mWNViewShowsPast )
525 return false; 525 return false;
526 tempText += "<font color=\"#F00000\">" + dateText + "</font>"; 526 tempText += "<font color=\"#F00000\">" + dateText + "</font>";
527 } 527 }
528 else if ( st < cdt ) 528 else if ( st < cdt )
529 tempText += "<font color=\"#008000\">" + dateText + "</font>"; 529 tempText += "<font color=\"#008000\">" + dateText + "</font>";
530 else 530 else
531 tempText += dateText; 531 tempText += dateText;
532 532
533 } 533 }
534 534
535 } else { 535 } else {
536 if ( bDay ) { 536 if ( bDay ) {
537 537
538 if ( ev->categories().contains( i18n("Birthday") )) 538 if ( ev->categories().contains( i18n("Birthday") ))
539 tempText += "<font color=\"#F00000\">" + i18n("Birthday") +":</font>"; 539 tempText += "<font color=\"#F00000\">" + i18n("Birthday") +":</font>";
540 else 540 else
541 tempText += "<font color=\"#F00000\">" + i18n("Anniversary")+":</font>"; 541 tempText += "<font color=\"#F00000\">" + i18n("Anniversary")+":</font>";
542 } else { 542 } else {
543 tempText += i18n("Allday:"); 543 tempText += i18n("Allday:");
544 } 544 }
545 545
546 } 546 }
547 } 547 }
548 } else { 548 } else {
549 mTodos.append( ev ); 549 mTodos.append( ev );
550 tempText += i18n("ToDo:"); 550 tempText += i18n("ToDo:");
551 if (reply) { 551 if (reply) {
552 tempText += " "; 552 tempText += " ";
553 if ( noc != cdt ) { 553 if ( noc != cdt ) {
554 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 554 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
555 } 555 }
556 } else { 556 } else {
557 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 557 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
558 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 558 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
559 QString dfs = KGlobal::locale()->dateFormatShort(); 559 QString dfs = KGlobal::locale()->dateFormatShort();
560 KGlobal::locale()->setDateFormatShort("%d.%b"); 560 KGlobal::locale()->setDateFormatShort("%d.%b");
561 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; 561 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>";
562 KGlobal::locale()->setDateFormatShort(dfs); 562 KGlobal::locale()->setDateFormatShort(dfs);
563 } else { 563 } else {
564 if (!ev->doesFloat() ) 564 if (!ev->doesFloat() )
565 if( ( (Todo*)ev)->dtDue() < cdt ) { 565 if( ( (Todo*)ev)->dtDue() < cdt ) {
566 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 566 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
567 567
568 568
569 } else 569 } else
570 tempText +=((Todo*)ev)->dtDueTimeStr(); 570 tempText +=((Todo*)ev)->dtDueTimeStr();
571 mTodos.append( ev ); 571 mTodos.append( ev );
572 } 572 }
573 } 573 }
574 } 574 }
575 tempText += "</b></td><td>"; 575 tempText += "</b></td><td>";
576 bool needClose = false; 576 bool needClose = false;
577 if ( ev->cancelled() ) { 577 if ( ev->cancelled() ) {
578 tempText += "<font color=\"#F00000\">[c"; 578 tempText += "<font color=\"#F00000\">[c";
579 needClose =true; 579 needClose =true;
580 580
581 } 581 }
582 if ( ev->isAlarmEnabled() ) { 582 if ( ev->isAlarmEnabled() ) {
583 if ( !needClose) 583 if ( !needClose)
584 tempText +="["; 584 tempText +="[";
585 tempText += "a"; 585 tempText += "a";
586 needClose =true; 586 needClose =true;
587 587
588 } 588 }
589 if ( ev->description().length() > 0 ) { 589 if ( ev->description().length() > 0 ) {
590 if ( !needClose) 590 if ( !needClose)
591 tempText +="["; 591 tempText +="[";
592 tempText += "i"; 592 tempText += "i";
593 needClose =true; 593 needClose =true;
594 } 594 }
595 if ( ev->recurrence()->doesRecur() ) { 595 if ( ev->recurrence()->doesRecur() ) {
596 if ( !needClose) 596 if ( !needClose)
597 tempText +="["; 597 tempText +="[";
598 tempText += "r"; 598 tempText += "r";
599 needClose =true; 599 needClose =true;
600 } 600 }
601 if ( needClose ) { 601 if ( needClose ) {
602 tempText += "] "; 602 tempText += "] ";
603 } 603 }
604 if ( ev->cancelled() ) 604 if ( ev->cancelled() )
605 tempText += "</font>"; 605 tempText += "</font>";
606 tempText += "<a "; 606 tempText += "<a ";
607 if (ev->type()=="Event") tempText += "href=\"event:"; 607 if (ev->type()=="Event") tempText += "href=\"event:";
608 if (ev->type()=="Todo") tempText += "href=\"todo:"; 608 if (ev->type()=="Todo") tempText += "href=\"todo:";
609 tempText += ev->uid() + "\">"; 609 tempText += ev->uid() + "\">";
610 if ( ev->summary().length() > 0 ) 610 if ( ev->summary().length() > 0 )
611 tempText += ev->summary(); 611 tempText += ev->summary();
612 else 612 else
613 tempText += i18n("-no summary-"); 613 tempText += i18n("-no summary-");
614 if ( bDay ) { 614 if ( bDay ) {
615 noc = ev->getNextOccurence( cdt, &ok ); 615 noc = ev->getNextOccurence( cdt.addDays(-1), &ok );
616 if ( ok ) { 616 if ( ok ) {
617 int years = noc.date().year() - ev->dtStart().date().year(); 617 int years = noc.date().year() - ev->dtStart().date().year();
618 tempText += i18n(" (%1 y.)"). arg( years ); 618 tempText += i18n(" (%1 y.)"). arg( years );
619 } 619 }
620 } 620 }
621 621
622 tempText += "</a>"; 622 tempText += "</a>";
623 if ( KOPrefs::instance()->mWNViewShowLocation ) 623 if ( KOPrefs::instance()->mWNViewShowLocation )
624 if ( !ev->location().isEmpty() ) 624 if ( !ev->location().isEmpty() )
625 tempText += " ("+ev->location() +")"; 625 tempText += " ("+ev->location() +")";
626 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) 626 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
627 tempText += " ["+ev->relatedTo()->summary() +"]"; 627 tempText += " ["+ev->relatedTo()->summary() +"]";
628 tempText += "</td></tr>\n"; 628 tempText += "</td></tr>\n";
629 mText += tempText; 629 mText += tempText;
630 return true; 630 return true;
631} 631}
632 632
633bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 633bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
634{ 634{
635 if ( mTodos.find( ev ) != mTodos.end() ) return false; 635 if ( mTodos.find( ev ) != mTodos.end() ) return false;
636 636
637 mTodos.append( ev ); 637 mTodos.append( ev );
638 if ( !isSub ) 638 if ( !isSub )
639 mText += "<p>"; 639 mText += "<p>";
640 else 640 else
641 mText += "<li>"; 641 mText += "<li>";
642 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; 642 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
643 643
644 644
645 mText += ind; 645 mText += ind;
646 bool needClose = false; 646 bool needClose = false;
647 if ( ev->cancelled() ) { 647 if ( ev->cancelled() ) {
648 mText += "<font color=\"#F00000\">[c"; 648 mText += "<font color=\"#F00000\">[c";
649 needClose =true; 649 needClose =true;
650 650
651 } 651 }
652 if ( ev->isAlarmEnabled() ) { 652 if ( ev->isAlarmEnabled() ) {
653 if ( !needClose) 653 if ( !needClose)
654 mText +="["; 654 mText +="[";
655 mText += "a"; 655 mText += "a";
656 needClose =true; 656 needClose =true;
657 657
658 } 658 }
659 659
660 if ( ev->description().length() > 0 ) { 660 if ( ev->description().length() > 0 ) {
661 if ( !needClose) 661 if ( !needClose)
662 mText +="["; 662 mText +="[";
663 mText += "i"; 663 mText += "i";
664 needClose =true; 664 needClose =true;
665 } 665 }
666 // if ( ev->recurrence()->doesRecur() ) { 666 // if ( ev->recurrence()->doesRecur() ) {
667 // if ( !needClose) 667 // if ( !needClose)
668 // mText +="("; 668 // mText +="(";
669 // mText += "r"; 669 // mText += "r";
670 // needClose =true; 670 // needClose =true;
671 // } 671 // }
672 if ( needClose ) 672 if ( needClose )
673 mText += "] "; 673 mText += "] ";
674 if ( ev->cancelled() ) 674 if ( ev->cancelled() )
675 mText += "</font>"; 675 mText += "</font>";
676 mText += "<a href=\"todo:" + ev->uid() + "\">"; 676 mText += "<a href=\"todo:" + ev->uid() + "\">";
677 if ( ev->summary().length() > 0 ) 677 if ( ev->summary().length() > 0 )
678 mText += ev->summary(); 678 mText += ev->summary();
679 else 679 else
680 mText += i18n("-no summary-"); 680 mText += i18n("-no summary-");
681 mText += "</a>"; 681 mText += "</a>";
682 if ( ((Todo*)ev)->hasDueDate () ) { 682 if ( ((Todo*)ev)->hasDueDate () ) {
683 QString year = ""; 683 QString year = "";
684 int ye = ((Todo*)ev)->dtDue().date().year(); 684 int ye = ((Todo*)ev)->dtDue().date().year();
685 if ( QDateTime::currentDateTime().date().year() != ye ) 685 if ( QDateTime::currentDateTime().date().year() != ye )
686 year = QString::number( ye ); 686 year = QString::number( ye );
687 QString dfs = KGlobal::locale()->dateFormatShort(); 687 QString dfs = KGlobal::locale()->dateFormatShort();
688 KGlobal::locale()->setDateFormatShort("%d.%b"); 688 KGlobal::locale()->setDateFormatShort("%d.%b");
689 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; 689 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
690 KGlobal::locale()->setDateFormatShort(dfs); 690 KGlobal::locale()->setDateFormatShort(dfs);
691 } 691 }
692 if ( KOPrefs::instance()->mWNViewShowLocation ) 692 if ( KOPrefs::instance()->mWNViewShowLocation )
693 if ( !ev->location().isEmpty() ) 693 if ( !ev->location().isEmpty() )
694 mText += " ("+ev->location() +")"; 694 mText += " ("+ev->location() +")";
695 if ( !isSub ) { 695 if ( !isSub ) {
696 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 696 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
697 mText += " ["+ev->relatedTo()->summary() +"]"; 697 mText += " ["+ev->relatedTo()->summary() +"]";
698 mText += "</p>\n"; 698 mText += "</p>\n";
699 } 699 }
700 else { 700 else {
701 ind += "-"; 701 ind += "-";
702 mText += "</li>\n"; 702 mText += "</li>\n";
703 } 703 }
704 QPtrList<Incidence> Relations = ev->relations(); 704 QPtrList<Incidence> Relations = ev->relations();
705 Incidence *to; 705 Incidence *to;
706 for (to=Relations.first();to;to=Relations.next()) { 706 for (to=Relations.first();to;to=Relations.next()) {
707 if (!((Todo*)to)->isCompleted()) 707 if (!((Todo*)to)->isCompleted())
708 appendTodo( to, ind , true ); 708 appendTodo( to, ind , true );
709 } 709 }
710 710
711 return true; 711 return true;
712} 712}
713 713
714/* 714/*
715 void KOWhatsNextView::createEventViewer() 715 void KOWhatsNextView::createEventViewer()
716 { 716 {
717 if (!mEventViewer) { 717 if (!mEventViewer) {
718 718
719 mEventViewer = new KOEventViewerDialog(this); 719 mEventViewer = new KOEventViewerDialog(this);
720 } 720 }
721 } 721 }
722*/ 722*/
723void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 723void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
724{ 724{
725 mEventViewer = v; 725 mEventViewer = v;
726} 726}
727 727
728// TODO: Create this function in CalendarView and remove it from here 728// TODO: Create this function in CalendarView and remove it from here
729void KOWhatsNextView::showIncidence(const QString &uid) 729void KOWhatsNextView::showIncidence(const QString &uid)
730{ 730{
731 731
732 if ( !mEventViewer ) { 732 if ( !mEventViewer ) {
733 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 733 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
734 return; 734 return;
735 } 735 }
736 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 736 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
737 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 737 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
738 if (uid.startsWith("event:")) { 738 if (uid.startsWith("event:")) {
739#ifdef DESKTOP_VERSION 739#ifdef DESKTOP_VERSION
740 Event *event = calendar()->event(uid.mid(8)); 740 Event *event = calendar()->event(uid.mid(8));
741#else 741#else
742 Event *event = calendar()->event(uid.mid(6)); 742 Event *event = calendar()->event(uid.mid(6));
743#endif 743#endif
744 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 744 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
745 if (!event) return; 745 if (!event) return;
746 //createEventViewer(); 746 //createEventViewer();
747 mEventViewer->setEvent(event); 747 mEventViewer->setEvent(event);
748 } else if (uid.startsWith("todo:")) { 748 } else if (uid.startsWith("todo:")) {
749#ifdef DESKTOP_VERSION 749#ifdef DESKTOP_VERSION
750 Todo *todo = calendar()->todo(uid.mid(7)); 750 Todo *todo = calendar()->todo(uid.mid(7));
751#else 751#else
752 Todo *todo = calendar()->todo(uid.mid(5)); 752 Todo *todo = calendar()->todo(uid.mid(5));
753#endif 753#endif
754 if (!todo) return; 754 if (!todo) return;
755 //createEventViewer(); 755 //createEventViewer();
756 mEventViewer->setTodo(todo); 756 mEventViewer->setTodo(todo);
757 } else { 757 } else {
758 return; 758 return;
759 759
760 } 760 }
761 mEventViewer->showMe(); 761 mEventViewer->showMe();
762 mEventViewer->raise(); 762 mEventViewer->raise();
763} 763}