mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +02:00
- Merged 1.4.3 to master
This commit is contained in:
parent
a815492111
commit
2cae1df42f
27 changed files with 950 additions and 431 deletions
27
src/TDB.cpp
27
src/TDB.cpp
|
@ -235,7 +235,7 @@ bool TDB::completeT (const T& t)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::addT (const T& t) const
|
||||
bool TDB::addT (const T& t)
|
||||
{
|
||||
T task (t);
|
||||
std::vector <std::string> tags;
|
||||
|
@ -254,7 +254,9 @@ bool TDB::addT (const T& t) const
|
|||
|
||||
if (task.getStatus () == T::pending ||
|
||||
task.getStatus () == T::recurring)
|
||||
{
|
||||
return writePending (task);
|
||||
}
|
||||
|
||||
return writeCompleted (task);
|
||||
}
|
||||
|
@ -312,6 +314,7 @@ bool TDB::overwritePending (std::vector <T>& all)
|
|||
fputs (it->compose ().c_str (), out);
|
||||
|
||||
fclose (out);
|
||||
dbChanged ();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -319,7 +322,7 @@ bool TDB::overwritePending (std::vector <T>& all)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::writePending (const T& t) const
|
||||
bool TDB::writePending (const T& t)
|
||||
{
|
||||
// Write a single task to the pending file
|
||||
FILE* out;
|
||||
|
@ -334,6 +337,7 @@ bool TDB::writePending (const T& t) const
|
|||
fputs (t.compose ().c_str (), out);
|
||||
|
||||
fclose (out);
|
||||
dbChanged ();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -341,7 +345,7 @@ bool TDB::writePending (const T& t) const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::writeCompleted (const T& t) const
|
||||
bool TDB::writeCompleted (const T& t)
|
||||
{
|
||||
// Write a single task to the pending file
|
||||
FILE* out;
|
||||
|
@ -356,6 +360,7 @@ bool TDB::writeCompleted (const T& t) const
|
|||
fputs (t.compose ().c_str (), out);
|
||||
|
||||
fclose (out);
|
||||
dbChanged ();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -439,4 +444,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