Handle month change in treeview

This commit is contained in:
Grégory Soutadé 2011-10-24 21:05:12 +02:00
parent f035692ea3
commit 42b1b3b85d
3 changed files with 52 additions and 51 deletions

View File

@ -52,6 +52,8 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
_tree = new QTreeWidget(this); _tree = new QTreeWidget(this);
_tree->headerItem()->setHidden(true); _tree->headerItem()->setHidden(true);
_tree->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); _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)); // ColorScheme* colorScheme = new ColorScheme(wxUI::categoryColors, WXSIZEOF(wxUI::categoryColors));
_pie = new PieView; _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->setHorizontalHeaderItem(ACCOUNT_FINAL, new QTableWidgetItem(_("Final value")));
_accountsGrid->resizeColumnsToContents(); _accountsGrid->resizeColumnsToContents();
_accountsGrid->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); _accountsGrid->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
for(i=0; i<NUMBER_COLS_ACCOUNTS; i++) for(i=0; i<NUMBER_COLS_ACCOUNTS; i++)
{ {
@ -408,7 +410,7 @@ void AccountPanel::ShowMonth(int month, int year)
_curYear = year; _curYear = year;
_curMonth = month; _curMonth = month;
_wxUI->setWindowTitle(user->_name + " - " + wxUI::months[month-1] + " " + QString::number(year)); _wxUI->setWindowTitle(user->_name + " - " + wxUI::months[month] + " " + QString::number(year));
// if (_grid->GetNumberRows() > 1) // if (_grid->GetNumberRows() > 1)
// _grid->DeleteRows(1, _grid->GetNumberRows()-1); // _grid->DeleteRows(1, _grid->GetNumberRows()-1);
@ -783,64 +785,63 @@ void AccountPanel::OnTreeRightClick()
// PopupMenu(&menu, event.GetPoint()); // PopupMenu(&menu, event.GetPoint());
} }
void AccountPanel::OnTreeChange() void AccountPanel::OnTreeChange (QTreeWidgetItem * item, int column)
{ {
// int month=-1, year; int month=-1, year;
// int i; int i;
// wxString monthString; QString monthString;
// static bool inModification = false ;
// if (inModification) return; item = _tree->currentItem ();
// inModification = true; if (!item) return;
// monthString = _tree.GetItemText(event.GetItem()); monthString = item->text(column);
// for (i=0; i<12; i++)
// if (monthString == wxUI::months[i])
// {
// month = i;
// break;
// }
// if (month == -1) for (i=0; i<12; i++)
// { {
// year = wxAtoi(monthString); if (monthString == wxUI::months[i])
{
month = i;
break;
}
}
if (month == -1)
{
year = monthString.toInt();
// // Error // Error
// if (year == 0) if (year == 0)
// { {
// inModification = false; return;
// return; }
// }
// if (year == _curYear) if (year == _curYear)
// { {
// inModification = false; return;
// return; }
// }
// // _tree.CollapseAll(); // _tree.CollapseAll();
// // _tree.Expand(event.GetItem()); // _tree.Expand(event.GetItem());
// LoadYear(year, false); LoadYear(year, false);
// } }
// else else
// { {
// year = wxAtoi(_tree.GetItemText(_tree.GetItemParent(event.GetItem()))); item = item->parent();
year = item->text(column).toInt();
// // Error // Error
// if (year == 0) if (year == 0)
// { {
// inModification = false; return;
// return; }
// }
// if (year != _curYear || month != _curMonth) if (year != _curYear || month != _curMonth)
// { {
// ShowMonth(month, year); ShowMonth(month, year);
// } }
// } }
// inModification = false;
} }
void AccountPanel::GetTreeSelection(int* month, int* year) void AccountPanel::GetTreeSelection(int* month, int* year)

View File

@ -67,7 +67,7 @@ private slots:
void OnOperationModified(); void OnOperationModified();
void OnAccountModified(); void OnAccountModified();
void OnTreeRightClick(); void OnTreeRightClick();
void OnTreeChange(); void OnTreeChange (QTreeWidgetItem * item, int column);
void OnMenuGenerate(); void OnMenuGenerate();
void OnMenuDelete(); void OnMenuDelete();
void OnCalendarChange(); void OnCalendarChange();

View File

@ -198,7 +198,7 @@ void GridAccount::LoadOperations(std::vector<Operation>* operations, int month,
it = _operations->begin(); it = _operations->begin();
if (rowCount() > 1) if (rowCount() > 1)
clear(); setRowCount(1);
TabDelegate* descriptionEditor = new TabDelegate(this, &_displayedOperations); TabDelegate* descriptionEditor = new TabDelegate(this, &_displayedOperations);
setItemDelegateForColumn(DESCRIPTION, descriptionEditor); setItemDelegateForColumn(DESCRIPTION, descriptionEditor);