First runnable version
This commit is contained in:
parent
991486a042
commit
658ec606ed
2
Makefile
2
Makefile
|
@ -5,6 +5,7 @@ DOC_DIR=$(DESTDIR)$(ROOT_DIR)"/share/doc/kisscount/"
|
|||
BIN_DIR=$(DESTDIR)$(ROOT_DIR)"/bin/"
|
||||
|
||||
CXXFLAGS=`pkg-config --cflags QtCore QtGui QtSql` -Wall -Isrc -ggdb
|
||||
CXXFLAGS+=-I/usr/include/libxml2
|
||||
CXXFLAGS+=-Wl,--rpath,"$(LIB_DIR)"
|
||||
CXXFLAGS+=-DRESSOURCES_ROOT="\"$(SHARE_DIR)\""
|
||||
# For developpers
|
||||
|
@ -12,6 +13,7 @@ CXXFLAGS+=-DRESSOURCES_ROOT="\"$(SHARE_DIR)\""
|
|||
|
||||
LDFLAGS=`pkg-config --libs QtCore QtGui QtSql`
|
||||
LDFLAGS+=-lofx
|
||||
LDFLAGS+=-lxml2
|
||||
|
||||
CXX=$(HOST)g++
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -17,18 +17,18 @@
|
|||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <controller/KissCount.hpp>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
if (argc == 2)
|
||||
KissCount(wxString(argv[1]).mb_str());
|
||||
return KissCount(argv[1]).exec();
|
||||
else
|
||||
KissCount(0);
|
||||
|
||||
return KissCount.exec();
|
||||
return KissCount(0).exec();
|
||||
}
|
||||
catch (std::string s)
|
||||
{
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
struct Account {
|
||||
int id;
|
||||
std::string name;
|
||||
std::string number;
|
||||
QString name;
|
||||
QString number;
|
||||
bool shared;
|
||||
bool blocked;
|
||||
bool _default;
|
||||
|
|
|
@ -27,10 +27,10 @@ struct Category
|
|||
{
|
||||
int id;
|
||||
int parent;
|
||||
std::string name;
|
||||
QString name;
|
||||
QColor backcolor;
|
||||
QColor forecolor;
|
||||
std::string font;
|
||||
QString font;
|
||||
bool fix_cost;
|
||||
|
||||
bool operator == (int catId)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -85,10 +85,10 @@ public:
|
|||
|
||||
Database(const char* filename, KissCount* kiss);
|
||||
|
||||
std::list<std::string> GetUsers();
|
||||
std::list<QString> GetUsers();
|
||||
bool IsValidUser(const QString& user, const QString& password);
|
||||
|
||||
User* LoadUser(const std::string& name);
|
||||
User* LoadUser(const QString& name);
|
||||
void LoadYear(User* user, int year);
|
||||
|
||||
void UpdateOperation(User* user, Operation& op, bool checkTransfert=true);
|
||||
|
@ -106,25 +106,25 @@ public:
|
|||
int AddAccount(User* user, Account& ac);
|
||||
void UpdateAccount(Account& ac);
|
||||
void DeleteAccount(User* user, Account& ac, int replacement);
|
||||
void AddSharedAccount(Account& ac, const std::string& granted);
|
||||
void RemoveSharedAccount(Account& ac, const std::string& granted);
|
||||
void AddSharedAccount(Account& ac, const QString& granted);
|
||||
void RemoveSharedAccount(Account& ac, int granted);
|
||||
|
||||
int AddCategory(User* user, Category& category);
|
||||
void UpdateCategory(Category& category);
|
||||
void DeleteCategory(User* user, Category& category, int replacement);
|
||||
bool LoadCategory(int id, const std::string& name, Category& category);
|
||||
bool LoadCategory(int id, const QString& 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 std::string& password);
|
||||
bool UserExists(const std::string& name);
|
||||
void ChangeName(User* user, const std::string& name);
|
||||
void NewUser(const std::string& name);
|
||||
void ChangePassword(User* user, const QString& password);
|
||||
bool UserExists(const QString& name);
|
||||
void ChangeName(User* user, const QString& name);
|
||||
void NewUser(const QString& name);
|
||||
|
||||
void UpdatePreference(User* user, const std::string& preference);
|
||||
void UpdatePreference(User* user, const QString& preference);
|
||||
|
||||
std::vector<Operation>* Search(User* user, std::string* description, QDate* dateFrom, QDate* dateTo,
|
||||
std::vector<Operation>* Search(User* user, QString* description, QDate* dateFrom, QDate* dateTo,
|
||||
int* amountFrom, int* amountTo,
|
||||
std::vector<int> categories, int types, std::vector<int> accounts, bool wildcards);
|
||||
|
||||
|
@ -138,11 +138,11 @@ public:
|
|||
|
||||
void KillMe(User* user);
|
||||
bool GetOperation(int id, Operation* op);
|
||||
std::map<std::string, std::string> getSharedAccountOwners(int account);
|
||||
int getSharedAccountOwner(int account);
|
||||
std::map<QString, QString> getSharedAccountOwners(int account);
|
||||
QString getSharedAccountOwner(int account);
|
||||
|
||||
std::map<int, int>* GetNotChecked(User* user, int month, int year);
|
||||
std::map<int, int>* GetVirtualAmount(User* user, int month, int year);
|
||||
std::map<int, double>* GetNotChecked(User* user, int month, int year);
|
||||
std::map<int, double>* GetVirtualAmount(User* user, int month, int year);
|
||||
|
||||
void UpdateImportPattern(User* user);
|
||||
|
||||
|
@ -150,12 +150,12 @@ public:
|
|||
|
||||
void CheckDatabaseVersion();
|
||||
|
||||
static QString HashPassword(const QString& password);
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
QSqlDatabase _db;
|
||||
|
||||
void CreateDatabase();
|
||||
QString HashPassword(const QString& password);
|
||||
void LinkOrUnlinkOperation(User* user, Operation& op);
|
||||
};
|
||||
|
||||
|
|
|
@ -17,56 +17,63 @@
|
|||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <QString>
|
||||
#include <QMessageBox>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
#include <QVariant>
|
||||
#include <QSqlRecord>
|
||||
|
||||
#include "Database.hpp"
|
||||
|
||||
#define ON_ERROR(m) \
|
||||
wxMessageBox(wxT(m), _("Error"), wxICON_ERROR | wxOK); \
|
||||
throw std::string(m);
|
||||
#define ON_ERROR(m) \
|
||||
QMessageBox::critical(0, _("Error"), m); \
|
||||
throw m;
|
||||
|
||||
typedef void (*update_func)(wxSQLite3Database& _db) ;
|
||||
typedef void (*update_func)(QSqlDatabase& _db) ;
|
||||
|
||||
#define UPDATE_TABLE(from, to, step) EXECUTE_SQL_UPDATE_WITH_CODE(req, , throw std::string("Error while upgrading from version " from " to version " to ", step " step);, });
|
||||
|
||||
static void Version_1_to_2(wxSQLite3Database& _db)
|
||||
static void Version_1_to_2(QSqlDatabase& _db)
|
||||
{
|
||||
wxString req ;
|
||||
wxSQLite3ResultSet set;
|
||||
QString req ;
|
||||
|
||||
/* Category */
|
||||
req = wxT("ALTER TABLE category ADD fix_cost CHAR(1)");
|
||||
req = "ALTER TABLE category ADD fix_cost CHAR(1)";
|
||||
|
||||
UPDATE_TABLE("1", "2", "1");
|
||||
|
||||
req = wxT("UPDATE category SET fix_cost='0'");
|
||||
req = "UPDATE category SET fix_cost='0'";
|
||||
|
||||
UPDATE_TABLE("1", "2", "2");
|
||||
|
||||
req = wxT("UPDATE category SET fix_cost='1' WHERE id IN (");
|
||||
req += wxT("SELECT MIN(category.id) FROM category, user WHERE category.user = user.id");
|
||||
req += wxT(")");
|
||||
req = "UPDATE category SET fix_cost='1' WHERE id IN (";
|
||||
req += "SELECT MIN(category.id) FROM category, user WHERE category.user = user.id";
|
||||
req += ")";
|
||||
|
||||
UPDATE_TABLE("1", "2", "3");
|
||||
|
||||
/* Account */
|
||||
req = wxT("ALTER TABLE account ADD virtual CHAR(1)");
|
||||
req = "ALTER TABLE account ADD virtual CHAR(1)";
|
||||
|
||||
UPDATE_TABLE("1", "2", "4");
|
||||
|
||||
req = wxT("UPDATE account SET virtual='0'");
|
||||
req = "UPDATE account SET virtual='0'";
|
||||
|
||||
UPDATE_TABLE("1", "2", "5");
|
||||
|
||||
/* Operation */
|
||||
req = wxT("ALTER TABLE operation ADD virtual CHAR(1)");
|
||||
req = "ALTER TABLE operation ADD virtual CHAR(1)";
|
||||
|
||||
UPDATE_TABLE("1", "2", "6");
|
||||
|
||||
req = wxT("UPDATE operation SET virtual='0'");
|
||||
req = "UPDATE operation SET virtual='0'";
|
||||
|
||||
UPDATE_TABLE("1", "2", "7");
|
||||
|
||||
/* Import Pattern */
|
||||
req = wxT("CREATE TABLE import_pattern(id INTEGER PRIMARY KEY, user REFERENCES user(id), description VARCHAR(255), pattern VARCHAR(255), account REFERENCES account(id), category REFERENCES category(id))");
|
||||
req = "CREATE TABLE import_pattern(id INTEGER PRIMARY KEY, user REFERENCES user(id), description VARCHAR(255), pattern VARCHAR(255), account REFERENCES account(id), category REFERENCES category(id))";
|
||||
|
||||
UPDATE_TABLE("1", "2", "8");
|
||||
}
|
||||
|
@ -77,16 +84,21 @@ static update_func updates[] = {
|
|||
|
||||
void Database::CheckDatabaseVersion()
|
||||
{
|
||||
wxString req ;
|
||||
wxSQLite3ResultSet set;
|
||||
QString req ;
|
||||
QSqlRecord set ;
|
||||
QSqlQuery query(_db);
|
||||
long int version;
|
||||
int i;
|
||||
|
||||
req = wxT("SELECT db_version FROM kisscount");
|
||||
req = "SELECT db_version FROM kisscount";
|
||||
|
||||
EXECUTE_SQL_QUERY_WITH_CODE(req, set, , ON_ERROR("Unable to get database version"), {});
|
||||
EXECUTE_SQL_QUERY_WITH_CODE(req, , ON_ERROR("Unable to get database version"), {});
|
||||
|
||||
if (!set.GetAsString(wxT("db_version")).ToLong(&version))
|
||||
query.next();
|
||||
|
||||
set = query.record();
|
||||
|
||||
if (!(version = set.value("db_version").toInt()))
|
||||
{
|
||||
ON_ERROR("Invalid database version");
|
||||
}
|
||||
|
@ -109,11 +121,11 @@ void Database::CheckDatabaseVersion()
|
|||
}
|
||||
}
|
||||
|
||||
wxMessageDialog dialog(0, wxT("You use an old database model. KissCount will try to upgrade it to the lastest version"), wxT("KissCount"), wxICON_INFORMATION | wxOK | wxCANCEL);
|
||||
if (dialog.ShowModal() == wxID_CANCEL)
|
||||
if (QMessageBox::question(0, "KissCount", "You use an old database model. KissCount will try to upgrade it to the lastest version")
|
||||
== QMessageBox::No)
|
||||
throw std::string("can't load this database");
|
||||
|
||||
_db.Begin();
|
||||
_db.transaction();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -122,7 +134,7 @@ void Database::CheckDatabaseVersion()
|
|||
updates[i](_db);
|
||||
}
|
||||
|
||||
req = wxT("UPDATE kisscount SET db_version='") + wxString::Format(wxT("%d"), Database::VERSION) + wxT("'");
|
||||
req = "UPDATE kisscount SET db_version='" + QString::number(Database::VERSION) + "'";
|
||||
|
||||
EXECUTE_SQL_UPDATE_WITH_CODE(req, , throw std::string("Unable to set new database version"), {});
|
||||
}
|
||||
|
@ -130,14 +142,14 @@ void Database::CheckDatabaseVersion()
|
|||
{
|
||||
std::cout << e << std::endl;
|
||||
|
||||
_db.Rollback();
|
||||
_db.rollback();
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
_db.Commit();
|
||||
_db.commit();
|
||||
|
||||
wxMessageBox(wxT("Database upgrade successful !"), _("KissCount"), wxICON_INFORMATION | wxOK);
|
||||
QMessageBox::information(0, "KissCount", "Database upgrade successful !");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define OPERATION_H
|
||||
|
||||
#include <vector>
|
||||
#include <QString>
|
||||
|
||||
struct Operation {
|
||||
int id;
|
||||
|
@ -29,13 +30,13 @@ struct Operation {
|
|||
unsigned int month;
|
||||
unsigned int year;
|
||||
double amount;
|
||||
std::string description;
|
||||
QString description;
|
||||
int category;
|
||||
bool fix_cost;
|
||||
int account;
|
||||
bool checked;
|
||||
int transfert;
|
||||
std::string formula;
|
||||
QString formula;
|
||||
bool meta;
|
||||
bool _virtual;
|
||||
std::vector<int> childs;
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,20 +42,20 @@ public:
|
|||
void InvalidateOperations();
|
||||
|
||||
int _id;
|
||||
std::string _name;
|
||||
std::string _password;
|
||||
QString _name;
|
||||
QString _password;
|
||||
std::vector<Account> _accounts;
|
||||
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* > _operations;
|
||||
std::vector<Category> _categories;
|
||||
std::vector<QFont> _categoriesFonts;
|
||||
std::map<std::string, std::string> _preferences;
|
||||
std::map<std::string, ImportPattern> _importPatterns;
|
||||
std::map<QString, QString> _preferences;
|
||||
std::map<QString, ImportPattern> _importPatterns;
|
||||
|
||||
class AccountNotFound {};
|
||||
|
||||
Category GetCategory(int catId);
|
||||
std::string GetCategoryName(int catId);
|
||||
int GetCategoryId(const std::string& catName);
|
||||
QString GetCategoryName(int catId);
|
||||
int GetCategoryId(const QString& catName);
|
||||
const QFont GetCategoryFont(int catId);
|
||||
void AddCategory(const Category& cat);
|
||||
void UpdateCategory(const Category& cat);
|
||||
|
@ -63,8 +63,9 @@ public:
|
|||
|
||||
|
||||
Account GetAccount(int accountId) throw (AccountNotFound);
|
||||
std::string GetAccountName(int accountId);
|
||||
int GetAccountId(const std::string& accountName);
|
||||
QString GetAccountName(int accountId);
|
||||
int GetAccountId(const QString& accountName);
|
||||
int GetAccountIdFromAccountNumber(const QString& accountNumber);
|
||||
void AddAccount(Account& ac);
|
||||
void UpdateAccount(Account& ac);
|
||||
void DeleteAccount(Account& ac);
|
||||
|
@ -74,7 +75,7 @@ public:
|
|||
int GetAccountsNumber();
|
||||
int GetOperationsNumber(int month, int year);
|
||||
|
||||
std::string GetLanguage();
|
||||
QString GetLanguage();
|
||||
|
||||
void LinkOrUnlinkOperation(Operation& op);
|
||||
|
||||
|
|
|
@ -27,25 +27,25 @@ ExportEngine::~ExportEngine()
|
|||
{
|
||||
}
|
||||
|
||||
bool ExportEngine::HandleFile(const wxString& path, User* user, Database* db, KissCount* kiss)
|
||||
bool ExportEngine::HandleFile(const QString& path, User* user, Database* db, KissCount* kiss)
|
||||
{
|
||||
_path = path;
|
||||
_user = user;
|
||||
_db = db;
|
||||
_kiss = kiss;
|
||||
|
||||
return path.EndsWith(_shortExt) || path.EndsWith(_shortExt.Upper());
|
||||
return path.endsWith(_shortExt) || path.endsWith(_shortExt.toUpper());
|
||||
}
|
||||
|
||||
bool ExportEngine::SaveFile(std::vector<Operation>* operations)
|
||||
{
|
||||
int i;
|
||||
wxString account, category;
|
||||
int account, category;
|
||||
AccountAmount accountAmount;
|
||||
int minMonth = -1, minYear = -1;
|
||||
unsigned int maxMonth = -1, maxYear = -1;
|
||||
unsigned int month, year;
|
||||
std::map<wxString, int>::iterator it;
|
||||
std::map<int, int>::iterator it;
|
||||
|
||||
if (!operations) return 0;
|
||||
|
||||
|
@ -73,10 +73,10 @@ bool ExportEngine::SaveFile(std::vector<Operation>* operations)
|
|||
if ((*operations)[i].month > maxMonth && (*operations)[i].year == maxYear)
|
||||
maxMonth = (*operations)[i].month;
|
||||
|
||||
if (account.Length() && !_accounts.count(account))
|
||||
if (account && !_accounts.count(account))
|
||||
_accounts[account]++;
|
||||
|
||||
if (category.Length() && !_categories.count(category))
|
||||
if (category && !_categories.count(category))
|
||||
_categories[category]++;
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,8 @@ bool ExportEngine::SaveFile(std::vector<Operation>* operations)
|
|||
return true;
|
||||
}
|
||||
|
||||
wxString ExportEngine::GetFileExt()
|
||||
QString ExportEngine::GetFileExt()
|
||||
{
|
||||
return wxGetTranslation(_longExt);
|
||||
return _(_longExt.toStdString().c_str());
|
||||
}
|
||||
|
||||
|
|
|
@ -33,22 +33,22 @@ public:
|
|||
|
||||
// Get supported file extension. Example :
|
||||
// "OFX files (*.ofx)|*.ofx"
|
||||
virtual std::string GetFileExt();
|
||||
virtual QString GetFileExt();
|
||||
|
||||
// Handle the file
|
||||
virtual bool HandleFile(const std::string& path, User* user, Database* db, KissCount* kiss)=0;
|
||||
virtual bool HandleFile(const QString& path, User* user, Database* db, KissCount* kiss)=0;
|
||||
|
||||
// Save operations (ExportEngin pre fill _accounts, _categories and _accountAmounts)
|
||||
virtual bool SaveFile(std::vector<Operation>* operations)=0;
|
||||
|
||||
protected:
|
||||
std::string _path;
|
||||
QString _path;
|
||||
Database* _db;
|
||||
User* _user;
|
||||
KissCount* _kiss;
|
||||
|
||||
std::string _shortExt;
|
||||
std::string _longExt;
|
||||
QString _shortExt;
|
||||
QString _longExt;
|
||||
|
||||
std::map<int, int> _accounts;
|
||||
std::map<int, int> _categories;
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <libxml/encoding.h>
|
||||
#include <libxml/xmlwriter.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "XMLExportEngine.hpp"
|
||||
|
||||
static XMLExportEngine xmlExportEngine;
|
||||
|
@ -28,7 +30,7 @@ XMLExportEngine::XMLExportEngine()
|
|||
{
|
||||
KissCount::RegisterExportEngine(this);
|
||||
|
||||
_shortExt = wxT("xml");
|
||||
_shortExt = "xml";
|
||||
_longExt = _("XML files (*.xml)|*.xml");
|
||||
}
|
||||
|
||||
|
@ -36,7 +38,7 @@ XMLExportEngine::~XMLExportEngine()
|
|||
{
|
||||
}
|
||||
|
||||
bool XMLExportEngine::HandleFile(const wxString& path, User* user, Database* db, KissCount* kiss)
|
||||
bool XMLExportEngine::HandleFile(const QString& path, User* user, Database* db, KissCount* kiss)
|
||||
{
|
||||
return ExportEngine::HandleFile(path, user, db, kiss);
|
||||
}
|
||||
|
@ -44,7 +46,7 @@ bool XMLExportEngine::HandleFile(const wxString& path, User* user, Database* db,
|
|||
bool XMLExportEngine::SaveAccounts()
|
||||
{
|
||||
Account account;
|
||||
std::map<wxString, int>::iterator it;
|
||||
std::map<int, int>::iterator it;
|
||||
|
||||
for(it=_accounts.begin(); it!=_accounts.end(); it++)
|
||||
{
|
||||
|
@ -54,9 +56,9 @@ bool XMLExportEngine::SaveAccounts()
|
|||
ESCAPE_CHARS(account.number);
|
||||
|
||||
xmlTextWriterStartElement(_writer, (const xmlChar*) "account");
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) account.id.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) account.name.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "number", (const xmlChar*) account.number.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) QString::number(account.id).toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) account.name.toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "number", (const xmlChar*) account.number.toStdString().c_str());
|
||||
// xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "shared", (const xmlChar*) (account.shared ? "1" : "0"));
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "blocked", (const xmlChar*) (account.blocked ? "1" : "0"));
|
||||
// xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "default", (const xmlChar*) (account._default ? "1" : "0"));
|
||||
|
@ -75,7 +77,7 @@ bool XMLExportEngine::SaveAccountAmounts()
|
|||
for(it=_accountAmounts.begin(); it!=_accountAmounts.end(); it++)
|
||||
{
|
||||
xmlTextWriterStartElement(_writer, (const xmlChar*) "account_amount");
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "account", (const xmlChar*) it->first.account.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "account", (const xmlChar*) QString::number(it->first.account).toStdString().c_str());
|
||||
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "month", "%d", it->first.month);
|
||||
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "year", "%d", it->first.year);
|
||||
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "amount", "%.2lf", it->second);
|
||||
|
@ -88,7 +90,7 @@ bool XMLExportEngine::SaveAccountAmounts()
|
|||
bool XMLExportEngine::SaveCategories()
|
||||
{
|
||||
Category category;
|
||||
std::map<wxString, int>::iterator it;
|
||||
std::map<int, int>::iterator it;
|
||||
int rgb;
|
||||
|
||||
for(it=_categories.begin(); it!=_categories.end(); it++)
|
||||
|
@ -98,16 +100,16 @@ bool XMLExportEngine::SaveCategories()
|
|||
ESCAPE_CHARS(category.name);
|
||||
|
||||
xmlTextWriterStartElement(_writer, (const xmlChar*) "category");
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) category.id.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) category.name.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "font", (const xmlChar*) category.font.utf8_str().data());
|
||||
rgb = category.backcolor.Blue();
|
||||
rgb |= category.backcolor.Green() << 8;
|
||||
rgb |= category.backcolor.Red() << 16;
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) QString::number(category.id).toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) category.name.toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "font", (const xmlChar*) category.font.toStdString().c_str());
|
||||
rgb = category.backcolor.blue();
|
||||
rgb |= category.backcolor.green() << 8;
|
||||
rgb |= category.backcolor.red() << 16;
|
||||
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "backcolor", "0x%08X", rgb);
|
||||
rgb = category.forecolor.Blue();
|
||||
rgb |= category.forecolor.Green() << 8;
|
||||
rgb |= category.forecolor.Red() << 16;
|
||||
rgb = category.forecolor.blue();
|
||||
rgb |= category.forecolor.green() << 8;
|
||||
rgb |= category.forecolor.red() << 16;
|
||||
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "forecolor", "0x%08X", rgb);
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "fix_cost", (const xmlChar*) (category.fix_cost ? "1" : "0"));
|
||||
xmlTextWriterEndElement(_writer);
|
||||
|
@ -125,19 +127,19 @@ bool XMLExportEngine::SaveOperations(std::vector<Operation>* operations)
|
|||
ESCAPE_CHARS(it->description);
|
||||
|
||||
xmlTextWriterStartElement(_writer, (const xmlChar*) "operation");
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) it->id.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "parent", (const xmlChar*) it->parent.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) QString::number(it->id).toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "parent", (const xmlChar*) QString::number(it->parent).toStdString().c_str());
|
||||
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "day", "%d", it->day);
|
||||
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "month", "%d", it->month);
|
||||
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "year", "%d", it->year);
|
||||
xmlTextWriterWriteFormatAttribute(_writer, (const xmlChar*) "amount", "%.2lf", it->amount);
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "description", (const xmlChar*) it->description.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "category", (const xmlChar*) it->category.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "description", (const xmlChar*) it->description.toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "category", (const xmlChar*) QString::number(it->category).toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "fix_cost", (const xmlChar*) (it->fix_cost ? "1" : "0"));
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "account", (const xmlChar*) it->account.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "account", (const xmlChar*) QString::number(it->account).toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "checked", (const xmlChar*) (it->checked ? "1" : "0"));
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "transfert", (const xmlChar*) it->transfert.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "formula", (const xmlChar*) it->formula.utf8_str().data());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "transfert", (const xmlChar*) QString::number(it->transfert).toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "formula", (const xmlChar*) it->formula.toStdString().c_str());
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "meta", (const xmlChar*) (it->meta ? "1" : "0"));
|
||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "virtual", (const xmlChar*) (it->_virtual ? "1" : "0"));
|
||||
xmlTextWriterEndElement(_writer);
|
||||
|
@ -154,7 +156,7 @@ bool XMLExportEngine::SaveFile(std::vector<Operation>* operations)
|
|||
|
||||
if (!rc) return false;
|
||||
|
||||
_writer = xmlNewTextWriterFilename(_path.mb_str(), 0);
|
||||
_writer = xmlNewTextWriterFilename(_path.toStdString().c_str(), 0);
|
||||
|
||||
if (!_writer)
|
||||
{
|
||||