Fix bugs in account/category modification/deletion
Fix some strings
This commit is contained in:
parent
c88c3b4836
commit
765483ff15
Binary file not shown.
|
@ -151,7 +151,7 @@ msgstr "Catégorie"
|
||||||
#: src/view/PreferencesPanel.cpp:657
|
#: src/view/PreferencesPanel.cpp:657
|
||||||
#: src/view/PreferencesPanel.cpp:676
|
#: src/view/PreferencesPanel.cpp:676
|
||||||
msgid "Category "
|
msgid "Category "
|
||||||
msgstr "Catégorie"
|
msgstr "La catégorie "
|
||||||
|
|
||||||
#: src/view/PreferencesPanel.cpp:77
|
#: src/view/PreferencesPanel.cpp:77
|
||||||
msgid "Change Name"
|
msgid "Change Name"
|
||||||
|
@ -359,7 +359,7 @@ msgstr "Il doit y avoir au moins un compte !"
|
||||||
|
|
||||||
#: src/view/AccountPanel.cpp:724
|
#: src/view/AccountPanel.cpp:724
|
||||||
msgid "It must be at least one month !"
|
msgid "It must be at least one month !"
|
||||||
msgstr "Il doit rester au mois un mois"
|
msgstr "Il doit rester au moins un mois"
|
||||||
|
|
||||||
#: src/view/PreferencesPanel.cpp:79
|
#: src/view/PreferencesPanel.cpp:79
|
||||||
msgid "Kill me"
|
msgid "Kill me"
|
||||||
|
@ -434,7 +434,7 @@ msgstr "Ancien mot de passe"
|
||||||
|
|
||||||
#: src/controller/KissCount.cpp:359
|
#: src/controller/KissCount.cpp:359
|
||||||
msgid "Operating exepense"
|
msgid "Operating exepense"
|
||||||
msgstr "Frais de fonctionnement"
|
msgstr "Fonctionnement"
|
||||||
|
|
||||||
#: src/view/PreferencesPanel.cpp:62
|
#: src/view/PreferencesPanel.cpp:62
|
||||||
msgid "Operation order"
|
msgid "Operation order"
|
||||||
|
|
|
@ -155,9 +155,15 @@ void KissCount::SetAccountAmount(int month, int year, const wxString& accountId,
|
||||||
|
|
||||||
wxString KissCount::AddAccount(Account& ac)
|
wxString KissCount::AddAccount(Account& ac)
|
||||||
{
|
{
|
||||||
|
wxDateTime curDate;
|
||||||
|
|
||||||
ac.id = _db->AddAccount(_user, ac);
|
ac.id = _db->AddAccount(_user, ac);
|
||||||
_user->_accounts.push_back(ac);
|
_user->_accounts.push_back(ac);
|
||||||
|
|
||||||
|
curDate.SetToCurrent();
|
||||||
|
|
||||||
|
SetAccountAmount((int)curDate.GetMonth(), curDate.GetYear(), ac.id, 0.0);
|
||||||
|
|
||||||
return ac.id;
|
return ac.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -329,11 +329,16 @@ User* Database::LoadUser(const wxString& name)
|
||||||
category.forecolor = wxColour(set.GetAsString(wxT("forecolor")));
|
category.forecolor = wxColour(set.GetAsString(wxT("forecolor")));
|
||||||
category.font = set.GetAsString(wxT("font"));
|
category.font = set.GetAsString(wxT("font"));
|
||||||
if (category.name != _("Fix"))
|
if (category.name != _("Fix"))
|
||||||
|
{
|
||||||
user->_categories.push_back(category);
|
user->_categories.push_back(category);
|
||||||
else
|
|
||||||
user->_categories.insert(user->_categories.begin(), category);
|
|
||||||
user->_categoriesFonts.push_back(_kiss->ExtractFont(category.font));
|
user->_categoriesFonts.push_back(_kiss->ExtractFont(category.font));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
user->_categories.insert(user->_categories.begin(), category);
|
||||||
|
user->_categoriesFonts.insert(user->_categoriesFonts.begin(), _kiss->ExtractFont(category.font));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set.Finalize();
|
set.Finalize();
|
||||||
|
|
||||||
|
@ -620,7 +625,7 @@ void Database::DeleteOperations(User* user, int month, int year)
|
||||||
req += wxT("', '") + it->id ;
|
req += wxT("', '") + it->id ;
|
||||||
}
|
}
|
||||||
req += wxT("')");
|
req += wxT("')");
|
||||||
req += wxT(" OR user='") + user->_id + wxT("'");
|
req += wxT(" OR user='") + user->_id + wxT("')");
|
||||||
req += wxT(" AND year='") + wxString::Format(wxT("%d"), year) + wxT("'");
|
req += wxT(" AND year='") + wxString::Format(wxT("%d"), year) + wxT("'");
|
||||||
if (month != -1)
|
if (month != -1)
|
||||||
req += wxT(" AND month='") + wxString::Format(wxT("%d"), month) + wxT("'");
|
req += wxT(" AND month='") + wxString::Format(wxT("%d"), month) + wxT("'");
|
||||||
|
|
|
@ -186,13 +186,13 @@ void AccountPanel::InitStatsGrid(User* user)
|
||||||
_statsGrid->SetCellValue(TOTAL_CREDIT, 0, _("Total Credit"));
|
_statsGrid->SetCellValue(TOTAL_CREDIT, 0, _("Total Credit"));
|
||||||
_statsGrid->SetCellValue(TOTAL_DEBIT, 0, _("Total Debit"));
|
_statsGrid->SetCellValue(TOTAL_DEBIT, 0, _("Total Debit"));
|
||||||
|
|
||||||
_statsGrid->AutoSizeColumn(0, false);
|
|
||||||
|
|
||||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
for(i=0; i<user->GetCategoriesNumber(); i++)
|
||||||
{
|
{
|
||||||
_statsGrid->SetCellValue(CATS_STATS+i, 0, _categories[i]);
|
_statsGrid->SetCellValue(CATS_STATS+i, 0, _categories[i]);
|
||||||
_statsGrid->SetCellAlignment(CATS_STATS+i, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
_statsGrid->SetCellAlignment(CATS_STATS+i, 1, wxALIGN_RIGHT, wxALIGN_CENTRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_statsGrid->AutoSizeColumn(0, false);
|
||||||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||||
_statsGrid->SetCellFont(CUR_CREDIT, 0, font);
|
_statsGrid->SetCellFont(CUR_CREDIT, 0, font);
|
||||||
_statsGrid->SetCellFont(CUR_DEBIT, 0, font);
|
_statsGrid->SetCellFont(CUR_DEBIT, 0, font);
|
||||||
|
@ -227,6 +227,8 @@ void AccountPanel::ChangeUser()
|
||||||
rootNode = _tree.AddRoot(wxT(""));
|
rootNode = _tree.AddRoot(wxT(""));
|
||||||
|
|
||||||
curDate.SetToCurrent();
|
curDate.SetToCurrent();
|
||||||
|
if (ops.size())
|
||||||
|
{
|
||||||
for(it = ops.begin(); it != ops.end(); it++)
|
for(it = ops.begin(); it != ops.end(); it++)
|
||||||
{
|
{
|
||||||
if ((int)it->first <= curDate.GetYear())
|
if ((int)it->first <= curDate.GetYear())
|
||||||
|
@ -244,6 +246,13 @@ void AccountPanel::ChangeUser()
|
||||||
LoadYear(curYear);
|
LoadYear(curYear);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curNode = _tree.AppendItem(rootNode, wxString::Format(wxT("%d"), curDate.GetYear()));
|
||||||
|
_tree.AppendItem(curNode, months[(int)curDate.GetYear()]);
|
||||||
|
Fit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AccountPanel::LoadYear(int year, bool showMonth)
|
void AccountPanel::LoadYear(int year, bool showMonth)
|
||||||
{
|
{
|
||||||
|
@ -719,7 +728,7 @@ void AccountPanel::OnMenuDelete(wxCommandEvent& event)
|
||||||
|
|
||||||
ops = _kiss->GetAllOperations();
|
ops = _kiss->GetAllOperations();
|
||||||
|
|
||||||
if (ops.size() == 1 && ops[year].size() == 1)
|
if (ops.size() == 1 && (ops[year].size() == 1 || month == -1))
|
||||||
{
|
{
|
||||||
wxMessageBox(_("It must be at least one month !"), _("Error"), wxICON_ERROR | wxOK);
|
wxMessageBox(_("It must be at least one month !"), _("Error"), wxICON_ERROR | wxOK);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -111,7 +111,10 @@ GenerateDialog::GenerateDialog(KissCount* kiss, wxUI *parent, int month, int yea
|
||||||
_yearTo->Select(year-2000);
|
_yearTo->Select(year-2000);
|
||||||
OnYearToChange(event);
|
OnYearToChange(event);
|
||||||
if (_ops[year].size())
|
if (_ops[year].size())
|
||||||
|
{
|
||||||
month = _ops[year][0];
|
month = _ops[year][0];
|
||||||
|
_yearTo->Select(year-1999);
|
||||||
|
}
|
||||||
|
|
||||||
if (month == -1)
|
if (month == -1)
|
||||||
_monthTo->Select(0);
|
_monthTo->Select(0);
|
||||||
|
|
|
@ -191,42 +191,54 @@ void PreferencesPanel::InitAccounts(User* user)
|
||||||
for (it = user->_accounts.begin(); it != user->_accounts.end(); it++, curLine++)
|
for (it = user->_accounts.begin(); it != user->_accounts.end(); it++, curLine++)
|
||||||
{
|
{
|
||||||
_accountsGrid->AppendRows();
|
_accountsGrid->AppendRows();
|
||||||
|
AddAccount(curLine, *it);
|
||||||
|
}
|
||||||
|
|
||||||
_accountsGrid->SetCellValue(curLine, ACCOUNT_NAME, it->name);
|
_accountsGrid->AppendRows();
|
||||||
if (it->shared)
|
account.id = wxT("0");
|
||||||
_accountsGrid->SetCellValue(curLine, ACCOUNT_NUMBER, it->number + wxT("*"));
|
AddAccount(curLine, account);
|
||||||
else
|
}
|
||||||
_accountsGrid->SetCellValue(curLine, ACCOUNT_NUMBER, it->number);
|
|
||||||
|
|
||||||
_accountsGrid->SetCellEditor(curLine, ACCOUNT_NUMBER, new wxGridCellStarEditor ());
|
void PreferencesPanel::AddAccount(int line, Account ac)
|
||||||
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ());
|
|
||||||
_accountsGrid->SetCellEditor(curLine, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ());
|
|
||||||
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_BLOCKED, new wxGridCellBoolRenderer ());
|
|
||||||
_accountsGrid->SetCellEditor(curLine, ACCOUNT_BLOCKED, new wxGridCellFastBoolEditor ());
|
|
||||||
_accountsGrid->SetCellRenderer(curLine, ACCOUNT_DELETE, new wxGridCellBoolRenderer ());
|
|
||||||
_accountsGrid->SetCellEditor(curLine, ACCOUNT_DELETE, new wxGridCellBoolEditor ());
|
|
||||||
_accountsGrid->SetCellValue(curLine, ACCOUNT_DEFAULT, (it->_default)?wxT("1"):wxT("0"));
|
|
||||||
_accountsGrid->SetCellValue(curLine, ACCOUNT_BLOCKED, (it->blocked)?wxT("1"):wxT("0"));
|
|
||||||
|
|
||||||
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
|
||||||
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_BLOCKED, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
|
||||||
_accountsGrid->SetCellAlignment(curLine, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
|
||||||
|
|
||||||
if (!it->is_owner)
|
|
||||||
{
|
{
|
||||||
_accountsGrid->SetReadOnly(curLine, ACCOUNT_NAME, true);
|
if (ac.id != wxT("0"))
|
||||||
_accountsGrid->SetReadOnly(curLine, ACCOUNT_NUMBER, true);
|
{
|
||||||
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true);
|
_accountsGrid->SetCellValue(line, ACCOUNT_NAME, ac.name);
|
||||||
_accountsGrid->SetReadOnly(curLine, ACCOUNT_BLOCKED, true);
|
if (ac.shared)
|
||||||
|
_accountsGrid->SetCellValue(line, ACCOUNT_NUMBER, ac.number + wxT("*"));
|
||||||
|
else
|
||||||
|
_accountsGrid->SetCellValue(line, ACCOUNT_NUMBER, ac.number);
|
||||||
|
|
||||||
|
_accountsGrid->SetCellEditor(line, ACCOUNT_NUMBER, new wxGridCellStarEditor ());
|
||||||
|
_accountsGrid->SetCellRenderer(line, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ());
|
||||||
|
_accountsGrid->SetCellEditor(line, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ());
|
||||||
|
_accountsGrid->SetCellRenderer(line, ACCOUNT_BLOCKED, new wxGridCellBoolRenderer ());
|
||||||
|
_accountsGrid->SetCellEditor(line, ACCOUNT_BLOCKED, new wxGridCellFastBoolEditor ());
|
||||||
|
_accountsGrid->SetCellRenderer(line, ACCOUNT_DELETE, new wxGridCellBoolRenderer ());
|
||||||
|
_accountsGrid->SetCellEditor(line, ACCOUNT_DELETE, new wxGridCellBoolEditor ());
|
||||||
|
_accountsGrid->SetCellValue(line, ACCOUNT_DEFAULT, (ac._default)?wxT("1"):wxT("0"));
|
||||||
|
_accountsGrid->SetCellValue(line, ACCOUNT_BLOCKED, (ac.blocked)?wxT("1"):wxT("0"));
|
||||||
|
|
||||||
|
_accountsGrid->SetCellAlignment(line, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||||
|
_accountsGrid->SetCellAlignment(line, ACCOUNT_BLOCKED, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||||
|
_accountsGrid->SetCellAlignment(line, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||||
|
|
||||||
|
if (!ac.is_owner)
|
||||||
|
{
|
||||||
|
_accountsGrid->SetReadOnly(line, ACCOUNT_NAME, true);
|
||||||
|
_accountsGrid->SetReadOnly(line, ACCOUNT_NUMBER, true);
|
||||||
|
_accountsGrid->SetReadOnly(line, ACCOUNT_DEFAULT, true);
|
||||||
|
_accountsGrid->SetReadOnly(line, ACCOUNT_BLOCKED, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_accountsGrid->SetReadOnly(line, ACCOUNT_DEFAULT, true);
|
||||||
|
_accountsGrid->SetReadOnly(line, ACCOUNT_BLOCKED, true);
|
||||||
|
_accountsGrid->SetReadOnly(line, ACCOUNT_DELETE, true);
|
||||||
|
|
||||||
_accountsGrid->AutoSizeColumns(true);
|
_accountsGrid->AutoSizeColumns(true);
|
||||||
_accountsGrid->AppendRows();
|
}
|
||||||
|
|
||||||
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DEFAULT, true);
|
|
||||||
_accountsGrid->SetReadOnly(curLine, ACCOUNT_BLOCKED, true);
|
|
||||||
_accountsGrid->SetReadOnly(curLine, ACCOUNT_DELETE, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SET_ROW_COLOR(row, backcolor, forecolor) for(int i=0; i<NUMBER_COLS_CATEGORY; i++) \
|
#define SET_ROW_COLOR(row, backcolor, forecolor) for(int i=0; i<NUMBER_COLS_CATEGORY; i++) \
|
||||||
|
@ -245,6 +257,7 @@ void PreferencesPanel::InitCategories(User* user)
|
||||||
std::vector<Category>::iterator it;
|
std::vector<Category>::iterator it;
|
||||||
int curLine = 0;
|
int curLine = 0;
|
||||||
DEFAULT_FONT(font);
|
DEFAULT_FONT(font);
|
||||||
|
Category cat;
|
||||||
|
|
||||||
_categoriesGrid->CreateGrid(0, NUMBER_COLS_CATEGORY);
|
_categoriesGrid->CreateGrid(0, NUMBER_COLS_CATEGORY);
|
||||||
_categoriesGrid->SetRowLabelSize(0);
|
_categoriesGrid->SetRowLabelSize(0);
|
||||||
|
@ -259,41 +272,56 @@ void PreferencesPanel::InitCategories(User* user)
|
||||||
for (it=user->_categories.begin(); it!=user->_categories.end(); it++, curLine++)
|
for (it=user->_categories.begin(); it!=user->_categories.end(); it++, curLine++)
|
||||||
{
|
{
|
||||||
_categoriesGrid->AppendRows();
|
_categoriesGrid->AppendRows();
|
||||||
|
AddCategory(curLine, *it);
|
||||||
_categoriesGrid->SetCellValue(curLine, CATEGORY_NAME, it->name);
|
|
||||||
SET_ROW_COLOR(curLine, it->backcolor, it->forecolor);
|
|
||||||
if (curLine)
|
|
||||||
{
|
|
||||||
_categoriesGrid->SetCellRenderer(curLine, CATEGORY_DELETE, new wxGridCellBoolRenderer ());
|
|
||||||
_categoriesGrid->SetCellEditor(curLine, CATEGORY_DELETE, new wxGridCellBoolEditor ());
|
|
||||||
}
|
|
||||||
|
|
||||||
_categoriesGrid->SetCellRenderer(curLine, CATEGORY_BACKGROUND_COLOR, new wxGridCellButtonRenderer (wxT("...")));
|
|
||||||
_categoriesGrid->SetCellRenderer(curLine, CATEGORY_FOREGROUND_COLOR, new wxGridCellButtonRenderer (wxT("...")));
|
|
||||||
_categoriesGrid->SetCellRenderer(curLine, CATEGORY_FONT, new wxGridCellButtonRenderer (wxT("...")));
|
|
||||||
_categoriesGrid->SetCellEditor(curLine, CATEGORY_BACKGROUND_COLOR, new wxGridCellButtonEditor (wxT("...")));
|
|
||||||
_categoriesGrid->SetCellEditor(curLine, CATEGORY_FOREGROUND_COLOR, new wxGridCellButtonEditor (wxT("...")));
|
|
||||||
_categoriesGrid->SetCellEditor(curLine, CATEGORY_FONT, new wxGridCellButtonEditor (wxT("...")));
|
|
||||||
|
|
||||||
if (it->font.Length())
|
|
||||||
{
|
|
||||||
wxFont font = user->GetCategoryFont(it->id);
|
|
||||||
SET_ROW_FONT(curLine, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
_categoriesGrid->SetCellAlignment(curLine, CATEGORY_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_categoriesGrid->SetReadOnly(0, CATEGORY_NAME, true);
|
_categoriesGrid->SetReadOnly(0, CATEGORY_NAME, true);
|
||||||
_categoriesGrid->SetReadOnly(0, CATEGORY_DELETE, true);
|
_categoriesGrid->SetReadOnly(0, CATEGORY_DELETE, true);
|
||||||
_categoriesGrid->AutoSizeColumns(true);
|
|
||||||
|
|
||||||
|
cat.id = wxT("0");
|
||||||
_categoriesGrid->AppendRows();
|
_categoriesGrid->AppendRows();
|
||||||
_categoriesGrid->SetReadOnly(curLine, CATEGORY_BACKGROUND_COLOR, true);
|
AddCategory(curLine, cat);
|
||||||
_categoriesGrid->SetReadOnly(curLine, CATEGORY_FOREGROUND_COLOR, true);
|
}
|
||||||
_categoriesGrid->SetReadOnly(curLine, CATEGORY_FONT, true);
|
|
||||||
_categoriesGrid->SetReadOnly(curLine, CATEGORY_DELETE, true);
|
void PreferencesPanel::AddCategory(int line, Category cat)
|
||||||
SET_ROW_COLOR(curLine, OWN_GREEN, *wxBLACK);
|
{
|
||||||
|
User* user = _kiss->GetUser();
|
||||||
|
|
||||||
|
if (cat.id != wxT("0"))
|
||||||
|
{
|
||||||
|
_categoriesGrid->SetCellValue(line, CATEGORY_NAME, cat.name);
|
||||||
|
SET_ROW_COLOR(line, cat.backcolor, cat.forecolor);
|
||||||
|
if (line)
|
||||||
|
{
|
||||||
|
_categoriesGrid->SetCellRenderer(line, CATEGORY_DELETE, new wxGridCellBoolRenderer ());
|
||||||
|
_categoriesGrid->SetCellEditor(line, CATEGORY_DELETE, new wxGridCellBoolEditor ());
|
||||||
|
}
|
||||||
|
|
||||||
|
_categoriesGrid->SetCellRenderer(line, CATEGORY_BACKGROUND_COLOR, new wxGridCellButtonRenderer (wxT("...")));
|
||||||
|
_categoriesGrid->SetCellRenderer(line, CATEGORY_FOREGROUND_COLOR, new wxGridCellButtonRenderer (wxT("...")));
|
||||||
|
_categoriesGrid->SetCellRenderer(line, CATEGORY_FONT, new wxGridCellButtonRenderer (wxT("...")));
|
||||||
|
_categoriesGrid->SetCellEditor(line, CATEGORY_BACKGROUND_COLOR, new wxGridCellButtonEditor (wxT("...")));
|
||||||
|
_categoriesGrid->SetCellEditor(line, CATEGORY_FOREGROUND_COLOR, new wxGridCellButtonEditor (wxT("...")));
|
||||||
|
_categoriesGrid->SetCellEditor(line, CATEGORY_FONT, new wxGridCellButtonEditor (wxT("...")));
|
||||||
|
|
||||||
|
if (cat.font.Length())
|
||||||
|
{
|
||||||
|
wxFont font = user->GetCategoryFont(cat.id);
|
||||||
|
SET_ROW_FONT(line, font);
|
||||||
|
}
|
||||||
|
|
||||||
|
_categoriesGrid->SetCellAlignment(line, CATEGORY_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_categoriesGrid->SetReadOnly(line, CATEGORY_BACKGROUND_COLOR, true);
|
||||||
|
_categoriesGrid->SetReadOnly(line, CATEGORY_FOREGROUND_COLOR, true);
|
||||||
|
_categoriesGrid->SetReadOnly(line, CATEGORY_FONT, true);
|
||||||
|
_categoriesGrid->SetReadOnly(line, CATEGORY_DELETE, true);
|
||||||
|
SET_ROW_COLOR(line, OWN_GREEN, *wxBLACK);
|
||||||
|
|
||||||
|
_categoriesGrid->AutoSizeColumns(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesPanel::InitLanguage(User* user)
|
void PreferencesPanel::InitLanguage(User* user)
|
||||||
|
@ -362,24 +390,6 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
|
||||||
else
|
else
|
||||||
new_account.blocked = false;
|
new_account.blocked = false;
|
||||||
|
|
||||||
if (col == ACCOUNT_DEFAULT)
|
|
||||||
{
|
|
||||||
for (i=0; i<user->GetAccountsNumber(); i++)
|
|
||||||
{
|
|
||||||
if (i != row)
|
|
||||||
{
|
|
||||||
account = user->_accounts[i];
|
|
||||||
if (account._default)
|
|
||||||
{
|
|
||||||
account._default = false;
|
|
||||||
_kiss->UpdateAccount(account);
|
|
||||||
_accountsGrid->SetCellValue(i, ACCOUNT_DEFAULT, wxT(""));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Account modification
|
// Account modification
|
||||||
if (user->GetAccountsNumber() && row < user->GetAccountsNumber())
|
if (user->GetAccountsNumber() && row < user->GetAccountsNumber())
|
||||||
{
|
{
|
||||||
|
@ -406,19 +416,49 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
|
||||||
_kiss->DeleteAccount(new_account);
|
_kiss->DeleteAccount(new_account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user->_accounts.size() == 1)
|
||||||
|
{
|
||||||
|
user->_accounts[0]._default = true;
|
||||||
|
_kiss->UpdateAccount(user->_accounts[0]);
|
||||||
|
_accountsGrid->SetCellValue(0, ACCOUNT_DEFAULT, wxT("1"));
|
||||||
|
}
|
||||||
|
|
||||||
_wxUI->Layout();
|
_wxUI->Layout();
|
||||||
inModification = false;
|
inModification = false;
|
||||||
_wxUI->NeedReload();
|
_wxUI->NeedReload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user->GetAccountId(new_account.name) != new_account.id)
|
if (col == ACCOUNT_DEFAULT)
|
||||||
|
{
|
||||||
|
for (i=0; i<user->GetAccountsNumber(); i++)
|
||||||
|
{
|
||||||
|
if (i != row)
|
||||||
|
{
|
||||||
|
account = user->_accounts[i];
|
||||||
|
if (account._default)
|
||||||
|
{
|
||||||
|
account._default = false;
|
||||||
|
_kiss->UpdateAccount(account);
|
||||||
|
_accountsGrid->SetCellValue(i, ACCOUNT_DEFAULT, wxT(""));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (col == ACCOUNT_NAME)
|
||||||
|
{
|
||||||
|
value = user->GetAccountId(new_account.name);
|
||||||
|
if (value != wxT("0") && value != new_account.id)
|
||||||
{
|
{
|
||||||
wxMessageBox(_("Account ")+new_account.name+_(" already exists"), _("Error"), wxICON_ERROR | wxOK );
|
wxMessageBox(_("Account ")+new_account.name+_(" already exists"), _("Error"), wxICON_ERROR | wxOK );
|
||||||
_accountsGrid->SetCellValue(row, ACCOUNT_NAME, user->_accounts[row].name);
|
_accountsGrid->SetCellValue(row, ACCOUNT_NAME, user->_accounts[row].name);
|
||||||
inModification = false;
|
inModification = false;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_kiss->UpdateAccount(new_account);
|
_kiss->UpdateAccount(new_account);
|
||||||
}
|
}
|
||||||
|
@ -441,34 +481,13 @@ void PreferencesPanel::OnAccountModified(wxGridEvent& event)
|
||||||
new_account.shared = false;
|
new_account.shared = false;
|
||||||
new_account.blocked = false;
|
new_account.blocked = false;
|
||||||
|
|
||||||
_accountsGrid->SetCellRenderer(row, ACCOUNT_DEFAULT, new wxGridCellBoolRenderer ());
|
AddAccount(row, new_account);
|
||||||
_accountsGrid->SetCellEditor(row, ACCOUNT_DEFAULT, new wxGridCellFastBoolEditor ());
|
|
||||||
_accountsGrid->SetCellRenderer(row, ACCOUNT_BLOCKED, new wxGridCellBoolRenderer ());
|
|
||||||
_accountsGrid->SetCellEditor(row, ACCOUNT_BLOCKED, new wxGridCellFastBoolEditor ());
|
|
||||||
_accountsGrid->SetCellRenderer(row, ACCOUNT_DELETE, new wxGridCellBoolRenderer ());
|
|
||||||
_accountsGrid->SetCellEditor(row, ACCOUNT_DELETE, new wxGridCellBoolEditor ());
|
|
||||||
_accountsGrid->SetCellAlignment(row, ACCOUNT_DEFAULT, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
|
||||||
_accountsGrid->SetCellAlignment(row, ACCOUNT_BLOCKED, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
|
||||||
_accountsGrid->SetCellAlignment(row, ACCOUNT_DELETE, wxALIGN_CENTRE, wxALIGN_CENTRE);
|
|
||||||
|
|
||||||
_accountsGrid->SetReadOnly(row, ACCOUNT_DEFAULT, false);
|
|
||||||
_accountsGrid->SetReadOnly(row, ACCOUNT_BLOCKED, false);
|
|
||||||
_accountsGrid->SetReadOnly(row, ACCOUNT_DELETE, false);
|
|
||||||
|
|
||||||
if (!user->GetAccountsNumber())
|
|
||||||
{
|
|
||||||
new_account._default = true;
|
|
||||||
_accountsGrid->SetCellValue(row, ACCOUNT_DEFAULT, wxT("1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
_accountsGrid->AutoSizeColumns(true);
|
|
||||||
_accountsGrid->AppendRows();
|
|
||||||
|
|
||||||
_accountsGrid->SetReadOnly(row+1, ACCOUNT_DEFAULT, true);
|
|
||||||
_accountsGrid->SetReadOnly(row+1, ACCOUNT_BLOCKED, true);
|
|
||||||
_accountsGrid->SetReadOnly(row+1, ACCOUNT_DELETE, true);
|
|
||||||
|
|
||||||
_kiss->AddAccount(new_account);
|
_kiss->AddAccount(new_account);
|
||||||
|
|
||||||
|
_accountsGrid->AppendRows();
|
||||||
|
new_account.id = wxT("0");
|
||||||
|
|
||||||
|
AddAccount(row, new_account);
|
||||||
}
|
}
|
||||||
|
|
||||||
_wxUI->Layout();
|
_wxUI->Layout();
|
||||||
|
@ -552,7 +571,7 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
|
||||||
int row = event.GetRow();
|
int row = event.GetRow();
|
||||||
int col = event.GetCol();
|
int col = event.GetCol();
|
||||||
static bool inModification = false ;
|
static bool inModification = false ;
|
||||||
Category new_cat;
|
Category new_cat, cat_tmp;
|
||||||
|
|
||||||
if (inModification) return;
|
if (inModification) return;
|
||||||
|
|
||||||
|
@ -652,7 +671,8 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user->GetCategoryId(new_cat.name) != new_cat.id)
|
value = user->GetCategoryId(new_cat.name);
|
||||||
|
if (value != wxT("0") && value != new_cat.id)
|
||||||
{
|
{
|
||||||
wxMessageBox(_("Category ")+new_cat.name+_(" already exists"), _("Error"), wxICON_ERROR | wxOK );
|
wxMessageBox(_("Category ")+new_cat.name+_(" already exists"), _("Error"), wxICON_ERROR | wxOK );
|
||||||
_categoriesGrid->SetCellValue(row, CATEGORY_NAME, user->_categories[row].name);
|
_categoriesGrid->SetCellValue(row, CATEGORY_NAME, user->_categories[row].name);
|
||||||
|
@ -679,20 +699,11 @@ void PreferencesPanel::OnCategoryModified(wxGridEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
_kiss->AddCategory(new_cat);
|
_kiss->AddCategory(new_cat);
|
||||||
_categoriesGrid->SetReadOnly(row, CATEGORY_BACKGROUND_COLOR, false);
|
AddCategory(row, new_cat);
|
||||||
_categoriesGrid->SetReadOnly(row, CATEGORY_FOREGROUND_COLOR, false);
|
|
||||||
_categoriesGrid->SetReadOnly(row, CATEGORY_FONT, false);
|
|
||||||
_categoriesGrid->SetReadOnly(row, CATEGORY_DELETE, false);
|
|
||||||
_categoriesGrid->SetCellRenderer(row, CATEGORY_DELETE, new wxGridCellBoolRenderer ());
|
|
||||||
_categoriesGrid->SetCellEditor(row, CATEGORY_DELETE, new wxGridCellBoolEditor ());
|
|
||||||
|
|
||||||
row++;
|
new_cat.id = wxT("0");
|
||||||
_categoriesGrid->AppendRows();
|
_categoriesGrid->AppendRows();
|
||||||
_categoriesGrid->SetReadOnly(row, CATEGORY_BACKGROUND_COLOR, true);
|
AddCategory(++row, new_cat);
|
||||||
_categoriesGrid->SetReadOnly(row, CATEGORY_FOREGROUND_COLOR, true);
|
|
||||||
_categoriesGrid->SetReadOnly(row, CATEGORY_FONT, true);
|
|
||||||
_categoriesGrid->SetReadOnly(row, CATEGORY_DELETE, true);
|
|
||||||
SET_ROW_COLOR(row, OWN_GREEN, *wxBLACK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_wxUI->Layout();
|
_wxUI->Layout();
|
||||||
|
|
|
@ -75,6 +75,9 @@ private:
|
||||||
void InitLanguage(User* user);
|
void InitLanguage(User* user);
|
||||||
void InitOperationOrder(User* user);
|
void InitOperationOrder(User* user);
|
||||||
|
|
||||||
|
void AddAccount(int line, Account ac);
|
||||||
|
void AddCategory(int line, Category cat);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user