Virtual Tag: Undocumented, experimental support for 'LATEST'

This commit is contained in:
Paul Beckingham 2015-08-31 12:59:44 -04:00
parent 86dc14823e
commit ada6c24789
4 changed files with 12 additions and 2 deletions

View file

@ -1287,6 +1287,13 @@ int TDB2::next_id ()
return _id++; return _id++;
} }
////////////////////////////////////////////////////////////////////////////////
// Latest ID is that of the last pending task.
int TDB2::latest_id ()
{
return _id - 1;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const std::vector <Task> TDB2::all_tasks () const std::vector <Task> TDB2::all_tasks ()
{ {

View file

@ -107,6 +107,7 @@ public:
void revert (); void revert ();
int gc (); int gc ();
int next_id (); int next_id ();
int latest_id ();
// Generalized task accessors. // Generalized task accessors.
const std::vector <Task> all_tasks (); const std::vector <Task> all_tasks ();

View file

@ -1198,6 +1198,7 @@ bool Task::hasTag (const std::string& tag) const
if (tag == "DELETED") return get ("status") == "deleted"; if (tag == "DELETED") return get ("status") == "deleted";
if (tag == "UDA") return is_udaPresent (); if (tag == "UDA") return is_udaPresent ();
if (tag == "ORPHAN") return is_orphanPresent (); if (tag == "ORPHAN") return is_orphanPresent ();
if (tag == "LATEST") return id == context.tdb2.latest_id ();
// Concrete tags. // Concrete tags.
std::vector <std::string> tags; std::vector <std::string> tags;

View file

@ -337,6 +337,7 @@ int CmdInfo::execute (std::string& output)
if (task.hasTag ("WEEK")) virtualTags += "WEEK "; if (task.hasTag ("WEEK")) virtualTags += "WEEK ";
if (task.hasTag ("YEAR")) virtualTags += "YEAR "; if (task.hasTag ("YEAR")) virtualTags += "YEAR ";
if (task.hasTag ("YESTERDAY")) virtualTags += "YESTERDAY "; if (task.hasTag ("YESTERDAY")) virtualTags += "YESTERDAY ";
if (task.hasTag ("LATEST")) virtualTags += "LATEST ";
// If you update the above list, update src/commands/CmdInfo.cpp and src/commands/CmdTags.cpp as well. // If you update the above list, update src/commands/CmdInfo.cpp and src/commands/CmdTags.cpp as well.
row = view.addRow (); row = view.addRow ();