From 3fe6d0ad286e2f200da4699efcc5d6a759f8f4b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 4 Feb 2012 13:43:01 +0100 Subject: [PATCH] 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 --- src/view/AccountPanel.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp index a58e8b6..1a52d12 100644 --- a/src/view/AccountPanel.cpp +++ b/src/view/AccountPanel.cpp @@ -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 > ops ; std::vector::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; iGetCategoriesNumber(); 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]); }