- Merged 1.4.3 to master

This commit is contained in:
Paul Beckingham 2008-11-01 16:31:30 -04:00
parent a815492111
commit 2cae1df42f
27 changed files with 950 additions and 431 deletions

View file

@ -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) ();
}
////////////////////////////////////////////////////////////////////////////////