Commit 3acd1a04 authored by Aaron J. Seigo's avatar Aaron J. Seigo
Browse files

don't bother limiting the number of events shown.

the data is already there in memory, it's at most one month of data and starts from the date the user selected, and apparently users expect to see it all .. which makes sense.
while i was in there, made some minor improvements to the code (style, efficiency..)

BUG:277472
parent f8b8abac
......@@ -83,6 +83,8 @@ class CalendarPrivate
{
}
bool addDateDetailsToDisplay(QString &html, const QDate &date);
ToolButton *back;
Plasma::Label *spacer0;
Plasma::ToolButton *month;
......@@ -398,47 +400,40 @@ void Calendar::displayEvents(const QDate &date)
}
QString html;
QList<QDate> datesToProcess;
if (dateHasDetails(date)) {
datesToProcess << date;
} else {
if (d->addDateDetailsToDisplay(html, date) < 1) {
QDate dt = calendarTable()->date();
QDate end = calendarTable()->endDate();
if (dt.isValid() && end.isValid()) {
while (dt <= end) {
datesToProcess << dt;
kDebug() << "adding" << date;
d->addDateDetailsToDisplay(html, dt);
dt = dt.addDays(1);
}
}
}
int processedDetails = 0;
const int detailsMax = 5;
foreach (const QDate &d, datesToProcess) {
if (dateHasDetails(d)) {
html+= "<b>"+d.toString()+"</b>";
html+= "<ul>";
d->eventsDisplay->setText(html);
}
QStringList details = dateDetails(d);
foreach (const QString &detail, details) {
if (processedDetails<detailsMax) {
html+= "<li>"+detail+"</li>";
processedDetails++;
}
}
bool CalendarPrivate::addDateDetailsToDisplay(QString &html, const QDate &date)
{
if (!calendarTable->dateHasDetails(date)) {
kDebug() << date << "has no details, returningfalse";
return false;
}
html+= "</ul>";
}
html += "<b>" + date.toString() + "</b>";
html += "<ul>";
if (processedDetails>=detailsMax) {
break;
}
const QStringList details = calendarTable->dateDetails(date);
foreach (const QString &detail, details) {
html+= "<li>" + detail + "</li>";
}
d->eventsDisplay->setText(html);
html += "</ul>";
return true;
}
// Update the nav widgets to show the current date in the CalendarTable
......
Supports Markdown
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