Handle month change in treeview
This commit is contained in:
parent
f035692ea3
commit
42b1b3b85d
|
@ -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; i<NUMBER_COLS_ACCOUNTS; i++)
|
||||
{
|
||||
|
@ -408,7 +410,7 @@ void AccountPanel::ShowMonth(int month, int year)
|
|||
|
||||
_curYear = year;
|
||||
_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)
|
||||
// _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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -198,7 +198,7 @@ void GridAccount::LoadOperations(std::vector<Operation>* operations, int month,
|
|||
it = _operations->begin();
|
||||
|
||||
if (rowCount() > 1)
|
||||
clear();
|
||||
setRowCount(1);
|
||||
|
||||
TabDelegate* descriptionEditor = new TabDelegate(this, &_displayedOperations);
|
||||
setItemDelegateForColumn(DESCRIPTION, descriptionEditor);
|
||||
|
|
Loading…
Reference in New Issue
Block a user