Enhancment - Record::has
- Used new Record::has method for efficiency.
This commit is contained in:
@@ -52,8 +52,8 @@ std::string handleAdd ()
|
|||||||
context.task.setEntry ();
|
context.task.setEntry ();
|
||||||
|
|
||||||
// Recurring tasks get a special status.
|
// Recurring tasks get a special status.
|
||||||
if (context.task.get ("due") != "" &&
|
if (context.task.has ("due") &&
|
||||||
context.task.get ("recur") != "")
|
context.task.has ("recur"))
|
||||||
{
|
{
|
||||||
context.task.setStatus (Task::recurring);
|
context.task.setStatus (Task::recurring);
|
||||||
context.task.set ("mask", "");
|
context.task.set ("mask", "");
|
||||||
@@ -197,7 +197,7 @@ std::string handleUndelete ()
|
|||||||
{
|
{
|
||||||
if (t->getStatus () == T::deleted)
|
if (t->getStatus () == T::deleted)
|
||||||
{
|
{
|
||||||
if (t->getAttribute ("recur") != "")
|
if (t->has ("recur"))
|
||||||
out << "Task does not support 'undo' for recurring tasks.\n";
|
out << "Task does not support 'undo' for recurring tasks.\n";
|
||||||
|
|
||||||
t->setStatus (T::pending);
|
t->setStatus (T::pending);
|
||||||
@@ -235,7 +235,7 @@ std::string handleUndo ()
|
|||||||
{
|
{
|
||||||
if (t->getStatus () == T::completed)
|
if (t->getStatus () == T::completed)
|
||||||
{
|
{
|
||||||
if (t->getAttribute ("recur") != "")
|
if (t->has ("recur"))
|
||||||
out << "Task does not support 'undo' for recurring tasks.\n";
|
out << "Task does not support 'undo' for recurring tasks.\n";
|
||||||
|
|
||||||
t->setStatus (T::pending);
|
t->setStatus (T::pending);
|
||||||
@@ -548,7 +548,7 @@ std::string handleStop ()
|
|||||||
|
|
||||||
foreach (t, all)
|
foreach (t, all)
|
||||||
{
|
{
|
||||||
if (t->getAttribute ("start") != "")
|
if (t->has ("start"))
|
||||||
{
|
{
|
||||||
t->removeAttribute ("start");
|
t->removeAttribute ("start");
|
||||||
tdb.modifyT (*t);
|
tdb.modifyT (*t);
|
||||||
@@ -705,21 +705,21 @@ std::string handleModify ()
|
|||||||
foreach (seq, filtered)
|
foreach (seq, filtered)
|
||||||
{
|
{
|
||||||
// Perform some logical consistency checks.
|
// Perform some logical consistency checks.
|
||||||
if (task.getAttribute ("recur") != "" &&
|
if (task.has ("recur") &&
|
||||||
task.getAttribute ("due") == "" &&
|
!task.has ("due") &&
|
||||||
seq->getAttribute ("due") == "")
|
!seq->has ("due"))
|
||||||
throw std::string ("You cannot specify a recurring task without a due date.");
|
throw std::string ("You cannot specify a recurring task without a due date.");
|
||||||
|
|
||||||
if (task.getAttribute ("until") != "" &&
|
if (task.has ("until") &&
|
||||||
task.getAttribute ("recur") == "" &&
|
!task.has ("recur") &&
|
||||||
seq->getAttribute ("recur") == "")
|
!seq->has ("recur"))
|
||||||
throw std::string ("You cannot specify an until date for a non-recurring task.");
|
throw std::string ("You cannot specify an until date for a non-recurring task.");
|
||||||
|
|
||||||
// Make all changes.
|
// Make all changes.
|
||||||
foreach (other, all)
|
foreach (other, all)
|
||||||
{
|
{
|
||||||
if (other->getId () == seq->getId () || // Self
|
if (other->getId () == seq->getId () || // Self
|
||||||
(seq->getAttribute ("parent") != "" &&
|
(seq->has ("parent") &&
|
||||||
seq->getAttribute ("parent") == other->getAttribute ("parent")) || // Sibling
|
seq->getAttribute ("parent") == other->getAttribute ("parent")) || // Sibling
|
||||||
other->getUUID () == seq->getAttribute ("parent")) // Parent
|
other->getUUID () == seq->getAttribute ("parent")) // Parent
|
||||||
{
|
{
|
||||||
@@ -764,7 +764,7 @@ std::string handleAppend ()
|
|||||||
foreach (other, all)
|
foreach (other, all)
|
||||||
{
|
{
|
||||||
if (other->getId () == seq->getId () || // Self
|
if (other->getId () == seq->getId () || // Self
|
||||||
(seq->getAttribute ("parent") != "" &&
|
(seq->has ("parent") &&
|
||||||
seq->getAttribute ("parent") == other->getAttribute ("parent")) || // Sibling
|
seq->getAttribute ("parent") == other->getAttribute ("parent")) || // Sibling
|
||||||
other->getUUID () == seq->getAttribute ("parent")) // Parent
|
other->getUUID () == seq->getAttribute ("parent")) // Parent
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ std::string handleInfo ()
|
|||||||
: refTask.getStatus () == T::deleted ? "Deleted"
|
: refTask.getStatus () == T::deleted ? "Deleted"
|
||||||
: refTask.getStatus () == T::recurring ? "Recurring"
|
: refTask.getStatus () == T::recurring ? "Recurring"
|
||||||
: "";
|
: "";
|
||||||
if (refTask.getAttribute ("parent") != "")
|
if (refTask.has ("parent"))
|
||||||
status += " (Recurring)";
|
status += " (Recurring)";
|
||||||
|
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
@@ -597,14 +597,14 @@ std::string handleInfo ()
|
|||||||
table.addCell (row, 0, "Description");
|
table.addCell (row, 0, "Description");
|
||||||
table.addCell (row, 1, description);
|
table.addCell (row, 1, description);
|
||||||
|
|
||||||
if (refTask.getAttribute ("project") != "")
|
if (refTask.has ("project"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Project");
|
table.addCell (row, 0, "Project");
|
||||||
table.addCell (row, 1, refTask.getAttribute ("project"));
|
table.addCell (row, 1, refTask.getAttribute ("project"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refTask.getAttribute ("priority") != "")
|
if (refTask.has ("priority"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Priority");
|
table.addCell (row, 0, "Priority");
|
||||||
@@ -612,30 +612,30 @@ std::string handleInfo ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (refTask.getStatus () == T::recurring ||
|
if (refTask.getStatus () == T::recurring ||
|
||||||
refTask.getAttribute ("parent") != "")
|
refTask.has ("parent"))
|
||||||
{
|
{
|
||||||
if (refTask.getAttribute ("recur") != "")
|
if (refTask.has ("recur"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Recurrence");
|
table.addCell (row, 0, "Recurrence");
|
||||||
table.addCell (row, 1, refTask.getAttribute ("recur"));
|
table.addCell (row, 1, refTask.getAttribute ("recur"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refTask.getAttribute ("until") != "")
|
if (refTask.has ("until"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Recur until");
|
table.addCell (row, 0, "Recur until");
|
||||||
table.addCell (row, 1, refTask.getAttribute ("until"));
|
table.addCell (row, 1, refTask.getAttribute ("until"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refTask.getAttribute ("mask") != "")
|
if (refTask.has ("mask"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Mask");
|
table.addCell (row, 0, "Mask");
|
||||||
table.addCell (row, 1, refTask.getAttribute ("mask"));
|
table.addCell (row, 1, refTask.getAttribute ("mask"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refTask.getAttribute ("parent") != "")
|
if (refTask.has ("parent"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Parent task");
|
table.addCell (row, 0, "Parent task");
|
||||||
@@ -677,7 +677,7 @@ std::string handleInfo ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start
|
// start
|
||||||
if (refTask.getAttribute ("start") != "")
|
if (refTask.has ("start"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "Start");
|
table.addCell (row, 0, "Start");
|
||||||
@@ -686,7 +686,7 @@ std::string handleInfo ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// end
|
// end
|
||||||
if (refTask.getAttribute ("end") != "")
|
if (refTask.has ("end"))
|
||||||
{
|
{
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 0, "End");
|
table.addCell (row, 0, "End");
|
||||||
@@ -1012,7 +1012,7 @@ std::string handleReportNext ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string active;
|
std::string active;
|
||||||
if (refTask.getAttribute ("start") != "")
|
if (refTask.has ("start"))
|
||||||
active = "*";
|
active = "*";
|
||||||
|
|
||||||
std::string age;
|
std::string age;
|
||||||
@@ -1665,7 +1665,7 @@ std::string handleReportTimesheet ()
|
|||||||
{
|
{
|
||||||
// If task started within range, but not completed withing range.
|
// If task started within range, but not completed withing range.
|
||||||
if (t->getStatus () == T::pending &&
|
if (t->getStatus () == T::pending &&
|
||||||
t->getAttribute ("start") != "")
|
t->has ("start"))
|
||||||
{
|
{
|
||||||
Date startDate (::atoi (t->getAttribute ("start").c_str ()));
|
Date startDate (::atoi (t->getAttribute ("start").c_str ()));
|
||||||
if (startDate >= start && startDate < end)
|
if (startDate >= start && startDate < end)
|
||||||
@@ -1909,7 +1909,7 @@ std::string handleReportCalendar ()
|
|||||||
std::vector <T>::iterator it;
|
std::vector <T>::iterator it;
|
||||||
for (it = pending.begin (); it != pending.end (); ++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 ()));
|
Date d (::atoi (it->getAttribute ("due").c_str ()));
|
||||||
|
|
||||||
@@ -2050,7 +2050,7 @@ std::string handleReportActive ()
|
|||||||
for (unsigned int i = 0; i < tasks.size (); ++i)
|
for (unsigned int i = 0; i < tasks.size (); ++i)
|
||||||
{
|
{
|
||||||
T refTask (tasks[i]);
|
T refTask (tasks[i]);
|
||||||
if (refTask.getAttribute ("start") != "")
|
if (refTask.has ("start"))
|
||||||
{
|
{
|
||||||
Date now;
|
Date now;
|
||||||
bool imminent = false;
|
bool imminent = false;
|
||||||
@@ -2177,7 +2177,7 @@ std::string handleReportOverdue ()
|
|||||||
{
|
{
|
||||||
T refTask (tasks[i]);
|
T refTask (tasks[i]);
|
||||||
std::string due;
|
std::string due;
|
||||||
if ((due = refTask.getAttribute ("due")) != "")
|
if ((due = refTask.has ("due")))
|
||||||
{
|
{
|
||||||
if (due.length ())
|
if (due.length ())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user