mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 09:53:08 +02:00
Task: Migrated part of ::modify to ColTags
This commit is contained in:
parent
c6f9d2c4b2
commit
f0b9ceb17b
3 changed files with 50 additions and 42 deletions
45
src/Task.cpp
45
src/Task.cpp
|
@ -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")
|
||||
{
|
||||
|
|
|
@ -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 = " [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 measure (Task&, unsigned int&, unsigned int&);
|
||||
void render (std::vector <std::string>&, Task&, int, Color&);
|
||||
void modify (Task&, const std::string&);
|
||||
|
||||
private:
|
||||
bool _hyphenate;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue