Add unresolved categories in ImportPanel
Fix two bugs : Don't take in account unknown categories (in stats) Don't try to draw more than MAX_CATEGORIES (12) in charts
This commit is contained in:
parent
ec3fa8d7d5
commit
c69621c2fe
|
@ -1,4 +1,4 @@
|
||||||
v0.2 (23/03/2011)
|
v0.2 (25/04/2011)
|
||||||
|
|
||||||
** User **
|
** User **
|
||||||
Better use of sizers (so better interface!)
|
Better use of sizers (so better interface!)
|
||||||
|
@ -38,3 +38,5 @@ v0.2 (23/03/2011)
|
||||||
Categories fonts not updated for new category --> crash
|
Categories fonts not updated for new category --> crash
|
||||||
New category had read only fields in PreferencesPanel
|
New category had read only fields in PreferencesPanel
|
||||||
Update all panels after generating/deleting month
|
Update all panels after generating/deleting month
|
||||||
|
Don't take in account unknown categories (in stats)
|
||||||
|
Don't try to draw more than MAX_CATEGORIES (12) in charts
|
||||||
|
|
|
@ -63,6 +63,7 @@ void GrisbiImportEngine::LoadCategory(GrisbiImportEngine* _this, const char** at
|
||||||
{
|
{
|
||||||
wxString name, id;
|
wxString name, id;
|
||||||
int i;
|
int i;
|
||||||
|
Category cat;
|
||||||
|
|
||||||
for (i=0; attrs[i]; i+=2)
|
for (i=0; attrs[i]; i+=2)
|
||||||
{
|
{
|
||||||
|
@ -82,8 +83,10 @@ void GrisbiImportEngine::LoadCategory(GrisbiImportEngine* _this, const char** at
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_this->_categories[id] = wxT("unknown-") + id;
|
_this->_categories[id] = wxT("unknown-") + name;
|
||||||
_this->_unresolvedCategories.push_back(name);
|
cat.id = id;
|
||||||
|
cat.name = name;
|
||||||
|
_this->_unresolvedCategories.push_back(cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrisbiImportEngine::LoadOperation(GrisbiImportEngine* _this, const char** attrs)
|
void GrisbiImportEngine::LoadOperation(GrisbiImportEngine* _this, const char** attrs)
|
||||||
|
@ -96,8 +99,8 @@ void GrisbiImportEngine::LoadOperation(GrisbiImportEngine* _this, const char** a
|
||||||
|
|
||||||
op.id = wxString::Format(wxT("%d"), ++id);
|
op.id = wxString::Format(wxT("%d"), ++id);
|
||||||
op.parent = wxT("");
|
op.parent = wxT("");
|
||||||
op.account = wxT("0");
|
op.account = wxT("unknwon-0");
|
||||||
op.category = wxT("0");
|
op.category = wxT("unknwon-0");
|
||||||
op.fix_cost = false;
|
op.fix_cost = false;
|
||||||
op.checked = false;
|
op.checked = false;
|
||||||
op.transfert = wxT("");
|
op.transfert = wxT("");
|
||||||
|
|
|
@ -282,12 +282,13 @@ void ImportEngine::MatchPattern(wxString& originalKey, Operation& op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Account> ImportEngine::ParseFile()
|
void ImportEngine::ParseFile(std::vector<Account>& accounts, std::vector<Category>& categories)
|
||||||
{
|
{
|
||||||
return _unresolvedAccounts;
|
accounts = _unresolvedAccounts;
|
||||||
|
categories = _unresolvedCategories;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Operation>* ImportEngine::GetOperations(std::map<wxString, wxString>& accounts)
|
std::vector<Operation>* ImportEngine::GetOperations(std::map<wxString, wxString>& accounts, std::map<wxString, wxString>& categories)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -295,6 +296,8 @@ std::vector<Operation>* ImportEngine::GetOperations(std::map<wxString, wxString>
|
||||||
{
|
{
|
||||||
if (_operations[i].account.StartsWith(wxT("unknown-")))
|
if (_operations[i].account.StartsWith(wxT("unknown-")))
|
||||||
_operations[i].account = accounts[_operations[i].account.Mid(8)];
|
_operations[i].account = accounts[_operations[i].account.Mid(8)];
|
||||||
|
if (_operations[i].category.StartsWith(wxT("unknown-")))
|
||||||
|
_operations[i].category = categories[_operations[i].category.Mid(8)];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_kiss->GetOperationOrder() == wxT("ASC"))
|
if (_kiss->GetOperationOrder() == wxT("ASC"))
|
||||||
|
|
|
@ -47,10 +47,10 @@ public:
|
||||||
virtual bool HandleFile(const wxString& path, User* user, Database* db, KissCount* kiss)=0;
|
virtual bool HandleFile(const wxString& path, User* user, Database* db, KissCount* kiss)=0;
|
||||||
|
|
||||||
// Parse the file and return accounts that doesn't match
|
// Parse the file and return accounts that doesn't match
|
||||||
virtual std::vector<Account> ParseFile();
|
virtual void ParseFile(std::vector<Account>& accounts, std::vector<Category>& categories);
|
||||||
|
|
||||||
// Final Step
|
// Final Step
|
||||||
virtual std::vector<Operation>* GetOperations(std::map<wxString, wxString>& accounts);
|
virtual std::vector<Operation>* GetOperations(std::map<wxString, wxString>& accounts, std::map<wxString, wxString>& categories);
|
||||||
|
|
||||||
void MatchPattern(wxString& key, Operation& op);
|
void MatchPattern(wxString& key, Operation& op);
|
||||||
int UpdatePattern(int pos);
|
int UpdatePattern(int pos);
|
||||||
|
@ -68,7 +68,7 @@ protected:
|
||||||
std::map<wxString, wxString> _accounts;
|
std::map<wxString, wxString> _accounts;
|
||||||
std::map<wxString, wxString> _categories;
|
std::map<wxString, wxString> _categories;
|
||||||
std::vector<Account> _unresolvedAccounts;
|
std::vector<Account> _unresolvedAccounts;
|
||||||
std::vector<wxString> _unresolvedCategories;
|
std::vector<Category> _unresolvedCategories;
|
||||||
std::vector<Operation> _operations;
|
std::vector<Operation> _operations;
|
||||||
std::map<wxString, wxString> _descriptions;
|
std::map<wxString, wxString> _descriptions;
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
std::vector<Category>::iterator categoryIt;
|
std::vector<Category>::iterator categoryIt;
|
||||||
DEFAULT_FONT(font);
|
DEFAULT_FONT(font);
|
||||||
wxRect rect = wxDisplay().GetGeometry();
|
wxRect rect = wxDisplay().GetGeometry();
|
||||||
|
int nbCategories;
|
||||||
|
|
||||||
SetSizer(hbox);
|
SetSizer(hbox);
|
||||||
|
|
||||||
|
@ -82,14 +83,16 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
_categories[i] = wxGetTranslation(categoryIt->name) ;
|
_categories[i] = wxGetTranslation(categoryIt->name) ;
|
||||||
_categoriesIndexes[categoryIt->name] = i;
|
_categoriesIndexes[categoryIt->name] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
_dataset = new CategorySimpleDataset(_categories, user->GetCategoriesNumber());
|
nbCategories = (user->GetCategoriesNumber() <= MAX_CATEGORY) ? user->GetCategoriesNumber() : MAX_CATEGORY;
|
||||||
|
|
||||||
_categoriesValues = new double[user->GetCategoriesNumber()];
|
_categoriesValues = new double[user->GetCategoriesNumber()];
|
||||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||||
_categoriesValues[i] = 0.0;
|
_categoriesValues[i] = 0.0;
|
||||||
|
|
||||||
_dataset->AddSerie(_("Serie 1"), _categoriesValues, user->GetCategoriesNumber());
|
_dataset = new CategorySimpleDataset(_categories, nbCategories);
|
||||||
|
_dataset->AddSerie(_("Serie 1"), _categoriesValues, nbCategories);
|
||||||
|
|
||||||
_dataset->SetRenderer(new CategoryRenderer(*colorScheme));
|
_dataset->SetRenderer(new CategoryRenderer(*colorScheme));
|
||||||
_pie->SetDataset(_dataset);
|
_pie->SetDataset(_dataset);
|
||||||
_pie->SetColorScheme(colorScheme);
|
_pie->SetColorScheme(colorScheme);
|
||||||
|
@ -509,7 +512,7 @@ void AccountPanel::UpdateStats()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!op.transfert.Length())
|
if (!op.transfert.Length() && user->GetCategoryName(op.category) != _("Unknown"))
|
||||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
||||||
|
|
||||||
if (!op.transfert.Length() || op._virtual)
|
if (!op.transfert.Length() || op._virtual)
|
||||||
|
@ -545,7 +548,7 @@ void AccountPanel::UpdateStats()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!op.transfert.Length())
|
if (!op.transfert.Length() && user->GetCategoryName(op.category) != _("Unknown"))
|
||||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
||||||
|
|
||||||
if (!op.transfert.Length() && !op._virtual)
|
if (!op.transfert.Length() && !op._virtual)
|
||||||
|
@ -583,7 +586,7 @@ void AccountPanel::UpdateStats()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!op.transfert.Length())
|
if (!op.transfert.Length() && user->GetCategoryName(op.category) != _("Unknown"))
|
||||||
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
_categoriesValues[_categoriesIndexes[user->GetCategoryName(op.category)]] += -op.amount ;
|
||||||
|
|
||||||
if (!op.transfert.Length() && !op._virtual)
|
if (!op.transfert.Length() && !op._virtual)
|
||||||
|
|
|
@ -33,12 +33,14 @@ END_EVENT_TABLE()
|
||||||
ImportPanel::ImportPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent)
|
ImportPanel::ImportPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent)
|
||||||
{
|
{
|
||||||
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
||||||
|
wxBoxSizer *vbox2 = new wxBoxSizer(wxVERTICAL);
|
||||||
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||||
_hbox = new wxBoxSizer(wxHORIZONTAL);
|
_hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||||
wxButton* buttonOpen;
|
wxButton* buttonOpen;
|
||||||
wxRect rect = wxDisplay().GetGeometry();
|
wxRect rect = wxDisplay().GetGeometry();
|
||||||
int w, h;
|
int w, h;
|
||||||
wxStaticBox* staticAccount = new wxStaticBox(this, wxID_ANY, _("Unresolved accounts"));
|
wxStaticBox* staticAccount = new wxStaticBox(this, wxID_ANY, _("Unresolved accounts"));
|
||||||
|
wxStaticBox* staticCategory = new wxStaticBox(this, wxID_ANY, _("Unresolved categories"));
|
||||||
|
|
||||||
SetSizer(vbox);
|
SetSizer(vbox);
|
||||||
|
|
||||||
|
@ -73,12 +75,25 @@ ImportPanel::ImportPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent
|
||||||
_accountsGrid->SetColLabelValue(2, _("Internal account"));
|
_accountsGrid->SetColLabelValue(2, _("Internal account"));
|
||||||
_accountsGrid->Fit();
|
_accountsGrid->Fit();
|
||||||
|
|
||||||
|
_categoriesGrid = new wxGrid(this, wxID_ANY);
|
||||||
|
_categoriesGrid->CreateGrid(0, 3);
|
||||||
|
_categoriesGrid->SetRowLabelSize(0);
|
||||||
|
_categoriesGrid->SetColLabelValue(0, _("File category"));
|
||||||
|
_categoriesGrid->SetColLabelValue(1, _("Category name"));
|
||||||
|
_categoriesGrid->SetColLabelValue(2, _("Internal category"));
|
||||||
|
_categoriesGrid->Fit();
|
||||||
|
|
||||||
wxStaticBoxSizer* staticBoxSizer = new wxStaticBoxSizer (staticAccount, wxVERTICAL);
|
wxStaticBoxSizer* staticBoxSizer = new wxStaticBoxSizer (staticAccount, wxVERTICAL);
|
||||||
staticBoxSizer->Add(_accountsGrid, 0, wxGROW|wxALL, 2);
|
staticBoxSizer->Add(_accountsGrid, 0, wxGROW|wxALL, 2);
|
||||||
|
vbox2->Add(staticBoxSizer, wxGROW|wxALL);
|
||||||
|
|
||||||
|
staticBoxSizer = new wxStaticBoxSizer (staticCategory, wxVERTICAL);
|
||||||
|
staticBoxSizer->Add(_categoriesGrid, 0, wxGROW|wxALL, 2);
|
||||||
|
vbox2->Add(staticBoxSizer, wxGROW|wxALL);
|
||||||
|
|
||||||
_operationsGrid = new GridAccount(kiss, this, OPS_GRID_ID, false, false, false);
|
_operationsGrid = new GridAccount(kiss, this, OPS_GRID_ID, false, false, false);
|
||||||
|
|
||||||
_hbox->Add(staticBoxSizer, 0, wxGROW|wxALL, 15);
|
_hbox->Add(vbox2, 0, wxGROW|wxALL, 15);
|
||||||
_hbox->Add(_operationsGrid, 0, wxGROW|wxALL, 15);
|
_hbox->Add(_operationsGrid, 0, wxGROW|wxALL, 15);
|
||||||
|
|
||||||
vbox->Add(_hbox, wxGROW);
|
vbox->Add(_hbox, wxGROW);
|
||||||
|
@ -136,11 +151,15 @@ void ImportPanel::OnFileEnter(wxCommandEvent& WXUNUSED(event))
|
||||||
void ImportPanel::ProcessFile()
|
void ImportPanel::ProcessFile()
|
||||||
{
|
{
|
||||||
std::vector<Account> accounts;
|
std::vector<Account> accounts;
|
||||||
|
std::vector<Category> categories;
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
int i;
|
int i;
|
||||||
wxGridCellChoiceEditor* accountEditor;
|
wxGridCellChoiceEditor* accountEditor;
|
||||||
wxString* userAccounts;
|
wxString* userAccounts;
|
||||||
std::map<wxString, wxString> resolvedAccounts;
|
std::map<wxString, wxString> resolvedAccounts;
|
||||||
|
wxGridCellChoiceEditor* categoryEditor;
|
||||||
|
wxString* userCategories;
|
||||||
|
std::map<wxString, wxString> resolvedCategories;
|
||||||
wxCommandEvent event;
|
wxCommandEvent event;
|
||||||
|
|
||||||
wxString path = _fileTxt->GetLineText(0);
|
wxString path = _fileTxt->GetLineText(0);
|
||||||
|
@ -148,6 +167,7 @@ void ImportPanel::ProcessFile()
|
||||||
_buttonLoadOperations->Disable();
|
_buttonLoadOperations->Disable();
|
||||||
_buttonIntegrate->Disable();
|
_buttonIntegrate->Disable();
|
||||||
_accountsGrid->ClearGrid();
|
_accountsGrid->ClearGrid();
|
||||||
|
_categoriesGrid->ClearGrid();
|
||||||
_operationsGrid->ClearGrid();
|
_operationsGrid->ClearGrid();
|
||||||
|
|
||||||
_importEngine = _kiss->GetImportEngine(path);
|
_importEngine = _kiss->GetImportEngine(path);
|
||||||
|
@ -159,7 +179,7 @@ void ImportPanel::ProcessFile()
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
accounts = _importEngine->ParseFile();
|
_importEngine->ParseFile(accounts, categories);
|
||||||
|
|
||||||
if (accounts.size())
|
if (accounts.size())
|
||||||
{
|
{
|
||||||
|
@ -190,7 +210,37 @@ void ImportPanel::ProcessFile()
|
||||||
_accountsGrid->AutoSize();
|
_accountsGrid->AutoSize();
|
||||||
_accountsGrid->Layout();
|
_accountsGrid->Layout();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (categories.size())
|
||||||
|
{
|
||||||
|
int nb_categories = user->GetCategoriesNumber();
|
||||||
|
userCategories = new wxString[nb_categories+1];
|
||||||
|
|
||||||
|
userCategories[0] = _("Create one");
|
||||||
|
|
||||||
|
for(i=0; i<nb_categories; i++)
|
||||||
|
userCategories[i+1] = user->_categories[i].name;
|
||||||
|
|
||||||
|
categoryEditor = new wxGridCellChoiceEditor(nb_categories+1, userCategories, false);
|
||||||
|
|
||||||
|
_buttonLoadOperations->Enable();
|
||||||
|
|
||||||
|
_categoriesGrid->AppendRows(categories.size());
|
||||||
|
|
||||||
|
for (i=0; i<(int)categories.size(); i++)
|
||||||
|
{
|
||||||
|
_categoriesGrid->SetCellValue(i, 0, categories[i].name);
|
||||||
|
_categoriesGrid->SetReadOnly(i, 0);
|
||||||
|
_categoriesGrid->SetCellValue(i, 2, userCategories[0]);
|
||||||
|
|
||||||
|
_categoriesGrid->SetCellEditor(i, 2, categoryEditor);
|
||||||
|
}
|
||||||
|
|
||||||
|
_categoriesGrid->AutoSize();
|
||||||
|
_categoriesGrid->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!accounts.size() && !categories.size())
|
||||||
{
|
{
|
||||||
OnLoadOperations(event);
|
OnLoadOperations(event);
|
||||||
}
|
}
|
||||||
|
@ -200,27 +250,44 @@ void ImportPanel::ProcessFile()
|
||||||
void ImportPanel::OnLoadOperations(wxCommandEvent& WXUNUSED(event))
|
void ImportPanel::OnLoadOperations(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
std::map<wxString, wxString> resolvedAccounts;
|
std::map<wxString, wxString> resolvedAccounts;
|
||||||
int i, nbAccounts;
|
std::map<wxString, wxString> resolvedCategories;
|
||||||
|
int i, nbAccounts=0, nbCategories=0;
|
||||||
User* user = _kiss->GetUser();
|
User* user = _kiss->GetUser();
|
||||||
Account account;
|
Account account;
|
||||||
|
Category category;
|
||||||
|
|
||||||
for(i=0; i<_accountsGrid->GetNumberRows(); i++)
|
|
||||||
{
|
|
||||||
resolvedAccounts[_accountsGrid->GetCellValue(i, 0)] =
|
|
||||||
user->GetAccountId(_accountsGrid->GetCellValue(i, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
nbAccounts = 0;
|
|
||||||
for(i=0; i<_accountsGrid->GetNumberRows(); i++)
|
for(i=0; i<_accountsGrid->GetNumberRows(); i++)
|
||||||
{
|
{
|
||||||
if (_accountsGrid->GetCellValue(i, 2) == _("Create one"))
|
if (_accountsGrid->GetCellValue(i, 2) == _("Create one"))
|
||||||
nbAccounts++;
|
nbAccounts++;
|
||||||
|
else
|
||||||
|
resolvedAccounts[_accountsGrid->GetCellValue(i, 0)] =
|
||||||
|
user->GetAccountId(_accountsGrid->GetCellValue(i, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbAccounts)
|
for(i=0; i<_categoriesGrid->GetNumberRows(); i++)
|
||||||
{
|
{
|
||||||
wxString message = wxString::Format(wxT("%d"), nbAccounts);
|
if (_categoriesGrid->GetCellValue(i, 2) == _("Create one"))
|
||||||
message += _(" account(s) will be created, is it ok ?");
|
nbCategories++;
|
||||||
|
else
|
||||||
|
resolvedCategories[_categoriesGrid->GetCellValue(i, 0)] =
|
||||||
|
user->GetAccountId(_categoriesGrid->GetCellValue(i, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nbAccounts || nbCategories)
|
||||||
|
{
|
||||||
|
wxString message;
|
||||||
|
|
||||||
|
if (nbAccounts)
|
||||||
|
{
|
||||||
|
message += wxString::Format(wxT("%d accounts"), nbAccounts);
|
||||||
|
if (nbCategories) message += wxT(" and ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nbCategories)
|
||||||
|
message += wxString::Format(wxT("%d categories"), nbCategories);
|
||||||
|
|
||||||
|
message += _(" will be created, is it ok ?");
|
||||||
|
|
||||||
wxMessageDialog dialog(_wxUI, message, wxT("KissCount"), wxYES_NO);
|
wxMessageDialog dialog(_wxUI, message, wxT("KissCount"), wxYES_NO);
|
||||||
if (dialog.ShowModal() == wxID_NO)
|
if (dialog.ShowModal() == wxID_NO)
|
||||||
|
@ -247,10 +314,29 @@ void ImportPanel::OnLoadOperations(wxCommandEvent& WXUNUSED(event))
|
||||||
|
|
||||||
_accountsGrid->DeleteRows(0, _accountsGrid->GetNumberRows ());
|
_accountsGrid->DeleteRows(0, _accountsGrid->GetNumberRows ());
|
||||||
|
|
||||||
|
for(i=0; i<_categoriesGrid->GetNumberRows(); i++)
|
||||||
|
{
|
||||||
|
if (_categoriesGrid->GetCellValue(i, 2) == _("Create one"))
|
||||||
|
{
|
||||||
|
if (_categoriesGrid->GetCellValue(i, 1).Length())
|
||||||
|
category.name = _categoriesGrid->GetCellValue(i, 1);
|
||||||
|
else
|
||||||
|
category.name = _categoriesGrid->GetCellValue(i, 0);
|
||||||
|
category.parent = wxT("0");
|
||||||
|
category.backcolor = OWN_GREEN ;
|
||||||
|
category.forecolor = *wxBLACK;
|
||||||
|
category.fix_cost = false;
|
||||||
|
|
||||||
|
resolvedCategories[_categoriesGrid->GetCellValue(i, 0)] = category.id = _kiss->AddCategory(category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_categoriesGrid->DeleteRows(0, _categoriesGrid->GetNumberRows ());
|
||||||
|
|
||||||
_wxUI->NeedReload();
|
_wxUI->NeedReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
_operations = _importEngine->GetOperations(resolvedAccounts);
|
_operations = _importEngine->GetOperations(resolvedAccounts, resolvedCategories);
|
||||||
|
|
||||||
if (_operations->size())
|
if (_operations->size())
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxBoxSizer *_hbox;
|
wxBoxSizer *_hbox;
|
||||||
wxGrid* _accountsGrid;
|
wxGrid* _accountsGrid, *_categoriesGrid;
|
||||||
wxTextCtrl* _fileTxt;
|
wxTextCtrl* _fileTxt;
|
||||||
GridAccount* _operationsGrid;
|
GridAccount* _operationsGrid;
|
||||||
ImportEngine* _importEngine;
|
ImportEngine* _importEngine;
|
||||||
|
|
|
@ -38,6 +38,7 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent),
|
||||||
std::vector<Category>::iterator categoryIt;
|
std::vector<Category>::iterator categoryIt;
|
||||||
std::map<int, std::vector<int> > operations;
|
std::map<int, std::vector<int> > operations;
|
||||||
std::map<int, std::vector<int> >::iterator it;
|
std::map<int, std::vector<int> >::iterator it;
|
||||||
|
int nbCategories;
|
||||||
|
|
||||||
SetSizer(vbox);
|
SetSizer(vbox);
|
||||||
|
|
||||||
|
@ -110,14 +111,16 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent),
|
||||||
|
|
||||||
_pie = new PiePlot();
|
_pie = new PiePlot();
|
||||||
|
|
||||||
_dataset = new CategorySimpleDataset(_categories, user->GetCategoriesNumber());
|
nbCategories = (user->GetCategoriesNumber() <= MAX_CATEGORY) ? user->GetCategoriesNumber() : MAX_CATEGORY;
|
||||||
|
|
||||||
|
_dataset = new CategorySimpleDataset(_categories, nbCategories);
|
||||||
ColorScheme* colorScheme = new ColorScheme(categoryColors, WXSIZEOF(categoryColors));
|
ColorScheme* colorScheme = new ColorScheme(categoryColors, WXSIZEOF(categoryColors));
|
||||||
|
|
||||||
_categoriesValues = new double[user->GetCategoriesNumber()];
|
_categoriesValues = new double[user->GetCategoriesNumber()];
|
||||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||||
_categoriesValues[i] = 0.0;
|
_categoriesValues[i] = 0.0;
|
||||||
|
|
||||||
_dataset->AddSerie(_("Serie 1"), _categoriesValues, user->GetCategoriesNumber());
|
_dataset->AddSerie(_("Serie 1"), _categoriesValues, nbCategories);
|
||||||
_dataset->SetRenderer(new CategoryRenderer(*colorScheme));
|
_dataset->SetRenderer(new CategoryRenderer(*colorScheme));
|
||||||
_pie->SetDataset(_dataset);
|
_pie->SetDataset(_dataset);
|
||||||
_pie->SetColorScheme(colorScheme);
|
_pie->SetColorScheme(colorScheme);
|
||||||
|
|
|
@ -28,7 +28,7 @@ EVT_BUTTON(BUTTON_QUIT_ID, wxUI::OnButtonQuit)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
wxString months[12] ;
|
wxString months[12] ;
|
||||||
wxColour categoryColors[12] = {wxColour(0x00, 0x45, 0x86),
|
wxColour categoryColors[MAX_CATEGORY] = {wxColour(0x00, 0x45, 0x86),
|
||||||
wxColour(0xFF, 0x3E, 0x0E),
|
wxColour(0xFF, 0x3E, 0x0E),
|
||||||
wxColour(0xFF, 0xD3, 0x20),
|
wxColour(0xFF, 0xD3, 0x20),
|
||||||
wxColour(0x58, 0x9D, 0x1B),
|
wxColour(0x58, 0x9D, 0x1B),
|
||||||
|
|
|
@ -48,6 +48,8 @@ class PreferencesPanel;
|
||||||
extern wxString months[12];
|
extern wxString months[12];
|
||||||
extern wxColour categoryColors[12];
|
extern wxColour categoryColors[12];
|
||||||
|
|
||||||
|
#define MAX_CATEGORY 12
|
||||||
|
|
||||||
class wxUI: public wxFrame
|
class wxUI: public wxFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue