mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-26 06:37:20 +02:00
Enhancement
- Added virtual tag support for the first batch. There will be follow-up work, tests and so on.
This commit is contained in:
parent
d73766484d
commit
8d66d801c0
4 changed files with 84 additions and 16 deletions
|
@ -9,6 +9,7 @@ Features
|
||||||
+ Removed deprecated 'fg:' and 'bg:' attributes.
|
+ Removed deprecated 'fg:' and 'bg:' attributes.
|
||||||
+ The 'diagnostics' command now reports libuuid details.
|
+ The 'diagnostics' command now reports libuuid details.
|
||||||
+ New characters for parsing and formating dates ('n', 's' and 'v').
|
+ New characters for parsing and formating dates ('n', 's' and 'v').
|
||||||
|
+ Virtual tags.
|
||||||
|
|
||||||
Bugs
|
Bugs
|
||||||
+ Fixed bug #1043, where aliases were not recognized by bash autocompletion.
|
+ Fixed bug #1043, where aliases were not recognized by bash autocompletion.
|
||||||
|
|
2
NEWS
2
NEWS
|
@ -2,7 +2,7 @@
|
||||||
New Features in taskwarrior 2.2.0
|
New Features in taskwarrior 2.2.0
|
||||||
|
|
||||||
- Bash autocompletion now works with aliases.
|
- Bash autocompletion now works with aliases.
|
||||||
|
- Virtual tags provide a tag query interface to more complex states.
|
||||||
- Deprectated 'fg' and 'bg' attributes removed. Any residual use of those
|
- Deprectated 'fg' and 'bg' attributes removed. Any residual use of those
|
||||||
will appear as orphaned UDAs.
|
will appear as orphaned UDAs.
|
||||||
|
|
||||||
|
|
93
src/Task.cpp
93
src/Task.cpp
|
@ -329,6 +329,60 @@ void Task::setStatus (Task::status status)
|
||||||
recalc_urgency = true;
|
recalc_urgency = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Task::is_due () const
|
||||||
|
{
|
||||||
|
if (has ("due"))
|
||||||
|
{
|
||||||
|
Task::status status = getStatus ();
|
||||||
|
|
||||||
|
if (status != Task::completed &&
|
||||||
|
status != Task::deleted)
|
||||||
|
{
|
||||||
|
if (getDueState (get ("due")) == 1)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Task::is_duetoday () const
|
||||||
|
{
|
||||||
|
if (has ("due"))
|
||||||
|
{
|
||||||
|
Task::status status = getStatus ();
|
||||||
|
|
||||||
|
if (status != Task::completed &&
|
||||||
|
status != Task::deleted)
|
||||||
|
{
|
||||||
|
if (getDueState (get ("due")) == 2)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Task::is_overdue () const
|
||||||
|
{
|
||||||
|
if (has ("due"))
|
||||||
|
{
|
||||||
|
Task::status status = getStatus ();
|
||||||
|
|
||||||
|
if (status != Task::completed &&
|
||||||
|
status != Task::deleted)
|
||||||
|
{
|
||||||
|
if (getDueState (get ("due")) == 3)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Attempt an FF4 parse first, using Task::parse, and in the event of an error
|
// Attempt an FF4 parse first, using Task::parse, and in the event of an error
|
||||||
// try a legacy parse (F3, FF2). Note that FF1 is no longer supported.
|
// try a legacy parse (F3, FF2). Note that FF1 is no longer supported.
|
||||||
|
@ -885,6 +939,15 @@ int Task::getTagCount () const
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool Task::hasTag (const std::string& tag) const
|
bool Task::hasTag (const std::string& tag) const
|
||||||
{
|
{
|
||||||
|
// Synthetic tags - dynamically generated, but do not occupy storage space.
|
||||||
|
if (tag == "BLOCKED") return is_blocked;
|
||||||
|
if (tag == "UNBLOCKED") return !is_blocked;
|
||||||
|
if (tag == "BLOCKING") return is_blocking;
|
||||||
|
if (tag == "DUE") return is_due ();
|
||||||
|
if (tag == "DUETODAY") return is_duetoday ();
|
||||||
|
if (tag == "OVERDUE") return is_overdue ();
|
||||||
|
|
||||||
|
// Concrete tags.
|
||||||
std::vector <std::string> tags;
|
std::vector <std::string> tags;
|
||||||
split (tags, get ("tags"), ',');
|
split (tags, get ("tags"), ',');
|
||||||
|
|
||||||
|
@ -1324,19 +1387,19 @@ float Task::urgency_c () const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Very useful for debugging urgency problems.
|
// Very useful for debugging urgency problems.
|
||||||
std::cout << "# Urgency for " << id << ":\n"
|
std::cout << "# Urgency for " << get ("uuid") << ":\n"
|
||||||
<< "# pri " << (urgency_priority () * urgencyPriorityCoefficient)
|
<< "# pri " << (urgency_priority () * urgencyPriorityCoefficient) << "\n"
|
||||||
<< "# pro " << (urgency_project () * urgencyProjectCoefficient)
|
<< "# pro " << (urgency_project () * urgencyProjectCoefficient) << "\n"
|
||||||
<< "# act " << (urgency_active () * urgencyActiveCoefficient)
|
<< "# act " << (urgency_active () * urgencyActiveCoefficient) << "\n"
|
||||||
<< "# sch " << (urgency_scheduled () * urgencyScheduledCoefficient)
|
<< "# sch " << (urgency_scheduled () * urgencyScheduledCoefficient) << "\n"
|
||||||
<< "# wai " << (urgency_waiting () * urgencyWaitingCoefficient)
|
<< "# wai " << (urgency_waiting () * urgencyWaitingCoefficient) << "\n"
|
||||||
<< "# blk " << (urgency_blocked () * urgencyBlockedCoefficient)
|
<< "# blk " << (urgency_blocked () * urgencyBlockedCoefficient) << "\n"
|
||||||
<< "# ann " << (urgency_annotations () * urgencyAnnotationsCoefficient)
|
<< "# ann " << (urgency_annotations () * urgencyAnnotationsCoefficient) << "\n"
|
||||||
<< "# tag " << (urgency_tags () * urgencyTagsCoefficient)
|
<< "# tag " << (urgency_tags () * urgencyTagsCoefficient) << "\n"
|
||||||
<< "# nex " << (urgency_next () * urgencyNextCoefficient)
|
<< "# nex " << (urgency_next () * urgencyNextCoefficient) << "\n"
|
||||||
<< "# due " << (urgency_due () * urgencyDueCoefficient)
|
<< "# due " << (urgency_due () * urgencyDueCoefficient) << "\n"
|
||||||
<< "# bkg " << (urgency_blocking () * urgencyBlockingCoefficient)
|
<< "# bkg " << (urgency_blocking () * urgencyBlockingCoefficient) << "\n"
|
||||||
<< "# age " << (urgency_age () * urgencyAgeCoefficient);
|
<< "# age " << (urgency_age () * urgencyAgeCoefficient) << "\n";
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Tag- and project-specific coefficients.
|
// Tag- and project-specific coefficients.
|
||||||
|
@ -1498,7 +1561,7 @@ float Task::urgency_due () const
|
||||||
Date due (get_date ("due"));
|
Date due (get_date ("due"));
|
||||||
int days_overdue = (now - due) / 86400;
|
int days_overdue = (now - due) / 86400;
|
||||||
|
|
||||||
if (days_overdue >= 7) return 1.0;
|
if (days_overdue >= 7) return 1.0; // 7 days ago
|
||||||
else if (days_overdue >= 6) return 0.96;
|
else if (days_overdue >= 6) return 0.96;
|
||||||
else if (days_overdue >= 5) return 0.92;
|
else if (days_overdue >= 5) return 0.92;
|
||||||
else if (days_overdue >= 4) return 0.88;
|
else if (days_overdue >= 4) return 0.88;
|
||||||
|
@ -1519,7 +1582,7 @@ float Task::urgency_due () const
|
||||||
else if (days_overdue >= -11) return 0.28;
|
else if (days_overdue >= -11) return 0.28;
|
||||||
else if (days_overdue >= -12) return 0.24;
|
else if (days_overdue >= -12) return 0.24;
|
||||||
else if (days_overdue >= -13) return 0.20;
|
else if (days_overdue >= -13) return 0.20;
|
||||||
else return 0.16;
|
else return 0.16; // two weeks from now
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
|
@ -81,6 +81,10 @@ public:
|
||||||
void set (const std::string&, int);
|
void set (const std::string&, int);
|
||||||
void remove (const std::string&);
|
void remove (const std::string&);
|
||||||
|
|
||||||
|
bool is_due () const;
|
||||||
|
bool is_duetoday () const;
|
||||||
|
bool is_overdue () const;
|
||||||
|
|
||||||
status getStatus () const;
|
status getStatus () const;
|
||||||
void setStatus (status);
|
void setStatus (status);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue