本文整理汇总了C++中ViewText::colorOdd方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewText::colorOdd方法的具体用法?C++ ViewText::colorOdd怎么用?C++ ViewText::colorOdd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewText
的用法示例。
在下文中一共展示了ViewText::colorOdd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
int CmdReports::execute (std::string& output)
{
std::vector <std::string> reports;
// Add custom reports.
std::vector <std::string> vars;
context.config.all (vars);
std::vector <std::string>::iterator i;
for (i = vars.begin (); i != vars.end (); ++i)
{
if (i->substr (0, 7) == "report.")
{
std::string report = i->substr (7);
std::string::size_type columns = report.find (".columns");
if (columns != std::string::npos)
reports.push_back (report.substr (0, columns));
}
}
// Add known reports.
reports.push_back ("burndown.daily");
reports.push_back ("burndown.monthly");
reports.push_back ("burndown.weekly");
reports.push_back ("ghistory.annual");
reports.push_back ("ghistory.monthly");
reports.push_back ("history.annual");
reports.push_back ("history.monthly");
reports.push_back ("information");
reports.push_back ("projects");
reports.push_back ("summary");
reports.push_back ("tags");
std::sort (reports.begin (), reports.end ());
// Compose the output.
std::stringstream out;
ViewText view;
view.width (context.getWidth ());
view.add (Column::factory ("string", STRING_CMD_REPORTS_REPORT));
view.add (Column::factory ("string", STRING_CMD_REPORTS_DESC));
// If an alternating row color is specified, notify the table.
if (context.color ())
{
Color alternate (context.config.get ("color.alternate"));
view.colorOdd (alternate);
view.intraColorOdd (alternate);
}
std::vector <std::string>::iterator report;
for (report = reports.begin (); report != reports.end (); ++report)
{
int row = view.addRow ();
view.set (row, 0, *report);
view.set (row, 1, context.commands[*report]->description ());
}
out << optionalBlankLine ()
<< view.render ()
<< optionalBlankLine ()
<< format (STRING_CMD_REPORTS_SUMMARY, reports.size ())
<< "\n";
output = out.str ();
return 0;
}
示例2: execute
//.........这里部分代码省略.........
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_DATA_SIZE);
view.set (row, 1, formatBytes (dataSize));
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_UNDO_TXNS);
view.set (row, 1, undoCount);
if (totalT)
{
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_TAGGED);
std::stringstream value;
value << std::setprecision (3) << (100.0 * taggedT / totalT) << "%";
view.set (row, 1, value.str ());
}
if (filtered.size ())
{
Date e (earliest);
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_OLDEST);
view.set (row, 1, e.toString (dateformat));
Date l (latest);
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_NEWEST);
view.set (row, 1, l.toString (dateformat));
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_USED_FOR);
view.set (row, 1, Duration (latest - earliest).format ());
}
if (totalT)
{
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_ADD_EVERY);
view.set (row, 1, Duration (((latest - earliest) / totalT)).format ());
}
if (completedT)
{
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_COMP_EVERY);
view.set (row, 1, Duration ((latest - earliest) / completedT).format ());
}
if (deletedT)
{
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_DEL_EVERY);
view.set (row, 1, Duration ((latest - earliest) / deletedT).format ());
}
if (pendingT || completedT)
{
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_AVG_PEND);
view.set (row, 1, Duration ((int) ((daysPending / (pendingT + completedT)) * 86400)).format ());
}
if (totalT)
{
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_DESC_LEN);
view.set (row, 1, format (STRING_CMD_STATS_CHARS, (int) (descLength / totalT)));
}
/*
// TODO Re-enable this when 2.1 has taskd support. Until then, it makes no
// sense to include this.
row = view.addRow ();
view.set (row, 0, STRING_CMD_STATS_LAST_SYNCH);
if (context.tdb2.synch_key._file.exists ())
view.set (row, 1, Date (context.tdb2.synch_key._file.mtime ()).toISO ());
else
view.set (row, 1, "-");
*/
// If an alternating row color is specified, notify the table.
if (context.color ())
{
Color alternate (context.config.get ("color.alternate"));
if (alternate.nontrivial ())
{
view.colorOdd (alternate);
view.intraColorOdd (alternate);
view.extraColorOdd (alternate);
}
}
out << optionalBlankLine ()
<< view.render ()
<< optionalBlankLine ();
output = out.str ();
return rc;
}
示例3: execute
int CmdInfo::execute (std::string& output)
{
int rc = 0;
// Apply filter.
std::vector <Task> filtered;
filter (filtered);
if (! filtered.size ())
{
context.footnote (STRING_FEEDBACK_NO_MATCH);
rc = 1;
}
// Get the undo data.
std::vector <std::string> undo;
if (context.config.getBoolean ("journal.info"))
undo = context.tdb2.undo.get_lines ();
// Determine the output date format, which uses a hierarchy of definitions.
// rc.dateformat.info
// rc.dateformat
std::string dateformat = context.config.get ("dateformat.info");
if (dateformat == "")
dateformat = context.config.get ("dateformat");
std::string dateformatanno = context.config.get ("dateformat.annotation");
if (dateformatanno == "")
dateformatanno = dateformat;
// Render each task.
std::stringstream out;
std::vector <Task>::iterator task;
for (task = filtered.begin (); task != filtered.end (); ++task)
{
ViewText view;
view.width (context.getWidth ());
view.add (Column::factory ("string", STRING_COLUMN_LABEL_NAME));
view.add (Column::factory ("string", STRING_COLUMN_LABEL_VALUE));
// If an alternating row color is specified, notify the table.
if (context.color ())
{
Color alternate (context.config.get ("color.alternate"));
view.colorOdd (alternate);
view.intraColorOdd (alternate);
}
Date now;
// id
int row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_ID);
view.set (row, 1, (task->id ? format (task->id) : "-"));
std::string status = ucFirst (Task::statusToText (task->getStatus ()));
// description
Color c;
autoColorize (*task, c);
std::string description = task->get ("description");
int indent = context.config.getInteger ("indent.annotation");
std::map <std::string, std::string> annotations;
task->getAnnotations (annotations);
std::map <std::string, std::string>::iterator ann;
for (ann = annotations.begin (); ann != annotations.end (); ++ann)
description += "\n"
+ std::string (indent, ' ')
+ Date (ann->first.substr (11)).toString (dateformatanno)
+ " "
+ ann->second;
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_DESC);
view.set (row, 1, description, c);
// status
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_STATUS);
view.set (row, 1, status);
// project
if (task->has ("project"))
{
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_PROJECT);
view.set (row, 1, task->get ("project"));
}
// priority
if (task->has ("priority"))
{
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_PRIORITY);
view.set (row, 1, task->get ("priority"));
}
// dependencies: blocked
{
//.........这里部分代码省略.........