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