mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-21 07:43:08 +02:00
Virtual Tags: New 'PROJECT', 'PRIORITY' and 'LATEST' virtual tags
- Added documentation.
This commit is contained in:
parent
ada6c24789
commit
4008a64fdd
6 changed files with 64 additions and 47 deletions
60
src/Task.cpp
60
src/Task.cpp
|
@ -32,6 +32,7 @@
|
|||
#include <string>
|
||||
#ifdef PRODUCT_TASKWARRIOR
|
||||
#include <math.h>
|
||||
#include <ctype.h>
|
||||
#include <cfloat>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
@ -1170,35 +1171,40 @@ bool Task::hasTag (const std::string& tag) const
|
|||
// Synthetic tags - dynamically generated, but do not occupy storage space.
|
||||
// Note: This list must match that in CmdInfo::execute.
|
||||
// Note: This list must match that in ::feedback_reserved_tags.
|
||||
if (tag == "BLOCKED") return is_blocked;
|
||||
if (tag == "UNBLOCKED") return !is_blocked;
|
||||
if (tag == "BLOCKING") return is_blocking;
|
||||
if (isupper (tag[0]))
|
||||
{
|
||||
if (tag == "BLOCKED") return is_blocked;
|
||||
if (tag == "UNBLOCKED") return !is_blocked;
|
||||
if (tag == "BLOCKING") return is_blocking;
|
||||
#ifdef PRODUCT_TASKWARRIOR
|
||||
if (tag == "READY") return is_ready ();
|
||||
if (tag == "DUE") return is_due ();
|
||||
if (tag == "DUETODAY") return is_duetoday ();
|
||||
if (tag == "TODAY") return is_duetoday ();
|
||||
if (tag == "YESTERDAY") return is_dueyesterday ();
|
||||
if (tag == "TOMORROW") return is_duetomorrow ();
|
||||
if (tag == "OVERDUE") return is_overdue ();
|
||||
if (tag == "WEEK") return is_dueweek ();
|
||||
if (tag == "MONTH") return is_duemonth ();
|
||||
if (tag == "YEAR") return is_dueyear ();
|
||||
if (tag == "READY") return is_ready ();
|
||||
if (tag == "DUE") return is_due ();
|
||||
if (tag == "DUETODAY") return is_duetoday ();
|
||||
if (tag == "TODAY") return is_duetoday ();
|
||||
if (tag == "YESTERDAY") return is_dueyesterday ();
|
||||
if (tag == "TOMORROW") return is_duetomorrow ();
|
||||
if (tag == "OVERDUE") return is_overdue ();
|
||||
if (tag == "WEEK") return is_dueweek ();
|
||||
if (tag == "MONTH") return is_duemonth ();
|
||||
if (tag == "YEAR") return is_dueyear ();
|
||||
#endif
|
||||
if (tag == "ACTIVE") return has ("start");
|
||||
if (tag == "SCHEDULED") return has ("scheduled");
|
||||
if (tag == "CHILD") return has ("parent");
|
||||
if (tag == "UNTIL") return has ("until");
|
||||
if (tag == "ANNOTATED") return hasAnnotations ();
|
||||
if (tag == "TAGGED") return has ("tags");
|
||||
if (tag == "PARENT") return has ("mask");
|
||||
if (tag == "WAITING") return get ("status") == "waiting";
|
||||
if (tag == "PENDING") return get ("status") == "pending";
|
||||
if (tag == "COMPLETED") return get ("status") == "completed";
|
||||
if (tag == "DELETED") return get ("status") == "deleted";
|
||||
if (tag == "UDA") return is_udaPresent ();
|
||||
if (tag == "ORPHAN") return is_orphanPresent ();
|
||||
if (tag == "LATEST") return id == context.tdb2.latest_id ();
|
||||
if (tag == "ACTIVE") return has ("start");
|
||||
if (tag == "SCHEDULED") return has ("scheduled");
|
||||
if (tag == "CHILD") return has ("parent");
|
||||
if (tag == "UNTIL") return has ("until");
|
||||
if (tag == "ANNOTATED") return hasAnnotations ();
|
||||
if (tag == "TAGGED") return has ("tags");
|
||||
if (tag == "PARENT") return has ("mask");
|
||||
if (tag == "WAITING") return get ("status") == "waiting";
|
||||
if (tag == "PENDING") return get ("status") == "pending";
|
||||
if (tag == "COMPLETED") return get ("status") == "completed";
|
||||
if (tag == "DELETED") return get ("status") == "deleted";
|
||||
if (tag == "UDA") return is_udaPresent ();
|
||||
if (tag == "ORPHAN") return is_orphanPresent ();
|
||||
if (tag == "LATEST") return id == context.tdb2.latest_id ();
|
||||
if (tag == "PROJECT") return has ("project");
|
||||
if (tag == "PRIORITY") return has ("priority");
|
||||
}
|
||||
|
||||
// Concrete tags.
|
||||
std::vector <std::string> tags;
|
||||
|
|
|
@ -338,6 +338,8 @@ int CmdInfo::execute (std::string& output)
|
|||
if (task.hasTag ("YEAR")) virtualTags += "YEAR ";
|
||||
if (task.hasTag ("YESTERDAY")) virtualTags += "YESTERDAY ";
|
||||
if (task.hasTag ("LATEST")) virtualTags += "LATEST ";
|
||||
if (task.hasTag ("PROJECT")) virtualTags += "PROJECT ";
|
||||
if (task.hasTag ("PRIORITY")) virtualTags += "PRIORITY ";
|
||||
// If you update the above list, update src/commands/CmdInfo.cpp and src/commands/CmdTags.cpp as well.
|
||||
|
||||
row = view.addRow ();
|
||||
|
|
|
@ -357,30 +357,35 @@ void feedback_reserved_tags (const std::string& tag)
|
|||
{
|
||||
// Note: This list must match that in Task::hasTag.
|
||||
// Note: This list must match that in CmdInfo::execute.
|
||||
if (tag == "BLOCKED" ||
|
||||
tag == "UNBLOCKED" ||
|
||||
if (tag == "ACTIVE" ||
|
||||
tag == "ANNOTATED" ||
|
||||
tag == "BLOCKED" ||
|
||||
tag == "BLOCKING" ||
|
||||
tag == "READY" ||
|
||||
tag == "CHILD" ||
|
||||
tag == "COMPLETED" ||
|
||||
tag == "DELETED" ||
|
||||
tag == "DUE" ||
|
||||
tag == "DUETODAY" ||
|
||||
tag == "TODAY" ||
|
||||
tag == "YESTERDAY" ||
|
||||
tag == "TOMORROW" ||
|
||||
tag == "OVERDUE" ||
|
||||
tag == "WEEK" ||
|
||||
tag == "LATEST" ||
|
||||
tag == "MONTH" ||
|
||||
tag == "YEAR" ||
|
||||
tag == "ACTIVE" ||
|
||||
tag == "SCHEDULED" ||
|
||||
tag == "CHILD" ||
|
||||
tag == "UNTIL" ||
|
||||
tag == "ANNOTATED" ||
|
||||
tag == "TAGGED" ||
|
||||
tag == "ORPHAN" ||
|
||||
tag == "OVERDUE" ||
|
||||
tag == "PARENT" ||
|
||||
tag == "WAITING" ||
|
||||
tag == "PENDING" ||
|
||||
tag == "COMPLETED" ||
|
||||
tag == "DELETED")
|
||||
tag == "PRIORITY" ||
|
||||
tag == "PROJECT" ||
|
||||
tag == "READY" ||
|
||||
tag == "SCHEDULED" ||
|
||||
tag == "TAGGED" ||
|
||||
tag == "TODAY" ||
|
||||
tag == "TOMORROW" ||
|
||||
tag == "UDA" ||
|
||||
tag == "UNBLOCKED" ||
|
||||
tag == "UNTIL" ||
|
||||
tag == "WAITING" ||
|
||||
tag == "WEEK" ||
|
||||
tag == "YEAR" ||
|
||||
tag == "YESTERDAY")
|
||||
{
|
||||
throw format (STRING_FEEDBACK_TAG_VIRTUAL, tag);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue