From 5a0535c9b55684ac8e6ea21a621a3bf2a06f71a9 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 12 Jun 2009 01:54:53 -0400 Subject: [PATCH] Enhancment - Record::has - Used new Record::has method for efficiency. --- src/command.cpp | 26 +++++++++++++------------- src/report.cpp | 30 +++++++++++++++--------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index ad33214e7..3e6defd1e 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -52,8 +52,8 @@ std::string handleAdd () context.task.setEntry (); // Recurring tasks get a special status. - if (context.task.get ("due") != "" && - context.task.get ("recur") != "") + if (context.task.has ("due") && + context.task.has ("recur")) { context.task.setStatus (Task::recurring); context.task.set ("mask", ""); @@ -197,7 +197,7 @@ std::string handleUndelete () { if (t->getStatus () == T::deleted) { - if (t->getAttribute ("recur") != "") + if (t->has ("recur")) out << "Task does not support 'undo' for recurring tasks.\n"; t->setStatus (T::pending); @@ -235,7 +235,7 @@ std::string handleUndo () { if (t->getStatus () == T::completed) { - if (t->getAttribute ("recur") != "") + if (t->has ("recur")) out << "Task does not support 'undo' for recurring tasks.\n"; t->setStatus (T::pending); @@ -548,7 +548,7 @@ std::string handleStop () foreach (t, all) { - if (t->getAttribute ("start") != "") + if (t->has ("start")) { t->removeAttribute ("start"); tdb.modifyT (*t); @@ -705,21 +705,21 @@ std::string handleModify () foreach (seq, filtered) { // Perform some logical consistency checks. - if (task.getAttribute ("recur") != "" && - task.getAttribute ("due") == "" && - seq->getAttribute ("due") == "") + if (task.has ("recur") && + !task.has ("due") && + !seq->has ("due")) throw std::string ("You cannot specify a recurring task without a due date."); - if (task.getAttribute ("until") != "" && - task.getAttribute ("recur") == "" && - seq->getAttribute ("recur") == "") + if (task.has ("until") && + !task.has ("recur") && + !seq->has ("recur")) throw std::string ("You cannot specify an until date for a non-recurring task."); // Make all changes. foreach (other, all) { if (other->getId () == seq->getId () || // Self - (seq->getAttribute ("parent") != "" && + (seq->has ("parent") && seq->getAttribute ("parent") == other->getAttribute ("parent")) || // Sibling other->getUUID () == seq->getAttribute ("parent")) // Parent { @@ -764,7 +764,7 @@ std::string handleAppend () foreach (other, all) { if (other->getId () == seq->getId () || // Self - (seq->getAttribute ("parent") != "" && + (seq->has ("parent") && seq->getAttribute ("parent") == other->getAttribute ("parent")) || // Sibling other->getUUID () == seq->getAttribute ("parent")) // Parent { diff --git a/src/report.cpp b/src/report.cpp index 6e413f8ca..9c7d83145 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -575,7 +575,7 @@ std::string handleInfo () : refTask.getStatus () == T::deleted ? "Deleted" : refTask.getStatus () == T::recurring ? "Recurring" : ""; - if (refTask.getAttribute ("parent") != "") + if (refTask.has ("parent")) status += " (Recurring)"; row = table.addRow (); @@ -597,14 +597,14 @@ std::string handleInfo () table.addCell (row, 0, "Description"); table.addCell (row, 1, description); - if (refTask.getAttribute ("project") != "") + if (refTask.has ("project")) { row = table.addRow (); table.addCell (row, 0, "Project"); table.addCell (row, 1, refTask.getAttribute ("project")); } - if (refTask.getAttribute ("priority") != "") + if (refTask.has ("priority")) { row = table.addRow (); table.addCell (row, 0, "Priority"); @@ -612,30 +612,30 @@ std::string handleInfo () } if (refTask.getStatus () == T::recurring || - refTask.getAttribute ("parent") != "") + refTask.has ("parent")) { - if (refTask.getAttribute ("recur") != "") + if (refTask.has ("recur")) { row = table.addRow (); table.addCell (row, 0, "Recurrence"); table.addCell (row, 1, refTask.getAttribute ("recur")); } - if (refTask.getAttribute ("until") != "") + if (refTask.has ("until")) { row = table.addRow (); table.addCell (row, 0, "Recur until"); table.addCell (row, 1, refTask.getAttribute ("until")); } - if (refTask.getAttribute ("mask") != "") + if (refTask.has ("mask")) { row = table.addRow (); table.addCell (row, 0, "Mask"); table.addCell (row, 1, refTask.getAttribute ("mask")); } - if (refTask.getAttribute ("parent") != "") + if (refTask.has ("parent")) { row = table.addRow (); table.addCell (row, 0, "Parent task"); @@ -677,7 +677,7 @@ std::string handleInfo () } // start - if (refTask.getAttribute ("start") != "") + if (refTask.has ("start")) { row = table.addRow (); table.addCell (row, 0, "Start"); @@ -686,7 +686,7 @@ std::string handleInfo () } // end - if (refTask.getAttribute ("end") != "") + if (refTask.has ("end")) { row = table.addRow (); table.addCell (row, 0, "End"); @@ -1012,7 +1012,7 @@ std::string handleReportNext () } std::string active; - if (refTask.getAttribute ("start") != "") + if (refTask.has ("start")) active = "*"; std::string age; @@ -1665,7 +1665,7 @@ std::string handleReportTimesheet () { // If task started within range, but not completed withing range. if (t->getStatus () == T::pending && - t->getAttribute ("start") != "") + t->has ("start")) { Date startDate (::atoi (t->getAttribute ("start").c_str ())); if (startDate >= start && startDate < end) @@ -1909,7 +1909,7 @@ std::string handleReportCalendar () std::vector ::iterator it; for (it = pending.begin (); it != pending.end (); ++it) { - if (it->getAttribute ("due") != "") + if (it->has ("due")) { Date d (::atoi (it->getAttribute ("due").c_str ())); @@ -2050,7 +2050,7 @@ std::string handleReportActive () for (unsigned int i = 0; i < tasks.size (); ++i) { T refTask (tasks[i]); - if (refTask.getAttribute ("start") != "") + if (refTask.has ("start")) { Date now; bool imminent = false; @@ -2177,7 +2177,7 @@ std::string handleReportOverdue () { T refTask (tasks[i]); std::string due; - if ((due = refTask.getAttribute ("due")) != "") + if ((due = refTask.has ("due"))) { if (due.length ()) {