diff --git a/src/view/AccountPanel.cpp b/src/view/AccountPanel.cpp index 1a88792..c0d3b50 100644 --- a/src/view/AccountPanel.cpp +++ b/src/view/AccountPanel.cpp @@ -52,6 +52,8 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare _tree = new QTreeWidget(this); _tree->headerItem()->setHidden(true); _tree->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + connect(_tree, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(OnTreeChange(QTreeWidgetItem*, int))); + // ColorScheme* colorScheme = new ColorScheme(wxUI::categoryColors, WXSIZEOF(wxUI::categoryColors)); _pie = new PieView; @@ -108,7 +110,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare _accountsGrid->setHorizontalHeaderItem(ACCOUNT_FINAL, new QTableWidgetItem(_("Final value"))); _accountsGrid->resizeColumnsToContents(); - _accountsGrid->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + _accountsGrid->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); for(i=0; isetWindowTitle(user->_name + " - " + wxUI::months[month-1] + " " + QString::number(year)); + _wxUI->setWindowTitle(user->_name + " - " + wxUI::months[month] + " " + QString::number(year)); // if (_grid->GetNumberRows() > 1) // _grid->DeleteRows(1, _grid->GetNumberRows()-1); @@ -783,64 +785,63 @@ void AccountPanel::OnTreeRightClick() // PopupMenu(&menu, event.GetPoint()); } -void AccountPanel::OnTreeChange() +void AccountPanel::OnTreeChange (QTreeWidgetItem * item, int column) { - // int month=-1, year; - // int i; - // wxString monthString; - // static bool inModification = false ; + int month=-1, year; + int i; + QString monthString; - // if (inModification) return; + item = _tree->currentItem (); - // inModification = true; + if (!item) return; - // monthString = _tree.GetItemText(event.GetItem()); - // for (i=0; i<12; i++) - // if (monthString == wxUI::months[i]) - // { - // month = i; - // break; - // } + monthString = item->text(column); - // if (month == -1) - // { - // year = wxAtoi(monthString); + for (i=0; i<12; i++) + { + if (monthString == wxUI::months[i]) + { + month = i; + break; + } + } + + if (month == -1) + { + year = monthString.toInt(); - // // Error - // if (year == 0) - // { - // inModification = false; - // return; - // } + // Error + if (year == 0) + { + return; + } - // if (year == _curYear) - // { - // inModification = false; - // return; - // } + if (year == _curYear) + { + return; + } - // // _tree.CollapseAll(); - // // _tree.Expand(event.GetItem()); - // LoadYear(year, false); - // } - // else - // { - // year = wxAtoi(_tree.GetItemText(_tree.GetItemParent(event.GetItem()))); + // _tree.CollapseAll(); + // _tree.Expand(event.GetItem()); + LoadYear(year, false); + } + else + { + item = item->parent(); + year = item->text(column).toInt(); - // // Error - // if (year == 0) - // { - // inModification = false; - // return; - // } + // Error + if (year == 0) + { + return; + } - // if (year != _curYear || month != _curMonth) - // { - // ShowMonth(month, year); - // } - // } + if (year != _curYear || month != _curMonth) + { + ShowMonth(month, year); + } + } - // inModification = false; } void AccountPanel::GetTreeSelection(int* month, int* year) diff --git a/src/view/AccountPanel.hpp b/src/view/AccountPanel.hpp index 486b9d1..f898f01 100644 --- a/src/view/AccountPanel.hpp +++ b/src/view/AccountPanel.hpp @@ -67,7 +67,7 @@ private slots: void OnOperationModified(); void OnAccountModified(); void OnTreeRightClick(); - void OnTreeChange(); + void OnTreeChange (QTreeWidgetItem * item, int column); void OnMenuGenerate(); void OnMenuDelete(); void OnCalendarChange(); diff --git a/src/view/grid/GridAccount.cpp b/src/view/grid/GridAccount.cpp index f9ad9e9..9dd4258 100644 --- a/src/view/grid/GridAccount.cpp +++ b/src/view/grid/GridAccount.cpp @@ -198,7 +198,7 @@ void GridAccount::LoadOperations(std::vector* operations, int month, it = _operations->begin(); if (rowCount() > 1) - clear(); + setRowCount(1); TabDelegate* descriptionEditor = new TabDelegate(this, &_displayedOperations); setItemDelegateForColumn(DESCRIPTION, descriptionEditor);