wip
This commit is contained in:
parent
f73c80fc6a
commit
1f50e15d39
4
init.sql
4
init.sql
|
@ -1,7 +1,7 @@
|
||||||
CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR(255), password VARCHAR(255));
|
CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR(255), password VARCHAR(255));
|
||||||
CREATE TABLE account(id INTEGER PRIMARY KEY, user REFERENCES user(id), name VARCHAR(255), number VARCHAR(255), shared CHAR(1), default_account CHAR(1));
|
CREATE TABLE account(id INTEGER PRIMARY KEY, user REFERENCES user(id), name VARCHAR(255), number VARCHAR(255), shared CHAR(1), default_account CHAR(1));
|
||||||
CREATE TABLE account_amount(id INTEGER PRIMARY KEY, account REFERENCES account(id), year INTEGER, month INTEGER, amount INTEGER);
|
CREATE TABLE account_amount(id INTEGER PRIMARY KEY, account REFERENCES account(id), year INTEGER, month INTEGER, amount FLOAT);
|
||||||
CREATE TABLE operation(id INTEGER PRIMARY KEY, user REFERENCES user(id), account REFERENCES account(id), year INTEGER, month INTEGER, day INTEGER, amount INTEGER, description VARCHAR(255), category REFERENCES preference(id), fix_cost CHAR(1));
|
CREATE TABLE operation(id INTEGER PRIMARY KEY, user REFERENCES user(id), account REFERENCES account(id), year INTEGER, month INTEGER, day INTEGER, amount FLOAT, description VARCHAR(255), category REFERENCES preference(id), fix_cost CHAR(1));
|
||||||
CREATE TABLE preference(id INTEGER PRIMARY KEY, user REFERENCES user(id), type VARCHAR(255), name VARCHAR(255), value VARCHAR(255));
|
CREATE TABLE preference(id INTEGER PRIMARY KEY, user REFERENCES user(id), type VARCHAR(255), name VARCHAR(255), value VARCHAR(255));
|
||||||
CREATE TABLE default_preference(id INTEGER PRIMARY KEY, type VARCHAR(255), name VARCHAR(255), value VARCHAR(255));
|
CREATE TABLE default_preference(id INTEGER PRIMARY KEY, type VARCHAR(255), name VARCHAR(255), value VARCHAR(255));
|
||||||
INSERT INTO default_preference ("type", "name", "value") VALUES ("category", "name", "Fixe");
|
INSERT INTO default_preference ("type", "name", "value") VALUES ("category", "name", "Fixe");
|
||||||
|
|
|
@ -223,7 +223,7 @@ void Database::LoadYear(User* user, int year)
|
||||||
op.day = set.GetInt(_("day"));
|
op.day = set.GetInt(_("day"));
|
||||||
op.month = set.GetInt(_("month"));
|
op.month = set.GetInt(_("month"));
|
||||||
op.year = set.GetInt(_("year"));
|
op.year = set.GetInt(_("year"));
|
||||||
op.amount = set.GetInt(_("amount"));
|
op.amount = set.GetDouble(_("amount"));
|
||||||
op.description = set.GetAsString(_("description"));
|
op.description = set.GetAsString(_("description"));
|
||||||
op.category = set.GetAsString(_("category"));
|
op.category = set.GetAsString(_("category"));
|
||||||
op.fix_cost = set.GetBool(_("fix_cost"));
|
op.fix_cost = set.GetBool(_("fix_cost"));
|
||||||
|
|
|
@ -27,3 +27,8 @@ wxString User::GetAccountName(wxString accountId)
|
||||||
return _("Unknown") ;
|
return _("Unknown") ;
|
||||||
return _accounts[accountId].name;
|
return _accounts[accountId].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int User::GetCategoriesNumber()
|
||||||
|
{
|
||||||
|
return _preferences._categories.size();
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct operation {
|
||||||
unsigned int day;
|
unsigned int day;
|
||||||
unsigned int month;
|
unsigned int month;
|
||||||
unsigned int year;
|
unsigned int year;
|
||||||
int amount;
|
double amount;
|
||||||
wxString description;
|
wxString description;
|
||||||
wxString category;
|
wxString category;
|
||||||
bool fix_cost;
|
bool fix_cost;
|
||||||
|
@ -40,6 +40,7 @@ public:
|
||||||
|
|
||||||
wxString GetCategoryName(wxString catId);
|
wxString GetCategoryName(wxString catId);
|
||||||
wxString GetAccountName(wxString accountId);
|
wxString GetAccountName(wxString accountId);
|
||||||
|
int GetCategoriesNumber();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,31 +6,57 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
||||||
{
|
{
|
||||||
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxChartPanel* chart ;
|
wxChartPanel* chart ;
|
||||||
double data[] = {1.0, 2.0, 3.0} ;
|
int i ;
|
||||||
wxString cats[] = {_("cat1"), _("cat2"), _("cat3")};
|
User* user = _kiss->GetUser();
|
||||||
wxColour colours[] = {OWN_CYAN, OWN_YELLOW, OWN_GREEN} ;
|
std::map<wxString, Account>::iterator accountIt;
|
||||||
double value;
|
std::map<wxString, wxString>::iterator it;
|
||||||
|
wxColour categoryColors[] = {wxColour(0x00, 0x45, 0x86),
|
||||||
|
wxColour(0xFF, 0x3E, 0x0E),
|
||||||
|
wxColour(0xFF, 0xD3, 0x20),
|
||||||
|
wxColour(0x58, 0x9D, 0x1B),
|
||||||
|
wxColour(0x7E, 0x00, 0x21),
|
||||||
|
wxColour(0x83, 0xCC, 0xFF),
|
||||||
|
wxColour(0x31, 0x40, 0x04),
|
||||||
|
wxColour(0xB0, 0xCF, 0x00),
|
||||||
|
wxColour(0x4B, 0x1F, 0x6F),
|
||||||
|
wxColour(0xFF, 0x93, 0x0E),
|
||||||
|
wxColour(0xC5, 0x00, 0x0D),
|
||||||
|
wxColour(0x00, 0x84, 0xD1)};
|
||||||
SetSizer(hbox);
|
SetSizer(hbox);
|
||||||
|
|
||||||
|
ColorScheme* colorScheme = new ColorScheme(categoryColors, WXSIZEOF(categoryColors));
|
||||||
|
|
||||||
_pie = new PiePlot();
|
_pie = new PiePlot();
|
||||||
CategorySimpleDataset* set = new CategorySimpleDataset(cats, 3);
|
|
||||||
value = 1.0;
|
|
||||||
//set->AddSerie(new CategorySerie(_("cat1"), &value, 1)) ;
|
|
||||||
set->AddSerie(_("série 1"), data, 3);
|
|
||||||
// value = 2.0;
|
|
||||||
// set->AddSerie(new CategorySerie(_("cat2"), &value, 1)) ;
|
|
||||||
// value = 3.0;
|
|
||||||
// set->AddSerie(new CategorySerie(_("cat3"), &value, 1)) ;
|
|
||||||
// set->SetRenderer(new XYLineRenderer());
|
|
||||||
// set serie names to be displayed on legend
|
|
||||||
//dataset->SetSerieName(0, wxT("Serie 0"));
|
|
||||||
//dataset->SetSerieName(1, wxT("Serie 1"));
|
|
||||||
|
|
||||||
_pie->SetDataset(set);
|
_accounts = new wxString[user->_accounts.size()+1];
|
||||||
_pie->SetColorScheme(new ColorScheme(colours, 3));
|
_accounts[0] = _("Unknown");
|
||||||
|
for (i=1,
|
||||||
|
accountIt = user->_accounts.begin();
|
||||||
|
accountIt != user->_accounts.end();
|
||||||
|
accountIt++, i++)
|
||||||
|
_accounts[i] = user->_accounts[accountIt->first].name;
|
||||||
|
|
||||||
// set legend
|
_categories = new wxString[user->GetCategoriesNumber()+1] ;
|
||||||
_pie->SetLegend(new Legend(wxCENTER, wxTOP));
|
_categories[0] = _("Unknown");
|
||||||
|
_categoriesIndexes[_("Unknown")] = 0;
|
||||||
|
for(i=1, it = user->_preferences._categories.begin(); it != user->_preferences._categories.end(); it++, i++)
|
||||||
|
{
|
||||||
|
_categories[i] = it->second ;
|
||||||
|
_categoriesIndexes[it->second] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dataset = new CategorySimpleDataset(_categories, user->GetCategoriesNumber()+1);
|
||||||
|
|
||||||
|
_categoriesValues = new double[user->GetCategoriesNumber()+1];
|
||||||
|
for(i=0; i<user->GetCategoriesNumber()+1; i++)
|
||||||
|
_categoriesValues[i] = 1.0;
|
||||||
|
|
||||||
|
_dataset->AddSerie(_("Serie 1"), _categoriesValues, user->GetCategoriesNumber()+1);
|
||||||
|
_dataset->SetRenderer(new CategoryRenderer(*colorScheme));
|
||||||
|
_pie->SetDataset(_dataset);
|
||||||
|
_pie->SetColorScheme(colorScheme);
|
||||||
|
|
||||||
|
_pie->SetLegend(new Legend(wxBOTTOM, wxCENTER));
|
||||||
|
|
||||||
_grid = new GridAccount(this, -1);
|
_grid = new GridAccount(this, -1);
|
||||||
_grid->CreateGrid(1, NUMBER_COLS);
|
_grid->CreateGrid(1, NUMBER_COLS);
|
||||||
|
@ -41,7 +67,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
||||||
chart->Fit();
|
chart->Fit();
|
||||||
chart->Layout();
|
chart->Layout();
|
||||||
chart->SetMinSize(// chart->GetSize()
|
chart->SetMinSize(// chart->GetSize()
|
||||||
wxSize(200,200));
|
wxSize(200,500));
|
||||||
hbox->Add(&_tree, 0);
|
hbox->Add(&_tree, 0);
|
||||||
hbox->Add(_grid, 0);
|
hbox->Add(_grid, 0);
|
||||||
hbox->Add(chart, 0);
|
hbox->Add(chart, 0);
|
||||||
|
@ -52,6 +78,13 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
|
||||||
SetMinSize(GetSize());
|
SetMinSize(GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AccountPanel::~AccountPanel()
|
||||||
|
{
|
||||||
|
delete[] _categoriesValues;
|
||||||
|
delete[] _categories;
|
||||||
|
delete[] _accounts;
|
||||||
|
}
|
||||||
|
|
||||||
void AccountPanel::ChangeUser()
|
void AccountPanel::ChangeUser()
|
||||||
{
|
{
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
|
@ -79,7 +112,8 @@ void AccountPanel::LoadYear(int year)
|
||||||
wxDateTime curDate;
|
wxDateTime curDate;
|
||||||
wxTreeItemId parentNode, curMonthNode;
|
wxTreeItemId parentNode, curMonthNode;
|
||||||
|
|
||||||
if (user->_operations[year] != NULL)
|
_curYear = year ;
|
||||||
|
if (user->_operations[year] != NULL)
|
||||||
{
|
{
|
||||||
ShowMonth(year, 0);
|
ShowMonth(year, 0);
|
||||||
return;
|
return;
|
||||||
|
@ -126,15 +160,14 @@ void AccountPanel::ShowMonth(int year, int month)
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
wxFont font(DEFAULT_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, DEFAULT_FONT);
|
wxFont font(DEFAULT_FONT_SIZE, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, DEFAULT_FONT);
|
||||||
std::map<wxString, wxString>::iterator categoryIt;
|
std::map<wxString, wxString>::iterator categoryIt;
|
||||||
std::map<wxString, Account>::iterator accountIt;
|
|
||||||
wxGridCellChoiceEditor* categoryEditor, *accountEditor;
|
wxGridCellChoiceEditor* categoryEditor, *accountEditor;
|
||||||
wxString* categories, *accounts;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
_curMonth = month;
|
||||||
_wxUI->SetTitle(user->_name + _(" - ") + months[month]);
|
_wxUI->SetTitle(user->_name + _(" - ") + months[month]);
|
||||||
|
|
||||||
// Operations are ordered
|
// Operations are ordered
|
||||||
operations = (*user->_operations[year])[month];
|
_curOperations = &((*user->_operations[year])[month]);
|
||||||
|
|
||||||
_grid->CreateGrid(1, NUMBER_COLS);
|
_grid->CreateGrid(1, NUMBER_COLS);
|
||||||
// Creating headers
|
// Creating headers
|
||||||
|
@ -158,24 +191,7 @@ void AccountPanel::ShowMonth(int year, int month)
|
||||||
// InsertRows (int pos=0, int numRows=1, bool updateLabels=true);
|
// InsertRows (int pos=0, int numRows=1, bool updateLabels=true);
|
||||||
// SetReadOnly(row, col, bool)
|
// SetReadOnly(row, col, bool)
|
||||||
|
|
||||||
categories = new wxString[user->_preferences._categories.size()+1];
|
it = _curOperations->begin();
|
||||||
categories[0] = _("Unknown");
|
|
||||||
for (i=1,
|
|
||||||
categoryIt = user->_preferences._categories.begin();
|
|
||||||
categoryIt != user->_preferences._categories.end();
|
|
||||||
categoryIt++, i++)
|
|
||||||
categories[i] = user->_preferences._categories[categoryIt->first];
|
|
||||||
|
|
||||||
accounts = new wxString[user->_accounts.size()+1];
|
|
||||||
accounts[0] = _("Unknown");
|
|
||||||
for (i=1,
|
|
||||||
accountIt = user->_accounts.begin();
|
|
||||||
accountIt != user->_accounts.end();
|
|
||||||
accountIt++, i++)
|
|
||||||
accounts[i] = user->_accounts[accountIt->first].name;
|
|
||||||
|
|
||||||
|
|
||||||
it = operations.begin();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
struct operation {
|
struct operation {
|
||||||
|
@ -199,16 +215,15 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
_grid->SetCellValue(curLine, DESCRIPTION, it->description);
|
_grid->SetCellValue(curLine, DESCRIPTION, it->description);
|
||||||
_grid->SetCellValue(curLine, DATE, wxString::Format(wxT("%02d/%02d/%d"), it->day+1, it->month+1, it->year));
|
_grid->SetCellValue(curLine, DATE, wxString::Format(wxT("%02d/%02d/%d"), it->day+1, it->month+1, it->year));
|
||||||
if (it->amount < 0)
|
if (it->amount < 0)
|
||||||
_grid->SetCellValue(curLine, DEBIT, wxString::Format(wxT("%d"), -it->amount));
|
_grid->SetCellValue(curLine, DEBIT, wxString::Format(wxT("%.2lf"), -it->amount));
|
||||||
else
|
else
|
||||||
_grid->SetCellValue(curLine, CREDIT, wxString::Format(wxT("%d"), it->amount));
|
_grid->SetCellValue(curLine, CREDIT, wxString::Format(wxT("%.2lf"), it->amount));
|
||||||
_grid->SetCellValue(curLine, CATEGORY, it->category);
|
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellFloatEditor(-1, 2));
|
||||||
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellNumberEditor());
|
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellFloatEditor(-1, 2));
|
||||||
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellNumberEditor());
|
categoryEditor = new wxGridCellChoiceEditor(user->GetCategoriesNumber()+1, _categories, false);
|
||||||
categoryEditor = new wxGridCellChoiceEditor(user->_preferences._categories.size()+1, categories, false);
|
|
||||||
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
|
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
|
||||||
_grid->SetCellValue(curLine, CATEGORY, user->GetCategoryName(it->category));
|
_grid->SetCellValue(curLine, CATEGORY, user->GetCategoryName(it->category));
|
||||||
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, accounts, false);
|
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, _accounts, false);
|
||||||
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
||||||
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
|
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
|
||||||
it++;
|
it++;
|
||||||
|
@ -217,16 +232,16 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
_grid->AppendRows();
|
_grid->AppendRows();
|
||||||
curLine++;
|
curLine++;
|
||||||
SET_ROW_COLOR(curLine, OWN_YELLOW);
|
SET_ROW_COLOR(curLine, OWN_YELLOW);
|
||||||
categoryEditor = new wxGridCellChoiceEditor(user->_preferences._categories.size()+1, categories, false);
|
categoryEditor = new wxGridCellChoiceEditor(user->_preferences._categories.size()+1, _categories, false);
|
||||||
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
|
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
|
||||||
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellNumberEditor());
|
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellFloatEditor(-1, 2));
|
||||||
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellNumberEditor());
|
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellFloatEditor(-1, 2));
|
||||||
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, accounts, false);
|
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, _accounts, false);
|
||||||
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
||||||
|
|
||||||
_grid->_fixCosts = ++fixCosts;
|
_grid->_fixCosts = ++fixCosts;
|
||||||
|
|
||||||
for (; it != operations.begin(); it++)
|
for (; it != _curOperations->begin(); it++)
|
||||||
{
|
{
|
||||||
_grid->AppendRows();
|
_grid->AppendRows();
|
||||||
curLine++;
|
curLine++;
|
||||||
|
@ -234,16 +249,15 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
_grid->SetCellValue(curLine, DESCRIPTION, it->description);
|
_grid->SetCellValue(curLine, DESCRIPTION, it->description);
|
||||||
_grid->SetCellValue(curLine, DATE, wxString::Format(wxT("%02d/%02d/%d"), it->day+1, it->month+1, it->year));
|
_grid->SetCellValue(curLine, DATE, wxString::Format(wxT("%02d/%02d/%d"), it->day+1, it->month+1, it->year));
|
||||||
if (it->amount < 0)
|
if (it->amount < 0)
|
||||||
_grid->SetCellValue(curLine, DEBIT, wxString::Format(wxT("%d"), -it->amount));
|
_grid->SetCellValue(curLine, DEBIT, wxString::Format(wxT("%.2lf"), -it->amount));
|
||||||
else
|
else
|
||||||
_grid->SetCellValue(curLine, CREDIT, wxString::Format(wxT("%d"), it->amount));
|
_grid->SetCellValue(curLine, CREDIT, wxString::Format(wxT("%.2lf"), it->amount));
|
||||||
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellNumberEditor());
|
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellFloatEditor(-1, 2));
|
||||||
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellNumberEditor());
|
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellFloatEditor(-1, 2));
|
||||||
_grid->SetCellValue(curLine, CATEGORY, it->category);
|
categoryEditor = new wxGridCellChoiceEditor(user->GetCategoriesNumber()+1, _categories, false);
|
||||||
categoryEditor = new wxGridCellChoiceEditor(user->_preferences._categories.size()+1, categories, false);
|
|
||||||
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
|
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
|
||||||
_grid->SetCellValue(curLine, CATEGORY, user->GetCategoryName(it->category));
|
_grid->SetCellValue(curLine, CATEGORY, user->GetCategoryName(it->category));
|
||||||
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, accounts, false);
|
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, _accounts, false);
|
||||||
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
||||||
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
|
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
|
||||||
it++;
|
it++;
|
||||||
|
@ -252,20 +266,41 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS};
|
||||||
_grid->AppendRows();
|
_grid->AppendRows();
|
||||||
curLine++;
|
curLine++;
|
||||||
SET_ROW_COLOR(curLine, OWN_GREEN);
|
SET_ROW_COLOR(curLine, OWN_GREEN);
|
||||||
categoryEditor = new wxGridCellChoiceEditor(user->_preferences._categories.size()+1, categories, false);
|
categoryEditor = new wxGridCellChoiceEditor(user->_preferences._categories.size()+1, _categories, false);
|
||||||
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
|
_grid->SetCellEditor(curLine, CATEGORY, categoryEditor);
|
||||||
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellNumberEditor());
|
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellFloatEditor(-1, 2));
|
||||||
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellNumberEditor());
|
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellFloatEditor(-1, 2));
|
||||||
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, accounts, false);
|
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, _accounts, false);
|
||||||
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
||||||
|
|
||||||
delete[] categories;
|
|
||||||
delete[] accounts;
|
|
||||||
|
|
||||||
_grid->AutoSizeColumn(CATEGORY, false);
|
_grid->AutoSizeColumn(CATEGORY, false);
|
||||||
_grid->AutoSizeColumn(ACCOUNT, false);
|
_grid->AutoSizeColumn(ACCOUNT, false);
|
||||||
|
|
||||||
|
UpdateChart();
|
||||||
|
|
||||||
Fit();
|
Fit();
|
||||||
SetMinSize(GetSize());
|
SetMinSize(GetSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccountPanel::UpdateChart()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
User* user = _kiss->GetUser();
|
||||||
|
std::list<operation>::iterator it;
|
||||||
|
|
||||||
|
//_dataset->BeginUpdate();
|
||||||
|
for (i=0; i<user->GetCategoriesNumber(); i++)
|
||||||
|
_categoriesValues[i] = 0.0;
|
||||||
|
|
||||||
|
// _categoriesValues[0] += 1.0;
|
||||||
|
// _categoriesValues[1] += 2.0;
|
||||||
|
// _categoriesValues[2] += 3.0;
|
||||||
|
for (it=_curOperations->begin(); it!=_curOperations->end(); it++)
|
||||||
|
{
|
||||||
|
if (it->amount > 0)
|
||||||
|
_categoriesValues[_categoriesIndexes[user->GetCategoryName(it->category)]] += it->amount ;
|
||||||
|
//std::cout << _categoriesValues[_categoriesIndexes[it->category]] << "\n";
|
||||||
|
}
|
||||||
|
//_dataset->EndUpdate();
|
||||||
|
_pie->DatasetChanged(_dataset);
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ class AccountPanel: public wxPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AccountPanel(KissCount* kiss, wxUI *parent);
|
AccountPanel(KissCount* kiss, wxUI *parent);
|
||||||
|
~AccountPanel();
|
||||||
void ChangeUser();
|
void ChangeUser();
|
||||||
void LoadYear(int year);
|
void LoadYear(int year);
|
||||||
void ShowMonth(int year, int month);
|
void ShowMonth(int year, int month);
|
||||||
|
@ -39,6 +40,14 @@ private:
|
||||||
wxTreeCtrl _tree;
|
wxTreeCtrl _tree;
|
||||||
GridAccount* _grid;
|
GridAccount* _grid;
|
||||||
PiePlot* _pie;
|
PiePlot* _pie;
|
||||||
|
double *_categoriesValues;
|
||||||
|
std::map<wxString, int> _categoriesIndexes;
|
||||||
|
std::list<operation>* _curOperations;
|
||||||
|
int _curMonth, _curYear;
|
||||||
|
wxString* _categories, *_accounts;
|
||||||
|
CategorySimpleDataset* _dataset;
|
||||||
|
|
||||||
|
void UpdateChart();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,10 +11,10 @@ END_EVENT_TABLE()
|
||||||
ButtonPanel::ButtonPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent)
|
ButtonPanel::ButtonPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent)
|
||||||
{
|
{
|
||||||
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||||
_account = new wxBitmapButton(this, ID_BUTTON_ACCOUNT, wxBitmap(_(ACCOUNT_ICON)));
|
_account = new wxBitmapButton(this, ID_BUTTON_ACCOUNT, wxBitmap(_(ACCOUNT_ICON)), wxDefaultPosition, wxSize(128, 128));
|
||||||
_stats = new wxBitmapButton(this, ID_BUTTON_STATS, wxBitmap(_(STATS_ICON)));
|
_stats = new wxBitmapButton(this, ID_BUTTON_STATS, wxBitmap(_(STATS_ICON)), wxDefaultPosition, wxSize(128, 128));
|
||||||
_prefs = new wxBitmapButton(this, ID_BUTTON_PREFS, wxBitmap(_(PREFS_ICON)));
|
_prefs = new wxBitmapButton(this, ID_BUTTON_PREFS, wxBitmap(_(PREFS_ICON)), wxDefaultPosition, wxSize(128, 128));
|
||||||
_changeUser = new wxBitmapButton(this, ID_BUTTON_CHANGE_USER, wxBitmap(_(CHANGE_USER_ICON)));
|
_changeUser = new wxBitmapButton(this, ID_BUTTON_CHANGE_USER, wxBitmap(_(CHANGE_USER_ICON)), wxDefaultPosition, wxSize(128, 128));
|
||||||
|
|
||||||
SetSizer(hbox);
|
SetSizer(hbox);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user