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

View File

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