First pass
This commit is contained in:
parent
ed6a7a5fef
commit
991486a042
25
Makefile
25
Makefile
|
@ -4,26 +4,14 @@ SHARE_DIR=$(DESTDIR)$(ROOT_DIR)"/share/kisscount/"
|
|||
DOC_DIR=$(DESTDIR)$(ROOT_DIR)"/share/doc/kisscount/"
|
||||
BIN_DIR=$(DESTDIR)$(ROOT_DIR)"/bin/"
|
||||
|
||||
CXXFLAGS+=`wx-config --cxxflags` -Wall -Isrc -ggdb
|
||||
CXXFLAGS+=-I./lib/wxsqlite3-1.9.9/include
|
||||
CXXFLAGS+=-I./lib/freechart/include
|
||||
CXXFLAGS+=-I/usr/include/libxml2
|
||||
CXXFLAGS=`pkg-config --cflags QtCore QtGui QtSql` -Wall -Isrc -ggdb
|
||||
CXXFLAGS+=-Wl,--rpath,"$(LIB_DIR)"
|
||||
CXXFLAGS+=-DRESSOURCES_ROOT="\"$(SHARE_DIR)\""
|
||||
# For developpers
|
||||
#CXXFLAGS+=-DRESSOURCES_ROOT="\"./ressources/\""
|
||||
|
||||
LDFLAGS+=`wx-config --libs`
|
||||
LDFLAGS=`pkg-config --libs QtCore QtGui QtSql`
|
||||
LDFLAGS+=-lofx
|
||||
LDFLAGS+=-lxml2
|
||||
|
||||
ifdef WIN32
|
||||
LDFLAGS+=-L./lib/wxsqlite3-1.9.9/lib/ -lwxcode_msw_wxsqlite3-2.8
|
||||
LDFLAGS+=-L./lib/freechart/lib -lwxcode_msw_freechart-2.8
|
||||
else
|
||||
LDFLAGS+=-L./lib/wxsqlite3-1.9.9/lib/ -lwxcode_gtk2u_wxsqlite3-2.8
|
||||
LDFLAGS+=-L./lib/freechart/lib -lwxcode_gtk2u_freechart-2.8
|
||||
endif
|
||||
|
||||
CXX=$(HOST)g++
|
||||
|
||||
|
@ -31,17 +19,16 @@ SOURCES=$(shell find src -name '*.cpp' -type f | tr '\n' ' ')
|
|||
HEADERS=$(shell find src -name '*.h' -type f)
|
||||
OBJS=$(SOURCES:.cpp=.o)
|
||||
|
||||
all: check kc
|
||||
all: kc
|
||||
|
||||
clean:
|
||||
find src -type f -name '*.[o~]' -exec rm -f \{\} \;
|
||||
rm -f kc
|
||||
|
||||
%.o : src/model/%.cpp src/model/import/%.cpp src/model/export/%.cpp src/view/%.cpp src/view/grid/%.cpp src/controller/%.cpp src/%.cpp
|
||||
$(CXX) $(CXXFLAGS) -c $<
|
||||
# %.o : src/model/%.cpp src/model/import/%.cpp src/model/export/%.cpp src/view/%.cpp src/view/grid/%.cpp src/controller/%.cpp src/%.cpp
|
||||
|
||||
check:
|
||||
if ! test -d lib ; then echo lib directory not found, please see INSTALL ; return 1 ; fi
|
||||
%.o : src/model/%.cpp src/model/import/%.cpp src/model/export/%.cpp src/view/%.cpp src/controller/%.cpp src/%.cpp src/%.c
|
||||
$(CXX) $(CXXFLAGS) -c $<
|
||||
|
||||
kc: $(OBJS)
|
||||
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
|
||||
|
|
|
@ -36,9 +36,9 @@ KissCount::KissCount(const char* bdd_filename) : _user(0)
|
|||
|
||||
_wxUI->SetLanguage(wxLocale::GetSystemLanguage());
|
||||
|
||||
_wxUI->Show(true);
|
||||
_wxUI->Centre();
|
||||
_wxUI->Disable();
|
||||
_wxUI->show();
|
||||
// _wxUI->Centre();
|
||||
// _wxUI->Disable();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -64,17 +64,17 @@ KissCount::~KissCount()
|
|||
if (_user) delete _user;
|
||||
}
|
||||
|
||||
std::list<wxString> KissCount::GetUsers()
|
||||
std::list<std::string> KissCount::GetUsers()
|
||||
{
|
||||
return _db->GetUsers();
|
||||
}
|
||||
|
||||
bool KissCount::IsValidUser(const wxString& user, const wxString& password)
|
||||
bool KissCount::IsValidUser(const std::string& user, const std::string& password)
|
||||
{
|
||||
return _db->IsValidUser(user, password) ;
|
||||
}
|
||||
|
||||
void KissCount::LoadUser(const wxString& user)
|
||||
void KissCount::LoadUser(const std::string& user)
|
||||
{
|
||||
if (_user) delete _user;
|
||||
_user = _db->LoadUser(user) ;
|
||||
|
@ -100,12 +100,12 @@ User* KissCount::GetUser()
|
|||
return _user;
|
||||
}
|
||||
|
||||
double KissCount::GetAccountAmount(const wxString& id, int month, int year)
|
||||
double KissCount::GetAccountAmount(int id, int month, int year)
|
||||
{
|
||||
return _db->GetAccountAmount(id, month, year);
|
||||
}
|
||||
|
||||
double KissCount::CalcAccountAmount(const wxString& id, int month, int year, bool* had_values)
|
||||
double KissCount::CalcAccountAmount(int id, int month, int year, bool* had_values)
|
||||
{
|
||||
return _db->CalcAccountAmount(id, month, year, had_values);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ void KissCount::UpdateOperation(Operation& op, bool checkTransfert)
|
|||
// Unlink
|
||||
if (checkTransfert)
|
||||
{
|
||||
op.transfert = wxT("");
|
||||
op.transfert = 0;
|
||||
_user->LinkOrUnlinkOperation(op);
|
||||
}
|
||||
|
||||
|
@ -126,9 +126,9 @@ void KissCount::UpdateOperation(Operation& op, bool checkTransfert)
|
|||
_user->LinkOrUnlinkOperation(op);
|
||||
}
|
||||
|
||||
wxString KissCount::AddOperation(Operation& op, bool checkTransfert)
|
||||
int KissCount::AddOperation(Operation& op, bool checkTransfert)
|
||||
{
|
||||
wxString ret = _db->AddOperation(_user, op, checkTransfert);
|
||||
int ret = _db->AddOperation(_user, op, checkTransfert);
|
||||
|
||||
if (checkTransfert && op.transfert.Length())
|
||||
_user->LinkOrUnlinkOperation(op);
|
||||
|
@ -140,7 +140,7 @@ void KissCount::DeleteOperation(Operation& op)
|
|||
{
|
||||
if (op.transfert.Length())
|
||||
{
|
||||
op.transfert = wxT("");
|
||||
op.transfert = 0;
|
||||
_user->LinkOrUnlinkOperation(op);
|
||||
}
|
||||
_db->DeleteOperation(_user, op);
|
||||
|
@ -159,22 +159,22 @@ void KissCount::DeleteOperations(int month, int year)
|
|||
}
|
||||
}
|
||||
|
||||
double KissCount::MetaAmount(const wxString& id)
|
||||
double KissCount::MetaAmount(int id)
|
||||
{
|
||||
return _db->MetaAmount(id);
|
||||
}
|
||||
|
||||
double KissCount::MetaPositiveAmount(const wxString& id)
|
||||
double KissCount::MetaPositiveAmount(int id)
|
||||
{
|
||||
return _db->MetaPositiveAmount(id);
|
||||
}
|
||||
|
||||
void KissCount::SetAccountAmount(const wxString& accountId, int month, int year, double amount)
|
||||
void KissCount::SetAccountAmount(int accountId, int month, int year, double amount)
|
||||
{
|
||||
_db->SetAccountAmount(accountId, month, year, amount);
|
||||
}
|
||||
|
||||
wxString KissCount::AddAccount(Account& ac)
|
||||
int KissCount::AddAccount(Account& ac)
|
||||
{
|
||||
wxDateTime curDate;
|
||||
|
||||
|
@ -196,7 +196,7 @@ void KissCount::UpdateAccount(Account& ac)
|
|||
std::sort(_user->_accounts.begin(), _user->_accounts.end(), Account());
|
||||
}
|
||||
|
||||
void KissCount::DeleteAccount(Account& ac, const wxString& replacement)
|
||||
void KissCount::DeleteAccount(Account& ac, int replacement)
|
||||
{
|
||||
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it2;
|
||||
|
||||
|
@ -209,27 +209,27 @@ void KissCount::DeleteAccount(Account& ac, const wxString& replacement)
|
|||
LoadYear(it2->first, true);
|
||||
}
|
||||
|
||||
void KissCount::AddSharedAccount(Account& ac, const wxString& granted)
|
||||
void KissCount::AddSharedAccount(Account& ac, const std::string& granted)
|
||||
{
|
||||
_db->AddSharedAccount(ac, granted);
|
||||
}
|
||||
|
||||
void KissCount::RemoveSharedAccount(Account& ac, const wxString& granted)
|
||||
void KissCount::RemoveSharedAccount(Account& ac, const std::string& granted)
|
||||
{
|
||||
_db->RemoveSharedAccount(ac, granted);
|
||||
}
|
||||
|
||||
std::map<wxString, wxString> KissCount::getSharedAccountOwners(const wxString& account)
|
||||
std::map<int, int> KissCount::getSharedAccountOwners(int account)
|
||||
{
|
||||
return _db->getSharedAccountOwners(account);
|
||||
}
|
||||
|
||||
wxString KissCount::getSharedAccountOwner(const wxString& account)
|
||||
int KissCount::getSharedAccountOwner(int account)
|
||||
{
|
||||
return _db->getSharedAccountOwner(account);
|
||||
}
|
||||
|
||||
wxString KissCount::AddCategory(Category& category)
|
||||
int KissCount::AddCategory(Category& category)
|
||||
{
|
||||
category.id = _db->AddCategory(_user, category);
|
||||
_user->AddCategory(category);
|
||||
|
@ -243,7 +243,7 @@ void KissCount::UpdateCategory(Category& category)
|
|||
_user->UpdateCategory(category);
|
||||
}
|
||||
|
||||
void KissCount::DeleteCategory(Category& category, const wxString& replacement)
|
||||
void KissCount::DeleteCategory(Category& category, int replacement)
|
||||
{
|
||||
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it;
|
||||
|
||||
|
@ -264,7 +264,7 @@ std::map<int, std::vector<int> > KissCount::GetAllOperations()
|
|||
void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int yearTo)
|
||||
{
|
||||
std::vector<Operation>::iterator it, it2;
|
||||
std::map<wxString, wxString> meta;
|
||||
std::map<int, int> meta;
|
||||
Operation op;
|
||||
|
||||
_db->GenerateMonth(_user, monthFrom, yearFrom, monthTo, yearTo);
|
||||
|
@ -317,17 +317,17 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year
|
|||
_wxUI->GenerateMonth(monthTo, yearTo);
|
||||
}
|
||||
|
||||
void KissCount::ChangePassword(const wxString& password)
|
||||
void KissCount::ChangePassword(const std::string& password)
|
||||
{
|
||||
_db->ChangePassword(_user, password);
|
||||
}
|
||||
|
||||
bool KissCount::UserExists(const wxString& name)
|
||||
bool KissCount::UserExists(const std::string& name)
|
||||
{
|
||||
return _db->UserExists(name);
|
||||
}
|
||||
|
||||
void KissCount::ChangeName(const wxString& name)
|
||||
void KissCount::ChangeName(const std::string& name)
|
||||
{
|
||||
_db->ChangeName(_user, name);
|
||||
_user->_name = name;
|
||||
|
@ -339,13 +339,13 @@ wxString default_cats[] = {
|
|||
_("Unexpected"), _("Other")
|
||||
};
|
||||
|
||||
void KissCount::NewUser(const wxString& name)
|
||||
void KissCount::NewUser(const std::string& name)
|
||||
{
|
||||
wxDateTime curDate;
|
||||
Account ac = {
|
||||
/*.id = */wxT(""),
|
||||
/*.id = */0,
|
||||
/*.name = */_("Account 1"),
|
||||
/*.number = */wxT(""),
|
||||
/*.number = */0,
|
||||
/*.shared = */false,
|
||||
/*.blocked = */false,
|
||||
/*._default = */true,
|
||||
|
@ -360,20 +360,20 @@ void KissCount::NewUser(const wxString& name)
|
|||
|
||||
AddAccount(ac);
|
||||
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Fix") ; cat.backcolor = view::OWN_YELLOW ; cat.forecolor = *wxBLACK; cat.fix_cost = true;
|
||||
cat.parent = 0 ; cat.name = "Fix" ; cat.backcolor = view::OWN_YELLOW ; cat.forecolor = Qt::black; cat.fix_cost = true;
|
||||
AddCategory(cat);
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Groceries") ; cat.backcolor = view::OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
|
||||
cat.parent = 0 ; cat.name = "Groceries" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
|
||||
AddCategory(cat);
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Hobbies") ; cat.backcolor = view::OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
|
||||
cat.parent = 0 ; cat.name = "Hobbies" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
|
||||
AddCategory(cat);
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Car") ; cat.backcolor = view::OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
|
||||
cat.parent = 0 ; cat.name = "Car" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
|
||||
AddCategory(cat);
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Unexpected") ; cat.backcolor = view::OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
|
||||
cat.parent = 0 ; cat.name = "Unexpected" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
|
||||
AddCategory(cat);
|
||||
cat.parent = wxT("0") ; cat.name = wxT("Other") ; cat.backcolor = view::OWN_GREEN; cat.forecolor = *wxBLACK; cat.fix_cost = false;
|
||||
cat.parent = 0 ; cat.name = "Other" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
|
||||
AddCategory(cat);
|
||||
|
||||
SetOperationOrder(wxT("ASC"));
|
||||
SetOperationOrder("ASC");
|
||||
|
||||
_db->GenerateMonth(_user, -1, -1, (int)curDate.GetMonth(), curDate.GetYear());
|
||||
}
|
||||
|
@ -389,27 +389,27 @@ void KissCount::KillMe()
|
|||
|
||||
void KissCount::SetLanguage(wxLanguage language)
|
||||
{
|
||||
_user->_preferences[wxT("language")] = wxString::Format(wxT("%d"), language) ;
|
||||
_db->UpdatePreference(_user, wxT("language"));
|
||||
_user->_preferences["language"] = wxString::Format(wxT("%d"), language) ;
|
||||
_db->UpdatePreference(_user, "language");
|
||||
}
|
||||
|
||||
/*
|
||||
ASC (default) or DESC
|
||||
*/
|
||||
void KissCount::SetOperationOrder(const wxString& order)
|
||||
void KissCount::SetOperationOrder(const std::string& order)
|
||||
{
|
||||
_user->_preferences[wxT("operation_order")] = order;
|
||||
_db->UpdatePreference(_user, wxT("operation_order"));
|
||||
_user->_preferences["operation_order"] = order;
|
||||
_db->UpdatePreference(_user, "operation_order");
|
||||
}
|
||||
|
||||
const wxString& KissCount::GetOperationOrder()
|
||||
const std::string& KissCount::GetOperationOrder()
|
||||
{
|
||||
return _user->_preferences[wxT("operation_order")] ;
|
||||
return _user->_preferences["operation_order"] ;
|
||||
}
|
||||
|
||||
std::vector<Operation>* KissCount::Search(wxString* description, wxDateTime* dateFrom, wxDateTime* dateTo,
|
||||
wxString* amountFrom, wxString* amountTo,
|
||||
std::vector<wxString> categories, int types, std::vector<wxString> accounts)
|
||||
std::vector<Operation>* KissCount::Search(std::string* description, wxDateTime* dateFrom, wxDateTime* dateTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts)
|
||||
{
|
||||
|
||||
return _db->Search(_user, description, dateFrom, dateTo, amountFrom, amountTo, categories, types, accounts, true);
|
||||
|
@ -460,8 +460,8 @@ bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month
|
|||
}
|
||||
|
||||
void KissCount::GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
||||
std::map<wxString, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<wxString, double>* categories)
|
||||
std::map<int, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<int, double>* categories)
|
||||
{
|
||||
wxString monthF = wxString::Format(wxT("%d"), monthFrom);
|
||||
wxString monthT = wxString::Format(wxT("%d"), monthTo);
|
||||
|
@ -472,8 +472,8 @@ void KissCount::GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
|||
}
|
||||
|
||||
void KissCount::GetMonthStats(int month, int year, int nbDays,
|
||||
std::map<wxString, std::vector<double> >* operations,
|
||||
std::map<wxString, double>* categories)
|
||||
std::map<int, std::vector<double> >* operations,
|
||||
std::map<int, double>* categories)
|
||||
{
|
||||
wxString monthS = wxString::Format(wxT("%d"), month);
|
||||
wxString yearS = wxString::Format(wxT("%d"), year);
|
||||
|
@ -482,70 +482,76 @@ void KissCount::GetMonthStats(int month, int year, int nbDays,
|
|||
}
|
||||
|
||||
|
||||
std::map<wxString, double>* KissCount::GetNotChecked(int month, int year)
|
||||
std::map<int, double>* KissCount::GetNotChecked(int month, int year)
|
||||
{
|
||||
return _db->GetNotChecked(_user, month, year);
|
||||
}
|
||||
|
||||
std::map<wxString, double>* KissCount::GetVirtualAmount(int month, int year)
|
||||
std::map<int, double>* KissCount::GetVirtualAmount(int month, int year)
|
||||
{
|
||||
return _db->GetVirtualAmount(_user, month, year);
|
||||
}
|
||||
|
||||
wxFont KissCount::ExtractFont(wxString strFont)
|
||||
QFont KissCount::ExtractFont(std::string strFont)
|
||||
{
|
||||
long int pos, pointSize, family, style, weight;
|
||||
long int pointSize, family, style, weight;
|
||||
size_t pos;
|
||||
std::string tmp;
|
||||
wxString faceName;
|
||||
|
||||
if (!strFont.Length())
|
||||
if (!strFont.size())
|
||||
{
|
||||
DEFAULT_FONT(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
pos = strFont.Find(wxT(";"));
|
||||
pos = strFont.find(";");
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
strFont.SubString(0, pos).ToLong(&pointSize);
|
||||
strFont = strFont.SubString(pos+1, strFont.Length());
|
||||
tmp = substring(strFont, 0, pos);
|
||||
pointSize = QString(tmp).toInt();
|
||||
strFont = strFont.substring(pos+1, strFont.size());
|
||||
}
|
||||
|
||||
pos = strFont.find(";");
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
tmp = substring(strFont, 0, pos);
|
||||
family = QString(tmp).toInt();
|
||||
strFont = strFont.substring(pos+1, strFont.size());
|
||||
}
|
||||
|
||||
pos = strFont.find(";");
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
tmp = substring(strFont, 0, pos);
|
||||
style = QString(tmp).toInt();
|
||||
strFont = strFont.substring(pos+1, strFont.size());
|
||||
}
|
||||
|
||||
pos = strFont.Find(wxT(";"));
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
strFont.SubString(0, pos).ToLong(&family);
|
||||
strFont = strFont.SubString(pos+1, strFont.Length());
|
||||
}
|
||||
|
||||
pos = strFont.Find(wxT(";"));
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
strFont.SubString(0, pos).ToLong(&style);
|
||||
strFont = strFont.SubString(pos+1, strFont.Length());
|
||||
}
|
||||
|
||||
pos = strFont.Find(wxT(";"));
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
strFont.SubString(0, pos).ToLong(&weight);
|
||||
strFont = strFont.SubString(pos+1, strFont.Length());
|
||||
tmp = substring(strFont, 0, pos);
|
||||
weight = QString(tmp).toInt();
|
||||
strFont = strFont.substring(pos+1, strFont.size());
|
||||
}
|
||||
|
||||
faceName = strFont;
|
||||
|
||||
return wxFont(pointSize, family, style, weight, false, faceName) ;
|
||||
return QFont(faceName, pointSize, weight);
|
||||
}
|
||||
|
||||
wxString KissCount::CompactFont(const wxFont& font)
|
||||
std::string KissCount::CompactFont(const QFont& font)
|
||||
{
|
||||
wxString res = wxString::Format(wxT("%d;%d;%d;%d;"), font.GetPointSize(), font.GetFamily(), font.GetStyle(), font.GetWeight());
|
||||
res += font.GetFaceName();
|
||||
QString res = QString::sprintf("%d;%d;%d;%d;", font.pointSize(), 0, 0, font.weight());
|
||||
res += font.family();
|
||||
|
||||
return res;
|
||||
return res.toStdString();
|
||||
}
|
||||
|
||||
void KissCount::UnRegisterImportEngine(ImportEngine* engine)
|
||||
|
@ -580,7 +586,7 @@ wxString KissCount::GetImportEngineExtensions()
|
|||
return res;
|
||||
}
|
||||
|
||||
ImportEngine* KissCount::GetImportEngine(wxString path)
|
||||
ImportEngine* KissCount::GetImportEngine(std::string path)
|
||||
{
|
||||
std::vector<ImportEngine*>::iterator it;
|
||||
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
|
||||
|
@ -615,13 +621,13 @@ void KissCount::RegisterExportEngine(ExportEngine* engine)
|
|||
|
||||
wxString KissCount::GetExportEngineExtensions()
|
||||
{
|
||||
wxString res;
|
||||
std::string res;
|
||||
std::vector<ExportEngine*>::iterator it;
|
||||
int i;
|
||||
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
|
||||
|
||||
for(i=0; i<(int)exportEngines->size()-1; i++)
|
||||
res = res + (*exportEngines)[i]->GetFileExt() + wxT("|") ;
|
||||
res = res + (*exportEngines)[i]->GetFileExt() + "|" ;
|
||||
|
||||
if (exportEngines->size())
|
||||
res = res + (*exportEngines)[i]->GetFileExt();
|
||||
|
@ -629,7 +635,7 @@ wxString KissCount::GetExportEngineExtensions()
|
|||
return res;
|
||||
}
|
||||
|
||||
ExportEngine* KissCount::GetExportEngine(wxString path)
|
||||
ExportEngine* KissCount::GetExportEngine(std::string path)
|
||||
{
|
||||
std::vector<ExportEngine*>::iterator it;
|
||||
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
|
||||
|
|
|
@ -22,112 +22,115 @@
|
|||
|
||||
#include <list>
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <model/import/ImportEngine.hpp>
|
||||
#include <model/export/ExportEngine.hpp>
|
||||
#include <model/model.hpp>
|
||||
|
||||
#include <wx/display.h>
|
||||
|
||||
#include <view/wxUI.hpp>
|
||||
|
||||
#define APP_VERSION "0.3"
|
||||
|
||||
#define ESCAPE_CHARS(s) { \
|
||||
#define ESCAPE_CHARS(s) s
|
||||
/*{ \
|
||||
if (s.Find(wxT("\\\"")) == wxNOT_FOUND) \
|
||||
s.Replace(wxT("\""), wxT("\\\""), true); \
|
||||
if (s.Find(wxT("\\\'")) == wxNOT_FOUND) \
|
||||
s.Replace(wxT("\'"), wxT("\\\'"), true); \
|
||||
}
|
||||
|
||||
#define UNESCAPE_CHARS(s) { \
|
||||
*/
|
||||
#define UNESCAPE_CHARS(s) s
|
||||
/*{ \
|
||||
s.Replace(wxT("\\\""), wxT("\""), true); \
|
||||
s.Replace(wxT("\\\'"), wxT("\'"), true); \
|
||||
}
|
||||
*/
|
||||
class wxUI;
|
||||
class Database;
|
||||
class ImportEngine;
|
||||
class ExportEngine;
|
||||
|
||||
class KissCount
|
||||
class KissCount : public QApplication
|
||||
{
|
||||
public:
|
||||
KissCount(const char* bdd_filename);
|
||||
~KissCount();
|
||||
|
||||
std::list<wxString> GetUsers();
|
||||
bool IsValidUser(const wxString& user, const wxString& password);
|
||||
void LoadUser(const wxString& user);
|
||||
std::list<std::string> GetUsers();
|
||||
bool IsValidUser(const std::string& user, const std::string& password);
|
||||
void LoadUser(const std::string& user);
|
||||
User* GetUser();
|
||||
void ChangePassword(const wxString& password);
|
||||
bool UserExists(const wxString& name);
|
||||
void ChangeName(const wxString& name);
|
||||
void NewUser(const wxString& name);
|
||||
void ChangePassword(const std::string& password);
|
||||
bool UserExists(const std::string& name);
|
||||
void ChangeName(const std::string& name);
|
||||
void NewUser(const std::string& name);
|
||||
|
||||
void LoadYear(int year, bool force=false);
|
||||
|
||||
wxString AddOperation(Operation& op, bool checkTransfert=true);
|
||||
int AddOperation(Operation& op, bool checkTransfert=true);
|
||||
void UpdateOperation(Operation& op, bool checkTransfert=true);
|
||||
void DeleteOperation(Operation& op);
|
||||
void DeleteOperations(int month, int year);
|
||||
double MetaAmount(const wxString& id);
|
||||
double MetaPositiveAmount(const wxString& id);
|
||||
double MetaAmount(int id);
|
||||
double MetaPositiveAmount(int id);
|
||||
|
||||
double GetAccountAmount(const wxString& id, int month, int year);
|
||||
void SetAccountAmount(const wxString& accountId, int month, int year, double value);
|
||||
double CalcAccountAmount(const wxString& id, int month, int year, bool* had_values);
|
||||
double GetAccountAmount(int id, int month, int year);
|
||||
void SetAccountAmount(int accountId, int month, int year, double value);
|
||||
double CalcAccountAmount(int id, int month, int year, bool* had_values);
|
||||
|
||||
wxString AddAccount(Account& ac);
|
||||
int AddAccount(Account& ac);
|
||||
void UpdateAccount(Account& ac);
|
||||
void DeleteAccount(Account& ac, const wxString& replacement);
|
||||
void AddSharedAccount(Account& ac, const wxString& granted);
|
||||
void RemoveSharedAccount(Account& ac, const wxString& granted);
|
||||
std::map<wxString, wxString> getSharedAccountOwners(const wxString& account);
|
||||
wxString getSharedAccountOwner(const wxString& account);
|
||||
void DeleteAccount(Account& ac, int replacement);
|
||||
void AddSharedAccount(Account& ac, const std::string& granted);
|
||||
void RemoveSharedAccount(Account& ac, const std::string& granted);
|
||||
std::map<int, int> getSharedAccountOwners(int account);
|
||||
int getSharedAccountOwner(int account);
|
||||
|
||||
wxString AddCategory(Category& category);
|
||||
int AddCategory(Category& category);
|
||||
void UpdateCategory(Category& category);
|
||||
void DeleteCategory(Category& category, const wxString& replacement);
|
||||
void DeleteCategory(Category& category, int replacement);
|
||||
|
||||
std::map<int, std::vector<int> > GetAllOperations();
|
||||
|
||||
void GenerateMonth(int monthFrom, int yearFrom, int monthTo, int yearTo);
|
||||
void KillMe();
|
||||
|
||||
void SetLanguage(wxLanguage language);
|
||||
void SetOperationOrder(const wxString& order);
|
||||
const wxString& GetOperationOrder();
|
||||
|
||||
std::vector<Operation>* Search(wxString* description, wxDateTime* dateFrom, wxDateTime* dateTo,
|
||||
wxString* amountFrom, wxString* amountTo,
|
||||
std::vector<wxString> categories, int types, std::vector<wxString> accounts);
|
||||
void SetLanguage(std::string language);
|
||||
void SetOperationOrder(const std::string& order);
|
||||
const std::string& GetOperationOrder();
|
||||
|
||||
std::vector<Operation>* Search(std::string* description, QDate* dateFrom, QDate* dateTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts);
|
||||
|
||||
bool SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType);
|
||||
|
||||
void GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
||||
std::map<wxString, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<wxString, double>* categories);
|
||||
std::map<int, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<int, double>* categories);
|
||||
|
||||
void GetMonthStats(int month, int year, int nbDays,
|
||||
std::map<wxString, std::vector<double> >* operations,
|
||||
std::map<wxString, double>* categories);
|
||||
std::map<int, std::vector<double> >* operations,
|
||||
std::map<int, double>* categories);
|
||||
|
||||
std::map<wxString, double>* GetNotChecked(int month, int year);
|
||||
std::map<wxString, double>* GetVirtualAmount(int month, int year);
|
||||
std::map<int, double>* GetNotChecked(int month, int year);
|
||||
std::map<int, double>* GetVirtualAmount(int month, int year);
|
||||
|
||||
static wxFont ExtractFont(wxString strFont);
|
||||
static wxString CompactFont(const wxFont& font);
|
||||
static QFont ExtractFont(std::string);
|
||||
static std::string CompactFont(const QFont& font);
|
||||
|
||||
static void RegisterImportEngine(ImportEngine* engine);
|
||||
static void UnRegisterImportEngine(ImportEngine* engine);
|
||||
|
||||
wxString GetImportEngineExtensions();
|
||||
ImportEngine* GetImportEngine(wxString path);
|
||||
std::string GetImportEngineExtensions();
|
||||
ImportEngine* GetImportEngine(std::string path);
|
||||
|
||||
static void RegisterExportEngine(ExportEngine* engine);
|
||||
static void UnRegisterExportEngine(ExportEngine* engine);
|
||||
|
||||
wxString GetExportEngineExtensions();
|
||||
ExportEngine* GetExportEngine(wxString path);
|
||||
std::string GetExportEngineExtensions();
|
||||
ExportEngine* GetExportEngine(std::string path);
|
||||
|
||||
void UpdateImportPattern();
|
||||
|
||||
|
|
34
src/main.cpp
34
src/main.cpp
|
@ -17,28 +17,22 @@
|
|||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <controller/KissCount.hpp>
|
||||
|
||||
class MyApp: public wxApp
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
virtual bool OnInit()
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
if (argc == 2)
|
||||
new KissCount(wxString(argv[1]).mb_str());
|
||||
else
|
||||
new KissCount(0);
|
||||
}
|
||||
catch (std::string s)
|
||||
{
|
||||
std::cerr << "Error " << s << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if (argc == 2)
|
||||
KissCount(wxString(argv[1]).mb_str());
|
||||
else
|
||||
KissCount(0);
|
||||
|
||||
IMPLEMENT_APP(MyApp);
|
||||
return KissCount.exec();
|
||||
}
|
||||
catch (std::string s)
|
||||
{
|
||||
std::cerr << "Error " << s << "\n";
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,10 @@
|
|||
#ifndef ACCOUNT_H
|
||||
#define ACCOUNT_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
struct Account {
|
||||
wxString id;
|
||||
wxString name;
|
||||
wxString number;
|
||||
int id;
|
||||
std::string name;
|
||||
std::string number;
|
||||
bool shared;
|
||||
bool blocked;
|
||||
bool _default;
|
||||
|
@ -43,10 +41,10 @@ struct Account {
|
|||
if (!ac1._virtual && ac2._virtual) return true;
|
||||
if (ac1._virtual && !ac2._virtual) return false;
|
||||
|
||||
return (ac1.name.Cmp(ac2.name) < 0);
|
||||
return ac1.name < ac2.name;
|
||||
}
|
||||
|
||||
bool operator == (const wxString& accountId)
|
||||
bool operator == (int accountId)
|
||||
{
|
||||
return id == accountId;
|
||||
}
|
||||
|
|
|
@ -21,21 +21,14 @@
|
|||
#define ACCOUNTAMOUNT_H
|
||||
|
||||
struct AccountAmount {
|
||||
wxString account;
|
||||
int account;
|
||||
int month;
|
||||
int year;
|
||||
|
||||
bool operator()(const AccountAmount& x, const AccountAmount& y) const
|
||||
{
|
||||
long x1, y1;
|
||||
|
||||
if (x.account != y.account)
|
||||
{
|
||||
x.account.ToLong(&x1);
|
||||
y.account.ToLong(&y1);
|
||||
|
||||
return x1 < y1;
|
||||
}
|
||||
return x.account < y.account;
|
||||
|
||||
return (x.year < y.year || ((x.year == y.year) && x.month < y.month));
|
||||
}
|
||||
|
|
|
@ -20,19 +20,20 @@
|
|||
#ifndef CATEGORY_H
|
||||
#define CATEGORY_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <string>
|
||||
#include <QColor>
|
||||
|
||||
struct Category
|
||||
{
|
||||
wxString id;
|
||||
wxString parent;
|
||||
wxString name;
|
||||
wxColour backcolor;
|
||||
wxColour forecolor;
|
||||
wxString font;
|
||||
int id;
|
||||
int parent;
|
||||
std::string name;
|
||||
QColor backcolor;
|
||||
QColor forecolor;
|
||||
std::string font;
|
||||
bool fix_cost;
|
||||
|
||||
bool operator == (const wxString& catId)
|
||||
bool operator == (int catId)
|
||||
{
|
||||
return id == catId;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,8 +21,9 @@
|
|||
#define DATABASE_H
|
||||
|
||||
#include <list>
|
||||
#include <wx/wxsqlite3.h>
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include <QSqlDatabase>
|
||||
#include <QDate>
|
||||
|
||||
#include <controller/KissCount.hpp>
|
||||
#include "model.hpp"
|
||||
|
@ -40,40 +41,31 @@
|
|||
// }
|
||||
|
||||
#define EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, code_if_fail, code_if_syntax_fail) \
|
||||
do{ \
|
||||
try \
|
||||
{ \
|
||||
_db.ExecuteUpdate(req); \
|
||||
} \
|
||||
catch (wxSQLite3Exception e) \
|
||||
{ \
|
||||
wxMessageBox(_("Update failed !\n") + req, _("Error"), wxICON_ERROR | wxOK); \
|
||||
std::cerr << __FUNCTION__ << "\n" ; \
|
||||
std::cerr << req.mb_str() << "\n" ; \
|
||||
std::cerr << e.GetMessage().mb_str() << "\n" ; \
|
||||
code_if_fail; \
|
||||
return return_value; \
|
||||
} \
|
||||
do { \
|
||||
QSqlQuery query; \
|
||||
if (!query.exec(req)) \
|
||||
{ \
|
||||
QMessageBox::critical(0, _("Error"), _("Update failed !\n") + req); \
|
||||
std::cerr << __FUNCTION__ << "\n" ; \
|
||||
std::cerr << req.toStdString() << "\n" ; \
|
||||
std::cerr << query.lastError().text().toStdString() << "\n" ; \
|
||||
code_if_fail; \
|
||||
return return_value; \
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define EXECUTE_SQL_QUERY_WITH_CODE(req, res, return_value, code_if_fail, code_if_syntax_fail) \
|
||||
do{ \
|
||||
try \
|
||||
{ \
|
||||
res = _db.ExecuteQuery(req); \
|
||||
} \
|
||||
catch (wxSQLite3Exception e) \
|
||||
{ \
|
||||
wxMessageBox(_("Query failed !\n") + req, _("Error"), wxICON_ERROR | wxOK); \
|
||||
std::cerr << __FUNCTION__ << "\n" ; \
|
||||
std::cerr << req.mb_str() << "\n" ; \
|
||||
std::cerr << e.GetMessage().mb_str() << "\n" ; \
|
||||
code_if_fail; \
|
||||
return return_value; \
|
||||
} \
|
||||
} while(0);
|
||||
#define EXECUTE_SQL_QUERY_WITH_CODE(req, return_value, code_if_fail, code_if_syntax_fail) \
|
||||
if (!query.exec(req)) \
|
||||
{ \
|
||||
QMessageBox::critical(0, _("Error"), _("Query failed !\n") + req); \
|
||||
std::cerr << __FUNCTION__ << "\n" ; \
|
||||
std::cerr << req.toStdString() << "\n" ; \
|
||||
std::cerr << query.lastError().text().toStdString() << "\n" ; \
|
||||
code_if_fail; \
|
||||
return return_value; \
|
||||
} \
|
||||
|
||||
#define EXECUTE_SQL_QUERY(req, res, return_value) EXECUTE_SQL_QUERY_WITH_CODE(req, res, return_value, {}, {})
|
||||
#define EXECUTE_SQL_QUERY(req, return_value) EXECUTE_SQL_QUERY_WITH_CODE(req, return_value, {}, {})
|
||||
|
||||
#define EXECUTE_SQL_UPDATE(req, return_value) EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, {}, {})
|
||||
|
||||
|
@ -83,8 +75,8 @@ class User;
|
|||
class Database
|
||||
{
|
||||
public:
|
||||
static const int FIX_OP = 1;//(1 << 0);
|
||||
static const int NON_FIX_OP = 2;//(1 << 1);
|
||||
static const int FIX_OP = (1 << 0);
|
||||
static const int NON_FIX_OP = (1 << 1);
|
||||
static const int CHECKED_OP = (1 << 2);
|
||||
static const int NOT_CHECKED_OP = (1 << 3);
|
||||
static const int ALL_OP = (~0);
|
||||
|
@ -93,64 +85,64 @@ public:
|
|||
|
||||
Database(const char* filename, KissCount* kiss);
|
||||
|
||||
std::list<wxString> GetUsers();
|
||||
bool IsValidUser(const wxString& user, const wxString& password);
|
||||
std::list<std::string> GetUsers();
|
||||
bool IsValidUser(const QString& user, const QString& password);
|
||||
|
||||
User* LoadUser(const wxString& name);
|
||||
User* LoadUser(const std::string& name);
|
||||
void LoadYear(User* user, int year);
|
||||
|
||||
void UpdateOperation(User* user, Operation& op, bool checkTransfert=true);
|
||||
wxString AddOperation(User* user, Operation& op, bool checkTransfert=true);
|
||||
int AddOperation(User* user, Operation& op, bool checkTransfert=true);
|
||||
void DeleteOperation(User* user, Operation& op);
|
||||
void DeleteOperations(User* user, int month, int year);
|
||||
bool LoadOperation(User* user, const wxString& id);
|
||||
double MetaAmount(const wxString& id);
|
||||
double MetaPositiveAmount(const wxString& id);
|
||||
bool LoadOperation(User* user, int id);
|
||||
double MetaAmount(int id);
|
||||
double MetaPositiveAmount(int id);
|
||||
|
||||
double GetAccountAmount(const wxString& id, int month, int year);
|
||||
void SetAccountAmount(const wxString& accountId, int month, int year, double amount);
|
||||
double CalcAccountAmount(const wxString& id, int month, int year, bool* had_values);
|
||||
double GetAccountAmount(int id, int month, int year);
|
||||
void SetAccountAmount(int accountId, int month, int year, double amount);
|
||||
double CalcAccountAmount(int id, int month, int year, bool* had_values);
|
||||
|
||||
wxString AddAccount(User* user, Account& ac);
|
||||
int AddAccount(User* user, Account& ac);
|
||||
void UpdateAccount(Account& ac);
|
||||
void DeleteAccount(User* user, Account& ac, const wxString& replacement);
|
||||
void AddSharedAccount(Account& ac, const wxString& granted);
|
||||
void RemoveSharedAccount(Account& ac, const wxString& granted);
|
||||
void DeleteAccount(User* user, Account& ac, int replacement);
|
||||
void AddSharedAccount(Account& ac, const std::string& granted);
|
||||
void RemoveSharedAccount(Account& ac, const std::string& granted);
|
||||
|
||||
wxString AddCategory(User* user, Category& category);
|
||||
int AddCategory(User* user, Category& category);
|
||||
void UpdateCategory(Category& category);
|
||||
void DeleteCategory(User* user, Category& category, const wxString& replacement);
|
||||
bool LoadCategory(const wxString& id, const wxString& name, Category& category);
|
||||
void DeleteCategory(User* user, Category& category, int replacement);
|
||||
bool LoadCategory(int id, const std::string& name, Category& category);
|
||||
|
||||
std::map<int, std::vector<int> > GetAllOperations(User* user);
|
||||
void GenerateMonth(User* user, int monthFrom, int yearFrom, int monthTo, int yearTo);
|
||||
|
||||
void ChangePassword(User* user, const wxString& password);
|
||||
bool UserExists(const wxString& name);
|
||||
void ChangeName(User* user, const wxString& name);
|
||||
void NewUser(const wxString& name);
|
||||
void ChangePassword(User* user, const std::string& password);
|
||||
bool UserExists(const std::string& name);
|
||||
void ChangeName(User* user, const std::string& name);
|
||||
void NewUser(const std::string& name);
|
||||
|
||||
void UpdatePreference(User* user, const wxString& preference);
|
||||
void UpdatePreference(User* user, const std::string& preference);
|
||||
|
||||
std::vector<Operation>* Search(User* user, wxString* description, wxDateTime* dateFrom, wxDateTime* dateTo,
|
||||
wxString* amountFrom, wxString* amountTo,
|
||||
std::vector<wxString> categories, int types, std::vector<wxString> accounts, bool wildcards);
|
||||
std::vector<Operation>* Search(User* user, std::string* description, QDate* dateFrom, QDate* dateTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts, bool wildcards);
|
||||
|
||||
void GetStats(User* user, const wxString& monthFrom, const wxString& yearFrom, const wxString& monthTo,
|
||||
const wxString& yearTo, std::map<wxString, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<wxString, double>* categories);
|
||||
void GetStats(User* user, int monthFrom, int yearFrom, int monthTo,
|
||||
int yearTo, std::map<int, std::map<int, std::map<int, double> > >* accountAmounts,
|
||||
std::map<int, double>* categories);
|
||||
|
||||
void GetMonthStats(User* user, const wxString& month, const wxString& year, int nbDays,
|
||||
std::map<wxString, std::vector<double> >* operations,
|
||||
std::map<wxString, double>* categories);
|
||||
void GetMonthStats(User* user, int month, int year, int nbDays,
|
||||
std::map<int, std::vector<double> >* operations,
|
||||
std::map<int, double>* categories);
|
||||
|
||||
void KillMe(User* user);
|
||||
bool GetOperation(const wxString& id, Operation* op);
|
||||
std::map<wxString, wxString> getSharedAccountOwners(const wxString& account);
|
||||
wxString getSharedAccountOwner(const wxString& account);
|
||||
bool GetOperation(int id, Operation* op);
|
||||
std::map<std::string, std::string> getSharedAccountOwners(int account);
|
||||
int getSharedAccountOwner(int account);
|
||||
|
||||
std::map<wxString, double>* GetNotChecked(User* user, int month, int year);
|
||||
std::map<wxString, double>* GetVirtualAmount(User* user, int month, int year);
|
||||
std::map<int, int>* GetNotChecked(User* user, int month, int year);
|
||||
std::map<int, int>* GetVirtualAmount(User* user, int month, int year);
|
||||
|
||||
void UpdateImportPattern(User* user);
|
||||
|
||||
|
@ -160,10 +152,10 @@ public:
|
|||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
wxSQLite3Database _db;
|
||||
QSqlDatabase _db;
|
||||
|
||||
void CreateDatabase();
|
||||
wxString HashPassword(const wxString& password);
|
||||
QString HashPassword(const QString& password);
|
||||
void LinkOrUnlinkOperation(User* user, Operation& op);
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ bool sortOperations(const Operation& op1, const Operation& op2)
|
|||
if (op1.day < op2.day)
|
||||
return true;
|
||||
else if (op1.day == op2.day)
|
||||
return (op1.description.Cmp(op2.description) < 0);
|
||||
return (op1.description < op2.description);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,28 +20,27 @@
|
|||
#ifndef OPERATION_H
|
||||
#define OPERATION_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <vector>
|
||||
|
||||
struct Operation {
|
||||
wxString id;
|
||||
wxString parent;
|
||||
int id;
|
||||
int parent;
|
||||
unsigned int day;
|
||||
unsigned int month;
|
||||
unsigned int year;
|
||||
double amount;
|
||||
wxString description;
|
||||
wxString category;
|
||||
std::string description;
|
||||
int category;
|
||||
bool fix_cost;
|
||||
wxString account;
|
||||
int account;
|
||||
bool checked;
|
||||
wxString transfert;
|
||||
wxString formula;
|
||||
int transfert;
|
||||
std::string formula;
|
||||
bool meta;
|
||||
bool _virtual;
|
||||
std::vector<wxString> childs;
|
||||
std::vector<int> childs;
|
||||
|
||||
bool operator == (const wxString& opId)
|
||||
bool operator == (int opId)
|
||||
{
|
||||
return id == opId;
|
||||
}
|
||||
|
|
|
@ -44,64 +44,64 @@ void User::InvalidateOperations()
|
|||
_operations.clear();
|
||||
}
|
||||
|
||||
Category User::GetCategory(const wxString& catId)
|
||||
Category User::GetCategory(int catId)
|
||||
{
|
||||
Category cat;
|
||||
std::vector<Category>::iterator it = std::find(_categories.begin(), _categories.end(), catId);
|
||||
|
||||
if (it !=_categories.end()) return *it;
|
||||
|
||||
if (_db->LoadCategory(catId, wxT(""), cat))
|
||||
if (_db->LoadCategory(catId, "", cat))
|
||||
return cat;
|
||||
|
||||
cat.id = wxT("0");
|
||||
cat.parent = wxT("0");
|
||||
cat.id = 0;
|
||||
cat.parent = 0;
|
||||
cat.name = _("Unknown");
|
||||
cat.font = wxT("");
|
||||
cat.font = "";
|
||||
cat.backcolor = view::OWN_GREEN;
|
||||
cat.forecolor = wxColour(0x00, 0x00, 0x00);
|
||||
|
||||
return cat;
|
||||
}
|
||||
|
||||
wxString User::GetCategoryName(const wxString& catId)
|
||||
std::string User::GetCategoryName(int catId)
|
||||
{
|
||||
Category cat;
|
||||
std::vector<Category>::iterator it = std::find(_categories.begin(), _categories.end(), catId);
|
||||
|
||||
if (it !=_categories.end()) return it->name;
|
||||
|
||||
if (_db->LoadCategory(catId, wxT(""), cat))
|
||||
if (_db->LoadCategory(catId, "", cat))
|
||||
return cat.name;
|
||||
|
||||
return _("Unknown") ;
|
||||
}
|
||||
|
||||
wxString User::GetCategoryId(const wxString& catName)
|
||||
int User::GetCategoryId(const std::string& catName)
|
||||
{
|
||||
std::vector<Category>::iterator it;
|
||||
Category cat;
|
||||
|
||||
for (it=_categories.begin(); it !=_categories.end(); it++)
|
||||
if (wxGetTranslation(it->name) == catName)
|
||||
if (_(it->name) == catName)
|
||||
return it->id;
|
||||
|
||||
if ( _db->LoadCategory(wxT(""), catName, cat))
|
||||
if ( _db->LoadCategory("", catName, cat))
|
||||
return cat.id;
|
||||
|
||||
return wxT("0") ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
const wxFont User::GetCategoryFont(const wxString& catId)
|
||||
const QFont User::GetCategoryFont(int catId)
|
||||
{
|
||||
wxFont f;
|
||||
QFont f;
|
||||
Category cat;
|
||||
|
||||
for (unsigned int i=0; i<_categories.size(); i++)
|
||||
if (_categories[i].id == catId)
|
||||
return _categoriesFonts[i];
|
||||
|
||||
if (_db->LoadCategory(catId, wxT(""), cat))
|
||||
if (_db->LoadCategory(catId, "", cat))
|
||||
return KissCount::ExtractFont(cat.font);
|
||||
|
||||
return f;
|
||||
|
@ -110,7 +110,7 @@ const wxFont User::GetCategoryFont(const wxString& catId)
|
|||
void User::AddCategory(const Category& cat)
|
||||
{
|
||||
_categories.push_back(cat);
|
||||
_categoriesFonts.push_back(KissCount::ExtractFont(wxT("")));
|
||||
_categoriesFonts.push_back(KissCount::ExtractFont(""));
|
||||
}
|
||||
|
||||
void User::UpdateCategory(const Category& cat)
|
||||
|
@ -136,7 +136,7 @@ void User::DeleteCategory(const Category& cat)
|
|||
}
|
||||
}
|
||||
|
||||
Account User::GetAccount(const wxString& accountId) throw (AccountNotFound)
|
||||
Account User::GetAccount(int accountId) throw (AccountNotFound)
|
||||
{
|
||||
std::vector<Account>::iterator it = std::find(_accounts.begin(), _accounts.end(), accountId);
|
||||
|
||||
|
@ -146,7 +146,7 @@ Account User::GetAccount(const wxString& accountId) throw (AccountNotFound)
|
|||
throw AccountNotFound();
|
||||
}
|
||||
|
||||
wxString User::GetAccountName(const wxString& accountId)
|
||||
std::string User::GetAccountName(int accountId)
|
||||
{
|
||||
std::vector<Account>::iterator it = std::find(_accounts.begin(), _accounts.end(), accountId);
|
||||
|
||||
|
@ -155,14 +155,14 @@ wxString User::GetAccountName(const wxString& accountId)
|
|||
return _("Unknown") ;
|
||||
}
|
||||
|
||||
wxString User::GetAccountId(const wxString& accountName)
|
||||
int User::GetAccountId(const std::string& accountName)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
for (it=_accounts.begin(); it !=_accounts.end(); it++)
|
||||
if (it->name == accountName)
|
||||
return it->id;
|
||||
|
||||
return wxT("0") ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
void User::AddAccount(Account& ac)
|
||||
|
@ -201,17 +201,17 @@ int User::GetOperationsNumber(int month, int year)
|
|||
return (*_operations[year])[month].size();
|
||||
}
|
||||
|
||||
wxLanguage User::GetLanguage()
|
||||
std::string User::GetLanguage()
|
||||
{
|
||||
wxString res = _preferences[wxT("language")];
|
||||
long val;
|
||||
return _preferences["language"];
|
||||
// long val;
|
||||
|
||||
if (!res.Length())
|
||||
return wxLANGUAGE_ENGLISH ;
|
||||
// if (!res.Length())
|
||||
// return wxLANGUAGE_ENGLISH ;
|
||||
|
||||
res.ToLong(&val);
|
||||
// res.ToLong(&val);
|
||||
|
||||
return (wxLanguage)val;
|
||||
// return (wxLanguage)val;
|
||||
}
|
||||
|
||||
void User::LinkOrUnlinkOperation(Operation& op)
|
||||
|
@ -226,13 +226,13 @@ void User::LinkOrUnlinkOperation(Operation& op)
|
|||
return;
|
||||
|
||||
// Not Linked
|
||||
if (!op.transfert.Length())
|
||||
if (!op.transfert)
|
||||
{
|
||||
for (it = (*_operations[op.year])[op.month].begin(); it != (*_operations[op.year])[op.month].end(); it++)
|
||||
{
|
||||
if (it->id != op.id && it->transfert == op.id)
|
||||
{
|
||||
it->transfert = wxT("");
|
||||
it->transfert = 0;
|
||||
it->_virtual = false;
|
||||
return;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ void User::LinkOrUnlinkOperation(Operation& op)
|
|||
return;
|
||||
}
|
||||
}
|
||||
op.transfert = wxT("");
|
||||
op.transfert = 0;
|
||||
op._virtual = false;
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ void User::LinkOrUnlinkOperation(Operation& op)
|
|||
bool User::Group(std::vector<Operation>* ops, const Operation& op)
|
||||
{
|
||||
std::vector<Operation>::iterator it;
|
||||
std::vector<wxString>::iterator it2;
|
||||
std::vector<int>::iterator it2;
|
||||
|
||||
for (it = ops->begin(); it != ops->end(); it++)
|
||||
{
|
||||
|
@ -280,9 +280,6 @@ bool User::Group(std::vector<Operation>* ops, const Operation& op)
|
|||
|
||||
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))
|
||||