mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-06 17:37:21 +02:00
add initial bulk run from pre-commit over all files
This commit is contained in:
parent
665aeeef61
commit
93356b39c3
418 changed files with 21354 additions and 23858 deletions
|
@ -28,30 +28,26 @@
|
|||
// cmake.h include header must come first
|
||||
|
||||
#include <ColDepends.h>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
#include <stdlib.h>
|
||||
#include <utf8.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <regex>
|
||||
|
||||
#define STRING_COLUMN_LABEL_DEP "Depends"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnDepends::ColumnDepends ()
|
||||
{
|
||||
_name = "depends";
|
||||
_style = "list";
|
||||
_label = STRING_COLUMN_LABEL_DEP;
|
||||
_styles = {"list",
|
||||
"count",
|
||||
"indicator"};
|
||||
_examples = {"1 2 10",
|
||||
"[3]",
|
||||
Context::getContext ().config.get ("dependency.indicator")};
|
||||
ColumnDepends::ColumnDepends() {
|
||||
_name = "depends";
|
||||
_style = "list";
|
||||
_label = STRING_COLUMN_LABEL_DEP;
|
||||
_styles = {"list", "count", "indicator"};
|
||||
_examples = {"1 2 10", "[3]", Context::getContext().config.get("dependency.indicator")};
|
||||
|
||||
_hyphenate = false;
|
||||
}
|
||||
|
@ -59,156 +55,131 @@ ColumnDepends::ColumnDepends ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnDepends::setStyle (const std::string& value)
|
||||
{
|
||||
Column::setStyle (value);
|
||||
void ColumnDepends::setStyle(const std::string& value) {
|
||||
Column::setStyle(value);
|
||||
|
||||
if (_style == "indicator" && _label == STRING_COLUMN_LABEL_DEP) _label = _label.substr (0, Context::getContext ().config.get ("dependency.indicator").length ());
|
||||
else if (_style == "count" && _label == STRING_COLUMN_LABEL_DEP) _label = "Dep";
|
||||
if (_style == "indicator" && _label == STRING_COLUMN_LABEL_DEP)
|
||||
_label = _label.substr(0, Context::getContext().config.get("dependency.indicator").length());
|
||||
else if (_style == "count" && _label == STRING_COLUMN_LABEL_DEP)
|
||||
_label = "Dep";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnDepends::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
auto deptasks = task.getDependencyTasks ();
|
||||
auto deptasks = task.getDependencyTasks();
|
||||
|
||||
if (deptasks.size () > 0)
|
||||
{
|
||||
if (_style == "indicator")
|
||||
{
|
||||
minimum = maximum = utf8_width (Context::getContext ().config.get ("dependency.indicator"));
|
||||
if (deptasks.size() > 0) {
|
||||
if (_style == "indicator") {
|
||||
minimum = maximum = utf8_width(Context::getContext().config.get("dependency.indicator"));
|
||||
}
|
||||
|
||||
else if (_style == "count")
|
||||
{
|
||||
minimum = maximum = 2 + format ((int) deptasks.size ()).length ();
|
||||
else if (_style == "count") {
|
||||
minimum = maximum = 2 + format((int)deptasks.size()).length();
|
||||
}
|
||||
|
||||
else if (_style == "default" ||
|
||||
_style == "list")
|
||||
{
|
||||
else if (_style == "default" || _style == "list") {
|
||||
minimum = maximum = 0;
|
||||
|
||||
std::vector <int> blocking_ids;
|
||||
std::vector<int> blocking_ids;
|
||||
blocking_ids.reserve(deptasks.size());
|
||||
for (auto& i : deptasks)
|
||||
blocking_ids.push_back (i.id);
|
||||
for (auto& i : deptasks) blocking_ids.push_back(i.id);
|
||||
|
||||
auto all = join (" ", blocking_ids);
|
||||
maximum = all.length ();
|
||||
auto all = join(" ", blocking_ids);
|
||||
maximum = all.length();
|
||||
|
||||
unsigned int length;
|
||||
for (auto& i : deptasks)
|
||||
{
|
||||
length = format (i.id).length ();
|
||||
if (length > minimum)
|
||||
minimum = length;
|
||||
for (auto& i : deptasks) {
|
||||
length = format(i.id).length();
|
||||
if (length > minimum) minimum = length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnDepends::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
auto deptasks = task.getDependencyTasks ();
|
||||
void ColumnDepends::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
auto deptasks = task.getDependencyTasks();
|
||||
|
||||
if (deptasks.size () > 0)
|
||||
{
|
||||
if (_style == "indicator")
|
||||
{
|
||||
renderStringRight (lines, width, color, Context::getContext ().config.get ("dependency.indicator"));
|
||||
if (deptasks.size() > 0) {
|
||||
if (_style == "indicator") {
|
||||
renderStringRight(lines, width, color,
|
||||
Context::getContext().config.get("dependency.indicator"));
|
||||
}
|
||||
|
||||
else if (_style == "count")
|
||||
{
|
||||
renderStringRight (lines, width, color, '[' + format (static_cast <int>(deptasks.size ())) + ']');
|
||||
else if (_style == "count") {
|
||||
renderStringRight(lines, width, color, '[' + format(static_cast<int>(deptasks.size())) + ']');
|
||||
}
|
||||
|
||||
else if (_style == "default" ||
|
||||
_style == "list")
|
||||
{
|
||||
std::vector <int> blocking_ids;
|
||||
else if (_style == "default" || _style == "list") {
|
||||
std::vector<int> blocking_ids;
|
||||
blocking_ids.reserve(deptasks.size());
|
||||
for (const auto& t : deptasks)
|
||||
blocking_ids.push_back (t.id);
|
||||
for (const auto& t : deptasks) blocking_ids.push_back(t.id);
|
||||
|
||||
auto combined = join (" ", blocking_ids);
|
||||
auto combined = join(" ", blocking_ids);
|
||||
|
||||
std::vector <std::string> all;
|
||||
wrapText (all, combined, width, _hyphenate);
|
||||
std::vector<std::string> all;
|
||||
wrapText(all, combined, width, _hyphenate);
|
||||
|
||||
for (const auto& i : all)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
for (const auto& i : all) renderStringLeft(lines, width, color, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnDepends::modify (Task& task, const std::string& value)
|
||||
{
|
||||
void ColumnDepends::modify(Task& task, const std::string& value) {
|
||||
// Apply or remove dendencies in turn.
|
||||
for (auto& dep : split (value, ','))
|
||||
{
|
||||
for (auto& dep : split(value, ',')) {
|
||||
bool removal = false;
|
||||
if (dep[0] == '-')
|
||||
{
|
||||
if (dep[0] == '-') {
|
||||
removal = true;
|
||||
dep = dep.substr(1);
|
||||
}
|
||||
|
||||
auto hyphen = dep.find ('-');
|
||||
long lower, upper; // For ID ranges
|
||||
std::regex valid_uuid ("[a-f0-9]{8}([a-f0-9-]{4,28})?"); // TODO: Make more precise
|
||||
auto hyphen = dep.find('-');
|
||||
long lower, upper; // For ID ranges
|
||||
std::regex valid_uuid("[a-f0-9]{8}([a-f0-9-]{4,28})?"); // TODO: Make more precise
|
||||
|
||||
// UUID
|
||||
if (dep.length () >= 8 && std::regex_match (dep, valid_uuid))
|
||||
{
|
||||
// Full UUID, can be added directly
|
||||
if (dep.length () == 36)
|
||||
if (removal)
|
||||
task.removeDependency (dep);
|
||||
else
|
||||
task.addDependency (dep);
|
||||
if (dep.length() >= 8 && std::regex_match(dep, valid_uuid)) {
|
||||
// Full UUID, can be added directly
|
||||
if (dep.length() == 36)
|
||||
if (removal)
|
||||
task.removeDependency(dep);
|
||||
else
|
||||
task.addDependency(dep);
|
||||
|
||||
// Short UUID, need to look up full form
|
||||
else
|
||||
{
|
||||
Task loaded_task;
|
||||
if (Context::getContext ().tdb2.get (dep, loaded_task))
|
||||
if (removal)
|
||||
task.removeDependency (loaded_task.get ("uuid"));
|
||||
else
|
||||
task.addDependency (loaded_task.get ("uuid"));
|
||||
else
|
||||
throw format ("Dependency could not be set - task with UUID '{1}' does not exist.", dep);
|
||||
}
|
||||
// Short UUID, need to look up full form
|
||||
else {
|
||||
Task loaded_task;
|
||||
if (Context::getContext().tdb2.get(dep, loaded_task))
|
||||
if (removal)
|
||||
task.removeDependency(loaded_task.get("uuid"));
|
||||
else
|
||||
task.addDependency(loaded_task.get("uuid"));
|
||||
else
|
||||
throw format("Dependency could not be set - task with UUID '{1}' does not exist.", dep);
|
||||
}
|
||||
}
|
||||
// ID range
|
||||
else if (dep.find ('-') != std::string::npos &&
|
||||
extractLongInteger (dep.substr (0, hyphen), lower) &&
|
||||
extractLongInteger (dep.substr (hyphen + 1), upper))
|
||||
{
|
||||
else if (dep.find('-') != std::string::npos &&
|
||||
extractLongInteger(dep.substr(0, hyphen), lower) &&
|
||||
extractLongInteger(dep.substr(hyphen + 1), upper)) {
|
||||
for (long i = lower; i <= upper; i++)
|
||||
if (removal)
|
||||
task.removeDependency (i);
|
||||
else
|
||||
task.addDependency (i);
|
||||
if (removal)
|
||||
task.removeDependency(i);
|
||||
else
|
||||
task.addDependency(i);
|
||||
}
|
||||
// Simple ID
|
||||
else if (extractLongInteger (dep, lower))
|
||||
else if (extractLongInteger(dep, lower))
|
||||
if (removal)
|
||||
task.removeDependency (lower);
|
||||
task.removeDependency(lower);
|
||||
else
|
||||
task.addDependency (lower);
|
||||
task.addDependency(lower);
|
||||
else
|
||||
throw format ("Invalid dependency value: '{1}'", dep);
|
||||
throw format("Invalid dependency value: '{1}'", dep);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,17 +29,16 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnDepends : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnDepends ();
|
||||
class ColumnDepends : public ColumnTypeString {
|
||||
public:
|
||||
ColumnDepends();
|
||||
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
void modify (Task&, const std::string&);
|
||||
void setStyle(const std::string&);
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
void modify(Task&, const std::string&);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool _hyphenate;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,233 +28,188 @@
|
|||
// cmake.h include header must come first
|
||||
|
||||
#include <ColDescription.h>
|
||||
#include <stdlib.h>
|
||||
#include <Context.h>
|
||||
#include <Datetime.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
#include <stdlib.h>
|
||||
#include <utf8.h>
|
||||
#include <util.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnDescription::ColumnDescription ()
|
||||
{
|
||||
_name = "description";
|
||||
_style = "combined";
|
||||
_label = "Description";
|
||||
ColumnDescription::ColumnDescription() {
|
||||
_name = "description";
|
||||
_style = "combined";
|
||||
_label = "Description";
|
||||
_modifiable = true;
|
||||
|
||||
_styles = {"combined",
|
||||
"desc",
|
||||
"oneline",
|
||||
"truncated",
|
||||
"count",
|
||||
"truncated_count"};
|
||||
_styles = {"combined", "desc", "oneline", "truncated", "count", "truncated_count"};
|
||||
|
||||
_dateformat = Context::getContext ().config.get ("dateformat.annotation");
|
||||
if (_dateformat == "")
|
||||
_dateformat = Context::getContext ().config.get ("dateformat");
|
||||
_dateformat = Context::getContext().config.get("dateformat.annotation");
|
||||
if (_dateformat == "") _dateformat = Context::getContext().config.get("dateformat");
|
||||
|
||||
std::string t = Datetime ().toString (_dateformat);
|
||||
std::string d = "Move your clothes down on to the lower peg";
|
||||
std::string t = Datetime().toString(_dateformat);
|
||||
std::string d = "Move your clothes down on to the lower peg";
|
||||
std::string a1 = "Immediately before your lunch";
|
||||
std::string a2 = "If you are playing in the match this afternoon";
|
||||
std::string a3 = "Before you write your letter home";
|
||||
std::string a4 = "If you're not getting your hair cut";
|
||||
|
||||
_examples = {d + "\n " + t + ' ' + a1
|
||||
+ "\n " + t + ' ' + a2
|
||||
+ "\n " + t + ' ' + a3
|
||||
+ "\n " + t + ' ' + a4,
|
||||
d,
|
||||
d + ' ' + t + ' ' + a1
|
||||
+ ' ' + t + ' ' + a2
|
||||
+ ' ' + t + ' ' + a3
|
||||
+ ' ' + t + ' ' + a4,
|
||||
d.substr (0, 20) + "...",
|
||||
d + " [4]",
|
||||
d.substr (0, 20) + "... [4]"};
|
||||
_examples = {
|
||||
d + "\n " + t + ' ' + a1 + "\n " + t + ' ' + a2 + "\n " + t + ' ' + a3 + "\n " + t + ' ' +
|
||||
a4,
|
||||
d,
|
||||
d + ' ' + t + ' ' + a1 + ' ' + t + ' ' + a2 + ' ' + t + ' ' + a3 + ' ' + t + ' ' + a4,
|
||||
d.substr(0, 20) + "...",
|
||||
d + " [4]",
|
||||
d.substr(0, 20) + "... [4]"};
|
||||
|
||||
_hyphenate = Context::getContext ().config.getBoolean ("hyphenate");
|
||||
_hyphenate = Context::getContext().config.getBoolean("hyphenate");
|
||||
|
||||
_indent = Context::getContext ().config.getInteger ("indent.annotation");
|
||||
_indent = Context::getContext().config.getInteger("indent.annotation");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnDescription::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
std::string description = task.get (_name);
|
||||
void ColumnDescription::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
std::string description = task.get(_name);
|
||||
|
||||
// The text
|
||||
// <indent> <date> <anno>
|
||||
// ...
|
||||
if (_style == "default" ||
|
||||
_style == "combined")
|
||||
{
|
||||
minimum = longestWord (description);
|
||||
maximum = utf8_width (description);
|
||||
if (_style == "default" || _style == "combined") {
|
||||
minimum = longestWord(description);
|
||||
maximum = utf8_width(description);
|
||||
|
||||
if (task.annotation_count)
|
||||
{
|
||||
unsigned int min_anno = _indent + Datetime::length (_dateformat);
|
||||
if (min_anno > minimum)
|
||||
minimum = min_anno;
|
||||
if (task.annotation_count) {
|
||||
unsigned int min_anno = _indent + Datetime::length(_dateformat);
|
||||
if (min_anno > minimum) minimum = min_anno;
|
||||
|
||||
for (auto& i : task.getAnnotations ())
|
||||
{
|
||||
unsigned int len = min_anno + 1 + utf8_width (i.second);
|
||||
if (len > maximum)
|
||||
maximum = len;
|
||||
for (auto& i : task.getAnnotations()) {
|
||||
unsigned int len = min_anno + 1 + utf8_width(i.second);
|
||||
if (len > maximum) maximum = len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Just the text
|
||||
else if (_style == "desc")
|
||||
{
|
||||
maximum = utf8_width (description);
|
||||
minimum = longestWord (description);
|
||||
else if (_style == "desc") {
|
||||
maximum = utf8_width(description);
|
||||
minimum = longestWord(description);
|
||||
}
|
||||
|
||||
// The text <date> <anno> ...
|
||||
else if (_style == "oneline")
|
||||
{
|
||||
minimum = longestWord (description);
|
||||
maximum = utf8_width (description);
|
||||
else if (_style == "oneline") {
|
||||
minimum = longestWord(description);
|
||||
maximum = utf8_width(description);
|
||||
|
||||
if (task.annotation_count)
|
||||
{
|
||||
auto min_anno = Datetime::length (_dateformat);
|
||||
for (auto& i : task.getAnnotations ())
|
||||
maximum += min_anno + 1 + utf8_width (i.second);
|
||||
if (task.annotation_count) {
|
||||
auto min_anno = Datetime::length(_dateformat);
|
||||
for (auto& i : task.getAnnotations()) maximum += min_anno + 1 + utf8_width(i.second);
|
||||
}
|
||||
}
|
||||
|
||||
// The te...
|
||||
else if (_style == "truncated")
|
||||
{
|
||||
else if (_style == "truncated") {
|
||||
minimum = 4;
|
||||
maximum = utf8_width (description);
|
||||
maximum = utf8_width(description);
|
||||
}
|
||||
|
||||
// The text [2]
|
||||
else if (_style == "count")
|
||||
{
|
||||
else if (_style == "count") {
|
||||
// <description> + ' ' + '[' + <count> + ']'
|
||||
maximum = utf8_width (description) + 1 + 1 + format (task.annotation_count).length () + 1;
|
||||
minimum = longestWord (description);
|
||||
maximum = utf8_width(description) + 1 + 1 + format(task.annotation_count).length() + 1;
|
||||
minimum = longestWord(description);
|
||||
}
|
||||
|
||||
// The te... [2]
|
||||
else if (_style == "truncated_count")
|
||||
{
|
||||
else if (_style == "truncated_count") {
|
||||
minimum = 4;
|
||||
maximum = utf8_width (description) + 1 + 1 + format (task.annotation_count).length () + 1;
|
||||
maximum = utf8_width(description) + 1 + 1 + format(task.annotation_count).length() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnDescription::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
std::string description = task.get (_name);
|
||||
void ColumnDescription::render(std::vector<std::string>& lines, Task& task, int width,
|
||||
Color& color) {
|
||||
std::string description = task.get(_name);
|
||||
|
||||
// This is a description
|
||||
// <date> <anno>
|
||||
// ...
|
||||
if (_style == "default" ||
|
||||
_style == "combined")
|
||||
{
|
||||
if (task.annotation_count)
|
||||
{
|
||||
for (const auto& i : task.getAnnotations ())
|
||||
{
|
||||
Datetime dt (strtoll (i.first.substr (11).c_str (), nullptr, 10));
|
||||
description += '\n' + std::string (_indent, ' ') + dt.toString (_dateformat) + ' ' + i.second;
|
||||
if (_style == "default" || _style == "combined") {
|
||||
if (task.annotation_count) {
|
||||
for (const auto& i : task.getAnnotations()) {
|
||||
Datetime dt(strtoll(i.first.substr(11).c_str(), nullptr, 10));
|
||||
description += '\n' + std::string(_indent, ' ') + dt.toString(_dateformat) + ' ' + i.second;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, description, width, _hyphenate);
|
||||
std::vector<std::string> raw;
|
||||
wrapText(raw, description, width, _hyphenate);
|
||||
|
||||
for (const auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
for (const auto& i : raw) renderStringLeft(lines, width, color, i);
|
||||
}
|
||||
|
||||
// This is a description
|
||||
else if (_style == "desc")
|
||||
{
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, description, width, _hyphenate);
|
||||
else if (_style == "desc") {
|
||||
std::vector<std::string> raw;
|
||||
wrapText(raw, description, width, _hyphenate);
|
||||
|
||||
for (const auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
for (const auto& i : raw) renderStringLeft(lines, width, color, i);
|
||||
}
|
||||
|
||||
// This is a description <date> <anno> ...
|
||||
else if (_style == "oneline")
|
||||
{
|
||||
if (task.annotation_count)
|
||||
{
|
||||
for (const auto& i : task.getAnnotations ())
|
||||
{
|
||||
Datetime dt (strtoll (i.first.substr (11).c_str (), nullptr, 10));
|
||||
description += ' ' + dt.toString (_dateformat) + ' ' + i.second;
|
||||
else if (_style == "oneline") {
|
||||
if (task.annotation_count) {
|
||||
for (const auto& i : task.getAnnotations()) {
|
||||
Datetime dt(strtoll(i.first.substr(11).c_str(), nullptr, 10));
|
||||
description += ' ' + dt.toString(_dateformat) + ' ' + i.second;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, description, width, _hyphenate);
|
||||
std::vector<std::string> raw;
|
||||
wrapText(raw, description, width, _hyphenate);
|
||||
|
||||
for (const auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
for (const auto& i : raw) renderStringLeft(lines, width, color, i);
|
||||
}
|
||||
|
||||
// This is a des...
|
||||
else if (_style == "truncated")
|
||||
{
|
||||
int len = utf8_width (description);
|
||||
else if (_style == "truncated") {
|
||||
int len = utf8_width(description);
|
||||
if (len > width)
|
||||
renderStringLeft (lines, width, color, description.substr (0, width - 3) + "...");
|
||||
renderStringLeft(lines, width, color, description.substr(0, width - 3) + "...");
|
||||
else
|
||||
renderStringLeft (lines, width, color, description);
|
||||
renderStringLeft(lines, width, color, description);
|
||||
}
|
||||
|
||||
// This is a description [2]
|
||||
else if (_style == "count")
|
||||
{
|
||||
if (task.annotation_count)
|
||||
description += " [" + format (task.annotation_count) + ']';
|
||||
else if (_style == "count") {
|
||||
if (task.annotation_count) description += " [" + format(task.annotation_count) + ']';
|
||||
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, description, width, _hyphenate);
|
||||
std::vector<std::string> raw;
|
||||
wrapText(raw, description, width, _hyphenate);
|
||||
|
||||
for (const auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
for (const auto& i : raw) renderStringLeft(lines, width, color, i);
|
||||
}
|
||||
|
||||
// This is a des... [2]
|
||||
else if (_style == "truncated_count")
|
||||
{
|
||||
int len = utf8_width (description);
|
||||
else if (_style == "truncated_count") {
|
||||
int len = utf8_width(description);
|
||||
|
||||
std::string annos_count;
|
||||
int len_annos = 0;
|
||||
if (task.annotation_count)
|
||||
{
|
||||
annos_count = " [" + format (task.annotation_count) + ']';
|
||||
len_annos = utf8_width (annos_count);
|
||||
if (task.annotation_count) {
|
||||
annos_count = " [" + format(task.annotation_count) + ']';
|
||||
len_annos = utf8_width(annos_count);
|
||||
len += len_annos;
|
||||
}
|
||||
|
||||
if (len > width)
|
||||
renderStringLeft (lines, width, color, description.substr (0, width - len_annos - 3) + "..." + annos_count);
|
||||
renderStringLeft(lines, width, color,
|
||||
description.substr(0, width - len_annos - 3) + "..." + annos_count);
|
||||
else
|
||||
renderStringLeft (lines, width, color, description + annos_count);
|
||||
renderStringLeft(lines, width, color, description + annos_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnDescription : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnDescription ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnDescription : public ColumnTypeString {
|
||||
public:
|
||||
ColumnDescription();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool _hyphenate;
|
||||
std::string _dateformat;
|
||||
int _indent;
|
||||
|
|
|
@ -30,22 +30,19 @@
|
|||
#include <ColDue.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnDue::ColumnDue ()
|
||||
{
|
||||
_name = "due";
|
||||
ColumnDue::ColumnDue() {
|
||||
_name = "due";
|
||||
_modifiable = true;
|
||||
_label = "Due";
|
||||
_label = "Due";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnDue::setStyle (const std::string& value)
|
||||
{
|
||||
Column::setStyle (value);
|
||||
void ColumnDue::setStyle(const std::string& value) {
|
||||
Column::setStyle(value);
|
||||
|
||||
if (_style == "countdown" && _label == "Due")
|
||||
_label = "Count";
|
||||
if (_style == "countdown" && _label == "Due") _label = "Count";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,11 +29,10 @@
|
|||
|
||||
#include <ColTypeDate.h>
|
||||
|
||||
class ColumnDue : public ColumnTypeDate
|
||||
{
|
||||
public:
|
||||
ColumnDue ();
|
||||
void setStyle (const std::string&);
|
||||
class ColumnDue : public ColumnTypeDate {
|
||||
public:
|
||||
ColumnDue();
|
||||
void setStyle(const std::string&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,9 +30,8 @@
|
|||
#include <ColEnd.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnEnd::ColumnEnd ()
|
||||
{
|
||||
_name = "end";
|
||||
ColumnEnd::ColumnEnd() {
|
||||
_name = "end";
|
||||
_label = "Completed";
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,9 @@
|
|||
|
||||
#include <ColTypeDate.h>
|
||||
|
||||
class ColumnEnd : public ColumnTypeDate
|
||||
{
|
||||
public:
|
||||
ColumnEnd ();
|
||||
class ColumnEnd : public ColumnTypeDate {
|
||||
public:
|
||||
ColumnEnd();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,23 +30,19 @@
|
|||
#include <ColEntry.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnEntry::ColumnEntry ()
|
||||
{
|
||||
_name = "entry";
|
||||
ColumnEntry::ColumnEntry() {
|
||||
_name = "entry";
|
||||
_modifiable = true;
|
||||
_label = "Added";
|
||||
_label = "Added";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnEntry::setStyle (const std::string& value)
|
||||
{
|
||||
Column::setStyle (value);
|
||||
void ColumnEntry::setStyle(const std::string& value) {
|
||||
Column::setStyle(value);
|
||||
|
||||
if (_style == "age" &&
|
||||
_label == "Added")
|
||||
_label = "Age";
|
||||
if (_style == "age" && _label == "Added") _label = "Age";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,11 +29,10 @@
|
|||
|
||||
#include <ColTypeDate.h>
|
||||
|
||||
class ColumnEntry : public ColumnTypeDate
|
||||
{
|
||||
public:
|
||||
ColumnEntry ();
|
||||
void setStyle (const std::string&);
|
||||
class ColumnEntry : public ColumnTypeDate {
|
||||
public:
|
||||
ColumnEntry();
|
||||
void setStyle(const std::string&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,48 +28,47 @@
|
|||
// cmake.h include header must come first
|
||||
|
||||
#include <ColID.h>
|
||||
#include <math.h>
|
||||
#include <format.h>
|
||||
#include <math.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnID::ColumnID ()
|
||||
{
|
||||
_name = "id";
|
||||
_style = "number";
|
||||
_label = "ID";
|
||||
ColumnID::ColumnID() {
|
||||
_name = "id";
|
||||
_style = "number";
|
||||
_label = "ID";
|
||||
_modifiable = false;
|
||||
_styles = {"number"};
|
||||
_examples = {"123"};
|
||||
_styles = {"number"};
|
||||
_examples = {"123"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnID::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnID::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
int length;
|
||||
|
||||
if (task.id < 10) length = 1; // Fast
|
||||
else if (task.id < 100) length = 2; // Fast
|
||||
else if (task.id < 1000) length = 3; // Fast
|
||||
else if (task.id < 10000) length = 4; // Fast
|
||||
else if (task.id < 100000) length = 5; // Fast
|
||||
else length = 1 + (int) log10 ((double) task.id); // Slow
|
||||
if (task.id < 10)
|
||||
length = 1; // Fast
|
||||
else if (task.id < 100)
|
||||
length = 2; // Fast
|
||||
else if (task.id < 1000)
|
||||
length = 3; // Fast
|
||||
else if (task.id < 10000)
|
||||
length = 4; // Fast
|
||||
else if (task.id < 100000)
|
||||
length = 5; // Fast
|
||||
else
|
||||
length = 1 + (int)log10((double)task.id); // Slow
|
||||
|
||||
minimum = maximum = length;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnID::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
// Completed and deleted tasks have no ID.
|
||||
void ColumnID::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
// Completed and deleted tasks have no ID.
|
||||
if (task.id)
|
||||
renderInteger (lines, width, color, task.id);
|
||||
renderInteger(lines, width, color, task.id);
|
||||
else
|
||||
renderStringRight (lines, width, color, "-");
|
||||
renderStringRight(lines, width, color, "-");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
|
||||
#include <ColTypeNumeric.h>
|
||||
|
||||
class ColumnID : public ColumnTypeNumeric
|
||||
{
|
||||
public:
|
||||
ColumnID ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnID : public ColumnTypeNumeric {
|
||||
public:
|
||||
ColumnID();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,34 +31,25 @@
|
|||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnIMask::ColumnIMask ()
|
||||
{
|
||||
_name = "imask";
|
||||
_style = "number";
|
||||
_label = "Mask Index";
|
||||
ColumnIMask::ColumnIMask() {
|
||||
_name = "imask";
|
||||
_style = "number";
|
||||
_label = "Mask Index";
|
||||
_modifiable = false;
|
||||
_styles = {"number"};
|
||||
_examples = {"12"};
|
||||
_styles = {"number"};
|
||||
_examples = {"12"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnIMask::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
minimum = maximum = task.get (_name).length ();
|
||||
if (task.has(_name)) minimum = maximum = task.get(_name).length();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnIMask::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
renderStringRight (lines, width, color, task.get (_name));
|
||||
void ColumnIMask::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) renderStringRight(lines, width, color, task.get(_name));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
|
||||
#include <ColTypeNumeric.h>
|
||||
|
||||
class ColumnIMask : public ColumnTypeNumeric
|
||||
{
|
||||
public:
|
||||
ColumnIMask ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnIMask : public ColumnTypeNumeric {
|
||||
public:
|
||||
ColumnIMask();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,34 +31,25 @@
|
|||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnLast::ColumnLast ()
|
||||
{
|
||||
_name = "last";
|
||||
_style = "number";
|
||||
_label = "Last instance";
|
||||
ColumnLast::ColumnLast() {
|
||||
_name = "last";
|
||||
_style = "number";
|
||||
_label = "Last instance";
|
||||
_modifiable = false;
|
||||
_styles = {"number"};
|
||||
_examples = {"12"};
|
||||
_styles = {"number"};
|
||||
_examples = {"12"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnLast::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnLast::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
minimum = maximum = task.get (_name).length ();
|
||||
if (task.has(_name)) minimum = maximum = task.get(_name).length();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnLast::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
renderStringRight (lines, width, color, task.get (_name));
|
||||
void ColumnLast::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) renderStringRight(lines, width, color, task.get(_name));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
|
||||
#include <ColTypeNumeric.h>
|
||||
|
||||
class ColumnLast : public ColumnTypeNumeric
|
||||
{
|
||||
public:
|
||||
ColumnLast ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnLast : public ColumnTypeNumeric {
|
||||
public:
|
||||
ColumnLast();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,34 +31,25 @@
|
|||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnMask::ColumnMask ()
|
||||
{
|
||||
_name = "mask";
|
||||
_style = "default";
|
||||
_label = "Mask";
|
||||
ColumnMask::ColumnMask() {
|
||||
_name = "mask";
|
||||
_style = "default";
|
||||
_label = "Mask";
|
||||
_modifiable = false;
|
||||
_styles = {"default"};
|
||||
_examples = {"++++---"};
|
||||
_styles = {"default"};
|
||||
_examples = {"++++---"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnMask::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
minimum = maximum = task.get (_name).length ();
|
||||
if (task.has(_name)) minimum = maximum = task.get(_name).length();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnMask::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
renderStringLeft (lines, width, color, task.get (_name));
|
||||
void ColumnMask::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) renderStringLeft(lines, width, color, task.get(_name));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnMask : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnMask ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnMask : public ColumnTypeString {
|
||||
public:
|
||||
ColumnMask();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,9 +30,8 @@
|
|||
#include <ColModified.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnModified::ColumnModified ()
|
||||
{
|
||||
_name = "modified";
|
||||
ColumnModified::ColumnModified() {
|
||||
_name = "modified";
|
||||
_label = "Modified";
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,9 @@
|
|||
|
||||
#include <ColTypeDate.h>
|
||||
|
||||
class ColumnModified : public ColumnTypeDate
|
||||
{
|
||||
public:
|
||||
ColumnModified ();
|
||||
class ColumnModified : public ColumnTypeDate {
|
||||
public:
|
||||
ColumnModified();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,45 +31,37 @@
|
|||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnParent::ColumnParent ()
|
||||
{
|
||||
_name = "parent";
|
||||
_style = "long";
|
||||
_label = "Parent task";
|
||||
ColumnParent::ColumnParent() {
|
||||
_name = "parent";
|
||||
_style = "long";
|
||||
_label = "Parent task";
|
||||
_modifiable = false;
|
||||
_styles = {"long", "short"};
|
||||
_examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "f30cb9c3"};
|
||||
_styles = {"long", "short"};
|
||||
_examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "f30cb9c3"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnParent::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnParent::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default" || _style == "long") minimum = maximum = 36;
|
||||
else if (_style == "short") minimum = maximum = 8;
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default" || _style == "long")
|
||||
minimum = maximum = 36;
|
||||
else if (_style == "short")
|
||||
minimum = maximum = 8;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnParent::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
void ColumnParent::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) {
|
||||
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
|
||||
// f30cb9c3 short
|
||||
if (_style == "default" ||
|
||||
_style == "long")
|
||||
renderStringLeft (lines, width, color, task.get(_name));
|
||||
if (_style == "default" || _style == "long")
|
||||
renderStringLeft(lines, width, color, task.get(_name));
|
||||
|
||||
else if (_style == "short")
|
||||
renderStringLeft (lines, width, color, task.get (_name).substr (0, 8));
|
||||
renderStringLeft(lines, width, color, task.get(_name).substr(0, 8));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnParent : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnParent ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnParent : public ColumnTypeString {
|
||||
public:
|
||||
ColumnParent();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,120 +30,91 @@
|
|||
#include <ColProject.h>
|
||||
#include <Context.h>
|
||||
#include <Eval.h>
|
||||
#include <Variant.h>
|
||||
#include <Lexer.h>
|
||||
#include <Filter.h>
|
||||
#include <shared.h>
|
||||
#include <Lexer.h>
|
||||
#include <Variant.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
#include <utf8.h>
|
||||
#include <util.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnProject::ColumnProject ()
|
||||
{
|
||||
_name = "project";
|
||||
_style = "full";
|
||||
_label = "Project";
|
||||
_styles = {"full", "parent", "indented"};
|
||||
_examples = {"home.garden",
|
||||
"home",
|
||||
" home.garden"};
|
||||
_hyphenate = Context::getContext ().config.getBoolean ("hyphenate");
|
||||
ColumnProject::ColumnProject() {
|
||||
_name = "project";
|
||||
_style = "full";
|
||||
_label = "Project";
|
||||
_styles = {"full", "parent", "indented"};
|
||||
_examples = {"home.garden", "home", " home.garden"};
|
||||
_hyphenate = Context::getContext().config.getBoolean("hyphenate");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnProject::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
std::string project = task.get (_name);
|
||||
if (task.has(_name)) {
|
||||
std::string project = task.get(_name);
|
||||
|
||||
if (_style == "parent")
|
||||
{
|
||||
auto period = project.find ('.');
|
||||
if (period != std::string::npos)
|
||||
project = project.substr (0, period);
|
||||
}
|
||||
else if (_style == "indented")
|
||||
{
|
||||
project = indentProject (project, " ", '.');
|
||||
if (_style == "parent") {
|
||||
auto period = project.find('.');
|
||||
if (period != std::string::npos) project = project.substr(0, period);
|
||||
} else if (_style == "indented") {
|
||||
project = indentProject(project, " ", '.');
|
||||
}
|
||||
|
||||
minimum = longestWord (project);
|
||||
maximum = utf8_width (project);
|
||||
minimum = longestWord(project);
|
||||
maximum = utf8_width(project);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnProject::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
std::string project = task.get (_name);
|
||||
if (_style == "parent")
|
||||
{
|
||||
auto period = project.find ('.');
|
||||
if (period != std::string::npos)
|
||||
project = project.substr (0, period);
|
||||
}
|
||||
else if (_style == "indented")
|
||||
{
|
||||
project = indentProject (project, " ", '.');
|
||||
void ColumnProject::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) {
|
||||
std::string project = task.get(_name);
|
||||
if (_style == "parent") {
|
||||
auto period = project.find('.');
|
||||
if (period != std::string::npos) project = project.substr(0, period);
|
||||
} else if (_style == "indented") {
|
||||
project = indentProject(project, " ", '.');
|
||||
}
|
||||
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, project, width, _hyphenate);
|
||||
std::vector<std::string> raw;
|
||||
wrapText(raw, project, width, _hyphenate);
|
||||
|
||||
for (const auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
for (const auto& i : raw) renderStringLeft(lines, width, color, i);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnProject::modify (Task& task, const std::string& value)
|
||||
{
|
||||
void ColumnProject::modify(Task& task, const std::string& value) {
|
||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||
|
||||
// Only if it's a DOM ref, eval it first.
|
||||
Lexer lexer (value);
|
||||
Lexer lexer(value);
|
||||
std::string domRef;
|
||||
Lexer::Type type;
|
||||
if (lexer.token (domRef, type) &&
|
||||
type == Lexer::Type::dom)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (lexer.token(domRef, type) && type == Lexer::Type::dom) {
|
||||
try {
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
e.addSource(domSource);
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
task.set (_name, (std::string) v);
|
||||
Context::getContext ().debug (label + _name + " <-- '" + (std::string) v + "' <-- '" + value + '\'');
|
||||
}
|
||||
catch (const std::string& e)
|
||||
{
|
||||
e.evaluateInfixExpression(value, v);
|
||||
task.set(_name, (std::string)v);
|
||||
Context::getContext().debug(label + _name + " <-- '" + (std::string)v + "' <-- '" + value +
|
||||
'\'');
|
||||
} catch (const std::string& e) {
|
||||
// If the expression failed because it didn't look like an expression,
|
||||
// simply store it as-is.
|
||||
if (e == "The value is not an expression.")
|
||||
{
|
||||
task.set (_name, value);
|
||||
Context::getContext ().debug (label + _name + " <-- '" + value + '\'');
|
||||
}
|
||||
else
|
||||
if (e == "The value is not an expression.") {
|
||||
task.set(_name, value);
|
||||
Context::getContext().debug(label + _name + " <-- '" + value + '\'');
|
||||
} else
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
task.set (_name, value);
|
||||
Context::getContext ().debug (label + _name + " <-- '" + value + '\'');
|
||||
} else {
|
||||
task.set(_name, value);
|
||||
Context::getContext().debug(label + _name + " <-- '" + value + '\'');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,15 +29,14 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnProject : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnProject ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
void modify (Task&, const std::string&);
|
||||
class ColumnProject : public ColumnTypeString {
|
||||
public:
|
||||
ColumnProject();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
void modify(Task&, const std::string&);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool _hyphenate;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,72 +29,60 @@
|
|||
|
||||
#include <ColRType.h>
|
||||
#include <Context.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
|
||||
#include <cctype>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnRType::ColumnRType ()
|
||||
{
|
||||
_name = "rtype";
|
||||
_style = "default";
|
||||
_label = "Recurrence type";
|
||||
ColumnRType::ColumnRType() {
|
||||
_name = "rtype";
|
||||
_style = "default";
|
||||
_label = "Recurrence type";
|
||||
_modifiable = false;
|
||||
_styles = {"default", "indicator"};
|
||||
_examples = {"periodic", "chained"};
|
||||
_styles = {"default", "indicator"};
|
||||
_examples = {"periodic", "chained"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnRType::setStyle (const std::string& value)
|
||||
{
|
||||
Column::setStyle (value);
|
||||
void ColumnRType::setStyle(const std::string& value) {
|
||||
Column::setStyle(value);
|
||||
|
||||
if (_style == "indicator" && _label == "Recurrence type")
|
||||
_label = _label.substr (0, Context::getContext ().config.get ("rtype.indicator").length ());
|
||||
_label = _label.substr(0, Context::getContext().config.get("rtype.indicator").length());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnRType::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnRType::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default")
|
||||
minimum = maximum = task.get (_name).length ();
|
||||
minimum = maximum = task.get(_name).length();
|
||||
else if (_style == "indicator")
|
||||
minimum = maximum = 1;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnRType::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
void ColumnRType::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default")
|
||||
renderStringRight (lines, width, color, task.get (_name));
|
||||
renderStringRight(lines, width, color, task.get(_name));
|
||||
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
std::string value {" "};
|
||||
value[0] = toupper (task.get (_name)[0]);
|
||||
renderStringRight (lines, width, color, value);
|
||||
else if (_style == "indicator") {
|
||||
std::string value{" "};
|
||||
value[0] = toupper(task.get(_name)[0]);
|
||||
renderStringRight(lines, width, color, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnRType::validate (const std::string& input) const
|
||||
{
|
||||
return input == "periodic" ||
|
||||
input == "chained";
|
||||
bool ColumnRType::validate(const std::string& input) const {
|
||||
return input == "periodic" || input == "chained";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,16 +29,15 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnRType : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnRType ();
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
bool validate (const std::string&) const;
|
||||
class ColumnRType : public ColumnTypeString {
|
||||
public:
|
||||
ColumnRType();
|
||||
void setStyle(const std::string&);
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
bool validate(const std::string&) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,100 +31,81 @@
|
|||
#include <Context.h>
|
||||
#include <Duration.h>
|
||||
#include <Eval.h>
|
||||
#include <Variant.h>
|
||||
#include <Lexer.h>
|
||||
#include <Filter.h>
|
||||
#include <shared.h>
|
||||
#include <Lexer.h>
|
||||
#include <Variant.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
#include <utf8.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnRecur::ColumnRecur ()
|
||||
{
|
||||
_name = "recur";
|
||||
_style = "duration";
|
||||
_label = "Recur";
|
||||
ColumnRecur::ColumnRecur() {
|
||||
_name = "recur";
|
||||
_style = "duration";
|
||||
_label = "Recur";
|
||||
_modifiable = true;
|
||||
_styles = {"duration", "indicator"};
|
||||
_examples = {"weekly", Context::getContext ().config.get ("recurrence.indicator")};
|
||||
_styles = {"duration", "indicator"};
|
||||
_examples = {"weekly", Context::getContext().config.get("recurrence.indicator")};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnRecur::setStyle (const std::string& value)
|
||||
{
|
||||
Column::setStyle (value);
|
||||
void ColumnRecur::setStyle(const std::string& value) {
|
||||
Column::setStyle(value);
|
||||
|
||||
if (_style == "indicator" && _label == "Recur")
|
||||
_label = _label.substr (0, Context::getContext ().config.get ("recurrence.indicator").length ());
|
||||
_label = _label.substr(0, Context::getContext().config.get("recurrence.indicator").length());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnRecur::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default" ||
|
||||
_style == "duration")
|
||||
{
|
||||
minimum = maximum = Duration (task.get (_name)).formatISO ().length ();
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
minimum = maximum = utf8_width (Context::getContext ().config.get ("recurrence.indicator"));
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default" || _style == "duration") {
|
||||
minimum = maximum = Duration(task.get(_name)).formatISO().length();
|
||||
} else if (_style == "indicator") {
|
||||
minimum = maximum = utf8_width(Context::getContext().config.get("recurrence.indicator"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnRecur::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default" ||
|
||||
_style == "duration")
|
||||
renderStringRight (lines, width, color, Duration (task.get (_name)).formatISO ());
|
||||
void ColumnRecur::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default" || _style == "duration")
|
||||
renderStringRight(lines, width, color, Duration(task.get(_name)).formatISO());
|
||||
|
||||
else if (_style == "indicator")
|
||||
renderStringRight (lines, width, color, Context::getContext ().config.get ("recurrence.indicator"));
|
||||
renderStringRight(lines, width, color,
|
||||
Context::getContext().config.get("recurrence.indicator"));
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The duration is stored in raw form, but it must still be valid,
|
||||
// and therefore is parsed first.
|
||||
void ColumnRecur::modify (Task& task, const std::string& value)
|
||||
{
|
||||
void ColumnRecur::modify(Task& task, const std::string& value) {
|
||||
// Try to evaluate 'value'. It might work.
|
||||
Variant evaluatedValue;
|
||||
try
|
||||
{
|
||||
try {
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
e.addSource(domSource);
|
||||
e.evaluateInfixExpression(value, evaluatedValue);
|
||||
}
|
||||
|
||||
catch (...)
|
||||
{
|
||||
evaluatedValue = Variant (value);
|
||||
catch (...) {
|
||||
evaluatedValue = Variant(value);
|
||||
}
|
||||
|
||||
if (evaluatedValue.type () == Variant::type_duration)
|
||||
{
|
||||
if (evaluatedValue.type() == Variant::type_duration) {
|
||||
// Store the raw value, for 'recur'.
|
||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||
Context::getContext ().debug (label + _name + " <-- '" + value + '\'');
|
||||
task.set (_name, value);
|
||||
}
|
||||
else
|
||||
throw format ("The duration value '{1}' is not supported.", value);
|
||||
Context::getContext().debug(label + _name + " <-- '" + value + '\'');
|
||||
task.set(_name, value);
|
||||
} else
|
||||
throw format("The duration value '{1}' is not supported.", value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -31,16 +31,15 @@
|
|||
|
||||
// This is 'string', and not 'duration' to force the value to be stored as a
|
||||
// raw duration, so that it can be reevaluated every time.
|
||||
class ColumnRecur : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnRecur ();
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
void modify (Task&, const std::string&);
|
||||
class ColumnRecur : public ColumnTypeString {
|
||||
public:
|
||||
ColumnRecur();
|
||||
void setStyle(const std::string&);
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
void modify(Task&, const std::string&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,21 +30,18 @@
|
|||
#include <ColScheduled.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnScheduled::ColumnScheduled ()
|
||||
{
|
||||
_name = "scheduled";
|
||||
ColumnScheduled::ColumnScheduled() {
|
||||
_name = "scheduled";
|
||||
_label = "Scheduled";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnScheduled::setStyle (const std::string& value)
|
||||
{
|
||||
Column::setStyle (value);
|
||||
void ColumnScheduled::setStyle(const std::string& value) {
|
||||
Column::setStyle(value);
|
||||
|
||||
if (_style == "countdown" && _label == "Scheduled")
|
||||
_label = "Count";
|
||||
if (_style == "countdown" && _label == "Scheduled") _label = "Count";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,11 +29,10 @@
|
|||
|
||||
#include <ColTypeDate.h>
|
||||
|
||||
class ColumnScheduled : public ColumnTypeDate
|
||||
{
|
||||
public:
|
||||
ColumnScheduled ();
|
||||
void setStyle (const std::string&);
|
||||
class ColumnScheduled : public ColumnTypeDate {
|
||||
public:
|
||||
ColumnScheduled();
|
||||
void setStyle(const std::string&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,58 +32,46 @@
|
|||
#include <utf8.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnStart::ColumnStart ()
|
||||
{
|
||||
_name = "start";
|
||||
ColumnStart::ColumnStart() {
|
||||
_name = "start";
|
||||
_label = "Started";
|
||||
|
||||
_styles.push_back ("active");
|
||||
_examples.push_back (Context::getContext ().config.get ("active.indicator"));
|
||||
_styles.push_back("active");
|
||||
_examples.push_back(Context::getContext().config.get("active.indicator"));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnStart::setStyle (const std::string& value)
|
||||
{
|
||||
Column::setStyle (value);
|
||||
void ColumnStart::setStyle(const std::string& value) {
|
||||
Column::setStyle(value);
|
||||
|
||||
if (_style == "active" && _label == "Started")
|
||||
_label = "A";
|
||||
if (_style == "active" && _label == "Started") _label = "A";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnStart::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnStart::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (task.has(_name)) {
|
||||
if (_style == "active")
|
||||
minimum = maximum = utf8_width (Context::getContext ().config.get ("active.indicator"));
|
||||
minimum = maximum = utf8_width(Context::getContext().config.get("active.indicator"));
|
||||
else
|
||||
ColumnTypeDate::measure (task, minimum, maximum);
|
||||
ColumnTypeDate::measure(task, minimum, maximum);
|
||||
|
||||
// TODO Throw on bad format.
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnStart::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "active")
|
||||
{
|
||||
if (! task.has ("end"))
|
||||
renderStringRight (lines, width, color, Context::getContext ().config.get ("active.indicator"));
|
||||
}
|
||||
else
|
||||
ColumnTypeDate::render (lines, task, width, color);
|
||||
void ColumnStart::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) {
|
||||
if (_style == "active") {
|
||||
if (!task.has("end"))
|
||||
renderStringRight(lines, width, color,
|
||||
Context::getContext().config.get("active.indicator"));
|
||||
} else
|
||||
ColumnTypeDate::render(lines, task, width, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,13 +29,12 @@
|
|||
|
||||
#include <ColTypeDate.h>
|
||||
|
||||
class ColumnStart : public ColumnTypeDate
|
||||
{
|
||||
public:
|
||||
ColumnStart ();
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnStart : public ColumnTypeDate {
|
||||
public:
|
||||
ColumnStart();
|
||||
void setStyle(const std::string&);
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,81 +32,75 @@
|
|||
#include <utf8.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnStatus::ColumnStatus ()
|
||||
{
|
||||
_name = "status";
|
||||
_style = "long";
|
||||
_label = "Status";
|
||||
_styles = {"long", "short"};
|
||||
_examples = {"Pending",
|
||||
"P"};
|
||||
ColumnStatus::ColumnStatus() {
|
||||
_name = "status";
|
||||
_style = "long";
|
||||
_label = "Status";
|
||||
_styles = {"long", "short"};
|
||||
_examples = {"Pending", "P"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnStatus::setStyle (const std::string& value)
|
||||
{
|
||||
Column::setStyle (value);
|
||||
void ColumnStatus::setStyle(const std::string& value) {
|
||||
Column::setStyle(value);
|
||||
|
||||
if (_style == "short" && _label == "Status")
|
||||
_label = "St";
|
||||
if (_style == "short" && _label == "Status") _label = "St";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnStatus::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
Task::status status = task.getStatus ();
|
||||
void ColumnStatus::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
Task::status status = task.getStatus();
|
||||
|
||||
if (_style == "default" ||
|
||||
_style == "long")
|
||||
{
|
||||
if (_style == "default" || _style == "long") {
|
||||
if (status == Task::pending)
|
||||
minimum = maximum = utf8_width ("Pending");
|
||||
minimum = maximum = utf8_width("Pending");
|
||||
else if (status == Task::deleted)
|
||||
minimum = maximum = utf8_width ("Deleted");
|
||||
minimum = maximum = utf8_width("Deleted");
|
||||
else if (status == Task::waiting)
|
||||
minimum = maximum = utf8_width ("Waiting");
|
||||
minimum = maximum = utf8_width("Waiting");
|
||||
else if (status == Task::completed)
|
||||
minimum = maximum = utf8_width ("Completed");
|
||||
minimum = maximum = utf8_width("Completed");
|
||||
else if (status == Task::recurring)
|
||||
minimum = maximum = utf8_width ("Recurring");
|
||||
}
|
||||
else if (_style == "short")
|
||||
minimum = maximum = utf8_width("Recurring");
|
||||
} else if (_style == "short")
|
||||
minimum = maximum = 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnStatus::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
Task::status status = task.getStatus ();
|
||||
void ColumnStatus::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
Task::status status = task.getStatus();
|
||||
std::string value;
|
||||
|
||||
if (_style == "default" ||
|
||||
_style == "long")
|
||||
{
|
||||
if (status == Task::pending) value = "Pending";
|
||||
else if (status == Task::completed) value = "Completed";
|
||||
else if (status == Task::deleted) value = "Deleted";
|
||||
else if (status == Task::waiting) value = "Waiting";
|
||||
else if (status == Task::recurring) value = "Recurring";
|
||||
if (_style == "default" || _style == "long") {
|
||||
if (status == Task::pending)
|
||||
value = "Pending";
|
||||
else if (status == Task::completed)
|
||||
value = "Completed";
|
||||
else if (status == Task::deleted)
|
||||
value = "Deleted";
|
||||
else if (status == Task::waiting)
|
||||
value = "Waiting";
|
||||
else if (status == Task::recurring)
|
||||
value = "Recurring";
|
||||
}
|
||||
|
||||
else if (_style == "short")
|
||||
{
|
||||
if (status == Task::pending) value = "P";
|
||||
else if (status == Task::completed) value = "C";
|
||||
else if (status == Task::deleted) value = "D";
|
||||
else if (status == Task::waiting) value = "W";
|
||||
else if (status == Task::recurring) value = "R";
|
||||
else if (_style == "short") {
|
||||
if (status == Task::pending)
|
||||
value = "P";
|
||||
else if (status == Task::completed)
|
||||
value = "C";
|
||||
else if (status == Task::deleted)
|
||||
value = "D";
|
||||
else if (status == Task::waiting)
|
||||
value = "W";
|
||||
else if (status == Task::recurring)
|
||||
value = "R";
|
||||
}
|
||||
|
||||
renderStringLeft (lines, width, color, value);
|
||||
renderStringLeft(lines, width, color, value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,15 +29,14 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnStatus : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnStatus ();
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnStatus : public ColumnTypeString {
|
||||
public:
|
||||
ColumnStatus();
|
||||
void setStyle(const std::string&);
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,154 +28,119 @@
|
|||
// cmake.h include header must come first
|
||||
|
||||
#include <ColTags.h>
|
||||
#include <algorithm>
|
||||
#include <Context.h>
|
||||
#include <Eval.h>
|
||||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <shared.h>
|
||||
#include <Variant.h>
|
||||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
#include <shared.h>
|
||||
#include <utf8.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTags::ColumnTags ()
|
||||
{
|
||||
_name = "tags";
|
||||
_style = "list";
|
||||
_label = "Tags";
|
||||
_styles = {"list", "indicator", "count"};
|
||||
_examples = {"home @chore next",
|
||||
Context::getContext ().config.get ("tag.indicator"),
|
||||
"[2]"};
|
||||
ColumnTags::ColumnTags() {
|
||||
_name = "tags";
|
||||
_style = "list";
|
||||
_label = "Tags";
|
||||
_styles = {"list", "indicator", "count"};
|
||||
_examples = {"home @chore next", Context::getContext().config.get("tag.indicator"), "[2]"};
|
||||
_hyphenate = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Overriden so that style <----> label are linked.
|
||||
// Note that you can not determine which gets called first.
|
||||
void ColumnTags::setStyle (const std::string& value)
|
||||
{
|
||||
Column::setStyle (value);
|
||||
void ColumnTags::setStyle(const std::string& value) {
|
||||
Column::setStyle(value);
|
||||
|
||||
if (_style == "indicator" &&
|
||||
_label == "Tags")
|
||||
_label = _label.substr (0, Context::getContext ().config.get ("tag.indicator").length ());
|
||||
if (_style == "indicator" && _label == "Tags")
|
||||
_label = _label.substr(0, Context::getContext().config.get("tag.indicator").length());
|
||||
|
||||
else if (_style == "count" &&
|
||||
_label == "Tags")
|
||||
else if (_style == "count" && _label == "Tags")
|
||||
_label = "Tag";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnTags::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "indicator")
|
||||
{
|
||||
minimum = maximum = utf8_width (Context::getContext ().config.get ("tag.indicator"));
|
||||
}
|
||||
else if (_style == "count")
|
||||
{
|
||||
if (task.has(_name)) {
|
||||
if (_style == "indicator") {
|
||||
minimum = maximum = utf8_width(Context::getContext().config.get("tag.indicator"));
|
||||
} else if (_style == "count") {
|
||||
minimum = maximum = 3;
|
||||
}
|
||||
else if (_style == "default" ||
|
||||
_style == "list")
|
||||
{
|
||||
std::string tags = task.get (_name);
|
||||
} else if (_style == "default" || _style == "list") {
|
||||
std::string tags = task.get(_name);
|
||||
|
||||
// Find the widest tag.
|
||||
if (tags.find (',') != std::string::npos)
|
||||
{
|
||||
auto all = split (tags, ',');
|
||||
for (const auto& tag : all)
|
||||
{
|
||||
auto length = utf8_width (tag);
|
||||
if (length > minimum)
|
||||
minimum = length;
|
||||
if (tags.find(',') != std::string::npos) {
|
||||
auto all = split(tags, ',');
|
||||
for (const auto& tag : all) {
|
||||
auto length = utf8_width(tag);
|
||||
if (length > minimum) minimum = length;
|
||||
}
|
||||
|
||||
maximum = utf8_width (tags);
|
||||
maximum = utf8_width(tags);
|
||||
}
|
||||
|
||||
// No need to split a single tag.
|
||||
else
|
||||
minimum = maximum = utf8_width (tags);
|
||||
minimum = maximum = utf8_width(tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnTags::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
auto all = task.getTags ();
|
||||
if (all.size() > 0)
|
||||
{
|
||||
if (_style == "default" ||
|
||||
_style == "list")
|
||||
{
|
||||
if (all.size () > 1)
|
||||
{
|
||||
std::sort (all.begin (), all.end ());
|
||||
auto tags = join (" ", all);
|
||||
void ColumnTags::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
auto all = task.getTags();
|
||||
if (all.size() > 0) {
|
||||
if (_style == "default" || _style == "list") {
|
||||
if (all.size() > 1) {
|
||||
std::sort(all.begin(), all.end());
|
||||
auto tags = join(" ", all);
|
||||
|
||||
all.clear ();
|
||||
wrapText (all, tags, width, _hyphenate);
|
||||
all.clear();
|
||||
wrapText(all, tags, width, _hyphenate);
|
||||
|
||||
for (const auto& i : all)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
}
|
||||
else
|
||||
renderStringLeft (lines, width, color, all[0]);
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
renderStringRight (lines, width, color, Context::getContext ().config.get ("tag.indicator"));
|
||||
}
|
||||
else if (_style == "count")
|
||||
{
|
||||
renderStringRight (lines, width, color, '[' + format (static_cast <int> (all.size ())) + ']');
|
||||
for (const auto& i : all) renderStringLeft(lines, width, color, i);
|
||||
} else
|
||||
renderStringLeft(lines, width, color, all[0]);
|
||||
} else if (_style == "indicator") {
|
||||
renderStringRight(lines, width, color, Context::getContext().config.get("tag.indicator"));
|
||||
} else if (_style == "count") {
|
||||
renderStringRight(lines, width, color, '[' + format(static_cast<int>(all.size())) + ']');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnTags::modify (Task& task, const std::string& value)
|
||||
{
|
||||
void ColumnTags::modify(Task& task, const std::string& value) {
|
||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||
std::string commasep;
|
||||
std::vector <std::string> tags;
|
||||
std::vector<std::string> tags;
|
||||
|
||||
// If it's a DOM ref, eval it first.
|
||||
Lexer lexer (value);
|
||||
Lexer lexer(value);
|
||||
std::string domRef;
|
||||
Lexer::Type type;
|
||||
if (lexer.token (domRef, type) &&
|
||||
type == Lexer::Type::dom)
|
||||
{
|
||||
if (lexer.token(domRef, type) && type == Lexer::Type::dom) {
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
e.addSource(domSource);
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
commasep = (std::string) v;
|
||||
e.evaluateInfixExpression(value, v);
|
||||
commasep = (std::string)v;
|
||||
} else {
|
||||
commasep = (std::string) value;
|
||||
commasep = (std::string)value;
|
||||
}
|
||||
|
||||
for (auto& tag : split (commasep, ','))
|
||||
{
|
||||
tags.push_back ((std::string) tag);
|
||||
Context::getContext ().debug (label + "tags <-- '" + tag + '\'');
|
||||
for (auto& tag : split(commasep, ',')) {
|
||||
tags.push_back((std::string)tag);
|
||||
Context::getContext().debug(label + "tags <-- '" + tag + '\'');
|
||||
|
||||
feedback_special_tags (task, tag);
|
||||
feedback_special_tags(task, tag);
|
||||
}
|
||||
|
||||
task.setTags(tags);
|
||||
|
|
|
@ -29,16 +29,15 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnTags : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnTags ();
|
||||
void setStyle (const std::string&);
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
void modify (Task&, const std::string&);
|
||||
class ColumnTags : public ColumnTypeString {
|
||||
public:
|
||||
ColumnTags();
|
||||
void setStyle(const std::string&);
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
void modify(Task&, const std::string&);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool _hyphenate;
|
||||
};
|
||||
|
||||
|
|
|
@ -31,45 +31,37 @@
|
|||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTemplate::ColumnTemplate ()
|
||||
{
|
||||
_name = "template";
|
||||
_style = "long";
|
||||
_label = "Template task";
|
||||
ColumnTemplate::ColumnTemplate() {
|
||||
_name = "template";
|
||||
_style = "long";
|
||||
_label = "Template task";
|
||||
_modifiable = false;
|
||||
_styles = {"long", "short"};
|
||||
_examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "f30cb9c3"};
|
||||
_styles = {"long", "short"};
|
||||
_examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "f30cb9c3"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnTemplate::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnTemplate::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default" || _style == "long") minimum = maximum = 36;
|
||||
else if (_style == "short") minimum = maximum = 8;
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default" || _style == "long")
|
||||
minimum = maximum = 36;
|
||||
else if (_style == "short")
|
||||
minimum = maximum = 8;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnTemplate::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
void ColumnTemplate::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) {
|
||||
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
|
||||
// f30cb9c3 short
|
||||
if (_style == "default" ||
|
||||
_style == "long")
|
||||
renderStringLeft (lines, width, color, task.get(_name));
|
||||
if (_style == "default" || _style == "long")
|
||||
renderStringLeft(lines, width, color, task.get(_name));
|
||||
|
||||
else if (_style == "short")
|
||||
renderStringLeft (lines, width, color, task.get (_name).substr (0, 8));
|
||||
renderStringLeft(lines, width, color, task.get(_name).substr(0, 8));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnTemplate : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnTemplate ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnTemplate : public ColumnTypeString {
|
||||
public:
|
||||
ColumnTemplate();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -32,215 +32,165 @@
|
|||
#include <Datetime.h>
|
||||
#include <Duration.h>
|
||||
#include <Eval.h>
|
||||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <Variant.h>
|
||||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeDate::ColumnTypeDate ()
|
||||
{
|
||||
_name = "";
|
||||
_type = "date";
|
||||
_style = "formatted";
|
||||
_label = "";
|
||||
_styles = {"formatted",
|
||||
"julian",
|
||||
"epoch",
|
||||
"iso",
|
||||
"age",
|
||||
"relative",
|
||||
"remaining",
|
||||
"countdown"};
|
||||
ColumnTypeDate::ColumnTypeDate() {
|
||||
_name = "";
|
||||
_type = "date";
|
||||
_style = "formatted";
|
||||
_label = "";
|
||||
_styles = {"formatted", "julian", "epoch", "iso", "age", "relative", "remaining", "countdown"};
|
||||
|
||||
Datetime now;
|
||||
now -= 125; // So that "age" is non-zero.
|
||||
_examples = {now.toString (Context::getContext ().config.get ("dateformat")),
|
||||
format (now.toJulian (), 13, 12),
|
||||
now.toEpochString (),
|
||||
now.toISO (),
|
||||
Duration (Datetime () - now).formatVague (true),
|
||||
'-' + Duration (Datetime () - now).formatVague (true),
|
||||
now -= 125; // So that "age" is non-zero.
|
||||
_examples = {now.toString(Context::getContext().config.get("dateformat")),
|
||||
format(now.toJulian(), 13, 12),
|
||||
now.toEpochString(),
|
||||
now.toISO(),
|
||||
Duration(Datetime() - now).formatVague(true),
|
||||
'-' + Duration(Datetime() - now).formatVague(true),
|
||||
"",
|
||||
Duration (Datetime () - now).format ()};
|
||||
Duration(Datetime() - now).format()};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnTypeDate::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
Datetime date (task.get_date (_name));
|
||||
if (task.has(_name)) {
|
||||
Datetime date(task.get_date(_name));
|
||||
|
||||
if (_style == "default" ||
|
||||
_style == "formatted")
|
||||
{
|
||||
if (_style == "default" || _style == "formatted") {
|
||||
// Determine the output date format, which uses a hierarchy of definitions.
|
||||
// rc.report.<report>.dateformat
|
||||
// rc.dateformat.report
|
||||
// rc.dateformat.
|
||||
std::string format = Context::getContext ().config.get ("report." + _report + ".dateformat");
|
||||
if (format == "")
|
||||
format = Context::getContext ().config.get ("dateformat.report");
|
||||
if (format == "")
|
||||
format = Context::getContext ().config.get ("dateformat");
|
||||
std::string format = Context::getContext().config.get("report." + _report + ".dateformat");
|
||||
if (format == "") format = Context::getContext().config.get("dateformat.report");
|
||||
if (format == "") format = Context::getContext().config.get("dateformat");
|
||||
|
||||
minimum = maximum = Datetime::length (format);
|
||||
}
|
||||
else if (_style == "countdown")
|
||||
{
|
||||
minimum = maximum = Datetime::length(format);
|
||||
} else if (_style == "countdown") {
|
||||
Datetime now;
|
||||
minimum = maximum = Duration (date - now).formatVague (true).length ();
|
||||
}
|
||||
else if (_style == "julian")
|
||||
{
|
||||
minimum = maximum = format (date.toJulian (), 13, 12).length ();
|
||||
}
|
||||
else if (_style == "epoch")
|
||||
{
|
||||
minimum = maximum = date.toEpochString ().length ();
|
||||
}
|
||||
else if (_style == "iso")
|
||||
{
|
||||
minimum = maximum = date.toISO ().length ();
|
||||
}
|
||||
else if (_style == "age")
|
||||
{
|
||||
minimum = maximum = Duration(date - now).formatVague(true).length();
|
||||
} else if (_style == "julian") {
|
||||
minimum = maximum = format(date.toJulian(), 13, 12).length();
|
||||
} else if (_style == "epoch") {
|
||||
minimum = maximum = date.toEpochString().length();
|
||||
} else if (_style == "iso") {
|
||||
minimum = maximum = date.toISO().length();
|
||||
} else if (_style == "age") {
|
||||
Datetime now;
|
||||
if (now > date)
|
||||
minimum = maximum = Duration (now - date).formatVague (true).length ();
|
||||
minimum = maximum = Duration(now - date).formatVague(true).length();
|
||||
else
|
||||
minimum = maximum = Duration (date - now).formatVague (true).length () + 1;
|
||||
}
|
||||
else if (_style == "relative")
|
||||
{
|
||||
minimum = maximum = Duration(date - now).formatVague(true).length() + 1;
|
||||
} else if (_style == "relative") {
|
||||
Datetime now;
|
||||
if (now < date)
|
||||
minimum = maximum = Duration (date - now).formatVague (true).length ();
|
||||
minimum = maximum = Duration(date - now).formatVague(true).length();
|
||||
else
|
||||
minimum = maximum = Duration (now - date).formatVague (true).length () + 1;
|
||||
}
|
||||
else if (_style == "remaining")
|
||||
{
|
||||
minimum = maximum = Duration(now - date).formatVague(true).length() + 1;
|
||||
} else if (_style == "remaining") {
|
||||
Datetime now;
|
||||
if (date > now)
|
||||
minimum = maximum = Duration (date - now).formatVague (true).length ();
|
||||
if (date > now) minimum = maximum = Duration(date - now).formatVague(true).length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnTypeDate::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
Datetime date (task.get_date (_name));
|
||||
void ColumnTypeDate::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) {
|
||||
Datetime date(task.get_date(_name));
|
||||
|
||||
if (_style == "default" ||
|
||||
_style == "formatted")
|
||||
{
|
||||
if (_style == "default" || _style == "formatted") {
|
||||
// Determine the output date format, which uses a hierarchy of definitions.
|
||||
// rc.report.<report>.dateformat
|
||||
// rc.dateformat.report
|
||||
// rc.dateformat
|
||||
std::string format = Context::getContext ().config.get ("report." + _report + ".dateformat");
|
||||
if (format == "")
|
||||
{
|
||||
format = Context::getContext ().config.get ("dateformat.report");
|
||||
if (format == "")
|
||||
format = Context::getContext ().config.get ("dateformat");
|
||||
std::string format = Context::getContext().config.get("report." + _report + ".dateformat");
|
||||
if (format == "") {
|
||||
format = Context::getContext().config.get("dateformat.report");
|
||||
if (format == "") format = Context::getContext().config.get("dateformat");
|
||||
}
|
||||
|
||||
renderStringLeft (lines, width, color, date.toString (format));
|
||||
}
|
||||
else if (_style == "countdown")
|
||||
{
|
||||
renderStringLeft(lines, width, color, date.toString(format));
|
||||
} else if (_style == "countdown") {
|
||||
Datetime now;
|
||||
renderStringRight (lines, width, color, Duration (date - now).formatVague (true));
|
||||
}
|
||||
else if (_style == "julian")
|
||||
renderStringRight (lines, width, color, format (date.toJulian (), 13, 12));
|
||||
renderStringRight(lines, width, color, Duration(date - now).formatVague(true));
|
||||
} else if (_style == "julian")
|
||||
renderStringRight(lines, width, color, format(date.toJulian(), 13, 12));
|
||||
|
||||
else if (_style == "epoch")
|
||||
renderStringRight (lines, width, color, date.toEpochString ());
|
||||
renderStringRight(lines, width, color, date.toEpochString());
|
||||
|
||||
else if (_style == "iso")
|
||||
renderStringLeft (lines, width, color, date.toISO ());
|
||||
renderStringLeft(lines, width, color, date.toISO());
|
||||
|
||||
else if (_style == "age")
|
||||
{
|
||||
else if (_style == "age") {
|
||||
Datetime now;
|
||||
if (now > date)
|
||||
renderStringRight (lines, width, color, Duration (now - date).formatVague (true));
|
||||
renderStringRight(lines, width, color, Duration(now - date).formatVague(true));
|
||||
else
|
||||
renderStringRight (lines, width, color, '-' + Duration (date - now).formatVague (true));
|
||||
}
|
||||
else if (_style == "relative")
|
||||
{
|
||||
renderStringRight(lines, width, color, '-' + Duration(date - now).formatVague(true));
|
||||
} else if (_style == "relative") {
|
||||
Datetime now;
|
||||
if (now < date)
|
||||
renderStringRight (lines, width, color, Duration (date - now).formatVague (true));
|
||||
renderStringRight(lines, width, color, Duration(date - now).formatVague(true));
|
||||
else
|
||||
renderStringRight (lines, width, color, '-' + Duration (now - date).formatVague (true));
|
||||
renderStringRight(lines, width, color, '-' + Duration(now - date).formatVague(true));
|
||||
}
|
||||
|
||||
else if (_style == "remaining")
|
||||
{
|
||||
else if (_style == "remaining") {
|
||||
Datetime now;
|
||||
if (date > now)
|
||||
renderStringRight (lines, width, color, Duration (date - now).formatVague (true));
|
||||
renderStringRight(lines, width, color, Duration(date - now).formatVague(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnTypeDate::validate (const std::string& input) const
|
||||
{
|
||||
return input.length () ? true : false;
|
||||
bool ColumnTypeDate::validate(const std::string& input) const {
|
||||
return input.length() ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnTypeDate::modify (Task& task, const std::string& value)
|
||||
{
|
||||
void ColumnTypeDate::modify(Task& task, const std::string& value) {
|
||||
// Try to evaluate 'value'. It might work.
|
||||
Variant evaluatedValue;
|
||||
try
|
||||
{
|
||||
try {
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
e.addSource(domSource);
|
||||
e.evaluateInfixExpression(value, evaluatedValue);
|
||||
}
|
||||
|
||||
catch (...)
|
||||
{
|
||||
evaluatedValue = Variant (value);
|
||||
catch (...) {
|
||||
evaluatedValue = Variant(value);
|
||||
}
|
||||
|
||||
// If v is duration, we need to convert it to date (and implicitly add now),
|
||||
// else store as date.
|
||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||
if (evaluatedValue.type () == Variant::type_duration)
|
||||
{
|
||||
Context::getContext ().debug (label + _name + " <-- '" + format ("{1}", format (evaluatedValue.get_duration ())) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + '\'');
|
||||
evaluatedValue.cast (Variant::type_date);
|
||||
}
|
||||
else
|
||||
{
|
||||
evaluatedValue.cast (Variant::type_date);
|
||||
Context::getContext ().debug (label + _name + " <-- '" + format ("{1}", evaluatedValue.get_date ()) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + '\'');
|
||||
if (evaluatedValue.type() == Variant::type_duration) {
|
||||
Context::getContext().debug(label + _name + " <-- '" +
|
||||
format("{1}", format(evaluatedValue.get_duration())) + "' <-- '" +
|
||||
(std::string)evaluatedValue + "' <-- '" + value + '\'');
|
||||
evaluatedValue.cast(Variant::type_date);
|
||||
} else {
|
||||
evaluatedValue.cast(Variant::type_date);
|
||||
Context::getContext().debug(label + _name + " <-- '" +
|
||||
format("{1}", evaluatedValue.get_date()) + "' <-- '" +
|
||||
(std::string)evaluatedValue + "' <-- '" + value + '\'');
|
||||
}
|
||||
|
||||
// If a date doesn't parse (2/29/2014) then it evaluates to zero.
|
||||
if (value != "" &&
|
||||
evaluatedValue.get_date () == 0)
|
||||
throw format ("'{1}' is not a valid date in the '{2}' format.", value, Variant::dateFormat);
|
||||
if (value != "" && evaluatedValue.get_date() == 0)
|
||||
throw format("'{1}' is not a valid date in the '{2}' format.", value, Variant::dateFormat);
|
||||
|
||||
task.set (_name, evaluatedValue.get_date ());
|
||||
task.set(_name, evaluatedValue.get_date());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,20 +27,20 @@
|
|||
#ifndef INCLUDED_COLTYPEDATE
|
||||
#define INCLUDED_COLTYPEDATE
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Column.h>
|
||||
#include <Color.h>
|
||||
#include <Column.h>
|
||||
#include <Task.h>
|
||||
|
||||
class ColumnTypeDate : public Column
|
||||
{
|
||||
public:
|
||||
ColumnTypeDate ();
|
||||
virtual void measure (Task&, unsigned int&, unsigned int&);
|
||||
virtual void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
virtual bool validate (const std::string&) const;
|
||||
virtual void modify (Task&, const std::string&);
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class ColumnTypeDate : public Column {
|
||||
public:
|
||||
ColumnTypeDate();
|
||||
virtual void measure(Task&, unsigned int&, unsigned int&);
|
||||
virtual void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
virtual bool validate(const std::string&) const;
|
||||
virtual void modify(Task&, const std::string&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,50 +30,42 @@
|
|||
#include <ColTypeDuration.h>
|
||||
#include <Context.h>
|
||||
#include <Eval.h>
|
||||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <Variant.h>
|
||||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeDuration::ColumnTypeDuration ()
|
||||
{
|
||||
_type = "duration";
|
||||
ColumnTypeDuration::ColumnTypeDuration() { _type = "duration"; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnTypeDuration::validate(const std::string& input) const {
|
||||
return input.length() ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnTypeDuration::validate (const std::string& input) const
|
||||
{
|
||||
return input.length () ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnTypeDuration::modify (Task& task, const std::string& value)
|
||||
{
|
||||
void ColumnTypeDuration::modify(Task& task, const std::string& value) {
|
||||
// Try to evaluate 'value'. It might work.
|
||||
Variant evaluatedValue;
|
||||
try
|
||||
{
|
||||
try {
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
e.addSource(domSource);
|
||||
e.evaluateInfixExpression(value, evaluatedValue);
|
||||
}
|
||||
|
||||
catch (...)
|
||||
{
|
||||
evaluatedValue = Variant (value);
|
||||
catch (...) {
|
||||
evaluatedValue = Variant(value);
|
||||
}
|
||||
|
||||
// The duration is stored in raw form, but it must still be valid,
|
||||
// and therefore is parsed first.
|
||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||
if (evaluatedValue.type () == Variant::type_duration)
|
||||
{
|
||||
if (evaluatedValue.type() == Variant::type_duration) {
|
||||
// Store the raw value, for 'recur'.
|
||||
Context::getContext ().debug (label + _name + " <-- " + (std::string) evaluatedValue + " <-- '" + value + '\'');
|
||||
task.set (_name, evaluatedValue);
|
||||
}
|
||||
else
|
||||
throw format ("The duration value '{1}' is not supported.", value);
|
||||
Context::getContext().debug(label + _name + " <-- " + (std::string)evaluatedValue + " <-- '" +
|
||||
value + '\'');
|
||||
task.set(_name, evaluatedValue);
|
||||
} else
|
||||
throw format("The duration value '{1}' is not supported.", value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,16 +27,16 @@
|
|||
#ifndef INCLUDED_COLTYPEDURATION
|
||||
#define INCLUDED_COLTYPEDURATION
|
||||
|
||||
#include <string>
|
||||
#include <Column.h>
|
||||
#include <Task.h>
|
||||
|
||||
class ColumnTypeDuration : public Column
|
||||
{
|
||||
public:
|
||||
ColumnTypeDuration ();
|
||||
virtual bool validate (const std::string&) const;
|
||||
virtual void modify (Task&, const std::string&);
|
||||
#include <string>
|
||||
|
||||
class ColumnTypeDuration : public Column {
|
||||
public:
|
||||
ColumnTypeDuration();
|
||||
virtual bool validate(const std::string&) const;
|
||||
virtual void modify(Task&, const std::string&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,45 +30,38 @@
|
|||
#include <ColTypeNumeric.h>
|
||||
#include <Context.h>
|
||||
#include <Eval.h>
|
||||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <Variant.h>
|
||||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeNumeric::ColumnTypeNumeric ()
|
||||
{
|
||||
_type = "numeric";
|
||||
ColumnTypeNumeric::ColumnTypeNumeric() { _type = "numeric"; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnTypeNumeric::validate(const std::string& input) const {
|
||||
return input.length() ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnTypeNumeric::validate (const std::string& input) const
|
||||
{
|
||||
return input.length () ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnTypeNumeric::modify (Task& task, const std::string& value)
|
||||
{
|
||||
void ColumnTypeNumeric::modify(Task& task, const std::string& value) {
|
||||
// Try to evaluate 'value'. It might work.
|
||||
Variant evaluatedValue;
|
||||
try
|
||||
{
|
||||
try {
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
e.addSource(domSource);
|
||||
e.evaluateInfixExpression(value, evaluatedValue);
|
||||
}
|
||||
|
||||
catch (...)
|
||||
{
|
||||
evaluatedValue = Variant (value);
|
||||
catch (...) {
|
||||
evaluatedValue = Variant(value);
|
||||
}
|
||||
|
||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||
Context::getContext ().debug (label + _name + " <-- '" + evaluatedValue.get_string () + "' <-- '" + value + '\'');
|
||||
Context::getContext().debug(label + _name + " <-- '" + evaluatedValue.get_string() + "' <-- '" +
|
||||
value + '\'');
|
||||
|
||||
// Convert the value of the expression to the correct type if needed
|
||||
switch (evaluatedValue.type ())
|
||||
{
|
||||
switch (evaluatedValue.type()) {
|
||||
// Expected variants - no conversion
|
||||
case Variant::type_integer:
|
||||
case Variant::type_real:
|
||||
|
@ -76,16 +69,16 @@ void ColumnTypeNumeric::modify (Task& task, const std::string& value)
|
|||
// Convertible variants - convert to int
|
||||
case Variant::type_date:
|
||||
case Variant::type_duration:
|
||||
evaluatedValue.cast (Variant::type_integer);
|
||||
evaluatedValue.cast(Variant::type_integer);
|
||||
break;
|
||||
// Non-convertible variants
|
||||
case Variant::type_string:
|
||||
throw format ("The value '{1}' is not a valid numeric value.", evaluatedValue.get_string ());
|
||||
throw format("The value '{1}' is not a valid numeric value.", evaluatedValue.get_string());
|
||||
default:
|
||||
throw format ("Unexpected variant type: '{1}'", evaluatedValue.type ());
|
||||
throw format("Unexpected variant type: '{1}'", evaluatedValue.type());
|
||||
}
|
||||
|
||||
task.set (_name, evaluatedValue);
|
||||
task.set(_name, evaluatedValue);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,16 +27,16 @@
|
|||
#ifndef INCLUDED_COLTYPENUMERIC
|
||||
#define INCLUDED_COLTYPENUMERIC
|
||||
|
||||
#include <string>
|
||||
#include <Column.h>
|
||||
#include <Task.h>
|
||||
|
||||
class ColumnTypeNumeric : public Column
|
||||
{
|
||||
public:
|
||||
ColumnTypeNumeric ();
|
||||
virtual bool validate (const std::string&) const;
|
||||
virtual void modify (Task&, const std::string&);
|
||||
#include <string>
|
||||
|
||||
class ColumnTypeNumeric : public Column {
|
||||
public:
|
||||
ColumnTypeNumeric();
|
||||
virtual bool validate(const std::string&) const;
|
||||
virtual void modify(Task&, const std::string&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,64 +30,51 @@
|
|||
#include <ColTypeString.h>
|
||||
#include <Context.h>
|
||||
#include <Eval.h>
|
||||
#include <Variant.h>
|
||||
#include <Filter.h>
|
||||
#include <Variant.h>
|
||||
#include <format.h>
|
||||
|
||||
#define STRING_INVALID_MOD "The '{1}' attribute does not allow a value of '{2}'."
|
||||
#define STRING_INVALID_MOD "The '{1}' attribute does not allow a value of '{2}'."
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeString::ColumnTypeString ()
|
||||
{
|
||||
_type = "string";
|
||||
ColumnTypeString::ColumnTypeString() { _type = "string"; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnTypeString::validate(const std::string& input) const {
|
||||
return input.length() ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnTypeString::validate (const std::string& input) const
|
||||
{
|
||||
return input.length () ? true : false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnTypeString::modify (Task& task, const std::string& value)
|
||||
{
|
||||
void ColumnTypeString::modify(Task& task, const std::string& value) {
|
||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||
|
||||
// Only if it's a DOM ref, eval it first.
|
||||
Lexer lexer (value);
|
||||
Lexer lexer(value);
|
||||
std::string domRef;
|
||||
Lexer::Type type;
|
||||
if (lexer.token (domRef, type) &&
|
||||
type == Lexer::Type::dom &&
|
||||
if (lexer.token(domRef, type) && type == Lexer::Type::dom &&
|
||||
// Ensure 'value' contains only the DOM reference and no other tokens
|
||||
// The lexer.token returns false for end-of-string.
|
||||
// This works as long as all the DOM references we should support consist
|
||||
// only of a single token.
|
||||
lexer.token (domRef, type) == false)
|
||||
{
|
||||
lexer.token(domRef, type) == false) {
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
e.addSource(domSource);
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
std::string strValue = (std::string) v;
|
||||
if (validate (strValue))
|
||||
{
|
||||
task.set (_name, strValue);
|
||||
Context::getContext ().debug (label + _name + " <-- '" + strValue + "' <-- '" + value + '\'');
|
||||
}
|
||||
else
|
||||
throw format (STRING_INVALID_MOD, _name, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (validate (value))
|
||||
{
|
||||
task.set (_name, value);
|
||||
Context::getContext ().debug (label + _name + " <-- '" + value + '\'');
|
||||
}
|
||||
else
|
||||
throw format (STRING_INVALID_MOD, _name, value);
|
||||
e.evaluateInfixExpression(value, v);
|
||||
std::string strValue = (std::string)v;
|
||||
if (validate(strValue)) {
|
||||
task.set(_name, strValue);
|
||||
Context::getContext().debug(label + _name + " <-- '" + strValue + "' <-- '" + value + '\'');
|
||||
} else
|
||||
throw format(STRING_INVALID_MOD, _name, value);
|
||||
} else {
|
||||
if (validate(value)) {
|
||||
task.set(_name, value);
|
||||
Context::getContext().debug(label + _name + " <-- '" + value + '\'');
|
||||
} else
|
||||
throw format(STRING_INVALID_MOD, _name, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,16 +27,16 @@
|
|||
#ifndef INCLUDED_COLTYPESTRING
|
||||
#define INCLUDED_COLTYPESTRING
|
||||
|
||||
#include <string>
|
||||
#include <Column.h>
|
||||
#include <Task.h>
|
||||
|
||||
class ColumnTypeString : public Column
|
||||
{
|
||||
public:
|
||||
ColumnTypeString ();
|
||||
virtual bool validate (const std::string&) const;
|
||||
virtual void modify (Task&, const std::string&);
|
||||
#include <string>
|
||||
|
||||
class ColumnTypeString : public Column {
|
||||
public:
|
||||
ColumnTypeString();
|
||||
virtual bool validate(const std::string&) const;
|
||||
virtual void modify(Task&, const std::string&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,34 +31,30 @@
|
|||
#include <Context.h>
|
||||
#include <Datetime.h>
|
||||
#include <Duration.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
#include <shared.h>
|
||||
#include <stdlib.h>
|
||||
#include <utf8.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnUDAString::ColumnUDAString ()
|
||||
{
|
||||
_name = "<uda>"; // Gets overwritten at runtime.
|
||||
_style = "default";
|
||||
_label = "";
|
||||
ColumnUDAString::ColumnUDAString() {
|
||||
_name = "<uda>"; // Gets overwritten at runtime.
|
||||
_style = "default";
|
||||
_label = "";
|
||||
_modifiable = true;
|
||||
_uda = true;
|
||||
_hyphenate = true;
|
||||
_styles = {_style, "indicator"};
|
||||
_uda = true;
|
||||
_hyphenate = true;
|
||||
_styles = {_style, "indicator"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnUDAString::validate (const std::string& value) const
|
||||
{
|
||||
bool ColumnUDAString::validate(const std::string& value) const {
|
||||
// No restrictions.
|
||||
if (_values.size () == 0)
|
||||
return true;
|
||||
if (_values.size() == 0) return true;
|
||||
|
||||
// Look for exact match value.
|
||||
for (auto& i : _values)
|
||||
if (i == value)
|
||||
return true;
|
||||
if (i == value) return true;
|
||||
|
||||
// Fail if not found.
|
||||
return false;
|
||||
|
@ -67,83 +63,61 @@ bool ColumnUDAString::validate (const std::string& value) const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
//
|
||||
void ColumnUDAString::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnUDAString::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
std::string value = task.get (_name);
|
||||
if (value != "")
|
||||
{
|
||||
auto stripped = Color::strip (value);
|
||||
maximum = longestLine (stripped);
|
||||
minimum = longestWord (stripped);
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default") {
|
||||
std::string value = task.get(_name);
|
||||
if (value != "") {
|
||||
auto stripped = Color::strip(value);
|
||||
maximum = longestLine(stripped);
|
||||
minimum = longestWord(stripped);
|
||||
}
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
auto indicator = Context::getContext ().config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
indicator = "U";
|
||||
} else if (_style == "indicator") {
|
||||
auto indicator = Context::getContext().config.get("uda." + _name + ".indicator");
|
||||
if (indicator == "") indicator = "U";
|
||||
|
||||
minimum = maximum = utf8_width (indicator);
|
||||
minimum = maximum = utf8_width(indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnUDAString::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
std::string value = task.get (_name);
|
||||
std::vector <std::string> raw;
|
||||
wrapText (raw, value, width, _hyphenate);
|
||||
void ColumnUDAString::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default") {
|
||||
std::string value = task.get(_name);
|
||||
std::vector<std::string> raw;
|
||||
wrapText(raw, value, width, _hyphenate);
|
||||
|
||||
for (auto& i : raw)
|
||||
renderStringLeft (lines, width, color, i);
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
auto indicator = Context::getContext ().config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
indicator = "U";
|
||||
for (auto& i : raw) renderStringLeft(lines, width, color, i);
|
||||
} else if (_style == "indicator") {
|
||||
auto indicator = Context::getContext().config.get("uda." + _name + ".indicator");
|
||||
if (indicator == "") indicator = "U";
|
||||
|
||||
renderStringRight (lines, width, color, indicator);
|
||||
renderStringRight(lines, width, color, indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnUDANumeric::ColumnUDANumeric ()
|
||||
{
|
||||
_name = "<uda>";
|
||||
_type = "numeric";
|
||||
_style = "default";
|
||||
_label = "";
|
||||
_uda = true;
|
||||
_styles = {_style, "indicator"};
|
||||
ColumnUDANumeric::ColumnUDANumeric() {
|
||||
_name = "<uda>";
|
||||
_type = "numeric";
|
||||
_style = "default";
|
||||
_label = "";
|
||||
_uda = true;
|
||||
_styles = {_style, "indicator"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnUDANumeric::validate (const std::string& value) const
|
||||
{
|
||||
bool ColumnUDANumeric::validate(const std::string& value) const {
|
||||
// No restrictions.
|
||||
if (_values.size () == 0)
|
||||
return true;
|
||||
if (_values.size() == 0) return true;
|
||||
|
||||
// Look for exact match value.
|
||||
for (auto& i : _values)
|
||||
if (i == value)
|
||||
return true;
|
||||
if (i == value) return true;
|
||||
|
||||
// Fail if not found.
|
||||
return false;
|
||||
|
@ -152,75 +126,55 @@ bool ColumnUDANumeric::validate (const std::string& value) const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
//
|
||||
void ColumnUDANumeric::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnUDANumeric::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
auto value = task.get (_name);
|
||||
if (value != "")
|
||||
minimum = maximum = value.length ();
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
auto indicator = Context::getContext ().config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
indicator = "U";
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default") {
|
||||
auto value = task.get(_name);
|
||||
if (value != "") minimum = maximum = value.length();
|
||||
} else if (_style == "indicator") {
|
||||
auto indicator = Context::getContext().config.get("uda." + _name + ".indicator");
|
||||
if (indicator == "") indicator = "U";
|
||||
|
||||
minimum = maximum = utf8_width (indicator);
|
||||
minimum = maximum = utf8_width(indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnUDANumeric::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
auto value = task.get (_name);
|
||||
renderStringRight (lines, width, color, value);
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
auto indicator = Context::getContext ().config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
indicator = "U";
|
||||
void ColumnUDANumeric::render(std::vector<std::string>& lines, Task& task, int width,
|
||||
Color& color) {
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default") {
|
||||
auto value = task.get(_name);
|
||||
renderStringRight(lines, width, color, value);
|
||||
} else if (_style == "indicator") {
|
||||
auto indicator = Context::getContext().config.get("uda." + _name + ".indicator");
|
||||
if (indicator == "") indicator = "U";
|
||||
|
||||
renderStringRight (lines, width, color, indicator);
|
||||
renderStringRight(lines, width, color, indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnUDADate::ColumnUDADate ()
|
||||
{
|
||||
_name = "<uda>";
|
||||
_type = "date";
|
||||
_style = "default";
|
||||
_label = "";
|
||||
_uda = true;
|
||||
_styles = {_style, "indicator"};
|
||||
ColumnUDADate::ColumnUDADate() {
|
||||
_name = "<uda>";
|
||||
_type = "date";
|
||||
_style = "default";
|
||||
_label = "";
|
||||
_uda = true;
|
||||
_styles = {_style, "indicator"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnUDADate::validate (const std::string& value) const
|
||||
{
|
||||
bool ColumnUDADate::validate(const std::string& value) const {
|
||||
// No restrictions.
|
||||
if (_values.size () == 0)
|
||||
return true;
|
||||
if (_values.size() == 0) return true;
|
||||
|
||||
// Look for exact match value.
|
||||
for (auto& i : _values)
|
||||
if (i == value)
|
||||
return true;
|
||||
if (i == value) return true;
|
||||
|
||||
// Fail if not found.
|
||||
return false;
|
||||
|
@ -229,101 +183,77 @@ bool ColumnUDADate::validate (const std::string& value) const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
//
|
||||
void ColumnUDADate::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnUDADate::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
auto value = task.get (_name);
|
||||
if (value != "")
|
||||
{
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default") {
|
||||
auto value = task.get(_name);
|
||||
if (value != "") {
|
||||
// Determine the output date format, which uses a hierarchy of definitions.
|
||||
// rc.report.<report>.dateformat
|
||||
// rc.dateformat.report
|
||||
// rc.dateformat
|
||||
Datetime date (strtoll (value.c_str (), nullptr, 10));
|
||||
auto format = Context::getContext ().config.get ("report." + _report + ".dateformat");
|
||||
if (format == "")
|
||||
format = Context::getContext ().config.get ("dateformat.report");
|
||||
if (format == "")
|
||||
format = Context::getContext ().config.get ("dateformat");
|
||||
Datetime date(strtoll(value.c_str(), nullptr, 10));
|
||||
auto format = Context::getContext().config.get("report." + _report + ".dateformat");
|
||||
if (format == "") format = Context::getContext().config.get("dateformat.report");
|
||||
if (format == "") format = Context::getContext().config.get("dateformat");
|
||||
|
||||
minimum = maximum = Datetime::length (format);
|
||||
minimum = maximum = Datetime::length(format);
|
||||
}
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
auto indicator = Context::getContext ().config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
indicator = "U";
|
||||
} else if (_style == "indicator") {
|
||||
auto indicator = Context::getContext().config.get("uda." + _name + ".indicator");
|
||||
if (indicator == "") indicator = "U";
|
||||
|
||||
minimum = maximum = utf8_width (indicator);
|
||||
minimum = maximum = utf8_width(indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnUDADate::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
auto value = task.get (_name);
|
||||
void ColumnUDADate::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default") {
|
||||
auto value = task.get(_name);
|
||||
|
||||
// Determine the output date format, which uses a hierarchy of definitions.
|
||||
// rc.report.<report>.dateformat
|
||||
// rc.dateformat.report
|
||||
// rc.dateformat.
|
||||
auto format = Context::getContext ().config.get ("report." + _report + ".dateformat");
|
||||
if (format == "")
|
||||
{
|
||||
format = Context::getContext ().config.get ("dateformat.report");
|
||||
if (format == "")
|
||||
format = Context::getContext ().config.get ("dateformat");
|
||||
auto format = Context::getContext().config.get("report." + _report + ".dateformat");
|
||||
if (format == "") {
|
||||
format = Context::getContext().config.get("dateformat.report");
|
||||
if (format == "") format = Context::getContext().config.get("dateformat");
|
||||
}
|
||||
|
||||
renderStringLeft (lines, width, color, Datetime (strtoll (value.c_str (), nullptr, 10)).toString (format));
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
auto indicator = Context::getContext ().config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
indicator = "U";
|
||||
renderStringLeft(lines, width, color,
|
||||
Datetime(strtoll(value.c_str(), nullptr, 10)).toString(format));
|
||||
} else if (_style == "indicator") {
|
||||
auto indicator = Context::getContext().config.get("uda." + _name + ".indicator");
|
||||
if (indicator == "") indicator = "U";
|
||||
|
||||
renderStringRight (lines, width, color, indicator);
|
||||
renderStringRight(lines, width, color, indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnUDADuration::ColumnUDADuration ()
|
||||
{
|
||||
_name = "<uda>";
|
||||
_type = "duration";
|
||||
_style = "default";
|
||||
_label = "";
|
||||
_uda = true;
|
||||
_styles = {_style, "indicator"};
|
||||
ColumnUDADuration::ColumnUDADuration() {
|
||||
_name = "<uda>";
|
||||
_type = "duration";
|
||||
_style = "default";
|
||||
_label = "";
|
||||
_uda = true;
|
||||
_styles = {_style, "indicator"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool ColumnUDADuration::validate (const std::string& value) const
|
||||
{
|
||||
bool ColumnUDADuration::validate(const std::string& value) const {
|
||||
// No restrictions.
|
||||
if (_values.size () == 0)
|
||||
return true;
|
||||
if (_values.size() == 0) return true;
|
||||
|
||||
// Look for exact match value.
|
||||
for (auto& i : _values)
|
||||
if (i == value)
|
||||
return true;
|
||||
if (i == value) return true;
|
||||
|
||||
// Fail if not found.
|
||||
return false;
|
||||
|
@ -332,54 +262,36 @@ bool ColumnUDADuration::validate (const std::string& value) const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
//
|
||||
void ColumnUDADuration::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnUDADuration::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
minimum = maximum = 0;
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
auto value = task.get (_name);
|
||||
if (value != "")
|
||||
minimum = maximum = Duration (value).formatISO ().length ();
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
auto indicator = Context::getContext ().config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
indicator = "U";
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default") {
|
||||
auto value = task.get(_name);
|
||||
if (value != "") minimum = maximum = Duration(value).formatISO().length();
|
||||
} else if (_style == "indicator") {
|
||||
if (task.has(_name)) {
|
||||
auto indicator = Context::getContext().config.get("uda." + _name + ".indicator");
|
||||
if (indicator == "") indicator = "U";
|
||||
|
||||
minimum = maximum = utf8_width (indicator);
|
||||
}
|
||||
else
|
||||
minimum = maximum = utf8_width(indicator);
|
||||
} else
|
||||
minimum = maximum = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnUDADuration::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (task.has (_name))
|
||||
{
|
||||
if (_style == "default")
|
||||
{
|
||||
auto value = task.get (_name);
|
||||
renderStringRight (lines, width, color, Duration (value).formatISO ());
|
||||
}
|
||||
else if (_style == "indicator")
|
||||
{
|
||||
auto indicator = Context::getContext ().config.get ("uda." + _name + ".indicator");
|
||||
if (indicator == "")
|
||||
indicator = "U";
|
||||
void ColumnUDADuration::render(std::vector<std::string>& lines, Task& task, int width,
|
||||
Color& color) {
|
||||
if (task.has(_name)) {
|
||||
if (_style == "default") {
|
||||
auto value = task.get(_name);
|
||||
renderStringRight(lines, width, color, Duration(value).formatISO());
|
||||
} else if (_style == "indicator") {
|
||||
auto indicator = Context::getContext().config.get("uda." + _name + ".indicator");
|
||||
if (indicator == "") indicator = "U";
|
||||
|
||||
renderStringRight (lines, width, color, indicator);
|
||||
renderStringRight(lines, width, color, indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,64 +27,60 @@
|
|||
#ifndef INCLUDED_COLUDA
|
||||
#define INCLUDED_COLUDA
|
||||
|
||||
#include <ColTypeString.h>
|
||||
#include <ColTypeNumeric.h>
|
||||
#include <ColTypeDate.h>
|
||||
#include <ColTypeDuration.h>
|
||||
#include <ColTypeNumeric.h>
|
||||
#include <ColTypeString.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class ColumnUDAString : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnUDAString ();
|
||||
bool validate (const std::string&) const;
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnUDAString : public ColumnTypeString {
|
||||
public:
|
||||
ColumnUDAString();
|
||||
bool validate(const std::string&) const;
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
public:
|
||||
std::vector <std::string> _values;
|
||||
public:
|
||||
std::vector<std::string> _values;
|
||||
|
||||
private:
|
||||
private:
|
||||
bool _hyphenate;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class ColumnUDANumeric : public ColumnTypeNumeric
|
||||
{
|
||||
public:
|
||||
ColumnUDANumeric ();
|
||||
bool validate (const std::string&) const;
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnUDANumeric : public ColumnTypeNumeric {
|
||||
public:
|
||||
ColumnUDANumeric();
|
||||
bool validate(const std::string&) const;
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
public:
|
||||
std::vector <std::string> _values;
|
||||
public:
|
||||
std::vector<std::string> _values;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class ColumnUDADate : public ColumnTypeDate
|
||||
{
|
||||
public:
|
||||
ColumnUDADate ();
|
||||
bool validate (const std::string&) const;
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnUDADate : public ColumnTypeDate {
|
||||
public:
|
||||
ColumnUDADate();
|
||||
bool validate(const std::string&) const;
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
public:
|
||||
std::vector <std::string> _values;
|
||||
public:
|
||||
std::vector<std::string> _values;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class ColumnUDADuration : public ColumnTypeDuration
|
||||
{
|
||||
public:
|
||||
ColumnUDADuration ();
|
||||
bool validate (const std::string&) const;
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnUDADuration : public ColumnTypeDuration {
|
||||
public:
|
||||
ColumnUDADuration();
|
||||
bool validate(const std::string&) const;
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
public:
|
||||
std::vector <std::string> _values;
|
||||
public:
|
||||
std::vector<std::string> _values;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,43 +31,37 @@
|
|||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnUUID::ColumnUUID ()
|
||||
{
|
||||
_name = "uuid";
|
||||
_style = "long";
|
||||
_label = "UUID";
|
||||
ColumnUUID::ColumnUUID() {
|
||||
_name = "uuid";
|
||||
_style = "long";
|
||||
_label = "UUID";
|
||||
_modifiable = false;
|
||||
_styles = {"long", "short"};
|
||||
_examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "f30cb9c3"};
|
||||
_styles = {"long", "short"};
|
||||
_examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "f30cb9c3"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnUUID::measure (Task&, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnUUID::measure(Task&, unsigned int& minimum, unsigned int& maximum) {
|
||||
// Mandatory attribute, no need to check the value.
|
||||
|
||||
if (_style == "default" || _style == "long") minimum = maximum = 36;
|
||||
else if (_style == "short") minimum = maximum = 8;
|
||||
if (_style == "default" || _style == "long")
|
||||
minimum = maximum = 36;
|
||||
else if (_style == "short")
|
||||
minimum = maximum = 8;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnUUID::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
void ColumnUUID::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
// No need to check the presence of UUID - all tasks have one.
|
||||
|
||||
// f30cb9c3-3fc0-483f-bfb2-3bf134f00694 default
|
||||
// f30cb9c3 short
|
||||
if (_style == "default" ||
|
||||
_style == "long")
|
||||
renderStringLeft (lines, width, color, task.get (_name));
|
||||
if (_style == "default" || _style == "long")
|
||||
renderStringLeft(lines, width, color, task.get(_name));
|
||||
|
||||
else if (_style == "short")
|
||||
renderStringLeft (lines, width, color, task.get (_name).substr (0, 8));
|
||||
renderStringLeft(lines, width, color, task.get(_name).substr(0, 8));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
|
||||
#include <ColTypeString.h>
|
||||
|
||||
class ColumnUUID : public ColumnTypeString
|
||||
{
|
||||
public:
|
||||
ColumnUUID ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnUUID : public ColumnTypeString {
|
||||
public:
|
||||
ColumnUUID();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,9 +30,8 @@
|
|||
#include <ColUntil.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnUntil::ColumnUntil ()
|
||||
{
|
||||
_name = "until";
|
||||
ColumnUntil::ColumnUntil() {
|
||||
_name = "until";
|
||||
_label = "Until";
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,9 @@
|
|||
|
||||
#include <ColTypeDate.h>
|
||||
|
||||
class ColumnUntil : public ColumnTypeDate
|
||||
{
|
||||
public:
|
||||
ColumnUntil ();
|
||||
class ColumnUntil : public ColumnTypeDate {
|
||||
public:
|
||||
ColumnUntil();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,39 +31,32 @@
|
|||
#include <format.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnUrgency::ColumnUrgency ()
|
||||
{
|
||||
_name = "urgency";
|
||||
_style = "real";
|
||||
_label = "Urgency";
|
||||
ColumnUrgency::ColumnUrgency() {
|
||||
_name = "urgency";
|
||||
_style = "real";
|
||||
_label = "Urgency";
|
||||
_modifiable = false;
|
||||
_styles = {"real", "integer"};
|
||||
_examples = {"4.6", "4"};
|
||||
_styles = {"real", "integer"};
|
||||
_examples = {"4.6", "4"};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set the minimum and maximum widths for the value.
|
||||
void ColumnUrgency::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
|
||||
{
|
||||
void ColumnUrgency::measure(Task& task, unsigned int& minimum, unsigned int& maximum) {
|
||||
if (_style == "default" || _style == "real")
|
||||
minimum = maximum = format (task.urgency (), 4, 3).length ();
|
||||
minimum = maximum = format(task.urgency(), 4, 3).length();
|
||||
|
||||
else if (_style == "integer")
|
||||
minimum = maximum = format ((int)task.urgency ()).length ();
|
||||
minimum = maximum = format((int)task.urgency()).length();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void ColumnUrgency::render (
|
||||
std::vector <std::string>& lines,
|
||||
Task& task,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
void ColumnUrgency::render(std::vector<std::string>& lines, Task& task, int width, Color& color) {
|
||||
if (_style == "default" || _style == "real")
|
||||
renderDouble (lines, width, color, task.urgency ());
|
||||
renderDouble(lines, width, color, task.urgency());
|
||||
|
||||
else if (_style == "integer")
|
||||
renderInteger (lines, width, color, static_cast <int> (task.urgency ()));
|
||||
renderInteger(lines, width, color, static_cast<int>(task.urgency()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,14 +29,13 @@
|
|||
|
||||
#include <ColTypeNumeric.h>
|
||||
|
||||
class ColumnUrgency : public ColumnTypeNumeric
|
||||
{
|
||||
public:
|
||||
ColumnUrgency ();
|
||||
void measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
class ColumnUrgency : public ColumnTypeNumeric {
|
||||
public:
|
||||
ColumnUrgency();
|
||||
void measure(Task&, unsigned int&, unsigned int&);
|
||||
void render(std::vector<std::string>&, Task&, int, Color&);
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,9 +30,8 @@
|
|||
#include <ColWait.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnWait::ColumnWait ()
|
||||
{
|
||||
_name = "wait";
|
||||
ColumnWait::ColumnWait() {
|
||||
_name = "wait";
|
||||
_label = "Wait";
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,9 @@
|
|||
|
||||
#include <ColTypeDate.h>
|
||||
|
||||
class ColumnWait : public ColumnTypeDate
|
||||
{
|
||||
public:
|
||||
ColumnWait ();
|
||||
class ColumnWait : public ColumnTypeDate {
|
||||
public:
|
||||
ColumnWait();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -27,10 +27,6 @@
|
|||
#include <cmake.h>
|
||||
// cmake.h include header must come first
|
||||
|
||||
#include <Column.h>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <Context.h>
|
||||
#include <ColDepends.h>
|
||||
#include <ColDescription.h>
|
||||
#include <ColDue.h>
|
||||
|
@ -43,294 +39,283 @@
|
|||
#include <ColModified.h>
|
||||
#include <ColParent.h>
|
||||
#include <ColProject.h>
|
||||
#include <ColRecur.h>
|
||||
#include <ColRType.h>
|
||||
#include <ColRecur.h>
|
||||
#include <ColScheduled.h>
|
||||
#include <ColStart.h>
|
||||
#include <ColStatus.h>
|
||||
#include <ColTags.h>
|
||||
#include <ColTemplate.h>
|
||||
#include <ColUDA.h>
|
||||
#include <ColUUID.h>
|
||||
#include <ColUntil.h>
|
||||
#include <ColUrgency.h>
|
||||
#include <ColUUID.h>
|
||||
#include <ColUDA.h>
|
||||
#include <ColWait.h>
|
||||
#include <shared.h>
|
||||
#include <Column.h>
|
||||
#include <Context.h>
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Supports the complete column definition:
|
||||
//
|
||||
// <type>[.<format>]
|
||||
//
|
||||
Column* Column::factory (const std::string& name, const std::string& report)
|
||||
{
|
||||
Column* Column::factory(const std::string& name, const std::string& report) {
|
||||
// Decompose name into type and style.
|
||||
auto dot = name.find ('.');
|
||||
auto dot = name.find('.');
|
||||
std::string column_name;
|
||||
std::string column_style;
|
||||
if (dot != std::string::npos)
|
||||
{
|
||||
column_name = name.substr (0, dot);
|
||||
column_style = name.substr (dot + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dot != std::string::npos) {
|
||||
column_name = name.substr(0, dot);
|
||||
column_style = name.substr(dot + 1);
|
||||
} else {
|
||||
column_name = name;
|
||||
column_style = "default";
|
||||
}
|
||||
|
||||
Column* c;
|
||||
if (column_name == "depends") c = new ColumnDepends ();
|
||||
else if (column_name == "description") c = new ColumnDescription ();
|
||||
else if (column_name == "due") c = new ColumnDue ();
|
||||
else if (column_name == "end") c = new ColumnEnd ();
|
||||
else if (column_name == "entry") c = new ColumnEntry ();
|
||||
else if (column_name == "id") c = new ColumnID ();
|
||||
else if (column_name == "imask") c = new ColumnIMask ();
|
||||
else if (column_name == "last") c = new ColumnLast ();
|
||||
else if (column_name == "mask") c = new ColumnMask ();
|
||||
else if (column_name == "modified") c = new ColumnModified ();
|
||||
else if (column_name == "parent") c = new ColumnParent ();
|
||||
else if (column_name == "project") c = new ColumnProject ();
|
||||
else if (column_name == "recur") c = new ColumnRecur ();
|
||||
else if (column_name == "rtype") c = new ColumnRType ();
|
||||
else if (column_name == "scheduled") c = new ColumnScheduled ();
|
||||
else if (column_name == "start") c = new ColumnStart ();
|
||||
else if (column_name == "status") c = new ColumnStatus ();
|
||||
else if (column_name == "tags") c = new ColumnTags ();
|
||||
else if (column_name == "template") c = new ColumnTemplate ();
|
||||
else if (column_name == "until") c = new ColumnUntil ();
|
||||
else if (column_name == "urgency") c = new ColumnUrgency ();
|
||||
else if (column_name == "uuid") c = new ColumnUUID ();
|
||||
else if (column_name == "wait") c = new ColumnWait ();
|
||||
if (column_name == "depends")
|
||||
c = new ColumnDepends();
|
||||
else if (column_name == "description")
|
||||
c = new ColumnDescription();
|
||||
else if (column_name == "due")
|
||||
c = new ColumnDue();
|
||||
else if (column_name == "end")
|
||||
c = new ColumnEnd();
|
||||
else if (column_name == "entry")
|
||||
c = new ColumnEntry();
|
||||
else if (column_name == "id")
|
||||
c = new ColumnID();
|
||||
else if (column_name == "imask")
|
||||
c = new ColumnIMask();
|
||||
else if (column_name == "last")
|
||||
c = new ColumnLast();
|
||||
else if (column_name == "mask")
|
||||
c = new ColumnMask();
|
||||
else if (column_name == "modified")
|
||||
c = new ColumnModified();
|
||||
else if (column_name == "parent")
|
||||
c = new ColumnParent();
|
||||
else if (column_name == "project")
|
||||
c = new ColumnProject();
|
||||
else if (column_name == "recur")
|
||||
c = new ColumnRecur();
|
||||
else if (column_name == "rtype")
|
||||
c = new ColumnRType();
|
||||
else if (column_name == "scheduled")
|
||||
c = new ColumnScheduled();
|
||||
else if (column_name == "start")
|
||||
c = new ColumnStart();
|
||||
else if (column_name == "status")
|
||||
c = new ColumnStatus();
|
||||
else if (column_name == "tags")
|
||||
c = new ColumnTags();
|
||||
else if (column_name == "template")
|
||||
c = new ColumnTemplate();
|
||||
else if (column_name == "until")
|
||||
c = new ColumnUntil();
|
||||
else if (column_name == "urgency")
|
||||
c = new ColumnUrgency();
|
||||
else if (column_name == "uuid")
|
||||
c = new ColumnUUID();
|
||||
else if (column_name == "wait")
|
||||
c = new ColumnWait();
|
||||
|
||||
// UDA.
|
||||
else if (Context::getContext ().config.has ("uda." + column_name + ".type"))
|
||||
c = Column::uda (column_name);
|
||||
else if (Context::getContext().config.has("uda." + column_name + ".type"))
|
||||
c = Column::uda(column_name);
|
||||
|
||||
else
|
||||
throw format ("Unrecognized column name '{1}'.", column_name);
|
||||
throw format("Unrecognized column name '{1}'.", column_name);
|
||||
|
||||
c->setReport (report);
|
||||
c->setStyle (column_style);
|
||||
c->setReport(report);
|
||||
c->setStyle(column_style);
|
||||
return c;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Bulk column instantiation.
|
||||
void Column::factory (std::map <std::string, Column*>& all)
|
||||
{
|
||||
void Column::factory(std::map<std::string, Column*>& all) {
|
||||
Column* c;
|
||||
|
||||
c = new ColumnDepends (); all[c->_name] = c;
|
||||
c = new ColumnDescription (); all[c->_name] = c;
|
||||
c = new ColumnDue (); all[c->_name] = c;
|
||||
c = new ColumnEnd (); all[c->_name] = c;
|
||||
c = new ColumnEntry (); all[c->_name] = c;
|
||||
c = new ColumnID (); all[c->_name] = c;
|
||||
c = new ColumnIMask (); all[c->_name] = c;
|
||||
c = new ColumnLast (); all[c->_name] = c;
|
||||
c = new ColumnMask (); all[c->_name] = c;
|
||||
c = new ColumnModified (); all[c->_name] = c;
|
||||
c = new ColumnParent (); all[c->_name] = c;
|
||||
c = new ColumnProject (); all[c->_name] = c;
|
||||
c = new ColumnRecur (); all[c->_name] = c;
|
||||
c = new ColumnRType (); all[c->_name] = c;
|
||||
c = new ColumnScheduled (); all[c->_name] = c;
|
||||
c = new ColumnStart (); all[c->_name] = c;
|
||||
c = new ColumnStatus (); all[c->_name] = c;
|
||||
c = new ColumnTags (); all[c->_name] = c;
|
||||
c = new ColumnTemplate (); all[c->_name] = c;
|
||||
c = new ColumnUntil (); all[c->_name] = c;
|
||||
c = new ColumnUrgency (); all[c->_name] = c;
|
||||
c = new ColumnUUID (); all[c->_name] = c;
|
||||
c = new ColumnWait (); all[c->_name] = c;
|
||||
c = new ColumnDepends();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnDescription();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnDue();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnEnd();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnEntry();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnID();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnIMask();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnLast();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnMask();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnModified();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnParent();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnProject();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnRecur();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnRType();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnScheduled();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnStart();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnStatus();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnTags();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnTemplate();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnUntil();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnUrgency();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnUUID();
|
||||
all[c->_name] = c;
|
||||
c = new ColumnWait();
|
||||
all[c->_name] = c;
|
||||
|
||||
Column::uda (all);
|
||||
Column::uda(all);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Column::uda (std::map <std::string, Column*>& all)
|
||||
{
|
||||
void Column::uda(std::map<std::string, Column*>& all) {
|
||||
// For each UDA, instantiate and initialize ColumnUDA.
|
||||
std::set <std::string> udas;
|
||||
std::set<std::string> udas;
|
||||
|
||||
for (const auto& i : Context::getContext ().config)
|
||||
{
|
||||
if (i.first.substr (0, 4) == "uda.")
|
||||
{
|
||||
std::string::size_type period = 4; // One byte after the first '.'.
|
||||
for (const auto& i : Context::getContext().config) {
|
||||
if (i.first.substr(0, 4) == "uda.") {
|
||||
std::string::size_type period = 4; // One byte after the first '.'.
|
||||
|
||||
if ((period = i.first.find ('.', period)) != std::string::npos)
|
||||
udas.insert (i.first.substr (4, period - 4));
|
||||
if ((period = i.first.find('.', period)) != std::string::npos)
|
||||
udas.insert(i.first.substr(4, period - 4));
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& uda : udas)
|
||||
{
|
||||
if (all.find (uda) != all.end ())
|
||||
throw format ("The UDA named '{1}' is the same as a core attribute, and is not permitted.", uda);
|
||||
for (const auto& uda : udas) {
|
||||
if (all.find(uda) != all.end())
|
||||
throw format("The UDA named '{1}' is the same as a core attribute, and is not permitted.",
|
||||
uda);
|
||||
|
||||
Column* c = Column::uda (uda);
|
||||
if (c)
|
||||
all[c->_name] = c;
|
||||
Column* c = Column::uda(uda);
|
||||
if (c) all[c->_name] = c;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Column* Column::uda (const std::string& name)
|
||||
{
|
||||
auto type = Context::getContext ().config.get ("uda." + name + ".type");
|
||||
auto label = Context::getContext ().config.get ("uda." + name + ".label");
|
||||
auto values = Context::getContext ().config.get ("uda." + name + ".values");
|
||||
Column* Column::uda(const std::string& name) {
|
||||
auto type = Context::getContext().config.get("uda." + name + ".type");
|
||||
auto label = Context::getContext().config.get("uda." + name + ".label");
|
||||
auto values = Context::getContext().config.get("uda." + name + ".values");
|
||||
|
||||
if (type == "string")
|
||||
{
|
||||
auto c = new ColumnUDAString ();
|
||||
if (type == "string") {
|
||||
auto c = new ColumnUDAString();
|
||||
c->_name = name;
|
||||
c->_label = label;
|
||||
if (values != "")
|
||||
c->_values = split (values, ',');
|
||||
if (values != "") c->_values = split(values, ',');
|
||||
return c;
|
||||
}
|
||||
else if (type == "numeric")
|
||||
{
|
||||
auto c = new ColumnUDANumeric ();
|
||||
} else if (type == "numeric") {
|
||||
auto c = new ColumnUDANumeric();
|
||||
c->_name = name;
|
||||
c->_label = label;
|
||||
if (values != "")
|
||||
c->_values = split (values, ',');
|
||||
if (values != "") c->_values = split(values, ',');
|
||||
return c;
|
||||
}
|
||||
else if (type == "date")
|
||||
{
|
||||
auto c = new ColumnUDADate ();
|
||||
} else if (type == "date") {
|
||||
auto c = new ColumnUDADate();
|
||||
c->_name = name;
|
||||
c->_label = label;
|
||||
if (values != "")
|
||||
c->_values = split (values, ',');
|
||||
if (values != "") c->_values = split(values, ',');
|
||||
return c;
|
||||
}
|
||||
else if (type == "duration")
|
||||
{
|
||||
auto c = new ColumnUDADuration ();
|
||||
} else if (type == "duration") {
|
||||
auto c = new ColumnUDADuration();
|
||||
c->_name = name;
|
||||
c->_label = label;
|
||||
if (values != "")
|
||||
c->_values = split (values, ',');
|
||||
if (values != "") c->_values = split(values, ',');
|
||||
return c;
|
||||
}
|
||||
else if (type != "")
|
||||
throw std::string ("User defined attributes may only be of type 'string', 'date', 'duration' or 'numeric'.");
|
||||
} else if (type != "")
|
||||
throw std::string(
|
||||
"User defined attributes may only be of type 'string', 'date', 'duration' or 'numeric'.");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Column::Column ()
|
||||
: _name ("")
|
||||
, _type ("string")
|
||||
, _style ("default")
|
||||
, _label ("")
|
||||
, _report ("")
|
||||
, _modifiable (true)
|
||||
, _uda (false)
|
||||
, _fixed_width (false)
|
||||
{
|
||||
}
|
||||
Column::Column()
|
||||
: _name(""),
|
||||
_type("string"),
|
||||
_style("default"),
|
||||
_label(""),
|
||||
_report(""),
|
||||
_modifiable(true),
|
||||
_uda(false),
|
||||
_fixed_width(false) {}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Column::renderHeader (
|
||||
std::vector <std::string>& lines,
|
||||
int width,
|
||||
Color& color)
|
||||
{
|
||||
if (Context::getContext ().verbose ("label") &&
|
||||
_label != "")
|
||||
{
|
||||
void Column::renderHeader(std::vector<std::string>& lines, int width, Color& color) {
|
||||
if (Context::getContext().verbose("label") && _label != "") {
|
||||
// Create a basic label.
|
||||
std::string header;
|
||||
header.reserve (width);
|
||||
header.reserve(width);
|
||||
header = _label;
|
||||
|
||||
// Create a fungible copy.
|
||||
Color c = color;
|
||||
|
||||
// Now underline the header, or add a dashed line.
|
||||
if (Context::getContext ().color () &&
|
||||
Context::getContext ().config.getBoolean ("fontunderline"))
|
||||
{
|
||||
c.blend (Color (Color::nocolor, Color::nocolor, true, false, false));
|
||||
lines.push_back (c.colorize (leftJustify (header, width)));
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.push_back (c.colorize (leftJustify (header, width)));
|
||||
lines.push_back (c.colorize (std::string (width, '-')));
|
||||
if (Context::getContext().color() && Context::getContext().config.getBoolean("fontunderline")) {
|
||||
c.blend(Color(Color::nocolor, Color::nocolor, true, false, false));
|
||||
lines.push_back(c.colorize(leftJustify(header, width)));
|
||||
} else {
|
||||
lines.push_back(c.colorize(leftJustify(header, width)));
|
||||
lines.push_back(c.colorize(std::string(width, '-')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Column::setStyle (const std::string& style)
|
||||
{
|
||||
if (style != "default" &&
|
||||
std::find (_styles.begin (), _styles.end (), style) == _styles.end ())
|
||||
throw format ("Unrecognized column format '{1}.{2}'", _name, style);
|
||||
void Column::setStyle(const std::string& style) {
|
||||
if (style != "default" && std::find(_styles.begin(), _styles.end(), style) == _styles.end())
|
||||
throw format("Unrecognized column format '{1}.{2}'", _name, style);
|
||||
|
||||
_style = style;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// All integer values are right-justified.
|
||||
void Column::renderInteger (
|
||||
std::vector <std::string>& lines,
|
||||
int width,
|
||||
Color& color,
|
||||
int value)
|
||||
{
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (value, width)));
|
||||
void Column::renderInteger(std::vector<std::string>& lines, int width, Color& color, int value) {
|
||||
lines.push_back(color.colorize(rightJustify(value, width)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// All floating point values are right-justified.
|
||||
void Column::renderDouble (
|
||||
std::vector <std::string>& lines,
|
||||
int width,
|
||||
Color& color,
|
||||
double value)
|
||||
{
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (
|
||||
format (value, 4, 3), width)));
|
||||
void Column::renderDouble(std::vector<std::string>& lines, int width, Color& color, double value) {
|
||||
lines.push_back(color.colorize(rightJustify(format(value, 4, 3), width)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Column::renderStringLeft (
|
||||
std::vector <std::string>& lines,
|
||||
int width,
|
||||
Color& color,
|
||||
const std::string& value)
|
||||
{
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
leftJustify (value, width)));
|
||||
void Column::renderStringLeft(std::vector<std::string>& lines, int width, Color& color,
|
||||
const std::string& value) {
|
||||
lines.push_back(color.colorize(leftJustify(value, width)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Column::renderStringRight (
|
||||
std::vector <std::string>& lines,
|
||||
int width,
|
||||
Color& color,
|
||||
const std::string& value)
|
||||
{
|
||||
lines.push_back (
|
||||
color.colorize (
|
||||
rightJustify (value, width)));
|
||||
void Column::renderStringRight(std::vector<std::string>& lines, int width, Color& color,
|
||||
const std::string& value) {
|
||||
lines.push_back(color.colorize(rightJustify(value, width)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,51 +27,51 @@
|
|||
#ifndef INCLUDED_COLUMN
|
||||
#define INCLUDED_COLUMN
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Color.h>
|
||||
#include <Task.h>
|
||||
|
||||
class Column
|
||||
{
|
||||
public:
|
||||
static Column* factory (const std::string&, const std::string&);
|
||||
static void factory (std::map <std::string, Column*>&);
|
||||
static void uda (std::map <std::string, Column*>&);
|
||||
static Column* uda (const std::string&);
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
Column ();
|
||||
virtual ~Column () = default;
|
||||
class Column {
|
||||
public:
|
||||
static Column* factory(const std::string&, const std::string&);
|
||||
static void factory(std::map<std::string, Column*>&);
|
||||
static void uda(std::map<std::string, Column*>&);
|
||||
static Column* uda(const std::string&);
|
||||
|
||||
const std::string& name () const { return _name; }
|
||||
const std::string& style () const { return _style; }
|
||||
const std::string& label () const { return _label; }
|
||||
const std::string& type () const { return _type; }
|
||||
bool modifiable () const { return _modifiable; }
|
||||
bool is_uda () const { return _uda; }
|
||||
bool is_fixed_width () const { return _fixed_width; }
|
||||
std::vector <std::string> styles () const { return _styles; }
|
||||
std::vector <std::string> examples () const { return _examples; }
|
||||
Column();
|
||||
virtual ~Column() = default;
|
||||
|
||||
virtual void setStyle (const std::string&);
|
||||
virtual void setLabel (const std::string& value) { _label = value; }
|
||||
virtual void setReport (const std::string& value) { _report = value; }
|
||||
const std::string& name() const { return _name; }
|
||||
const std::string& style() const { return _style; }
|
||||
const std::string& label() const { return _label; }
|
||||
const std::string& type() const { return _type; }
|
||||
bool modifiable() const { return _modifiable; }
|
||||
bool is_uda() const { return _uda; }
|
||||
bool is_fixed_width() const { return _fixed_width; }
|
||||
std::vector<std::string> styles() const { return _styles; }
|
||||
std::vector<std::string> examples() const { return _examples; }
|
||||
|
||||
virtual void measure (const std::string&, unsigned int&, unsigned int&) {};
|
||||
virtual void measure (Task&, unsigned int&, unsigned int&) {};
|
||||
virtual void renderHeader (std::vector <std::string>&, int, Color&);
|
||||
virtual void render (std::vector <std::string>&, const std::string&, int, Color&) {};
|
||||
virtual void render (std::vector <std::string>&, Task&, int, Color&) {};
|
||||
virtual bool validate (const std::string&) const {return false;};
|
||||
virtual void modify (Task&, const std::string&) {};
|
||||
virtual void setStyle(const std::string&);
|
||||
virtual void setLabel(const std::string& value) { _label = value; }
|
||||
virtual void setReport(const std::string& value) { _report = value; }
|
||||
|
||||
protected:
|
||||
void renderInteger (std::vector <std::string>&, int, Color&, int);
|
||||
void renderDouble (std::vector <std::string>&, int, Color&, double);
|
||||
void renderStringLeft (std::vector <std::string>&, int, Color&, const std::string&);
|
||||
void renderStringRight (std::vector <std::string>&, int, Color&, const std::string&);
|
||||
virtual void measure(const std::string&, unsigned int&, unsigned int&) {};
|
||||
virtual void measure(Task&, unsigned int&, unsigned int&) {};
|
||||
virtual void renderHeader(std::vector<std::string>&, int, Color&);
|
||||
virtual void render(std::vector<std::string>&, const std::string&, int, Color&) {};
|
||||
virtual void render(std::vector<std::string>&, Task&, int, Color&) {};
|
||||
virtual bool validate(const std::string&) const { return false; };
|
||||
virtual void modify(Task&, const std::string&) {};
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void renderInteger(std::vector<std::string>&, int, Color&, int);
|
||||
void renderDouble(std::vector<std::string>&, int, Color&, double);
|
||||
void renderStringLeft(std::vector<std::string>&, int, Color&, const std::string&);
|
||||
void renderStringRight(std::vector<std::string>&, int, Color&, const std::string&);
|
||||
|
||||
protected:
|
||||
std::string _name;
|
||||
std::string _type;
|
||||
std::string _style;
|
||||
|
@ -80,8 +80,8 @@ protected:
|
|||
bool _modifiable;
|
||||
bool _uda;
|
||||
bool _fixed_width;
|
||||
std::vector <std::string> _styles;
|
||||
std::vector <std::string> _examples;
|
||||
std::vector<std::string> _styles;
|
||||
std::vector<std::string> _examples;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue