Task: Migrated part of ::modify to ColTags

This commit is contained in:
Paul Beckingham 2016-01-31 17:23:19 -05:00
parent c6f9d2c4b2
commit f0b9ceb17b
3 changed files with 50 additions and 42 deletions

View file

@ -2006,53 +2006,14 @@ void Task::modify (modType type, bool text_required /* = false */)
evaluatedValue = Variant (value);
}
// Dependencies are specified as IDs.
if (name == "depends")
// Dependencies are specified as IDs or UUIDs.
if (name == "depends" ||
name == "tags")
{
column->modify (*this, value);
mods = true;
}
// For those using the "tags:..." attribute directly.
else if (name == "tags")
{
// TW-1701
set ("tags", "");
std::vector <std::string> tags;
split (tags, value, ',');
for (auto& tag : tags)
{
// If it's a DOM ref, eval it first.
Lexer lexer (tag);
std::string domRef;
Lexer::Type type;
if (lexer.token (domRef, type) &&
type == Lexer::Type::dom)
{
Eval e;
e.addSource (domSource);
e.addSource (namedDates);
contextTask = *this;
Variant v;
e.evaluateInfixExpression (value, v);
addTag ((std::string) v);
context.debug (label + "tags <-- '" + (std::string) v + "' <-- '" + tag + "'");
}
else
{
addTag (tag);
context.debug (label + "tags <-- '" + tag + "'");
}
feedback_special_tags (*this, tag);
}
mods = true;
}
// Dates are special, maybe.
else if (column->type () == "date")
{

View file

@ -28,11 +28,17 @@
#include <ColTags.h>
#include <algorithm>
#include <Context.h>
#include <Eval.h>
#include <Variant.h>
#include <Filter.h>
#include <Dates.h>
#include <text.h>
#include <i18n.h>
#include <utf8.h>
#include <main.h>
extern Context context;
extern Task& contextTask;
////////////////////////////////////////////////////////////////////////////////
ColumnTags::ColumnTags ()
@ -146,3 +152,43 @@ void ColumnTags::render (
}
////////////////////////////////////////////////////////////////////////////////
void ColumnTags::modify (Task& task, const std::string& value)
{
std::string label = " MODIFICATION ";
// TW-1701
task.set ("tags", "");
std::vector <std::string> tags;
split (tags, value, ',');
for (auto& tag : tags)
{
// If it's a DOM ref, eval it first.
Lexer lexer (tag);
std::string domRef;
Lexer::Type type;
if (lexer.token (domRef, type) &&
type == Lexer::Type::dom)
{
Eval e;
e.addSource (domSource);
e.addSource (namedDates);
contextTask = task;
Variant v;
e.evaluateInfixExpression (value, v);
task.addTag ((std::string) v);
context.debug (label + "tags <-- '" + (std::string) v + "' <-- '" + tag + "'");
}
else
{
task.addTag (tag);
context.debug (label + "tags <-- '" + tag + "'");
}
feedback_special_tags (task, tag);
}
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -36,6 +36,7 @@ public:
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:
bool _hyphenate;