From 06d54b2e7299bb97a986562036d407ad33d49767 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 14 Aug 2011 12:04:34 -0400 Subject: [PATCH] Commands - Calendar - Converted the 'cal' command to TDB2. - Reinstated command line handling for 'cal' command, but realized there is a conflict with filters. Filtering disabled for 'cal' until a good solution is found. - Converted recur.cpp to use TDB2, which eliminates the file locking problems that occur when both TDB and TDB2 are in use at the same time. This will cause other issues until all commands are converted to TDB2. --- src/commands/CmdCalendar.cpp | 25 +++++++++---------------- src/recur.cpp | 10 +++------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/commands/CmdCalendar.cpp b/src/commands/CmdCalendar.cpp index e216ce728..145fc308a 100644 --- a/src/commands/CmdCalendar.cpp +++ b/src/commands/CmdCalendar.cpp @@ -62,17 +62,10 @@ int CmdCalendar::execute (std::string& output) if (preferredMonthsPerLine != 0 && preferredMonthsPerLine < monthsThatFit) monthsPerLine = preferredMonthsPerLine; - // Get all the tasks. - std::vector tasks; - context.tdb.lock (context.config.getBoolean ("locking")); + // Load the pending tasks. handleRecurrence (); - context.tdb.loadPending (tasks); - context.tdb.commit (); - context.tdb.unlock (); - - // Apply filter. - std::vector filtered; - filter (tasks, filtered); + context.tdb2.commit (); + std::vector tasks = context.tdb2.pending.get_tasks (); Date today; bool getpendingdate = false; @@ -117,10 +110,11 @@ int CmdCalendar::execute (std::string& output) int argMonth = 0; int argYear = 0; bool argWholeYear = false; -/* - std::vector args = context.args.list (); + + std::vector words = context.a3.extract_words (); + std::vector ::iterator arg; - for (arg = args.begin (); arg != args.end (); ++arg) + for (arg = words.begin (); arg != words.end (); ++arg) { // Some version of "calendar". if (autoComplete (lowerCase (*arg), commandNames, matches, context.config.getInteger ("abbreviation.minimum")) == 1) @@ -157,7 +151,6 @@ int CmdCalendar::execute (std::string& output) else throw std::string ("Could not recognize argument '") + *arg + "'."; } -*/ // Supported combinations: // @@ -189,7 +182,7 @@ int CmdCalendar::execute (std::string& output) // Find the oldest pending due date. Date oldest (12,31,2037); std::vector ::iterator task; - for (task = filtered.begin (); task != filtered.end (); ++task) + for (task = tasks.begin (); task != tasks.end (); ++task) { if (task->getStatus () == Task::pending) { @@ -282,7 +275,7 @@ int CmdCalendar::execute (std::string& output) out << "\n" << optionalBlankLine () - << renderMonths (mFrom, yFrom, today, filtered, monthsPerLine) + << renderMonths (mFrom, yFrom, today, tasks, monthsPerLine) << "\n"; mFrom += monthsPerLine; diff --git a/src/recur.cpp b/src/recur.cpp index d8df90d0c..2fc02f9ce 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -55,8 +55,7 @@ extern Context context; // child tasks need to be generated to fill gaps. void handleRecurrence () { - std::vector tasks; - context.tdb.loadPending (tasks); + std::vector tasks = context.tdb2.pending.get_tasks (); std::vector modified; // Look at all tasks and find any recurring ones. @@ -368,7 +367,7 @@ void updateRecurrenceMask ( : '?'; it->set ("mask", mask); - context.tdb.update (*it); + context.tdb2.modify (*it); } else { @@ -438,10 +437,7 @@ bool nag (Task& task) if (nagMessage != "") { // Load all pending tasks. - std::vector tasks; - - // Piggy-back on existing locked TDB. - context.tdb.loadPending (tasks); + std::vector tasks = context.tdb2.pending.get_tasks (); // Counters. int overdue = 0;