mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-24 08:56:43 +02:00
Task: Improved method signature
This commit is contained in:
parent
7e629ef30a
commit
04043d267f
7 changed files with 26 additions and 52 deletions
|
@ -528,10 +528,7 @@ void TF2::dependency_scan ()
|
||||||
{
|
{
|
||||||
if (left.has ("depends"))
|
if (left.has ("depends"))
|
||||||
{
|
{
|
||||||
std::vector <std::string> deps;
|
for (auto& dep : left.getDependencyUUIDs ())
|
||||||
left.getDependencies (deps);
|
|
||||||
|
|
||||||
for (auto& dep : deps)
|
|
||||||
{
|
{
|
||||||
for (auto& right : _tasks)
|
for (auto& right : _tasks)
|
||||||
{
|
{
|
||||||
|
|
26
src/Task.cpp
26
src/Task.cpp
|
@ -1186,35 +1186,33 @@ void Task::removeDependency (int id)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Task::getDependencies (std::vector <int>& all) const
|
std::vector <int> Task::getDependencyIDs () const
|
||||||
{
|
{
|
||||||
auto deps = split (get ("depends"), ',');
|
std::vector <int> all;
|
||||||
|
for (auto& dep : split (get ("depends"), ','))
|
||||||
all.clear ();
|
|
||||||
|
|
||||||
for (auto& dep : deps)
|
|
||||||
all.push_back (context.tdb2.pending.id (dep));
|
all.push_back (context.tdb2.pending.id (dep));
|
||||||
|
|
||||||
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Task::getDependencies (std::vector <std::string>& all) const
|
std::vector <std::string> Task::getDependencyUUIDs () const
|
||||||
{
|
{
|
||||||
all = split (get ("depends"), ',');
|
return split (get ("depends"), ',');
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Task::getDependencies (std::vector <Task>& all) const
|
std::vector <Task> Task::getDependencyTasks () const
|
||||||
{
|
{
|
||||||
std::vector <std::string> deps = split (get ("depends"), ',');
|
std::vector <Task> all;
|
||||||
|
for (auto& dep : split (get ("depends"), ','))
|
||||||
all.clear ();
|
|
||||||
|
|
||||||
for (auto& dep : deps)
|
|
||||||
{
|
{
|
||||||
Task task;
|
Task task;
|
||||||
context.tdb2.get (dep, task);
|
context.tdb2.get (dep, task);
|
||||||
all.push_back (task);
|
all.push_back (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return all;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -141,9 +141,9 @@ public:
|
||||||
#ifdef PRODUCT_TASKWARRIOR
|
#ifdef PRODUCT_TASKWARRIOR
|
||||||
void removeDependency (int);
|
void removeDependency (int);
|
||||||
void removeDependency (const std::string&);
|
void removeDependency (const std::string&);
|
||||||
void getDependencies (std::vector <int>&) const;
|
std::vector <int> getDependencyIDs () const;
|
||||||
void getDependencies (std::vector <std::string>&) const;
|
std::vector <std::string> getDependencyUUIDs () const;
|
||||||
void getDependencies (std::vector <Task>&) const;
|
std::vector <Task> getDependencyTasks () const;
|
||||||
|
|
||||||
std::vector <std::string> getUDAOrphanUUIDs () const;
|
std::vector <std::string> getUDAOrphanUUIDs () const;
|
||||||
|
|
||||||
|
|
|
@ -456,10 +456,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||||
for (auto& task : all)
|
for (auto& task : all)
|
||||||
{
|
{
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
std::vector <std::string> dependencies;
|
for (auto& uuid : task.getDependencyUUIDs ())
|
||||||
task.getDependencies(dependencies);
|
|
||||||
|
|
||||||
for (auto& uuid : dependencies)
|
|
||||||
{
|
{
|
||||||
if (! context.tdb2.has (uuid))
|
if (! context.tdb2.has (uuid))
|
||||||
{
|
{
|
||||||
|
|
|
@ -256,8 +256,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
|
||||||
before << " Annotation: " << now.toString (dateformat) << " -- \n";
|
before << " Annotation: " << now.toString (dateformat) << " -- \n";
|
||||||
|
|
||||||
// Add dependencies here.
|
// Add dependencies here.
|
||||||
std::vector <std::string> dependencies;
|
auto dependencies = task.getDependencyUUIDs ();
|
||||||
task.getDependencies (dependencies);
|
|
||||||
std::stringstream allDeps;
|
std::stringstream allDeps;
|
||||||
for (unsigned int i = 0; i < dependencies.size (); ++i)
|
for (unsigned int i = 0; i < dependencies.size (); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,8 +82,7 @@ bool dependencyIsCircular (const Task& task)
|
||||||
while (! s.empty ())
|
while (! s.empty ())
|
||||||
{
|
{
|
||||||
Task& current = s.top ();
|
Task& current = s.top ();
|
||||||
std::vector <std::string> deps_current;
|
auto deps_current = current.getDependencyUUIDs ();
|
||||||
current.getDependencies (deps_current);
|
|
||||||
|
|
||||||
// This is a basic depth first search that always terminates given the
|
// This is a basic depth first search that always terminates given the
|
||||||
// fact that we do not visit any task twice
|
// fact that we do not visit any task twice
|
||||||
|
|
|
@ -84,8 +84,7 @@ std::string taskDifferences (const Task& before, const Task& after)
|
||||||
{
|
{
|
||||||
if (name == "depends")
|
if (name == "depends")
|
||||||
{
|
{
|
||||||
std::vector <Task> deps_after;
|
auto deps_after = after.getDependencyTasks ();
|
||||||
after.getDependencies (deps_after);
|
|
||||||
|
|
||||||
out << " - "
|
out << " - "
|
||||||
<< format (STRING_FEEDBACK_DEP_SET, taskIdentifiers (deps_after))
|
<< format (STRING_FEEDBACK_DEP_SET, taskIdentifiers (deps_after))
|
||||||
|
@ -110,12 +109,10 @@ std::string taskDifferences (const Task& before, const Task& after)
|
||||||
{
|
{
|
||||||
if (name == "depends")
|
if (name == "depends")
|
||||||
{
|
{
|
||||||
std::vector <Task> deps_before;
|
auto deps_before = before.getDependencyTasks ();
|
||||||
before.getDependencies (deps_before);
|
|
||||||
std::string from = taskIdentifiers (deps_before);
|
std::string from = taskIdentifiers (deps_before);
|
||||||
|
|
||||||
std::vector <Task> deps_after;
|
auto deps_after = after.getDependencyTasks ();
|
||||||
after.getDependencies (deps_after);
|
|
||||||
std::string to = taskIdentifiers (deps_after);
|
std::string to = taskIdentifiers (deps_after);
|
||||||
|
|
||||||
out << " - "
|
out << " - "
|
||||||
|
@ -169,11 +166,7 @@ std::string taskInfoDifferences (
|
||||||
{
|
{
|
||||||
if (name == "depends")
|
if (name == "depends")
|
||||||
{
|
{
|
||||||
std::vector <Task> deps_before;
|
out << format (STRING_FEEDBACK_DEP_DEL, taskIdentifiers (before.getDependencyTasks ()))
|
||||||
before.getDependencies (deps_before);
|
|
||||||
std::string from = taskIdentifiers (deps_before);
|
|
||||||
|
|
||||||
out << format (STRING_FEEDBACK_DEP_DEL, from)
|
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
else if (name.substr (0, 11) == "annotation_")
|
else if (name.substr (0, 11) == "annotation_")
|
||||||
|
@ -198,11 +191,7 @@ std::string taskInfoDifferences (
|
||||||
{
|
{
|
||||||
if (name == "depends")
|
if (name == "depends")
|
||||||
{
|
{
|
||||||
std::vector <Task> deps_after;
|
out << format (STRING_FEEDBACK_DEP_WAS_SET, taskIdentifiers (after.getDependencyTasks ()))
|
||||||
after.getDependencies (deps_after);
|
|
||||||
std::string to = taskIdentifiers (deps_after);
|
|
||||||
|
|
||||||
out << format (STRING_FEEDBACK_DEP_WAS_SET, to)
|
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
else if (name.substr (0, 11) == "annotation_")
|
else if (name.substr (0, 11) == "annotation_")
|
||||||
|
@ -231,13 +220,8 @@ std::string taskInfoDifferences (
|
||||||
{
|
{
|
||||||
if (name == "depends")
|
if (name == "depends")
|
||||||
{
|
{
|
||||||
std::vector <Task> deps_before;
|
auto from = taskIdentifiers (before.getDependencyTasks ());
|
||||||
before.getDependencies (deps_before);
|
auto to = taskIdentifiers (after.getDependencyTasks ());
|
||||||
std::string from = taskIdentifiers (deps_before);
|
|
||||||
|
|
||||||
std::vector <Task> deps_after;
|
|
||||||
after.getDependencies (deps_after);
|
|
||||||
std::string to = taskIdentifiers (deps_after);
|
|
||||||
|
|
||||||
out << format (STRING_FEEDBACK_DEP_WAS_MOD, from, to)
|
out << format (STRING_FEEDBACK_DEP_WAS_MOD, from, to)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue