Fix a bug : month & year changed when AccountPanel is re created (wxUI needs update)
This commit is contained in:
parent
62541cbe2e
commit
9991415e2c
|
@ -34,6 +34,16 @@ 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), _inModification(false)
|
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _curMonth(-1), _curYear(-1), _inModification(false)
|
||||||
|
{
|
||||||
|
Init(kiss, parent, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent, int month=-1, int year=-1, int mode=VIRTUAL_MODE) : KissPanel(kiss, parent), _curMonth(month), _curYear(year), _inModification(false)
|
||||||
|
{
|
||||||
|
Init(kiss, parent, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountPanel::Init(KissCount* kiss, wxUI *parent, int curMode)
|
||||||
{
|
{
|
||||||
QHBoxLayout *hbox = new QHBoxLayout;
|
QHBoxLayout *hbox = new QHBoxLayout;
|
||||||
QHBoxLayout *hbox2 = new QHBoxLayout;
|
QHBoxLayout *hbox2 = new QHBoxLayout;
|
||||||
|
@ -149,7 +159,13 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
_real = new QRadioButton(_("Real"));
|
_real = new QRadioButton(_("Real"));
|
||||||
_check = new QRadioButton(_("Check"));
|
_check = new QRadioButton(_("Check"));
|
||||||
|
|
||||||
_virtual->setChecked(true);
|
switch(curMode)
|
||||||
|
{
|
||||||
|
case VIRTUAL_MODE: _virtual->setChecked(true); break;
|
||||||
|
case REAL_MODE: _real->setChecked(true); break;
|
||||||
|
case CHECK_MODE: _check->setChecked(true); break;
|
||||||
|
default: _virtual->setChecked(true); break;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QVBoxLayout *vbox = new QVBoxLayout;
|
QVBoxLayout *vbox = new QVBoxLayout;
|
||||||
|
@ -212,7 +228,13 @@ AccountPanel::~AccountPanel()
|
||||||
|
|
||||||
KissPanel* AccountPanel::CreatePanel()
|
KissPanel* AccountPanel::CreatePanel()
|
||||||
{
|
{
|
||||||
return new AccountPanel(_kiss, _wxUI);
|
int mode;
|
||||||
|
|
||||||
|
if (_virtual->isChecked()) mode = VIRTUAL_MODE;
|
||||||
|
else if (_real->isChecked()) mode = REAL_MODE;
|
||||||
|
else if (_check->isChecked()) mode = CHECK_MODE;
|
||||||
|
|
||||||
|
return new AccountPanel(_kiss, _wxUI, _curMonth, _curYear, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPushButton* AccountPanel::GetButton()
|
QPushButton* AccountPanel::GetButton()
|
||||||
|
@ -302,7 +324,7 @@ void AccountPanel::InitStatsGrid(User* user)
|
||||||
void AccountPanel::ChangeUser()
|
void AccountPanel::ChangeUser()
|
||||||
{
|
{
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
int curYear = -1;
|
int curYear = -1, year;
|
||||||
QDate curDate = QDate::currentDate();
|
QDate curDate = QDate::currentDate();
|
||||||
QTreeWidgetItem* curNode=NULL, *node;
|
QTreeWidgetItem* curNode=NULL, *node;
|
||||||
std::map<int, std::vector<int> > ops;
|
std::map<int, std::vector<int> > ops;
|
||||||
|
@ -316,10 +338,11 @@ void AccountPanel::ChangeUser()
|
||||||
|
|
||||||
if (ops.size())
|
if (ops.size())
|
||||||
{
|
{
|
||||||
|
year = (_curYear == -1) ? curDate.year() : _curYear;
|
||||||
for(it = ops.begin(); it != ops.end(); it++)
|
for(it = ops.begin(); it != ops.end(); it++)
|
||||||
{
|
{
|
||||||
node = new QTreeWidgetItem(QStringList(QString::number(it->first)));
|
node = new QTreeWidgetItem(QStringList(QString::number(it->first)));
|
||||||
if ((int)it->first <= curDate.year())
|
if ((int)it->first <= year)
|
||||||
{
|
{
|
||||||
curYear = it->first;
|
curYear = it->first;
|
||||||
curNode = node;
|
curNode = node;
|
||||||
|
@ -343,7 +366,7 @@ void AccountPanel::ChangeUser()
|
||||||
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, month;
|
||||||
QTreeWidgetItem* parentNode, *curMonthNode = 0;
|
QTreeWidgetItem* parentNode, *curMonthNode = 0;
|
||||||
std::map<int, std::vector<int> > ops ;
|
std::map<int, std::vector<int> > ops ;
|
||||||
std::vector<int>::iterator it;
|
std::vector<int>::iterator it;
|
||||||
|
@ -365,9 +388,11 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
||||||
if (!parentNode)
|
if (!parentNode)
|
||||||
parentNode = _tree->topLevelItem(0);
|
parentNode = _tree->topLevelItem(0);
|
||||||
|
|
||||||
|
month = (_curMonth == -1) ? curDate.month()-1 : _curMonth;
|
||||||
|
|
||||||
for (it = ops[year].begin(); it != ops[year].end(); it++)
|
for (it = ops[year].begin(); it != ops[year].end(); it++)
|
||||||
{
|
{
|
||||||
if (!curMonthNode || (curDate.year() == _curYear && *it <= curDate.month()-1))
|
if (!curMonthNode || (year == _curYear && *it <= month))
|
||||||
{
|
{
|
||||||
curMonth = *it;
|
curMonth = *it;
|
||||||
curMonthNode = new QTreeWidgetItem(QStringList(wxUI::months[*it]));
|
curMonthNode = new QTreeWidgetItem(QStringList(wxUI::months[*it]));
|
||||||
|
|
|
@ -40,6 +40,8 @@ class AccountPanel: public KissPanel
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AccountPanel(KissCount* kiss, wxUI *parent);
|
AccountPanel(KissCount* kiss, wxUI *parent);
|
||||||
|
AccountPanel(KissCount* kiss, wxUI *parent, int month, int year, int mode);
|
||||||
|
void Init(KissCount* kiss, wxUI *parent, int curMode);
|
||||||
~AccountPanel();
|
~AccountPanel();
|
||||||
|
|
||||||
KissPanel* CreatePanel();
|
KissPanel* CreatePanel();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user