summaryrefslogtreecommitdiffabout
path: root/korganizer/kowhatsnextview.cpp
Unidiff
Diffstat (limited to 'korganizer/kowhatsnextview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kowhatsnextview.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 53fe7d0..8473db9 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -145,96 +145,97 @@ QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
145{ 145{
146 QPtrList<Incidence> eventList; 146 QPtrList<Incidence> eventList;
147 147
148 return eventList; 148 return eventList;
149} 149}
150 150
151void KOWhatsNextView::printMe() 151void KOWhatsNextView::printMe()
152{ 152{
153#ifdef DESKTOP_VERSION 153#ifdef DESKTOP_VERSION
154 mView->printMe(); 154 mView->printMe();
155#endif 155#endif
156} 156}
157void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 157void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
158 const QDate &td) 158 const QDate &td)
159{ 159{
160#ifndef KORG_NOPRINTER 160#ifndef KORG_NOPRINTER
161 calPrinter->preview(CalPrinter::Day, fd, td); 161 calPrinter->preview(CalPrinter::Day, fd, td);
162#endif 162#endif
163} 163}
164void KOWhatsNextView::updateConfig() 164void KOWhatsNextView::updateConfig()
165{ 165{
166 setFont( KOPrefs::instance()->mWhatsNextFont ); 166 setFont( KOPrefs::instance()->mWhatsNextFont );
167 updateView(); 167 updateView();
168 168
169} 169}
170void KOWhatsNextView::showEvent ( QShowEvent * e ) 170void KOWhatsNextView::showEvent ( QShowEvent * e )
171{ 171{
172 //qDebug("KOWhatsNextView::showEvent "); 172 //qDebug("KOWhatsNextView::showEvent ");
173 restartTimer(); 173 restartTimer();
174 QWidget::showEvent ( e ); 174 QWidget::showEvent ( e );
175} 175}
176void KOWhatsNextView::hideEvent ( QHideEvent * e) 176void KOWhatsNextView::hideEvent ( QHideEvent * e)
177{ 177{
178 //qDebug(" KOWhatsNextView::hideEvent"); 178 //qDebug(" KOWhatsNextView::hideEvent");
179 mTimer->stop(); 179 mTimer->stop();
180 QWidget::hideEvent ( e ); 180 QWidget::hideEvent ( e );
181} 181}
182void KOWhatsNextView::restartTimer() 182void KOWhatsNextView::restartTimer()
183{ 183{
184 //qDebug("KOWhatsNextView::restartTimer() "); 184 //qDebug("KOWhatsNextView::restartTimer() ");
185 mTimer->start( 300000 ); 185 mTimer->start( 300000 );
186 //mTimer->start( 5000 ); 186 //mTimer->start( 5000 );
187} 187}
188void KOWhatsNextView::updateView() 188void KOWhatsNextView::updateView()
189{ 189{
190 //qDebug("KOWhatsNextView::updateView() "); 190 //qDebug("KOWhatsNextView::updateView() ");
191 if ( mTimer->isActive() ) 191 if ( mTimer->isActive() )
192 restartTimer(); 192 restartTimer();
193 mCurrentMaxPrio = 5;
193 //qDebug("KOWhatsNextView::updateView() "); 194 //qDebug("KOWhatsNextView::updateView() ");
194 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 195 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
195 KIconLoader kil("korganizer"); 196 KIconLoader kil("korganizer");
196 QString ipath;// = new QString(); 197 QString ipath;// = new QString();
197 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 198 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
198 //<big><big><strong>" + date + "</strong></big></big>\n"; 199 //<big><big><strong>" + date + "</strong></big></big>\n";
199 mText = "<table width=\"100%\">\n"; 200 mText = "<table width=\"100%\">\n";
200 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 201 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
201#ifdef DESKTOP_VERSION 202#ifdef DESKTOP_VERSION
202 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 203 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
203#else 204#else
204 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 205 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
205#endif 206#endif
206 // mText += "<img src=\""; 207 // mText += "<img src=\"";
207 // mText += ipath; 208 // mText += ipath;
208 // mText += "\">"; 209 // mText += "\">";
209 mEventDate = QDate::currentDate(); 210 mEventDate = QDate::currentDate();
210#ifdef DESKTOP_VERSION 211#ifdef DESKTOP_VERSION
211 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 212 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
212#else 213#else
213 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 214 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
214#endif 215#endif
215 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 216 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
216 int iii; 217 int iii;
217 mTodos.clear(); 218 mTodos.clear();
218 QPtrList<Event> events; 219 QPtrList<Event> events;
219 QPtrList<Todo> todos = calendar()->todos(); 220 QPtrList<Todo> todos = calendar()->todos();
220 Todo * todo; 221 Todo * todo;
221 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 222 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
222 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 223 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
223 bool itemAdded = false; 224 bool itemAdded = false;
224 for ( iii = 0; iii < daysToShow; ++iii ) { 225 for ( iii = 0; iii < daysToShow; ++iii ) {
225 QString date; 226 QString date;
226 itemAdded = false; 227 itemAdded = false;
227 events = calendar()->events( mEventDate, true ); 228 events = calendar()->events( mEventDate, true );
228 229
229 if ( iii == 0 ) { // today !!! 230 if ( iii == 0 ) { // today !!!
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 } //bool reply=false, bool notRed = true, bool appendTable = false); 238 } //bool reply=false, bool notRed = true, bool appendTable = false);
238 appendEvent(todo, false, false, !itemAdded ); 239 appendEvent(todo, false, false, !itemAdded );
239 itemAdded = true; 240 itemAdded = true;
240 } 241 }
@@ -273,96 +274,97 @@ void KOWhatsNextView::updateView()
273 274
274 todo = todos.first(); 275 todo = todos.first();
275 while(todo) { 276 while(todo) {
276 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { 277 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
277 if ( ! itemAdded ) { 278 if ( ! itemAdded ) {
278 appendDay ( iii, mEventDate ); 279 appendDay ( iii, mEventDate );
279 //itemAdded = true; 280 //itemAdded = true;
280 } 281 }
281 appendEvent(todo, false , iii!= 0,!itemAdded); 282 appendEvent(todo, false , iii!= 0,!itemAdded);
282 itemAdded = true; 283 itemAdded = true;
283 } 284 }
284 todo = todos.next(); 285 todo = todos.next();
285 } 286 }
286 if ( !itemAdded && iii == 0 ) { 287 if ( !itemAdded && iii == 0 ) {
287 // appendDay ( iii, mEventDate ); 288 // appendDay ( iii, mEventDate );
288 //mText += "<table>"; 289 //mText += "<table>";
289 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; 290 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n";
290 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; 291 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n";
291 //mText +="</table>"; 292 //mText +="</table>";
292 } 293 }
293 if ( itemAdded ) 294 if ( itemAdded )
294 mText += "</table>\n"; 295 mText += "</table>\n";
295 mEventDate = mEventDate.addDays( 1 ); 296 mEventDate = mEventDate.addDays( 1 );
296 } 297 }
297 298
298 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; 299 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios;
299 if (todos.count() > 0 && topmostPrios > 0 ) { 300 if (todos.count() > 0 && topmostPrios > 0 ) {
300 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 301 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
301 // mText += "<h2>"; 302 // mText += "<h2>";
302 //<img src=\""; 303 //<img src=\"";
303 // mText += ipath; 304 // mText += ipath;
304 // mText += "\">"; 305 // mText += "\">";
305 // mText += i18n("Overdue To-Do:") + "</h2>\n"; 306 // mText += i18n("Overdue To-Do:") + "</h2>\n";
306 307
307 //mText += "<ul>\n"; 308 //mText += "<ul>\n";
308 bool gotone = false; 309 bool gotone = false;
309 int priority = 1; 310 int priority = 1;
310 int priosFound = 0; 311 int priosFound = 0;
311#ifdef DESKTOP_VERSION 312#ifdef DESKTOP_VERSION
312 mText +="<p></p>"; 313 mText +="<p></p>";
313#endif 314#endif
314 315
315 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; 316 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n";
316 mText += "<ul>\n"; 317 mText += "<ul>\n";
317 while (!gotone && priority<6) { 318 while (!gotone && priority<6) {
318 todo = todos.first(); 319 todo = todos.first();
319 while(todo) { 320 while(todo) {
320 if (!todo->isCompleted() && (todo->priority() == priority) ) { 321 if (!todo->isCompleted() && (todo->priority() == priority) ) {
322 mCurrentMaxPrio = priority - priosFound + topmostPrios -1;
321 if ( appendTodo(todo) ) 323 if ( appendTodo(todo) )
322 gotone = true; 324 gotone = true;
323 } 325 }
324 todo = todos.next(); 326 todo = todos.next();
325 } 327 }
326 if ( gotone ) { 328 if ( gotone ) {
327 gotone = false; 329 gotone = false;
328 ++priosFound; 330 ++priosFound;
329 if ( priosFound == topmostPrios ) 331 if ( priosFound == topmostPrios )
330 break; 332 break;
331 } 333 }
332 priority++; 334 priority++;
333 // kdDebug() << "adding the todos..." << endl; 335 // kdDebug() << "adding the todos..." << endl;
334 } 336 }
335 mText += "</ul>\n"; 337 mText += "</ul>\n";
336 } 338 }
337 339
338 int replys = 0; 340 int replys = 0;
339 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); 341 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6));
340 if (events.count() > 0) { 342 if (events.count() > 0) {
341 Event *ev = events.first(); 343 Event *ev = events.first();
342 while(ev) { 344 while(ev) {
343 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 345 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
344 if (me!=0) { 346 if (me!=0) {
345 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 347 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
346 if (replys == 0) { 348 if (replys == 0) {
347 mText += "<p></p>"; 349 mText += "<p></p>";
348 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 350 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
349 //mText += "<h2>"; 351 //mText += "<h2>";
350 //<img src=\""; 352 //<img src=\"";
351 // mText += ipath; 353 // mText += ipath;
352 // mText += "\">"; 354 // mText += "\">";
353 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 355 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
354 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 356 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
355 mText += "<table>\n"; 357 mText += "<table>\n";
356 } 358 }
357 replys++; 359 replys++;
358 appendEvent(ev,true); 360 appendEvent(ev,true);
359 } 361 }
360 } 362 }
361 ev = events.next(); 363 ev = events.next();
362 } 364 }
363 } 365 }
364 todos = calendar()->todos(); 366 todos = calendar()->todos();
365 if (todos.count() > 0) { 367 if (todos.count() > 0) {
366 Todo *to = todos.first(); 368 Todo *to = todos.first();
367 while(to) { 369 while(to) {
368 if ( !to->isCompleted() ){ 370 if ( !to->isCompleted() ){
@@ -680,97 +682,97 @@ bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
680 } 682 }
681 if ( ev->doesRecur() ) { 683 if ( ev->doesRecur() ) {
682 if ( !needClose) 684 if ( !needClose)
683 mText +="["; 685 mText +="[";
684 mText += "r"; 686 mText += "r";
685 needClose =true; 687 needClose =true;
686 } 688 }
687 // if ( ev->recurrence()->doesRecur() ) { 689 // if ( ev->recurrence()->doesRecur() ) {
688 // if ( !needClose) 690 // if ( !needClose)
689 // mText +="("; 691 // mText +="(";
690 // mText += "r"; 692 // mText += "r";
691 // needClose =true; 693 // needClose =true;
692 // } 694 // }
693 if ( needClose ) 695 if ( needClose )
694 mText += "] "; 696 mText += "] ";
695 if ( ev->cancelled() ) 697 if ( ev->cancelled() )
696 mText += "</font>"; 698 mText += "</font>";
697 mText += "<a href=\"todo:" + ev->uid() + "\">"; 699 mText += "<a href=\"todo:" + ev->uid() + "\">";
698 if ( ev->summary().length() > 0 ) 700 if ( ev->summary().length() > 0 )
699 mText += ev->summary(); 701 mText += ev->summary();
700 else 702 else
701 mText += i18n("-no summary-"); 703 mText += i18n("-no summary-");
702 mText += "</a>"; 704 mText += "</a>";
703 if ( ((Todo*)ev)->hasDueDate () ) { 705 if ( ((Todo*)ev)->hasDueDate () ) {
704 QString year = ""; 706 QString year = "";
705 int ye = ((Todo*)ev)->dtDue().date().year(); 707 int ye = ((Todo*)ev)->dtDue().date().year();
706 if ( QDateTime::currentDateTime().date().year() != ye ) 708 if ( QDateTime::currentDateTime().date().year() != ye )
707 year = QString::number( ye ); 709 year = QString::number( ye );
708 QString dfs = KGlobal::locale()->dateFormatShort(); 710 QString dfs = KGlobal::locale()->dateFormatShort();
709 KGlobal::locale()->setDateFormatShort("%d.%b"); 711 KGlobal::locale()->setDateFormatShort("%d.%b");
710 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; 712 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
711 KGlobal::locale()->setDateFormatShort(dfs); 713 KGlobal::locale()->setDateFormatShort(dfs);
712 } 714 }
713 if ( KOPrefs::instance()->mWNViewShowLocation ) 715 if ( KOPrefs::instance()->mWNViewShowLocation )
714 if ( !ev->location().isEmpty() ) 716 if ( !ev->location().isEmpty() )
715 mText += " ("+ev->location() +")"; 717 mText += " ("+ev->location() +")";
716 if ( !isSub ) { 718 if ( !isSub ) {
717 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 719 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
718 mText += " ["+ev->relatedTo()->summary() +"]"; 720 mText += " ["+ev->relatedTo()->summary() +"]";
719 mText += "</p>\n"; 721 mText += "</p>\n";
720 } 722 }
721 else { 723 else {
722 ind += "-"; 724 ind += "-";
723 mText += "</li>\n"; 725 mText += "</li>\n";
724 } 726 }
725 QPtrList<Incidence> Relations = ev->relations(); 727 QPtrList<Incidence> Relations = ev->relations();
726 Incidence *to; 728 Incidence *to;
727 for (to=Relations.first();to;to=Relations.next()) { 729 for (to=Relations.first();to;to=Relations.next()) {
728 if (!((Todo*)to)->isCompleted()) 730 if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio )
729 appendTodo( to, ind , true ); 731 appendTodo( to, ind , true );
730 } 732 }
731 733
732 return true; 734 return true;
733} 735}
734 736
735/* 737/*
736 void KOWhatsNextView::createEventViewer() 738 void KOWhatsNextView::createEventViewer()
737 { 739 {
738 if (!mEventViewer) { 740 if (!mEventViewer) {
739 741
740 mEventViewer = new KOEventViewerDialog(this); 742 mEventViewer = new KOEventViewerDialog(this);
741 } 743 }
742 } 744 }
743*/ 745*/
744void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 746void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
745{ 747{
746 mEventViewer = v; 748 mEventViewer = v;
747} 749}
748 750
749// TODO: Create this function in CalendarView and remove it from here 751// TODO: Create this function in CalendarView and remove it from here
750void KOWhatsNextView::showIncidence(const QString &uid) 752void KOWhatsNextView::showIncidence(const QString &uid)
751{ 753{
752 754
753 if ( !mEventViewer ) { 755 if ( !mEventViewer ) {
754 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 756 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
755 return; 757 return;
756 } 758 }
757 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 759 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
758 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 760 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
759 if (uid.startsWith("event:")) { 761 if (uid.startsWith("event:")) {
760#ifdef DESKTOP_VERSION 762#ifdef DESKTOP_VERSION
761 Event *event = calendar()->event(uid.mid(8)); 763 Event *event = calendar()->event(uid.mid(8));
762#else 764#else
763 Event *event = calendar()->event(uid.mid(6)); 765 Event *event = calendar()->event(uid.mid(6));
764#endif 766#endif
765 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 767 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
766 if (!event) return; 768 if (!event) return;
767 //createEventViewer(); 769 //createEventViewer();
768 mEventViewer->setEvent(event); 770 mEventViewer->setEvent(event);
769 } else if (uid.startsWith("todo:")) { 771 } else if (uid.startsWith("todo:")) {
770#ifdef DESKTOP_VERSION 772#ifdef DESKTOP_VERSION
771 Todo *todo = calendar()->todo(uid.mid(7)); 773 Todo *todo = calendar()->todo(uid.mid(7));
772#else 774#else
773 Todo *todo = calendar()->todo(uid.mid(5)); 775 Todo *todo = calendar()->todo(uid.mid(5));
774#endif 776#endif
775 if (!todo) return; 777 if (!todo) return;
776 //createEventViewer(); 778 //createEventViewer();