First runnable version
This commit is contained in:
@@ -28,13 +28,13 @@
|
||||
std::vector<ImportEngine*> * KissCount::_importEngines;
|
||||
std::vector<ExportEngine*> * KissCount::_exportEngines;
|
||||
|
||||
KissCount::KissCount(const char* bdd_filename) : _user(0)
|
||||
KissCount::KissCount(const char* bdd_filename) : QApplication(0, 0), _user(0)
|
||||
{
|
||||
wxRect rect = wxDisplay().GetGeometry();
|
||||
//wxRect rect = wxDisplay().GetGeometry();
|
||||
|
||||
_wxUI = new wxUI(this, wxT("KissCount"), wxPoint(50, 50), wxSize(rect.width-rect.x, rect.height-rect.y));
|
||||
_wxUI = new wxUI(this, "KissCount");
|
||||
|
||||
_wxUI->SetLanguage(wxLocale::GetSystemLanguage());
|
||||
//_wxUI->SetLanguage(wxLocale::GetSystemLanguage());
|
||||
|
||||
_wxUI->show();
|
||||
// _wxUI->Centre();
|
||||
@@ -46,12 +46,12 @@ KissCount::KissCount(const char* bdd_filename) : _user(0)
|
||||
}
|
||||
catch (std::string s)
|
||||
{
|
||||
_wxUI->Close(true);
|
||||
_wxUI->close();
|
||||
throw ;
|
||||
}
|
||||
|
||||
_wxUI->ChangeUser();
|
||||
_wxUI->Enable();
|
||||
//_wxUI->enable();
|
||||
}
|
||||
|
||||
KissCount::~KissCount()
|
||||
@@ -64,17 +64,17 @@ KissCount::~KissCount()
|
||||
if (_user) delete _user;
|
||||
}
|
||||
|
||||
std::list<std::string> KissCount::GetUsers()
|
||||
std::list<QString> KissCount::GetUsers()
|
||||
{
|
||||
return _db->GetUsers();
|
||||
}
|
||||
|
||||
bool KissCount::IsValidUser(const std::string& user, const std::string& password)
|
||||
bool KissCount::IsValidUser(const QString& user, const QString& password)
|
||||
{
|
||||
return _db->IsValidUser(user, password) ;
|
||||
}
|
||||
|
||||
void KissCount::LoadUser(const std::string& user)
|
||||
void KissCount::LoadUser(const QString& user)
|
||||
{
|
||||
if (_user) delete _user;
|
||||
_user = _db->LoadUser(user) ;
|
||||
@@ -130,7 +130,7 @@ int KissCount::AddOperation(Operation& op, bool checkTransfert)
|
||||
{
|
||||
int ret = _db->AddOperation(_user, op, checkTransfert);
|
||||
|
||||
if (checkTransfert && op.transfert.Length())
|
||||
if (checkTransfert && op.transfert)
|
||||
_user->LinkOrUnlinkOperation(op);
|
||||
|
||||
return ret;
|
||||
@@ -138,7 +138,7 @@ int KissCount::AddOperation(Operation& op, bool checkTransfert)
|
||||
|
||||
void KissCount::DeleteOperation(Operation& op)
|
||||
{
|
||||
if (op.transfert.Length())
|
||||
if (op.transfert)
|
||||
{
|
||||
op.transfert = 0;
|
||||
_user->LinkOrUnlinkOperation(op);
|
||||
@@ -176,13 +176,12 @@ void KissCount::SetAccountAmount(int accountId, int month, int year, double amou
|
||||
|
||||
int KissCount::AddAccount(Account& ac)
|
||||
{
|
||||
wxDateTime curDate;
|
||||
QDate curDate = QDate::currentDate();
|
||||
|
||||
ac.id = _db->AddAccount(_user, ac);
|
||||
_user->AddAccount(ac);
|
||||
curDate.SetToCurrent();
|
||||
|
||||
SetAccountAmount(ac.id, (int)curDate.GetMonth(), curDate.GetYear(), 0.0);
|
||||
SetAccountAmount(ac.id, curDate.month(), curDate.year(), 0.0);
|
||||
|
||||
return ac.id;
|
||||
}
|
||||
@@ -209,22 +208,22 @@ void KissCount::DeleteAccount(Account& ac, int replacement)
|
||||
LoadYear(it2->first, true);
|
||||
}
|
||||
|
||||
void KissCount::AddSharedAccount(Account& ac, const std::string& granted)
|
||||
void KissCount::AddSharedAccount(Account& ac, const QString& granted)
|
||||
{
|
||||
_db->AddSharedAccount(ac, granted);
|
||||
}
|
||||
|
||||
void KissCount::RemoveSharedAccount(Account& ac, const std::string& granted)
|
||||
void KissCount::RemoveSharedAccount(Account& ac, int granted)
|
||||
{
|
||||
_db->RemoveSharedAccount(ac, granted);
|
||||
}
|
||||
|
||||
std::map<int, int> KissCount::getSharedAccountOwners(int account)
|
||||
std::map<QString, QString> KissCount::getSharedAccountOwners(int account)
|
||||
{
|
||||
return _db->getSharedAccountOwners(account);
|
||||
}
|
||||
|
||||
int KissCount::getSharedAccountOwner(int account)
|
||||
QString KissCount::getSharedAccountOwner(int account)
|
||||
{
|
||||
return _db->getSharedAccountOwner(account);
|
||||
}
|
||||
@@ -298,7 +297,7 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year
|
||||
it != (*_user->_operations[yearTo])[monthTo].end();
|
||||
it++)
|
||||
{
|
||||
if (it->parent.Length())
|
||||
if (it->parent)
|
||||
{
|
||||
it->parent = meta[it->parent];
|
||||
UpdateOperation(*it);
|
||||
@@ -317,31 +316,31 @@ void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int year
|
||||
_wxUI->GenerateMonth(monthTo, yearTo);
|
||||
}
|
||||
|
||||
void KissCount::ChangePassword(const std::string& password)
|
||||
void KissCount::ChangePassword(const QString& password)
|
||||
{
|
||||
_db->ChangePassword(_user, password);
|
||||
}
|
||||
|
||||
bool KissCount::UserExists(const std::string& name)
|
||||
bool KissCount::UserExists(const QString& name)
|
||||
{
|
||||
return _db->UserExists(name);
|
||||
}
|
||||
|
||||
void KissCount::ChangeName(const std::string& name)
|
||||
void KissCount::ChangeName(const QString& name)
|
||||
{
|
||||
_db->ChangeName(_user, name);
|
||||
_user->_name = name;
|
||||
}
|
||||
|
||||
// To enable translation during xgettext
|
||||
wxString default_cats[] = {
|
||||
QString default_cats[] = {
|
||||
_("Fix"), _("Groceries"), _("Hobbies"), _("Car"),
|
||||
_("Unexpected"), _("Other")
|
||||
};
|
||||
|
||||
void KissCount::NewUser(const std::string& name)
|
||||
void KissCount::NewUser(const QString& name)
|
||||
{
|
||||
wxDateTime curDate;
|
||||
QDate curDate = QDate::currentDate();
|
||||
Account ac = {
|
||||
/*.id = */0,
|
||||
/*.name = */_("Account 1"),
|
||||
@@ -356,8 +355,6 @@ void KissCount::NewUser(const std::string& name)
|
||||
if (_user) delete _user;
|
||||
_user = _db->LoadUser(name) ;
|
||||
|
||||
curDate.SetToCurrent();
|
||||
|
||||
AddAccount(ac);
|
||||
|
||||
cat.parent = 0 ; cat.name = "Fix" ; cat.backcolor = view::OWN_YELLOW ; cat.forecolor = Qt::black; cat.fix_cost = true;
|
||||
@@ -375,7 +372,7 @@ void KissCount::NewUser(const std::string& name)
|
||||
|
||||
SetOperationOrder("ASC");
|
||||
|
||||
_db->GenerateMonth(_user, -1, -1, (int)curDate.GetMonth(), curDate.GetYear());
|
||||
_db->GenerateMonth(_user, -1, -1, (int)curDate.month(), curDate.year());
|
||||
}
|
||||
|
||||
void KissCount::KillMe()
|
||||
@@ -387,27 +384,27 @@ void KissCount::KillMe()
|
||||
_wxUI->ChangeUser();
|
||||
}
|
||||
|
||||
void KissCount::SetLanguage(wxLanguage language)
|
||||
void KissCount::SetLanguage(QString language)
|
||||
{
|
||||
_user->_preferences["language"] = wxString::Format(wxT("%d"), language) ;
|
||||
_user->_preferences["language"] = language;
|
||||
_db->UpdatePreference(_user, "language");
|
||||
}
|
||||
|
||||
/*
|
||||
ASC (default) or DESC
|
||||
*/
|
||||
void KissCount::SetOperationOrder(const std::string& order)
|
||||
void KissCount::SetOperationOrder(const QString& order)
|
||||
{
|
||||
_user->_preferences["operation_order"] = order;
|
||||
_db->UpdatePreference(_user, "operation_order");
|
||||
}
|
||||
|
||||
const std::string& KissCount::GetOperationOrder()
|
||||
const QString& KissCount::GetOperationOrder()
|
||||
{
|
||||
return _user->_preferences["operation_order"] ;
|
||||
}
|
||||
|
||||
std::vector<Operation>* KissCount::Search(std::string* description, wxDateTime* dateFrom, wxDateTime* dateTo,
|
||||
std::vector<Operation>* KissCount::Search(QString* description, QDate* dateFrom, QDate* dateTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts)
|
||||
{
|
||||
@@ -418,9 +415,9 @@ std::vector<Operation>* KissCount::Search(std::string* description, wxDateTime*
|
||||
bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType)
|
||||
{
|
||||
std::vector<Operation>* operations;
|
||||
wxDateTime* date ;
|
||||
QDate* date ;
|
||||
//wxDateSpan threeMonths(0, 3); Not working :(
|
||||
std::vector<wxString> v;
|
||||
std::vector<int> v;
|
||||
int i;
|
||||
|
||||
month -= 3;
|
||||
@@ -430,7 +427,7 @@ bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month
|
||||
month += 12;
|
||||
}
|
||||
|
||||
date = new wxDateTime(0, (wxDateTime::Month)month, year);
|
||||
date = new QDate(year, month, 0);
|
||||
|
||||
if (limitToType)
|
||||
operations = _db->Search(_user, &op.description, date, 0, 0, 0, v, op.fix_cost ? +Database::FIX_OP : +Database::NON_FIX_OP, v, false);
|
||||
@@ -463,22 +460,14 @@ void KissCount::GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
|
||||
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);
|
||||
wxString yearF = wxString::Format(wxT("%d"), yearFrom);
|
||||
wxString yearT = wxString::Format(wxT("%d"), yearTo);
|
||||
|
||||
_db->GetStats(_user, monthF, yearF, monthT, yearT, accountAmounts, categories);
|
||||
_db->GetStats(_user, monthFrom, yearFrom, monthTo, yearTo, accountAmounts, categories);
|
||||
}
|
||||
|
||||
void KissCount::GetMonthStats(int month, int year, int nbDays,
|
||||
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);
|
||||
|
||||
_db->GetMonthStats(_user, monthS, yearS, nbDays, operations, categories);
|
||||
_db->GetMonthStats(_user, month, year, nbDays, operations, categories);
|
||||
}
|
||||
|
||||
|
||||
@@ -492,66 +481,34 @@ std::map<int, double>* KissCount::GetVirtualAmount(int month, int year)
|
||||
return _db->GetVirtualAmount(_user, month, year);
|
||||
}
|
||||
|
||||
QFont KissCount::ExtractFont(std::string strFont)
|
||||
QFont KissCount::ExtractFont(QString strFont)
|
||||
{
|
||||
long int pointSize, family, style, weight;
|
||||
size_t pos;
|
||||
std::string tmp;
|
||||
wxString faceName;
|
||||
long int pointSize, weight, family, style;
|
||||
QString faceName;
|
||||
|
||||
if (!strFont.size())
|
||||
{
|
||||
DEFAULT_FONT(f);
|
||||
return f;
|
||||
}
|
||||
QStringList list = strFont.split(";");
|
||||
|
||||
pos = strFont.find(";");
|
||||
|
||||
if (pos != -1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
tmp = substring(strFont, 0, pos);
|
||||
weight = QString(tmp).toInt();
|
||||
strFont = strFont.substring(pos+1, strFont.size());
|
||||
}
|
||||
|
||||
faceName = strFont;
|
||||
pointSize = list[0].toInt();
|
||||
family = list[1].toInt();
|
||||
style = list[2].toInt();
|
||||
weight = list[3].toInt();
|
||||
faceName = list[4];
|
||||
|
||||
return QFont(faceName, pointSize, weight);
|
||||
}
|
||||
|
||||
std::string KissCount::CompactFont(const QFont& font)
|
||||
QString KissCount::CompactFont(const QFont& font)
|
||||
{
|
||||
QString res = QString::sprintf("%d;%d;%d;%d;", font.pointSize(), 0, 0, font.weight());
|
||||
QString res ;
|
||||
res = res.sprintf("%d;%d;%d;%d;", font.pointSize(), 0, 0, font.weight());
|
||||
res += font.family();
|
||||
|
||||
return res.toStdString();
|
||||
return res;
|
||||
}
|
||||
|
||||
void KissCount::UnRegisterImportEngine(ImportEngine* engine)
|
||||
@@ -570,15 +527,15 @@ void KissCount::RegisterImportEngine(ImportEngine* engine)
|
||||
importEngines->push_back(engine);
|
||||
}
|
||||
|
||||
wxString KissCount::GetImportEngineExtensions()
|
||||
QString KissCount::GetImportEngineExtensions()
|
||||
{
|
||||
wxString res;
|
||||
QString res;
|
||||
std::vector<ImportEngine*>::iterator it;
|
||||
int i;
|
||||
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
|
||||
|
||||
for(i=0; i<(int)importEngines->size()-1; i++)
|
||||
res = res + (*importEngines)[i]->GetFileExt() + wxT("|") ;
|
||||
res = res + (*importEngines)[i]->GetFileExt() + "|" ;
|
||||
|
||||
if (importEngines->size())
|
||||
res = res + (*importEngines)[i]->GetFileExt();
|
||||
@@ -586,7 +543,7 @@ wxString KissCount::GetImportEngineExtensions()
|
||||
return res;
|
||||
}
|
||||
|
||||
ImportEngine* KissCount::GetImportEngine(std::string path)
|
||||
ImportEngine* KissCount::GetImportEngine(QString path)
|
||||
{
|
||||
std::vector<ImportEngine*>::iterator it;
|
||||
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
|
||||
@@ -619,9 +576,9 @@ void KissCount::RegisterExportEngine(ExportEngine* engine)
|
||||
exportEngines->push_back(engine);
|
||||
}
|
||||
|
||||
wxString KissCount::GetExportEngineExtensions()
|
||||
QString KissCount::GetExportEngineExtensions()
|
||||
{
|
||||
std::string res;
|
||||
QString res;
|
||||
std::vector<ExportEngine*>::iterator it;
|
||||
int i;
|
||||
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
|
||||
@@ -635,7 +592,7 @@ wxString KissCount::GetExportEngineExtensions()
|
||||
return res;
|
||||
}
|
||||
|
||||
ExportEngine* KissCount::GetExportEngine(std::string path)
|
||||
ExportEngine* KissCount::GetExportEngine(QString path)
|
||||
{
|
||||
std::vector<ExportEngine*>::iterator it;
|
||||
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#define APP_VERSION "0.3"
|
||||
|
||||
#define ESCAPE_CHARS(s) s
|
||||
#define ESCAPE_CHARS(s) s.replace("\"", "\\\"");
|
||||
/*{ \
|
||||
if (s.Find(wxT("\\\"")) == wxNOT_FOUND) \
|
||||
s.Replace(wxT("\""), wxT("\\\""), true); \
|
||||
@@ -40,7 +40,7 @@
|
||||
s.Replace(wxT("\'"), wxT("\\\'"), true); \
|
||||
}
|
||||
*/
|
||||
#define UNESCAPE_CHARS(s) s
|
||||
#define UNESCAPE_CHARS(s) s.replace("\\\"", "\"");
|
||||
/*{ \
|
||||
s.Replace(wxT("\\\""), wxT("\""), true); \
|
||||
s.Replace(wxT("\\\'"), wxT("\'"), true); \
|
||||
@@ -57,14 +57,14 @@ public:
|
||||
KissCount(const char* bdd_filename);
|
||||
~KissCount();
|
||||
|
||||
std::list<std::string> GetUsers();
|
||||
bool IsValidUser(const std::string& user, const std::string& password);
|
||||
void LoadUser(const std::string& user);
|
||||
std::list<QString> GetUsers();
|
||||
bool IsValidUser(const QString& user, const QString& password);
|
||||
void LoadUser(const QString& user);
|
||||
User* GetUser();
|
||||
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 ChangePassword(const QString& password);
|
||||
bool UserExists(const QString& name);
|
||||
void ChangeName(const QString& name);
|
||||
void NewUser(const QString& name);
|
||||
|
||||
void LoadYear(int year, bool force=false);
|
||||
|
||||
@@ -82,10 +82,10 @@ public:
|
||||
int AddAccount(Account& ac);
|
||||
void UpdateAccount(Account& ac);
|
||||
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);
|
||||
void AddSharedAccount(Account& ac, const QString& granted);
|
||||
void RemoveSharedAccount(Account& ac, int granted);
|
||||
std::map<QString, QString> getSharedAccountOwners(int account);
|
||||
QString getSharedAccountOwner(int account);
|
||||
|
||||
int AddCategory(Category& category);
|
||||
void UpdateCategory(Category& category);
|
||||
@@ -96,11 +96,11 @@ public:
|
||||
void GenerateMonth(int monthFrom, int yearFrom, int monthTo, int yearTo);
|
||||
void KillMe();
|
||||
|
||||
void SetLanguage(std::string language);
|
||||
void SetOperationOrder(const std::string& order);
|
||||
const std::string& GetOperationOrder();
|
||||
void SetLanguage(QString language);
|
||||
void SetOperationOrder(const QString& order);
|
||||
const QString& GetOperationOrder();
|
||||
|
||||
std::vector<Operation>* Search(std::string* description, QDate* dateFrom, QDate* dateTo,
|
||||
std::vector<Operation>* Search(QString* description, QDate* dateFrom, QDate* dateTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts);
|
||||
|
||||
@@ -117,20 +117,20 @@ public:
|
||||
std::map<int, double>* GetNotChecked(int month, int year);
|
||||
std::map<int, double>* GetVirtualAmount(int month, int year);
|
||||
|
||||
static QFont ExtractFont(std::string);
|
||||
static std::string CompactFont(const QFont& font);
|
||||
static QFont ExtractFont(QString);
|
||||
static QString CompactFont(const QFont& font);
|
||||
|
||||
static void RegisterImportEngine(ImportEngine* engine);
|
||||
static void UnRegisterImportEngine(ImportEngine* engine);
|
||||
|
||||
std::string GetImportEngineExtensions();
|
||||
ImportEngine* GetImportEngine(std::string path);
|
||||
QString GetImportEngineExtensions();
|
||||
ImportEngine* GetImportEngine(QString path);
|
||||
|
||||
static void RegisterExportEngine(ExportEngine* engine);
|
||||
static void UnRegisterExportEngine(ExportEngine* engine);
|
||||
|
||||
std::string GetExportEngineExtensions();
|
||||
ExportEngine* GetExportEngine(std::string path);
|
||||
QString GetExportEngineExtensions();
|
||||
ExportEngine* GetExportEngine(QString path);
|
||||
|
||||
void UpdateImportPattern();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user