From: <gua...@us...> - 2013-04-29 04:41:24
|
Revision: 3797 http://sourceforge.net/p/moneymanagerex/code/3797 Author: guanlisheng Date: 2013-04-29 04:41:21 +0000 (Mon, 29 Apr 2013) Log Message: ----------- more range-based loop Modified Paths: -------------- trunk/mmex/src/budgetingpanel.cpp trunk/mmex/src/categdialog.cpp trunk/mmex/src/mmcategory.h trunk/mmex/src/mmcheckingpanel.cpp trunk/mmex/src/mmpayee.h trunk/mmex/src/qif_export.cpp trunk/mmex/src/reports/transactions.cpp Modified: trunk/mmex/src/budgetingpanel.cpp =================================================================== --- trunk/mmex/src/budgetingpanel.cpp 2013-04-28 22:19:35 UTC (rev 3796) +++ trunk/mmex/src/budgetingpanel.cpp 2013-04-29 04:41:21 UTC (rev 3797) @@ -306,11 +306,8 @@ core_->currencyList_.LoadBaseCurrencySettings(); - std::pair<mmCategoryList::const_iterator, mmCategoryList::const_iterator> range = core_->categoryList_.Range(); - for (mmCategoryList::const_iterator it = range.first; it != range.second; ++ it) + for (const auto& category: core_->categoryList_.entries_) { - const wxSharedPtr<mmCategory> category = *it; - mmBudgetEntryHolder th; budgetDetails.initBudgetEntryFields(th, budgetYearID_); th.categID_ = category->categID_; Modified: trunk/mmex/src/categdialog.cpp =================================================================== --- trunk/mmex/src/categdialog.cpp 2013-04-28 22:19:35 UTC (rev 3796) +++ trunk/mmex/src/categdialog.cpp 2013-04-29 04:41:21 UTC (rev 3797) @@ -102,11 +102,9 @@ bool bResult = core_->iniSettings_->GetBoolSetting("SHOW_HIDDEN_CATEGS", true); cbShowAll_->SetValue(bResult); - std::pair<mmCategoryList::const_iterator, mmCategoryList::const_iterator> range = core_->categoryList_.Range(); - for (mmCategoryList::const_iterator it = range.first; it != range.second; ++ it) + for (const auto& category: core_->categoryList_.entries_) { wxTreeItemId maincat; - const wxSharedPtr<mmCategory> category = *it; bool bShow = categShowStatus(category->categID_, -1); if (cbShowAll_->IsChecked() || bShow) { Modified: trunk/mmex/src/mmcategory.h =================================================================== --- trunk/mmex/src/mmcategory.h 2013-04-28 22:19:35 UTC (rev 3796) +++ trunk/mmex/src/mmcategory.h 2013-04-29 04:41:21 UTC (rev 3797) @@ -73,10 +73,6 @@ /* Public Data */ std::vector< wxSharedPtr<mmCategory> > entries_; typedef std::vector< wxSharedPtr<mmCategory> >::const_iterator const_iterator; - std::pair<const_iterator, const_iterator> Range() const - { - return std::make_pair(entries_.begin(), entries_.end()); - } private: mmCoreDB* core_; Modified: trunk/mmex/src/mmcheckingpanel.cpp =================================================================== --- trunk/mmex/src/mmcheckingpanel.cpp 2013-04-28 22:19:35 UTC (rev 3796) +++ trunk/mmex/src/mmcheckingpanel.cpp 2013-04-29 04:41:21 UTC (rev 3797) @@ -682,44 +682,6 @@ } //---------------------------------------------------------------------------- -typedef wxSharedPtr<mmBankTransaction> TransactionPtr; -struct TransactionPtr_Matcher -{ - virtual ~TransactionPtr_Matcher() {} - virtual bool Match(const TransactionPtr&) = 0; -}; -typedef wxSharedPtr<TransactionPtr_Matcher> TransactionPtr_MatcherPtr; - -template <class EqualTraits = std::equal_to<wxString> > -class MatchTransaction_Status: public TransactionPtr_Matcher -{ - wxString m_name; - EqualTraits m_equalTraits; - -public: - MatchTransaction_Status(wxString n): m_name(n) {} - - bool Match(const TransactionPtr& pTrans) - { - return m_equalTraits(pTrans->status_, m_name); - } -}; - -template <typename DateTimeProvider> -class MatchTransaction_DateTime: public TransactionPtr_Matcher -{ -public: - bool Match(const TransactionPtr& pTrans) - { - wxASSERT(pTrans); - wxDateTime startRange = DateTimeProvider::StartRange(); - wxDateTime endRange = DateTimeProvider::EndRange(); - // ::OutputDebugStringW(("- start: " + startRange.Format(L"%x %X") + ", end: " + endRange.Format(L"%x %X") + "\r\n")); - return pTrans->date_.IsBetween(startRange, endRange); - } -}; -//--------------------------------------------------------------------------- - void mmCheckingPanel::initVirtualListControl(const int trans_id) { // clear everything Modified: trunk/mmex/src/mmpayee.h =================================================================== --- trunk/mmex/src/mmpayee.h 2013-04-28 22:19:35 UTC (rev 3796) +++ trunk/mmex/src/mmpayee.h 2013-04-29 04:41:21 UTC (rev 3797) @@ -61,10 +61,6 @@ return entries_.size(); } typedef std::vector< wxSharedPtr<mmPayee> >::const_iterator const_iterator; - std::pair<const_iterator, const_iterator> Range() const - { - return std::make_pair(entries_.begin(), entries_.end()); - } /// Loads database Payees into memory void LoadPayees(); Modified: trunk/mmex/src/qif_export.cpp =================================================================== --- trunk/mmex/src/qif_export.cpp 2013-04-28 22:19:35 UTC (rev 3796) +++ trunk/mmex/src/qif_export.cpp 2013-04-29 04:41:21 UTC (rev 3797) @@ -344,10 +344,8 @@ wxString buffer_qif, buffer_csv; buffer_qif << "!Type:Cat" << "\n"; - std::pair<mmCategoryList::const_iterator, mmCategoryList::const_iterator> range = core_->categoryList_.Range(); - for (mmCategoryList::const_iterator it = range.first; it != range.second; ++ it) + for (const auto& category: core_->categoryList_.entries_) { - const wxSharedPtr<mmCategory> category = *it; const wxString categ_name = category->categName_; bool bIncome = false; core_->bTransactionList_.IsCategoryUsed(category->categID_ Modified: trunk/mmex/src/reports/transactions.cpp =================================================================== --- trunk/mmex/src/reports/transactions.cpp 2013-04-28 22:19:35 UTC (rev 3796) +++ trunk/mmex/src/reports/transactions.cpp 2013-04-29 04:41:21 UTC (rev 3797) @@ -32,8 +32,8 @@ , transDialog_(transDialog) { std::sort(trans_.begin(), trans_.end(), - [] (wxSharedPtr<mmBankTransaction> i, wxSharedPtr<mmBankTransaction> j) - { return (i.get()->date_ < j.get()->date_); }); + [&] (const wxSharedPtr<mmBankTransaction>& i, const wxSharedPtr<mmBankTransaction>& j) + { return (i->date_ < j->date_); }); } mmReportTransactions::~mmReportTransactions() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |