Enhancement - Hooks
- Implemented API::callTaskHook. - Implemented Hook object inside Hooks.cpp, not Hooks.h. - Implemented Hooks.setTaskId to provide context for task hooks. - Implemented pre-tag, post-tag, pre-detag, post-detag events. - Implemented pre-file-lock, post-file-lock, pre-file-unlock, post-file-unlock events.
This commit is contained in:
@@ -1701,20 +1701,29 @@ int deltaDescription (Task& task)
|
||||
int deltaTags (Task& task)
|
||||
{
|
||||
int changes = 0;
|
||||
context.hooks.setTaskId (task.id);
|
||||
|
||||
// Apply or remove tags, if any.
|
||||
std::vector <std::string> tags;
|
||||
context.task.getTags (tags);
|
||||
foreach (tag, tags)
|
||||
{
|
||||
task.addTag (*tag);
|
||||
++changes;
|
||||
if (context.hooks.trigger ("pre-tag"))
|
||||
{
|
||||
task.addTag (*tag);
|
||||
++changes;
|
||||
context.hooks.trigger ("post-tag");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (tag, context.tagRemovals)
|
||||
{
|
||||
task.removeTag (*tag);
|
||||
++changes;
|
||||
if (context.hooks.trigger ("pre-detag"))
|
||||
{
|
||||
task.removeTag (*tag);
|
||||
++changes;
|
||||
context.hooks.trigger ("post-detag");
|
||||
}
|
||||
}
|
||||
|
||||
return changes;
|
||||
|
||||
Reference in New Issue
Block a user