wip
This commit is contained in:
@@ -226,11 +226,12 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
||||
std::map<unsigned int, std::vector<operation> >::iterator it;
|
||||
wxDateTime curDate;
|
||||
wxTreeItemId parentNode, curMonthNode;
|
||||
|
||||
//std::map<int, std::vector<int> > Database::GetAllOperations(User* user)
|
||||
|
||||
if (user->_operations[year])
|
||||
{
|
||||
if (showMonth)
|
||||
ShowMonth(year, -1);
|
||||
ShowMonth(-1, year);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -256,7 +257,7 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
||||
if (showMonth)
|
||||
{
|
||||
_tree.SelectItem(curMonthNode, true);
|
||||
ShowMonth(year, curMonth);
|
||||
ShowMonth(curMonth, year);
|
||||
}
|
||||
|
||||
_wxUI->Layout();
|
||||
@@ -267,7 +268,7 @@ void AccountPanel::LoadYear(int year, bool showMonth)
|
||||
_grid->SetCellBackgroundColour(row, i, color);\
|
||||
}
|
||||
|
||||
void AccountPanel::ShowMonth(int year, int month)
|
||||
void AccountPanel::ShowMonth(int month, int year)
|
||||
{
|
||||
std::vector<operation> operations;
|
||||
std::vector<operation>::iterator it;
|
||||
@@ -278,7 +279,6 @@ void AccountPanel::ShowMonth(int year, int month)
|
||||
std::vector<category>::iterator categoryIt;
|
||||
std::map<unsigned int, std::vector<operation> >::iterator monthIt;
|
||||
wxDateTime curDate;
|
||||
|
||||
curDate.SetToCurrent();
|
||||
|
||||
if (month == -1)
|
||||
@@ -846,7 +846,7 @@ void AccountPanel::OnTreeChange(wxTreeEvent& event)
|
||||
|
||||
if (year != _curYear || month != _curMonth)
|
||||
{
|
||||
ShowMonth(year, month);
|
||||
ShowMonth(month, year);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -893,3 +893,64 @@ void AccountPanel::OnMenuDelete(wxCommandEvent& event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AccountPanel::GenerateMonth(int month, int year)
|
||||
{
|
||||
wxTreeItemId root, years, node ;
|
||||
wxTreeItemIdValue cookie;
|
||||
wxString monthString, yearString;
|
||||
std::map<unsigned int, std::vector<operation> >::iterator it;
|
||||
int i;
|
||||
User* user = _kiss->GetUser();
|
||||
|
||||
root = _tree.GetRootItem();
|
||||
yearString = wxString::Format(wxT("%d"), year);
|
||||
monthString = months[month];
|
||||
|
||||
if (_tree.GetChildrenCount(root, true) < 1)
|
||||
{
|
||||
node = _tree.AppendItem(root, yearString);
|
||||
node = _tree.AppendItem(node, monthString);
|
||||
|
||||
_tree.SelectItem(node, true);
|
||||
ShowMonth(month, year);
|
||||
return ;
|
||||
}
|
||||
|
||||
years = _tree.GetFirstChild(root, cookie);
|
||||
while (years.IsOk())
|
||||
{
|
||||
if (_tree.GetItemText(years) == yearString)
|
||||
break;
|
||||
if (wxAtoi(_tree.GetItemText(years)) > year)
|
||||
{
|
||||
years = _tree.GetPrevSibling(years);
|
||||
if (!years.IsOk())
|
||||
years = _tree.PrependItem(root, yearString);
|
||||
else
|
||||
years = _tree.InsertItem(root, years, yearString);
|
||||
break;
|
||||
}
|
||||
years = _tree.GetNextSibling(years);
|
||||
}
|
||||
|
||||
if (!years.IsOk())
|
||||
years = _tree.PrependItem(root, yearString);
|
||||
|
||||
if (!_tree.GetChildrenCount(years, true))
|
||||
node = _tree.AppendItem(years, monthString);
|
||||
else
|
||||
{
|
||||
for(i=0, it = user->_operations[year]->begin();
|
||||
it != user->_operations[year]->end();
|
||||
it++, i++)
|
||||
{
|
||||
if ((int)it->first >= month)
|
||||
break;
|
||||
}
|
||||
years = _tree.InsertItem(years, i, monthString);
|
||||
}
|
||||
|
||||
_tree.SelectItem(node, true);
|
||||
ShowMonth(month, year);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ public:
|
||||
~AccountPanel();
|
||||
void ChangeUser();
|
||||
void LoadYear(int year, bool showMonth=true);
|
||||
void ShowMonth(int year, int month);
|
||||
void ShowMonth(int month, int year);
|
||||
void GenerateMonth(int month, int year);
|
||||
|
||||
void OnOperationModified(wxGridEvent& event);
|
||||
void OnAccountModified(wxGridEvent& event);
|
||||
|
||||
@@ -168,8 +168,39 @@ void GenerateDialog::OnYearToChange(wxCommandEvent& event)
|
||||
}
|
||||
|
||||
void GenerateDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
{
|
||||
int monthFrom, yearFrom, monthTo, yearTo, i;
|
||||
|
||||
if (_yearFrom->GetString(_yearTo->GetCurrentSelection()) == _(""))
|
||||
{
|
||||
monthFrom = -1;
|
||||
yearFrom = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<12; i++)
|
||||
{
|
||||
if (months[i] == _monthFrom->GetString(_monthFrom->GetCurrentSelection()))
|
||||
{
|
||||
monthFrom = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
yearFrom = wxAtoi(_yearFrom->GetString(_yearFrom->GetCurrentSelection()));
|
||||
}
|
||||
|
||||
for (i=0; i<12; i++)
|
||||
{
|
||||
if (months[i] == _monthTo->GetString(_monthTo->GetCurrentSelection()))
|
||||
{
|
||||
monthTo = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
yearTo = wxAtoi(_yearTo->GetString(_yearTo->GetCurrentSelection()));
|
||||
|
||||
Close();
|
||||
_kiss->GenerateMonth(monthFrom, yearFrom, monthTo, yearTo);
|
||||
}
|
||||
|
||||
void GenerateDialog::OnCancel(wxCommandEvent& event)
|
||||
|
||||
@@ -101,3 +101,8 @@ void wxUI::ShowPanel(wxPanel* panel)
|
||||
_curPanel->Show();
|
||||
Layout();
|
||||
}
|
||||
|
||||
void wxUI::GenerateMonth(int month, int year)
|
||||
{
|
||||
_accountPanel->GenerateMonth(month, year);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
|
||||
void ShowAccount();
|
||||
void ShowPreferences();
|
||||
void GenerateMonth(int month, int year);
|
||||
|
||||
private:
|
||||
KissCount *_kiss;
|
||||
|
||||
Reference in New Issue
Block a user