diff --git a/ChangeLog b/ChangeLog index 15e21356f..849fb30a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 ------------------------------ diff --git a/html/task.html b/html/task.html index e9c331b54..13efc3172 100644 --- a/html/task.html +++ b/html/task.html @@ -127,6 +127,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.

    diff --git a/src/TDB.cpp b/src/TDB.cpp index 3c203f999..98c2c8009 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -244,55 +244,6 @@ bool TDB::allCompletedT (std::vector & all) const return false; } -//////////////////////////////////////////////////////////////////////////////// -bool TDB::deleteT (const T& t) -{ - T task (t); - - std::vector all; - allPendingT (all); - - std::vector ::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 all; - allPendingT (all); - - std::vector ::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) { diff --git a/src/TDB.h b/src/TDB.h index 49a68fa11..e2c0257ec 100644 --- a/src/TDB.h +++ b/src/TDB.h @@ -43,11 +43,8 @@ public: bool allPendingT (std::vector &); bool completedT (std::vector &) const; bool allCompletedT (std::vector &) const; - bool deleteT (const T&); - bool completeT (const T&); bool addT (const T&); bool modifyT (const T&); - bool logRead (std::vector &) const; int gc (); int nextId (); diff --git a/src/command.cpp b/src/command.cpp index 04abee49d..d5a715585 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -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)) diff --git a/src/task.cpp b/src/task.cpp index cd7a18066..82138d4be 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -470,7 +470,13 @@ void handleRecurrence (TDB& tdb, std::vector & 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; } diff --git a/src/tests/tdb.t.cpp b/src/tests/tdb.t.cpp index c874c00fa..4ef77694e 100644 --- a/src/tests/tdb.t.cpp +++ b/src/tests/tdb.t.cpp @@ -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");