First runnable version

This commit is contained in:
2011-08-27 18:35:36 +02:00
parent 991486a042
commit 658ec606ed
28 changed files with 657 additions and 646 deletions

View File

@@ -18,6 +18,9 @@
*/
#include <algorithm>
#include <QString>
#include <view/view.hpp>
#include "User.hpp"
@@ -59,12 +62,12 @@ Category User::GetCategory(int catId)
cat.name = _("Unknown");
cat.font = "";
cat.backcolor = view::OWN_GREEN;
cat.forecolor = wxColour(0x00, 0x00, 0x00);
cat.forecolor = Qt::black;
return cat;
}
std::string User::GetCategoryName(int catId)
QString User::GetCategoryName(int catId)
{
Category cat;
std::vector<Category>::iterator it = std::find(_categories.begin(), _categories.end(), catId);
@@ -77,16 +80,16 @@ std::string User::GetCategoryName(int catId)
return _("Unknown") ;
}
int User::GetCategoryId(const std::string& catName)
int User::GetCategoryId(const QString& catName)
{
std::vector<Category>::iterator it;
Category cat;
for (it=_categories.begin(); it !=_categories.end(); it++)
if (_(it->name) == catName)
if (_(it->name.toStdString().c_str()) == catName)
return it->id;
if ( _db->LoadCategory("", catName, cat))
if ( _db->LoadCategory(0, catName, cat))
return cat.id;
return 0 ;
@@ -146,7 +149,7 @@ Account User::GetAccount(int accountId) throw (AccountNotFound)
throw AccountNotFound();
}
std::string User::GetAccountName(int accountId)
QString User::GetAccountName(int accountId)
{
std::vector<Account>::iterator it = std::find(_accounts.begin(), _accounts.end(), accountId);
@@ -155,7 +158,7 @@ std::string User::GetAccountName(int accountId)
return _("Unknown") ;
}
int User::GetAccountId(const std::string& accountName)
int User::GetAccountId(const QString& accountName)
{
std::vector<Account>::iterator it;
for (it=_accounts.begin(); it !=_accounts.end(); it++)
@@ -165,6 +168,16 @@ int User::GetAccountId(const std::string& accountName)
return 0 ;
}
int User::GetAccountIdFromAccountNumber(const QString& accountNumber)
{
std::vector<Account>::iterator it;
for (it=_accounts.begin(); it !=_accounts.end(); it++)
if (it->number == accountNumber)
return it->id;
return 0 ;
}
void User::AddAccount(Account& ac)
{
_accounts.push_back(ac);
@@ -201,7 +214,7 @@ int User::GetOperationsNumber(int month, int year)
return (*_operations[year])[month].size();
}
std::string User::GetLanguage()
QString User::GetLanguage()
{
return _preferences["language"];
// long val;
@@ -314,7 +327,7 @@ void User::ResolveGroups(int year)
for (it = _operations[year]->begin(); it != _operations[year]->end(); it++)
{
for (i=0; i<it->second.size(); i++)
if (it->second[i].parent.Length())
if (it->second[i].parent)
Group(((*_operations[year])[it->first])[i]);
}
}