From: <vo...@us...> - 2013-05-28 03:57:02
|
Revision: 4010 http://sourceforge.net/p/moneymanagerex/code/4010 Author: vomikan Date: 2013-05-28 03:56:59 +0000 (Tue, 28 May 2013) Log Message: ----------- new html function Modified Paths: -------------- trunk/mmex/src/lua_interface.cpp trunk/mmex/src/lua_interface.h trunk/mmex/src/scripts/transaction_stats.lua Modified: trunk/mmex/src/lua_interface.cpp =================================================================== --- trunk/mmex/src/lua_interface.cpp 2013-05-28 03:53:51 UTC (rev 4009) +++ trunk/mmex/src/lua_interface.cpp 2013-05-28 03:56:59 UTC (rev 4010) @@ -165,16 +165,17 @@ lua_register(lua_, "mmGetLuaDir", cpp2lua_GetLuaDir); //html builder functions - lua_register(lua_, "mmHTMLBuilder", cpp2lua_HTMLBuilder); - lua_register(lua_, "mmHTMLTableCellMonth", cpp2lua_HTMLTableCellMonth); - lua_register(lua_, "mmHTMLTableCellInteger", cpp2lua_HTMLTableCellInteger); - lua_register(lua_, "mmHTMLTableCell", cpp2lua_HTMLTableCell); - lua_register(lua_, "mmHTMLReportHeader", cpp2lua_HTMLReportHeader); - lua_register(lua_, "mmHTMLStartTable", cpp2lua_HTMLStartTable); - lua_register(lua_, "mmHTMLEndTable", cpp2lua_HTMLEndTable); - lua_register(lua_, "mmHTMLStartTableRow", cpp2lua_HTMLStartTableRow); - lua_register(lua_, "mmHTMLEndTableRow", cpp2lua_HTMLEndTableRow); - lua_register(lua_, "mmHTMLTableHeaderCell", cpp2lua_mmHTMLTableHeaderCell); + lua_register(lua_, "mmHTMLBuilder", mmHTMLBuilderUni); + lua_register(lua_, "mmHTMLTableCellMonth", mmHTMLTableCellMonth); + lua_register(lua_, "mmHTMLTableCellInteger", mmHTMLTableCellInteger); + lua_register(lua_, "mmHTMLTableCell", mmHTMLTableCell); + lua_register(lua_, "mmHTMLReportHeader", mmHTMLReportHeader); + lua_register(lua_, "mmHTMLStartTable", mmHTMLStartTable); + lua_register(lua_, "mmHTMLEndTable", mmHTMLEndTable); + lua_register(lua_, "mmHTMLStartTableRow", mmHTMLStartTableRow); + lua_register(lua_, "mmHTMLEndTableRow", mmHTMLEndTableRow); + lua_register(lua_, "mmHTMLTableHeaderCell", mmHTMLTableHeaderCell); + lua_register(lua_, "mmHTMLhr", mmHTMLhr); } /****************************************************************************** @@ -606,7 +607,7 @@ /****************************************************************************** html = mmHTMLBuilder("function[, value_1][, value_2][, value_3][, value_4]") *****************************************************************************/ -int TLuaInterface::cpp2lua_HTMLBuilder(lua_State* lua) +int TLuaInterface::mmHTMLBuilderUni(lua_State* lua) { wxString value_6; if (lua_gettop(lua) > 6 ) value_6 = GetLuaString(lua); @@ -667,57 +668,63 @@ return 0; } -int TLuaInterface::cpp2lua_HTMLReportHeader(lua_State* lua) +int TLuaInterface::mmHTMLReportHeader(lua_State* lua) { wxString report_name = GetLuaString(lua); html_builder_->addHeader(1, report_name); return 0; } -int TLuaInterface::cpp2lua_HTMLTableCellMonth(lua_State* lua) +int TLuaInterface::mmHTMLTableCellMonth(lua_State* lua) { html_builder_->addTableCellMonth(GetLuaInteger(lua)-1); return 0; } -int TLuaInterface::cpp2lua_HTMLTableCell(lua_State* lua) +int TLuaInterface::mmHTMLTableCell(lua_State* lua) { html_builder_->addTableCell(GetLuaString(lua)); return 0; } -int TLuaInterface::cpp2lua_HTMLTableCellInteger(lua_State* lua) +int TLuaInterface::mmHTMLTableCellInteger(lua_State* lua) { html_builder_->addTableCell(wxString()<<GetLuaInteger(lua), true); return 0; } -int TLuaInterface::cpp2lua_mmHTMLTableHeaderCell(lua_State* lua) +int TLuaInterface::mmHTMLTableHeaderCell(lua_State* lua) { html_builder_->addTableHeaderCell(GetLuaString(lua)); return 0; } -int TLuaInterface::cpp2lua_HTMLStartTable(lua_State* lua) +int TLuaInterface::mmHTMLStartTable(lua_State* lua) { html_builder_->startTable(GetLuaString(lua)); return 0; } -int TLuaInterface::cpp2lua_HTMLEndTable(lua_State* /*lua*/) +int TLuaInterface::mmHTMLEndTable(lua_State* /*lua*/) { html_builder_->endTable(); return 0; } -int TLuaInterface::cpp2lua_HTMLStartTableRow(lua_State* /*lua*/) +int TLuaInterface::mmHTMLStartTableRow(lua_State* /*lua*/) { html_builder_->startTableRow(); return 0; } -int TLuaInterface::cpp2lua_HTMLEndTableRow(lua_State* /*lua*/) +int TLuaInterface::mmHTMLEndTableRow(lua_State* /*lua*/) { html_builder_->endTableRow(); return 0; } + +int TLuaInterface::mmHTMLhr(lua_State* /*lua*/) +{ + html_builder_->addHorizontalLine(); + return 0; +} Modified: trunk/mmex/src/lua_interface.h =================================================================== --- trunk/mmex/src/lua_interface.h 2013-05-28 03:53:51 UTC (rev 4009) +++ trunk/mmex/src/lua_interface.h 2013-05-28 03:56:59 UTC (rev 4010) @@ -95,16 +95,17 @@ static int cpp2lua_GetExeDir(lua_State* lua); static int cpp2lua_GetLuaDir(lua_State* lua); - static int cpp2lua_HTMLReportHeader(lua_State* lua); - static int cpp2lua_HTMLStartTable(lua_State* lua); - static int cpp2lua_HTMLEndTable(lua_State* lua); - static int cpp2lua_HTMLStartTableRow(lua_State* lua); - static int cpp2lua_HTMLEndTableRow(lua_State* lua); - static int cpp2lua_HTMLBuilder(lua_State* lua); - static int cpp2lua_HTMLTableCellMonth(lua_State* lua); - static int cpp2lua_HTMLTableCellInteger(lua_State* lua); - static int cpp2lua_HTMLTableCell(lua_State* lua); - static int cpp2lua_mmHTMLTableHeaderCell(lua_State* lua); + static int mmHTMLBuilderUni(lua_State* lua); + static int mmHTMLReportHeader(lua_State* lua); + static int mmHTMLStartTable(lua_State* lua); + static int mmHTMLEndTable(lua_State* lua); + static int mmHTMLStartTableRow(lua_State* lua); + static int mmHTMLEndTableRow(lua_State* lua); + static int mmHTMLTableCellMonth(lua_State* lua); + static int mmHTMLTableCellInteger(lua_State* lua); + static int mmHTMLTableCell(lua_State* lua); + static int mmHTMLTableHeaderCell(lua_State* lua); + static int mmHTMLhr(lua_State* lua); }; #endif // _MM_EX_LUA_INTERFACE_H_ Modified: trunk/mmex/src/scripts/transaction_stats.lua =================================================================== --- trunk/mmex/src/scripts/transaction_stats.lua 2013-05-28 03:53:51 UTC (rev 4009) +++ trunk/mmex/src/scripts/transaction_stats.lua 2013-05-28 03:56:59 UTC (rev 4010) @@ -5,6 +5,7 @@ for m = 1, 12, 1 do m_stat[m] = (y_stat) end --test end + mmHTMLStartTable("50%") for m = 0, 12 , 1 do mmHTMLStartTableRow() mmHTMLTableCellMonth(m) @@ -17,11 +18,12 @@ end mmHTMLEndTableRow() end + mmHTMLEndTable() end ----------------------------------------------------------- --Main function ----------------------------------------------------------- mmHTMLReportHeader(_("Transaction Statistics")) -mmHTMLStartTable("50%") +--mmHTMLhr get_stats() -mmHTMLEndTable() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2013-05-28 10:29:54
|
Revision: 4018 http://sourceforge.net/p/moneymanagerex/code/4018 Author: vomikan Date: 2013-05-28 10:29:51 +0000 (Tue, 28 May 2013) Log Message: ----------- fix for horizontal line function Modified Paths: -------------- trunk/mmex/src/lua_interface.cpp trunk/mmex/src/scripts/transaction_stats.lua Modified: trunk/mmex/src/lua_interface.cpp =================================================================== --- trunk/mmex/src/lua_interface.cpp 2013-05-28 09:14:11 UTC (rev 4017) +++ trunk/mmex/src/lua_interface.cpp 2013-05-28 10:29:51 UTC (rev 4018) @@ -725,6 +725,6 @@ int TLuaInterface::mmHTMLhr(lua_State* /*lua*/) { - html_builder_->addHorizontalLine(); + html_builder_->addHorizontalLine(1); return 0; } Modified: trunk/mmex/src/scripts/transaction_stats.lua =================================================================== --- trunk/mmex/src/scripts/transaction_stats.lua 2013-05-28 09:14:11 UTC (rev 4017) +++ trunk/mmex/src/scripts/transaction_stats.lua 2013-05-28 10:29:51 UTC (rev 4018) @@ -24,6 +24,6 @@ --Main function ----------------------------------------------------------- mmHTMLReportHeader(_("Transaction Statistics")) ---mmHTMLhr +mmHTMLhr() get_stats() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2013-05-28 11:17:31
|
Revision: 4019 http://sourceforge.net/p/moneymanagerex/code/4019 Author: vomikan Date: 2013-05-28 11:17:28 +0000 (Tue, 28 May 2013) Log Message: ----------- fix for errors output Modified Paths: -------------- trunk/mmex/src/lua_interface.cpp trunk/mmex/src/lua_interface.h Modified: trunk/mmex/src/lua_interface.cpp =================================================================== --- trunk/mmex/src/lua_interface.cpp 2013-05-28 10:29:51 UTC (rev 4018) +++ trunk/mmex/src/lua_interface.cpp 2013-05-28 11:17:28 UTC (rev 4019) @@ -51,39 +51,41 @@ } // Passes Lua code in a string, to be run by Lua. -wxString TLuaInterface::RunLuaCode(const wxString& lua_code) +bool TLuaInterface::RunLuaCode(const wxString& lua_code) { lua_result_ = luaL_loadstring(lua_, lua_code.ToUTF8()); if (lua_result_) { - return LuaErrorResult(); + this->html_builder_->addParaText(LuaErrorResult()); + return false; } lua_result_ = lua_pcall(lua_, 0, LUA_MULTRET, 0); if (lua_result_) { - return LuaErrorResult(); + this->html_builder_->addParaText(LuaErrorResult()); + return false; } - - return html_builder_->getHTMLText(); + return true; } // Passes a filename containing Lua code, to be run by Lua. -wxString TLuaInterface::RunLuaFile(const wxString& lua_filename) +bool TLuaInterface::RunLuaFile(const wxString& lua_filename) { lua_result_ = luaL_loadfile(lua_, lua_filename.ToUTF8()); if (lua_result_) { - return LuaErrorResult(); + this->html_builder_->addParaText(LuaErrorResult()); + return false; } lua_result_ = lua_pcall(lua_, 0, LUA_MULTRET, 0); if (lua_result_) { - return LuaErrorResult(); + this->html_builder_->addParaText(LuaErrorResult()); + return false; } - - return html_builder_->getHTMLText(); //wxString::FromUTF8(lua_tostring(lua_, -1)); + return true; } // Decode the error into a literal string Modified: trunk/mmex/src/lua_interface.h =================================================================== --- trunk/mmex/src/lua_interface.h 2013-05-28 10:29:51 UTC (rev 4018) +++ trunk/mmex/src/lua_interface.h 2013-05-28 11:17:28 UTC (rev 4019) @@ -47,8 +47,8 @@ TLuaInterface(mmHTMLBuilder* hb); ~TLuaInterface(); - wxString RunLuaCode(const wxString& lua_code); - wxString RunLuaFile(const wxString& lua_filename); + bool RunLuaCode(const wxString& lua_code); + bool RunLuaFile(const wxString& lua_filename); public: static mmHTMLBuilder* html_builder_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2013-05-29 02:49:11
|
Revision: 4022 http://sourceforge.net/p/moneymanagerex/code/4022 Author: vomikan Date: 2013-05-29 02:49:08 +0000 (Wed, 29 May 2013) Log Message: ----------- addText new function for Lua Modified Paths: -------------- trunk/mmex/src/lua_interface.cpp trunk/mmex/src/lua_interface.h trunk/mmex/src/scripts/transaction_stats.lua Modified: trunk/mmex/src/lua_interface.cpp =================================================================== --- trunk/mmex/src/lua_interface.cpp 2013-05-28 13:06:26 UTC (rev 4021) +++ trunk/mmex/src/lua_interface.cpp 2013-05-29 02:49:08 UTC (rev 4022) @@ -182,6 +182,7 @@ lua_register(lua_, "mmHTMLStartTableRow", mmHTMLStartTableRow); lua_register(lua_, "mmHTMLEndTableRow", mmHTMLEndTableRow); lua_register(lua_, "mmHTMLTableHeaderCell", mmHTMLTableHeaderCell); + lua_register(lua_, "mmHTMLaddText", mmHTMLaddText); lua_register(lua_, "mmHTMLhr", mmHTMLhr); } @@ -730,6 +731,12 @@ return 0; } +int TLuaInterface::mmHTMLaddText(lua_State* lua) +{ + html_builder_->addText(GetLuaString(lua)); + return 0; +} + int TLuaInterface::mmHTMLhr(lua_State* /*lua*/) { html_builder_->addHorizontalLine(1); Modified: trunk/mmex/src/lua_interface.h =================================================================== --- trunk/mmex/src/lua_interface.h 2013-05-28 13:06:26 UTC (rev 4021) +++ trunk/mmex/src/lua_interface.h 2013-05-29 02:49:08 UTC (rev 4022) @@ -105,6 +105,7 @@ static int mmHTMLTableCellInteger(lua_State* lua); static int mmHTMLTableCell(lua_State* lua); static int mmHTMLTableHeaderCell(lua_State* lua); + static int mmHTMLaddText(lua_State* lua); static int mmHTMLhr(lua_State* lua); }; Modified: trunk/mmex/src/scripts/transaction_stats.lua =================================================================== --- trunk/mmex/src/scripts/transaction_stats.lua 2013-05-28 13:06:26 UTC (rev 4021) +++ trunk/mmex/src/scripts/transaction_stats.lua 2013-05-29 02:49:08 UTC (rev 4022) @@ -1,10 +1,10 @@ -total = 0 local function get_stats(t) --test table local m_stat = {} -- TODO: provide c++ function to get stats local y_stat = {1,2,3,4,5,6,7,8,9,10} for m = 1, 12, 1 do m_stat[m] = (y_stat) end --test end + local total = 0 mmHTMLStartTable("50%") for m = 0, 12 , 1 do mmHTMLStartTableRow() @@ -20,13 +20,17 @@ mmHTMLEndTableRow() end mmHTMLEndTable() + return total end ----------------------------------------------------------- --Main function ----------------------------------------------------------- -mmHTMLReportHeader(_("Transaction Statistics")) -mmHTMLhr() -get_stats() -mmHTMLhr() +local function main() + mmHTMLReportHeader(_("Transaction Statistics")) + mmHTMLhr() + total = get_stats() + mmHTMLhr() + mmHTMLaddText("Total transactions:" .. total) +end -return "Total transactions:" .. total \ No newline at end of file +main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2013-05-31 11:20:29
|
Revision: 4026 http://sourceforge.net/p/moneymanagerex/code/4026 Author: stef145g Date: 2013-05-31 11:20:26 +0000 (Fri, 31 May 2013) Log Message: ----------- Fix lockup for cash flow using every_X processing. Modified Paths: -------------- trunk/mmex/src/db/transactionbill.cpp trunk/mmex/src/db/transactionbill.h trunk/mmex/src/reports/cashflow.cpp trunk/mmex/src/reports/cashflow.h Modified: trunk/mmex/src/db/transactionbill.cpp =================================================================== --- trunk/mmex/src/db/transactionbill.cpp 2013-05-29 07:49:15 UTC (rev 4025) +++ trunk/mmex/src/db/transactionbill.cpp 2013-05-31 11:20:26 UTC (rev 4026) @@ -313,6 +313,16 @@ return result; } +bool TTransactionBillEntry::UsingEvery_X_Processing() +{ + bool result = false; + if ((repeat_type_ == TYPE_EVERY_X_DAYS) || (repeat_type_ == TYPE_EVERY_X_MONTHS)) + { + result = true; + } + return result; +} + bool TTransactionBillEntry::UsingRepeatProcessing() { bool result = false; Modified: trunk/mmex/src/db/transactionbill.h =================================================================== --- trunk/mmex/src/db/transactionbill.h 2013-05-29 07:49:15 UTC (rev 4025) +++ trunk/mmex/src/db/transactionbill.h 2013-05-31 11:20:26 UTC (rev 4026) @@ -113,6 +113,8 @@ bool UsingRepeatProcessing(); // Returns true when using In X Days/Months transaction. bool UsingIn_X_Processing(); + // Returns true when using Every X Days/Months transaction. + bool UsingEvery_X_Processing(); }; /************************************************************************************ Modified: trunk/mmex/src/reports/cashflow.cpp =================================================================== --- trunk/mmex/src/reports/cashflow.cpp 2013-05-29 07:49:15 UTC (rev 4025) +++ trunk/mmex/src/reports/cashflow.cpp 2013-05-31 11:20:26 UTC (rev 4026) @@ -46,7 +46,8 @@ this->accountArray_ = selections; } -void mmReportCashFlow::SetRepeatForecast(forecastVec& fvec, TTransactionBillEntry* repeat_entry, double& amount) +void mmReportCashFlow::SetRepeatForecast(forecastVec& fvec +, TTransactionBillEntry* repeat_entry, double& amount) { mmRepeatForecast rf; rf.date = repeat_entry->NextOccurDate(); @@ -56,6 +57,15 @@ repeat_entry->AdjustNextOccuranceDate(); } +void mmReportCashFlow::SetYearsRepeatForecast(forecastVec& fvec +, TTransactionBillEntry* repeat_entry, double& amount, const wxDateTime& future_year) +{ + while((repeat_entry->NextOccurDate() < future_year)) + { + SetRepeatForecast(fvec, repeat_entry, amount); + } +} + wxString mmReportCashFlow::getHTMLText() { return this->getHTMLText_i(); @@ -186,6 +196,10 @@ { SetRepeatForecast(fvec, repeat_entry.get(), amount); } + else if (repeat_entry->UsingEvery_X_Processing()) + { + SetYearsRepeatForecast(fvec, repeat_entry.get(), amount, yearFromNow); + } else { while (repeat_entry->num_repeats_ > 0) @@ -196,10 +210,7 @@ } else { - while((repeat_entry->NextOccurDate() < yearFromNow)) - { - SetRepeatForecast(fvec, repeat_entry.get(), amount); - } + SetYearsRepeatForecast(fvec, repeat_entry.get(), amount, yearFromNow); } } Modified: trunk/mmex/src/reports/cashflow.h =================================================================== --- trunk/mmex/src/reports/cashflow.h 2013-05-29 07:49:15 UTC (rev 4025) +++ trunk/mmex/src/reports/cashflow.h 2013-05-31 11:20:26 UTC (rev 4026) @@ -30,7 +30,10 @@ typedef std::vector<mmRepeatForecast> forecastVec; std::vector<forecastVec> bdForecastVec; - void SetRepeatForecast(forecastVec& fvec, TTransactionBillEntry* repeat_entry, double& amount); + void SetRepeatForecast(forecastVec& fvec + , TTransactionBillEntry* repeat_entry, double& amount); + void SetYearsRepeatForecast(forecastVec& fvec + , TTransactionBillEntry* repeat_entry, double& amount, const wxDateTime& future_year); mmGUIFrame* frame_; const wxArrayString* accountArray_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2013-06-02 05:29:53
|
Revision: 4027 http://sourceforge.net/p/moneymanagerex/code/4027 Author: stef145g Date: 2013-06-02 05:29:50 +0000 (Sun, 02 Jun 2013) Log Message: ----------- Converting shared pointers to pointers - Not complete Modified Paths: -------------- trunk/mmex/src/assetspanel.cpp trunk/mmex/src/db/account.cpp trunk/mmex/src/db/account.h trunk/mmex/src/db/assets.cpp trunk/mmex/src/db/assets.h trunk/mmex/src/db/budget_table.cpp trunk/mmex/src/db/budget_table.h trunk/mmex/src/db/budget_year.cpp trunk/mmex/src/db/budget_year.h trunk/mmex/src/db/category.cpp trunk/mmex/src/db/category.h trunk/mmex/src/db/currency.cpp trunk/mmex/src/db/currency.h trunk/mmex/src/db/entry_base.cpp trunk/mmex/src/db/entry_base.h trunk/mmex/src/db/payee_table.cpp trunk/mmex/src/db/payee_table.h trunk/mmex/src/db/settings.cpp trunk/mmex/src/db/settings.h trunk/mmex/src/db/splittransaction.cpp trunk/mmex/src/db/splittransaction.h trunk/mmex/src/db/stocks.cpp trunk/mmex/src/db/stocks.h trunk/mmex/src/db/subcategory.cpp trunk/mmex/src/db/subcategory.h trunk/mmex/src/db/transaction.cpp trunk/mmex/src/db/transaction.h trunk/mmex/src/db/transactionbill.cpp trunk/mmex/src/db/transactionbill.h trunk/mmex/src/mmhomepagepanel.cpp trunk/mmex/src/reports/cashflow.cpp trunk/mmex/src/reports/summary.cpp trunk/mmex/src/reports/summaryassets.cpp trunk/mmex/src/tests/new_classes_test.cpp Modified: trunk/mmex/src/assetspanel.cpp =================================================================== --- trunk/mmex/src/assetspanel.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/assetspanel.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -200,7 +200,7 @@ int original_index = selectedIndex_; // Duplicate the asset entry - TAssetEntry* pNewEntry = new TAssetEntry(cp_->AssetList().entrylist_[selectedIndex_].get()); + TAssetEntry* pNewEntry = new TAssetEntry(cp_->AssetList().entrylist_[selectedIndex_]); int new_asset_id = cp_->AssetList().AddEntry(pNewEntry); // Locate new entry in the visual list. cp_->AssetList().GetEntryPtr(new_asset_id); @@ -218,7 +218,7 @@ void mmAssetsListCtrl::OnListItemActivated(wxListEvent& event) { selectedIndex_ = event.GetIndex(); - EditAsset(cp_->AssetList().entrylist_[selectedIndex_].get()); + EditAsset(cp_->AssetList().entrylist_[selectedIndex_]); } bool mmAssetsListCtrl::EditAsset(TAssetEntry* pEntry) @@ -268,7 +268,7 @@ mmAssetsPanel::mmAssetsPanel(wxWindow *parent, mmCoreDB* core) : mmPanelBase(core) -, asset_list_(core->db_, false) // don't load entries at this point. +, asset_list_(core->db_.get(), false) // don't load entries at this point. { Create(parent, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxPanelNameStr); } @@ -441,7 +441,7 @@ + wxString::Format(" where ASSETTYPE in ( %s ) ", filter_) + " order by " + (wxString() << col + 1) + (!asc ? " desc" : " "); - asset_list_.LoadAssetEntriesUsing(sql); + asset_list_.LoadEntriesUsing(sql); m_listCtrlAssets->SetItemCount(asset_list_.entrylist_.size()); header_text_->SetLabel(wxString::Format(_("Total: %s") Modified: trunk/mmex/src/db/account.cpp =================================================================== --- trunk/mmex/src/db/account.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/account.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -127,7 +127,7 @@ TAccountList Methods ***********************************************************************************/ /// Constructor -TAccountList::TAccountList(std::shared_ptr<wxSQLite3Database> db +TAccountList::TAccountList(wxSQLite3Database* db , TCurrencyList& currency_list, bool load_entries) : TListBase(db) , currency_list_(currency_list) @@ -139,7 +139,7 @@ { try { - if (!db_->TableExists("ACCOUNTLIST_V1")) + if (!ListDatabase()->TableExists("ACCOUNTLIST_V1")) { const char CREATE_TABLE_ACCOUNTLIST_V1[] = "CREATE TABLE ACCOUNTLIST_V1(ACCOUNTID integer primary key, " @@ -149,7 +149,7 @@ "ACCESSINFO TEXT, INITIALBAL numeric, FAVORITEACCT TEXT NOT NULL, " "CURRENCYID integer NOT NULL)"; - db_->ExecuteUpdate(CREATE_TABLE_ACCOUNTLIST_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_ACCOUNTLIST_V1); } if (load_entries) @@ -169,7 +169,7 @@ try { entrylist_.clear(); - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { TAccountEntry entry(q1); @@ -196,7 +196,7 @@ TAccountEntry* pEntry = GetEntryPtr(account_id); if (pEntry) { - pEntry->Delete(db_.get()); + pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); } } Modified: trunk/mmex/src/db/account.h =================================================================== --- trunk/mmex/src/db/account.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/account.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -84,7 +84,7 @@ public: std::vector<TAccountEntry> entrylist_; - TAccountList(std::shared_ptr<wxSQLite3Database> db, + TAccountList(wxSQLite3Database* db, TCurrencyList& currency_list, bool load_entries = true); /// Allows specialised list loading provided by SQL statement Modified: trunk/mmex/src/db/assets.cpp =================================================================== --- trunk/mmex/src/db/assets.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/assets.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -176,17 +176,22 @@ TAssetList Methods ***********************************************************************************/ /// Constructor -TAssetList::TAssetList(std::shared_ptr<wxSQLite3Database> db, bool load_entries) +TAssetList::TAssetList(wxSQLite3Database* db, bool load_entries) : TListBase(db) { LoadEntries(load_entries); } +TAssetList::~TAssetList() +{ + DestroyEntryList(); +} + void TAssetList::LoadEntries(bool load_entries) { try { - if (!db_->TableExists("ASSETS_V1")) + if (!ListDatabase()->TableExists("ASSETS_V1")) { const char CREATE_TABLE_ASSETS_V1[] = "CREATE TABLE ASSETS_V1 (ASSETID integer primary key, " @@ -194,12 +199,12 @@ "VALUE numeric, VALUECHANGE TEXT, NOTES TEXT, VALUECHANGERATE numeric, " "ASSETTYPE TEXT)"; - db_->ExecuteUpdate(CREATE_TABLE_ASSETS_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_ASSETS_V1); } if (load_entries) { - LoadAssetEntriesUsing("select * from assets_v1"); + LoadEntriesUsing("select * from assets_v1"); } } catch (const wxSQLite3Exception& e) @@ -208,44 +213,51 @@ } } -void TAssetList::LoadAssetEntriesUsing(const wxString& sql_statement) +void TAssetList::LoadEntriesUsing(const wxString& sql_statement) { - entrylist_.clear(); - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + DestroyEntryList(); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - std::shared_ptr<TAssetEntry> pEntry(new TAssetEntry(q1)); - entrylist_.push_back(pEntry); + entrylist_.push_back(new TAssetEntry(q1)); } q1.Finalize(); } +void TAssetList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} + int TAssetList::AddEntry(TAssetEntry* pAssetEntry) { - std::shared_ptr<TAssetEntry> pEntry(pAssetEntry); - entrylist_.push_back(pEntry); - pEntry->Add(db_.get()); + entrylist_.push_back(pAssetEntry); + pAssetEntry->Add(ListDatabase()); - return pEntry->id_; + return pAssetEntry->id_; } void TAssetList::DeleteEntry(int asset_id) { - std::shared_ptr<TAssetEntry> pEntry = GetEntryPtr(asset_id); + TAssetEntry* pEntry = GetEntryPtr(asset_id); if (pEntry) { - pEntry->Delete(db_.get()); + pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pEntry; } } -std::shared_ptr<TAssetEntry> TAssetList::GetEntryPtr(int asset_id) +TAssetEntry* TAssetList::GetEntryPtr(int asset_id) { - std::shared_ptr<TAssetEntry> pEntry; - size_t list_size = entrylist_.size(); + TAssetEntry* pEntry = 0; size_t index = 0; - while (index < list_size) + while (index < entrylist_.size()) { if (entrylist_[index]->id_ == asset_id) { @@ -259,9 +271,9 @@ return pEntry; } -std::shared_ptr<TAssetEntry> TAssetList::GetIndexedEntryPtr(unsigned int list_index) +TAssetEntry* TAssetList::GetIndexedEntryPtr(unsigned int list_index) { - std::shared_ptr<TAssetEntry> pEntry; + TAssetEntry* pEntry = 0; if (list_index < entrylist_.size()) { pEntry = entrylist_[list_index]; Modified: trunk/mmex/src/db/assets.h =================================================================== --- trunk/mmex/src/db/assets.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/assets.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -97,20 +97,23 @@ { private: void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); public: - std::vector<std::shared_ptr<TAssetEntry> >entrylist_; + std::vector<TAssetEntry*> entrylist_; - TAssetList(std::shared_ptr<wxSQLite3Database> db, bool load_entries = true); + TAssetList(wxSQLite3Database* db, bool load_entries = true); + ~TAssetList(); /// Allows specialised loads by providing the required SQL statement - void LoadAssetEntriesUsing(const wxString& sql_statement); + void LoadEntriesUsing(const wxString& sql_statement); int AddEntry(TAssetEntry* pAssetEntry); void DeleteEntry(int asset_id); - std::shared_ptr<TAssetEntry> GetEntryPtr(int asset_id); - std::shared_ptr<TAssetEntry> GetIndexedEntryPtr(unsigned int list_index); + TAssetEntry* GetEntryPtr(int asset_id); + TAssetEntry* GetIndexedEntryPtr(unsigned int list_index); int CurrentListSize(); double GetAssetBalance(bool value_today = true); Modified: trunk/mmex/src/db/budget_table.cpp =================================================================== --- trunk/mmex/src/db/budget_table.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/budget_table.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -116,7 +116,7 @@ TBudgetTableList Methods ***********************************************************************************/ /// Constructor -TBudgetList::TBudgetList(std::shared_ptr<wxSQLite3Database> db, bool load_entries) +TBudgetList::TBudgetList(wxSQLite3Database* db, bool load_entries) : TListBase(db) { LoadEntries(load_entries); @@ -126,14 +126,14 @@ { try { - if (!db_->TableExists("BUDGETTABLE_V1")) + if (!ListDatabase()->TableExists("BUDGETTABLE_V1")) { const char CREATE_TABLE_BUDGETTABLE_V1[] = "CREATE TABLE BUDGETTABLE_V1(BUDGETENTRYID integer primary key, " "BUDGETYEARID integer, CATEGID integer, SUBCATEGID integer, " "PERIOD TEXT NOT NULL, AMOUNT numeric NOT NULL)"; - db_->ExecuteUpdate(CREATE_TABLE_BUDGETTABLE_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_BUDGETTABLE_V1); } if (load_entries) @@ -150,7 +150,7 @@ void TBudgetList::LoadEntriesUsing(const wxString& sql_statement) { entrylist_.clear(); - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { std::shared_ptr<TBudgetEntry> pEntry(new TBudgetEntry(q1)); @@ -162,7 +162,7 @@ int TBudgetList::AddEntry(TBudgetEntry* pBudgetEntry) { std::shared_ptr<TBudgetEntry> pEntry(pBudgetEntry); - pBudgetEntry->Add(db_.get()); + pBudgetEntry->Add(ListDatabase()); entrylist_.push_back(pEntry); return pBudgetEntry->id_; @@ -173,7 +173,7 @@ TBudgetEntry* pEntry = GetEntryPtr(budget_entry_id); if (pEntry) { - pEntry->Delete(db_.get()); + pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); } } Modified: trunk/mmex/src/db/budget_table.h =================================================================== --- trunk/mmex/src/db/budget_table.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/budget_table.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -93,7 +93,7 @@ public: std::vector<std::shared_ptr<TBudgetEntry> >entrylist_; - TBudgetList(std::shared_ptr<wxSQLite3Database> db, bool load_entries = true); + TBudgetList(wxSQLite3Database* db, bool load_entries = true); // Allows specialised loads by providing the required SQL statement void LoadEntriesUsing(const wxString& sql_statement); Modified: trunk/mmex/src/db/budget_year.cpp =================================================================== --- trunk/mmex/src/db/budget_year.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/budget_year.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -90,24 +90,29 @@ /************************************************************************************ TBudgetYearList Methods ***********************************************************************************/ -/// Constructor -TBudgetYearList::TBudgetYearList(std::shared_ptr<wxSQLite3Database> db, bool load_entries) +// Constructor +TBudgetYearList::TBudgetYearList(wxSQLite3Database* db, bool load_entries) : TListBase(db) { LoadEntries(load_entries); } +TBudgetYearList::~TBudgetYearList() +{ + DestroyEntryList(); +} + void TBudgetYearList::LoadEntries(bool load_entries) { try { - if (!db_->TableExists("BUDGETYEAR_V1")) + if (!ListDatabase()->TableExists("BUDGETYEAR_V1")) { const char CREATE_TABLE_BUDGETYEAR_V1[] = "CREATE TABLE BUDGETYEAR_V1(BUDGETYEARID integer primary key, " "BUDGETYEARNAME TEXT NOT NULL UNIQUE)"; - db_->ExecuteUpdate(CREATE_TABLE_BUDGETYEAR_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_BUDGETYEAR_V1); } if (load_entries) @@ -123,23 +128,30 @@ void TBudgetYearList::LoadEntriesUsing(const wxString& sql_statement) { - entrylist_.clear(); - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + DestroyEntryList(); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - std::shared_ptr<TBudgetYearEntry> pEntry(new TBudgetYearEntry(q1)); - entrylist_.push_back(pEntry); + entrylist_.push_back(new TBudgetYearEntry(q1)); } q1.Finalize(); } +void TBudgetYearList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} + int TBudgetYearList::AddEntry(TBudgetYearEntry* pBudgetYearEntry) { - std::shared_ptr<TBudgetYearEntry> pEntry(pBudgetYearEntry); - entrylist_.push_back(pEntry); - pEntry->Add(db_.get()); + entrylist_.push_back(pBudgetYearEntry); + pBudgetYearEntry->Add(ListDatabase()); - return pEntry->id_; + return pBudgetYearEntry->id_; } int TBudgetYearList::AddEntry(wxString budget_year_name) @@ -155,7 +167,7 @@ TBudgetYearEntry* pEntry = GetEntryPtr(budget_year_id); if (pEntry) { - pEntry->Delete(db_.get()); + pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); } } @@ -169,7 +181,7 @@ { if (entrylist_[index]->id_ == budget_year_id) { - pEntry = entrylist_[index].get(); + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -184,7 +196,7 @@ TBudgetYearEntry* pEntry = 0; if (list_index < entrylist_.size()) { - pEntry = entrylist_[list_index].get(); + pEntry = entrylist_[list_index]; } return pEntry; Modified: trunk/mmex/src/db/budget_year.h =================================================================== --- trunk/mmex/src/db/budget_year.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/budget_year.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -49,11 +49,14 @@ { private: void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); public: - std::vector<std::shared_ptr<TBudgetYearEntry> >entrylist_; + std::vector<TBudgetYearEntry*> entrylist_; - TBudgetYearList(std::shared_ptr<wxSQLite3Database> db, bool load_entries = true); + TBudgetYearList(wxSQLite3Database* db, bool load_entries = true); + ~TBudgetYearList(); /// Allows specialised loads by providing the required SQL statement void LoadEntriesUsing(const wxString& sql_statement); Modified: trunk/mmex/src/db/category.cpp =================================================================== --- trunk/mmex/src/db/category.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/category.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -84,23 +84,28 @@ TCategoryList Methods ***********************************************************************************/ /// Constructor -TCategoryList::TCategoryList(std::shared_ptr<wxSQLite3Database> db) +TCategoryList::TCategoryList(wxSQLite3Database* db) : TListBase(db) { LoadEntries(); } +TCategoryList::~TCategoryList() +{ + DestroyEntryList(); +} + void TCategoryList::LoadEntries(bool load_entries) { try { - if (!db_->TableExists("CATEGORY_V1")) + if (!ListDatabase()->TableExists("CATEGORY_V1")) { const char CREATE_TABLE_CATEGORY_V1[]= "CREATE TABLE CATEGORY_V1(CATEGID integer primary key, " "CATEGNAME TEXT NOT NULL)"; - db_->ExecuteUpdate(CREATE_TABLE_CATEGORY_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_CATEGORY_V1); } if (load_entries) @@ -114,30 +119,39 @@ } } - // Allows specialised loads by providing the required SQL statement +// Allows specialised loads by providing the required SQL statement void TCategoryList::LoadEntriesUsing(const wxString& sql_statement) { - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + DestroyEntryList(); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - TCategoryEntry pCategory(q1); - entrylist_.push_back(pCategory); + entrylist_.push_back(new TCategoryEntry(q1)); } q1.Finalize(); } +// delete all the objects in the list and clear the list. +void TCategoryList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} int TCategoryList::AddEntry(const wxString& name) { int cat_id = -1; if (CategoryExists(name)) { - cat_id = entrylist_[current_index_].id_; + cat_id = entrylist_[current_index_]->id_; } else { - TCategoryEntry entry(name); - cat_id = entry.Add(db_.get()); - entrylist_.push_back(entry); + TCategoryEntry* pEntry = new TCategoryEntry(name); + cat_id = pEntry->Add(ListDatabase()); + entrylist_.push_back(pEntry); } return cat_id; @@ -147,7 +161,7 @@ { TCategoryEntry* pEntry = GetEntryPtr(cat_id); pEntry->name_ = new_category; - pEntry->Update(db_.get()); + pEntry->Update(ListDatabase()); } /// Note: At this level, no checking is done for usage in other tables. @@ -156,8 +170,9 @@ TCategoryEntry* pEntry = GetEntryPtr(cat_id); if (pEntry) { - pEntry->Delete(db_.get()); + pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pEntry; } } @@ -170,9 +185,9 @@ while (index < entrylist_.size()) { - if (entrylist_[index].id_ == cat_id) + if (entrylist_[index]->id_ == cat_id) { - pEntry = &entrylist_[index]; + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -188,9 +203,9 @@ size_t index = 0; while (index < entrylist_.size()) { - if (entrylist_[index].name_ == name) + if (entrylist_[index]->name_ == name) { - pEntry = &entrylist_[index]; + pEntry = entrylist_[index]; current_index_ = index; break; } Modified: trunk/mmex/src/db/category.h =================================================================== --- trunk/mmex/src/db/category.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/category.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -48,12 +48,15 @@ class TCategoryList : public TListBase { private: - std::vector<TCategoryEntry> entrylist_; + std::vector<TCategoryEntry*> entrylist_; void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); public: - TCategoryList(std::shared_ptr<wxSQLite3Database> db); + TCategoryList(wxSQLite3Database* db); + ~TCategoryList(); // Allows specialised loads by providing the required SQL statement void LoadEntriesUsing(const wxString& sql_statement); Modified: trunk/mmex/src/db/currency.cpp =================================================================== --- trunk/mmex/src/db/currency.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/currency.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -152,7 +152,7 @@ TCurrencyList Methods ***********************************************************************************/ /// Constructor -TCurrencyList::TCurrencyList(std::shared_ptr<wxSQLite3Database> db) +TCurrencyList::TCurrencyList(wxSQLite3Database* db) : TListBase(db) , basecurrency_id_(-1) { @@ -164,7 +164,7 @@ { try { - if (!db_->TableExists("CURRENCYFORMATS_V1")) + if (!ListDatabase()->TableExists("CURRENCYFORMATS_V1")) { const char SQL_CREATE_TABLE_CURRENCYFORMATS_V1[] = "create table CURRENCYFORMATS_V1 " @@ -172,13 +172,13 @@ " PFX_SYMBOL TEXT, SFX_SYMBOL TEXT, DECIMAL_POINT TEXT, GROUP_SEPARATOR TEXT," " UNIT_NAME TEXT, CENT_NAME TEXT, SCALE numeric, BASECONVRATE numeric, CURRENCY_SYMBOL TEXT)"; - db_->ExecuteUpdate(SQL_CREATE_TABLE_CURRENCYFORMATS_V1); + ListDatabase()->ExecuteUpdate(SQL_CREATE_TABLE_CURRENCYFORMATS_V1); } const char SQL_SELECT_CURRENCYFORMAT[] = "select * from CURRENCYFORMATS_V1 " "order by CURRENCYNAME"; - wxSQLite3ResultSet q1 = db_->ExecuteQuery(SQL_SELECT_CURRENCYFORMAT); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(SQL_SELECT_CURRENCYFORMAT); while (q1.NextRow()) { std::shared_ptr<TCurrencyEntry> pEntry(new TCurrencyEntry(q1)); @@ -231,7 +231,7 @@ TCurrencyEntry* pEntry = GetEntryPtr(currency_id); if (pEntry) { - pEntry->Delete(db_.get()); + pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); } } Modified: trunk/mmex/src/db/currency.h =================================================================== --- trunk/mmex/src/db/currency.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/currency.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -235,7 +235,7 @@ public: std::vector<std::shared_ptr<TCurrencyEntry> > entrylist_; - TCurrencyList(std::shared_ptr<wxSQLite3Database> db); + TCurrencyList(wxSQLite3Database* db); int AddEntry(TCurrencyEntry* pCurrencyEntry); void SetBaseCurrency(int currency_id); Modified: trunk/mmex/src/db/entry_base.cpp =================================================================== --- trunk/mmex/src/db/entry_base.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/entry_base.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -61,14 +61,14 @@ /************************************************************************************ TListBase Methods ***********************************************************************************/ -TListBase::TListBase(std::shared_ptr<wxSQLite3Database> db) +TListBase::TListBase(wxSQLite3Database* db) : db_(db) , current_index_(-1) {} wxSQLite3Database* TListBase::ListDatabase() { - return db_.get(); + return db_; } int TListBase::GetCurrentIndex() Modified: trunk/mmex/src/db/entry_base.h =================================================================== --- trunk/mmex/src/db/entry_base.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/entry_base.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -36,7 +36,7 @@ /// This will finalise the sql statement. void FinaliseStatement(wxSQLite3Statement& st); - + // Delete the entry from the database void DeleteEntry(wxSQLite3Database* db, const wxString& sql_statement); public: @@ -54,13 +54,14 @@ ***********************************************************************************/ class TListBase { +private: + wxSQLite3Database* db_; + protected: - std::shared_ptr<wxSQLite3Database> db_; int current_index_; public: - TListBase(std::shared_ptr<wxSQLite3Database> db); + TListBase(wxSQLite3Database* db); wxSQLite3Database* ListDatabase(); int GetCurrentIndex(); - }; Modified: trunk/mmex/src/db/payee_table.cpp =================================================================== --- trunk/mmex/src/db/payee_table.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/payee_table.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -98,23 +98,28 @@ TPayeeList Methods ***********************************************************************************/ /// Constructor -TPayeeList::TPayeeList(std::shared_ptr<wxSQLite3Database> db) +TPayeeList::TPayeeList(wxSQLite3Database* db) : TListBase(db) { LoadEntries(); } +TPayeeList::~TPayeeList() +{ + DestroyEntryList(); +} + void TPayeeList::LoadEntries(bool load_entries) { try { - if (!db_->TableExists("PAYEE_V1")) + if (!ListDatabase()->TableExists("PAYEE_V1")) { const char CREATE_TABLE_PAYEE_V1[]= "CREATE TABLE PAYEE_V1(PAYEEID integer primary key, " "PAYEENAME TEXT NOT NULL UNIQUE, CATEGID integer, SUBCATEGID integer)"; - db_->ExecuteUpdate(CREATE_TABLE_PAYEE_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_PAYEE_V1); } if (load_entries) @@ -130,28 +135,36 @@ void TPayeeList::LoadEntriesUsing(const wxString& sql_statement) { - entrylist_.clear(); - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + DestroyEntryList(); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - TPayeeEntry pEntry(q1); - entrylist_.push_back(pEntry); + entrylist_.push_back(new TPayeeEntry(q1)); } q1.Finalize(); } +void TPayeeList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} + int TPayeeList::AddEntry(const wxString& name, wxString category, wxString subcategory) { int payee_id = -1; if (PayeeExists(name)) { - payee_id = entrylist_[current_index_].id_; + payee_id = entrylist_[current_index_]->GetId(); } else { - TPayeeEntry pEntry(name); - payee_id = pEntry.Add(db_.get()); + TPayeeEntry* pEntry = new TPayeeEntry(name); entrylist_.push_back(pEntry); + payee_id = pEntry->Add(ListDatabase()); } return payee_id; @@ -172,7 +185,7 @@ { pEntry->subcat_id_ = subcat_id; } - pEntry->Update(db_.get()); + pEntry->Update(ListDatabase()); } void TPayeeList::UpdateEntry(const wxString& payee_name, int cat_id, int subcat_id) @@ -180,7 +193,7 @@ TPayeeEntry* pEntry = GetEntryPtr(payee_name); pEntry->cat_id_ = cat_id; pEntry->subcat_id_ = subcat_id; - pEntry->Update(db_.get()); + pEntry->Update(ListDatabase()); } void TPayeeList::DeleteEntry(int payee_id) @@ -188,8 +201,9 @@ TPayeeEntry* pEntry = GetEntryPtr(payee_id); if (pEntry) { - pEntry->Delete(db_.get()); + pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pEntry; } } @@ -207,9 +221,9 @@ while (index < entrylist_.size()) { - if (entrylist_[index].id_ == payee_id) + if (entrylist_[index]->GetId() == payee_id) { - pEntry = &entrylist_[index]; + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -226,9 +240,9 @@ while (index < entrylist_.size()) { - if (entrylist_[index].name_ == name) + if (entrylist_[index]->name_ == name) { - pEntry = &entrylist_[index]; + pEntry = entrylist_[index]; current_index_ = index; break; } Modified: trunk/mmex/src/db/payee_table.h =================================================================== --- trunk/mmex/src/db/payee_table.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/payee_table.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -52,11 +52,14 @@ { private: void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); public: - std::vector<TPayeeEntry> entrylist_; + std::vector<TPayeeEntry*> entrylist_; - TPayeeList(std::shared_ptr<wxSQLite3Database> db); + TPayeeList(wxSQLite3Database* db); + ~TPayeeList(); // Allows specialised loads by providing the required SQL statement void LoadEntriesUsing(const wxString& sql_statement); Modified: trunk/mmex/src/db/settings.cpp =================================================================== --- trunk/mmex/src/db/settings.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/settings.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -118,7 +118,7 @@ /**************************************************************************** TSettingsList Class methods ****************************************************************************/ -TSettingsList::TSettingsList(std::shared_ptr<wxSQLite3Database> db, bool main_db) +TSettingsList::TSettingsList(wxSQLite3Database* db, bool main_db) : TListBase(db) , main_db_(main_db) { @@ -150,8 +150,8 @@ void TSettingsList::Load() { wxSQLite3ResultSet q1; - if (main_db_) q1 = db_->ExecuteQuery(SELECT_INFO_RECORD); - else q1 = db_->ExecuteQuery(SELECT_INI_RECORD); + if (main_db_) q1 = ListDatabase()->ExecuteQuery(SELECT_INFO_RECORD); + else q1 = ListDatabase()->ExecuteQuery(SELECT_INI_RECORD); while (q1.NextRow()) { std::shared_ptr<TSettingsEntry> pRecord(new TSettingsEntry(main_db_, q1)); @@ -165,13 +165,13 @@ size_t list_size = ini_records_.size(); size_t element = 0; - db_->Begin(); + ListDatabase()->Begin(); while (element < list_size) { ini_records_[element]->Save(ListDatabase()); ++ element; } - db_->Commit(); + ListDatabase()->Commit(); } TSettingsEntry* TSettingsList::GetRecord(const wxString& name) Modified: trunk/mmex/src/db/settings.h =================================================================== --- trunk/mmex/src/db/settings.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/settings.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -54,7 +54,7 @@ { public: /// Constructor - TSettingsList(std::shared_ptr<wxSQLite3Database> db, bool main_db = false); + TSettingsList(wxSQLite3Database* db, bool main_db = false); ~TSettingsList(); bool GetBoolSetting(const wxString& name, bool default_value); Modified: trunk/mmex/src/db/splittransaction.cpp =================================================================== --- trunk/mmex/src/db/splittransaction.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/splittransaction.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -85,7 +85,7 @@ /*********************************************************************************** TSplitEntriesList **********************************************************************************/ -TSplitEntriesList::TSplitEntriesList(std::shared_ptr<wxSQLite3Database> db, wxString db_table) +TSplitEntriesList::TSplitEntriesList(wxSQLite3Database* db, wxString db_table) : TListBase(db) , db_table_(db_table) , global_entries_() @@ -97,14 +97,14 @@ { try { - if (! db_->TableExists(db_table_)) + if (! ListDatabase()->TableExists(db_table_)) { wxString sql_statement; sql_statement << "CREATE TABLE " << db_table_ << "(SPLITTRANSID integer primary key, " << " TRANSID numeric NOT NULL, " << " CATEGID integer, SUBCATEGID integer, SPLITTRANSAMOUNT numeric)"; - db_->ExecuteUpdate(sql_statement); + ListDatabase()->ExecuteUpdate(sql_statement); } wxString sql_statement; @@ -112,7 +112,7 @@ << " CATEGID, SUBCATEGID," << " SPLITTRANSAMOUNT " << "from " << db_table_ << " order by SPLITTRANSID"; - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { std::shared_ptr<TSplitEntry> pEntry(new TSplitEntry(q1)); @@ -178,14 +178,14 @@ void TSplitTransactionList::SaveListforTransaction(int id_transaction) { id_transaction_ = id_transaction; - entries_List_.db_->Begin(); + entries_List_.ListDatabase()->Begin(); for (size_t i = 0; i < entries_.size(); ++i) { entries_List_.global_entries_.push_back(entries_[i]); // Add to global list - entries_[i]->Add(entries_List_.db_.get(), entries_List_.db_table_); + entries_[i]->Add(entries_List_.ListDatabase(), entries_List_.db_table_); } - entries_List_.db_->Commit(); + entries_List_.ListDatabase()->Commit(); } double TSplitTransactionList::TotalAmount() @@ -198,7 +198,7 @@ total_ += pEntry->amount_; entries_.push_back(pEntry); // Add to local list entries_List_.global_entries_.push_back(pEntry); // Add to global list - pEntry->Add(entries_List_.db_.get(), entries_List_.db_table_); + pEntry->Add(entries_List_.ListDatabase(), entries_List_.db_table_); } int TSplitTransactionList::AddEntry(int cat_id, int subcat_id, double amount) @@ -215,13 +215,13 @@ void TSplitTransactionList::UpdateEntry(std::shared_ptr<TSplitEntry> split_entry) { - split_entry->Update(entries_List_.db_.get(), entries_List_.db_table_); + split_entry->Update(entries_List_.ListDatabase(), entries_List_.db_table_); ReEvaluateTotal(); } void TSplitTransactionList::DeleteEntry(std::shared_ptr<TSplitEntry> split_entry) { - split_entry->Delete(entries_List_.db_.get(), entries_List_.db_table_); + split_entry->Delete(entries_List_.ListDatabase(), entries_List_.db_table_); entries_.clear(); RemoveGlobalEntry(split_entry->id_); total_ = 0.0; Modified: trunk/mmex/src/db/splittransaction.h =================================================================== --- trunk/mmex/src/db/splittransaction.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/splittransaction.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -68,7 +68,7 @@ void LoadSplitEntries(); public: - TSplitEntriesList(std::shared_ptr<wxSQLite3Database> db, wxString db_table = SPLIT_TRANS_TABLE); + TSplitEntriesList(wxSQLite3Database* db, wxString db_table = SPLIT_TRANS_TABLE); }; /*********************************************************************************** @@ -112,5 +112,4 @@ int GetListSize(); std::shared_ptr<TSplitEntry> GetEntryPtr(int id_split_trans); std::shared_ptr<TSplitEntry> GetIndexedEntryPtr(int index); - }; Modified: trunk/mmex/src/db/stocks.cpp =================================================================== --- trunk/mmex/src/db/stocks.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/stocks.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -169,7 +169,7 @@ TStockList Methods ***********************************************************************************/ /// Constructor -TStockList::TStockList(std::shared_ptr<wxSQLite3Database> db, bool load_entries) +TStockList::TStockList(wxSQLite3Database* db, bool load_entries) : TListBase(db) { LoadEntries(load_entries); @@ -179,7 +179,7 @@ { try { - if (!db_->TableExists("STOCK_V1")) + if (!ListDatabase()->TableExists("STOCK_V1")) { const char CREATE_TABLE_STOCK_V1[] = "CREATE TABLE STOCK_V1(STOCKID integer primary key, " @@ -187,7 +187,7 @@ "NUMSHARES numeric, PURCHASEPRICE numeric NOT NULL, NOTES TEXT, CURRENTPRICE numeric NOT NULL, " "VALUE numeric, COMMISSION numeric)"; - db_->ExecuteUpdate(CREATE_TABLE_STOCK_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_STOCK_V1); } if (load_entries) @@ -206,7 +206,7 @@ try { entrylist_.clear(); - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { TStockEntry entry(q1); Modified: trunk/mmex/src/db/stocks.h =================================================================== --- trunk/mmex/src/db/stocks.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/stocks.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -76,7 +76,7 @@ public: std::vector<TStockEntry> entrylist_; - TStockList(std::shared_ptr<wxSQLite3Database> db, bool load_entries = true); + TStockList(wxSQLite3Database* db, bool load_entries = true); // Allows specialised list loading provided by SQL statement void LoadEntriesUsing(const wxString& sql_statement); Modified: trunk/mmex/src/db/subcategory.cpp =================================================================== --- trunk/mmex/src/db/subcategory.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/subcategory.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -91,7 +91,7 @@ TSubCategoryList Methods ***********************************************************************************/ /// Constructor -TSubCategoryList::TSubCategoryList(std::shared_ptr<wxSQLite3Database> db, int cat_id) +TSubCategoryList::TSubCategoryList(wxSQLite3Database* db, int cat_id) : TListBase(db) { LoadEntries(cat_id); @@ -101,13 +101,13 @@ { try { - if (!db_->TableExists("SUBCATEGORY_V1")) + if (!ListDatabase()->TableExists("SUBCATEGORY_V1")) { const char CREATE_TABLE_SUBCATEGORY_V1[]= "CREATE TABLE SUBCATEGORY_V1(SUBCATEGID integer primary key, " "SUBCATEGNAME TEXT NOT NULL, CATEGID integer NOT NULL)"; - db_->ExecuteUpdate(CREATE_TABLE_SUBCATEGORY_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_SUBCATEGORY_V1); } if (load_entries) @@ -130,7 +130,7 @@ void TSubCategoryList::LoadEntriesUsing(const wxString& sql_statement) { entrylist_.clear(); - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { TSubCategoryEntry entry(q1); @@ -149,7 +149,7 @@ else { TSubCategoryEntry entry(cat_id, name); - subcat_id = entry.Add(db_.get()); + subcat_id = entry.Add(ListDatabase()); entrylist_.push_back(entry); } @@ -160,15 +160,15 @@ { TSubCategoryEntry* pSubCategory = GetEntryPtr(cat_id, subcat_id); pSubCategory->name_ = new_category; - pSubCategory->Update(db_.get()); + pSubCategory->Update(ListDatabase()); } /// Note: At this level, no checking is done for usage in other tables. void TSubCategoryList::DeleteEntry(int cat_id, int subcat_id) { TSubCategoryEntry* pSubCatEntry = GetEntryPtr(cat_id, subcat_id); - pSubCatEntry->Delete(db_.get()); - entrylist_.erase(entrylist_.begin() + current_index_); + pSubCatEntry->Delete(ListDatabase()); + entrylist_.erase(entrylist_.begin() + current_index_); } TSubCategoryEntry* TSubCategoryList::GetEntryPtr(int cat_id, int subcat_id) Modified: trunk/mmex/src/db/subcategory.h =================================================================== --- trunk/mmex/src/db/subcategory.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/subcategory.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -55,7 +55,7 @@ public: std::vector<TSubCategoryEntry> entrylist_; - TSubCategoryList(std::shared_ptr<wxSQLite3Database> db, int cat_id = -1); + TSubCategoryList(wxSQLite3Database* db, int cat_id = -1); // Allows specialised loads by providing the required SQL statement void LoadEntriesUsing(const wxString& sql_statement); Modified: trunk/mmex/src/db/transaction.cpp =================================================================== --- trunk/mmex/src/db/transaction.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/transaction.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -196,17 +196,22 @@ TTransactionList Methods ***********************************************************************************/ /// Constructor -TTransactionList::TTransactionList(std::shared_ptr<wxSQLite3Database> db, bool load_entries) +TTransactionList::TTransactionList(wxSQLite3Database* db, bool load_entries) : TListBase(db) { LoadEntries(load_entries); } +TTransactionList::~TTransactionList() +{ + DestroyEntryList(); +} + void TTransactionList::LoadEntries(bool load_entries) { try { - if (!db_->TableExists("CHECKINGACCOUNT_V1")) + if (!ListDatabase()->TableExists("CHECKINGACCOUNT_V1")) { const char CREATE_TABLE_CHECKINGACCOUNT_V1[]= "CREATE TABLE CHECKINGACCOUNT_V1(TRANSID integer primary key, " @@ -214,7 +219,7 @@ "TRANSAMOUNT numeric NOT NULL, STATUS TEXT, TRANSACTIONNUMBER TEXT, NOTES TEXT, " "CATEGID integer, SUBCATEGID integer, TRANSDATE TEXT, FOLLOWUPID integer, TOTRANSAMOUNT numeric)"; - db_->ExecuteUpdate(CREATE_TABLE_CHECKINGACCOUNT_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_CHECKINGACCOUNT_V1); } if (load_entries) @@ -230,23 +235,30 @@ void TTransactionList::LoadEntriesUsing(const wxString& sql_statement) { - entrylist_.clear(); - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + DestroyEntryList(); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - std::shared_ptr<TTransactionEntry> pEntry(new TTransactionEntry(q1)); - entrylist_.push_back(pEntry); + entrylist_.push_back(new TTransactionEntry(q1)); } q1.Finalize(); } +void TTransactionList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} + int TTransactionList::AddEntry(TTransactionEntry* pTransEntry) { - std::shared_ptr<TTransactionEntry> pEntry(pTransEntry); - entrylist_.push_back(pEntry); - pEntry->Add(db_.get()); + entrylist_.push_back(pTransEntry); + pTransEntry->Add(ListDatabase()); - return pEntry->id_; + return pTransEntry->id_; } void TTransactionList::DeleteEntry(int trans_id) @@ -254,8 +266,9 @@ TTransactionEntry* pEntry = GetEntryPtr(trans_id); if (pEntry) { - pEntry->Delete(db_.get()); + pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pEntry; } } @@ -268,7 +281,7 @@ { if (entrylist_[index]->id_ == trans_id) { - pEntry = entrylist_[index].get(); + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -283,7 +296,7 @@ TTransactionEntry* pEntry = 0; if (list_index < entrylist_.size()) { - pEntry = entrylist_[list_index].get(); + pEntry = entrylist_[list_index]; } return pEntry; @@ -293,4 +306,3 @@ { return entrylist_.size(); } - Modified: trunk/mmex/src/db/transaction.h =================================================================== --- trunk/mmex/src/db/transaction.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/transaction.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -42,7 +42,9 @@ private: friend class TTransactionList; + // Add the entry to the database int Add(wxSQLite3Database* db); + // Delete the entry from the dataase void Delete(wxSQLite3Database* db); protected: @@ -106,16 +108,21 @@ { private: void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); public: - std::vector<std::shared_ptr<TTransactionEntry> > entrylist_; + std::vector<TTransactionEntry*> entrylist_; - TTransactionList(std::shared_ptr<wxSQLite3Database> db, bool load_entries = true); + TTransactionList(wxSQLite3Database* db, bool load_entries = true); + ~TTransactionList(); // Allows specialised loads by providing the required SQL statement void LoadEntriesUsing(const wxString& sql_statement); + // Add the entry to the current list and the database int AddEntry(TTransactionEntry* pTransEntry); + // Add the entry from the current list and the database void DeleteEntry(int trans_id); TTransactionEntry* GetEntryPtr(int trans_id); Modified: trunk/mmex/src/db/transactionbill.cpp =================================================================== --- trunk/mmex/src/db/transactionbill.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/transactionbill.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -356,17 +356,22 @@ TTransactionBillList Methods ***********************************************************************************/ /// Constructor -TTransactionBillList::TTransactionBillList(std::shared_ptr<wxSQLite3Database> db, bool load_entries) +TTransactionBillList::TTransactionBillList(wxSQLite3Database* db, bool load_entries) : TTransactionList(db, false) { LoadEntries(load_entries); } +TTransactionBillList::~TTransactionBillList() +{ + DestroyEntryList(); +} + void TTransactionBillList::LoadEntries(bool load_entries) { try { - if (!db_->TableExists("BILLSDEPOSITS_V1")) + if (!ListDatabase()->TableExists("BILLSDEPOSITS_V1")) { const char CREATE_TABLE_BILLSDEPOSITS_V1[] = "CREATE TABLE BILLSDEPOSITS_V1 (BDID INTEGER PRIMARY KEY, " @@ -375,7 +380,7 @@ "CATEGID integer, SUBCATEGID integer, TRANSDATE TEXT, FOLLOWUPID integer, TOTRANSAMOUNT numeric, " "REPEATS numeric, NEXTOCCURRENCEDATE TEXT, NUMOCCURRENCES numeric)"; - db_->ExecuteUpdate(CREATE_TABLE_BILLSDEPOSITS_V1); + ListDatabase()->ExecuteUpdate(CREATE_TABLE_BILLSDEPOSITS_V1); } if (load_entries) @@ -391,23 +396,31 @@ void TTransactionBillList::LoadEntriesUsing(const wxString& sql_statement) { - entrylist_.clear(); - wxSQLite3ResultSet q1 = db_->ExecuteQuery(sql_statement); + DestroyEntryList(); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - std::shared_ptr<TTransactionBillEntry> pEntry(new TTransactionBillEntry(q1)); - entrylist_.push_back(pEntry); + entrylist_.push_back(new TTransactionBillEntry(q1)); } q1.Finalize(); } +// delete all the objects in the list and clear the list. +void TTransactionBillList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} + int TTransactionBillList::AddEntry(TTransactionBillEntry* pTransBillEntry) { - std::shared_ptr<TTransactionBillEntry> pEntry(pTransBillEntry); - entrylist_.push_back(pEntry); - pEntry->Add(db_.get()); + entrylist_.push_back(pTransBillEntry); + pTransBillEntry->Add(ListDatabase()); - return pEntry->id_; + return pTransBillEntry->id_; } void TTransactionBillList::DeleteEntry(int bill_entry_id) @@ -415,8 +428,9 @@ TTransactionBillEntry* pEntry = GetEntryPtr(bill_entry_id); if (pEntry) { - pEntry->Delete(db_.get()); + pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pEntry; } } @@ -428,7 +442,7 @@ { if (entrylist_[index]->id_ == bill_entry_id) { - pEntry = entrylist_[index].get(); + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -443,7 +457,7 @@ TTransactionBillEntry* pEntry = 0; if (list_index < entrylist_.size()) { - pEntry = entrylist_[list_index].get(); + pEntry = entrylist_[list_index]; } return pEntry; Modified: trunk/mmex/src/db/transactionbill.h =================================================================== --- trunk/mmex/src/db/transactionbill.h 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/db/transactionbill.h 2013-06-02 05:29:50 UTC (rev 4027) @@ -124,11 +124,14 @@ { private: void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); public: - std::vector<std::shared_ptr<TTransactionBillEntry> > entrylist_; + std::vector<TTransactionBillEntry*> entrylist_; - TTransactionBillList(std::shared_ptr<wxSQLite3Database> db, bool load_entries = true); + TTransactionBillList(wxSQLite3Database* db, bool load_entries = true); + ~TTransactionBillList(); /// Allows specialised loads by providing the required SQL statement void LoadEntriesUsing(const wxString& sql_statement); Modified: trunk/mmex/src/mmhomepagepanel.cpp =================================================================== --- trunk/mmex/src/mmhomepagepanel.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/mmhomepagepanel.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -336,7 +336,7 @@ { mmHTMLBuilder hb; core_->currencyList_.LoadBaseCurrencySettings(); - TAssetList asset_list(core_->db_); + TAssetList asset_list(core_->db_.get()); if (mmIniOptions::instance().enableAssets_) { Modified: trunk/mmex/src/reports/cashflow.cpp =================================================================== --- trunk/mmex/src/reports/cashflow.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/reports/cashflow.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -167,7 +167,7 @@ #define USING_NEW_DB_CLASSES // Activation switch #ifdef USING_NEW_DB_CLASSES // load a fresh list of repeating transactions. - TTransactionBillList repeat_trans_list(core_->db_); + TTransactionBillList repeat_trans_list(core_->db_.get()); for (const auto& repeat_entry:repeat_trans_list.entrylist_) { @@ -194,23 +194,23 @@ { if (repeat_entry->UsingIn_X_Processing()) { - SetRepeatForecast(fvec, repeat_entry.get(), amount); + SetRepeatForecast(fvec, repeat_entry, amount); } else if (repeat_entry->UsingEvery_X_Processing()) { - SetYearsRepeatForecast(fvec, repeat_entry.get(), amount, yearFromNow); + SetYearsRepeatForecast(fvec, repeat_entry, amount, yearFromNow); } else { while (repeat_entry->num_repeats_ > 0) { - SetRepeatForecast(fvec, repeat_entry.get(), amount); + SetRepeatForecast(fvec, repeat_entry, amount); } } } else { - SetYearsRepeatForecast(fvec, repeat_entry.get(), amount, yearFromNow); + SetYearsRepeatForecast(fvec, repeat_entry, amount, yearFromNow); } } Modified: trunk/mmex/src/reports/summary.cpp =================================================================== --- trunk/mmex/src/reports/summary.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/reports/summary.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -132,7 +132,7 @@ hb.addRowSeparator(2); /* Assets */ - TAssetList asset_list(core_->db_); + TAssetList asset_list(core_->db_.get()); hb.startTableRow(); hb.addTableCellLink("Assets", _("Assets"), false, true); Modified: trunk/mmex/src/reports/summaryassets.cpp =================================================================== --- trunk/mmex/src/reports/summaryassets.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/reports/summaryassets.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -44,7 +44,7 @@ core_->currencyList_.LoadBaseCurrencySettings(); - TAssetList asset_list_(core_->db_); + TAssetList asset_list_(core_->db_.get()); for (const auto & pEntry: asset_list_.entrylist_) { hb.startTableRow(); Modified: trunk/mmex/src/tests/new_classes_test.cpp =================================================================== --- trunk/mmex/src/tests/new_classes_test.cpp 2013-05-31 11:20:26 UTC (rev 4026) +++ trunk/mmex/src/tests/new_classes_test.cpp 2013-06-02 05:29:50 UTC (rev 4027) @@ -45,7 +45,7 @@ //---------------------------------------------------------------------------- // This is a way to prevent certain tests occuring during development testing -//#define CENTRALL_DB_TESTS +#define CENTRALL_DB_TESTS #define CURRENCY_TESTS #define ACCOUNT_TESTS #define CATEGORY_TESTS @@ -53,11 +53,13 @@ #define PAYEE_TESTS #define TRANSACTION_TESTS #define REPEAT_TRANSACTION_TESTS -//#define SPLIT_TRANSACTION_TESTS -//#define ASSET_TESTS +#define SPLIT_TRANSACTION_TESTS +#define ASSET_TESTS #define STOCK_TESTS #define BUDGET_TESTS +//#define PAUSE_DISPLAY_CLOSING + //---------------------------------------------------------------------------- /// Central class holding all major components of the database class TDatabase @@ -77,7 +79,7 @@ TBudgetYearList budget_year_list_; TBudgetList budget_entry_list_; - TDatabase(std::shared_ptr<wxSQLite3Database> db) + TDatabase(wxSQLite3Database* db) : info_settings_(db, true) , currency_list_(db) , account_list_(db, currency_list_) @@ -97,7 +99,7 @@ // Create a single access point for the main database, stored in memory. std::shared_ptr<TDatabase> main_db() { - static std::shared_ptr<TDatabase> pCore(new TDatabase(get_pDb())); + static std::shared_ptr<TDatabase> pCore(new TDatabase(get_pDb().get())); return pCore; } @@ -144,7 +146,7 @@ const wxStopWatch start_time; - TCurrencyList currency_list(get_pDb()); + TCurrencyList currency_list(get_pDb().get()); TCurrencyEntry* pCurrencyEntry = new TCurrencyEntry(); // default = USD int id_first = currency_list.AddEntry(pCurrencyEntry); @@ -182,7 +184,7 @@ { const wxStopWatch start_time; - TCurrencyList currency_list(get_pDb()); + TCurrencyList currency_list(get_pDb().get()); int id_AUD = currency_list.GetCurrencyId(CURRENCIES[TCurrencyEntry::SYMBOL_AUD], true); TCurrencyEntry* pEntry_AUD = currency_list.GetEntryPtr(id_AUD); @@ -203,9 +205,9 @@ TEST(TAccountList_Test_Add) { const wxStopWatch start_time; - TCurrencyList currency_list(get_pDb()); + TCurrencyList currency_list(get_pDb().get()); - TAccountList account_list(get_pDb(), currency_list); + TAccountList account_list(get_pDb().get(), currency_list); TAccountEntry account_entry; account_entry.acc_name_ = "Savings"; account_entry.acc_state_ = ACCOUNT_STATE_DEF[TAccountEntry::STATE_OPEN]; @@ -234,7 +236,7 @@ { const wxStopWatch start_time; - TCategoryList cat_list(get_pDb()); + TCategoryList cat_list(get_pDb().get()); int cat_id; cat_list.ListDatabase()->Begin(); @@ -280,8 +282,8 @@ { const wxStopWatch start_time; - TCategoryList cat_list(get_pDb()); - TSubCategoryList subcat_list(get_pDb()); + TCategoryList cat_list(get_pDb().get()); + TSubCategoryList subcat_list(get_pDb().get()); cat_list.ListDatabase()->Begin(); int cat_id = -1; @@ -348,10 +350,10 @@ TEST(TCategoryList_SubList_Test) { const wxStopWatch start_time; - TCategoryList cat_list(get_pDb()); + TCategoryList cat_list(get_pDb().get()); int cat_id = cat_list.GetCategoryId("Automobile"); - TSubCategoryList subcat_sublist(get_pDb(), cat_id); + TSubCategoryList subcat_sublist(get_pDb().get(), cat_id); int subcat_id = subcat_sublist.GetSubCategoryId(cat_id, "Registration"); @@ -373,7 +375,7 @@ { const wxStopWatch start_time; - TPayeeList payee_list(get_pDb()); + TPayeeList payee_list(get_pDb().get()); int payee_id; payee_id = payee_list.AddEntry("Coles"); @@ -416,7 +418,7 @@ { const wxStopWatch start_time; - TPayeeList payee_list(get_pDb()); + TPayeeList payee_list(get_pDb().get()); //std::shared_ptr<TPayeeEntry> pEntry = payee_list.GetEntryPtr("Woolworths"); TPayeeEntry* pEntry = payee_list.GetEntryPtr("Woolworths"); @@ -437,7 +439,7 @@ { const wxStopWatch start_time; - TTransactionList transactions(get_pDb()); + TTransactionList transactions(get_pDb().get()); transactions.ListDatabase()->Begin(); TTransactionEntry* pTransEntry_1 = new TTransactionEntry(); @@ -478,7 +480,7 @@ { const wxStopWatch start_time; - TTransactionList transactions(get_pDb()); + TTransactionList transactions(get_pDb().get()); TTransactionEntry* pTransEntry = transactions.GetEntryPtr(2); CHECK_EQUAL(2, pTransEntry->GetId()); @@ -499,7 +501,7 @@ TEST(BillList_Add_first_four_entries) { const wxStopWatch start_time; - TTransactionBillList repeat_transactions(get_pDb()); + TTransactionBillList repeat_transactions(get_pDb().get()); TTransactionBillEntry* pBillEntry = new TTransactionBillEntry(); pBillEntry->amount_from_ = 1000; @@ -573,8 +575,8 @@ { const wxStopWatch start_time; - TTransactionList transactions(get_pDb()); - TTransactionBillList repeat_transactions(get_pDb()); + TTransactionList transactions(get_pDb().get()); + TTransactionBillList repeat_transactions(get_pDb().get()); TTransactionBillEntry* pBillEntry = new TTransactionBillEntry(); pBillEntry->amount_from_ = 1000; @@ -603,8 +605,8 @@ { const wxDateTime start_time(wxDateTime::UNow()); - TTransactionList transactions(get_pDb()); - TTransactionBillList repeat_transactions(get_pDb()); + TTransactionList transactions(get_pDb().get()); + TTransactionBillList repeat_transactions(get_pDb().get()); TTransactionEntry* pTransEntry = transactions.GetEntryPtr(2); @@ -625,8 +627,8 @@ { const wxStopWatch start_time; - TTransactionList transactions(get_pDb()); - TTransactionBillList repeat_transactions(get_pDb()); + TTransactionList transactions(get_pDb().get()); + TTransactionBillList repeat_transactions(get_pDb().get()); int days_remaining; bool continue_Execution = false; @@ -676,7 +678,7 @@ TEST(BillList_Deleting_First_Entry) { const wxStopWatch start_time; - TTransactionBillList repeat_transactions(get_pDb()); + TTransactionBillList repeat_transactions(get_pDb().get()); int currentsize = repeat_transactions.CurrentListSize(); if ( c... [truncated message content] |
From: <ste...@us...> - 2013-06-02 07:16:17
|
Revision: 4028 http://sourceforge.net/p/moneymanagerex/code/4028 Author: stef145g Date: 2013-06-02 07:16:10 +0000 (Sun, 02 Jun 2013) Log Message: ----------- Converting objects to object pointers Modified Paths: -------------- trunk/mmex/src/db/account.cpp trunk/mmex/src/db/account.h trunk/mmex/src/db/assets.cpp trunk/mmex/src/tests/new_classes_test.cpp Modified: trunk/mmex/src/db/account.cpp =================================================================== --- trunk/mmex/src/db/account.cpp 2013-06-02 05:29:50 UTC (rev 4027) +++ trunk/mmex/src/db/account.cpp 2013-06-02 07:16:10 UTC (rev 4028) @@ -43,6 +43,24 @@ currency_id_ = q1.GetDouble("CURRENCYID"); } +// Copy constructor using a pointer +TAccountEntry::TAccountEntry(TAccountEntry* pEntry) +: TEntryBase() +{ + acc_name_ = pEntry->acc_name_; + acc_type_ = pEntry->acc_type_; + acc_number_ = pEntry->acc_number_; + acc_state_ = pEntry->acc_type_; + notes_ = pEntry->notes_; + held_at_ = pEntry->held_at_; + website_ = pEntry->website_; + contact_info_ = pEntry->contact_info_; + access_info_ = pEntry->access_info_; + init_balance_ = pEntry->init_balance_; + favoriteAcct_ = pEntry->favoriteAcct_; + currency_id_ = pEntry->currency_id_; +} + void TAccountEntry::SetDatabaseValues(wxSQLite3Statement& st, int& db_index) { st.Bind(++db_index, acc_name_); @@ -135,6 +153,11 @@ LoadEntries(load_entries); } +TAccountList::~TAccountList() +{ + DestroyEntryList(); +} + void TAccountList::LoadEntries(bool load_entries) { try @@ -163,17 +186,16 @@ } } -/// Allows specialised list loading provided by SQL statement +// Allows specialised list loading provided by SQL statement void TAccountList::LoadEntriesUsing(const wxString& sql_statement) { try { - entrylist_.clear(); + DestroyEntryList(); wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - TAccountEntry entry(q1); - entrylist_.push_back(entry); + entrylist_.push_back(new TAccountEntry(q1)); } q1.Finalize(); } @@ -182,13 +204,22 @@ wxLogError("TAccountList:LoadEntriesUsing: %s", e.GetMessage().c_str()); } } +// delete all the objects in the list and clear the list. +void TAccountList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} -int TAccountList::AddEntry(TAccountEntry& account_entry) +int TAccountList::AddEntry(TAccountEntry* pAccountEntry) { - account_entry.Add(ListDatabase()); - entrylist_.push_back(account_entry); + pAccountEntry->Add(ListDatabase()); + entrylist_.push_back(pAccountEntry); - return account_entry.id_; + return pAccountEntry->id_; } void TAccountList::DeleteEntry(int account_id) @@ -198,6 +229,7 @@ { pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pEntry; } } @@ -215,9 +247,9 @@ while (index < entrylist_.size()) { - if (entrylist_[index].id_ == account_id) + if (entrylist_[index]->id_ == account_id) { - pEntry = &entrylist_[index]; + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -234,9 +266,9 @@ while (index < entrylist_.size()) { - if (entrylist_[index].acc_name_ == name) + if (entrylist_[index]->acc_name_ == name) { - pEntry = &entrylist_[index]; + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -251,7 +283,7 @@ TAccountEntry* pEntry = 0; if (list_index < entrylist_.size()) { - pEntry = &entrylist_[list_index]; + pEntry = entrylist_[list_index]; } return pEntry; @@ -291,6 +323,11 @@ return result; } +int TAccountList::CurrentListSize() +{ + return entrylist_.size(); +} + int TAccountList::NumberOfAccounts(int account_type) { size_t index = 0; @@ -298,7 +335,7 @@ while (index < entrylist_.size()) { - if (entrylist_[index].acc_type_ == ACCOUNT_TYPE_DEF[account_type]) + if (entrylist_[index]->acc_type_ == ACCOUNT_TYPE_DEF[account_type]) { ++ count; } Modified: trunk/mmex/src/db/account.h =================================================================== --- trunk/mmex/src/db/account.h 2013-06-02 05:29:50 UTC (rev 4027) +++ trunk/mmex/src/db/account.h 2013-06-02 07:16:10 UTC (rev 4028) @@ -61,10 +61,11 @@ double init_balance_; int currency_id_; - /// Constructor used when loading payees from the database + // Constructor used when loading payees from the database TAccountEntry(wxSQLite3ResultSet& q1); - - /// Constructor for creating a new account entry + // Copy constructor using a pointer + TAccountEntry(TAccountEntry* pEntry); + // Constructor for creating a new account entry TAccountEntry(); void Update(wxSQLite3Database* db); @@ -78,19 +79,22 @@ private: TCurrencyList& currency_list_; void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); int NumberOfAccounts(int account_type); public: - std::vector<TAccountEntry> entrylist_; + std::vector<TAccountEntry*> entrylist_; - TAccountList(wxSQLite3Database* db, - TCurrencyList& currency_list, bool load_entries = true); + TAccountList(wxSQLite3Database* db + , TCurrencyList& currency_list, bool load_entries = true); + ~TAccountList(); /// Allows specialised list loading provided by SQL statement void LoadEntriesUsing(const wxString& sql_statement); - int AddEntry(TAccountEntry& account_entry); + int AddEntry(TAccountEntry* pAccountEntry); /// Note: At this level, no checking is done for usage in other tables. void DeleteEntry(int account_id); @@ -103,6 +107,7 @@ int GetAccountId(const wxString& account_name); wxString GetAccountName(int account_id); bool AccountExists(const wxString& account_name); + int CurrentListSize(); int NumberOfBankAccounts(); int NumberOfTermAccounts(); Modified: trunk/mmex/src/db/assets.cpp =================================================================== --- trunk/mmex/src/db/assets.cpp 2013-06-02 05:29:50 UTC (rev 4027) +++ trunk/mmex/src/db/assets.cpp 2013-06-02 07:16:10 UTC (rev 4028) @@ -36,7 +36,7 @@ type_ = q1.GetString("ASSETTYPE"); } -/// Copy constructor using a pointer +// Copy constructor using a pointer TAssetEntry::TAssetEntry(TAssetEntry* pEntry) : TEntryBase() { Modified: trunk/mmex/src/tests/new_classes_test.cpp =================================================================== --- trunk/mmex/src/tests/new_classes_test.cpp 2013-06-02 05:29:50 UTC (rev 4027) +++ trunk/mmex/src/tests/new_classes_test.cpp 2013-06-02 07:16:10 UTC (rev 4028) @@ -208,24 +208,68 @@ TCurrencyList currency_list(get_pDb().get()); TAccountList account_list(get_pDb().get(), currency_list); - TAccountEntry account_entry; - account_entry.acc_name_ = "Savings"; - account_entry.acc_state_ = ACCOUNT_STATE_DEF[TAccountEntry::STATE_OPEN]; - account_entry.acc_type_ = ACCOUNT_TYPE_DEF[TAccountEntry::TYPE_BANK]; - account_entry.currency_id_ = currency_list.GetCurrencyId("AUD", true); - int id_1 = account_list.AddEntry(account_entry); + TAccountEntry* pAaccountEntry = new TAccountEntry(); + pAaccountEntry->acc_name_ = "Savings"; + pAaccountEntry->acc_state_ = ACCOUNT_STATE_DEF[TAccountEntry::STATE_OPEN]; + pAaccountEntry->acc_type_ = ACCOUNT_TYPE_DEF[TAccountEntry::TYPE_BANK]; + pAaccountEntry->currency_id_ = currency_list.GetCurrencyId("AUD", true); + int id_1 = account_list.AddEntry(pAaccountEntry); - TAccountEntry account_entry_1; - account_entry_1.acc_name_ = "Cheque"; - account_entry_1.acc_state_ = ACCOUNT_STATE_DEF[TAccountEntry::STATE_CLOSED]; - account_entry_1.acc_type_ = ACCOUNT_TYPE_DEF[TAccountEntry::TYPE_TERM]; - account_entry_1.currency_id_ = currency_list.GetCurrencyId("USD", true); - int id_2 = account_list.AddEntry(account_entry_1); + pAaccountEntry = new TAccountEntry(pAaccountEntry); + pAaccountEntry->acc_name_ = "Cheque"; + pAaccountEntry->acc_state_ = ACCOUNT_STATE_DEF[TAccountEntry::STATE_CLOSED]; + pAaccountEntry->acc_type_ = ACCOUNT_TYPE_DEF[TAccountEntry::TYPE_TERM]; + pAaccountEntry->currency_id_ = currency_list.GetCurrencyId("USD", true); + int id_2 = account_list.AddEntry(pAaccountEntry); - CHECK(id_1 != id_2); + CHECK_EQUAL(1, id_1); + CHECK_EQUAL(2, id_2); displayTimeTaken("TAccountList_Test_Add", start_time); } + +TEST(TAccountList_Test_Update) +{ + const wxStopWatch start_time; + TCurrencyList currency_list(get_pDb().get()); + + TAccountList account_list(get_pDb().get(), currency_list); + TAccountEntry* pAaccountEntry = new TAccountEntry(); + pAaccountEntry->acc_name_ = "Mastercard"; + pAaccountEntry->acc_state_ = ACCOUNT_STATE_DEF[TAccountEntry::STATE_OPEN]; + pAaccountEntry->acc_type_ = ACCOUNT_TYPE_DEF[TAccountEntry::TYPE_BANK]; + pAaccountEntry->currency_id_ = currency_list.GetCurrencyId("AUD", true); + int id_1 = account_list.AddEntry(pAaccountEntry); + + pAaccountEntry = new TAccountEntry(pAaccountEntry); + pAaccountEntry->acc_name_ = "Visa"; + pAaccountEntry->acc_state_ = ACCOUNT_STATE_DEF[TAccountEntry::STATE_CLOSED]; + int id_2 = account_list.AddEntry(pAaccountEntry); + + CHECK_EQUAL(3, id_1); + CHECK_EQUAL(4, id_2); + + pAaccountEntry->acc_state_ = ACCOUNT_STATE_DEF[TAccountEntry::STATE_OPEN]; + pAaccountEntry->Update(account_list.ListDatabase()); + + displayTimeTaken("TAccountList_Test_Update", start_time); +} + +TEST(TAccountList_Test_Delete) +{ + const wxStopWatch start_time; + TCurrencyList currency_list(get_pDb().get()); + TAccountList account_list(get_pDb().get(), currency_list); + + TAccountEntry* pAaccountEntry = account_list.GetEntryPtr("Visa"); + CHECK_EQUAL(4, pAaccountEntry->GetId()); + CHECK_EQUAL("Open", pAaccountEntry->acc_state_); + + account_list.DeleteEntry(pAaccountEntry->GetId()); + CHECK_EQUAL(3, account_list.CurrentListSize()); + + displayTimeTaken("TAccountList_Test_Delete", start_time); +} #endif #ifdef CATEGORY_TESTS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ste...@us...> - 2013-06-03 03:20:56
|
Revision: 4029 http://sourceforge.net/p/moneymanagerex/code/4029 Author: stef145g Date: 2013-06-03 03:20:53 +0000 (Mon, 03 Jun 2013) Log Message: ----------- Converting objects & shared pointers to pointers - Not complete Modified Paths: -------------- trunk/mmex/src/db/budget_table.cpp trunk/mmex/src/db/budget_table.h trunk/mmex/src/db/currency.cpp trunk/mmex/src/db/currency.h trunk/mmex/src/db/splittransaction.cpp trunk/mmex/src/db/splittransaction.h trunk/mmex/src/db/stocks.cpp trunk/mmex/src/db/stocks.h trunk/mmex/src/db/subcategory.cpp trunk/mmex/src/db/subcategory.h trunk/mmex/src/tests/new_classes_test.cpp Modified: trunk/mmex/src/db/budget_table.cpp =================================================================== --- trunk/mmex/src/db/budget_table.cpp 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/budget_table.cpp 2013-06-03 03:20:53 UTC (rev 4029) @@ -122,6 +122,11 @@ LoadEntries(load_entries); } +TBudgetList::~TBudgetList() +{ + DestroyEntryList(); +} + void TBudgetList::LoadEntries(bool load_entries) { try @@ -149,21 +154,28 @@ void TBudgetList::LoadEntriesUsing(const wxString& sql_statement) { - entrylist_.clear(); + DestroyEntryList(); wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - std::shared_ptr<TBudgetEntry> pEntry(new TBudgetEntry(q1)); - entrylist_.push_back(pEntry); + entrylist_.push_back(new TBudgetEntry(q1)); } q1.Finalize(); } +void TBudgetList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} + int TBudgetList::AddEntry(TBudgetEntry* pBudgetEntry) { - std::shared_ptr<TBudgetEntry> pEntry(pBudgetEntry); pBudgetEntry->Add(ListDatabase()); - entrylist_.push_back(pEntry); + entrylist_.push_back(pBudgetEntry); return pBudgetEntry->id_; } @@ -175,6 +187,7 @@ { pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pEntry; } } @@ -187,7 +200,7 @@ { if (entrylist_[index]->id_ == budget_entry_id) { - pEntry = entrylist_[index].get(); + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -202,7 +215,7 @@ TBudgetEntry* pEntry = 0; if (list_index < entrylist_.size()) { - pEntry = entrylist_[list_index].get(); + pEntry = entrylist_[list_index]; } return pEntry; Modified: trunk/mmex/src/db/budget_table.h =================================================================== --- trunk/mmex/src/db/budget_table.h 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/budget_table.h 2013-06-03 03:20:53 UTC (rev 4029) @@ -89,11 +89,14 @@ { private: void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); public: - std::vector<std::shared_ptr<TBudgetEntry> >entrylist_; + std::vector<TBudgetEntry*> entrylist_; TBudgetList(wxSQLite3Database* db, bool load_entries = true); + ~TBudgetList(); // Allows specialised loads by providing the required SQL statement void LoadEntriesUsing(const wxString& sql_statement); Modified: trunk/mmex/src/db/currency.cpp =================================================================== --- trunk/mmex/src/db/currency.cpp 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/currency.cpp 2013-06-03 03:20:53 UTC (rev 4029) @@ -160,8 +160,13 @@ LoadEntries(); } -void TCurrencyList::LoadEntries() +TCurrencyList::~TCurrencyList() { + DestroyEntryList(); +} + +void TCurrencyList::LoadEntries(bool load_entries) +{ try { if (!ListDatabase()->TableExists("CURRENCYFORMATS_V1")) @@ -175,16 +180,10 @@ ListDatabase()->ExecuteUpdate(SQL_CREATE_TABLE_CURRENCYFORMATS_V1); } - const char SQL_SELECT_CURRENCYFORMAT[] = - "select * from CURRENCYFORMATS_V1 " - "order by CURRENCYNAME"; - wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(SQL_SELECT_CURRENCYFORMAT); - while (q1.NextRow()) + if (load_entries) { - std::shared_ptr<TCurrencyEntry> pEntry(new TCurrencyEntry(q1)); - entrylist_.push_back(pEntry); + LoadEntriesUsing("select * from CURRENCYFORMATS_V1 order by CURRENCYNAME"); } - q1.Finalize(); } catch (const wxSQLite3Exception& e) { @@ -192,6 +191,26 @@ } } +void TCurrencyList::LoadEntriesUsing(const wxString& sql_statement) +{ + DestroyEntryList(); + wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); + while (q1.NextRow()) + { + entrylist_.push_back(new TCurrencyEntry(q1)); + } + q1.Finalize(); +} + +void TCurrencyList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} + int TCurrencyList::AddEntry(TCurrencyEntry* pCurrencyEntry) { int currency_id = -1; @@ -201,11 +220,10 @@ } else { - std::shared_ptr<TCurrencyEntry> pEntry(pCurrencyEntry); - entrylist_.push_back(pEntry); - pEntry->Add(ListDatabase()); + entrylist_.push_back(pCurrencyEntry); + pCurrencyEntry->Add(ListDatabase()); - currency_id = pEntry->id_; + currency_id = pCurrencyEntry->id_; } return currency_id; @@ -233,6 +251,7 @@ { pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pEntry; } } @@ -252,7 +271,7 @@ { if (entrylist_[index]->id_ == currency_id) { - pEntry = entrylist_[index].get(); + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -282,7 +301,7 @@ if (found) { - pEntry = entrylist_[index].get(); + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -294,7 +313,7 @@ TCurrencyEntry* TCurrencyList::GetIndexedEntryPtr(int index) { - return entrylist_[index].get(); + return entrylist_[index]; } int TCurrencyList::GetCurrencyId(const wxString& name, bool is_symbol) Modified: trunk/mmex/src/db/currency.h =================================================================== --- trunk/mmex/src/db/currency.h 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/currency.h 2013-06-03 03:20:53 UTC (rev 4029) @@ -230,13 +230,20 @@ { private: int basecurrency_id_; - void LoadEntries(); + void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); + public: - std::vector<std::shared_ptr<TCurrencyEntry> > entrylist_; + std::vector<TCurrencyEntry*> entrylist_; TCurrencyList(wxSQLite3Database* db); + ~TCurrencyList(); + // Allows specialised loads by providing the required SQL statement + void LoadEntriesUsing(const wxString& sql_statement); + int AddEntry(TCurrencyEntry* pCurrencyEntry); void SetBaseCurrency(int currency_id); Modified: trunk/mmex/src/db/splittransaction.cpp =================================================================== --- trunk/mmex/src/db/splittransaction.cpp 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/splittransaction.cpp 2013-06-03 03:20:53 UTC (rev 4029) @@ -213,13 +213,13 @@ return pEntry->id_; } -void TSplitTransactionList::UpdateEntry(std::shared_ptr<TSplitEntry> split_entry) +void TSplitTransactionList::UpdateEntry(TSplitEntry* split_entry) { split_entry->Update(entries_List_.ListDatabase(), entries_List_.db_table_); ReEvaluateTotal(); } -void TSplitTransactionList::DeleteEntry(std::shared_ptr<TSplitEntry> split_entry) +void TSplitTransactionList::DeleteEntry(TSplitEntry* split_entry) { split_entry->Delete(entries_List_.ListDatabase(), entries_List_.db_table_); entries_.clear(); @@ -245,14 +245,14 @@ return entries_.size(); } -std::shared_ptr<TSplitEntry> TSplitTransactionList::GetEntryPtr(int id_split_trans) +TSplitEntry* TSplitTransactionList::GetEntryPtr(int id_split_trans) { - std::shared_ptr<TSplitEntry> entry_ptr; + TSplitEntry* entry_ptr = 0; for (size_t i = 0; i < entries_.size(); ++i) { if (entries_[i]->id_ == id_split_trans) { - entry_ptr = entries_[i]; + entry_ptr = entries_[i].get(); break; } } @@ -260,9 +260,9 @@ return entry_ptr; } -std::shared_ptr<TSplitEntry> TSplitTransactionList::GetIndexedEntryPtr(int index) +TSplitEntry* TSplitTransactionList::GetIndexedEntryPtr(int index) { - return entries_[index]; + return entries_[index].get(); } void TSplitTransactionList::ReEvaluateTotal() Modified: trunk/mmex/src/db/splittransaction.h =================================================================== --- trunk/mmex/src/db/splittransaction.h 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/splittransaction.h 2013-06-03 03:20:53 UTC (rev 4029) @@ -106,10 +106,10 @@ double TotalAmount(); int AddEntry(int cat_id, int subcat_id, double amount); - void UpdateEntry(std::shared_ptr<TSplitEntry> split_entry); - void DeleteEntry(std::shared_ptr<TSplitEntry> split_entry); + void UpdateEntry(TSplitEntry* split_entry); + void DeleteEntry(TSplitEntry* split_entry); int GetListSize(); - std::shared_ptr<TSplitEntry> GetEntryPtr(int id_split_trans); - std::shared_ptr<TSplitEntry> GetIndexedEntryPtr(int index); + TSplitEntry* GetEntryPtr(int id_split_trans); + TSplitEntry* GetIndexedEntryPtr(int index); }; Modified: trunk/mmex/src/db/stocks.cpp =================================================================== --- trunk/mmex/src/db/stocks.cpp 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/stocks.cpp 2013-06-03 03:20:53 UTC (rev 4029) @@ -175,6 +175,11 @@ LoadEntries(load_entries); } +TStockList::~TStockList() +{ + DestroyEntryList(); +} + void TStockList::LoadEntries(bool load_entries) { try @@ -205,12 +210,11 @@ { try { - entrylist_.clear(); + DestroyEntryList(); wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - TStockEntry entry(q1); - entrylist_.push_back(entry); + entrylist_.push_back(new TStockEntry(q1)); } q1.Finalize(); } @@ -220,12 +224,21 @@ } } -int TStockList::AddEntry(TStockEntry& stock_entry) +void TStockList::DestroyEntryList() { - stock_entry.Add(ListDatabase()); - entrylist_.push_back(stock_entry); + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} - return stock_entry.id_; +int TStockList::AddEntry(TStockEntry* pEntry) +{ + pEntry->Add(ListDatabase()); + entrylist_.push_back(pEntry); + + return pEntry->id_; } void TStockList::DeleteEntry(int stock_id) @@ -235,6 +248,7 @@ { pEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pEntry; } } @@ -245,9 +259,9 @@ while (index < entrylist_.size()) { - if (entrylist_[index].id_ == stock_id) + if (entrylist_[index]->id_ == stock_id) { - pEntry = &entrylist_[index]; + pEntry = entrylist_[index]; current_index_ = index; break; } @@ -262,7 +276,7 @@ TStockEntry* pEntry = 0; if (list_index < entrylist_.size()) { - pEntry = &entrylist_[list_index]; + pEntry = entrylist_[list_index]; } return pEntry; @@ -278,7 +292,7 @@ double total_value = 0.0; for (size_t i = 0; i < entrylist_.size(); ++i) { - total_value = total_value + entrylist_[i].value_; + total_value = total_value + entrylist_[i]->value_; } return total_value; Modified: trunk/mmex/src/db/stocks.h =================================================================== --- trunk/mmex/src/db/stocks.h 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/stocks.h 2013-06-03 03:20:53 UTC (rev 4029) @@ -72,16 +72,19 @@ { private: void LoadEntries(bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); public: - std::vector<TStockEntry> entrylist_; + std::vector<TStockEntry*> entrylist_; TStockList(wxSQLite3Database* db, bool load_entries = true); + ~TStockList(); // Allows specialised list loading provided by SQL statement void LoadEntriesUsing(const wxString& sql_statement); - int AddEntry(TStockEntry& stock_entry); + int AddEntry(TStockEntry* pEntry); void DeleteEntry(int stock_id); TStockEntry* GetEntryPtr(int stock_id); Modified: trunk/mmex/src/db/subcategory.cpp =================================================================== --- trunk/mmex/src/db/subcategory.cpp 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/subcategory.cpp 2013-06-03 03:20:53 UTC (rev 4029) @@ -97,6 +97,11 @@ LoadEntries(cat_id); } +TSubCategoryList::~TSubCategoryList() +{ + DestroyEntryList(); +} + void TSubCategoryList::LoadEntries(int cat_id, bool load_entries) { try @@ -129,28 +134,36 @@ void TSubCategoryList::LoadEntriesUsing(const wxString& sql_statement) { - entrylist_.clear(); + DestroyEntryList(); wxSQLite3ResultSet q1 = ListDatabase()->ExecuteQuery(sql_statement); while (q1.NextRow()) { - TSubCategoryEntry entry(q1); - entrylist_.push_back(entry); + entrylist_.push_back(new TSubCategoryEntry(q1)); } q1.Finalize(); } +void TSubCategoryList::DestroyEntryList() +{ + for (size_t i = 0; i < entrylist_.size(); ++i) + { + delete entrylist_[i]; + } + entrylist_.clear(); +} + int TSubCategoryList::AddEntry(int cat_id, const wxString& name) { int subcat_id; if (SubCategoryExists(cat_id, name)) { - subcat_id = entrylist_[current_index_].id_; + subcat_id = entrylist_[current_index_]->GetId(); } else { - TSubCategoryEntry entry(cat_id, name); - subcat_id = entry.Add(ListDatabase()); - entrylist_.push_back(entry); + TSubCategoryEntry* pEntry = new TSubCategoryEntry(cat_id, name); + subcat_id = pEntry->Add(ListDatabase()); + entrylist_.push_back(pEntry); } return subcat_id; @@ -169,6 +182,7 @@ TSubCategoryEntry* pSubCatEntry = GetEntryPtr(cat_id, subcat_id); pSubCatEntry->Delete(ListDatabase()); entrylist_.erase(entrylist_.begin() + current_index_); + delete pSubCatEntry; } TSubCategoryEntry* TSubCategoryList::GetEntryPtr(int cat_id, int subcat_id) @@ -177,9 +191,9 @@ size_t index = 0; while (index < entrylist_.size()) { - if ((entrylist_[index].id_ == subcat_id) && (entrylist_[index].cat_id_ == cat_id)) + if ((entrylist_[index]->GetId() == subcat_id) && (entrylist_[index]->cat_id_ == cat_id)) { - pSubCatEntry = &entrylist_[index]; + pSubCatEntry = entrylist_[index]; current_index_ = index; break; } @@ -195,9 +209,9 @@ size_t index = 0; while (index < entrylist_.size()) { - if ((entrylist_[index].cat_id_ == cat_id) && (entrylist_[index].name_ == name)) + if ((entrylist_[index]->cat_id_ == cat_id) && (entrylist_[index]->name_ == name)) { - pSubCatEntry = &entrylist_[index]; + pSubCatEntry = entrylist_[index]; current_index_ = index; break; } @@ -219,7 +233,6 @@ return subcat_id; } - wxString TSubCategoryList::GetSubCategoryName(int cat_id, int subcat_id) { wxString subcat_name; Modified: trunk/mmex/src/db/subcategory.h =================================================================== --- trunk/mmex/src/db/subcategory.h 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/db/subcategory.h 2013-06-03 03:20:53 UTC (rev 4029) @@ -51,11 +51,15 @@ { private: void LoadEntries(int cat_id = -1, bool load_entries = true); + // delete all the objects in the list and clear the list. + void DestroyEntryList(); public: - std::vector<TSubCategoryEntry> entrylist_; + std::vector<TSubCategoryEntry*> entrylist_; TSubCategoryList(wxSQLite3Database* db, int cat_id = -1); + ~TSubCategoryList(); + // Allows specialised loads by providing the required SQL statement void LoadEntriesUsing(const wxString& sql_statement); Modified: trunk/mmex/src/tests/new_classes_test.cpp =================================================================== --- trunk/mmex/src/tests/new_classes_test.cpp 2013-06-02 07:16:10 UTC (rev 4028) +++ trunk/mmex/src/tests/new_classes_test.cpp 2013-06-03 03:20:53 UTC (rev 4029) @@ -800,7 +800,7 @@ int list_size = split_list.GetListSize(); CHECK_EQUAL(4, list_size); // record_id = 3, list_index = 2 - std::shared_ptr<TSplitEntry> pEntry = split_list.GetIndexedEntryPtr(2); + TSplitEntry* pEntry = split_list.GetIndexedEntryPtr(2); pEntry->amount_ = 500; split_list.UpdateEntry(pEntry); @@ -821,7 +821,7 @@ int list_size = split_list.GetListSize(); CHECK_EQUAL(4, list_size); - std::shared_ptr<TSplitEntry> pEntry = split_list.GetIndexedEntryPtr(2); + TSplitEntry* pEntry = split_list.GetIndexedEntryPtr(2); split_list.DeleteEntry(pEntry); CHECK_EQUAL(700, split_list.TotalAmount()); list_size = split_list.GetListSize(); @@ -1189,27 +1189,28 @@ int account_id = 10; TStockList stock_list(get_pDb().get()); - TStockEntry stock_entry; - stock_entry.heldat_ = account_id; - stock_entry.name_ = "Stock Name - Should be in Account"; - stock_entry.pur_date_ = date; // date of purchase - stock_entry.pur_price_ = 1.2275; - stock_entry.num_shares_ = 2000; - stock_entry.cur_price_ = 1.575; - stock_entry.value_ = 2000; + TStockEntry* stock_entry = new TStockEntry(); + stock_entry->heldat_ = account_id; + stock_entry->name_ = "Stock Name - Should be in Account"; + stock_entry->pur_date_ = date; // date of purchase + stock_entry->pur_price_ = 1.2275; + stock_entry->num_shares_ = 2000; + stock_entry->cur_price_ = 1.575; + stock_entry->value_ = 2000; int id_1 = stock_list.AddEntry(stock_entry); - TStockEntry stock_entry_1; - stock_entry_1.heldat_ = account_id; - stock_entry_1.name_ = "Stock Name - Should be in Account"; - stock_entry_1.pur_date_ = date; // date of purchase - stock_entry_1.pur_price_ = 1.7275; - stock_entry_1.num_shares_ = 1000; - stock_entry_1.cur_price_ = 1.575; - stock_entry_1.value_ = 1000; - int id_2 = stock_list.AddEntry(stock_entry_1); + stock_entry = new TStockEntry(stock_entry); + stock_entry->heldat_ = account_id; +// stock_entry->name_ = "Stock Name - Should be in Account"; + stock_entry->pur_date_ = date; // date of purchase + stock_entry->pur_price_ = 1.7275; + stock_entry->num_shares_ = 1000; + stock_entry->cur_price_ = 1.575; + stock_entry->value_ = 1000; + int id_2 = stock_list.AddEntry(stock_entry); - CHECK(id_1 != id_2); + CHECK_EQUAL(1, id_1); + CHECK_EQUAL(2, id_2); double value = stock_list.GetStockBalance(); CHECK_EQUAL(3000, value); @@ -1254,6 +1255,7 @@ stock_list.DeleteEntry(1); // 1st entry from test 1 double value = stock_list.GetStockBalance(); CHECK_EQUAL(3000, value); + CHECK_EQUAL(1, stock_list.CurrentListSize()); displayTimeTaken("TStockList_Test_Delete", start_time); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2013-06-06 07:30:44
|
Revision: 4039 http://sourceforge.net/p/moneymanagerex/code/4039 Author: vomikan Date: 2013-06-06 07:30:40 +0000 (Thu, 06 Jun 2013) Log Message: ----------- for(const auto& ...) usage Modified Paths: -------------- trunk/mmex/src/optionsdialog.cpp trunk/mmex/src/qif_import.cpp trunk/mmex/src/univcsvdialog.cpp trunk/mmex/src/util.cpp trunk/mmex/src/util.h Modified: trunk/mmex/src/optionsdialog.cpp =================================================================== --- trunk/mmex/src/optionsdialog.cpp 2013-06-06 00:10:33 UTC (rev 4038) +++ trunk/mmex/src/optionsdialog.cpp 2013-06-06 07:30:40 UTC (rev 4039) @@ -204,8 +204,9 @@ generalPanelSizer->Add(dateFormatStaticBoxSizer, flagsExpand); dateFormatStaticBoxSizer->Add(flex_sizer); - choiceDateFormat_ = new wxComboBox(generalPanel, wxID_STATIC, "", - wxDefaultPosition, wxDefaultSize, date_format()); + choiceDateFormat_ = new wxComboBox(generalPanel, wxID_STATIC); + for (const auto& i : date_formats_map()) + choiceDateFormat_->Append(i.second, new wxStringClientData(i.first)); flex_sizer->Add(choiceDateFormat_, flags); choiceDateFormat_->SetToolTip(_("Specify the date format for display")); choiceDateFormat_->SetValue(FormatDate2DisplayDate(dateFormat_)); Modified: trunk/mmex/src/qif_import.cpp =================================================================== --- trunk/mmex/src/qif_import.cpp 2013-06-06 00:10:33 UTC (rev 4038) +++ trunk/mmex/src/qif_import.cpp 2013-06-06 07:30:40 UTC (rev 4039) @@ -173,8 +173,9 @@ // Date Format Settings wxStaticText* dateFormat = new wxStaticText(this, wxID_STATIC, _("Date Format")); - choiceDateFormat_ = new wxComboBox(this, wxID_ANY, "", - wxDefaultPosition, wxDefaultSize, date_format()); + choiceDateFormat_ = new wxComboBox(this, wxID_ANY); + for (const auto& i : date_formats_map()) + choiceDateFormat_->Append(i.second, new wxStringClientData(i.first)); choiceDateFormat_->Connect(wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(mmQIFImportDialog::OnDateMaskChange), NULL, this); @@ -978,7 +979,6 @@ { fromDateCtrl_->Enable(dateFromCheckBox_->GetValue()); toDateCtrl_->Enable(dateToCheckBox_->GetValue()); - } void mmQIFImportDialog::OnOk(wxCommandEvent& /*event*/) Modified: trunk/mmex/src/univcsvdialog.cpp =================================================================== --- trunk/mmex/src/univcsvdialog.cpp 2013-06-06 00:10:33 UTC (rev 4038) +++ trunk/mmex/src/univcsvdialog.cpp 2013-06-06 07:30:40 UTC (rev 4039) @@ -129,8 +129,8 @@ csvFieldCandicate_ = new wxListBox(this, ID_LISTBOX_CANDICATE, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE|wxLB_NEEDED_SB); itemBoxSizer3->Add(csvFieldCandicate_, 1, wxGROW|wxALL, 1); - for(std::map<int, wxString>::const_iterator it = CSVFieldName_.begin(); it != CSVFieldName_.end(); it ++) - csvFieldCandicate_->Append(it->second, new mmListBoxItem(it->first, it->second)); + for (const auto& it : CSVFieldName_) + csvFieldCandicate_->Append(it.second, new mmListBoxItem(it.first, it.second)); //Add Remove Area wxPanel* itemPanel_AddRemove = new wxPanel(this, ID_PANEL10, @@ -238,10 +238,10 @@ wxString default_date_format = core_->dbInfoSettings_->GetStringSetting("DATEFORMAT", mmex::DEFDATEFORMAT); choiceDateFormat_ = new wxChoice(itemPanel7, ID_DIALOG_OPTIONS_DATE_FORMAT); - for(size_t i = 0; i < date_format_mask().Count(); ++i) + for (const auto& i : date_formats_map()) { - choiceDateFormat_->Append(date_format()[i], new wxStringClientData(date_format_mask()[i])); - if (default_date_format == date_format_mask()[i]) choiceDateFormat_->SetSelection(i); + choiceDateFormat_->Append(i.second, new wxStringClientData(i.first)); + if (default_date_format == i.second) choiceDateFormat_->SetStringSelection(i.second); } itemBoxSizer8->Add(choiceDateFormat_, flags); @@ -335,7 +335,7 @@ void mmUnivCSVDialog::csv2tab_separated_values(wxString& line, const wxString& delimit) { - //csv line example: + //csv line example: //12.02.2010,Payee,-1105.08,Category,Subcategory,,"Fuel ""95"", 42.31 l (24.20) 212366" int i=0; //Single quotes will be used instead double quotes @@ -828,16 +828,16 @@ } toamount = adjustedExportAmount(amtSeparator,wxString()<<tovalue); CurrencyFormatter::formatCurrencyToDouble(toamount, tovalue); - toamount = CurrencyFormatter::float2String(tovalue); + toamount = CurrencyFormatter::float2String(tovalue); } else if (type == "Withdrawal") value = -value; wxString amount = adjustedExportAmount(amtSeparator, wxString()<<value); CurrencyFormatter::formatCurrencyToDouble(amount, value); - amount = CurrencyFormatter::float2String(value); + amount = CurrencyFormatter::float2String(value); - wxString amount_tmp = CurrencyFormatter::float2String(-value); + wxString amount_tmp = CurrencyFormatter::float2String(-value); buffer = ""; for (std::vector<int>::const_iterator sit = csvFieldOrder_.begin(); sit != csvFieldOrder_.end(); ++ sit) @@ -1012,7 +1012,7 @@ } toamount = adjustedExportAmount(amtSeparator,wxString()<<tovalue); CurrencyFormatter::formatCurrencyToDouble(toamount, tovalue); - toamount = CurrencyFormatter::float2String(tovalue); + toamount = CurrencyFormatter::float2String(tovalue); } else if (type == "Withdrawal") value = -value; @@ -1021,7 +1021,7 @@ CurrencyFormatter::formatCurrencyToDouble(amount, value); amount = CurrencyFormatter::float2String(value); - wxString amount_tmp = CurrencyFormatter::float2String(-value); + wxString amount_tmp = CurrencyFormatter::float2String(-value); int col = 0; wxString buf; Modified: trunk/mmex/src/util.cpp =================================================================== --- trunk/mmex/src/util.cpp 2013-06-06 00:10:33 UTC (rev 4038) +++ trunk/mmex/src/util.cpp 2013-06-06 07:30:40 UTC (rev 4039) @@ -400,26 +400,6 @@ return date_formats_map()[sDateMask]; } -const wxArrayString date_format_mask() -{ - wxArrayString mask; - for (const auto& date_mask: date_formats_map()) - { - mask.Add(date_mask.first); - }; - return mask; -} - -const wxArrayString date_format() -{ - wxArrayString format; - for (const auto& date_mask: date_formats_map()) - { - format.Add(date_mask.second); - }; - return format; - -} //*--------------------------------------------------------------------------*// // FIXME: Freeze - Thaw is ok for wx2.8.x but not for wx2.9.x @@ -623,15 +603,15 @@ sTemp.Replace(midBrackets, wxString()<<dAmount); } if (bResult) - { - if (sTemp.Contains("(")||sTemp.Contains(")")) bResult = false; - else - { - sOutput = CurrencyFormatter::float2String(dAmount); - bResult = !sOutput.IsEmpty() && bResult; - } - } - return bResult; + { + if (sTemp.Contains("(")||sTemp.Contains(")")) bResult = false; + else + { + sOutput = CurrencyFormatter::float2String(dAmount); + bResult = !sOutput.IsEmpty() && bResult; + } + } + return bResult; } wxDateTime getUserDefinedFinancialYear(bool prevDayRequired) Modified: trunk/mmex/src/util.h =================================================================== --- trunk/mmex/src/util.h 2013-06-06 00:10:33 UTC (rev 4038) +++ trunk/mmex/src/util.h 2013-06-06 07:30:40 UTC (rev 4039) @@ -93,8 +93,9 @@ wxString mmGetNiceDateSimpleString( const wxDateTime &dt ); wxString DisplayDate2FormatDate(const wxString strDate); wxString FormatDate2DisplayDate(const wxString strDate); -const wxArrayString date_format(); -const wxArrayString date_format_mask(); +//const wxArrayString date_format(); +//const wxArrayString date_format_mask(); +std::map<wxString,wxString> date_formats_map(); wxString inQuotes(wxString label, wxString& delimiter); wxString adjustedExportAmount(wxString amtSeparator, wxString strValue); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2013-06-06 10:41:25
|
Revision: 4040 http://sourceforge.net/p/moneymanagerex/code/4040 Author: vomikan Date: 2013-06-06 10:41:22 +0000 (Thu, 06 Jun 2013) Log Message: ----------- date format choosers modification Modified Paths: -------------- trunk/mmex/src/qif_import.cpp trunk/mmex/src/univcsvdialog.cpp trunk/mmex/src/univcsvdialog.h Modified: trunk/mmex/src/qif_import.cpp =================================================================== --- trunk/mmex/src/qif_import.cpp 2013-06-06 07:30:40 UTC (rev 4039) +++ trunk/mmex/src/qif_import.cpp 2013-06-06 10:41:22 UTC (rev 4040) @@ -172,10 +172,15 @@ box_sizer1->Add(flex_sizer, flagsExpand); // Date Format Settings + dateFormat_ = mmOptions::instance().dateFormat_; + wxStaticText* dateFormat = new wxStaticText(this, wxID_STATIC, _("Date Format")); choiceDateFormat_ = new wxComboBox(this, wxID_ANY); for (const auto& i : date_formats_map()) + { choiceDateFormat_->Append(i.second, new wxStringClientData(i.first)); + if (dateFormat_ == i.first) choiceDateFormat_->SetStringSelection(i.second); + } choiceDateFormat_->Connect(wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(mmQIFImportDialog::OnDateMaskChange), NULL, this); @@ -237,9 +242,6 @@ void mmQIFImportDialog::fillControls() { - dateFormat_ = core_->dbInfoSettings_->GetStringSetting("DATEFORMAT", mmex::DEFDATEFORMAT); - choiceDateFormat_->SetStringSelection(FormatDate2DisplayDate(dateFormat_)); - wxArrayString accounts_type; accounts_type.Add(ACCOUNT_TYPE_BANK); accounts_type.Add(ACCOUNT_TYPE_TERM); @@ -971,7 +973,8 @@ void mmQIFImportDialog::OnDateMaskChange(wxCommandEvent& /*event*/) { - dateFormat_ = DisplayDate2FormatDate(choiceDateFormat_->GetValue()); + wxStringClientData* data = (wxStringClientData*)(choiceDateFormat_->GetClientObject(choiceDateFormat_->GetSelection())); + if (data) dateFormat_ = data->GetData(); checkQIFFile(sFileName_); } Modified: trunk/mmex/src/univcsvdialog.cpp =================================================================== --- trunk/mmex/src/univcsvdialog.cpp 2013-06-06 07:30:40 UTC (rev 4039) +++ trunk/mmex/src/univcsvdialog.cpp 2013-06-06 10:41:22 UTC (rev 4040) @@ -236,14 +236,13 @@ itemStaticText66->SetFont(staticBoxFontSetting); //itemStaticText66->Enable(!this->is_importer_); - wxString default_date_format = core_->dbInfoSettings_->GetStringSetting("DATEFORMAT", mmex::DEFDATEFORMAT); + date_format_ = mmOptions::instance().dateFormat_; choiceDateFormat_ = new wxChoice(itemPanel7, ID_DIALOG_OPTIONS_DATE_FORMAT); for (const auto& i : date_formats_map()) { choiceDateFormat_->Append(i.second, new wxStringClientData(i.first)); - if (default_date_format == i.second) choiceDateFormat_->SetStringSelection(i.second); + if (date_format_ == i.first) choiceDateFormat_->SetStringSelection(i.second); } - itemBoxSizer8->Add(choiceDateFormat_, flags); // CSV Delimiter @@ -776,8 +775,6 @@ wxString delimit = this->delimit_; wxString acctName = m_choice_account_->GetStringSelection(); int fromAccountID = core_->accountList_.GetAccountId(acctName); - wxString date_format = DisplayDate2FormatDate(choiceDateFormat_->GetStringSelection()); - *log_field_ << date_format << "\n"; if (fromAccountID > 0) { @@ -846,7 +843,7 @@ { case UNIV_CSV_DATE: trx_date = pBankTransaction->date_; - buffer << inQuotes(trx_date.Format(date_format), delimit); + buffer << inQuotes(trx_date.Format(date_format_), delimit); break; case UNIV_CSV_PAYEE: buffer << inQuotes(payee, delimit); @@ -1239,12 +1236,11 @@ void mmUnivCSVDialog::parseToken(int index, wxString& token) { if (token.Trim().IsEmpty()) return; - wxString date_format = DisplayDate2FormatDate(choiceDateFormat_->GetStringSelection()); switch (index) { case UNIV_CSV_DATE: - mmParseDisplayStringToDate(dtdt_, token, date_format); + mmParseDisplayStringToDate(dtdt_, token, date_format_); dt_ = dtdt_.GetDateOnly().FormatISODate(); break; @@ -1361,4 +1357,7 @@ void mmUnivCSVDialog::OnDateFormatChanged(wxCommandEvent& /*event*/) { this->update_preview(); + wxStringClientData* data = (wxStringClientData*)(choiceDateFormat_->GetClientObject(choiceDateFormat_->GetSelection())); + if (data) date_format_ = data->GetData(); + *log_field_ << date_format_ << "\n"; } Modified: trunk/mmex/src/univcsvdialog.h =================================================================== --- trunk/mmex/src/univcsvdialog.h 2013-06-06 07:30:40 UTC (rev 4039) +++ trunk/mmex/src/univcsvdialog.h 2013-06-06 10:41:22 UTC (rev 4040) @@ -120,6 +120,7 @@ double val_; wxDateTime dtdt_; wxChoice* choiceDateFormat_; + wxString date_format_; int fromAccountID_; bool importSuccessful_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2013-06-06 11:07:22
|
Revision: 4041 http://sourceforge.net/p/moneymanagerex/code/4041 Author: vomikan Date: 2013-06-06 11:07:20 +0000 (Thu, 06 Jun 2013) Log Message: ----------- date format chooser reorganization Modified Paths: -------------- trunk/mmex/src/optionsdialog.cpp trunk/mmex/src/optionsdialog.h trunk/mmex/src/util.cpp trunk/mmex/src/util.h Modified: trunk/mmex/src/optionsdialog.cpp =================================================================== --- trunk/mmex/src/optionsdialog.cpp 2013-06-06 10:41:22 UTC (rev 4040) +++ trunk/mmex/src/optionsdialog.cpp 2013-06-06 11:07:20 UTC (rev 4041) @@ -204,13 +204,14 @@ generalPanelSizer->Add(dateFormatStaticBoxSizer, flagsExpand); dateFormatStaticBoxSizer->Add(flex_sizer); - choiceDateFormat_ = new wxComboBox(generalPanel, wxID_STATIC); + choiceDateFormat_ = new wxChoice(generalPanel, wxID_STATIC); for (const auto& i : date_formats_map()) + { choiceDateFormat_->Append(i.second, new wxStringClientData(i.first)); + if (dateFormat_ == i.first) choiceDateFormat_->SetStringSelection(i.second); + } flex_sizer->Add(choiceDateFormat_, flags); choiceDateFormat_->SetToolTip(_("Specify the date format for display")); - choiceDateFormat_->SetValue(FormatDate2DisplayDate(dateFormat_)); - //choiceDateFormat_->AutoComplete(date_format()); wxButton* setFormatButton = new wxButton(generalPanel, wxID_APPLY, _("Set")); flex_sizer->Add(setFormatButton, flags); @@ -758,29 +759,16 @@ void mmOptionsDialog::OnDateFormatChanged(wxCommandEvent& /*event*/) { - wxString newFormat = choiceDateFormat_->GetValue().Upper(); - if (newFormat == DisplayDate2FormatDate(newFormat)) // Not a predefined format + wxStringClientData* data = (wxStringClientData*)(choiceDateFormat_->GetClientObject(choiceDateFormat_->GetSelection())); + if (data) { - //choiceDateFormat_->SetValue(FormatDate2DisplayDate(mmex::DEFDATEFORMAT)); - return; + dateFormat_ = data->GetData(); + mmOptions::instance().dateFormat_ = dateFormat_; + sampleDateText_->SetLabel(wxDateTime::Now().Format(dateFormat_)); + core_->bTransactionList_.ChangeDateFormat(); } - - try // setting the date to the new format to ensure it works. - { - wxDateTime::Now().Format(DisplayDate2FormatDate(newFormat)); - } - catch(...) - { - choiceDateFormat_->SetValue(FormatDate2DisplayDate(mmex::DEFDATEFORMAT)); + else return; - } - - dateFormat_ = DisplayDate2FormatDate(newFormat); - mmOptions::instance().dateFormat_ = dateFormat_; - - sampleDateText_->SetLabel(wxDateTime::Now().Format(dateFormat_)); - core_->bTransactionList_.ChangeDateFormat(); - choiceDateFormat_->SetValue(newFormat); } void mmOptionsDialog::OnNavTreeColorChanged(wxCommandEvent& event) Modified: trunk/mmex/src/optionsdialog.h =================================================================== --- trunk/mmex/src/optionsdialog.h 2013-06-06 10:41:22 UTC (rev 4040) +++ trunk/mmex/src/optionsdialog.h 2013-06-06 11:07:20 UTC (rev 4041) @@ -61,7 +61,7 @@ /// Dialog specific controls wxImageList* m_imageList; - wxComboBox* choiceDateFormat_; + wxChoice* choiceDateFormat_; wxChoice* choiceVisible_; wxChoice* choiceTransVisible_; wxChoice* choiceFontSize_; Modified: trunk/mmex/src/util.cpp =================================================================== --- trunk/mmex/src/util.cpp 2013-06-06 10:41:22 UTC (rev 4040) +++ trunk/mmex/src/util.cpp 2013-06-06 11:07:20 UTC (rev 4041) @@ -385,21 +385,6 @@ return date_formats; } -wxString DisplayDate2FormatDate(const wxString sDateMask) -{ - for (const auto& date_mask: date_formats_map()) - { - if (date_mask.second == sDateMask) return date_mask.first; - }; - wxASSERT(false); - return mmex::DEFDATEFORMAT; -} - -wxString FormatDate2DisplayDate(const wxString sDateMask) -{ - return date_formats_map()[sDateMask]; -} - //*--------------------------------------------------------------------------*// // FIXME: Freeze - Thaw is ok for wx2.8.x but not for wx2.9.x Modified: trunk/mmex/src/util.h =================================================================== --- trunk/mmex/src/util.h 2013-06-06 10:41:22 UTC (rev 4040) +++ trunk/mmex/src/util.h 2013-06-06 11:07:20 UTC (rev 4041) @@ -91,10 +91,6 @@ wxString mmGetDateForDisplay( const wxDateTime &dt ); bool mmParseDisplayStringToDate(wxDateTime& date, const wxString sDate, wxString sDateMask ); wxString mmGetNiceDateSimpleString( const wxDateTime &dt ); -wxString DisplayDate2FormatDate(const wxString strDate); -wxString FormatDate2DisplayDate(const wxString strDate); -//const wxArrayString date_format(); -//const wxArrayString date_format_mask(); std::map<wxString,wxString> date_formats_map(); wxString inQuotes(wxString label, wxString& delimiter); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2013-06-06 16:02:11
|
Revision: 4042 http://sourceforge.net/p/moneymanagerex/code/4042 Author: vomikan Date: 2013-06-06 16:02:06 +0000 (Thu, 06 Jun 2013) Log Message: ----------- for (auto... and translation fix Modified Paths: -------------- trunk/mmex/src/assetdialog.cpp trunk/mmex/src/db/assets.h Modified: trunk/mmex/src/assetdialog.cpp =================================================================== --- trunk/mmex/src/assetdialog.cpp 2013-06-06 11:07:20 UTC (rev 4041) +++ trunk/mmex/src/assetdialog.cpp 2013-06-06 16:02:06 UTC (rev 4042) @@ -97,8 +97,8 @@ m_valueChangeRate->SetValue(valueChangeRate); wxString valueChangeTypeStr = pAssetEntry_->rate_type_; - m_valueChange->SetStringSelection(wxGetTranslation(valueChangeTypeStr)); - enableDisableRate(valueChangeTypeStr != ASSET_RATE_DEF[TAssetEntry::RATE_NONE]); + m_valueChange->SetStringSelection(wxGetTranslation(valueChangeTypeStr)); + enableDisableRate(valueChangeTypeStr != ASSET_RATE_DEF[TAssetEntry::RATE_NONE]); m_assetType->SetStringSelection(wxGetTranslation(pAssetEntry_->type_)); } @@ -142,10 +142,8 @@ itemFlexGridSizer6->Add(new wxStaticText( itemPanel5, wxID_STATIC, _("Asset Type")), flags); m_assetType = new wxChoice( itemPanel5, wxID_STATIC, wxDefaultPosition, wxSize(150,-1)); - size_t size = sizeof(ASSET_TYPE_DEF)/sizeof(wxString); - for(size_t i = 0; i < size; ++i) - m_assetType->Append(wxGetTranslation(ASSET_TYPE_DEF[i]), - new wxStringClientData(ASSET_TYPE_DEF[i])); + for (const auto& a : ASSET_TYPE_DEF) + m_assetType->Append(wxGetTranslation(a), new wxStringClientData(a)); m_assetType->SetToolTip(_("Select type of asset")); m_assetType->SetSelection(TAssetEntry::TYPE_PROPERTY); @@ -161,12 +159,8 @@ itemFlexGridSizer6->Add(new wxStaticText( itemPanel5, wxID_STATIC, _("Change in Value")), flags); m_valueChange = new wxChoice( itemPanel5, IDC_COMBO_TYPE, wxDefaultPosition, wxSize(150,-1)); - size = sizeof(ASSET_RATE_DEF)/sizeof(wxString); - for(size_t i = 0; i < size; ++i) - { - m_valueChange->Append(wxGetTranslation(ASSET_RATE_DEF[i]), - new wxStringClientData(ASSET_RATE_DEF[i])); - } + for(const auto& a : ASSET_RATE_DEF) + m_valueChange->Append(wxGetTranslation(a), new wxStringClientData(a)); m_valueChange->SetToolTip(_("Specify if the value of the asset changes over time")); m_valueChange->SetSelection(TAssetEntry::RATE_NONE); @@ -300,8 +294,5 @@ void mmAssetDialog::changeFocus(wxChildFocusEvent& event) { wxWindow *w = event.GetWindow(); - if ( w ) - { - assetRichText = (w->GetId() == IDC_NOTES ? true : false); - } + if ( w ) assetRichText = (w->GetId() == IDC_NOTES ? true : false); } Modified: trunk/mmex/src/db/assets.h =================================================================== --- trunk/mmex/src/db/assets.h 2013-06-06 11:07:20 UTC (rev 4041) +++ trunk/mmex/src/db/assets.h 2013-06-06 16:02:06 UTC (rev 4042) @@ -20,9 +20,9 @@ #include "entry_base.h" const wxString ASSET_RATE_DEF[] = { - "None", - "Appreciates", - "Depreciates" + wxTRANSLATE("None"), + wxTRANSLATE("Appreciates"), + wxTRANSLATE("Depreciates") }; const wxString ASSET_TYPE_DEF[] = { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2013-06-06 17:02:13
|
Revision: 4043 http://sourceforge.net/p/moneymanagerex/code/4043 Author: vomikan Date: 2013-06-06 17:02:09 +0000 (Thu, 06 Jun 2013) Log Message: ----------- fix for warning messages Modified Paths: -------------- trunk/mmex/src/maincurrencydialog.cpp trunk/mmex/src/mmex.cpp Modified: trunk/mmex/src/maincurrencydialog.cpp =================================================================== --- trunk/mmex/src/maincurrencydialog.cpp 2013-06-06 16:02:06 UTC (rev 4042) +++ trunk/mmex/src/maincurrencydialog.cpp 2013-06-06 17:02:09 UTC (rev 4043) @@ -343,20 +343,17 @@ } else { - wxMessageDialog msgDlg(this, sMsg, _("Error"), wxICON_ERROR); + wxMessageDialog msgDlg(this, sMsg, _("Error"), wxOK|wxICON_ERROR); msgDlg.ShowModal(); } } void mmMainCurrencyDialog::OnMenuSelected(wxCommandEvent& event) { - //currencyID_ = currencyListBox_->GetItemData(selectedIndex_); -// int baseCurrencyID = core_->currencyList_.getBaseCurrencySettings(); int baseCurrencyID = core_->dbInfoSettings_->GetIntSetting("BASECURRENCYID", -1); if (baseCurrencyID == currencyID_) return; -// core_->currencyList_.setBaseCurrencySettings(currencyID_); core_->dbInfoSettings_->SetIntSetting("BASECURRENCYID", currencyID_); core_->dbInfoSettings_->Save(); Modified: trunk/mmex/src/mmex.cpp =================================================================== --- trunk/mmex/src/mmex.cpp 2013-06-06 16:02:06 UTC (rev 4042) +++ trunk/mmex/src/mmex.cpp 2013-06-06 17:02:09 UTC (rev 4043) @@ -3369,7 +3369,7 @@ } else { - wxMessageDialog msgDlg(this, sMsg, _("Error"), wxICON_ERROR); + wxMessageDialog msgDlg(this, sMsg, _("Error"), wxOK|wxICON_ERROR); msgDlg.ShowModal(); } wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, MENU_TREEPOPUP_ACCOUNT_LIST); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vo...@us...> - 2013-06-07 09:03:03
|
Revision: 4046 http://sourceforge.net/p/moneymanagerex/code/4046 Author: vomikan Date: 2013-06-07 09:03:01 +0000 (Fri, 07 Jun 2013) Log Message: ----------- Currency Symbol/Name pairs provided from map Modified Paths: -------------- trunk/mmex/src/currencydialog.cpp trunk/mmex/src/currencydialog.h Modified: trunk/mmex/src/currencydialog.cpp =================================================================== --- trunk/mmex/src/currencydialog.cpp 2013-06-06 17:49:43 UTC (rev 4045) +++ trunk/mmex/src/currencydialog.cpp 2013-06-07 09:03:01 UTC (rev 4046) @@ -101,6 +101,16 @@ currencyNameCombo_->SetSelection(0); } + for(const auto& i : ce_->CURRENCIES_MAP()) + { + currency_symbols_.Add(i.first); + currency_names_.Add(i.second); + currencyNameCombo_->Append(i.second); + currencySymbolCombo_->Append(i.first); + } + currencyNameCombo_->AutoComplete(currency_names_); + currencySymbolCombo_->AutoComplete(currency_symbols_); + updateControls(); } @@ -159,17 +169,9 @@ itemBoxSizer2->Add(itemFlexGridSizer3, flags); //-------------------------- - - for(size_t i = 0; i < sizeof(CURRENCIES)/sizeof(wxString); ++i) - { - currency_symbols_.Add(CURRENCIES[i]); - currency_names_.Add(CURRENCIES[++i]); - } - itemFlexGridSizer3->Add(new wxStaticText( this, wxID_STATIC, _("Currency Name")), flags); - currencyNameCombo_ = new wxComboBox( this, ID_DIALOG_CURRENCY_CHOICE, "", - wxDefaultPosition, size, currency_names_); + currencyNameCombo_ = new wxComboBox( this, ID_DIALOG_CURRENCY_CHOICE); itemFlexGridSizer3->Add(currencyNameCombo_, flags); currencyNameCombo_->Connect(ID_DIALOG_CURRENCY_CHOICE, wxEVT_COMMAND_COMBOBOX_SELECTED, @@ -177,8 +179,7 @@ itemFlexGridSizer3->Add(new wxStaticText( this, wxID_STATIC, _("Currency Symbol")), flags); - currencySymbolCombo_ = new wxComboBox( this, wxID_ANY, "", - wxDefaultPosition, wxDefaultSize, currency_symbols_); + currencySymbolCombo_ = new wxComboBox( this, wxID_ANY); itemFlexGridSizer3->Add(currencySymbolCombo_, flagsExpand); currencyNameCombo_->AutoComplete(currency_symbols_); @@ -279,12 +280,12 @@ void mmCurrencyDialog::OnCurrencyNameSelected(wxCommandEvent& /*event*/) { - wxString currency_name = currencyNameCombo_->GetValue(); - int index = currency_names_.Index(currency_name); - wxString currency_symbol; - if (index != wxNOT_FOUND) + for (const auto& i : ce_->CURRENCIES_MAP()) { - currency_symbol = currency_symbols_[index]; - currencySymbolCombo_->SetValue(currency_symbol); + if (i.second == currencyNameCombo_->GetValue()) + { + currencySymbolCombo_->SetValue(i.first); + break; + } } } Modified: trunk/mmex/src/currencydialog.h =================================================================== --- trunk/mmex/src/currencydialog.h 2013-06-06 17:49:43 UTC (rev 4045) +++ trunk/mmex/src/currencydialog.h 2013-06-07 09:03:01 UTC (rev 4046) @@ -29,6 +29,7 @@ #include "defs.h" #include "mmcoredb.h" #include "dbwrapper.h" +#include "db/currency.h" enum { ID_DIALOG_CURRENCY = wxID_HIGHEST + 1, @@ -48,6 +49,8 @@ ID_DIALOG_CURRENCY_TEXT_SYMBOL, }; +class TCurrencyEntry; + class mmCurrencyDialog : public wxDialog { DECLARE_DYNAMIC_CLASS( mmCurrencyDialog ) @@ -87,9 +90,10 @@ void fillControls(); mmCoreDB* core_; + TCurrencyEntry* ce_; - wxArrayString currency_symbols_; - wxArrayString currency_names_; + wxSortedArrayString currency_symbols_; + wxSortedArrayString currency_names_; int currencyID_; double convRate_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gua...@us...> - 2013-06-13 12:56:14
|
Revision: 4062 http://sourceforge.net/p/moneymanagerex/code/4062 Author: guanlisheng Date: 2013-06-13 12:56:11 +0000 (Thu, 13 Jun 2013) Log Message: ----------- cleanup & format Modified Paths: -------------- trunk/mmex/src/assetspanel.cpp trunk/mmex/src/assetspanel.h trunk/mmex/src/stockspanel.cpp trunk/mmex/src/stockspanel.h trunk/mmex/src/util.cpp Modified: trunk/mmex/src/assetspanel.cpp =================================================================== --- trunk/mmex/src/assetspanel.cpp 2013-06-13 06:14:32 UTC (rev 4061) +++ trunk/mmex/src/assetspanel.cpp 2013-06-13 12:56:11 UTC (rev 4062) @@ -270,6 +270,7 @@ : mmPanelBase(core) , asset_list_(core->db_.get(), false) // don't load entries at this point. { + this->tips_ = _("MMEX allows you to track fixed assets like cars, houses, land and others. Each asset can have its value appreciate by a certain rate per year, depreciate by a certain rate per year, or not change in value. The total assets are added to your total financial worth."); Create(parent, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxPanelNameStr); } @@ -523,7 +524,7 @@ else { stm -> SetLabel(""); - st->SetLabel(Tips(TIPS_ASSETS)); + st->SetLabel(this->tips_); enableEditDeleteButtons(false); } } Modified: trunk/mmex/src/assetspanel.h =================================================================== --- trunk/mmex/src/assetspanel.h 2013-06-13 06:14:32 UTC (rev 4061) +++ trunk/mmex/src/assetspanel.h 2013-06-13 12:56:11 UTC (rev 4062) @@ -113,4 +113,7 @@ void OnViewPopupSelected(wxCommandEvent& event); void sortTable(); + +private: + wxString tips_; }; Modified: trunk/mmex/src/stockspanel.cpp =================================================================== --- trunk/mmex/src/stockspanel.cpp 2013-06-13 06:14:32 UTC (rev 4061) +++ trunk/mmex/src/stockspanel.cpp 2013-06-13 12:56:11 UTC (rev 4062) @@ -257,6 +257,7 @@ , m_imageList(0) , accountID_(accountID) { + this->tips_ = _("Using MMEX it is possible to track stocks/mutual funds investments."); Create(parent, winid, pos, size, style, name); } @@ -724,7 +725,7 @@ { if (selectedIndex == -1) { - stock_details_->SetLabel(Tips(TIPS_STOCK)); + stock_details_->SetLabel(this->tips_); stock_details_short_->SetLabel(wxString::Format(_("Last updated %s"), strLastUpdate_)); } else Modified: trunk/mmex/src/stockspanel.h =================================================================== --- trunk/mmex/src/stockspanel.h 2013-06-13 06:14:32 UTC (rev 4061) +++ trunk/mmex/src/stockspanel.h 2013-06-13 12:56:11 UTC (rev 4062) @@ -178,6 +178,9 @@ wxString strLastUpdate_; bool StocksRefreshStatus_; wxDateTime LastRefreshDT_; + +private: + wxString tips_; }; #endif Modified: trunk/mmex/src/util.cpp =================================================================== --- trunk/mmex/src/util.cpp 2013-06-13 06:14:32 UTC (rev 4061) +++ trunk/mmex/src/util.cpp 2013-06-13 12:56:11 UTC (rev 4062) @@ -332,16 +332,8 @@ wxString Tips(wxString type) { wxString tipsStr = wxEmptyString; - if (type == TIPS_ASSETS) + if (type == TIPS_BILLS) { - tipsStr = _("MMEX allows you to track fixed assets like cars, houses, land and others. Each asset can have its value appreciate by a certain rate per year, depreciate by a certain rate per year, or not change in value. The total assets are added to your total financial worth."); - } - else if (type == TIPS_STOCK) - { - tipsStr = _("Using MMEX it is possible to track stocks/mutual funds investments."); - } - else if (type == TIPS_BILLS) - { wxArrayString tips; tips.Add(_("MMEX allows regular payments to be set up as transactions. These transactions can also be regular deposits, or transfers that will occur at some future time. These transactions act a reminder that an event is about to occur, and appears on the Home Page 14 days before the transaction is due. ")); tips.Add(_("Tip: These transactions can be set up to activate – allowing the user to adjust any values on the due date.")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gua...@us...> - 2013-06-13 13:05:42
|
Revision: 4063 http://sourceforge.net/p/moneymanagerex/code/4063 Author: guanlisheng Date: 2013-06-13 13:05:39 +0000 (Thu, 13 Jun 2013) Log Message: ----------- cleanup & format Modified Paths: -------------- trunk/mmex/src/billsdepositspanel.cpp trunk/mmex/src/billsdepositspanel.h trunk/mmex/src/util.cpp Modified: trunk/mmex/src/billsdepositspanel.cpp =================================================================== --- trunk/mmex/src/billsdepositspanel.cpp 2013-06-13 12:56:11 UTC (rev 4062) +++ trunk/mmex/src/billsdepositspanel.cpp 2013-06-13 13:05:39 UTC (rev 4063) @@ -56,6 +56,9 @@ , m_imageList() , listCtrlAccount_() { + this->tips_.Add(_("MMEX allows regular payments to be set up as transactions. These transactions can also be regular deposits, or transfers that will occur at some future time. These transactions act a reminder that an event is about to occur, and appears on the Home Page 14 days before the transaction is due. ")); + this->tips_.Add(_("Tip: These transactions can be set up to activate – allowing the user to adjust any values on the due date.")); + Create(parent, winid, pos, size, style, name); } @@ -551,7 +554,7 @@ } else { - st-> SetLabel(Tips(TIPS_BILLS)); + st-> SetLabel(this->tips()); stm-> SetLabel(""); } } @@ -568,6 +571,16 @@ bS->Enable(en); } +void mmBillsDepositsPanel::sortTable() +{ + // TODO +} + +wxString mmBillsDepositsPanel::tips() +{ + return this->tips_[rand() % this->tips_.GetCount()]; +} + void billsDepositsListCtrl::refreshVisualList(int selected_index) { Modified: trunk/mmex/src/billsdepositspanel.h =================================================================== --- trunk/mmex/src/billsdepositspanel.h 2013-06-13 12:56:11 UTC (rev 4062) +++ trunk/mmex/src/billsdepositspanel.h 2013-06-13 13:05:39 UTC (rev 4063) @@ -156,7 +156,9 @@ void OnViewPopupSelected(wxCommandEvent& event); void sortTable(); + wxString tips(); +private: wxImageList* m_imageList; billsDepositsListCtrl* listCtrlAccount_; @@ -164,6 +166,8 @@ void OnFilterTransactions(wxMouseEvent& event); mmFilterTransactionsDialog* transFilterDlg_; wxStaticBitmap* bitmapTransFilter_; + + wxArrayString tips_; }; #endif Modified: trunk/mmex/src/util.cpp =================================================================== --- trunk/mmex/src/util.cpp 2013-06-13 12:56:11 UTC (rev 4062) +++ trunk/mmex/src/util.cpp 2013-06-13 13:05:39 UTC (rev 4063) @@ -331,21 +331,7 @@ wxString Tips(wxString type) { - wxString tipsStr = wxEmptyString; - if (type == TIPS_BILLS) - { - wxArrayString tips; - tips.Add(_("MMEX allows regular payments to be set up as transactions. These transactions can also be regular deposits, or transfers that will occur at some future time. These transactions act a reminder that an event is about to occur, and appears on the Home Page 14 days before the transaction is due. ")); - tips.Add(_("Tip: These transactions can be set up to activate – allowing the user to adjust any values on the due date.")); - - tipsStr = tips[rand() % tips.GetCount()]; - } - else - { - tipsStr = wxGetTranslation(TIPS[rand() % sizeof(TIPS)/sizeof(wxString)]); - } - - return tipsStr; + return wxGetTranslation(TIPS[rand() % sizeof(TIPS)/sizeof(wxString)]); } //*--------------------------------------------------------------------------*// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gua...@us...> - 2013-06-13 13:15:37
|
Revision: 4065 http://sourceforge.net/p/moneymanagerex/code/4065 Author: guanlisheng Date: 2013-06-13 13:15:32 +0000 (Thu, 13 Jun 2013) Log Message: ----------- cleanup & format Modified Paths: -------------- trunk/mmex/src/assetspanel.cpp trunk/mmex/src/assetspanel.h Modified: trunk/mmex/src/assetspanel.cpp =================================================================== --- trunk/mmex/src/assetspanel.cpp 2013-06-13 13:09:32 UTC (rev 4064) +++ trunk/mmex/src/assetspanel.cpp 2013-06-13 13:15:32 UTC (rev 4065) @@ -488,7 +488,7 @@ return item_data; } -void mmAssetsPanel::SetFilter(wxString filter) +void mmAssetsPanel::SetFilter(const wxString& filter) { filter_ = filter; } Modified: trunk/mmex/src/assetspanel.h =================================================================== --- trunk/mmex/src/assetspanel.h 2013-06-13 13:09:32 UTC (rev 4064) +++ trunk/mmex/src/assetspanel.h 2013-06-13 13:15:32 UTC (rev 4065) @@ -85,7 +85,7 @@ void updateExtraAssetData(int selIndex); int initVirtualListControl(int trx_id = -1, int col = 0, bool asc = true); wxString getItem(long item, long column); - void SetFilter(wxString filter); + void SetFilter(const wxString& filter); int GetListCtrlWidth(int id); void SetListCtrlColumn(int m_selected_col, wxListItem item); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gua...@us...> - 2013-06-13 13:20:40
|
Revision: 4066 http://sourceforge.net/p/moneymanagerex/code/4066 Author: guanlisheng Date: 2013-06-13 13:20:36 +0000 (Thu, 13 Jun 2013) Log Message: ----------- cleanup & format Modified Paths: -------------- trunk/mmex/src/mmex.cpp trunk/mmex/src/mmex.h Modified: trunk/mmex/src/mmex.cpp =================================================================== --- trunk/mmex/src/mmex.cpp 2013-06-13 13:15:32 UTC (rev 4065) +++ trunk/mmex/src/mmex.cpp 2013-06-13 13:20:36 UTC (rev 4066) @@ -769,7 +769,7 @@ } //---------------------------------------------------------------------------- -bool mmGUIFrame::setAccountInSection(wxString sectionName, wxString accountName) +bool mmGUIFrame::setAccountInSection(const wxString& sectionName, const wxString& accountName) { bool accountNotFound = true; wxTreeItemId rootItem = getTreeItemfor(navTreeCtrl_->GetRootItem(), sectionName ); Modified: trunk/mmex/src/mmex.h =================================================================== --- trunk/mmex/src/mmex.h 2013-06-13 13:15:32 UTC (rev 4065) +++ trunk/mmex/src/mmex.h 2013-06-13 13:20:36 UTC (rev 4066) @@ -252,7 +252,7 @@ wxMenuItem* menuItemOnlineUpdateCurRate_; // Menu Item for Disabling Item wxTreeItemId getTreeItemfor(wxTreeItemId itemID, const wxString& accountName) const; - bool setAccountInSection(wxString sectionName, wxString accountName); + bool setAccountInSection(const wxString& sectionName, const wxString& accountName); /* Custom Reports */ CustomReportIndex* custRepIndex_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gua...@us...> - 2013-06-13 13:23:45
|
Revision: 4067 http://sourceforge.net/p/moneymanagerex/code/4067 Author: guanlisheng Date: 2013-06-13 13:23:42 +0000 (Thu, 13 Jun 2013) Log Message: ----------- pass const reference for wxString Modified Paths: -------------- trunk/mmex/src/mmex.cpp trunk/mmex/src/mmex.h Modified: trunk/mmex/src/mmex.cpp =================================================================== --- trunk/mmex/src/mmex.cpp 2013-06-13 13:20:36 UTC (rev 4066) +++ trunk/mmex/src/mmex.cpp 2013-06-13 13:23:42 UTC (rev 4067) @@ -808,7 +808,7 @@ } //---------------------------------------------------------------------------- -void mmGUIFrame::setAccountNavTreeSection(wxString accountName) +void mmGUIFrame::setAccountNavTreeSection(const wxString& accountName) { if ( setAccountInSection(_("Bank Accounts"), accountName)) if (setAccountInSection(_("Term Accounts"), accountName)) @@ -3253,7 +3253,7 @@ } //---------------------------------------------------------------------------- -bool mmGUIFrame::IsUpdateAvailable(wxString page) +bool mmGUIFrame::IsUpdateAvailable(const wxString& page) { wxStringTokenizer tkz(page, '.', wxTOKEN_RET_EMPTY_ALL); int numTokens = (int)tkz.CountTokens(); @@ -3841,7 +3841,7 @@ } //---------------------------------------------------------------------------- -void mmGUIFrame::RunCustomSqlDialog(wxString customReportSelectedItem) +void mmGUIFrame::RunCustomSqlDialog(const wxString& customReportSelectedItem) { this->SetEvtHandlerEnabled(false); mmCustomSQLDialog dlg(custRepIndex_, customReportSelectedItem, this); Modified: trunk/mmex/src/mmex.h =================================================================== --- trunk/mmex/src/mmex.h 2013-06-13 13:20:36 UTC (rev 4066) +++ trunk/mmex/src/mmex.h 2013-06-13 13:23:42 UTC (rev 4067) @@ -210,7 +210,7 @@ return helpFileIndex_; } - void setAccountNavTreeSection(wxString accountName); + void setAccountNavTreeSection(const wxString& accountName); bool setNavTreeSection( wxString sectionName); void SetCheckingAccountPageInactive(); void SetBudgetingPageInactive(); @@ -368,7 +368,7 @@ /* Custom Report*/ bool IsCustomReportSelected(int& customSqlReportID, mmTreeItemData* iData ); void CreateCustomReport(int index); - void RunCustomSqlDialog(wxString customSqlReportSelectedItem = ""); + void RunCustomSqlDialog(const wxString& customSqlReportSelectedItem = ""); bool expandedCustomSqlReportNavTree_; bool expandedBudgetingNavTree_; @@ -379,7 +379,7 @@ void OnEditCustomSqlReport(wxCommandEvent& event); - bool IsUpdateAvailable(wxString page); + bool IsUpdateAvailable(const wxString& page); void processPendingEvents(); /* Recent Files */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |