mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 04:13:07 +02:00
Task: Migrated part of ::modify to ColDepends
This commit is contained in:
parent
974841883b
commit
25d4392edf
3 changed files with 30 additions and 23 deletions
24
src/Task.cpp
24
src/Task.cpp
|
@ -2009,29 +2009,7 @@ void Task::modify (modType type, bool text_required /* = false */)
|
||||||
// Dependencies are specified as IDs.
|
// Dependencies are specified as IDs.
|
||||||
if (name == "depends")
|
if (name == "depends")
|
||||||
{
|
{
|
||||||
// Parse IDs
|
column->modify (*this, value);
|
||||||
std::vector <std::string> deps;
|
|
||||||
split (deps, value, ',');
|
|
||||||
|
|
||||||
// Apply or remove dendencies in turn.
|
|
||||||
for (auto& dep : deps)
|
|
||||||
{
|
|
||||||
if (dep[0] == '-')
|
|
||||||
{
|
|
||||||
if (dep.length () == 37)
|
|
||||||
removeDependency (dep.substr (1));
|
|
||||||
else
|
|
||||||
removeDependency (strtol (dep.substr (1).c_str (), NULL, 10));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (dep.length () == 36)
|
|
||||||
addDependency (dep);
|
|
||||||
else
|
|
||||||
addDependency (strtol (dep.c_str (), NULL, 10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
++modCount;
|
++modCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <utf8.h>
|
#include <utf8.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
|
||||||
|
@ -147,3 +148,30 @@ void ColumnDepends::render (
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void ColumnDepends::modify (Task& task, const std::string& value)
|
||||||
|
{
|
||||||
|
// Parse IDs
|
||||||
|
std::vector <std::string> deps;
|
||||||
|
split (deps, value, ',');
|
||||||
|
|
||||||
|
// Apply or remove dendencies in turn.
|
||||||
|
for (auto& dep : deps)
|
||||||
|
{
|
||||||
|
if (dep[0] == '-')
|
||||||
|
{
|
||||||
|
if (dep.length () == 37)
|
||||||
|
task.removeDependency (dep.substr (1));
|
||||||
|
else
|
||||||
|
task.removeDependency (strtol (dep.substr (1).c_str (), NULL, 10));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (dep.length () == 36)
|
||||||
|
task.addDependency (dep);
|
||||||
|
else
|
||||||
|
task.addDependency (strtol (dep.c_str (), NULL, 10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -37,6 +37,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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue