Meta specifications where not reported into search

This commit is contained in:
Grégory Soutadé 2010-10-25 21:33:09 +02:00
parent 1c4662a01c
commit 6568acbae7
3 changed files with 30 additions and 9 deletions

View File

@ -1229,7 +1229,8 @@ std::vector<Operation>* Database::Search(User* user, wxString* description, wxDa
std::vector<wxString>::iterator it;
std::vector<Account>::iterator accountIt;
std::vector<Operation>* res = new std::vector<Operation>;
int i;
wxString dayFrom, monthFrom, yearFrom;
wxString dayTo, monthTo, yearTo;
wxString desc;
@ -1311,19 +1312,20 @@ std::vector<Operation>* Database::Search(User* user, wxString* description, wxDa
if (accounts.size())
{
req += wxT("account IN ('");
req += wxT("(account IN ('");
it = accounts.begin();
req += *it;
it++;
for (; it != categories.end(); it++)
for (; it != accounts.end(); it++)
req += wxT("', '") + *it ;
req += wxT("')");
req += wxT(" OR user ='") + user->_id + wxT("')");
}
else
{
req += wxT("account IN ('");
req += wxT("(account IN ('");
accountIt = user->_accounts.begin();
req += accountIt->id;
accountIt++;
@ -1332,6 +1334,7 @@ std::vector<Operation>* Database::Search(User* user, wxString* description, wxDa
req += wxT("', '") + accountIt->id ;
}
req += wxT("')");
req += wxT(" OR user ='") + user->_id + wxT("')");
}
req += wxT(" ORDER BY year ") ;
@ -1347,6 +1350,7 @@ std::vector<Operation>* Database::Search(User* user, wxString* description, wxDa
{
Operation op;
op.id = set.GetAsString(wxT("id"));
op.parent = set.GetAsString(wxT("parent"));
op.account = set.GetAsString(wxT("account"));
op.day = set.GetInt(wxT("day"));
op.month = set.GetInt(wxT("month"));
@ -1356,9 +1360,16 @@ std::vector<Operation>* Database::Search(User* user, wxString* description, wxDa
op.category = set.GetAsString(wxT("category"));
op.fix_cost = set.GetBool(wxT("fix_cost"));
op.checked = set.GetBool(wxT("checked"));
op.transfert = set.GetAsString(wxT("transfert"));
op.formula = set.GetAsString(wxT("formula"));
op.meta = set.GetBool(wxT("meta"));
res->push_back(op);
}
for(i=0; i < (int)res->size(); i++)
if ((*res)[i].parent.Length())
user->Group(res, (*res)[i]);
return res;
}

View File

@ -181,12 +181,12 @@ void User::LinkOrUnlinkOperation(Operation& op)
}
}
void User::Group(const Operation& op)
bool User::Group(std::vector<Operation>* ops, const Operation& op)
{
std::vector<Operation>::iterator it;
std::vector<wxString>::iterator it2;
for (it = (*_operations[op.year])[op.month].begin(); it != (*_operations[op.year])[op.month].end(); it++)
for (it = ops->begin(); it != ops->end(); it++)
{
if (it->id == op.parent)
{
@ -194,13 +194,22 @@ void User::Group(const Operation& op)
if (*it2 == op.id)
break;
// Already into childs
if (it2 != it->childs.end()) return;
if (it2 != it->childs.end()) return true;
it->childs.push_back(op.id);
return;
return true;
}
}
if (_db->LoadOperation(this, op.parent))
return false ;
}
void User::Group(const Operation& op)
{
std::vector<Operation>::iterator it;
std::vector<wxString>::iterator it2;
if (!Group(&(*_operations[op.year])[op.month], op)
&& _db->LoadOperation(this, op.parent))
{
(*_operations[op.year])[op.month][(*_operations[op.year])[op.month].size()-1].childs.push_back(op.id);
}

View File

@ -59,6 +59,7 @@ public:
wxLanguage GetLanguage();
void LinkOrUnlinkOperation(Operation& op);
void Group(const Operation& op);
bool Group(std::vector<Operation>* ops, const Operation& op);
void UnGroup(const Operation& op);
void ResolveGroups(int year);