mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Code Cleanup
- Obsoleted Filter.{h,cpp}. - Obsoleted Sequence.{h,cpp}. - Eliminated Context::autoFilter. - Stubbed Expression::eval.
This commit is contained in:
parent
6b85669812
commit
f971fcd110
28 changed files with 148 additions and 616 deletions
|
@ -17,7 +17,6 @@ set (task_SRCS API.cpp API.h
|
||||||
Duration.cpp Duration.h
|
Duration.cpp Duration.h
|
||||||
Expression.cpp Expression.h
|
Expression.cpp Expression.h
|
||||||
File.cpp File.h
|
File.cpp File.h
|
||||||
Filter.cpp Filter.h
|
|
||||||
Hooks.cpp Hooks.h
|
Hooks.cpp Hooks.h
|
||||||
JSON.cpp JSON.h
|
JSON.cpp JSON.h
|
||||||
Lexer.cpp Lexer.h
|
Lexer.cpp Lexer.h
|
||||||
|
@ -26,7 +25,6 @@ set (task_SRCS API.cpp API.h
|
||||||
Path.cpp Path.h
|
Path.cpp Path.h
|
||||||
Permission.cpp Permission.h
|
Permission.cpp Permission.h
|
||||||
Record.cpp Record.h
|
Record.cpp Record.h
|
||||||
Sequence.cpp Sequence.h
|
|
||||||
TDB.cpp TDB.h
|
TDB.cpp TDB.h
|
||||||
TDB2.cpp TDB2.h
|
TDB2.cpp TDB2.h
|
||||||
Task.cpp Task.h
|
Task.cpp Task.h
|
||||||
|
|
112
src/Context.cpp
112
src/Context.cpp
|
@ -450,118 +450,6 @@ void Context::clear ()
|
||||||
clearMessages ();
|
clearMessages ();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Add all the attributes in the task to the filter. All except uuid.
|
|
||||||
/*
|
|
||||||
void Context::autoFilter (Att& a, Filter& f)
|
|
||||||
{
|
|
||||||
// Words are found in the description using the .has modifier.
|
|
||||||
if (a.name () == "description" && a.mod () == "")
|
|
||||||
{
|
|
||||||
std::vector <std::string> words;
|
|
||||||
split (words, a.value (), ' ');
|
|
||||||
std::vector <std::string>::iterator word;
|
|
||||||
for (word = words.begin (); word != words.end (); ++word)
|
|
||||||
{
|
|
||||||
f.push_back (Att ("description", "has", *word));
|
|
||||||
debug ("auto filter: " + a.name () + ".has:" + *word);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Projects are matched left-most.
|
|
||||||
else if (a.name () == "project" && (a.mod () == "" || a.mod () == "not"))
|
|
||||||
{
|
|
||||||
if (a.value () != "")
|
|
||||||
{
|
|
||||||
if (a.mod () == "not")
|
|
||||||
{
|
|
||||||
f.push_back (Att ("project", "startswith", a.value (), "negative"));
|
|
||||||
debug ("auto filter: " + a.name () + ".~startswith:" + a.value ());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f.push_back (Att ("project", "startswith", a.value ()));
|
|
||||||
debug ("auto filter: " + a.name () + ".startswith:" + a.value ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f.push_back (Att ("project", "is", a.value ()));
|
|
||||||
debug ("auto filter: " + a.name () + ".is:" + a.value ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recurrence periods are matched left-most.
|
|
||||||
else if (a.name () == "recur" && a.mod () == "")
|
|
||||||
{
|
|
||||||
if (a.value () != "")
|
|
||||||
{
|
|
||||||
f.push_back (Att ("recur", "startswith", a.value ()));
|
|
||||||
debug ("auto filter: " + a.name () + ".startswith:" + a.value ());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f.push_back (Att ("recur", "is", a.value ()));
|
|
||||||
debug ("auto filter: " + a.name () + ".is:" + a.value ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The limit attribute does not participate in filtering, and needs to be
|
|
||||||
// specifically handled in handleCustomReport.
|
|
||||||
else if (a.name () == "limit")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Every task has a unique uuid by default, and it shouldn't be included,
|
|
||||||
// because it is guaranteed to not match.
|
|
||||||
else if (a.name () == "uuid")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: Tags are handled via the +/-<tag> syntax, but also via attribute
|
|
||||||
// modifiers.
|
|
||||||
|
|
||||||
// Generic attribute matching.
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f.push_back (a);
|
|
||||||
debug ("auto filter: " +
|
|
||||||
a.name () +
|
|
||||||
(a.mod () != "" ?
|
|
||||||
("." + a.mod () + ":") :
|
|
||||||
":") +
|
|
||||||
a.value ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Add all the tags in the task to the filter.
|
|
||||||
/*
|
|
||||||
void Context::autoFilter (Filter& f)
|
|
||||||
{
|
|
||||||
// This is now a correct implementation of a filter on the presence or absence
|
|
||||||
// of a tag. The prior code provided the illusion of leftmost partial tag
|
|
||||||
// matches, but was really using the 'contains' and 'nocontains' attribute
|
|
||||||
// modifiers. See bug #293.
|
|
||||||
|
|
||||||
// Include tagAdditions.
|
|
||||||
std::vector <std::string>::iterator tag;
|
|
||||||
for (tag = tagAdditions.begin (); tag != tagAdditions.end (); ++tag)
|
|
||||||
{
|
|
||||||
f.push_back (Att ("tags", "word", *tag));
|
|
||||||
debug ("auto filter: +" + *tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Include tagRemovals.
|
|
||||||
for (tag = tagRemovals.begin (); tag != tagRemovals.end (); ++tag)
|
|
||||||
{
|
|
||||||
f.push_back (Att ("tags", "noword", *tag));
|
|
||||||
debug ("auto filter: -" + *tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// This capability is to answer the question of 'what did I just do to generate
|
// This capability is to answer the question of 'what did I just do to generate
|
||||||
// this output?'.
|
// this output?'.
|
||||||
|
|
|
@ -30,9 +30,7 @@
|
||||||
|
|
||||||
#include <Command.h>
|
#include <Command.h>
|
||||||
#include <Column.h>
|
#include <Column.h>
|
||||||
#include <Filter.h>
|
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <Sequence.h>
|
|
||||||
#include <Task.h>
|
#include <Task.h>
|
||||||
#include <TDB.h>
|
#include <TDB.h>
|
||||||
#include <TDB2.h>
|
#include <TDB2.h>
|
||||||
|
@ -77,8 +75,6 @@ private:
|
||||||
void determineDataLocation ();
|
void determineDataLocation ();
|
||||||
void createDefaultConfig ();
|
void createDefaultConfig ();
|
||||||
void loadAliases ();
|
void loadAliases ();
|
||||||
// void autoFilter (Att&, Filter&);
|
|
||||||
// void autoFilter (Filter&);
|
|
||||||
void updateXtermTitle ();
|
void updateXtermTitle ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -52,17 +52,12 @@ Expression::Expression (Arguments& arguments)
|
||||||
context.debug ("Filter --> old");
|
context.debug ("Filter --> old");
|
||||||
|
|
||||||
expand_sequence ();
|
expand_sequence ();
|
||||||
|
|
||||||
if (new_style)
|
|
||||||
{
|
|
||||||
implicit_and ();
|
implicit_and ();
|
||||||
expand_tag ();
|
expand_tag ();
|
||||||
expand_pattern ();
|
expand_pattern ();
|
||||||
expand_attr ();
|
expand_attr ();
|
||||||
expand_attmod ();
|
expand_attmod ();
|
||||||
expand_word ();
|
expand_word ();
|
||||||
}
|
|
||||||
|
|
||||||
expand_tokens ();
|
expand_tokens ();
|
||||||
postfix ();
|
postfix ();
|
||||||
}
|
}
|
||||||
|
@ -82,24 +77,111 @@ bool Expression::eval (Task& task)
|
||||||
{
|
{
|
||||||
if (arg->second == "op")
|
if (arg->second == "op")
|
||||||
{
|
{
|
||||||
|
// We already know it's an operator, but we need to know more. Or do we?
|
||||||
|
/*
|
||||||
char type;
|
char type;
|
||||||
int precedence;
|
int precedence;
|
||||||
char associativity;
|
char associativity;
|
||||||
Arguments::is_operator (arg->first, type, precedence, associativity);
|
Arguments::is_operator (arg->first, type, precedence, associativity);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO Need helpers that pop, and error out if necessary.
|
||||||
if (arg->first == "+")
|
if (arg->first == "+")
|
||||||
{
|
{
|
||||||
// TODO pop
|
// TODO This needs to be type-aware.
|
||||||
// TODO pop
|
Variant right (value_stack.back ());
|
||||||
// TODO add the operators
|
value_stack.pop_back ();
|
||||||
// TODO push the result
|
Variant left (value_stack.back ());
|
||||||
|
value_stack.pop_back ();
|
||||||
|
|
||||||
|
left = left + right;
|
||||||
|
|
||||||
|
value_stack.push_back (left);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
else if (arg->first == "and")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "xor")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "or")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "<=")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == ">=")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "!~")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "!=")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "=")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "^")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == ">")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "~")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "!")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "*")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "/")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "%")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "+")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "-")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "<")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == "(")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (arg->first == ")")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
throw std::string ("Unsupported operator '") + arg->first + "'.";
|
throw std::string ("Unsupported operator '") + arg->first + "'.";
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
else
|
else
|
||||||
|
@ -107,6 +189,7 @@ bool Expression::eval (Task& task)
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Any more values on stack? Error.
|
||||||
// TODO Return the value that is on the stack.
|
// TODO Return the value that is on the stack.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
155
src/Filter.cpp
155
src/Filter.cpp
|
@ -1,155 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// taskwarrior - a command line task list manager.
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU General Public License as published by the Free Software
|
|
||||||
// Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
// version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
// details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License along with
|
|
||||||
// this program; if not, write to the
|
|
||||||
//
|
|
||||||
// Free Software Foundation, Inc.,
|
|
||||||
// 51 Franklin Street, Fifth Floor,
|
|
||||||
// Boston, MA
|
|
||||||
// 02110-1301
|
|
||||||
// USA
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <Filter.h>
|
|
||||||
#include <util.h>
|
|
||||||
#include <main.h>
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// For every Att in the filter, lookup the equivalent in Record, and perform a
|
|
||||||
// match. Aren't filters easy now that everything is an attribute?
|
|
||||||
bool Filter::pass (const Record& record) const
|
|
||||||
{
|
|
||||||
Record::const_iterator r;
|
|
||||||
|
|
||||||
// First do description/annotation matches.
|
|
||||||
foreach (att, (*this))
|
|
||||||
{
|
|
||||||
// Descriptions have special handling such that they are linked to
|
|
||||||
// annotations, and filtering on description implies identical filtering
|
|
||||||
// on annotations.
|
|
||||||
//
|
|
||||||
// For positive modifiers (has, is ...) either the description or the
|
|
||||||
// annotation filter must succeed.
|
|
||||||
//
|
|
||||||
// For negative modifiers (hasnt, isnt ...) both the description and the
|
|
||||||
// annotation filter must succeed.
|
|
||||||
if (att->name () == "description")
|
|
||||||
{
|
|
||||||
bool pass = true;
|
|
||||||
int annotation_pass_count = 0;
|
|
||||||
int annotation_fail_count = 0;
|
|
||||||
|
|
||||||
if ((r = record.find (att->name ())) != record.end ())
|
|
||||||
{
|
|
||||||
pass = att->match (r->second);
|
|
||||||
|
|
||||||
foreach (ra, record)
|
|
||||||
{
|
|
||||||
if (ra->first.length () > 11 &&
|
|
||||||
ra->first.substr (0, 11) == "annotation_")
|
|
||||||
{
|
|
||||||
if (att->match (ra->second))
|
|
||||||
++annotation_pass_count;
|
|
||||||
else
|
|
||||||
++annotation_fail_count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Missing attribute implies failure.
|
|
||||||
else if (! att->match (Att ()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// This innocuous little if-else took significantly more thinking and
|
|
||||||
// debugging than anything else in task. Only change this code if you
|
|
||||||
// are willing to invest a week understanding and testing it.
|
|
||||||
if (att->modType (att->mod ()) == "positive")
|
|
||||||
{
|
|
||||||
if (! att->logicSense (pass || annotation_pass_count))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (! att->logicSense (pass && annotation_fail_count == 0))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Annotations are skipped, because they are handled above.
|
|
||||||
else if (att->name ().length () > 11 &&
|
|
||||||
att->name ().substr (0, 11) == "annotation_")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// An individual attribute match failure is enough to fail the filter.
|
|
||||||
if ((r = record.find (att->name ())) != record.end ())
|
|
||||||
{
|
|
||||||
if (! att->logicSense (att->match (r->second)))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (! att->match (Att ()))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Filter::applySequence (std::vector<Task>& all, Sequence& sequence)
|
|
||||||
{
|
|
||||||
std::vector <Task> filtered;
|
|
||||||
foreach (task, all)
|
|
||||||
foreach (i, sequence)
|
|
||||||
if (task->id == *i)
|
|
||||||
filtered.push_back (*task);
|
|
||||||
|
|
||||||
if (sequence.size () != filtered.size ())
|
|
||||||
{
|
|
||||||
std::vector <int> filteredSequence;
|
|
||||||
foreach (task, filtered)
|
|
||||||
filteredSequence.push_back (task->id);
|
|
||||||
|
|
||||||
std::vector <int> left;
|
|
||||||
std::vector <int> right;
|
|
||||||
listDiff (filteredSequence, (std::vector <int>&)sequence, left, right);
|
|
||||||
if (left.size ())
|
|
||||||
throw std::string ("Sequence filtering error - please report this error to support@taskwarrior.org.");
|
|
||||||
|
|
||||||
if (right.size ())
|
|
||||||
{
|
|
||||||
std::stringstream out;
|
|
||||||
out << "Task";
|
|
||||||
|
|
||||||
if (right.size () > 1) out << "s";
|
|
||||||
|
|
||||||
foreach (r, right)
|
|
||||||
out << " " << *r;
|
|
||||||
|
|
||||||
out << " not found.";
|
|
||||||
throw out.str ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
all = filtered;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
44
src/Filter.h
44
src/Filter.h
|
@ -1,44 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// taskwarrior - a command line task list manager.
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU General Public License as published by the Free Software
|
|
||||||
// Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
// version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
// details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License along with
|
|
||||||
// this program; if not, write to the
|
|
||||||
//
|
|
||||||
// Free Software Foundation, Inc.,
|
|
||||||
// 51 Franklin Street, Fifth Floor,
|
|
||||||
// Boston, MA
|
|
||||||
// 02110-1301
|
|
||||||
// USA
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef INCLUDED_FILTER
|
|
||||||
#define INCLUDED_FILTER
|
|
||||||
#define L10N // Localization complete.
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <Att.h>
|
|
||||||
#include <Task.h>
|
|
||||||
#include <Record.h>
|
|
||||||
|
|
||||||
class Filter : public std::vector <Att>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool pass (const Record&) const;
|
|
||||||
void applySequence (std::vector<Task>&, Sequence&);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
161
src/Sequence.cpp
161
src/Sequence.cpp
|
@ -1,161 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// taskwarrior - a command line task list manager.
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU General Public License as published by the Free Software
|
|
||||||
// Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
// version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
// details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License along with
|
|
||||||
// this program; if not, write to the
|
|
||||||
//
|
|
||||||
// Free Software Foundation, Inc.,
|
|
||||||
// 51 Franklin Street, Fifth Floor,
|
|
||||||
// Boston, MA
|
|
||||||
// 02110-1301
|
|
||||||
// USA
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <text.h>
|
|
||||||
#include <Context.h>
|
|
||||||
#include <Sequence.h>
|
|
||||||
|
|
||||||
extern Context context;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Sequence::Sequence ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Sequence::Sequence (const std::string& input)
|
|
||||||
{
|
|
||||||
parse (input);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
Sequence::~Sequence ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool Sequence::valid (const std::string& input) const
|
|
||||||
{
|
|
||||||
std::vector <std::string> ranges;
|
|
||||||
split (ranges, input, ',');
|
|
||||||
|
|
||||||
std::vector <std::string>::iterator it;
|
|
||||||
for (it = ranges.begin (); it != ranges.end (); ++it)
|
|
||||||
{
|
|
||||||
std::vector <std::string> range;
|
|
||||||
split (range, *it, '-');
|
|
||||||
|
|
||||||
if (range.size () < 1 ||
|
|
||||||
range.size () > 2)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (range.size () <= 2 && !validId (range[0]))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (range.size () == 2 && !validId (range[1]))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Sequence::parse (const std::string& input)
|
|
||||||
{
|
|
||||||
std::vector <std::string> ranges;
|
|
||||||
split (ranges, input, ',');
|
|
||||||
|
|
||||||
std::vector <std::string>::iterator it;
|
|
||||||
for (it = ranges.begin (); it != ranges.end (); ++it)
|
|
||||||
{
|
|
||||||
std::vector <std::string> range;
|
|
||||||
split (range, *it, '-');
|
|
||||||
|
|
||||||
switch (range.size ())
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
if (! validId (range[0]))
|
|
||||||
throw std::string ("Invalid ID in sequence.");
|
|
||||||
|
|
||||||
int id = strtol (range[0].c_str (), NULL, 10);
|
|
||||||
this->push_back (id);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
if (! validId (range[0]) ||
|
|
||||||
! validId (range[1]))
|
|
||||||
throw std::string ("Invalid ID in range.");
|
|
||||||
|
|
||||||
int low = strtol (range[0].c_str (), NULL, 10);
|
|
||||||
int high = strtol (range[1].c_str (), NULL, 10);
|
|
||||||
if (low > high)
|
|
||||||
throw std::string ("Inverted sequence range high-low.");
|
|
||||||
|
|
||||||
if (high - low >= SEQUENCE_MAX)
|
|
||||||
throw std::string ("ID Range too large.");
|
|
||||||
|
|
||||||
for (int i = low; i <= high; ++i)
|
|
||||||
this->push_back (i);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw std::string ("Not a sequence.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
void Sequence::combine (const Sequence& other)
|
|
||||||
{
|
|
||||||
// Create a map using the sequence elements as keys. This will create a
|
|
||||||
// unique list, with no duplicates.
|
|
||||||
std::map <int, int> both;
|
|
||||||
std::vector <int>::iterator i1;
|
|
||||||
for (i1 = this->begin (); i1 != this->end (); ++i1) both[*i1] = 0;
|
|
||||||
|
|
||||||
std::vector <int>::const_iterator i2;
|
|
||||||
for (i2 = other.begin (); i2 != other.end (); ++i2) both[*i2] = 0;
|
|
||||||
|
|
||||||
// Now make a sequence out of the keys of the map.
|
|
||||||
this->clear ();
|
|
||||||
std::map <int, int>::iterator i3;
|
|
||||||
for (i3 = both.begin (); i3 != both.end (); ++i3)
|
|
||||||
this->push_back (i3->first);
|
|
||||||
|
|
||||||
std::sort (this->begin (), this->end ());
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool Sequence::validId (const std::string& input) const
|
|
||||||
{
|
|
||||||
if (input.length () == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return digitsOnly (input);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
|
@ -1,52 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// taskwarrior - a command line task list manager.
|
|
||||||
//
|
|
||||||
// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or modify it under
|
|
||||||
// the terms of the GNU General Public License as published by the Free Software
|
|
||||||
// Foundation; either version 2 of the License, or (at your option) any later
|
|
||||||
// version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
||||||
// details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License along with
|
|
||||||
// this program; if not, write to the
|
|
||||||
//
|
|
||||||
// Free Software Foundation, Inc.,
|
|
||||||
// 51 Franklin Street, Fifth Floor,
|
|
||||||
// Boston, MA
|
|
||||||
// 02110-1301
|
|
||||||
// USA
|
|
||||||
//
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef INCLUDED_SEQUENCE
|
|
||||||
#define INCLUDED_SEQUENCE
|
|
||||||
#define L10N // Localization complete.
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#define SEQUENCE_MAX 1000
|
|
||||||
|
|
||||||
class Sequence : public std::vector <int>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Sequence (); // Default constructor
|
|
||||||
Sequence (const std::string&); // Parse
|
|
||||||
~Sequence (); // Destructor
|
|
||||||
|
|
||||||
bool valid (const std::string&) const;
|
|
||||||
void parse (const std::string&);
|
|
||||||
void combine (const Sequence&);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool validId (const std::string&) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
24
src/TDB.cpp
24
src/TDB.cpp
|
@ -124,9 +124,8 @@ void readTaskmods (std::vector <std::string> &input,
|
||||||
// | | open
|
// | | open
|
||||||
// | | [lock]
|
// | | [lock]
|
||||||
// | |
|
// | |
|
||||||
// | | +- TDB::load (Filter)
|
// | | +- TDB::load
|
||||||
// | | | read all
|
// | | | read all
|
||||||
// | | | apply filter
|
|
||||||
// | | | return subset
|
// | | | return subset
|
||||||
// | | |
|
// | | |
|
||||||
// | | +- TDB::add (T)
|
// | | +- TDB::add (T)
|
||||||
|
@ -238,12 +237,13 @@ void TDB::unlock ()
|
||||||
// Returns number of filtered tasks.
|
// Returns number of filtered tasks.
|
||||||
// Note: tasks.clear () is deliberately not called, to allow the combination of
|
// Note: tasks.clear () is deliberately not called, to allow the combination of
|
||||||
// multiple files.
|
// multiple files.
|
||||||
int TDB::load (std::vector <Task>& tasks, Filter& filter)
|
int TDB::load (std::vector <Task>& tasks)
|
||||||
{
|
{
|
||||||
// Special optimization: if the filter contains Att ('status', '', 'pending'),
|
// Special optimization: if the filter contains Att ('status', '', 'pending'),
|
||||||
// and no other 'status' filters, then loadCompleted can be skipped.
|
// and no other 'status' filters, then loadCompleted can be skipped.
|
||||||
int numberStatusClauses = 0;
|
int numberStatusClauses = 0;
|
||||||
int numberSimpleStatusClauses = 0;
|
int numberSimpleStatusClauses = 0;
|
||||||
|
/*
|
||||||
foreach (att, filter)
|
foreach (att, filter)
|
||||||
{
|
{
|
||||||
if (att->name () == "status")
|
if (att->name () == "status")
|
||||||
|
@ -256,12 +256,13 @@ int TDB::load (std::vector <Task>& tasks, Filter& filter)
|
||||||
++numberSimpleStatusClauses;
|
++numberSimpleStatusClauses;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
loadPending (tasks, filter);
|
loadPending (tasks);
|
||||||
|
|
||||||
if (numberStatusClauses == 0 ||
|
if (numberStatusClauses == 0 ||
|
||||||
numberStatusClauses != numberSimpleStatusClauses)
|
numberStatusClauses != numberSimpleStatusClauses)
|
||||||
loadCompleted (tasks, filter);
|
loadCompleted (tasks);
|
||||||
else
|
else
|
||||||
context.debug ("load optimization short circuit");
|
context.debug ("load optimization short circuit");
|
||||||
|
|
||||||
|
@ -272,7 +273,7 @@ int TDB::load (std::vector <Task>& tasks, Filter& filter)
|
||||||
// Returns number of filtered tasks.
|
// Returns number of filtered tasks.
|
||||||
// Note: tasks.clear () is deliberately not called, to allow the combination of
|
// Note: tasks.clear () is deliberately not called, to allow the combination of
|
||||||
// multiple files.
|
// multiple files.
|
||||||
int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
|
int TDB::loadPending (std::vector <Task>& tasks)
|
||||||
{
|
{
|
||||||
Timer t ("TDB::loadPending");
|
Timer t ("TDB::loadPending");
|
||||||
|
|
||||||
|
@ -316,6 +317,7 @@ int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now filter and return.
|
// Now filter and return.
|
||||||
|
/*
|
||||||
if (filter.size ())
|
if (filter.size ())
|
||||||
{
|
{
|
||||||
foreach (task, mPending)
|
foreach (task, mPending)
|
||||||
|
@ -323,6 +325,7 @@ int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
|
||||||
tasks.push_back (*task);
|
tasks.push_back (*task);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
foreach (task, mPending)
|
foreach (task, mPending)
|
||||||
tasks.push_back (*task);
|
tasks.push_back (*task);
|
||||||
|
@ -331,6 +334,7 @@ int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
|
||||||
// Hand back any accumulated additions, if TDB::loadPending is being called
|
// Hand back any accumulated additions, if TDB::loadPending is being called
|
||||||
// repeatedly.
|
// repeatedly.
|
||||||
int fakeId = mId;
|
int fakeId = mId;
|
||||||
|
/*
|
||||||
if (filter.size ())
|
if (filter.size ())
|
||||||
{
|
{
|
||||||
foreach (task, mNew)
|
foreach (task, mNew)
|
||||||
|
@ -341,6 +345,7 @@ int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
foreach (task, mNew)
|
foreach (task, mNew)
|
||||||
{
|
{
|
||||||
|
@ -364,7 +369,7 @@ int TDB::loadPending (std::vector <Task>& tasks, Filter& filter)
|
||||||
// Returns number of filtered tasks.
|
// Returns number of filtered tasks.
|
||||||
// Note: tasks.clear () is deliberately not called, to allow the combination of
|
// Note: tasks.clear () is deliberately not called, to allow the combination of
|
||||||
// multiple files.
|
// multiple files.
|
||||||
int TDB::loadCompleted (std::vector <Task>& tasks, Filter& filter)
|
int TDB::loadCompleted (std::vector <Task>& tasks)
|
||||||
{
|
{
|
||||||
Timer t ("TDB::loadCompleted");
|
Timer t ("TDB::loadCompleted");
|
||||||
|
|
||||||
|
@ -401,6 +406,7 @@ int TDB::loadCompleted (std::vector <Task>& tasks, Filter& filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now filter and return.
|
// Now filter and return.
|
||||||
|
/*
|
||||||
if (filter.size ())
|
if (filter.size ())
|
||||||
{
|
{
|
||||||
foreach (task, mCompleted)
|
foreach (task, mCompleted)
|
||||||
|
@ -408,6 +414,7 @@ int TDB::loadCompleted (std::vector <Task>& tasks, Filter& filter)
|
||||||
tasks.push_back (*task);
|
tasks.push_back (*task);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
foreach (task, mCompleted)
|
foreach (task, mCompleted)
|
||||||
tasks.push_back (*task);
|
tasks.push_back (*task);
|
||||||
|
@ -599,9 +606,8 @@ int TDB::gc ()
|
||||||
|
|
||||||
lock ();
|
lock ();
|
||||||
|
|
||||||
Filter filter;
|
|
||||||
std::vector <Task> ignore;
|
std::vector <Task> ignore;
|
||||||
loadPending (ignore, filter);
|
loadPending (ignore);
|
||||||
|
|
||||||
// Search for dangling dependencies. These are dependencies whose uuid cannot
|
// Search for dangling dependencies. These are dependencies whose uuid cannot
|
||||||
// be converted to an id by TDB.
|
// be converted to an id by TDB.
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Location.h>
|
#include <Location.h>
|
||||||
#include <Filter.h>
|
|
||||||
#include <Task.h>
|
#include <Task.h>
|
||||||
|
|
||||||
// Length of longest line.
|
// Length of longest line.
|
||||||
|
@ -53,9 +52,9 @@ public:
|
||||||
void lock (bool lockFile = true);
|
void lock (bool lockFile = true);
|
||||||
void unlock ();
|
void unlock ();
|
||||||
|
|
||||||
int load (std::vector <Task>&, Filter&);
|
int load (std::vector <Task>&);
|
||||||
int loadPending (std::vector <Task>&, Filter&);
|
int loadPending (std::vector <Task>&);
|
||||||
int loadCompleted (std::vector <Task>&, Filter&);
|
int loadCompleted (std::vector <Task>&);
|
||||||
|
|
||||||
const std::vector <Task>& getAllPending ();
|
const std::vector <Task>& getAllPending ();
|
||||||
const std::vector <Task>& getAllNew ();
|
const std::vector <Task>& getAllNew ();
|
||||||
|
|
|
@ -368,7 +368,7 @@ void readTaskmods (std::vector <std::string> &input,
|
||||||
// | | open
|
// | | open
|
||||||
// | | [lock]
|
// | | [lock]
|
||||||
// | |
|
// | |
|
||||||
// | | +- TDB::load (Filter)
|
// | | +- TDB::load
|
||||||
// | | | read all
|
// | | | read all
|
||||||
// | | | apply filter
|
// | | | apply filter
|
||||||
// | | | return subset
|
// | | | return subset
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <Record.h>
|
#include <Record.h>
|
||||||
#include <Sequence.h>
|
|
||||||
|
|
||||||
class Task : public Record
|
class Task : public Record
|
||||||
{
|
{
|
||||||
|
|
|
@ -343,13 +343,12 @@ Variant& Variant::operator- (const Variant& other)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_date:
|
case v_date:
|
||||||
// TODO operator-= only takes integers.
|
mDuration = Duration (mDate - other.mDate);
|
||||||
//mDate -= other.mDate;
|
mType = v_duration;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_duration:
|
case v_duration:
|
||||||
// TODO Missing operator -=
|
mDuration = mDuration - other.mDuration;
|
||||||
//mDuration -= other.mDuration;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case v_unknown:
|
case v_unknown:
|
||||||
|
|
|
@ -987,8 +987,7 @@ int CmdBurndownMonthly::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
@ -1038,8 +1037,7 @@ int CmdBurndownWeekly::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
@ -1089,8 +1087,7 @@ int CmdBurndownDaily::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -65,10 +65,9 @@ int CmdCalendar::execute (std::string& output)
|
||||||
|
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
Filter filter;
|
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.loadPending (tasks, filter);
|
context.tdb.loadPending (tasks);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,7 @@ int CmdCustom::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter; // Blank
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter); // No filter.
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,7 @@ int CmdHistoryMonthly::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
@ -225,8 +224,7 @@ int CmdHistoryAnnual::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
@ -388,8 +386,7 @@ int CmdGHistoryMonthly::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
@ -594,8 +591,7 @@ int CmdGHistoryAnnual::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,7 @@ int CmdIDs::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
@ -93,8 +92,7 @@ int CmdCompletionIds::execute (std::string& output)
|
||||||
{
|
{
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
Filter filter;
|
context.tdb.loadPending (tasks);
|
||||||
context.tdb.loadPending (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
@ -140,8 +138,7 @@ int CmdZshCompletionIds::execute (std::string& output)
|
||||||
{
|
{
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
Filter filter;
|
context.tdb.loadPending (tasks);
|
||||||
context.tdb.loadPending (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -1178,8 +1178,7 @@ std::string CmdImport::YAML (const std::vector <std::string>& lines)
|
||||||
|
|
||||||
// Load all the tasks so that the uuid uniqueness can be checked.
|
// Load all the tasks so that the uuid uniqueness can be checked.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
|
|
||||||
Task t;
|
Task t;
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.loadPending (tasks);
|
||||||
context.tdb.loadPending (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,7 @@ int CmdQuery::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,7 @@ int CmdStatistics::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,7 @@ int CmdSummary::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,10 @@ int CmdTags::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
int quantity = 0;
|
int quantity = 0;
|
||||||
Filter filter;
|
|
||||||
if (context.config.getBoolean ("list.all.tags"))
|
if (context.config.getBoolean ("list.all.tags"))
|
||||||
quantity += context.tdb.load (tasks, filter);
|
quantity += context.tdb.load (tasks);
|
||||||
else
|
else
|
||||||
quantity += context.tdb.loadPending (tasks, filter);
|
quantity += context.tdb.loadPending (tasks);
|
||||||
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
@ -147,11 +146,10 @@ int CmdCompletionTags::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
|
|
||||||
Filter filter;
|
|
||||||
if (context.config.getBoolean ("complete.all.tags"))
|
if (context.config.getBoolean ("complete.all.tags"))
|
||||||
context.tdb.load (tasks, filter);
|
context.tdb.load (tasks);
|
||||||
else
|
else
|
||||||
context.tdb.loadPending (tasks, filter);
|
context.tdb.loadPending (tasks);
|
||||||
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
|
@ -55,8 +55,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.load (tasks);
|
||||||
context.tdb.load (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,7 @@ int CmdUrgency::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
Filter filter;
|
context.tdb.loadPending (tasks);
|
||||||
context.tdb.loadPending (tasks, filter);
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
|
|
@ -133,8 +133,7 @@ std::string onProjectChange (Task& task, bool scope /* = true */)
|
||||||
int count_done = 0;
|
int count_done = 0;
|
||||||
|
|
||||||
std::vector <Task> all;
|
std::vector <Task> all;
|
||||||
Filter filter;
|
context.tdb.load (all);
|
||||||
context.tdb.load (all, filter);
|
|
||||||
|
|
||||||
countTasks (all, project, context.tdb.getAllModified (), count_pending, count_done);
|
countTasks (all, project, context.tdb.getAllModified (), count_pending, count_done);
|
||||||
countTasks (context.tdb.getAllModified (), project, (std::vector <Task>) NULL, count_pending, count_done);
|
countTasks (context.tdb.getAllModified (), project, (std::vector <Task>) NULL, count_pending, count_done);
|
||||||
|
|
|
@ -53,8 +53,7 @@ extern Context context;
|
||||||
void handleRecurrence ()
|
void handleRecurrence ()
|
||||||
{
|
{
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
Filter filter;
|
context.tdb.loadPending (tasks);
|
||||||
context.tdb.loadPending (tasks, filter);
|
|
||||||
|
|
||||||
std::vector <Task> modified;
|
std::vector <Task> modified;
|
||||||
|
|
||||||
|
@ -441,10 +440,9 @@ bool nag (Task& task)
|
||||||
{
|
{
|
||||||
// Load all pending tasks.
|
// Load all pending tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
Filter filter;
|
|
||||||
|
|
||||||
// Piggy-back on existing locked TDB.
|
// Piggy-back on existing locked TDB.
|
||||||
context.tdb.loadPending (tasks, filter);
|
context.tdb.loadPending (tasks);
|
||||||
|
|
||||||
// Counters.
|
// Counters.
|
||||||
int overdue = 0;
|
int overdue = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue