mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +02:00
- Added support for shadow file, shadow file command
- Added support for TDB::onChange callback
This commit is contained in:
parent
e7304e86ce
commit
a5ec1e4b27
7 changed files with 168 additions and 81 deletions
40
src/TDB.cpp
40
src/TDB.cpp
|
@ -206,7 +206,9 @@ bool TDB::deleteT (const T& t)
|
|||
sprintf (endTime, "%u", (unsigned int) time (NULL));
|
||||
it->setAttribute ("end", endTime);
|
||||
|
||||
return overwritePending (all);
|
||||
bool status = overwritePending (all);
|
||||
dbChanged ();
|
||||
return status;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -230,14 +232,16 @@ bool TDB::completeT (const T& t)
|
|||
sprintf (endTime, "%u", (unsigned int) time (NULL));
|
||||
it->setAttribute ("end", endTime);
|
||||
|
||||
return overwritePending (all);
|
||||
bool status = overwritePending (all);
|
||||
dbChanged ();
|
||||
return status;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::addT (const T& t) const
|
||||
bool TDB::addT (const T& t)
|
||||
{
|
||||
T task (t);
|
||||
std::vector <std::string> tags;
|
||||
|
@ -256,9 +260,15 @@ bool TDB::addT (const T& t) const
|
|||
|
||||
if (task.getStatus () == T::pending ||
|
||||
task.getStatus () == T::recurring)
|
||||
return writePending (task);
|
||||
{
|
||||
bool status = writePending (task);
|
||||
dbChanged ();
|
||||
return status;
|
||||
}
|
||||
|
||||
return writeCompleted (task);
|
||||
bool status = writeCompleted (task);
|
||||
dbChanged ();
|
||||
return status;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -283,7 +293,9 @@ bool TDB::modifyT (const T& t)
|
|||
pending.push_back (*it);
|
||||
}
|
||||
|
||||
return overwritePending (pending);
|
||||
bool status = overwritePending (pending);
|
||||
dbChanged ();
|
||||
return status;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -493,4 +505,20 @@ int TDB::nextId ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void TDB::onChange (void (*callback)())
|
||||
{
|
||||
if (callback)
|
||||
mOnChange.push_back (callback);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Iterate over callbacks.
|
||||
void TDB::dbChanged ()
|
||||
{
|
||||
foreach (i, mOnChange)
|
||||
if (*i)
|
||||
(**i) ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue