mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 09:53:08 +02:00
move use of contextTask out of columns, into commands
This commit is contained in:
parent
e98b61f2b5
commit
6e9ad1048d
17 changed files with 44 additions and 35 deletions
|
@ -36,8 +36,6 @@
|
|||
#include <utf8.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnProject::ColumnProject ()
|
||||
{
|
||||
|
@ -121,9 +119,6 @@ void ColumnProject::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
if (!task.is_empty ()) {
|
||||
contextTask = &task;
|
||||
}
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnRecur::ColumnRecur ()
|
||||
{
|
||||
|
@ -108,9 +106,6 @@ void ColumnRecur::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
if (!task.is_empty ()) {
|
||||
contextTask = &task;
|
||||
}
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTags::ColumnTags ()
|
||||
{
|
||||
|
@ -162,9 +160,6 @@ void ColumnTags::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
if (!task.is_empty ()) {
|
||||
contextTask = &task;
|
||||
}
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include <Filter.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeDate::ColumnTypeDate ()
|
||||
{
|
||||
|
@ -213,9 +211,6 @@ void ColumnTypeDate::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
if (!task.is_empty ()) {
|
||||
contextTask = &task;
|
||||
}
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
#include <Filter.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeDuration::ColumnTypeDuration ()
|
||||
{
|
||||
|
@ -55,9 +53,6 @@ void ColumnTypeDuration::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
if (!task.is_empty ()) {
|
||||
contextTask = &task;
|
||||
}
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
#include <Filter.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeNumeric::ColumnTypeNumeric ()
|
||||
{
|
||||
|
@ -55,9 +53,6 @@ void ColumnTypeNumeric::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
if (!task.is_empty ()) {
|
||||
contextTask = &task;
|
||||
}
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
|
||||
#define STRING_INVALID_MOD "The '{1}' attribute does not allow a value of '{2}'."
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeString::ColumnTypeString ()
|
||||
{
|
||||
|
@ -67,9 +65,6 @@ void ColumnTypeString::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
if (!task.is_empty ()) {
|
||||
contextTask = &task;
|
||||
}
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdAdd::CmdAdd ()
|
||||
{
|
||||
|
@ -51,6 +53,10 @@ int CmdAdd::execute (std::string& output)
|
|||
{
|
||||
// Apply the command line modifications to the new task.
|
||||
Task task;
|
||||
|
||||
// the task is empty, but DOM references can refer to earlier parts of the
|
||||
// command line, e.g., `task add due:20110101 wait:due`.
|
||||
contextTask = &task;
|
||||
task.modify (Task::modReplace, true);
|
||||
Context::getContext ().tdb2.add (task);
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <shared.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdAnnotate::CmdAnnotate ()
|
||||
{
|
||||
|
@ -82,6 +84,7 @@ int CmdAnnotate::execute (std::string&)
|
|||
task.identifier (true),
|
||||
task.get ("description"));
|
||||
|
||||
contextTask = &task;
|
||||
task.modify (Task::modAnnotate, true);
|
||||
|
||||
if (permission (before.diff (task) + question, filtered.size ()))
|
||||
|
@ -102,6 +105,7 @@ int CmdAnnotate::execute (std::string&)
|
|||
auto siblings = Context::getContext ().tdb2.siblings (task);
|
||||
for (auto& sibling : siblings)
|
||||
{
|
||||
contextTask = &sibling;
|
||||
sibling.modify (Task::modAnnotate, true);
|
||||
Context::getContext ().tdb2.modify (sibling);
|
||||
++count;
|
||||
|
@ -111,6 +115,7 @@ int CmdAnnotate::execute (std::string&)
|
|||
// Annotate the parent
|
||||
Task parent;
|
||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||
contextTask = &parent;
|
||||
parent.modify (Task::modAnnotate, true);
|
||||
Context::getContext ().tdb2.modify (parent);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdAppend::CmdAppend ()
|
||||
{
|
||||
|
@ -82,6 +84,7 @@ int CmdAppend::execute (std::string&)
|
|||
task.identifier (true),
|
||||
task.get ("description"));
|
||||
|
||||
contextTask = &task;
|
||||
task.modify (Task::modAppend, true);
|
||||
|
||||
if (permission (before.diff (task) + question, filtered.size ()))
|
||||
|
@ -102,6 +105,7 @@ int CmdAppend::execute (std::string&)
|
|||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||
for (auto& sibling : siblings)
|
||||
{
|
||||
contextTask = &sibling;
|
||||
sibling.modify (Task::modAppend, true);
|
||||
Context::getContext ().tdb2.modify (sibling);
|
||||
++count;
|
||||
|
@ -111,6 +115,7 @@ int CmdAppend::execute (std::string&)
|
|||
// Append to the parent
|
||||
Task parent;
|
||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||
contextTask = &parent;
|
||||
parent.modify (Task::modAppend, true);
|
||||
Context::getContext ().tdb2.modify (parent);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#define STRING_CMD_DELETE_TASK_R "Deleting recurring task {1} '{2}'."
|
||||
#define STRING_CMD_DELETE_CONFIRM_R "This is a recurring task. Do you want to delete all pending recurrences of this same task?"
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdDelete::CmdDelete ()
|
||||
{
|
||||
|
@ -87,6 +89,7 @@ int CmdDelete::execute (std::string&)
|
|||
task.identifier (true),
|
||||
task.get ("description"));
|
||||
|
||||
contextTask = &task;
|
||||
task.modify (Task::modAnnotate);
|
||||
task.setStatus (Task::deleted);
|
||||
if (! task.has ("end"))
|
||||
|
@ -113,6 +116,7 @@ int CmdDelete::execute (std::string&)
|
|||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||
for (auto& sibling : siblings)
|
||||
{
|
||||
contextTask = &sibling;
|
||||
sibling.modify (Task::modAnnotate);
|
||||
sibling.setStatus (Task::deleted);
|
||||
if (! sibling.has ("end"))
|
||||
|
@ -147,6 +151,7 @@ int CmdDelete::execute (std::string&)
|
|||
{
|
||||
for (auto& child : children)
|
||||
{
|
||||
contextTask = &child;
|
||||
child.modify (Task::modAnnotate);
|
||||
child.setStatus (Task::deleted);
|
||||
if (! child.has ("end"))
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdDone::CmdDone ()
|
||||
{
|
||||
|
@ -85,6 +87,7 @@ int CmdDone::execute (std::string&)
|
|||
task.identifier (true),
|
||||
task.get ("description"));
|
||||
|
||||
contextTask = &task;
|
||||
task.modify (Task::modAnnotate);
|
||||
task.setStatus (Task::completed);
|
||||
if (! task.has ("end"))
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <util.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdDuplicate::CmdDuplicate ()
|
||||
{
|
||||
|
@ -100,6 +102,7 @@ int CmdDuplicate::execute (std::string&)
|
|||
dup.setStatus (Task::pending); // Does not inherit status.
|
||||
// Must occur after Task::recurring check.
|
||||
|
||||
contextTask = &dup;
|
||||
dup.modify (Task::modAnnotate);
|
||||
|
||||
if (permission (format ("Duplicate task {1} '{2}'?",
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#define STRING_CMD_MODIFY_TASK_R "Modifying recurring task {1} '{2}'."
|
||||
#define STRING_CMD_MODIFY_RECUR "This is a recurring task. Do you want to modify all pending recurrences of this same task?"
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdModify::CmdModify ()
|
||||
{
|
||||
|
@ -77,6 +79,7 @@ int CmdModify::execute (std::string&)
|
|||
for (auto& task : filtered)
|
||||
{
|
||||
Task before (task);
|
||||
contextTask = &task;
|
||||
task.modify (Task::modReplace);
|
||||
|
||||
if (before != task)
|
||||
|
@ -174,6 +177,7 @@ int CmdModify::modifyRecurrenceSiblings (
|
|||
for (auto& sibling : siblings)
|
||||
{
|
||||
Task alternate (sibling);
|
||||
contextTask = &sibling;
|
||||
sibling.modify (Task::modReplace);
|
||||
updateRecurrenceMask (sibling);
|
||||
++count;
|
||||
|
@ -187,6 +191,7 @@ int CmdModify::modifyRecurrenceSiblings (
|
|||
// Modify the parent
|
||||
Task parent;
|
||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||
contextTask = &parent;
|
||||
parent.modify (Task::modReplace);
|
||||
Context::getContext ().tdb2.modify (parent);
|
||||
}
|
||||
|
@ -210,6 +215,7 @@ int CmdModify::modifyRecurrenceParent (
|
|||
for (auto& child : children)
|
||||
{
|
||||
Task alternate (child);
|
||||
contextTask = &child;
|
||||
child.modify (Task::modReplace);
|
||||
updateRecurrenceMask (child);
|
||||
Context::getContext ().tdb2.modify (child);
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdPrepend::CmdPrepend ()
|
||||
{
|
||||
|
@ -82,6 +84,7 @@ int CmdPrepend::execute (std::string&)
|
|||
task.identifier (true),
|
||||
task.get ("description"));
|
||||
|
||||
contextTask = &task;
|
||||
task.modify (Task::modPrepend, true);
|
||||
|
||||
if (permission (before.diff (task) + question, filtered.size ()))
|
||||
|
@ -102,6 +105,7 @@ int CmdPrepend::execute (std::string&)
|
|||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||
for (auto& sibling : siblings)
|
||||
{
|
||||
contextTask = &sibling;
|
||||
sibling.modify (Task::modPrepend, true);
|
||||
Context::getContext ().tdb2.modify (sibling);
|
||||
++count;
|
||||
|
@ -111,6 +115,7 @@ int CmdPrepend::execute (std::string&)
|
|||
// Prepend to the parent
|
||||
Task parent;
|
||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||
contextTask = &parent;
|
||||
parent.modify (Task::modPrepend, true);
|
||||
Context::getContext ().tdb2.modify (parent);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdStart::CmdStart ()
|
||||
{
|
||||
|
@ -83,6 +85,7 @@ int CmdStart::execute (std::string&)
|
|||
std::string question = format ("Start task {1} '{2}'?",
|
||||
task.identifier (true),
|
||||
task.get ("description"));
|
||||
contextTask = &task;
|
||||
task.modify (Task::modAnnotate);
|
||||
task.setAsNow ("start");
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include <main.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdStop::CmdStop ()
|
||||
{
|
||||
|
@ -81,6 +83,7 @@ int CmdStop::execute (std::string&)
|
|||
task.identifier (true),
|
||||
task.get ("description"));
|
||||
|
||||
contextTask = &task;
|
||||
task.modify (Task::modAnnotate);
|
||||
task.remove ("start");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue