Missing files

This commit is contained in:
Grégory Soutadé 2010-06-27 21:42:05 +02:00
parent 442384ebbc
commit bd3d96f64a
2 changed files with 48 additions and 46 deletions

View File

@ -18,7 +18,7 @@ EVT_TREE_KEY_DOWN(CALENDAR_TREE_ID, AccountPanel::OnTreeChange)
EVT_SHOW(AccountPanel::OnShow)
END_EVENT_TABLE()
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _curMonth(-1), _curYear(-1), _kiss(kiss), _wxUI(parent), _tree(this, CALENDAR_TREE_ID, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT)
AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _curMonth(-1), _curYear(-1), _kiss(kiss), _wxUI(parent)
{
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
@ -46,6 +46,8 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
ColorScheme* colorScheme = new ColorScheme(categoryColors, WXSIZEOF(categoryColors));
_tree = new wxTreeCtrl(this, CALENDAR_TREE_ID, wxDefaultPosition, wxDefaultSize, wxTR_HIDE_ROOT);
_pie = new PiePlot();
_accounts = new wxString[user->GetAccountsNumber()];
@ -121,7 +123,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)),
chart->Layout();
chart->SetMinSize(// chart->GetSize()
wxSize(200,250));
hbox->Add(&_tree, 0);
hbox->Add(_tree, 0);
vbox2->Add(_accountsGrid, 0);
vbox2->Add(-1, 10);
vbox2->Add(_grid, 0);
@ -203,8 +205,8 @@ void AccountPanel::ChangeUser()
InitStatsGrid(user);
_tree.DeleteAllItems();
rootNode = _tree.AddRoot(_(""));
_tree->DeleteAllItems();
rootNode = _tree->AddRoot(_(""));
curDate.SetToCurrent();
for(it = user->_operations.begin(); it != user->_operations.end(); it++)
@ -212,15 +214,15 @@ void AccountPanel::ChangeUser()
if ((int)it->first <= curDate.GetYear())
{
curYear = it->first;
curNode = _tree.AppendItem(rootNode, wxString::Format(wxT("%d"), it->first));
curNode = _tree->AppendItem(rootNode, wxString::Format(wxT("%d"), it->first));
}
else
_tree.AppendItem(rootNode, wxString::Format(wxT("%d"), it->first));
_tree->AppendItem(rootNode, wxString::Format(wxT("%d"), it->first));
}
if (curYear != -1)
{
_tree.SelectItem(curNode, true);
_tree->SelectItem(curNode, true);
LoadYear(curYear);
}
}
@ -246,24 +248,24 @@ void AccountPanel::LoadYear(int year, bool showMonth)
ops = _kiss->GetAllOperations();
curDate.SetToCurrent();
parentNode = _tree.GetSelection();
parentNode = _tree->GetSelection();
for (it = ops[year].begin(); it != ops[year].end(); it++)
{
if (curMonth == -1 || (year == curDate.GetYear() && *it <= curDate.GetMonth()))
{
curMonth = *it;
curMonthNode = _tree.AppendItem(parentNode, months[*it]);
curMonthNode = _tree->AppendItem(parentNode, months[*it]);
}
else
_tree.AppendItem(parentNode, months[*it]);
_tree->AppendItem(parentNode, months[*it]);
}
_tree.Expand(parentNode);
_tree->Expand(parentNode);
if (showMonth)
{
_tree.SelectItem(curMonthNode, true);
_tree->SelectItem(curMonthNode, true);
ShowMonth(curMonth, year);
}
@ -795,7 +797,7 @@ void AccountPanel::OnTreeRightClick(wxTreeEvent& event)
menu.Append(MENU_GENERATE_ID, _("Generate month"));
menu.AppendSeparator();
if (_tree.GetCount() > 1)
if (_tree->GetCount() > 1)
menu.Append(MENU_DELETE_ID, _("Delete"));
PopupMenu(&menu, event.GetPoint());
@ -812,7 +814,7 @@ void AccountPanel::OnTreeChange(wxTreeEvent& event)
inModification = true;
monthString = _tree.GetItemText(event.GetItem());
monthString = _tree->GetItemText(event.GetItem());
for (i=0; i<12; i++)
if (monthString == months[i])
{
@ -837,13 +839,13 @@ void AccountPanel::OnTreeChange(wxTreeEvent& event)
return;
}
// _tree.CollapseAll();
// _tree.Expand(event.GetItem());
// _tree->CollapseAll();
// _tree->Expand(event.GetItem());
LoadYear(year, false);
}
else
{
year = wxAtoi(_tree.GetItemText(_tree.GetItemParent(event.GetItem())));
year = wxAtoi(_tree->GetItemText(_tree->GetItemParent(event.GetItem())));
// Error
if (year == 0)
@ -868,7 +870,7 @@ void AccountPanel::GetTreeSelection(int* month, int* year)
*month = -1; *year = -1;
monthString = _tree.GetItemText(_tree.GetSelection());
monthString = _tree->GetItemText(_tree->GetSelection());
for (i=0; i<12; i++)
if (monthString == months[i])
{
@ -890,7 +892,7 @@ void AccountPanel::GetTreeSelection(int* month, int* year)
}
else
{
*year = wxAtoi(_tree.GetItemText(_tree.GetItemParent(_tree.GetSelection())));
*year = wxAtoi(_tree->GetItemText(_tree->GetItemParent(_tree->GetSelection())));
// Error
if (year == 0)
@ -940,25 +942,25 @@ void AccountPanel::OnMenuDelete(wxCommandEvent& event)
if (dialog.ShowModal() == wxID_NO)
return;
curNode = _tree.GetSelection();
curNode = _tree->GetSelection();
if (ops[year].size() == 1 && month != -1)
curNode = _tree.GetItemParent(curNode);
curNode = _tree->GetItemParent(curNode);
_kiss->DeleteOperations(month, year);
node = _tree.GetNextSibling(curNode);
node = _tree->GetNextSibling(curNode);
if (!node.IsOk())
node = _tree.GetPrevSibling(curNode);
node = _tree->GetPrevSibling(curNode);
_tree.Delete(curNode);
_tree->Delete(curNode);
if (!node.IsOk())
ChangeUser();
else
{
_tree.SelectItem(node);
_tree->SelectItem(node);
GetTreeSelection(&month, &year);
if (month == -1)
month = ops[year][0];
@ -975,48 +977,48 @@ void AccountPanel::GenerateMonth(int month, int year)
int i;
User* user = _kiss->GetUser();
root = _tree.GetRootItem();
root = _tree->GetRootItem();
yearString = wxString::Format(wxT("%d"), year);
monthString = months[month];
if (_tree.GetChildrenCount(root, true) < 1)
if (_tree->GetChildrenCount(root, true) < 1)
{
node = _tree.AppendItem(root, yearString);
node = _tree.AppendItem(node, monthString);
node = _tree->AppendItem(root, yearString);
node = _tree->AppendItem(node, monthString);
_tree.SelectItem(node, true);
_tree->SelectItem(node, true);
ShowMonth(month, year);
return ;
}
years = _tree.GetFirstChild(root, cookie);
years = _tree->GetFirstChild(root, cookie);
while (years.IsOk())
{
if (_tree.GetItemText(years) == yearString)
if (_tree->GetItemText(years) == yearString)
break;
if (wxAtoi(_tree.GetItemText(years)) > year)
if (wxAtoi(_tree->GetItemText(years)) > year)
{
years = _tree.GetPrevSibling(years);
years = _tree->GetPrevSibling(years);
if (!years.IsOk())
years = _tree.PrependItem(root, yearString);
years = _tree->PrependItem(root, yearString);
else
years = _tree.InsertItem(root, years, yearString);
years = _tree->InsertItem(root, years, yearString);
break;
}
years = _tree.GetNextSibling(years);
years = _tree->GetNextSibling(years);
}
if (!years.IsOk())
{
years = _tree.GetFirstChild(root, cookie);
if (wxAtoi(_tree.GetItemText(years)) > year)
years = _tree.PrependItem(root, yearString);
years = _tree->GetFirstChild(root, cookie);
if (wxAtoi(_tree->GetItemText(years)) > year)
years = _tree->PrependItem(root, yearString);
else
years = _tree.AppendItem(root, yearString);
years = _tree->AppendItem(root, yearString);
}
if (!_tree.GetChildrenCount(years, true))
node = _tree.AppendItem(years, monthString);
if (!_tree->GetChildrenCount(years, true))
node = _tree->AppendItem(years, monthString);
else
{
for(i=0, it = user->_operations[year]->begin();
@ -1026,10 +1028,10 @@ void AccountPanel::GenerateMonth(int month, int year)
if ((int)it->first > month)
break;
}
years = _tree.InsertItem(years, i, monthString);
years = _tree->InsertItem(years, i, monthString);
}
_tree.SelectItem(node, true);
_tree->SelectItem(node, true);
ShowMonth(month, year);
}

View File

@ -51,7 +51,7 @@ public:
private:
KissCount* _kiss;
wxUI* _wxUI;
wxTreeCtrl _tree;
wxTreeCtrl* _tree;
GridAccount* _grid;
wxGrid *_statsGrid, *_accountsGrid;
PiePlot* _pie;