diff --git a/src/Context.cpp b/src/Context.cpp index 8ba0f64db..b2ed08e82 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -162,9 +162,7 @@ std::string Context::dispatch () int gcMod = 0; // Change occurred by way of gc. std::string out; - // TODO Look at this thing. It just cries out for a dispatch table. -/* -*/ + // TODO Just look at this thing. It just cries out for a dispatch table. if (cmd.command == "projects") { out = handleProjects (); } else if (cmd.command == "tags") { out = handleTags (); } else if (cmd.command == "colors") { out = handleColor (); } @@ -175,9 +173,7 @@ std::string Context::dispatch () else if (cmd.command == "history") { out = handleReportHistory (); } else if (cmd.command == "ghistory") { out = handleReportGHistory (); } else if (cmd.command == "summary") { out = handleReportSummary (); } -/* else if (cmd.command == "calendar") { out = handleReportCalendar (); } -*/ else if (cmd.command == "timesheet") { out = handleReportTimesheet (); } else if (cmd.command == "add") { out = handleAdd (); } /* diff --git a/src/report.cpp b/src/report.cpp index 84faa462c..0b59caeaf 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -1473,9 +1473,6 @@ std::string renderMonths ( //////////////////////////////////////////////////////////////////////////////// std::string handleReportCalendar () { - std::stringstream out; - -/* // Each month requires 28 text columns width. See how many will actually // fit. But if a preference is specified, and it fits, use it. int width = context.getWidth (); @@ -1486,21 +1483,21 @@ std::string handleReportCalendar () if (preferredMonthsPerLine != 0 && preferredMonthsPerLine < monthsThatFit) monthsPerLine = preferredMonthsPerLine; - // Load all the pending tasks. - std::vector pending; - tdb.allPendingT (pending); - handleRecurrence (tdb, pending); - filter (pending, task); + // Get all the tasks. + std::vector tasks; + context.tdb.lock (context.config.get ("locking", true)); + context.tdb.loadPending (tasks, context.filter); + context.tdb.unlock (); + // TODO handleRecurrence (tdb, tasks); // Find the oldest pending due date. Date oldest; Date newest; - std::vector ::iterator it; - for (it = pending.begin (); it != pending.end (); ++it) + foreach (task, tasks) { - if (it->has ("due")) + if (task->has ("due")) { - Date d (::atoi (it->get ("due").c_str ())); + Date d (::atoi (task->get ("due").c_str ())); if (d < oldest) oldest = d; if (d > newest) newest = d; @@ -1515,6 +1512,7 @@ std::string handleReportCalendar () int mTo = newest.month (); int yTo = newest.year (); + std::stringstream out; out << std::endl; std::string output; @@ -1562,7 +1560,7 @@ std::string handleReportCalendar () out << std::endl << optionalBlankLine () - << renderMonths (mFrom, yFrom, today, pending, monthsPerLine) + << renderMonths (mFrom, yFrom, today, tasks, monthsPerLine) << std::endl; mFrom += monthsPerLine; @@ -1583,7 +1581,7 @@ std::string handleReportCalendar () << "." << optionalBlankLine () << std::endl; -*/ + return out.str (); }