mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
TDB2
- Converted 'delete' command to TDB2.
This commit is contained in:
parent
eb992d3523
commit
84ccf4399c
1 changed files with 10 additions and 15 deletions
|
@ -55,14 +55,9 @@ int CmdDelete::execute (std::string& output)
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
|
||||||
context.tdb.loadPending (tasks);
|
|
||||||
|
|
||||||
// Apply filter.
|
// Apply filter.
|
||||||
std::vector <Task> filtered;
|
std::vector <Task> filtered;
|
||||||
filter (tasks, filtered);
|
filter (filtered);
|
||||||
|
|
||||||
if (filtered.size () == 0)
|
if (filtered.size () == 0)
|
||||||
{
|
{
|
||||||
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
||||||
|
@ -91,13 +86,16 @@ int CmdDelete::execute (std::string& output)
|
||||||
std::string parent = task->get ("parent");
|
std::string parent = task->get ("parent");
|
||||||
if (parent != "")
|
if (parent != "")
|
||||||
{
|
{
|
||||||
|
std::vector <Task> siblings;
|
||||||
|
|
||||||
if (context.config.getBoolean ("confirmation") &&
|
if (context.config.getBoolean ("confirmation") &&
|
||||||
confirm (STRING_CMD_DELETE_CONF_RECUR))
|
confirm (STRING_CMD_DELETE_CONF_RECUR))
|
||||||
{
|
{
|
||||||
// Scan all pending tasks for siblings of this task, and the parent
|
// Scan all pending tasks for siblings of this task, and the parent
|
||||||
// itself, and delete them.
|
// itself, and delete them.
|
||||||
|
siblings = context.tdb2.siblings (*task);
|
||||||
std::vector <Task>::iterator sibling;
|
std::vector <Task>::iterator sibling;
|
||||||
for (sibling = tasks.begin (); sibling != tasks.end (); ++sibling)
|
for (sibling = siblings.begin (); sibling != siblings.end (); ++sibling)
|
||||||
{
|
{
|
||||||
if (sibling->get ("parent") == parent ||
|
if (sibling->get ("parent") == parent ||
|
||||||
sibling->get ("uuid") == parent)
|
sibling->get ("uuid") == parent)
|
||||||
|
@ -111,7 +109,7 @@ int CmdDelete::execute (std::string& output)
|
||||||
|
|
||||||
// Apply the command line modifications to the sibling.
|
// Apply the command line modifications to the sibling.
|
||||||
modify_task_annotate (*sibling, modifications);
|
modify_task_annotate (*sibling, modifications);
|
||||||
context.tdb.update (*sibling);
|
context.tdb2.modify (*sibling);
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
// TODO Feedback.
|
// TODO Feedback.
|
||||||
|
@ -127,14 +125,14 @@ int CmdDelete::execute (std::string& output)
|
||||||
{
|
{
|
||||||
// Update mask in parent.
|
// Update mask in parent.
|
||||||
task->setStatus (Task::deleted);
|
task->setStatus (Task::deleted);
|
||||||
updateRecurrenceMask (tasks, *task);
|
updateRecurrenceMask (siblings, *task);
|
||||||
|
|
||||||
// Don't want a 'delete' to clobber the end date that may have
|
// Don't want a 'delete' to clobber the end date that may have
|
||||||
// been written by a 'done' command.
|
// been written by a 'done' command.
|
||||||
if (! task->has ("end"))
|
if (! task->has ("end"))
|
||||||
task->setEnd ();
|
task->setEnd ();
|
||||||
|
|
||||||
context.tdb.update (*task);
|
context.tdb2.modify (*task);
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
out << format (STRING_CMD_DELETE_RECURRING,
|
out << format (STRING_CMD_DELETE_RECURRING,
|
||||||
|
@ -155,7 +153,7 @@ int CmdDelete::execute (std::string& output)
|
||||||
if (! task->has ("end"))
|
if (! task->has ("end"))
|
||||||
task->setEnd ();
|
task->setEnd ();
|
||||||
|
|
||||||
context.tdb.update (*task);
|
context.tdb2.modify (*task);
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
|
@ -184,10 +182,7 @@ int CmdDelete::execute (std::string& output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count)
|
context.tdb2.commit ();
|
||||||
context.tdb.commit ();
|
|
||||||
|
|
||||||
context.tdb.unlock ();
|
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
return rc;
|
return rc;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue