Fix a regression : only first month was shown at startupt (not current)
Display all categories in chart (AccountPanel) Fix a bug : curDate was wrong if you come back from another month to current month
This commit is contained in:
parent
37f03a1da0
commit
3fe6d0ad28
|
@ -322,7 +322,7 @@ void AccountPanel::ChangeUser()
|
|||
if (curYear != -1)
|
||||
{
|
||||
_tree->setCurrentItem(curNode);
|
||||
LoadYear(curYear);
|
||||
LoadYear(curYear, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -340,6 +340,7 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
|||
QTreeWidgetItem* parentNode, *curMonthNode = 0;
|
||||
std::map<int, std::vector<int> > ops ;
|
||||
std::vector<int>::iterator it;
|
||||
QDate curDate = QDate::currentDate();
|
||||
|
||||
if (user->_operations[year] && _tree->currentItem()->childCount())
|
||||
{
|
||||
|
@ -359,7 +360,7 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
|||
|
||||
for (it = ops[year].begin(); it != ops[year].end(); it++)
|
||||
{
|
||||
if (!curMonthNode)
|
||||
if (!curMonthNode || (curDate.year() == _curYear && *it <= curDate.month()-1))
|
||||
{
|
||||
curMonth = *it;
|
||||
curMonthNode = new QTreeWidgetItem(QStringList(wxUI::months[*it]));
|
||||
|
@ -398,7 +399,7 @@ void AccountPanel::ShowMonth(int month, int year)
|
|||
{
|
||||
for (monthIt = user->_operations[year]->begin(); monthIt != user->_operations[year]->end(); monthIt++)
|
||||
{
|
||||
if ((int)monthIt->first <= curDate.month())
|
||||
if ((int)monthIt->first+1 <= curDate.month())
|
||||
{
|
||||
month = monthIt->first;
|
||||
}
|
||||
|
@ -437,8 +438,8 @@ void AccountPanel::ShowMonth(int month, int year)
|
|||
dateStart.setDate(_curYear, _curMonth+1, 1);
|
||||
dateEnd.setDate(_curYear, _curMonth+1, dateStart.daysInMonth());
|
||||
_calendar->setDateRange(dateStart, dateEnd);
|
||||
if ((curDate.month()-1) == month && curDate.year() == year)
|
||||
_calendar->showToday();
|
||||
if (curDate.month() == (_curMonth+1) && curDate.year() == year)
|
||||
_calendar->setSelectedDate (curDate) ;
|
||||
else if ((curDate.month()-1) > month || curDate.year() > year)
|
||||
_calendar->setSelectedDate (dateEnd) ;
|
||||
else if ((curDate.month()-1) < month || curDate.year() < year)
|
||||
|
@ -719,7 +720,7 @@ void AccountPanel::UpdateStats()
|
|||
_statsGrid->item(BALANCE, 1)->setText(v.sprintf("%.2lf", balance));
|
||||
_statsGrid->item(BALANCE, 1)->setForeground((balance >= 0) ? QBrush(Qt::green) : QBrush(Qt::red));
|
||||
|
||||
KDChart::Legend* legend = _pie->legend();
|
||||
// KDChart::Legend* legend = _pie->legend();
|
||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||
{
|
||||
if (totalDebit != 0)
|
||||
|
@ -734,10 +735,10 @@ void AccountPanel::UpdateStats()
|
|||
QVector< double > vec;
|
||||
vec << _categoriesValues[i];
|
||||
_pie->setDataset( i, vec, _categories[i] );
|
||||
if (_categoriesValues[i] == 0.0)
|
||||
legend->setDatasetHidden(i, true);
|
||||
else
|
||||
legend->setDatasetHidden(i, false);
|
||||
// if (_categoriesValues[i] == 0.0)
|
||||
// legend->setDatasetHidden(i, true);
|
||||
// else
|
||||
// legend->setDatasetHidden(i, false);
|
||||
// _dataset->setData(_dataset->index(i, 1, QModelIndex()), _categoriesValues[i]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user