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