From: <vo...@us...> - 2012-08-27 22:20:55
|
Revision: 2921 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=2921&view=rev Author: vomikan Date: 2012-08-27 22:20:48 +0000 (Mon, 27 Aug 2012) Log Message: ----------- update for user defined transaction filter settings (not finished yet) Modified Paths: -------------- branches/0.9.9.0/mmex/src/filtertransdialog.cpp branches/0.9.9.0/mmex/src/filtertransdialog.h branches/0.9.9.0/mmex/src/mmex.cpp branches/0.9.9.0/mmex/src/util.cpp Modified: branches/0.9.9.0/mmex/src/filtertransdialog.cpp =================================================================== --- branches/0.9.9.0/mmex/src/filtertransdialog.cpp 2012-08-27 14:16:59 UTC (rev 2920) +++ branches/0.9.9.0/mmex/src/filtertransdialog.cpp 2012-08-27 22:20:48 UTC (rev 2921) @@ -60,12 +60,12 @@ } mmFilterTransactionsDialog::mmFilterTransactionsDialog(std::vector< boost::shared_ptr<mmBankTransaction> >* trans, - mmCoreDB* core, + mmCoreDB* core, wxSQLite3Database* inidb, wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) -: trans_(trans), core_(core), db_(core->db_.get()) +: trans_(trans), core_(core), db_(core->db_.get()), inidb_(inidb) , categID_(-1), subcategID_(-1), payeeID_(-1), refAccountID_(-1) { Create(parent, id, caption, pos, size, style); @@ -75,29 +75,12 @@ const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { - accountCheckBox_ = NULL; - accountDropDown_ = NULL; - dateRangeCheckBox_ = NULL; - fromDateCtrl_ = NULL; - toDateControl_ = NULL; - payeeCheckBox_ = NULL; - btnPayee_ = NULL; - categoryCheckBox_ = NULL; - btnCategory_ = NULL; - statusCheckBox_ = NULL; - choiceStatus_ = NULL; - typeCheckBox_ = NULL; - choiceType_ = NULL; - amountRangeCheckBox_ = NULL; - amountMinEdit_ = NULL; - amountMaxEdit_ = NULL; - notesCheckBox_ = NULL; - notesEdit_ = NULL; - SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); wxDialog::Create( parent, id, caption, pos, size, style ); CreateControls(); + GetStoredSettings(0); + dataToControls(); GetSizer()->Fit(this); GetSizer()->SetSizeHints(this); @@ -107,6 +90,68 @@ return true; } +void mmFilterTransactionsDialog::dataToControls() +{ + wxStringTokenizer tkz(settings_string_, wxT(";"), wxTOKEN_RET_EMPTY_ALL); + wxString value = wxT(""); + bool status; + + status = get_next_value(tkz, value); + accountCheckBox_ ->SetValue(status); + accountDropDown_ ->Enable(status); + accountDropDown_ ->SetSelection(wxAtoi(value)); + + status = get_next_value(tkz, value); + dateRangeCheckBox_ ->SetValue(status); + fromDateCtrl_ ->Enable(status); + fromDateCtrl_ ->SetValue(mmGetStorageStringAsDate(value)); + get_next_value(tkz, value); + toDateControl_ ->Enable(status); + toDateControl_ ->SetValue(mmGetStorageStringAsDate(value)); + + status = get_next_value(tkz, value); + payeeCheckBox_ ->SetValue(status); + btnPayee_ ->Enable(status); + + status = get_next_value(tkz, value); + categoryCheckBox_ ->SetValue(status); + btnCategory_ ->Enable(status); + if (!value.IsEmpty()) btnCategory_ ->SetLabel(value); + + status = get_next_value(tkz, value); + statusCheckBox_ ->SetValue(status); + choiceStatus_ ->Enable(status); + choiceStatus_ ->SetSelection(wxAtoi(value)); + + status = get_next_value(tkz, value); + typeCheckBox_ ->SetValue(status); + choiceType_ ->Enable(status); + choiceType_ ->SetSelection(wxAtoi(value)); + cbTypeWithdrawal_ ->SetValue(value.Contains(wxT("W"))); + cbTypeWithdrawal_ ->Enable(status); + cbTypeDeposit_ ->SetValue(value.Contains(wxT("D"))); + cbTypeDeposit_ ->Enable(status); + cbTypeTransfer_ ->SetValue(value.Contains(wxT("T"))); + cbTypeTransfer_ ->Enable(status); + + status = get_next_value(tkz, value); + amountRangeCheckBox_ ->SetValue(status); + amountMinEdit_ ->Enable(status); + amountMinEdit_ ->SetValue(value); + get_next_value(tkz, value); + amountMaxEdit_ ->Enable(status); + amountMaxEdit_ ->SetValue(value); + + status = get_next_value(tkz, value); + transNumberCheckBox_ ->SetValue(status); + transNumberEdit_ ->Enable(status); + transNumberEdit_ ->SetValue(value); + + status = get_next_value(tkz, value); + notesCheckBox_ ->SetValue(status); + notesEdit_ ->Enable(status); + notesEdit_ ->SetValue(value); +} void mmFilterTransactionsDialog::CreateControls() { int fieldWidth = 220; @@ -139,7 +184,6 @@ //--Start of Row -------------------------------------------------------- accountCheckBox_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Account"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - accountCheckBox_->SetValue(FALSE); itemPanelSizer->Add(accountCheckBox_, flags); wxArrayString as = core_->accountList_.getAccountsName(); @@ -150,7 +194,6 @@ dateRangeCheckBox_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Date Range"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - dateRangeCheckBox_->SetValue(FALSE); itemPanelSizer->Add(dateRangeCheckBox_, flags); fromDateCtrl_ = new wxDatePickerCtrl( itemPanel, wxID_STATIC, wxDefaultDateTime, @@ -158,6 +201,7 @@ toDateControl_ = new wxDatePickerCtrl( itemPanel, wxID_STATIC, wxDefaultDateTime, wxDefaultPosition, wxSize(fieldWidth/2-5,-1), wxDP_DROPDOWN); + false; wxBoxSizer* dateSizer = new wxBoxSizer(wxHORIZONTAL); dateSizer->Add(fromDateCtrl_, flags); dateSizer->Add(toDateControl_, flags); @@ -166,7 +210,6 @@ payeeCheckBox_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Payee"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - payeeCheckBox_->SetValue(FALSE); itemPanelSizer->Add(payeeCheckBox_, flags); btnPayee_ = new wxButton( itemPanel, wxID_STATIC, _("Select Payee"), @@ -178,7 +221,7 @@ categoryCheckBox_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Category"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - categoryCheckBox_->SetValue(FALSE); + //categoryCheckBox_->SetValue(false); itemPanelSizer->Add(categoryCheckBox_, flags); btnCategory_ = new wxButton( itemPanel, wxID_STATIC, _("Select Category"), @@ -190,7 +233,7 @@ statusCheckBox_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Status"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - statusCheckBox_->SetValue(FALSE); + statusCheckBox_->SetValue(false); itemPanelSizer->Add(statusCheckBox_, flags); wxArrayString choiceStatusStrings; @@ -208,7 +251,6 @@ typeCheckBox_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Type"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - typeCheckBox_->SetValue(FALSE); wxArrayString choiceTypeStrings; choiceTypeStrings.Add(_("Withdrawal")); @@ -222,11 +264,8 @@ wxBoxSizer* typeSizer = new wxBoxSizer(wxVERTICAL); cbTypeWithdrawal_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Withdrawal"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - cbTypeWithdrawal_->Enable(false); cbTypeDeposit_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Deposit"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - cbTypeDeposit_->Enable(false); cbTypeTransfer_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Transfer"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - cbTypeTransfer_->Enable(false); itemPanelSizer->Add(typeCheckBox_, flags); itemPanelSizer->Add(typeSizer, flags); @@ -239,7 +278,6 @@ amountRangeCheckBox_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Amount Range"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - amountRangeCheckBox_->SetValue(FALSE); itemPanelSizer->Add(amountRangeCheckBox_, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5); amountMinEdit_ = new wxTextCtrl( itemPanel, wxID_STATIC, wxT(""), wxDefaultPosition, wxSize(fieldWidth/2-5,-1), wxALIGN_RIGHT|wxTE_PROCESS_ENTER , doubleValidator() ); @@ -253,7 +291,6 @@ transNumberCheckBox_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Number"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - transNumberCheckBox_->SetValue(FALSE); itemPanelSizer->Add(transNumberCheckBox_, flags); transNumberEdit_ = new wxTextCtrl( itemPanel, wxID_STATIC, _T(""), wxDefaultPosition, wxSize(fieldWidth,-1), 0 ); @@ -262,7 +299,6 @@ notesCheckBox_ = new wxCheckBox( itemPanel, wxID_STATIC, _("Notes"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); - notesCheckBox_->SetValue(FALSE); itemPanelSizer->Add(notesCheckBox_, flags); notesEdit_ = new wxTextCtrl( itemPanel, wxID_STATIC, _T(""), wxDefaultPosition, wxSize(fieldWidth,-1), 0 ); @@ -306,18 +342,6 @@ buttonPanelSizer->Add(itemButtonOK, flags); buttonPanelSizer->Add(itemButtonCancel, flags); - // disable all controls at startup - accountDropDown_->Enable(false); - fromDateCtrl_->Enable(false); - toDateControl_->Enable(false); - btnPayee_->Enable(false); - btnCategory_->Enable(false); - choiceStatus_->Enable(false); - choiceType_->Enable(false); - amountMinEdit_->Enable(false); - amountMaxEdit_->Enable(false); - notesEdit_->Enable(false); - transNumberEdit_->Enable(false); } /*! @@ -331,11 +355,12 @@ void mmFilterTransactionsDialog::OnCheckboxClick( wxCommandEvent& /*event*/ ) { + btnCategory_->Enable(categoryCheckBox_->GetValue()); accountDropDown_->Enable(accountCheckBox_->GetValue()); - fromDateCtrl_->Enable(this->dateRangeCheckBox_->GetValue()); - toDateControl_->Enable(this->dateRangeCheckBox_->GetValue()); - btnPayee_->Enable(this->payeeCheckBox_->GetValue()); - btnCategory_->Enable(this->categoryCheckBox_->GetValue()); + fromDateCtrl_->Enable(dateRangeCheckBox_->GetValue()); + toDateControl_->Enable(dateRangeCheckBox_->GetValue()); + btnPayee_->Enable(payeeCheckBox_->GetValue()); + btnCategory_->Enable(categoryCheckBox_->GetValue()); choiceStatus_->Enable(statusCheckBox_->GetValue()); choiceType_->Enable(typeCheckBox_->GetValue()); cbTypeWithdrawal_->Enable(typeCheckBox_->GetValue()); @@ -495,18 +520,6 @@ EndModal(wxID_OK); } -void mmFilterTransactionsDialog::OnButtonSaveClick( wxCommandEvent& /*event*/ ) -{ - int i = m_radio_box_->GetSelection(); - wxSafeShowMessage(wxString()<<i, wxT("")); -} - -void mmFilterTransactionsDialog::OnSettingsSelected( wxCommandEvent& event ) -{ - int i = event.GetSelection(); - wxSafeShowMessage(wxString()<<i, wxT("")); -} - void mmFilterTransactionsDialog::OnButtoncancelClick( wxCommandEvent& /*event*/ ) { EndModal(wxID_CANCEL); @@ -674,3 +687,51 @@ } return notesStr; } + +void mmFilterTransactionsDialog::OnButtonSaveClick( wxCommandEvent& /*event*/ ) +{ + int i = m_radio_box_->GetSelection(); + settings_string_ = GetCurrentSettings(i); + mmDBWrapper::setINISettingValue(inidb_, wxString::Format(wxT("TRANSACTIONS_FILTER_%d"), i), settings_string_); + wxSafeShowMessage(wxT("Save"), settings_string_); + +} + +void mmFilterTransactionsDialog::OnSettingsSelected( wxCommandEvent& event ) +{ + int i = event.GetSelection(); + wxSafeShowMessage(wxString(wxT("Read "))<<i, GetStoredSettings(i)); + dataToControls(); +} + +wxString mmFilterTransactionsDialog::GetStoredSettings(const int id) +{ + settings_string_ = mmDBWrapper::getINISettingValue(inidb_, wxString::Format(wxT("TRANSACTIONS_FILTER_%d"), id) + ,wxT("0;;0;;0;;0;;0;;0;;0;;0;;0;;0;;0;;")); + return settings_string_; +} + +wxString mmFilterTransactionsDialog::GetCurrentSettings(const int id) +{ + wxArrayString settings; + settings.Add(wxT("0;;0;;0;;0;;0;;0;;0;;0;;0;;0;;0;;")); + settings.Add(wxT("1;;0;;0;;0;;0;;0;;0;;0;;0;;0;;0;;")); + settings.Add(wxT("0;;1;;1;;0;;0;;0;;0;;0;;0;;0;;0;;")); + settings.Add(wxT("0;;0;;0;;1;;0;;0;;0;;0;;0;;0;;0;;")); + settings.Add(wxT("0;;0;;0;;0;;1;;0;;0;;0;;0;;0;;0;;")); + settings.Add(wxT("0;;0;;0;;0;;0;;1;;0;;0;;0;;0;;0;;")); + settings.Add(wxT("0;;0;;0;;0;;0;;0;;1;;0;;0;;0;;0;;")); + settings.Add(wxT("0;;0;;0;;0;;0;;0;;0;;1;;0;;0;;0;;")); + settings.Add(wxT("0;;0;;0;;0;;0;;0;;0;;0;;1;;0;;0;;")); + settings.Add(wxT("0;;1;2012-08-01;1;;1;;0;;0;;0;;0;;0;;1;123;0;;")); + settings_string_ = settings[id]; + return settings_string_; +} + +bool mmFilterTransactionsDialog::get_next_value( wxStringTokenizer& tkz, wxString& value) +{ + value = wxT(""); + bool on = wxT("1") == tkz.GetNextToken(); + value = tkz.GetNextToken(); + return on; +} Modified: branches/0.9.9.0/mmex/src/filtertransdialog.h =================================================================== --- branches/0.9.9.0/mmex/src/filtertransdialog.h 2012-08-27 14:16:59 UTC (rev 2920) +++ branches/0.9.9.0/mmex/src/filtertransdialog.h 2012-08-27 22:20:48 UTC (rev 2921) @@ -33,7 +33,7 @@ /// Constructors mmFilterTransactionsDialog( ); mmFilterTransactionsDialog( std::vector< boost::shared_ptr<mmBankTransaction> >* trans, - mmCoreDB* core, + mmCoreDB* core, wxSQLite3Database* inidb, wxWindow* parent, wxWindowID id = SYMBOL_MMFILTERTRANSACTIONSDIALOG_IDNAME, const wxString& caption = SYMBOL_MMFILTERTRANSACTIONSDIALOG_TITLE, @@ -51,6 +51,9 @@ /// Creates the controls and sizers void CreateControls(); + void dataToControls(); + wxString GetStoredSettings(const int id); + wxString GetCurrentSettings(const int id); /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CHECKBOXACCOUNT void OnCheckboxClick( wxCommandEvent& event ); @@ -59,6 +62,7 @@ void OnButtoncancelClick( wxCommandEvent& event ); void OnButtonSaveClick( wxCommandEvent& event ); void OnSettingsSelected( wxCommandEvent& event ); + bool get_next_value(wxStringTokenizer& tkz, wxString& value); void OnCategs(wxCommandEvent& event); void OnPayee(wxCommandEvent& event); @@ -66,6 +70,7 @@ /// Should we show tooltips? static bool ShowToolTips(); + wxString settings_string_; wxCheckBox* accountCheckBox_; wxChoice* accountDropDown_; wxCheckBox* dateRangeCheckBox_; @@ -92,6 +97,7 @@ wxTextCtrl* transNumberEdit_; std::vector< boost::shared_ptr<mmBankTransaction> >* trans_; wxSQLite3Database* db_; + wxSQLite3Database* inidb_; mmCoreDB* core_; int categID_; Modified: branches/0.9.9.0/mmex/src/mmex.cpp =================================================================== --- branches/0.9.9.0/mmex/src/mmex.cpp 2012-08-27 14:16:59 UTC (rev 2920) +++ branches/0.9.9.0/mmex/src/mmex.cpp 2012-08-27 22:20:48 UTC (rev 2921) @@ -3336,7 +3336,7 @@ std::vector< boost::shared_ptr<mmBankTransaction> >* trans = new std::vector< boost::shared_ptr<mmBankTransaction> >; - mmFilterTransactionsDialog* dlg= new mmFilterTransactionsDialog(trans, m_core.get(), this); + mmFilterTransactionsDialog* dlg= new mmFilterTransactionsDialog(trans, m_core.get(), m_inidb.get(), this); if (dlg->ShowModal() == wxID_OK) { mmReportTransactions* rs = new mmReportTransactions(trans, m_core.get(), dlg->refAccountID_, dlg->refAccountStr_, dlg); Modified: branches/0.9.9.0/mmex/src/util.cpp =================================================================== --- branches/0.9.9.0/mmex/src/util.cpp 2012-08-27 14:16:59 UTC (rev 2920) +++ branches/0.9.9.0/mmex/src/util.cpp 2012-08-27 22:20:48 UTC (rev 2921) @@ -537,9 +537,10 @@ wxDateTime mmGetStorageStringAsDate(const wxString& str) { - wxDateTime dt; - dt.ParseDate(str.GetData()); - return dt; + wxDateTime dt = wxDateTime::Now(); + if (!str.IsEmpty()) dt.ParseDate(str.GetData()); + if (dt.IsValid()) return dt; + return wxDateTime::Now(); } wxColour mmGetColourFromString(const wxString& str) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |