Commit 7aa71f9f authored by Laurent Montel's avatar Laurent Montel 😁

Don't add empty entry

parent d0c36260
......@@ -68,6 +68,18 @@ int WhatsNextView::currentDateCount() const
return mStartDate.daysTo( mEndDate );
}
void WhatsNextView::createTaskRow(KIconLoader &kil)
{
QString ipath;
kil.loadIcon( QLatin1String("view-calendar-tasks"), KIconLoader::NoGroup, 22,
KIconLoader::DefaultState, QStringList(), &ipath );
mText += QLatin1String("<h2><img src=\"");
mText += ipath;
mText += QLatin1String("\">");
mText += i18n( "To-dos:" ) + QLatin1String("</h2>\n");
mText += QLatin1String("<ul>\n");
}
void WhatsNextView::updateView()
{
KIconLoader kil( QLatin1String("korganizer") );
......@@ -146,15 +158,13 @@ void WhatsNextView::updateView()
KCalCore::Todo::List todos = calendar()->todos( KCalCore::TodoSortDueDate,
KCalCore::SortDirectionAscending );
if ( todos.count() > 0 ) {
kil.loadIcon( QLatin1String("view-calendar-tasks"), KIconLoader::NoGroup, 22,
KIconLoader::DefaultState, QStringList(), &ipath );
mText += QLatin1String("<h2><img src=\"");
mText += ipath;
mText += QLatin1String("\">");
mText += i18n( "To-dos:" ) + QLatin1String("</h2>\n");
mText += QLatin1String("<ul>\n");
bool taskHeaderWasCreated = false;
Q_FOREACH( const KCalCore::Todo::Ptr &todo, todos ) {
if ( !todo->isCompleted() && todo->hasDueDate() && todo->dtDue().date() <= mEndDate ) {
if (!taskHeaderWasCreated) {
createTaskRow(kil);
taskHeaderWasCreated = true;
}
appendTodo( todo );
}
}
......@@ -163,13 +173,19 @@ void WhatsNextView::updateView()
while ( !gotone && priority <= 9 ) {
Q_FOREACH( const KCalCore::Todo::Ptr &todo, todos ) {
if ( !todo->isCompleted() && ( todo->priority() == priority ) ) {
if (!taskHeaderWasCreated) {
createTaskRow(kil);
taskHeaderWasCreated = true;
}
appendTodo( todo );
gotone = true;
}
}
priority++;
}
mText += QLatin1String("</ul>\n");
if (taskHeaderWasCreated) {
mText += QLatin1String("</ul>\n");
}
}
QStringList myEmails( CalendarSupport::KCalPrefs::instance()->allEmails() );
......@@ -294,7 +310,6 @@ void WhatsNextView::appendTodo( const KCalCore::Incidence::Ptr &incidence )
if ( mTodos.contains( aitem ) ) {
return;
}
mTodos.append( aitem );
mText += QLatin1String("<li><a href=\"todo:") + incidence->uid() + QLatin1String("\">");
mText += incidence->summary();
......
......@@ -29,6 +29,7 @@
#include <Akonadi/Calendar/IncidenceChanger>
#include <Akonadi/Calendar/ETMCalendar>
#include <KTextBrowser>
#include <kiconloader.h>
namespace EventViews {
......@@ -77,6 +78,7 @@ class EVENTVIEWS_EXPORT WhatsNextView : public EventViews::EventView
void showIncidence( const QString & );
private:
void createTaskRow(KIconLoader &kil);
KTextBrowser *mView;
QString mText;
QDate mStartDate;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment