Fix default month selection (sometimes not current month)
This commit is contained in:
parent
b1ce5fc2a2
commit
05b070a502
|
@ -331,8 +331,8 @@ 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, month;
|
int lastMonth = -1, month;
|
||||||
QTreeWidgetItem* parentNode, *curMonthNode = 0;
|
QTreeWidgetItem* parentNode, *curMonthNode = 0, *lastMonthNode = 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;
|
||||||
QDate curDate = QDate::currentDate();
|
QDate curDate = QDate::currentDate();
|
||||||
|
@ -344,6 +344,7 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_inModification = true;
|
||||||
_curYear = year ;
|
_curYear = year ;
|
||||||
_kiss->LoadYear(year);
|
_kiss->LoadYear(year);
|
||||||
ops = _kiss->GetAllOperations();
|
ops = _kiss->GetAllOperations();
|
||||||
|
@ -353,35 +354,38 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
||||||
if (!parentNode)
|
if (!parentNode)
|
||||||
parentNode = _tree->topLevelItem(0);
|
parentNode = _tree->topLevelItem(0);
|
||||||
|
|
||||||
if (_curMonth == -1)
|
|
||||||
{
|
|
||||||
if (_curYear == curDate.year())
|
if (_curYear == curDate.year())
|
||||||
month = curDate.month()-1;
|
month = curDate.month()-1;
|
||||||
else
|
else
|
||||||
month = 0;
|
month = 0;
|
||||||
}
|
|
||||||
|
|
||||||
for (it = ops[year].begin(); it != ops[year].end(); it++)
|
for (it = ops[year].begin(); it != ops[year].end(); it++)
|
||||||
{
|
{
|
||||||
if (!curMonthNode || (year == _curYear && *it <= month))
|
lastMonthNode = new QTreeWidgetItem(QStringList(wxUI::months[*it]));
|
||||||
{
|
if (year == _curYear && *it == month)
|
||||||
curMonth = *it;
|
curMonthNode = lastMonthNode;
|
||||||
curMonthNode = new QTreeWidgetItem(QStringList(wxUI::months[*it]));
|
lastMonth = *it;
|
||||||
parentNode->addChild(curMonthNode);
|
parentNode->addChild(lastMonthNode);
|
||||||
}
|
|
||||||
else
|
|
||||||
parentNode->addChild(new QTreeWidgetItem(QStringList(wxUI::months[*it])));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_tree->expandItem(parentNode);
|
_tree->expandItem(parentNode);
|
||||||
layout();
|
layout();
|
||||||
if (showMonth)
|
if (showMonth)
|
||||||
|
{
|
||||||
|
if (curMonthNode)
|
||||||
{
|
{
|
||||||
_tree->setCurrentItem(curMonthNode);
|
_tree->setCurrentItem(curMonthNode);
|
||||||
ShowMonth(curMonth, year);
|
ShowMonth(month, year);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_tree->setCurrentItem(lastMonthNode);
|
||||||
|
ShowMonth(lastMonth, year);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_wxUI->layout();
|
_wxUI->layout();
|
||||||
|
_inModification = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountPanel::ShowMonth(int month, int year)
|
void AccountPanel::ShowMonth(int month, int year)
|
||||||
|
@ -775,8 +779,6 @@ void AccountPanel::UpdateStats()
|
||||||
void AccountPanel::OnOperationModified()
|
void AccountPanel::OnOperationModified()
|
||||||
{
|
{
|
||||||
UpdateStats();
|
UpdateStats();
|
||||||
|
|
||||||
layout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountPanel::OnAccountModified(int row, int column)
|
void AccountPanel::OnAccountModified(int row, int column)
|
||||||
|
@ -792,6 +794,7 @@ void AccountPanel::OnAccountModified(int row, int column)
|
||||||
_accountsInitValues[id] = amount;
|
_accountsInitValues[id] = amount;
|
||||||
|
|
||||||
UpdateStats();
|
UpdateStats();
|
||||||
|
_wxUI->NeedReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountPanel::OnTreeRightClick(const QPoint & pos)
|
void AccountPanel::OnTreeRightClick(const QPoint & pos)
|
||||||
|
@ -812,6 +815,8 @@ void AccountPanel::OnTreeChange (QTreeWidgetItem * item, int column)
|
||||||
int i;
|
int i;
|
||||||
QString monthString;
|
QString monthString;
|
||||||
|
|
||||||
|
if (_inModification) return;
|
||||||
|
|
||||||
item = _tree->currentItem ();
|
item = _tree->currentItem ();
|
||||||
|
|
||||||
if (!item) return;
|
if (!item) return;
|
||||||
|
@ -924,6 +929,7 @@ void AccountPanel::OnMenuGenerate()
|
||||||
g.setModal(true);
|
g.setModal(true);
|
||||||
g.exec();
|
g.exec();
|
||||||
_wxUI->setEnabled(true);
|
_wxUI->setEnabled(true);
|
||||||
|
_wxUI->NeedReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountPanel::OnMenuDelete()
|
void AccountPanel::OnMenuDelete()
|
||||||
|
@ -1140,6 +1146,7 @@ void AccountPanel::OnUpdateNextMonths()
|
||||||
else
|
else
|
||||||
QMessageBox::information(0, "KissCount", _("Any account updated !"));
|
QMessageBox::information(0, "KissCount", _("Any account updated !"));
|
||||||
|
|
||||||
|
_wxUI->NeedReload();
|
||||||
delete[] cur_amounts;
|
delete[] cur_amounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user