Work on AccountPanel : add treeview
This commit is contained in:
parent
633bd15fdd
commit
fc9b06c507
|
@ -1011,7 +1011,7 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||||
{
|
{
|
||||||
QString req, req2, reqUnion;
|
QString req, req2, reqUnion;
|
||||||
QSqlRecord set;
|
QSqlRecord set;
|
||||||
QSqlQuery query(_db);
|
QSqlQuery query(_db),query2(_db);
|
||||||
std::vector<Account>::iterator it;
|
std::vector<Account>::iterator it;
|
||||||
std::map<int, std::vector<int> > res;
|
std::map<int, std::vector<int> > res;
|
||||||
int year;
|
int year;
|
||||||
|
@ -1041,9 +1041,10 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||||
reqUnion = req + " UNION " + req2;
|
reqUnion = req + " UNION " + req2;
|
||||||
EXECUTE_SQL_QUERY(reqUnion, res);
|
EXECUTE_SQL_QUERY(reqUnion, res);
|
||||||
|
|
||||||
while (query.next())
|
query2 = query;
|
||||||
|
while (query2.next())
|
||||||
{
|
{
|
||||||
set = query.record();
|
set = query2.record();
|
||||||
|
|
||||||
year = set.value("year").toInt();
|
year = set.value("year").toInt();
|
||||||
|
|
||||||
|
@ -1081,7 +1082,7 @@ std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||||
}
|
}
|
||||||
query.clear();
|
query.clear();
|
||||||
}
|
}
|
||||||
query.clear();
|
query2.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -27,28 +27,25 @@ enum {CUR_CREDIT, CUR_DEBIT, TOTAL_CREDIT, TOTAL_DEBIT, BALANCE, STATS_ROW, CATS
|
||||||
|
|
||||||
enum {VIRTUAL_MODE=0, REAL_MODE, CHECK_MODE};
|
enum {VIRTUAL_MODE=0, REAL_MODE, CHECK_MODE};
|
||||||
|
|
||||||
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _curMonth(-1), _curYear(-1) //, _tree(this, CALENDAR_TREE_ID, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT)
|
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _curMonth(-1), _curYear(-1)
|
||||||
{
|
{
|
||||||
// wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
QHBoxLayout *hbox = new QHBoxLayout;
|
||||||
// wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL);
|
QHBoxLayout *hbox2 = new QHBoxLayout;
|
||||||
// wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
QVBoxLayout *vbox = new QVBoxLayout;
|
||||||
// wxBoxSizer *vbox2 = new wxBoxSizer(wxVERTICAL);
|
QVBoxLayout *vbox2 = new QVBoxLayout;
|
||||||
// wxBoxSizer *vbox3 = new wxBoxSizer(wxVERTICAL);
|
QVBoxLayout *vbox3 = new QVBoxLayout;
|
||||||
// wxChartPanel* chart ;
|
// wxChartPanel* chart ;
|
||||||
// int i ;
|
int i ;
|
||||||
// User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
// std::vector<Account>::iterator accountIt;
|
std::vector<Account>::iterator accountIt;
|
||||||
// std::vector<Category>::iterator categoryIt;
|
std::vector<Category>::iterator categoryIt;
|
||||||
// DEFAULT_FONT(font);
|
DEFAULT_FONT(font);
|
||||||
// wxRect rect = wxDisplay().GetGeometry();
|
int nbCategories;
|
||||||
// int nbCategories;
|
|
||||||
|
|
||||||
// SetSizer(hbox);
|
setLayout(hbox);
|
||||||
|
|
||||||
_categoriesValues=0;
|
|
||||||
_categories=0;
|
|
||||||
_accounts=0;
|
|
||||||
|
|
||||||
|
_tree = new QTreeWidget(this);
|
||||||
|
_tree->headerItem()->setHidden(true);
|
||||||
// ColorScheme* colorScheme = new ColorScheme(wxUI::categoryColors, WXSIZEOF(wxUI::categoryColors));
|
// ColorScheme* colorScheme = new ColorScheme(wxUI::categoryColors, WXSIZEOF(wxUI::categoryColors));
|
||||||
|
|
||||||
// _pie = new PiePlot();
|
// _pie = new PiePlot();
|
||||||
|
@ -59,27 +56,27 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
// _calendar->EnableHolidayDisplay(false);
|
// _calendar->EnableHolidayDisplay(false);
|
||||||
// _calendar->Enable(false);
|
// _calendar->Enable(false);
|
||||||
|
|
||||||
// _accounts = new wxString[user->GetAccountsNumber()];
|
_accounts = new QString[user->GetAccountsNumber()];
|
||||||
// for (i=0,
|
for (i=0,
|
||||||
// accountIt = user->_accounts.begin();
|
accountIt = user->_accounts.begin();
|
||||||
// accountIt != user->_accounts.end();
|
accountIt != user->_accounts.end();
|
||||||
// accountIt++, i++)
|
accountIt++, i++)
|
||||||
// _accounts[i] = accountIt->name;
|
_accounts[i] = accountIt->name;
|
||||||
|
|
||||||
// _categories = new wxString[user->GetCategoriesNumber()] ;
|
_categories = new QString[user->GetCategoriesNumber()] ;
|
||||||
// for(i=0, categoryIt = user->_categories.begin();
|
for(i=0, categoryIt = user->_categories.begin();
|
||||||
// categoryIt != user->_categories.end();
|
categoryIt != user->_categories.end();
|
||||||
// categoryIt++, i++)
|
categoryIt++, i++)
|
||||||
// {
|
{
|
||||||
// _categories[i] = wxGetTranslation(categoryIt->name) ;
|
_categories[i] = _(categoryIt->name.toStdString().c_str()) ;
|
||||||
// _categoriesIndexes[categoryIt->name] = i;
|
_categoriesIndexes[categoryIt->name] = i;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// nbCategories = (user->GetCategoriesNumber() <= wxUI::MAX_CATEGORY) ? user->GetCategoriesNumber() : wxUI::MAX_CATEGORY;
|
nbCategories = (user->GetCategoriesNumber() <= wxUI::MAX_CATEGORY) ? user->GetCategoriesNumber() : wxUI::MAX_CATEGORY;
|
||||||
|
|
||||||
// _categoriesValues = new double[user->GetCategoriesNumber()];
|
_categoriesValues = new double[user->GetCategoriesNumber()];
|
||||||
// for(i=0; i<user->GetCategoriesNumber(); i++)
|
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||||
// _categoriesValues[i] = 0.0;
|
_categoriesValues[i] = 0.0;
|
||||||
|
|
||||||
// _dataset = new CategorySimpleDataset(_categories, nbCategories);
|
// _dataset = new CategorySimpleDataset(_categories, nbCategories);
|
||||||
// _dataset->AddSerie(_("Serie 1"), _categoriesValues, nbCategories);
|
// _dataset->AddSerie(_("Serie 1"), _categoriesValues, nbCategories);
|
||||||
|
@ -125,13 +122,13 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
// wxButton* buttonUnGroup = new wxButton(this, UNGROUP_ID, _("UnGroup"));
|
// wxButton* buttonUnGroup = new wxButton(this, UNGROUP_ID, _("UnGroup"));
|
||||||
// wxButton* buttonUpdateNextMonths = new wxButton(this, UPDATE_NEXT_MONTHS_ID, _("Update next months"));
|
// wxButton* buttonUpdateNextMonths = new wxButton(this, UPDATE_NEXT_MONTHS_ID, _("Update next months"));
|
||||||
|
|
||||||
// vbox3->Add(&_tree, 0, wxGROW|wxALL, 2);
|
vbox3->addWidget(_tree);
|
||||||
// vbox3->Add(buttonUpdateNextMonths, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
|
// vbox3->Add(buttonUpdateNextMonths, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
|
||||||
// vbox3->Add(buttonGroup, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
|
// vbox3->Add(buttonGroup, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
|
||||||
// vbox3->Add(buttonUnGroup, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
|
// vbox3->Add(buttonUnGroup, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
|
||||||
// vbox3->Add(_radioMode, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 50);
|
// vbox3->Add(_radioMode, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 50);
|
||||||
|
|
||||||
// hbox->Add(vbox3, 0, wxALL, 2);
|
hbox->addLayout(vbox3);
|
||||||
// // hbox->Add(vbox3, 0, wxGROW|wxALL, 2);
|
// // hbox->Add(vbox3, 0, wxGROW|wxALL, 2);
|
||||||
// hbox2->Add(_accountsGrid, 0, wxGROW|wxALL, 2);
|
// hbox2->Add(_accountsGrid, 0, wxGROW|wxALL, 2);
|
||||||
// hbox2->Add(_calendar, 0, wxALL, 2);
|
// hbox2->Add(_calendar, 0, wxALL, 2);
|
||||||
|
@ -142,9 +139,9 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
// vbox->Add(chart, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 10);
|
// vbox->Add(chart, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 10);
|
||||||
// hbox->Add(vbox, 0, wxGROW|wxALL, 2);
|
// hbox->Add(vbox, 0, wxGROW|wxALL, 2);
|
||||||
|
|
||||||
// ChangeUser();
|
ChangeUser();
|
||||||
|
|
||||||
// Fit();
|
layout();
|
||||||
|
|
||||||
// SetMinSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25));
|
// SetMinSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25));
|
||||||
// SetMaxSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25));
|
// SetMaxSize(wxSize(rect.width-rect.x-15, rect.height-rect.y-128-25));
|
||||||
|
@ -237,94 +234,89 @@ void AccountPanel::InitStatsGrid(User* user)
|
||||||
// _statsGrid->SetCellAlignment(BALANCE, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
// _statsGrid->SetCellAlignment(BALANCE, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||||
// _statsGrid->SetCellAlignment(NON_FIX, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
// _statsGrid->SetCellAlignment(NON_FIX, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||||
}
|
}
|
||||||
|
#include <iostream>
|
||||||
void AccountPanel::ChangeUser()
|
void AccountPanel::ChangeUser()
|
||||||
{
|
{
|
||||||
// User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
// int curYear = -1;
|
int curYear = -1;
|
||||||
// wxDateTime curDate;
|
QDate curDate = QDate::currentDate();
|
||||||
// wxTreeItemId rootNode, curNode;
|
QTreeWidgetItem* curNode;
|
||||||
// std::map<int, std::vector<int> > ops;
|
std::map<int, std::vector<int> > ops;
|
||||||
// std::map<int, std::vector<int> >::iterator it;
|
std::map<int, std::vector<int> >::iterator it;
|
||||||
|
|
||||||
// ops = _kiss->GetAllOperations();
|
ops = _kiss->GetAllOperations();
|
||||||
|
|
||||||
// InitStatsGrid(user);
|
InitStatsGrid(user);
|
||||||
|
|
||||||
// _tree.DeleteAllItems();
|
_tree->clear();
|
||||||
// rootNode = _tree.AddRoot(wxT(""));
|
|
||||||
|
|
||||||
// curDate.SetToCurrent();
|
if (ops.size())
|
||||||
// if (ops.size())
|
{
|
||||||
// {
|
for(it = ops.begin(); it != ops.end(); it++)
|
||||||
// for(it = ops.begin(); it != ops.end(); it++)
|
{
|
||||||
// {
|
if ((int)it->first <= curDate.year())
|
||||||
// if ((int)it->first <= curDate.GetYear())
|
curYear = it->first;
|
||||||
// {
|
curNode = new QTreeWidgetItem(QStringList(QString::number(it->first)));
|
||||||
// curYear = it->first;
|
_tree->addTopLevelItem(curNode);
|
||||||
// curNode = _tree.AppendItem(rootNode, wxString::Format(wxT("%d"), it->first));
|
}
|
||||||
// }
|
layout();
|
||||||
// else
|
if (curYear != -1)
|
||||||
// _tree.AppendItem(rootNode, wxString::Format(wxT("%d"), it->first));
|
{
|
||||||
// }
|
_tree->setCurrentItem(curNode);
|
||||||
// Fit();
|
LoadYear(curYear);
|
||||||
// if (curYear != -1)
|
}
|
||||||
// {
|
}
|
||||||
// _tree.SelectItem(curNode, true);
|
else
|
||||||
// LoadYear(curYear);
|
{
|
||||||
// }
|
curNode = new QTreeWidgetItem(QStringList(QString::number(curDate.year())));
|
||||||
// }
|
_tree->addTopLevelItem(curNode);
|
||||||
// else
|
layout();
|
||||||
// {
|
}
|
||||||
// curNode = _tree.AppendItem(rootNode, wxString::Format(wxT("%d"), curDate.GetYear()));
|
|
||||||
// _tree.AppendItem(curNode, wxUI::months[(int)curDate.GetYear()]);
|
|
||||||
// Fit();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountPanel::LoadYear(int year, bool showMonth)
|
void AccountPanel::LoadYear(int year, bool showMonth)
|
||||||
{
|
{
|
||||||
// User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
// int curMonth = -1;
|
int curMonth = -1;
|
||||||
// wxDateTime curDate;
|
QDate curDate = QDate::currentDate();
|
||||||
// wxTreeItemId parentNode, curMonthNode;
|
QTreeWidgetItem* parentNode, *curMonthNode;
|
||||||
// std::map<int, std::vector<int> > ops ;
|
std::map<int, std::vector<int> > ops ;
|
||||||
// std::vector<int>::iterator it;
|
std::vector<int>::iterator it;
|
||||||
|
|
||||||
// if (user->_operations[year] && _tree.GetChildrenCount(_tree.GetSelection(), true))
|
if (user->_operations[year] && _tree->currentItem()->childCount())
|
||||||
// {
|
{
|
||||||
// if (showMonth)
|
if (showMonth)
|
||||||
// ShowMonth(-1, year);
|
ShowMonth(-1, year);
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// _curYear = year ;
|
_curYear = year ;
|
||||||
// _kiss->LoadYear(year);
|
_kiss->LoadYear(year);
|
||||||
// ops = _kiss->GetAllOperations();
|
ops = _kiss->GetAllOperations();
|
||||||
|
|
||||||
// curDate.SetToCurrent();
|
parentNode = _tree->currentItem();
|
||||||
// parentNode = _tree.GetSelection();
|
|
||||||
|
|
||||||
// for (it = ops[year].begin(); it != ops[year].end(); it++)
|
for (it = ops[year].begin(); it != ops[year].end(); it++)
|
||||||
// {
|
{
|
||||||
// if (curMonth == -1 || (year == curDate.GetYear() && *it <= curDate.GetMonth()))
|
if (curMonth == -1 || (year == curDate.year() && *it <= curDate.month()))
|
||||||
// {
|
{
|
||||||
// curMonth = *it;
|
curMonth = *it;
|
||||||
// curMonthNode = _tree.AppendItem(parentNode, wxUI::months[*it]);
|
curMonthNode = new QTreeWidgetItem(QStringList(wxUI::months[*it]));
|
||||||
// }
|
parentNode->addChild(curMonthNode);
|
||||||
// else
|
}
|
||||||
// _tree.AppendItem(parentNode, wxUI::months[*it]);
|
else
|
||||||
// }
|
_tree->topLevelItem(0)->addChild(new QTreeWidgetItem(QStringList(wxUI::months[*it])));
|
||||||
|
}
|
||||||
|
|
||||||
// _tree.Expand(parentNode);
|
_tree->expandItem(parentNode);
|
||||||
// Fit();
|
layout();
|
||||||
// if (showMonth)
|
if (showMonth)
|
||||||
// {
|
{
|
||||||
// _tree.SelectItem(curMonthNode, true);
|
_tree->setCurrentItem(curMonthNode);
|
||||||
// ShowMonth(curMonth, year);
|
ShowMonth(curMonth, year);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// _wxUI->Layout();
|
_wxUI->layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountPanel::ShowMonth(int month, int year)
|
void AccountPanel::ShowMonth(int month, int year)
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
// #include <wx/chartpanel.h>
|
// #include <wx/chartpanel.h>
|
||||||
// #include <wx/radiobox.h>
|
// #include <wx/radiobox.h>
|
||||||
|
|
||||||
|
#include <QTreeWidget>
|
||||||
|
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
|
|
||||||
#include <model/model.hpp>
|
#include <model/model.hpp>
|
||||||
|
@ -69,7 +71,7 @@ public:
|
||||||
int _curMonth, _curYear;
|
int _curMonth, _curYear;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// wxTreeCtrl _tree;
|
QTreeWidget *_tree;
|
||||||
// wxCalendarCtrl* _calendar;
|
// wxCalendarCtrl* _calendar;
|
||||||
// GridAccount* _grid;
|
// GridAccount* _grid;
|
||||||
// wxGrid *_statsGrid, *_accountsGrid;
|
// wxGrid *_statsGrid, *_accountsGrid;
|
||||||
|
|
|
@ -136,7 +136,7 @@ bool wxUI::SetLanguage(QString language)
|
||||||
|
|
||||||
months[0] = _("january");
|
months[0] = _("january");
|
||||||
months[1] = _("february");
|
months[1] = _("february");
|
||||||
months[2] = _("marchpp");
|
months[2] = _("march");
|
||||||
months[3] = _("april");
|
months[3] = _("april");
|
||||||
months[4] = _("may");
|
months[4] = _("may");
|
||||||
months[5] = _("june");
|
months[5] = _("june");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user