From abc9aa08ec79efce041b925a93e06ba6d226f6b7 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 27 May 2008 21:03:27 -0400 Subject: [PATCH] - Fixed bug where "task projects" rendered an empty table instead of saying "no projects". --- ChangeLog | 4 ++-- src/task.cpp | 48 +++++++++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 81e31e2aa..f728f703e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,11 +4,11 @@ 1.0.0 (?) - New movie made, uploaded - Bug: assertion fails on mobile for t v - - Bug: configure.ac does not properly determine ncurses availability + + Bug: configure.ac does not properly determine ncurses availability - Bug: when run without arguments, task dumps core on Solaris 10 - Bug: Cannot seem to use the percent character in a task description - Bug: New installation "task stats" reports newest task 12/31/1969 - - Bug: New installation task projects displays header but no data - should short-circuit + + Bug: New installation task projects displays header but no data - should short-circuit + Bug: incorrect color specification in sample .taskrc file ------ reality ----------------------------------- diff --git a/src/task.cpp b/src/task.cpp index 6b6b8b4a0..71761f364 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -307,29 +307,35 @@ void handleProjects (const TDB& tdb, T& task, Config& conf) unique[task.getAttribute ("project")] += 1; } - // Render a list of project names from the map. - Table table; - table.addColumn ("Project"); - table.addColumn ("Tasks"); - - table.setColumnUnderline (0); - table.setColumnUnderline (1); - - table.setColumnJustification (1, Table::right); - - foreach (i, unique) + if (unique.size ()) { - int row = table.addRow (); - table.addCell (row, 0, i->first); - table.addCell (row, 1, i->second); - } + // Render a list of project names from the map. + Table table; + table.addColumn ("Project"); + table.addColumn ("Tasks"); - std::cout << std::endl - << table.render () - << std::endl - << unique.size () - << (unique.size () == 1 ? " project" : " projects") - << std::endl; + table.setColumnUnderline (0); + table.setColumnUnderline (1); + + table.setColumnJustification (1, Table::right); + + foreach (i, unique) + { + int row = table.addRow (); + table.addCell (row, 0, i->first); + table.addCell (row, 1, i->second); + } + + std::cout << std::endl + << table.render () + << std::endl + << unique.size () + << (unique.size () == 1 ? " project" : " projects") + << std::endl; + } + else + std::cout << "No projects." + << std::endl; } ////////////////////////////////////////////////////////////////////////////////