本文整理汇总了C++中ViewText::rows方法的典型用法代码示例。如果您正苦于以下问题:C++ ViewText::rows方法的具体用法?C++ ViewText::rows怎么用?C++ ViewText::rows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ViewText
的用法示例。
在下文中一共展示了ViewText::rows方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
//.........这里部分代码省略.........
int totalDeleted = 0;
int priorYear = 0;
int row = 0;
std::map <time_t, int>::iterator i;
for (i = groups.begin (); i != groups.end (); ++i)
{
row = view.addRow ();
totalAdded += addedGroup[i->first];
totalCompleted += completedGroup[i->first];
totalDeleted += deletedGroup[i->first];
Date dt (i->first);
int m, d, y;
dt.toMDY (m, d, y);
if (y != priorYear)
{
view.set (row, 0, y);
priorYear = y;
}
unsigned int addedBar = (widthOfBar * addedGroup[i->first]) / maxLine;
unsigned int completedBar = (widthOfBar * completedGroup[i->first]) / maxLine;
unsigned int deletedBar = (widthOfBar * deletedGroup[i->first]) / maxLine;
std::string bar = "";
if (context.color ())
{
std::string aBar = "";
if (addedGroup[i->first])
{
aBar = format (addedGroup[i->first]);
while (aBar.length () < addedBar)
aBar = " " + aBar;
}
std::string cBar = "";
if (completedGroup[i->first])
{
cBar = format (completedGroup[i->first]);
while (cBar.length () < completedBar)
cBar = " " + cBar;
}
std::string dBar = "";
if (deletedGroup[i->first])
{
dBar = format (deletedGroup[i->first]);
while (dBar.length () < deletedBar)
dBar = " " + dBar;
}
bar += std::string (leftOffset - aBar.length (), ' ');
bar += color_add.colorize (aBar);
bar += color_done.colorize (cBar);
bar += color_delete.colorize (dBar);
}
else
{
std::string aBar = ""; while (aBar.length () < addedBar) aBar += "+";
std::string cBar = ""; while (cBar.length () < completedBar) cBar += "X";
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += "-";
bar += std::string (leftOffset - aBar.length (), ' ');
bar += aBar + cBar + dBar;
}
view.set (row, 1, bar);
}
}
std::stringstream out;
if (view.rows ())
{
out << optionalBlankLine ()
<< view.render ()
<< "\n";
if (context.color ())
out << format (STRING_CMD_HISTORY_LEGEND,
color_add.colorize (STRING_CMD_HISTORY_ADDED),
color_done.colorize (STRING_CMD_HISTORY_COMP),
color_delete.colorize (STRING_CMD_HISTORY_DEL))
<< optionalBlankLine ()
<< "\n";
else
out << STRING_CMD_HISTORY_LEGEND_A
<< "\n";
}
else
{
context.footnote (STRING_FEEDBACK_NO_TASKS);
rc = 1;
}
output = out.str ();
return rc;
}
示例2: execute
//.........这里部分代码省略.........
else if (task->getStatus () == Task::completed)
{
++countCompleted[project];
time_t entry = strtol (task->get ("entry").c_str (), NULL, 10);
time_t end = strtol (task->get ("end").c_str (), NULL, 10);
if (entry && end)
sumEntry[project] = sumEntry[project] + (double) (end - entry);
}
}
// Create a table for output.
ViewText view;
view.width (context.getWidth ());
view.add (Column::factory ("string", STRING_CMD_SUMMARY_PROJECT));
view.add (Column::factory ("string.right", STRING_CMD_SUMMARY_REMAINING));
view.add (Column::factory ("string.right", STRING_CMD_SUMMARY_AVG_AGE));
view.add (Column::factory ("string.right", STRING_CMD_SUMMARY_COMPLETE));
view.add (Column::factory ("string.left_fixed", "0% 100%"));
Color bar_color (context.config.get ("color.summary.bar"));
Color bg_color (context.config.get ("color.summary.background"));
int barWidth = 30;
std::vector <std::string> processed;
std::map <std::string, bool>::iterator i;
for (i = allProjects.begin (); i != allProjects.end (); ++i)
{
if (countPending[i->first] > 0)
{
const std::vector <std::string> parents = extractParents (i->first);
std::vector <std::string>::const_iterator parent;
for (parent = parents.begin (); parent != parents.end (); parent++)
{
if (std::find (processed.begin (), processed.end (), *parent)
== processed.end ())
{
int row = view.addRow ();
view.set (row, 0, indentProject (*parent));
processed.push_back (*parent);
}
}
int row = view.addRow ();
view.set (row, 0, (i->first == ""
? STRING_CMD_SUMMARY_NONE
: indentProject (i->first, " ", '.')));
view.set (row, 1, countPending[i->first]);
if (counter[i->first])
view.set (row, 2, Duration ((int) (sumEntry[i->first] / (double)counter[i->first])).format ());
int c = countCompleted[i->first];
int p = countPending[i->first];
int completedBar = (c * barWidth) / (c + p);
std::string bar;
std::string subbar;
if (context.color ())
{
bar += bar_color.colorize (std::string ( completedBar, ' '));
bar += bg_color.colorize (std::string (barWidth - completedBar, ' '));
}
else
{
bar += std::string ( completedBar, '=')
+ std::string (barWidth - completedBar, ' ');
}
view.set (row, 4, bar);
char percent[12];
sprintf (percent, "%d%%", 100 * c / (c + p));
view.set (row, 3, percent);
processed.push_back (i->first);
}
}
std::stringstream out;
if (view.rows ())
{
out << optionalBlankLine ()
<< view.render ()
<< optionalBlankLine ();
if (view.rows ())
out << format (STRING_CMD_PROJECTS_SUMMARY2, view.rows ());
else
out << STRING_CMD_PROJECTS_SUMMARY;
out << "\n";
}
else {
out << STRING_CMD_PROJECTS_NO << "\n";
rc = 1;
}
output = out.str ();
return rc;
}
示例3: execute
int CmdTimesheet::execute (std::string& output)
{
int rc = 0;
// Scan the pending tasks.
handleRecurrence ();
std::vector <Task> all = context.tdb2.all_tasks ();
context.tdb2.commit ();
// What day of the week does the user consider the first?
int weekStart = Date::dayOfWeek (context.config.get ("weekstart"));
if (weekStart != 0 && weekStart != 1)
throw std::string (STRING_DATE_BAD_WEEKSTART);
// Determine the date of the first day of the most recent report.
Date today;
Date start;
start -= (((today.dayOfWeek () - weekStart) + 7) % 7) * 86400;
// Roll back to midnight.
start = Date (start.month (), start.day (), start.year ());
Date end = start + (7 * 86400);
// Determine how many reports to run.
int quantity = 1;
std::vector <std::string> words = context.a3.extract_words ();
if (words.size () == 1)
quantity = strtol (words[0].c_str (), NULL, 10);;
std::stringstream out;
for (int week = 0; week < quantity; ++week)
{
Date endString (end);
endString -= 86400;
std::string title = start.toString (context.config.get ("dateformat"))
+ " - "
+ endString.toString (context.config.get ("dateformat"));
Color bold (Color::nocolor, Color::nocolor, false, true, false);
out << "\n"
<< (context.color () ? bold.colorize (title) : title)
<< "\n";
// Render the completed table.
ViewText completed;
completed.width (context.getWidth ());
completed.add (Column::factory ("string", " "));
completed.add (Column::factory ("string", STRING_COLUMN_LABEL_PROJECT));
completed.add (Column::factory ("string.right", STRING_COLUMN_LABEL_DUE));
completed.add (Column::factory ("string", STRING_COLUMN_LABEL_DESC));
std::vector <Task>::iterator task;
for (task = all.begin (); task != all.end (); ++task)
{
// If task completed within range.
if (task->getStatus () == Task::completed)
{
Date compDate (task->get_date ("end"));
if (compDate >= start && compDate < end)
{
Color c (task->get ("fg") + " " + task->get ("bg"));
if (context.color ())
autoColorize (*task, c);
int row = completed.addRow ();
std::string format = context.config.get ("dateformat.report");
if (format == "")
format = context.config.get ("dateformat");
completed.set (row, 1, task->get ("project"), c);
if(task->has ("due"))
{
Date dt (task->get_date ("due"));
completed.set (row, 2, dt.toString (format));
}
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 (context.config.get ("dateformat"))
+ " "
+ ann->second;
completed.set (row, 3, description, c);
}
}
}
out << " " << format (STRING_CMD_TIMESHEET_DONE, completed.rows ()) << "\n";
if (completed.rows ())
out << completed.render ()
<< "\n";
//.........这里部分代码省略.........
示例4: execute
//.........这里部分代码省略.........
section = "";
for (i = all.begin (); i != all.end (); ++i)
{
std::string::size_type loc = i->find (section, 0);
if (loc != std::string::npos)
{
// Look for unrecognized.
Color color;
if (std::find (unrecognized.begin (), unrecognized.end (), *i) != unrecognized.end ())
color = error;
else if (std::find (default_values.begin (), default_values.end (), *i) != default_values.end ())
color = warning;
std::string value = context.config.get (*i);
// hide sensible information
if ( (i->substr (0, 5) == "push." ||
i->substr (0, 5) == "pull." ||
i->substr (0, 6) == "merge.") && (i->find (".uri") != std::string::npos) ) {
Uri uri (value);
uri.parse ();
value = uri.ToString ();
}
int row = view.addRow ();
view.set (row, 0, *i, color);
view.set (row, 1, value, color);
}
}
out << "\n"
<< view.render ()
<< (view.rows () == 0 ? STRING_CMD_SHOW_NONE : "")
<< (view.rows () == 0 ? "\n\n" : "\n");
if (default_values.size ())
{
out << STRING_CMD_SHOW_DIFFER;
if (context.color ())
out << " "
<< format (STRING_CMD_SHOW_DIFFER_COLOR, warning.colorize ("color"))
<< "\n\n";
}
// Display the unrecognized variables.
if (unrecognized.size ())
{
out << STRING_CMD_SHOW_UNREC << "\n";
for (i = unrecognized.begin (); i != unrecognized.end (); ++i)
out << " " << *i << "\n";
if (context.color ())
out << "\n " << format (STRING_CMD_SHOW_DIFFER_COLOR, error.colorize ("color"));
out << "\n\n";
}
out << legacyCheckForDeprecatedVariables ();
out << legacyCheckForDeprecatedColor ();
out << legacyCheckForDeprecatedColumns ();
// TODO Check for referenced but missing theme files.
// TODO Check for referenced but missing string files.
示例5: execute
//.........这里部分代码省略.........
context.columns.find (*att) == context.columns.end ())
{
row = view.addRow ();
view.set (row, 0, "[" + *att);
view.set (row, 1, task->get (*att) + "]");
}
// Create a second table, containing undo log change details.
ViewText journal;
// If an alternating row color is specified, notify the table.
if (context.color ())
{
Color alternate (context.config.get ("color.alternate"));
journal.colorOdd (alternate);
journal.intraColorOdd (alternate);
}
journal.width (context.getWidth ());
journal.add (Column::factory ("string", STRING_COLUMN_LABEL_DATE));
journal.add (Column::factory ("string", STRING_CMD_INFO_MODIFICATION));
if (context.config.getBoolean ("journal.info") &&
undo.size () > 3)
{
// Scan the undo data for entries matching this task.
std::string when;
std::string previous;
std::string current;
unsigned int i = 0;
long total_time = 0;
while (i < undo.size ())
{
when = undo[i++];
previous = "";
if (undo[i].substr (0, 3) == "old")
previous = undo[i++];
current = undo[i++];
i++; // Separator
if (current.find ("uuid:\"" + uuid) != std::string::npos)
{
if (previous != "")
{
int row = journal.addRow ();
Date timestamp (strtol (when.substr (5).c_str (), NULL, 10));
journal.set (row, 0, timestamp.toString (dateformat));
Task before (previous.substr (4));
Task after (current.substr (4));
journal.set (row, 1, taskInfoDifferences (before, after, dateformat));
// calculate the total active time
if (before.get ("start") == ""
&& after.get ("start") != "")
{
// task started
total_time -= timestamp.toEpoch ();
}
else if (((before.get ("start") != "" &&
after.get ("start") == "") ||
(before.get ("status") != "completed" &&
after.get ("status") == "completed")) &&
total_time < 0)
{
// task stopped or done
total_time += timestamp.toEpoch ();
}
}
}
}
// add now() if task is still active
if (total_time < 0)
total_time += Date ().toEpoch ();
// print total active time
if (total_time > 0)
{
row = journal.addRow ();
journal.set (row, 0, STRING_CMD_INFO_TOTAL_ACTIVE);
journal.set (row, 1, Duration (total_time).formatPrecise (),
(context.color () ? Color ("bold") : Color ()));
}
}
out << optionalBlankLine ()
<< view.render ()
<< "\n";
if (journal.rows () > 0)
out << journal.render ()
<< "\n";
}
output = out.str ();
return rc;
}