mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement - add
- Modified Record::get* methods to be const. - Implemented TDB2::add. - Renamed Task::valid to Task::validate. - Implemented Task::setEntry to default creation time. - Fixed bug where TDB2 was opening files "rw" instead of "r+".
This commit is contained in:
parent
8728312da6
commit
7b9cb12308
8 changed files with 70 additions and 55 deletions
|
@ -48,44 +48,36 @@ extern Context context;
|
|||
std::string handleAdd ()
|
||||
{
|
||||
std::stringstream out;
|
||||
/*
|
||||
char entryTime[16];
|
||||
sprintf (entryTime, "%u", (unsigned int) time (NULL));
|
||||
task.setAttribute ("entry", entryTime);
|
||||
|
||||
std::map <std::string, std::string> atts;
|
||||
task.getAttributes (atts);
|
||||
foreach (i, atts)
|
||||
if (i->second == "")
|
||||
task.removeAttribute (i->first);
|
||||
context.task.setEntry ();
|
||||
|
||||
// Recurring tasks get a special status.
|
||||
if (task.getAttribute ("due") != "" &&
|
||||
task.getAttribute ("recur") != "")
|
||||
if (context.task.get ("due") != "" &&
|
||||
context.task.get ("recur") != "")
|
||||
{
|
||||
task.setStatus (T::recurring);
|
||||
task.setAttribute ("mask", "");
|
||||
context.task.setStatus (Task::recurring);
|
||||
context.task.set ("mask", "");
|
||||
}
|
||||
|
||||
// Override with default.project, if not specified.
|
||||
if (task.getAttribute ("project") == "")
|
||||
task.setAttribute ("project", context.config.get ("default.project", ""));
|
||||
if (context.task.get ("project") == "")
|
||||
context.task.set ("project", context.config.get ("default.project", ""));
|
||||
|
||||
// Override with default.priority, if not specified.
|
||||
if (task.getAttribute ("priority") == "")
|
||||
if (context.task.get ("priority") == "")
|
||||
{
|
||||
std::string defaultPriority = context.config.get ("default.priority", "");
|
||||
if (validPriority (defaultPriority))
|
||||
task.setAttribute ("priority", defaultPriority);
|
||||
context.task.set ("priority", defaultPriority);
|
||||
}
|
||||
|
||||
// Disallow blank descriptions.
|
||||
if (task.getDescription () == "")
|
||||
throw std::string ("Cannot add a task that is blank, or contains <CR> or <LF> characters.");
|
||||
// Only valid tasks can be added.
|
||||
context.task.validate ();
|
||||
|
||||
context.tdb.lock (context.config.get ("locking", true));
|
||||
context.tdb.add (context.task);
|
||||
context.tdb.unlock ();
|
||||
|
||||
if (!tdb.addT (task))
|
||||
throw std::string ("Could not create new task.");
|
||||
*/
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue