diff --git a/i18n/strings.de-DE b/i18n/strings.de-DE index 4f828b8e9..d2b89c235 100644 --- a/i18n/strings.de-DE +++ b/i18n/strings.de-DE @@ -54,7 +54,7 @@ 223 zusammenfassung #summary 224 etikett #tags 225 zeitdatenblatt#timesheet -226 wiederherstellen #undelete + 227 rücksetzen #undo 228 version #version diff --git a/i18n/strings.en-US b/i18n/strings.en-US index c17c70afe..5d7156b43 100644 --- a/i18n/strings.en-US +++ b/i18n/strings.en-US @@ -55,7 +55,7 @@ 223 summary 224 tags 225 timesheet -226 undelete + 227 undo 228 version 229 shell diff --git a/i18n/strings.sv-SE b/i18n/strings.sv-SE index dfa29a0f8..79e192187 100644 --- a/i18n/strings.sv-SE +++ b/i18n/strings.sv-SE @@ -54,7 +54,7 @@ 223 sammanfattning #summary 224 taggar #tags 225 tidsrapport #timesheet -226 ångra borttagning #undelete + 227 ångra #undo 228 version #version diff --git a/src/Context.cpp b/src/Context.cpp index 15fa89113..f13ea174d 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -180,10 +180,8 @@ std::string Context::dispatch () { Timer t ("Context::dispatch"); - int gcMod = 0; // Change occurred by way of gc. - std::string out; - // TODO Just look at this thing. It cries out for a dispatch table. + std::string out; if (cmd.command == "projects") { out = handleProjects (); } else if (cmd.command == "tags") { out = handleTags (); } else if (cmd.command == "colors") { out = handleColor (); } @@ -215,8 +213,8 @@ std::string Context::dispatch () sequence.size ()) { out = handleModify (); } // Command that display IDs and therefore need TDB::gc first. - else if (cmd.command == "next") { if (!inShadow) gcMod = tdb.gc (); out = handleReportNext (); } - else if (cmd.validCustom (cmd.command)) { if (!inShadow) gcMod = tdb.gc (); out = handleCustomReport (cmd.command); } + else if (cmd.command == "next") { if (!inShadow) tdb.gc (); out = handleReportNext (); } + else if (cmd.validCustom (cmd.command)) { if (!inShadow) tdb.gc (); out = handleCustomReport (cmd.command); } // If the command is not recognized, display usage. else { out = shortUsage (); } diff --git a/src/TDB.cpp b/src/TDB.cpp index 33f13302f..f7a594b30 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -61,7 +61,9 @@ extern Context context; // | | +- TDB::update (T) // | | | // | | +- TDB::commit -// | | write all +// | | | write all +// | | | +// | | +- TDB::undo // | | // | +- TDB::unlock // | [unlock] @@ -491,6 +493,23 @@ int TDB::nextId () //////////////////////////////////////////////////////////////////////////////// void TDB::undo () { + // TODO Load all undo.data + + // TODO Load all pending.data + std::vector allPending; + + // TODO Load all completed.data + std::vector allCompleted; + + // TODO 'pop' last transaction + // TODO Locate 'new' task + + // TODO Confirm + // TODO Overwrite 'old' task, or delete + + // TODO Write all pending.data + // TODO Write all completed.data + // TODO Write all undo.data } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/command.cpp b/src/command.cpp index cbe7ae482..d9fe5d09f 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -208,7 +208,9 @@ std::string handleTags () //////////////////////////////////////////////////////////////////////////////// void handleUndo () { + context.tdb.lock (context.config.get ("locking", true)); context.tdb.undo (); + context.tdb.unlock (); } //////////////////////////////////////////////////////////////////////////////// @@ -299,12 +301,11 @@ std::string handleVersion () std::string recognized = " blanklines color color.active color.due color.overdue color.pri.H " "color.pri.L color.pri.M color.pri.none color.recurring color.tagged " - "color.footnote color.header color.message color.debug confirmation curses " - "data.location dateformat debug default.command default.priority " - "defaultwidth displayweeknumber due echo.command locale locking " - "monthsperline nag next project shadow.command shadow.file shadow.notify " - "weekstart editor import.synonym.id import.synonym.uuid " - "longversion " + "color.footnote color.header color.debug confirmation curses data.location " + "dateformat debug default.command default.priority defaultwidth due locale " + "displayweeknumber echo.command locking monthsperline nag next project " + "shadow.command shadow.file shadow.notify weekstart editor import.synonym.id " + "import.synonym.uuid longversion " #ifdef FEATURE_SHELL "shell.prompt " #endif @@ -681,14 +682,13 @@ std::string handleExport () std::vector tasks; context.tdb.lock (context.config.get ("locking", true)); handleRecurrence (); - context.tdb.loadPending (tasks, context.filter); + context.tdb.load (tasks, context.filter); context.tdb.commit (); context.tdb.unlock (); foreach (task, tasks) { - if (task->getStatus () != Task::recurring && - task->getStatus () != Task::deleted) + if (task->getStatus () != Task::recurring) { out << task->composeCSV ().c_str (); ++count; diff --git a/src/util.cpp b/src/util.cpp index fc1959adf..1ec2d9050 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -426,6 +426,20 @@ void spit (const std::string& file, const std::string& contents) throw std::string ("Could not write file '") + file + "'"; // TODO i18n } +//////////////////////////////////////////////////////////////////////////////// +void spit (const std::string& file, const std::vector & lines) +{ + std::ofstream out (file.c_str ()); + if (out.good ()) + { + foreach (line, lines) + out << *line; + out.close (); + } + else + throw std::string ("Could not write file '") + file + "'"; // TODO i18n +} + //////////////////////////////////////////////////////////////////////////////// bool taskDiff (const Task& before, const Task& after) { diff --git a/src/util.h b/src/util.h index 422f3bc21..02b43e05a 100644 --- a/src/util.h +++ b/src/util.h @@ -73,6 +73,7 @@ std::string expandPath (const std::string&); bool slurp (const std::string&, std::vector &, bool trimLines = false); bool slurp (const std::string&, std::string&, bool trimLines = false); void spit (const std::string&, const std::string&); +void spit (const std::string&, const std::vector &); bool taskDiff (const Task&, const Task&); std::string taskDifferences (const Task&, const Task&);