Task: Migrated part of ::modify to ColTags
This commit is contained in:
45
src/Task.cpp
45
src/Task.cpp
@@ -2006,53 +2006,14 @@ void Task::modify (modType type, bool text_required /* = false */)
|
|||||||
evaluatedValue = Variant (value);
|
evaluatedValue = Variant (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dependencies are specified as IDs.
|
// Dependencies are specified as IDs or UUIDs.
|
||||||
if (name == "depends")
|
if (name == "depends" ||
|
||||||
|
name == "tags")
|
||||||
{
|
{
|
||||||
column->modify (*this, value);
|
column->modify (*this, value);
|
||||||
mods = true;
|
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.
|
// Dates are special, maybe.
|
||||||
else if (column->type () == "date")
|
else if (column->type () == "date")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,11 +28,17 @@
|
|||||||
#include <ColTags.h>
|
#include <ColTags.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Eval.h>
|
||||||
|
#include <Variant.h>
|
||||||
|
#include <Filter.h>
|
||||||
|
#include <Dates.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <utf8.h>
|
#include <utf8.h>
|
||||||
|
#include <main.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
extern Task& contextTask;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ColumnTags::ColumnTags ()
|
ColumnTags::ColumnTags ()
|
||||||
@@ -146,3 +152,43 @@ void ColumnTags::render (
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void ColumnTags::modify (Task& task, const std::string& value)
|
||||||
|
{
|
||||||
|
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public:
|
|||||||
void setStyle (const std::string&);
|
void setStyle (const std::string&);
|
||||||
void measure (Task&, unsigned int&, unsigned int&);
|
void measure (Task&, unsigned int&, unsigned int&);
|
||||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||||
|
void modify (Task&, const std::string&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _hyphenate;
|
bool _hyphenate;
|
||||||
|
|||||||
Reference in New Issue
Block a user