From 21c3a0ef4810b5e81f46bc5c1399561679a665c7 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 1 Jul 2009 01:00:25 -0400 Subject: [PATCH] Code Cleanup - undo - Improved description of most recent change. - Added timestamp of most recent change. --- src/TDB.cpp | 15 +++++++++------ src/util.cpp | 22 ++++++++++------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/TDB.cpp b/src/TDB.cpp index 2deddb47b..d6a39f16d 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -528,22 +528,25 @@ void TDB::undo () u.pop_back (); } + Date lastChange (::atoi (when.c_str ())); + std::cout << std::endl + << "The last modification was made " + << lastChange.toString () + << std::endl; + // confirm if (prior != "") { Task priorTask (prior); Task currentTask (current); - std::cout << "The last modification was that " - << taskDifferences (prior, current) - << std::endl + std::cout << taskDifferences (prior, current) << std::endl; } else - std::cout << "This was a new task." - << std::endl + std::cout << " - This was a new task" << std::endl; - if (!confirm ("The undo command is irreversible. Are you sure you want to undo the last update?")) + if (!confirm ("The undo command is not reversible. Are you sure you want to undo the last update?")) throw std::string ("No changes made."); // Extract identifying uuid. diff --git a/src/util.cpp b/src/util.cpp index 889104823..073bdf16b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -498,35 +498,33 @@ std::string taskDifferences (const Task& before, const Task& after) // Now start generating a description of the differences. std::stringstream out; foreach (name, beforeOnly) - out << *name - << " was deleted. "; + out << " - " + << *name + << " was deleted\n"; foreach (name, afterOnly) - out << *name + out << " - " + << *name << " was set to '" << after.get (*name) - << "'. "; + << "'\n"; foreach (name, beforeAtts) if (*name != "uuid" && after.get (*name) != "" && before.get (*name) != after.get (*name)) - out << *name + out << " - " + << *name << " was changed from '" << before.get (*name) << "' to '" << after.get (*name) - << "'. "; + << "'\n"; // Can't just say nothing. if (out.str ().length () == 0) - out << "No changes were made. "; + out << " - No changes were made\n"; -/* - std::stringstream decorated; - decorated << "Task " << before.id << " was modified. " << out.str (); - return decorated.str (); -*/ return out.str (); }