mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
make TDB2.pending/completed non-public
References to methods on these fields are replaced with methods on TDB2, several of which already existed.
This commit is contained in:
parent
4ebd0ffb39
commit
271d06cd9c
11 changed files with 43 additions and 33 deletions
|
@ -98,7 +98,7 @@ void Filter::subset (std::vector <Task>& output)
|
||||||
if (precompiled.size ())
|
if (precompiled.size ())
|
||||||
{
|
{
|
||||||
Timer timer_pending;
|
Timer timer_pending;
|
||||||
auto pending = Context::getContext ().tdb2.pending.get_tasks ();
|
auto pending = Context::getContext ().tdb2.pending_tasks ();
|
||||||
Context::getContext ().time_filter_us -= timer_pending.total_us ();
|
Context::getContext ().time_filter_us -= timer_pending.total_us ();
|
||||||
_startCount = (int) pending.size ();
|
_startCount = (int) pending.size ();
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ void Filter::subset (std::vector <Task>& output)
|
||||||
if (! shortcut)
|
if (! shortcut)
|
||||||
{
|
{
|
||||||
Timer timer_completed;
|
Timer timer_completed;
|
||||||
auto completed = Context::getContext ().tdb2.completed.get_tasks ();
|
auto completed = Context::getContext ().tdb2.completed_tasks ();
|
||||||
Context::getContext ().time_filter_us -= timer_completed.total_us ();
|
Context::getContext ().time_filter_us -= timer_completed.total_us ();
|
||||||
_startCount += (int) completed.size ();
|
_startCount += (int) completed.size ();
|
||||||
|
|
||||||
|
@ -149,11 +149,7 @@ void Filter::subset (std::vector <Task>& output)
|
||||||
safety ();
|
safety ();
|
||||||
|
|
||||||
Timer pending_completed;
|
Timer pending_completed;
|
||||||
for (auto& task : Context::getContext ().tdb2.pending.get_tasks ())
|
output = Context::getContext ().tdb2.all_tasks ();
|
||||||
output.push_back (task);
|
|
||||||
|
|
||||||
for (auto& task : Context::getContext ().tdb2.completed.get_tasks ())
|
|
||||||
output.push_back (task);
|
|
||||||
Context::getContext ().time_filter_us -= pending_completed.total_us ();
|
Context::getContext ().time_filter_us -= pending_completed.total_us ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
src/TDB2.cpp
12
src/TDB2.cpp
|
@ -1133,6 +1133,18 @@ const std::vector <Task> TDB2::all_tasks ()
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::vector <Task> TDB2::pending_tasks ()
|
||||||
|
{
|
||||||
|
return pending.get_tasks ();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::vector <Task> TDB2::completed_tasks ()
|
||||||
|
{
|
||||||
|
return completed.get_tasks ();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Locate task by ID, wherever it is.
|
// Locate task by ID, wherever it is.
|
||||||
bool TDB2::get (int id, Task& task)
|
bool TDB2::get (int id, Task& task)
|
||||||
|
|
|
@ -122,6 +122,8 @@ public:
|
||||||
|
|
||||||
// Generalized task accessors.
|
// Generalized task accessors.
|
||||||
const std::vector <Task> all_tasks ();
|
const std::vector <Task> all_tasks ();
|
||||||
|
const std::vector <Task> pending_tasks ();
|
||||||
|
const std::vector <Task> completed_tasks ();
|
||||||
bool get (int, Task&);
|
bool get (int, Task&);
|
||||||
bool get (const std::string&, Task&);
|
bool get (const std::string&, Task&);
|
||||||
bool has (const std::string&);
|
bool has (const std::string&);
|
||||||
|
@ -152,11 +154,11 @@ private:
|
||||||
void revert_completed (std::vector <std::string>&, std::vector <std::string>&, const std::string&, const std::string&);
|
void revert_completed (std::vector <std::string>&, std::vector <std::string>&, const std::string&, const std::string&);
|
||||||
void revert_backlog (std::vector <std::string>&, const std::string&, const std::string&, const std::string&);
|
void revert_backlog (std::vector <std::string>&, const std::string&, const std::string&, const std::string&);
|
||||||
|
|
||||||
public:
|
protected:
|
||||||
|
friend class TF2; // TF2 reaches into TDB2 internals for gc
|
||||||
TF2 pending;
|
TF2 pending;
|
||||||
TF2 completed;
|
TF2 completed;
|
||||||
|
|
||||||
protected:
|
|
||||||
friend class CmdSync; // CmdSync accesses the backlog directly
|
friend class CmdSync; // CmdSync accesses the backlog directly
|
||||||
TF2 backlog;
|
TF2 backlog;
|
||||||
friend class CmdInfo; // CmdInfo uses undo data to give history
|
friend class CmdInfo; // CmdInfo uses undo data to give history
|
||||||
|
|
10
src/Task.cpp
10
src/Task.cpp
|
@ -1211,7 +1211,7 @@ void Task::setAnnotations (const std::map <std::string, std::string>& annotation
|
||||||
void Task::addDependency (int depid)
|
void Task::addDependency (int depid)
|
||||||
{
|
{
|
||||||
// Check that id is resolvable.
|
// Check that id is resolvable.
|
||||||
std::string uuid = Context::getContext ().tdb2.pending.uuid (depid);
|
std::string uuid = Context::getContext ().tdb2.uuid (depid);
|
||||||
if (uuid == "")
|
if (uuid == "")
|
||||||
throw format ("Could not create a dependency on task {1} - not found.", depid);
|
throw format ("Could not create a dependency on task {1} - not found.", depid);
|
||||||
|
|
||||||
|
@ -1259,7 +1259,7 @@ void Task::addDependency (const std::string& uuid)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Task::removeDependency (int id)
|
void Task::removeDependency (int id)
|
||||||
{
|
{
|
||||||
std::string uuid = Context::getContext ().tdb2.pending.uuid (id);
|
std::string uuid = Context::getContext ().tdb2.uuid (id);
|
||||||
|
|
||||||
// The removeDependency(std::string&) method will check this too, but here we
|
// The removeDependency(std::string&) method will check this too, but here we
|
||||||
// can give a more natural error message containing the id provided by the user
|
// can give a more natural error message containing the id provided by the user
|
||||||
|
@ -1296,7 +1296,7 @@ std::vector <int> Task::getDependencyIDs () const
|
||||||
if (!isDepAttr (attr))
|
if (!isDepAttr (attr))
|
||||||
continue;
|
continue;
|
||||||
auto dep = attr2Dep (attr);
|
auto dep = attr2Dep (attr);
|
||||||
ids.push_back (Context::getContext ().tdb2.pending.id (dep));
|
ids.push_back (Context::getContext ().tdb2.id (dep));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ids;
|
return ids;
|
||||||
|
@ -1326,7 +1326,7 @@ std::vector <Task> Task::getDependencyTasks () const
|
||||||
// efficient.
|
// efficient.
|
||||||
std::vector <Task> blocking;
|
std::vector <Task> blocking;
|
||||||
if (uuids.size() > 0)
|
if (uuids.size() > 0)
|
||||||
for (auto& it : Context::getContext ().tdb2.pending.get_tasks ())
|
for (auto& it : Context::getContext ().tdb2.pending_tasks ())
|
||||||
if (it.getStatus () != Task::completed &&
|
if (it.getStatus () != Task::completed &&
|
||||||
it.getStatus () != Task::deleted &&
|
it.getStatus () != Task::deleted &&
|
||||||
std::find (uuids.begin (), uuids.end (), it.get ("uuid")) != uuids.end ())
|
std::find (uuids.begin (), uuids.end (), it.get ("uuid")) != uuids.end ())
|
||||||
|
@ -1341,7 +1341,7 @@ std::vector <Task> Task::getBlockedTasks () const
|
||||||
auto uuid = get ("uuid");
|
auto uuid = get ("uuid");
|
||||||
|
|
||||||
std::vector <Task> blocked;
|
std::vector <Task> blocked;
|
||||||
for (auto& it : Context::getContext ().tdb2.pending.get_tasks ())
|
for (auto& it : Context::getContext ().tdb2.pending_tasks ())
|
||||||
if (it.getStatus () != Task::completed &&
|
if (it.getStatus () != Task::completed &&
|
||||||
it.getStatus () != Task::deleted &&
|
it.getStatus () != Task::deleted &&
|
||||||
it.hasDependency (uuid))
|
it.hasDependency (uuid))
|
||||||
|
|
|
@ -81,7 +81,7 @@ int CmdCalendar::execute (std::string& output)
|
||||||
// Load the pending tasks.
|
// Load the pending tasks.
|
||||||
handleUntil ();
|
handleUntil ();
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
auto tasks = Context::getContext ().tdb2.pending_tasks ();
|
||||||
|
|
||||||
Datetime today;
|
Datetime today;
|
||||||
auto getPendingDate = false;
|
auto getPendingDate = false;
|
||||||
|
|
|
@ -202,7 +202,7 @@ void CmdContext::defineContext (const std::vector <std::string>& words, std::str
|
||||||
// Check if the value is a proper filter by filtering current pending.data
|
// Check if the value is a proper filter by filtering current pending.data
|
||||||
Filter filter;
|
Filter filter;
|
||||||
std::vector <Task> filtered;
|
std::vector <Task> filtered;
|
||||||
auto pending = Context::getContext ().tdb2.pending.get_tasks ();
|
auto pending = Context::getContext ().tdb2.pending_tasks ();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,10 +60,10 @@ int CmdProjects::execute (std::string& output)
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
handleUntil ();
|
handleUntil ();
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
auto tasks = Context::getContext ().tdb2.pending_tasks ();
|
||||||
|
|
||||||
if (Context::getContext ().config.getBoolean ("list.all.projects"))
|
if (Context::getContext ().config.getBoolean ("list.all.projects"))
|
||||||
for (auto& task : Context::getContext ().tdb2.completed.get_tasks ())
|
for (auto& task : Context::getContext ().tdb2.completed_tasks ())
|
||||||
tasks.push_back (task);
|
tasks.push_back (task);
|
||||||
|
|
||||||
// Apply the filter.
|
// Apply the filter.
|
||||||
|
@ -172,10 +172,10 @@ int CmdCompletionProjects::execute (std::string& output)
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
handleUntil ();
|
handleUntil ();
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
auto tasks = Context::getContext ().tdb2.pending_tasks ();
|
||||||
|
|
||||||
if (Context::getContext ().config.getBoolean ("list.all.projects"))
|
if (Context::getContext ().config.getBoolean ("list.all.projects"))
|
||||||
for (auto& task : Context::getContext ().tdb2.completed.get_tasks ())
|
for (auto& task : Context::getContext ().tdb2.completed_tasks ())
|
||||||
tasks.push_back (task);
|
tasks.push_back (task);
|
||||||
|
|
||||||
// Apply the filter.
|
// Apply the filter.
|
||||||
|
|
|
@ -58,10 +58,10 @@ int CmdTags::execute (std::string& output)
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
auto tasks = Context::getContext ().tdb2.pending_tasks ();
|
||||||
|
|
||||||
if (Context::getContext ().config.getBoolean ("list.all.tags"))
|
if (Context::getContext ().config.getBoolean ("list.all.tags"))
|
||||||
for (auto& task : Context::getContext ().tdb2.completed.get_tasks ())
|
for (auto& task : Context::getContext ().tdb2.completed_tasks ())
|
||||||
tasks.push_back (task);
|
tasks.push_back (task);
|
||||||
|
|
||||||
int quantity = tasks.size ();
|
int quantity = tasks.size ();
|
||||||
|
@ -157,10 +157,10 @@ CmdCompletionTags::CmdCompletionTags ()
|
||||||
int CmdCompletionTags::execute (std::string& output)
|
int CmdCompletionTags::execute (std::string& output)
|
||||||
{
|
{
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
auto tasks = Context::getContext ().tdb2.pending_tasks ();
|
||||||
|
|
||||||
if (Context::getContext ().config.getBoolean ("complete.all.tags"))
|
if (Context::getContext ().config.getBoolean ("complete.all.tags"))
|
||||||
for (auto& task : Context::getContext ().tdb2.completed.get_tasks ())
|
for (auto& task : Context::getContext ().tdb2.completed_tasks ())
|
||||||
tasks.push_back (task);
|
tasks.push_back (task);
|
||||||
|
|
||||||
// Apply filter.
|
// Apply filter.
|
||||||
|
|
|
@ -40,7 +40,7 @@ void nag (std::vector <Task>& tasks)
|
||||||
if (msg == "")
|
if (msg == "")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto pending = Context::getContext ().tdb2.pending.get_tasks ();
|
auto pending = Context::getContext ().tdb2.pending_tasks ();
|
||||||
for (auto& t1 : tasks) {
|
for (auto& t1 : tasks) {
|
||||||
if (t1.hasTag ("nonag"))
|
if (t1.hasTag ("nonag"))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -56,7 +56,7 @@ void handleRecurrence ()
|
||||||
if (! Context::getContext ().config.getBoolean ("recurrence"))
|
if (! Context::getContext ().config.getBoolean ("recurrence"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
auto tasks = Context::getContext ().tdb2.pending_tasks ();
|
||||||
Datetime now;
|
Datetime now;
|
||||||
|
|
||||||
// Look at all tasks and find any recurring ones.
|
// Look at all tasks and find any recurring ones.
|
||||||
|
@ -411,7 +411,7 @@ void updateRecurrenceMask (Task& task)
|
||||||
void handleUntil ()
|
void handleUntil ()
|
||||||
{
|
{
|
||||||
Datetime now;
|
Datetime now;
|
||||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
auto tasks = Context::getContext ().tdb2.pending_tasks ();
|
||||||
for (auto& t : tasks)
|
for (auto& t : tasks)
|
||||||
{
|
{
|
||||||
// TODO What about expiring template tasks?
|
// TODO What about expiring template tasks?
|
||||||
|
|
|
@ -58,8 +58,8 @@ int main (int, char**)
|
||||||
context.tdb2.set_location (".");
|
context.tdb2.set_location (".");
|
||||||
|
|
||||||
// Try reading an empty database.
|
// Try reading an empty database.
|
||||||
std::vector <Task> pending = context.tdb2.pending.get_tasks ();
|
std::vector <Task> pending = context.tdb2.pending_tasks ();
|
||||||
std::vector <Task> completed = context.tdb2.completed.get_tasks ();
|
std::vector <Task> completed = context.tdb2.completed_tasks ();
|
||||||
int num_reverts_possible = context.tdb2.num_reverts_possible ();
|
int num_reverts_possible = context.tdb2.num_reverts_possible ();
|
||||||
int num_local_changes = context.tdb2.num_local_changes ();
|
int num_local_changes = context.tdb2.num_local_changes ();
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ int main (int, char**)
|
||||||
Task task (R"([description:"description" name:"value"])");
|
Task task (R"([description:"description" name:"value"])");
|
||||||
context.tdb2.add (task);
|
context.tdb2.add (task);
|
||||||
|
|
||||||
pending = context.tdb2.pending.get_tasks ();
|
pending = context.tdb2.pending_tasks ();
|
||||||
completed = context.tdb2.completed.get_tasks ();
|
completed = context.tdb2.completed_tasks ();
|
||||||
num_reverts_possible = context.tdb2.num_reverts_possible ();
|
num_reverts_possible = context.tdb2.num_reverts_possible ();
|
||||||
num_local_changes = context.tdb2.num_local_changes ();
|
num_local_changes = context.tdb2.num_local_changes ();
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@ int main (int, char**)
|
||||||
task.set ("description", "This is a test");
|
task.set ("description", "This is a test");
|
||||||
context.tdb2.modify (task);
|
context.tdb2.modify (task);
|
||||||
|
|
||||||
pending = context.tdb2.pending.get_tasks ();
|
pending = context.tdb2.pending_tasks ();
|
||||||
completed = context.tdb2.completed.get_tasks ();
|
completed = context.tdb2.completed_tasks ();
|
||||||
num_reverts_possible = context.tdb2.num_reverts_possible ();
|
num_reverts_possible = context.tdb2.num_reverts_possible ();
|
||||||
num_local_changes = context.tdb2.num_local_changes ();
|
num_local_changes = context.tdb2.num_local_changes ();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue