summaryrefslogtreecommitdiffabout
path: root/korganizer/kowhatsnextview.cpp
Unidiff
Diffstat (limited to 'korganizer/kowhatsnextview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kowhatsnextview.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index f88403c..bfe930f 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,271 +1,277 @@
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 <q3textbrowser.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#include <QDesktopWidget>
27#ifdef DESKTOP_VERSION 28#ifdef DESKTOP_VERSION
28#include <qpaintdevicemetrics.h> 29#include <q3paintdevicemetrics.h>
30//Added by qt3to4:
31#include <Q3PtrList>
32#include <QHideEvent>
33#include <Q3VBoxLayout>
34#include <QShowEvent>
29#endif 35#endif
30#include <kglobal.h> 36#include <kglobal.h>
31#include <klocale.h> 37#include <klocale.h>
32#include <kdebug.h> 38#include <kdebug.h>
33#include <kiconloader.h> 39#include <kiconloader.h>
34#include <kmessagebox.h> 40#include <kmessagebox.h>
35 41
36#include <libkcal/calendar.h> 42#include <libkcal/calendar.h>
37 43
38#ifndef KORG_NOPRINTER 44#ifndef KORG_NOPRINTER
39#include "calprinter.h" 45#include "calprinter.h"
40#endif 46#endif
41#include "koglobals.h" 47#include "koglobals.h"
42#include "koprefs.h" 48#include "koprefs.h"
43#include "koeventviewerdialog.h" 49#include "koeventviewerdialog.h"
44#include "koeventviewer.h" 50#include "koeventviewer.h"
45#include <qstylesheet.h> 51#include <q3stylesheet.h>
46#include "kowhatsnextview.h" 52#include "kowhatsnextview.h"
47using namespace KOrg; 53using namespace KOrg;
48 54
49void WhatsNextTextBrowser::setSource(const QString& n) 55void WhatsNextTextBrowser::setSource(const QString& n)
50{ 56{
51 57
52 if (n.startsWith("event:")) { 58 if (n.startsWith("event:")) {
53 emit showIncidence(n); 59 emit showIncidence(n);
54 return; 60 return;
55 } else if (n.startsWith("todo:")) { 61 } else if (n.startsWith("todo:")) {
56 emit showIncidence(n); 62 emit showIncidence(n);
57 return; 63 return;
58 } else { 64 } else {
59 QTextBrowser::setSource(n); 65 Q3TextBrowser::setSource(n);
60 } 66 }
61} 67}
62void WhatsNextTextBrowser::printMe() 68void WhatsNextTextBrowser::printMe()
63{ 69{
64#ifdef DESKTOP_VERSION 70#ifdef DESKTOP_VERSION
65 KOPrintPrefs pp ( this ); 71 KOPrintPrefs pp ( this );
66 if (!pp.exec() ) 72 if (!pp.exec() )
67 return; 73 return;
68 int scaleval = pp.printMode() ; 74 int scaleval = pp.printMode() ;
69 75
70 QPrinter printer; 76 QPrinter printer;
71 if (!printer.setup() ) 77 if (!printer.setup() )
72 return; 78 return;
73 QPainter p; 79 QPainter p;
74 p.begin ( &printer ); 80 p.begin ( &printer );
75 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 81 Q3PaintDeviceMetrics m = Q3PaintDeviceMetrics ( &printer );
76 float dx, dy; 82 float dx, dy;
77 int wid = (m.width() * 9)/10; 83 int wid = (m.width() * 9)/10;
78 dx = (float) wid/(float)contentsWidth (); 84 dx = (float) wid/(float)contentsWidth ();
79 dy = (float)(m.height()) / (float)contentsHeight (); 85 dy = (float)(m.height()) / (float)contentsHeight ();
80 float scale; 86 float scale;
81 // scale to fit the width or height of the paper 87 // scale to fit the width or height of the paper
82 if ( dx < dy ) 88 if ( dx < dy )
83 scale = dx; 89 scale = dx;
84 else 90 else
85 scale = dy; 91 scale = dy;
86 p.translate( m.width()/10,0 ); 92 p.translate( m.width()/10,0 );
87 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 93 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
88 p.scale( scale, scale ); 94 p.scale( scale, scale );
89 } 95 }
90 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 96 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
91 p.end(); 97 p.end();
92#endif 98#endif
93} 99}
94 100
95KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 101KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
96 const char *name) 102 const char *name)
97 : KOrg::BaseView(calendar, parent, name) 103 : KOrg::BaseView(calendar, parent, name)
98{ 104{
99 // mDateLabel = 105 // mDateLabel =
100 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 106 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
101 // mDateLabel->setMargin(2); 107 // mDateLabel->setMargin(2);
102 // mDateLabel->setAlignment(AlignCenter); 108 // mDateLabel->setAlignment(AlignCenter);
103 setFont( KOPrefs::instance()->mWhatsNextFont ); 109 setFont( KOPrefs::instance()->mWhatsNextFont );
104 mView = new WhatsNextTextBrowser(this); 110 mView = new WhatsNextTextBrowser(this);
105 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 111 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
106 QStyleSheet* stsh = mView->styleSheet(); 112 Q3StyleSheet* stsh = mView->styleSheet();
107 QStyleSheetItem * style ; 113 Q3StyleSheetItem * style ;
108 style = stsh->item ("h2" ); 114 style = stsh->item ("h2" );
109 if ( style ) { 115 if ( style ) {
110 style->setMargin(QStyleSheetItem::MarginAll,0); 116 style->setMargin(Q3StyleSheetItem::MarginAll,0);
111 } 117 }
112 style = stsh->item ("h3" ); 118 style = stsh->item ("h3" );
113 if ( style ) { 119 if ( style ) {
114 style->setMargin(QStyleSheetItem::MarginAll,0); 120 style->setMargin(Q3StyleSheetItem::MarginAll,0);
115 } 121 }
116 mEventViewer = 0; 122 mEventViewer = 0;
117 123
118 QBoxLayout *topLayout = new QVBoxLayout(this); 124 Q3BoxLayout *topLayout = new Q3VBoxLayout(this);
119 // topLayout->addWidget(mDateLabel); 125 // topLayout->addWidget(mDateLabel);
120 topLayout->addWidget(mView); 126 topLayout->addWidget(mView);
121 mTimer = new QTimer( this ); 127 mTimer = new QTimer( this );
122 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); 128 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView()));
123 129
124 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 130 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
125 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 131 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
126} 132}
127 133
128KOWhatsNextView::~KOWhatsNextView() 134KOWhatsNextView::~KOWhatsNextView()
129{ 135{
130} 136}
131 137
132int KOWhatsNextView::maxDatesHint() 138int KOWhatsNextView::maxDatesHint()
133{ 139{
134 return 0; 140 return 0;
135} 141}
136 142
137int KOWhatsNextView::currentDateCount() 143int KOWhatsNextView::currentDateCount()
138{ 144{
139 return 0; 145 return 0;
140} 146}
141 147
142void KOWhatsNextView::clearList() 148void KOWhatsNextView::clearList()
143{ 149{
144 mTimer->stop(); 150 mTimer->stop();
145 mView->setText(" "); 151 mView->setText(" ");
146} 152}
147QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 153Q3PtrList<Incidence> KOWhatsNextView::selectedIncidences()
148{ 154{
149 QPtrList<Incidence> eventList; 155 Q3PtrList<Incidence> eventList;
150 156
151 return eventList; 157 return eventList;
152} 158}
153 159
154void KOWhatsNextView::printMe() 160void KOWhatsNextView::printMe()
155{ 161{
156#ifdef DESKTOP_VERSION 162#ifdef DESKTOP_VERSION
157 mView->printMe(); 163 mView->printMe();
158#endif 164#endif
159} 165}
160void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 166void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
161 const QDate &td) 167 const QDate &td)
162{ 168{
163#ifndef KORG_NOPRINTER 169#ifndef KORG_NOPRINTER
164 calPrinter->preview(CalPrinter::Day, fd, td); 170 calPrinter->preview(CalPrinter::Day, fd, td);
165#endif 171#endif
166} 172}
167void KOWhatsNextView::updateConfig() 173void KOWhatsNextView::updateConfig()
168{ 174{
169 setFont( KOPrefs::instance()->mWhatsNextFont ); 175 setFont( KOPrefs::instance()->mWhatsNextFont );
170 updateView(); 176 updateView();
171 177
172} 178}
173void KOWhatsNextView::showEvent ( QShowEvent * e ) 179void KOWhatsNextView::showEvent ( QShowEvent * e )
174{ 180{
175 //qDebug("KOWhatsNextView::showEvent "); 181 //qDebug("KOWhatsNextView::showEvent ");
176 restartTimer(); 182 restartTimer();
177 QWidget::showEvent ( e ); 183 QWidget::showEvent ( e );
178} 184}
179void KOWhatsNextView::hideEvent ( QHideEvent * e) 185void KOWhatsNextView::hideEvent ( QHideEvent * e)
180{ 186{
181 //qDebug(" KOWhatsNextView::hideEvent"); 187 //qDebug(" KOWhatsNextView::hideEvent");
182 mTimer->stop(); 188 mTimer->stop();
183 QWidget::hideEvent ( e ); 189 QWidget::hideEvent ( e );
184} 190}
185void KOWhatsNextView::restartTimer() 191void KOWhatsNextView::restartTimer()
186{ 192{
187 //qDebug("KOWhatsNextView::restartTimer() "); 193 //qDebug("KOWhatsNextView::restartTimer() ");
188 mTimer->start( 300000 ); 194 mTimer->start( 300000 );
189 //mTimer->start( 5000 ); 195 //mTimer->start( 5000 );
190} 196}
191void KOWhatsNextView::updateView() 197void KOWhatsNextView::updateView()
192{ 198{
193 //qDebug("KOWhatsNextView::updateView() "); 199 //qDebug("KOWhatsNextView::updateView() ");
194 if ( mTimer->isActive() ) 200 if ( mTimer->isActive() )
195 restartTimer(); 201 restartTimer();
196 mCurrentMaxPrio = 5; 202 mCurrentMaxPrio = 5;
197 //qDebug("KOWhatsNextView::updateView() "); 203 //qDebug("KOWhatsNextView::updateView() ");
198 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 204 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
199 KIconLoader kil("korganizer"); 205 KIconLoader kil("korganizer");
200 QString ipath;// = new QString(); 206 QString ipath;// = new QString();
201 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 207 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
202 //<big><big><strong>" + date + "</strong></big></big>\n"; 208 //<big><big><strong>" + date + "</strong></big></big>\n";
203 mText = "<table width=\"100%\">\n"; 209 mText = "<table width=\"100%\">\n";
204 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 210 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
205#ifdef DESKTOP_VERSION 211#ifdef DESKTOP_VERSION
206 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 212 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
207#else 213#else
208 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 214 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
209#endif 215#endif
210 // mText += "<img src=\""; 216 // mText += "<img src=\"";
211 // mText += ipath; 217 // mText += ipath;
212 // mText += "\">"; 218 // mText += "\">";
213 mEventDate = QDate::currentDate(); 219 mEventDate = QDate::currentDate();
214#ifdef DESKTOP_VERSION 220#ifdef DESKTOP_VERSION
215 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 221 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
216#else 222#else
217 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 223 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
218#endif 224#endif
219 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 225 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
220 int iii; 226 int iii;
221 mTodos.clear(); 227 mTodos.clear();
222 QPtrList<Event> events; 228 Q3PtrList<Event> events;
223 QPtrList<Todo> todos = calendar()->todos(); 229 Q3PtrList<Todo> todos = calendar()->todos();
224 Todo * todo; 230 Todo * todo;
225 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 231 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
226 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 232 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
227 bool itemAdded = false; 233 bool itemAdded = false;
228 for ( iii = 0; iii < daysToShow; ++iii ) { 234 for ( iii = 0; iii < daysToShow; ++iii ) {
229 QString date; 235 QString date;
230 itemAdded = false; 236 itemAdded = false;
231 events = calendar()->events( mEventDate, true ); 237 events = calendar()->events( mEventDate, true );
232 238
233 if ( iii == 0 ) { // today !!! 239 if ( iii == 0 ) { // today !!!
234 todo = todos.first(); 240 todo = todos.first();
235 while(todo) { 241 while(todo) {
236 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 242 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
237 if ( ! itemAdded ) { 243 if ( ! itemAdded ) {
238 appendDay ( iii, mEventDate ); 244 appendDay ( iii, mEventDate );
239 //itemAdded = true; 245 //itemAdded = true;
240 246
241 } //bool reply=false, bool notRed = true, bool appendTable = false); 247 } //bool reply=false, bool notRed = true, bool appendTable = false);
242 appendEvent(todo, false, false, !itemAdded ); 248 appendEvent(todo, false, false, !itemAdded );
243 itemAdded = true; 249 itemAdded = true;
244 } 250 }
245 todo = todos.next(); 251 todo = todos.next();
246 } 252 }
247 } 253 }
248 254
249 255
250 if (events.count() > 0) { 256 if (events.count() > 0) {
251 // mText += "<p></p>"; 257 // mText += "<p></p>";
252 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 258 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
253 // mText += "<h2>"; 259 // mText += "<h2>";
254 //mText += " <img src=\""; 260 //mText += " <img src=\"";
255 //mText += ipath; 261 //mText += ipath;
256 //mText += "\">"; 262 //mText += "\">";
257 if ( ! itemAdded ) { 263 if ( ! itemAdded ) {
258 appendDay ( iii, mEventDate ); 264 appendDay ( iii, mEventDate );
259 265
260 } 266 }
261 // for first day (iii == 0) 267 // for first day (iii == 0)
262 // we may have syncevents, or events in the past, which maybe should not be diaplayed 268 // we may have syncevents, or events in the past, which maybe should not be diaplayed
263 // for that reason we cannot append <table> in appendDay () for iii == 0 269 // for that reason we cannot append <table> in appendDay () for iii == 0
264 // we must append it in the first successful call of appendEvent() 270 // we must append it in the first successful call of appendEvent()
265 Event *ev = events.first(); 271 Event *ev = events.first();
266 while(ev) { 272 while(ev) {
267 //qDebug("+++++event append %s", ev->summary().latin1()); 273 //qDebug("+++++event append %s", ev->summary().latin1());
268 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 274 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
269 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) 275 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) )
270 itemAdded = true; 276 itemAdded = true;
271 } 277 }
@@ -409,97 +415,97 @@ void KOWhatsNextView::updateView()
409void KOWhatsNextView::appendDay( int i, QDate eventDate ) 415void KOWhatsNextView::appendDay( int i, QDate eventDate )
410{ 416{
411 QString date; 417 QString date;
412 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 418 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
413 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 419 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
414 if ( i == 0 ) { 420 if ( i == 0 ) {
415 //mText += "<table>\n"; 421 //mText += "<table>\n";
416 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 422 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
417 } 423 }
418 else if ( i == 1 ) 424 else if ( i == 1 )
419 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 425 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
420 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 426 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
421 mText += "<h2>" + date + "</h2>\n"; 427 mText += "<h2>" + date + "</h2>\n";
422 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 428 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
423 mText += "<table>\n"; 429 mText += "<table>\n";
424 430
425 431
426 432
427 } else { 433 } else {
428 if ( i == 0 ) { 434 if ( i == 0 ) {
429 //mText += "<table>\n"; 435 //mText += "<table>\n";
430 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 436 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
431 } 437 }
432 438
433#ifdef DESKTOP_VERSION 439#ifdef DESKTOP_VERSION
434 else if ( i == 1 ) { 440 else if ( i == 1 ) {
435 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 441 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
436 } 442 }
437 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 443 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
438#else 444#else
439 else if ( i == 1 ) { 445 else if ( i == 1 ) {
440 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 446 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
441 } 447 }
442 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 448 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
443 449
444#endif 450#endif
445 mText += "<h2>" + date + "</h2>\n"; 451 mText += "<h2>" + date + "</h2>\n";
446 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 452 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
447 mText += "<table>\n"; 453 mText += "<table>\n";
448 } 454 }
449} 455}
450 456
451 457
452void KOWhatsNextView::showDates(const QDate &, const QDate &) 458void KOWhatsNextView::showDates(const QDate &, const QDate &)
453{ 459{
454 updateView(); 460 updateView();
455} 461}
456 462
457void KOWhatsNextView::showEvents(QPtrList<Event>) 463void KOWhatsNextView::showEvents(Q3PtrList<Event>)
458{ 464{
459} 465}
460 466
461void KOWhatsNextView::changeEventDisplay(Event *, int action) 467void KOWhatsNextView::changeEventDisplay(Event *, int action)
462{ 468{
463 switch(action) { 469 switch(action) {
464 case KOGlobals::EVENTADDED: 470 case KOGlobals::EVENTADDED:
465 updateView(); 471 updateView();
466 break; 472 break;
467 case KOGlobals::EVENTEDITED: 473 case KOGlobals::EVENTEDITED:
468 updateView(); 474 updateView();
469 break; 475 break;
470 case KOGlobals::EVENTDELETED: 476 case KOGlobals::EVENTDELETED:
471 updateView(); 477 updateView();
472 break; 478 break;
473 default: 479 default:
474 updateView(); 480 updateView();
475 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 481 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
476 } 482 }
477} 483}
478 484
479bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) 485bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable )
480{ 486{
481 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) 487 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") )
482 return false; 488 return false;
483 QDateTime cdt = QDateTime::currentDateTime(); 489 QDateTime cdt = QDateTime::currentDateTime();
484 QDateTime noc; 490 QDateTime noc;
485 QString tempText; 491 QString tempText;
486 if ( appendTable && !notRed ) { 492 if ( appendTable && !notRed ) {
487 tempText = "<table>"; 493 tempText = "<table>";
488 } 494 }
489 bool ok = true; 495 bool ok = true;
490 if ( reply ) { 496 if ( reply ) {
491 noc = ev->getNextOccurence( cdt, &ok ); 497 noc = ev->getNextOccurence( cdt, &ok );
492 if (! ok && ev->typeID() == eventID) 498 if (! ok && ev->typeID() == eventID)
493 return false; 499 return false;
494 } 500 }
495 bool bDay = false; 501 bool bDay = false;
496 if ( ev->isBirthday() || ev->isAnniversary() ) 502 if ( ev->isBirthday() || ev->isAnniversary() )
497 bDay = true; 503 bDay = true;
498 tempText += "<tr><td><b>"; 504 tempText += "<tr><td><b>";
499 if (ev->typeID() == eventID ) { 505 if (ev->typeID() == eventID ) {
500 if (reply) { 506 if (reply) {
501 if (!ev->doesFloat()) 507 if (!ev->doesFloat())
502 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; 508 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": ";
503 else 509 else
504 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 510 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
505 511
@@ -696,97 +702,97 @@ bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
696 mText +="["; 702 mText +="[";
697 mText += "i"; 703 mText += "i";
698 needClose =true; 704 needClose =true;
699 } 705 }
700 if ( ev->doesRecur() ) { 706 if ( ev->doesRecur() ) {
701 if ( !needClose) 707 if ( !needClose)
702 mText +="["; 708 mText +="[";
703 mText += "r"; 709 mText += "r";
704 needClose =true; 710 needClose =true;
705 } 711 }
706 // if ( ev->recurrence()->doesRecur() ) { 712 // if ( ev->recurrence()->doesRecur() ) {
707 // if ( !needClose) 713 // if ( !needClose)
708 // mText +="("; 714 // mText +="(";
709 // mText += "r"; 715 // mText += "r";
710 // needClose =true; 716 // needClose =true;
711 // } 717 // }
712 if ( needClose ) 718 if ( needClose )
713 mText += "] "; 719 mText += "] ";
714 if ( ev->cancelled() ) 720 if ( ev->cancelled() )
715 mText += "</font>"; 721 mText += "</font>";
716 mText += "<a href=\"todo:" + ev->uid() + "\">"; 722 mText += "<a href=\"todo:" + ev->uid() + "\">";
717 if ( ev->summary().length() > 0 ) 723 if ( ev->summary().length() > 0 )
718 mText += ev->summary(); 724 mText += ev->summary();
719 else 725 else
720 mText += i18n("-no summary-"); 726 mText += i18n("-no summary-");
721 mText += "</a>"; 727 mText += "</a>";
722 if ( ((Todo*)ev)->hasDueDate () ) { 728 if ( ((Todo*)ev)->hasDueDate () ) {
723 QString year = ""; 729 QString year = "";
724 int ye = ((Todo*)ev)->dtDue().date().year(); 730 int ye = ((Todo*)ev)->dtDue().date().year();
725 if ( QDateTime::currentDateTime().date().year() != ye ) 731 if ( QDateTime::currentDateTime().date().year() != ye )
726 year = QString::number( ye ); 732 year = QString::number( ye );
727 QString dfs = KGlobal::locale()->dateFormatShort(); 733 QString dfs = KGlobal::locale()->dateFormatShort();
728 KGlobal::locale()->setDateFormatShort("%d.%b"); 734 KGlobal::locale()->setDateFormatShort("%d.%b");
729 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; 735 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
730 KGlobal::locale()->setDateFormatShort(dfs); 736 KGlobal::locale()->setDateFormatShort(dfs);
731 } 737 }
732 if ( KOPrefs::instance()->mWNViewShowLocation ) 738 if ( KOPrefs::instance()->mWNViewShowLocation )
733 if ( !ev->location().isEmpty() ) 739 if ( !ev->location().isEmpty() )
734 mText += " ("+ev->location() +")"; 740 mText += " ("+ev->location() +")";
735 if ( !isSub ) { 741 if ( !isSub ) {
736 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 742 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
737 mText += " ["+ev->relatedTo()->summary() +"]"; 743 mText += " ["+ev->relatedTo()->summary() +"]";
738 mText += "</p>\n"; 744 mText += "</p>\n";
739 } 745 }
740 else { 746 else {
741 ind += "-"; 747 ind += "-";
742 mText += "</li>\n"; 748 mText += "</li>\n";
743 } 749 }
744 QPtrList<Incidence> Relations = ev->relations(); 750 Q3PtrList<Incidence> Relations = ev->relations();
745 Incidence *to; 751 Incidence *to;
746 for (to=Relations.first();to;to=Relations.next()) { 752 for (to=Relations.first();to;to=Relations.next()) {
747 if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) 753 if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio )
748 appendTodo( to, ind , true ); 754 appendTodo( to, ind , true );
749 } 755 }
750 756
751 return true; 757 return true;
752} 758}
753 759
754/* 760/*
755 void KOWhatsNextView::createEventViewer() 761 void KOWhatsNextView::createEventViewer()
756 { 762 {
757 if (!mEventViewer) { 763 if (!mEventViewer) {
758 764
759 mEventViewer = new KOEventViewerDialog(this); 765 mEventViewer = new KOEventViewerDialog(this);
760 } 766 }
761 } 767 }
762*/ 768*/
763void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 769void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
764{ 770{
765 mEventViewer = v; 771 mEventViewer = v;
766} 772}
767 773
768// TODO: Create this function in CalendarView and remove it from here 774// TODO: Create this function in CalendarView and remove it from here
769void KOWhatsNextView::showIncidence(const QString &uid) 775void KOWhatsNextView::showIncidence(const QString &uid)
770{ 776{
771 777
772 if ( !mEventViewer ) { 778 if ( !mEventViewer ) {
773 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 779 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
774 return; 780 return;
775 } 781 }
776 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 782 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
777 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 783 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
778 if (uid.startsWith("event:")) { 784 if (uid.startsWith("event:")) {
779#ifdef DESKTOP_VERSION 785#ifdef DESKTOP_VERSION
780 Event *event = calendar()->event(uid.mid(8)); 786 Event *event = calendar()->event(uid.mid(8));
781#else 787#else
782 Event *event = calendar()->event(uid.mid(6)); 788 Event *event = calendar()->event(uid.mid(6));
783#endif 789#endif
784 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 790 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
785 if (!event) return; 791 if (!event) return;
786 //createEventViewer(); 792 //createEventViewer();
787 mEventViewer->setEvent(event); 793 mEventViewer->setEvent(event);
788 } else if (uid.startsWith("todo:")) { 794 } else if (uid.startsWith("todo:")) {
789#ifdef DESKTOP_VERSION 795#ifdef DESKTOP_VERSION
790 Todo *todo = calendar()->todo(uid.mid(7)); 796 Todo *todo = calendar()->todo(uid.mid(7));
791#else 797#else
792 Todo *todo = calendar()->todo(uid.mid(5)); 798 Todo *todo = calendar()->todo(uid.mid(5));