From d898f3f5096e893e536d7c9ec96f7c39b5f78fd6 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 11 Jun 2009 22:58:38 -0400 Subject: [PATCH] Enhancement - Annotations - Annotations are now being parsed properly from FF3. --- src/Task.cpp | 4 +--- src/Task.h | 2 +- src/custom.cpp | 51 ++++++++++++++++++++++++++------------------------ 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/Task.cpp b/src/Task.cpp index 0428b84af..4486ccef6 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -247,7 +247,6 @@ void Task::legacyParse (const std::string& line) set (pair[0], pair[1]); } -/* // Extract and split the annotations, which are of the form: // 1234:"..." 5678:"..." std::string annotations = line.substr ( @@ -282,10 +281,9 @@ void Task::legacyParse (const std::string& line) { std::string name = pair.substr (0, colon); std::string value = pair.substr (colon + 2, pair.length () - colon - 3); - mAnnotations[::atoi (name.c_str ())] = value; + set ("annotation_" + name, value); } } -*/ set ("description", line.substr (closeAnnoBracket + 2, std::string::npos)); } diff --git a/src/Task.h b/src/Task.h index 12907da7b..6efb751f2 100644 --- a/src/Task.h +++ b/src/Task.h @@ -51,7 +51,7 @@ public: Subst subst; // Series of helper functions. - int id () const { return sequence.size () ? sequence[0] : 0; } + int id () const { return sequence.size () ? sequence[0] : 0; } void id (int anotherId) { sequence.push_back (anotherId); } static status textToStatus (const std::string&); diff --git a/src/custom.cpp b/src/custom.cpp index f00362a27..4dedc4fa2 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -104,6 +104,7 @@ std::string handleCustomReport (const std::string& report) filter (tasks, filterTask); // Filter from custom report filter (tasks, task); // Filter from command line } +*/ // Initialize colorization for subsequent auto colorization. initializeColorRules (); @@ -127,7 +128,7 @@ std::string handleCustomReport (const std::string& report) table.setColumnJustification (columnCount, Table::right); for (unsigned int row = 0; row < tasks.size(); ++row) - table.addCell (row, columnCount, tasks[row].getId ()); + table.addCell (row, columnCount, tasks[row].id ()); } else if (*col == "uuid") @@ -137,7 +138,7 @@ std::string handleCustomReport (const std::string& report) table.setColumnJustification (columnCount, Table::left); for (unsigned int row = 0; row < tasks.size(); ++row) - table.addCell (row, columnCount, tasks[row].getUUID ()); + table.addCell (row, columnCount, tasks[row].get ("uuid")); } else if (*col == "project") @@ -147,7 +148,7 @@ std::string handleCustomReport (const std::string& report) table.setColumnJustification (columnCount, Table::left); for (unsigned int row = 0; row < tasks.size(); ++row) - table.addCell (row, columnCount, tasks[row].getAttribute ("project")); + table.addCell (row, columnCount, tasks[row].get ("project")); } else if (*col == "priority") @@ -157,7 +158,7 @@ std::string handleCustomReport (const std::string& report) table.setColumnJustification (columnCount, Table::left); for (unsigned int row = 0; row < tasks.size(); ++row) - table.addCell (row, columnCount, tasks[row].getAttribute ("priority")); + table.addCell (row, columnCount, tasks[row].get ("priority")); } else if (*col == "entry") @@ -169,7 +170,7 @@ std::string handleCustomReport (const std::string& report) std::string entered; for (unsigned int row = 0; row < tasks.size(); ++row) { - entered = tasks[row].getAttribute ("entry"); + entered = tasks[row].get ("entry"); if (entered.length ()) { Date dt (::atoi (entered.c_str ())); @@ -188,7 +189,7 @@ std::string handleCustomReport (const std::string& report) std::string started; for (unsigned int row = 0; row < tasks.size(); ++row) { - started = tasks[row].getAttribute ("start"); + started = tasks[row].get ("start"); if (started.length ()) { Date dt (::atoi (started.c_str ())); @@ -207,7 +208,7 @@ std::string handleCustomReport (const std::string& report) std::string due; for (unsigned int row = 0; row < tasks.size(); ++row) { - due = tasks[row].getAttribute ("due"); + due = tasks[row].get ("due"); if (due.length ()) { Date dt (::atoi (due.c_str ())); @@ -230,7 +231,7 @@ std::string handleCustomReport (const std::string& report) Date now; for (unsigned int row = 0; row < tasks.size(); ++row) { - created = tasks[row].getAttribute ("entry"); + created = tasks[row].get ("entry"); if (created.length ()) { Date dt (::atoi (created.c_str ())); @@ -251,7 +252,7 @@ std::string handleCustomReport (const std::string& report) Date now; for (unsigned int row = 0; row < tasks.size(); ++row) { - created = tasks[row].getAttribute ("entry"); + created = tasks[row].get ("entry"); if (created.length ()) { Date dt (::atoi (created.c_str ())); @@ -268,7 +269,7 @@ std::string handleCustomReport (const std::string& report) table.setColumnJustification (columnCount, Table::left); for (unsigned int row = 0; row < tasks.size(); ++row) - if (tasks[row].getAttribute ("start") != "") + if (tasks[row].get ("start") != "") table.addCell (row, columnCount, "*"); } @@ -295,7 +296,7 @@ std::string handleCustomReport (const std::string& report) table.setColumnJustification (columnCount, Table::left); for (unsigned int row = 0; row < tasks.size(); ++row) - table.addCell (row, columnCount, tasks[row].getDescription ()); + table.addCell (row, columnCount, tasks[row].get ("description")); } else if (*col == "description") @@ -308,14 +309,15 @@ std::string handleCustomReport (const std::string& report) std::string when; for (unsigned int row = 0; row < tasks.size(); ++row) { - description = tasks[row].getDescription (); - std::map annotations; + description = tasks[row].get ("description"); + + std::vector annotations; tasks[row].getAnnotations (annotations); foreach (anno, annotations) { - Date dt (anno->first); + Date dt (::atoi (anno->name ().substr (11, std::string::npos).c_str ())); when = dt.toString (context.config.get ("dateformat", "m/d/Y")); - description += "\n" + when + " " + anno->second; + description += "\n" + when + " " + anno->value (); } table.addCell (row, columnCount, description); @@ -329,7 +331,7 @@ std::string handleCustomReport (const std::string& report) table.setColumnJustification (columnCount, Table::right); for (unsigned int row = 0; row < tasks.size (); ++row) - table.addCell (row, columnCount, tasks[row].getAttribute ("recur")); + table.addCell (row, columnCount, tasks[row].get ("recur")); } else if (*col == "recurrence_indicator") @@ -340,7 +342,7 @@ std::string handleCustomReport (const std::string& report) for (unsigned int row = 0; row < tasks.size (); ++row) table.addCell (row, columnCount, - tasks[row].getAttribute ("recur") != "" ? "R" : ""); + tasks[row].get ("recur") != "" ? "R" : ""); } else if (*col == "tag_indicator") @@ -415,13 +417,13 @@ std::string handleCustomReport (const std::string& report) for (unsigned int row = 0; row < tasks.size (); ++row) { imminent = false; - overdue = false; - due = tasks[row].getAttribute ("due"); + overdue = false; + due = tasks[row].get ("due"); if (due.length ()) { switch (getDueState (due)) { - case 2: overdue = true; break; + case 2: overdue = true; break; case 1: imminent = true; break; case 0: default: break; @@ -430,8 +432,8 @@ std::string handleCustomReport (const std::string& report) if (context.config.get ("color", true) || context.config.get (std::string ("_forcecolor"), false)) { - Text::color fg = Text::colorCode (tasks[row].getAttribute ("fg")); - Text::color bg = Text::colorCode (tasks[row].getAttribute ("bg")); + Text::color fg = Text::colorCode (tasks[row].get ("fg")); + Text::color bg = Text::colorCode (tasks[row].get ("bg")); autoColorize (tasks[row], fg, bg); table.setRowFg (row, fg); table.setRowBg (row, bg); @@ -452,6 +454,7 @@ std::string handleCustomReport (const std::string& report) // Limit the number of rows according to the report definition. int maximum = context.config.get (std::string ("report.") + report + ".limit", (int)0); +/* // If the custom report has a defined limit, then allow an override, which // will show up as a single ID sequence. if (context.config.get (std::string ("report.") + report + ".limit", (int)0) != 0) @@ -461,8 +464,8 @@ std::string handleCustomReport (const std::string& report) maximum = sequence[0]; } */ + std::stringstream out; -/* if (table.rowCount ()) out << optionalBlankLine () << table.render (maximum) @@ -473,7 +476,7 @@ std::string handleCustomReport (const std::string& report) else out << "No matches." << std::endl; -*/ + return out.str (); }