mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
TDB2
- Added ::has methods to determine whether a UUID is known.
This commit is contained in:
parent
2028c7186c
commit
1058f045b0
2 changed files with 24 additions and 3 deletions
25
src/TDB2.cpp
25
src/TDB2.cpp
|
@ -134,6 +134,20 @@ bool TF2::get (const std::string& uuid, Task& task)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TF2::has (const std::string& uuid)
|
||||
{
|
||||
if (! _loaded_tasks)
|
||||
load_tasks ();
|
||||
|
||||
std::vector <Task>::iterator i;
|
||||
for (i = _tasks.begin (); i != _tasks.end (); ++i)
|
||||
if (i->get ("uuid") == uuid)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TF2::add_task (Task& task)
|
||||
{
|
||||
|
@ -589,9 +603,6 @@ void TDB2::modify (Task& task, bool add_to_backlog /* = true */)
|
|||
// Ensure the task is consistent, and provide defaults if necessary.
|
||||
task.validate (false);
|
||||
|
||||
// All modified tasks are timestamped.
|
||||
task.setModified ();
|
||||
|
||||
// Find task, overwrite it.
|
||||
Task original;
|
||||
get (task.get ("uuid"), original);
|
||||
|
@ -1287,6 +1298,14 @@ bool TDB2::get (const std::string& uuid, Task& task)
|
|||
completed.get (uuid, task);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Locate task by UUID, wherever it is.
|
||||
bool TDB2::has (const std::string& uuid)
|
||||
{
|
||||
return pending.has (uuid) ||
|
||||
completed.has (uuid);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::vector <Task> TDB2::siblings (Task& task)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
|
||||
bool get (int, Task&);
|
||||
bool get (const std::string&, Task&);
|
||||
bool has (const std::string&);
|
||||
|
||||
void add_task (Task&);
|
||||
bool modify_task (const Task&);
|
||||
|
@ -110,6 +111,7 @@ public:
|
|||
const std::vector <Task> all_tasks ();
|
||||
bool get (int, Task&);
|
||||
bool get (const std::string&, Task&);
|
||||
bool has (const std::string&);
|
||||
const std::vector <Task> siblings (Task&);
|
||||
const std::vector <Task> children (Task&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue