Add ascending/descending operation order in preferences

Remove default_preferences table
Force date by default in SearchPanel
Update TODO !!
Add a generic UpdatePreference instead of SetLanguage, SetXXX into Database
This commit is contained in:
2010-07-27 22:31:56 +02:00
parent c5ad18fd12
commit 8ad5e7d0ad
10 changed files with 104 additions and 23 deletions

View File

@@ -22,7 +22,8 @@ along with KissCount. If not, see <http://www.gnu.org/licenses/>.
enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_SHARED, ACCOUNT_DEFAULT, ACCOUNT_DELETE, NUMBER_COLS_ACCOUNT};
enum {CATEGORY_NAME, CATEGORY_COLOR, CATEGORY_FONT, CATEGORY_DELETE, NUMBER_COLS_CATEGORY};
enum {CATEGORIES_GRID_ID=1, ACCOUNTS_GRID_ID, NAME_ID, CHANGE_NAME_ID, CHANGE_PASSWORD_ID, KILL_ME_ID, LANGUAGE_ID};
enum {CATEGORIES_GRID_ID=1, ACCOUNTS_GRID_ID, NAME_ID, CHANGE_NAME_ID, CHANGE_PASSWORD_ID, KILL_ME_ID, LANGUAGE_ID,
OPERATION_ORDER_ID};
BEGIN_EVENT_TABLE(PreferencesPanel, wxPanel)
EVT_BUTTON(CHANGE_NAME_ID, PreferencesPanel::OnChangeName)
@@ -30,6 +31,7 @@ EVT_BUTTON(CHANGE_PASSWORD_ID, PreferencesPanel::OnChangePassword)
EVT_BUTTON(KILL_ME_ID, PreferencesPanel::OnKillMe)
EVT_GRID_CMD_CELL_CHANGE(CATEGORIES_GRID_ID, PreferencesPanel::OnCategoryModified)
EVT_GRID_CMD_CELL_CHANGE(ACCOUNTS_GRID_ID, PreferencesPanel::OnAccountModified)
EVT_COMBOBOX(OPERATION_ORDER_ID, PreferencesPanel::OnOperationOrderChange)
EVT_COMBOBOX(LANGUAGE_ID, PreferencesPanel::OnLanguageChange)
EVT_SHOW(PreferencesPanel::OnShow)
END_EVENT_TABLE()
@@ -37,8 +39,10 @@ END_EVENT_TABLE()
PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*parent)), _kiss(kiss), _wxUI(parent)
{
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *hbox1 = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *hbox2 = new wxBoxSizer(wxHORIZONTAL);
//wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
wxStaticBox* staticUser, *staticAccount, *staticCategories, *staticLanguage;
wxStaticBox* staticUser, *staticAccount, *staticCategories, *staticLanguage, *staticOperationOrder;
User* user = _kiss->GetUser();
wxGridBagSizer *gridBagSizer;
wxStaticText* label;
@@ -51,6 +55,7 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
staticAccount = new wxStaticBox(this, wxID_ANY, _("Accounts"));
staticCategories = new wxStaticBox(this, wxID_ANY, _("Categories"));
staticLanguage = new wxStaticBox(this, wxID_ANY, _("Language"));
staticOperationOrder = new wxStaticBox(this, wxID_ANY, _("Operation order"));
// User
staticBoxSizer = new wxStaticBoxSizer (staticUser, wxVERTICAL);
@@ -84,8 +89,8 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
staticBoxSizer->Add(_accountsGrid);
vbox->Add(staticBoxSizer);
vbox->Add(-1, 20);
hbox1->Add(staticBoxSizer);
hbox1->Add(-1, 20);
// Categories
staticBoxSizer = new wxStaticBoxSizer (staticCategories, wxVERTICAL);
@@ -96,9 +101,25 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
InitCategories(user);
vbox->Add(staticBoxSizer);
hbox1->Add(staticBoxSizer);
hbox1->Add(-1, 20);
vbox->Add(hbox1);
vbox->Add(-1, 20);
// Operation Order
staticBoxSizer = new wxStaticBoxSizer (staticOperationOrder, wxVERTICAL);
_operationOrder = new wxComboBox(this, OPERATION_ORDER_ID);
_operationOrder->SetWindowStyle(wxCB_READONLY);
staticBoxSizer->Add(_operationOrder);
hbox2->Add(staticBoxSizer);
hbox2->Add(-1, 20);
InitOperationOrder(user);
// Language
staticBoxSizer = new wxStaticBoxSizer (staticLanguage, wxVERTICAL);
@@ -107,12 +128,15 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
staticBoxSizer->Add(_language);
vbox->Add(staticBoxSizer);
hbox2->Add(staticBoxSizer);
hbox2->Add(-1, 20);
InitLanguage(user);
_language->Fit();
vbox->Add(hbox2);
Fit();
SetMinSize(GetSize());
@@ -226,6 +250,17 @@ void PreferencesPanel::InitLanguage(User* user)
_language->Select(select);
}
void PreferencesPanel::InitOperationOrder(User* user)
{
_operationOrder->Append(_("Ascending"));
_operationOrder->Append(_("Descending"));
if (user->_preferences[wxT("operation_order")] == wxT("ASC"))
_operationOrder->Select(0);
else
_operationOrder->Select(1);
}
void PreferencesPanel::OnAccountModified(wxGridEvent& event)
{
int op_complete = 2;
@@ -511,6 +546,16 @@ void PreferencesPanel::OnChangePassword(wxCommandEvent& event)
p.ShowModal();
}
void PreferencesPanel::OnOperationOrderChange(wxCommandEvent& event)
{
if (_operationOrder->GetCurrentSelection() == 0)
_kiss->SetOperationOrder(wxT("ASC"));
else
_kiss->SetOperationOrder(wxT("DESC"));
_wxUI->NeedReload();
}
void PreferencesPanel::OnLanguageChange(wxCommandEvent& event)
{
wxLanguage language = languages[_language->GetSelection()].language;
@@ -522,7 +567,6 @@ void PreferencesPanel::OnLanguageChange(wxCommandEvent& event)
}
else
wxMessageBox(_("Language not changed"), _("KissCount"), wxICON_ERROR | wxOK);
}
void PreferencesPanel::OnShow(wxShowEvent& event)