- Added feature #415, which supports displaying just a single page of tasks,
  by specifying either 'limit:page' to a command, or 'report.xxx.limit:page'
  in a report specification (thanks to T. Charles Yun).
- Modified the 'next' report to only display a page, by default.
This commit is contained in:
Paul Beckingham
2010-06-20 17:32:11 -04:00
parent 2f85941d37
commit 916b8641b3
13 changed files with 239 additions and 28 deletions

View File

@@ -1024,10 +1024,13 @@ void Table::clean (std::string& value)
}
////////////////////////////////////////////////////////////////////////////////
const std::string Table::render (int maximum /* = 0 */)
const std::string Table::render (int maxrows /* = 0 */, int maxlines /* = 0 */)
{
Timer t ("Table::render");
// May not exceed maxlines, if non-zero.
int renderedlines = 0;
calculateColumnWidths ();
// Print column headers in column order.
@@ -1048,8 +1051,12 @@ const std::string Table::render (int maximum /* = 0 */)
}
output += "\n";
++renderedlines;
if (underline.length ())
{
output += underline + "\n";
++renderedlines;
}
// Determine row order, according to sort options.
std::vector <int> order;
@@ -1060,14 +1067,17 @@ const std::string Table::render (int maximum /* = 0 */)
if (mSortColumns.size ())
sort (order);
// If a non-zero maximum is specified, then it limits the number of rows of
// If a non-zero maxrows is specified, then it limits the number of rows of
// the table that are rendered.
int limit = mRows;
if (maximum != 0)
limit = min (maximum, mRows);
int limitrows = mRows;
if (maxrows != 0)
limitrows = min (maxrows, mRows);
// If a non-zero maxlines is specified, then it limits the number of lines
// of output from the table that are rendered.
// Print all rows.
for (int row = 0; row < limit; ++row)
for (int row = 0; row < limitrows; ++row)
{
std::vector <std::vector <std::string> > columns;
std::vector <std::string> blanks;
@@ -1105,6 +1115,11 @@ const std::string Table::render (int maximum /* = 0 */)
// Trim right.
output.erase (output.find_last_not_of (" ") + 1);
output += "\n";
++renderedlines;
if (maxlines != 0 && renderedlines >= maxlines)
break;
}
}
else
@@ -1113,6 +1128,9 @@ const std::string Table::render (int maximum /* = 0 */)
output.erase (output.find_last_not_of (" ") + 1);
output += "\n";
}
if (maxlines != 0 && renderedlines >= maxlines)
break;
}
optimize (output);