mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Enhancement - TDB API cleanup
- Removed obsolete TDB::deleteT method. - Removed obsolete TDB::completeT method. - Updated documentation.
This commit is contained in:
parent
90c721295a
commit
5814432366
7 changed files with 37 additions and 59 deletions
|
@ -16,6 +16,7 @@
|
|||
and also have modifications applied (thanks to David J Patrick).
|
||||
+ The "append", and "done" commands now allow modifications to be applied
|
||||
to the task(s) (thanks to David J Patrick).
|
||||
+ Improved word wrapping in various output.
|
||||
|
||||
------ old releases ------------------------------
|
||||
|
||||
|
|
|
@ -127,6 +127,7 @@
|
|||
and also have modifications applied (thanks to David J Patrick).
|
||||
<li>The "append", and "done" commands now allow modifications to be applied
|
||||
to the task(s) (thanks to David J Patrick).
|
||||
<li>Improved word wrapping in various output.
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
|
|
49
src/TDB.cpp
49
src/TDB.cpp
|
@ -244,55 +244,6 @@ bool TDB::allCompletedT (std::vector <T>& all) const
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::deleteT (const T& t)
|
||||
{
|
||||
T task (t);
|
||||
|
||||
std::vector <T> all;
|
||||
allPendingT (all);
|
||||
|
||||
std::vector <T>::iterator it;
|
||||
for (it = all.begin (); it != all.end (); ++it)
|
||||
if (task.getId () == it->getId ())
|
||||
{
|
||||
it->setStatus (T::deleted);
|
||||
|
||||
char endTime[16];
|
||||
sprintf (endTime, "%u", (unsigned int) time (NULL));
|
||||
it->setAttribute ("end", endTime);
|
||||
|
||||
return overwritePending (all);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::completeT (const T& t)
|
||||
{
|
||||
T task (t);
|
||||
|
||||
std::vector <T> all;
|
||||
allPendingT (all);
|
||||
|
||||
std::vector <T>::iterator it;
|
||||
for (it = all.begin (); it != all.end (); ++it)
|
||||
if (task.getId () == it->getId ())
|
||||
{
|
||||
*it = t;
|
||||
it->setStatus (T::completed);
|
||||
|
||||
char endTime[16];
|
||||
sprintf (endTime, "%u", (unsigned int) time (NULL));
|
||||
it->setAttribute ("end", endTime);
|
||||
|
||||
return overwritePending (all);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool TDB::addT (const T& t)
|
||||
{
|
||||
|
|
|
@ -43,11 +43,8 @@ public:
|
|||
bool allPendingT (std::vector <T>&);
|
||||
bool completedT (std::vector <T>&) const;
|
||||
bool allCompletedT (std::vector <T>&) const;
|
||||
bool deleteT (const T&);
|
||||
bool completeT (const T&);
|
||||
bool addT (const T&);
|
||||
bool modifyT (const T&);
|
||||
bool logRead (std::vector <std::string>&) const;
|
||||
int gc ();
|
||||
int nextId ();
|
||||
|
||||
|
|
|
@ -433,6 +433,10 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
|
|||
tdb.allPendingT (all);
|
||||
filterSequence (all, task);
|
||||
|
||||
// Determine the end date.
|
||||
char endTime[16];
|
||||
sprintf (endTime, "%u", (unsigned int) time (NULL));
|
||||
|
||||
foreach (t, all)
|
||||
{
|
||||
std::stringstream question;
|
||||
|
@ -458,7 +462,10 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
|
|||
if (sibling->getAttribute ("parent") == parent ||
|
||||
sibling->getUUID () == parent)
|
||||
{
|
||||
tdb.deleteT (*sibling);
|
||||
sibling->setStatus (T::deleted);
|
||||
sibling->setAttribute ("end", endTime);
|
||||
tdb.modifyT (*sibling);
|
||||
|
||||
if (conf.get ("echo.command", true))
|
||||
out << "Deleting recurring task "
|
||||
<< sibling->getId ()
|
||||
|
@ -474,7 +481,10 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
|
|||
// Update mask in parent.
|
||||
t->setStatus (T::deleted);
|
||||
updateRecurrenceMask (tdb, all, *t);
|
||||
tdb.deleteT (*t);
|
||||
|
||||
t->setAttribute ("end", endTime);
|
||||
tdb.modifyT (*t);
|
||||
|
||||
out << "Deleting recurring task "
|
||||
<< t->getId ()
|
||||
<< " '"
|
||||
|
@ -485,7 +495,10 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
|
|||
}
|
||||
else
|
||||
{
|
||||
tdb.deleteT (*t);
|
||||
t->setStatus (T::deleted);
|
||||
t->setAttribute ("end", endTime);
|
||||
tdb.modifyT (*t);
|
||||
|
||||
if (conf.get ("echo.command", true))
|
||||
out << "Deleting task "
|
||||
<< t->getId ()
|
||||
|
@ -587,8 +600,15 @@ std::string handleDone (TDB& tdb, T& task, Config& conf)
|
|||
deltaAttributes (*seq, task);
|
||||
deltaSubstitutions (*seq, task);
|
||||
|
||||
// Add an end date.
|
||||
char entryTime[16];
|
||||
sprintf (entryTime, "%u", (unsigned int) time (NULL));
|
||||
task.setAttribute ("end", entryTime);
|
||||
|
||||
// Change status.
|
||||
seq->setStatus (T::completed);
|
||||
if (!tdb.completeT (*seq))
|
||||
|
||||
if (!tdb.modifyT (*seq))
|
||||
throw std::string ("Could not mark task as completed.");
|
||||
|
||||
if (conf.get ("echo.command", true))
|
||||
|
|
|
@ -470,7 +470,13 @@ void handleRecurrence (TDB& tdb, std::vector <T>& tasks)
|
|||
<< " ("
|
||||
<< trim (t->getDescription ())
|
||||
<< ") is past its 'until' date, and has be deleted" << std::endl;
|
||||
tdb.deleteT (*t);
|
||||
|
||||
// Determine the end date.
|
||||
char endTime[16];
|
||||
sprintf (endTime, "%u", (unsigned int) time (NULL));
|
||||
t->setAttribute ("end", endTime);
|
||||
t->setStatus (T::deleted);
|
||||
tdb.modifyT (*t);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,8 @@ int main (int argc, char** argv)
|
|||
// TODO Modify task.
|
||||
|
||||
// Complete task.
|
||||
t.ok (tdb.completeT (t1), "TDB::completeT t1");;
|
||||
t1.setStatus (T::completed);
|
||||
t.ok (tdb.modifyT (t1), "TDB::modifyT (completed) t1");;
|
||||
t.ok (tdb.pendingT (all), "TDB::pendingT read db");
|
||||
t.is ((int) all.size (), 0, "empty db");
|
||||
t.ok (tdb.allPendingT (all), "TDB::allPendingT read db");
|
||||
|
@ -105,7 +106,8 @@ int main (int argc, char** argv)
|
|||
t.ok (tdb.addT (t2), "TDB::addT t2");
|
||||
|
||||
// Delete task.
|
||||
t.ok (tdb.deleteT (t2), "TDB::deleteT t2");
|
||||
t2.setStatus (T::deleted);
|
||||
t.ok (tdb.modifyT (t2), "TDB::modifyT (deleted) t2");
|
||||
|
||||
// GC the files.
|
||||
t.is (tdb.gc (), 1, "1 <- TDB::gc");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue