26 #include <tqtextbrowser.h>
27 #include <tqtextcodec.h>
28 #include <tqfileinfo.h>
31 #include <tdeglobal.h>
32 #include <tdelocale.h>
34 #include <kiconloader.h>
35 #include <tdemessagebox.h>
38 #include <libkcal/incidenceformatter.h>
40 #include "koglobals.h"
42 #include "koeventviewerdialog.h"
44 #include "kowhatsnextview.h"
48 void WhatsNextTextBrowser::setSource(
const TQString& n)
50 kdDebug(5850) <<
"WhatsNextTextBrowser::setSource(): " << n << endl;
52 if (n.startsWith(
"event:")) {
53 emit showIncidence(n);
55 }
else if (n.startsWith(
"todo:")) {
56 emit showIncidence(n);
59 TQTextBrowser::setSource(n);
63 KOWhatsNextView::KOWhatsNextView(
Calendar *calendar, TQWidget *parent,
65 : KOrg::
BaseView(calendar, parent, name)
72 mView =
new WhatsNextTextBrowser(
this);
73 connect(mView,TQ_SIGNAL(showIncidence(
const TQString &)),TQ_SLOT(showIncidence(
const TQString &)));
75 TQBoxLayout *topLayout =
new TQVBoxLayout(
this);
77 topLayout->addWidget(mView);
80 KOWhatsNextView::~KOWhatsNextView()
86 return mStartDate.daysTo( mEndDate );
89 void KOWhatsNextView::updateView()
91 TDEIconLoader kil(
"tdepim");
92 TQString *ipath =
new TQString();
93 kil.loadIcon(
"tdepim",TDEIcon::NoGroup,32,TDEIcon::DefaultState,ipath);
95 mText =
"<table width=\"100%\">\n";
96 mText +=
"<tr bgcolor=\"#3679AD\"><td><h1>";
97 mText +=
"<img src=\"";
100 mText +=
"<font color=\"white\"> ";
101 mText += i18n(
"What's Next?") +
"</font></h1>";
102 mText +=
"</td></tr>\n<tr><td>";
105 if ( mStartDate.daysTo( mEndDate ) < 1 ) {
106 mText += TDEGlobal::locale()->formatDate( mStartDate );
108 mText += i18n(
"Date from - to",
"%1 - %2")
109 .arg( TDEGlobal::locale()->formatDate( mStartDate ) )
110 .arg( TDEGlobal::locale()->formatDate( mEndDate ) );
115 for ( TQDate date = mStartDate; date <= mEndDate; date = date.addDays( 1 ) )
116 events +=
calendar()->
events(date, EventSortStartDate, SortDirectionAscending);
118 if (events.count() > 0) {
120 kil.loadIcon(
"appointment",TDEIcon::NoGroup,22,TDEIcon::DefaultState,ipath);
121 mText +=
"<h2><img src=\"";
124 mText += i18n(
"Events:") +
"</h2>\n";
125 mText +=
"<table>\n";
126 Event::List::ConstIterator it;
127 for( it = events.begin(); it != events.end(); ++it ) {
138 TQDateTime( mStartDate, TQTime() ) );
139 TQDateTime end = start.addSecs( duration );
140 if ( end.date() >= mStartDate ) {
141 appendEvent( ev, start, end );
144 while ( start.isValid() && start.date() <= mEndDate ) {
145 appendEvent( ev, start );
150 mText +=
"</table>\n";
154 Todo::List todos =
calendar()->
todos( TodoSortDueDate, SortDirectionAscending );
155 if ( todos.count() > 0 ) {
156 kil.loadIcon(
"todo",TDEIcon::NoGroup,22,TDEIcon::DefaultState,ipath);
157 mText +=
"<h2><img src=\"";
160 mText += i18n(
"To-do:") +
"</h2>\n";
162 Todo::List::ConstIterator it;
163 for( it = todos.begin(); it != todos.end(); ++it ) {
170 while (!gotone && priority<=9 ) {
171 for( it = todos.begin(); it != todos.end(); ++it ) {
179 kdDebug(5850) <<
"adding the todos..." << endl;
184 TQStringList myEmails( KOPrefs::instance()->allEmails() );
186 events =
calendar()->
events( TQDate::currentDate(), TQDate(2975,12,6) );
187 Event::List::ConstIterator it2;
188 for( it2 = events.begin(); it2 != events.end(); ++it2 ) {
192 if (me->
status()==Attendee::NeedsAction && me->
RSVP()) {
195 kil.loadIcon(
"reply",TDEIcon::NoGroup,22,TDEIcon::DefaultState,ipath);
196 mText +=
"<h2><img src=\"";
199 mText += i18n(
"Events and to-dos that need a reply:") +
"</h2>\n";
200 mText +=
"<table>\n";
208 Todo::List::ConstIterator it3;
209 for( it3 = todos.begin(); it3 != todos.end(); ++it3 ) {
213 if (me->
status()==Attendee::NeedsAction && me->
RSVP()) {
216 kil.loadIcon(
"reply",TDEIcon::NoGroup,22,TDEIcon::DefaultState,ipath);
217 mText +=
"<h2><img src=\"";
220 mText += i18n(
"Events and to-dos that need a reply:") +
"</h2>\n";
221 mText +=
"<table>\n";
227 kdDebug () <<
"check for todo-replies..." << endl;
229 if (replies > 0 ) mText +=
"</table>\n";
232 mText +=
"</td></tr>\n</table>\n";
234 kdDebug(5850) <<
"KOWhatsNextView::updateView: text: " << mText << endl;
238 mView->setText(mText);
241 void KOWhatsNextView::showDates(
const TQDate &start,
const TQDate &end )
248 void KOWhatsNextView::showIncidences(
const Incidence::List &,
const TQDate & )
252 void KOWhatsNextView::changeIncidenceDisplay(
Incidence *,
int action)
255 case KOGlobals::INCIDENCEADDED:
256 case KOGlobals::INCIDENCEEDITED:
257 case KOGlobals::INCIDENCEDELETED:
261 kdDebug(5850) <<
"KOWhatsNextView::changeIncidenceDisplay(): Illegal action " << action << endl;
265 void KOWhatsNextView::appendEvent(
Incidence *ev,
const TQDateTime &start,
266 const TQDateTime &end )
268 kdDebug(5850) <<
"KOWhatsNextView::appendEvent(): " << ev->
uid() << endl;
270 mText +=
"<tr><td><b>";
272 if (ev->type()==
"Event") {
274 TQDateTime starttime( start );
275 if ( !starttime.isValid() )
276 starttime =
event->dtStart();
277 TQDateTime endtime( end );
278 if ( !endtime.isValid() )
279 endtime = starttime.addSecs(
280 event->dtStart().secsTo( event->dtEnd() ) );
282 if ( starttime.date().daysTo( endtime.date() ) >= 1 ) {
283 mText += i18n(
"date from - to",
"%1 - %2")
284 .arg( TDEGlobal::locale()->formatDateTime( starttime ) )
285 .arg( TDEGlobal::locale()->formatDateTime( endtime ) );
288 mText += i18n(
"date, from - to",
"%1, %2 - %3")
289 .arg( TDEGlobal::locale()->formatDate( starttime.date(),
true ) )
290 .arg( TDEGlobal::locale()->formatTime( starttime.time() ) )
291 .arg( TDEGlobal::locale()->formatTime( endtime.time() ) );
295 mText +=
"</b></td><td><a ";
296 if (ev->type()==
"Event") mText +=
"href=\"event:";
297 if (ev->type()==
"Todo") mText +=
"href=\"todo:";
298 mText += ev->
uid() +
"\">";
300 mText +=
"</a></td></tr>\n";
303 void KOWhatsNextView::appendTodo(
Incidence *ev )
305 if ( mTodos.find( ev ) != mTodos.end() )
return;
309 mText +=
"<li><a href=\"todo:" + ev->
uid() +
"\">";
313 if ( ev->type()==
"Todo" ) {
314 Todo *todo =
static_cast<Todo*
>(ev);
316 mText += i18n(
" (Due: %1)" ).
317 arg( IncidenceFormatter::dateTimeToString( todo->
dtDue(), todo->
doesFloat() ) );
323 void KOWhatsNextView::showIncidence(
const TQString &uid )
325 kdDebug(5850) <<
"KOWhatsNextView::showIncidence(): " << uid << endl;
328 if ( uid.startsWith(
"event://" ) ) {
330 }
else if ( uid.startsWith(
"todo://" ) ) {
338 #include "kowhatsnextview.moc"
virtual Event::List events(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
Incidence * incidence(const TQString &uid)
virtual Todo::List todos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
virtual TQDateTime dtEnd() const
Attendee * attendeeByMails(const TQStringList &, const TQString &email=TQString()) const
virtual TQDateTime dtStart() const
Recurrence * recurrence() const
TQDateTime getPreviousDateTime(const TQDateTime &afterDateTime) const
TQDateTime getNextDateTime(const TQDateTime &preDateTime) const
TQDateTime dtDue(bool first=false) const
virtual int currentDateCount()
Return number of currently shown dates.
This class provides an interface for all views being displayed within the main calendar view.
void showIncidenceSignal(Incidence *, const TQDate &)
instructs the receiver to show the incidence in read-only mode.
virtual Calendar * calendar()
Return calendar object of this view.