mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Silver Bullet - Snapshot
- until working - due working - Also allows editing of recurring parent tasks
This commit is contained in:
parent
38907ac6d7
commit
f97955ded8
1 changed files with 46 additions and 25 deletions
71
src/edit.cpp
71
src/edit.cpp
|
@ -67,14 +67,17 @@ static std::string findDate (
|
||||||
std::string::size_type eol = text.find ("\n", found);
|
std::string::size_type eol = text.find ("\n", found);
|
||||||
if (eol != std::string::npos)
|
if (eol != std::string::npos)
|
||||||
{
|
{
|
||||||
std::string value = text.substr (
|
std::string value = trim (text.substr (
|
||||||
found + name.length (),
|
found + name.length (),
|
||||||
eol - (found + name.length ()));
|
eol - (found + name.length ())), "\t ");
|
||||||
|
|
||||||
Date dt (trim (value, "\t "), conf.get ("dateformat", "m/d/Y"));
|
if (value != "")
|
||||||
char epoch [16];
|
{
|
||||||
sprintf (epoch, "%d", (int)dt.toEpoch ());
|
Date dt (value, conf.get ("dateformat", "m/d/Y"));
|
||||||
return std::string (epoch);
|
char epoch [16];
|
||||||
|
sprintf (epoch, "%d", (int)dt.toEpoch ());
|
||||||
|
return std::string (epoch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,14 +303,21 @@ static void parseTask (Config& conf, T& task, const std::string& after)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// due
|
// due
|
||||||
/*
|
|
||||||
value = findDate (conf, after, "Due:");
|
value = findDate (conf, after, "Due:");
|
||||||
if (value != "")
|
if (value != "")
|
||||||
{
|
{
|
||||||
Date original (::atoi (task.getAttribute ("due").c_str ()));
|
|
||||||
Date edited (::atoi (value.c_str ()));
|
Date edited (::atoi (value.c_str ()));
|
||||||
|
|
||||||
if (!original.sameDay (edited))
|
if (task.getAttribute ("due") != "")
|
||||||
|
{
|
||||||
|
Date original (::atoi (task.getAttribute ("due").c_str ()));
|
||||||
|
if (!original.sameDay (edited))
|
||||||
|
{
|
||||||
|
std::cout << "Due date modified." << std::endl;
|
||||||
|
task.setAttribute ("due", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Due date modified." << std::endl;
|
std::cout << "Due date modified." << std::endl;
|
||||||
task.setAttribute ("due", value);
|
task.setAttribute ("due", value);
|
||||||
|
@ -315,28 +325,37 @@ static void parseTask (Config& conf, T& task, const std::string& after)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (task.getStatus () == T::recurring ||
|
if (task.getAttribute ("due") != "")
|
||||||
task.getAttribute ("parent") != "")
|
|
||||||
{
|
{
|
||||||
std::cout << "Cannot remove a due date from a recurring task." << std::endl;
|
if (task.getStatus () == T::recurring ||
|
||||||
}
|
task.getAttribute ("parent") != "")
|
||||||
else
|
{
|
||||||
{
|
std::cout << "Cannot remove a due date from a recurring task." << std::endl;
|
||||||
std::cout << "Due date removed." << std::endl;
|
}
|
||||||
task.removeAttribute ("due");
|
else
|
||||||
|
{
|
||||||
|
std::cout << "Due date removed." << std::endl;
|
||||||
|
task.removeAttribute ("due");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// until
|
// until
|
||||||
/*
|
|
||||||
value = findDate (conf, after, "Until:");
|
value = findDate (conf, after, "Until:");
|
||||||
if (value != "")
|
if (value != "")
|
||||||
{
|
{
|
||||||
Date original (::atoi (task.getAttribute ("until").c_str ()));
|
|
||||||
Date edited (::atoi (value.c_str ()));
|
Date edited (::atoi (value.c_str ()));
|
||||||
|
|
||||||
if (!original.sameDay (edited))
|
if (task.getAttribute ("until") != "")
|
||||||
|
{
|
||||||
|
Date original (::atoi (task.getAttribute ("until").c_str ()));
|
||||||
|
if (!original.sameDay (edited))
|
||||||
|
{
|
||||||
|
std::cout << "Until date modified." << std::endl;
|
||||||
|
task.setAttribute ("until", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Until date modified." << std::endl;
|
std::cout << "Until date modified." << std::endl;
|
||||||
task.setAttribute ("until", value);
|
task.setAttribute ("until", value);
|
||||||
|
@ -344,10 +363,12 @@ static void parseTask (Config& conf, T& task, const std::string& after)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Until date removed." << std::endl;
|
if (task.getAttribute ("until") != "")
|
||||||
task.removeAttribute ("until");
|
{
|
||||||
|
std::cout << "Until date removed." << std::endl;
|
||||||
|
task.removeAttribute ("until");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// recur
|
// recur
|
||||||
value = findValue (after, "Recur:");
|
value = findValue (after, "Recur:");
|
||||||
|
@ -459,7 +480,7 @@ std::string handleEdit (TDB& tdb, T& task, Config& conf)
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
std::vector <T> all;
|
std::vector <T> all;
|
||||||
tdb.pendingT (all);
|
tdb.allPendingT (all);
|
||||||
|
|
||||||
filterSequence (all, task);
|
filterSequence (all, task);
|
||||||
foreach (seq, all)
|
foreach (seq, all)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue