From 14d3abacf48b63f4b917f9648607298efc748d84 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 19 Nov 2008 00:33:43 -0500 Subject: [PATCH] - Beginning to fill out processing of the generalized custom report. --- src/report.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/report.cpp b/src/report.cpp index 50f26257d..16ffcaf9b 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -2679,14 +2679,51 @@ std::string handleCustomReport ( Config& conf, const std::string& report) { - std::cout << "# woohoo!" << std::endl; + // Determine window size, and set table accordingly. + int width = conf.get ("defaultwidth", 80); +#ifdef HAVE_LIBNCURSES + if (conf.get ("curses", true)) + { + WINDOW* w = initscr (); + width = w->_maxx + 1; + endwin (); + } +#endif + + // Load report configuration. + std::string columnList = conf.get ("report." + report + ".columns"); + std::vector columns; + split (columns, columnList, ','); + + std::string sortList = conf.get ("report." + report + ".sort"); + std::vector sortOrder; + split (sortOrder, sortList, ','); + + std::string filter = conf.get ("report." + report + ".filter"); + + std::cout << "# columns " << columnList << std::endl + << "# sort " << sortList << std::endl + << "# filter " << filter << std::endl; + + Table table; + table.setTableWidth (width); + + // TODO Load pending tasks. + // TODO Apply filters. + // TODO Add columns. + // TODO Add data. std::stringstream out; - - // TODO Load columns. - // TODO Load sort order. - - + if (table.rowCount ()) + out << optionalBlankLine (conf) + << table.render () + << optionalBlankLine (conf) + << table.rowCount () + << (table.rowCount () == 1 ? " task" : " tasks") + << std::endl; + else + out << "No matches." + << std::endl; return out.str (); }