Mercurial > hgweb.cgi > drn
changeset 912:3b7b0af742db
IN 37: Split out the presentation tags from the presentation functions.
Adds the ability to convert the SupportedAccountTypes to bypass locale language.
Updated ChangeLog information.
author | John Schneiderman <JohnMS@member.fsf.org> |
---|---|
date | Thu, 03 Nov 2022 17:27:52 +0100 |
parents | 9321a45dd0e2 |
children | bef8c811eda2 |
files | ChangeLog INSTALL src/banking/external/banking/BankAccount.cpp src/banking/external/banking/BankAccount.h src/banking/external/banking/BankAccountType.cpp src/banking/external/banking/BankAccountType.h src/foundation/CMakeLists.txt src/foundation/external/foundation/PresentationTags.hpp src/foundation/external/foundation/PresentationText.h src/surveying/external/surveying/ReconciledSurvey.cpp |
diffstat | 10 files changed, 84 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Nov 02 19:00:49 2022 +0100 +++ b/ChangeLog Thu Nov 03 17:27:52 2022 +0100 @@ -18,6 +18,9 @@ #** along with this program. If not, see <http://www.gnu.org/licenses/>. *** #******************************************************************************* XXXX-XX-XX John Schneiderman <JohnMS_AT_member_DOT_fsf_DOT_org> 0.5.0 + * Feature #32: Adds the ability to store bank reconciliation information. + * Development #28: All Qt memory is validated at runtime in the debug build. + * Development #37: Upgraded to the Qt-mocks 0.5. 2022-02-21 John Schneiderman <JohnMS_AT_member_DOT_fsf_DOT_org> 0.4.1 * Bug Fix #1: Fixed exiting requiring double confirmation when exiting with a clean budget file state. @@ -29,7 +32,6 @@ * Bug Fix #2: Added OpenSSL to the list of 3rd-party libraries to install on Windows. * Bug Fix #3: Fixed compilation failing on macOS. - * Development #28: All Qt memory is validated at runtime in the debug build. 2021-12-27 John Schneiderman <JohnMS_AT_member_DOT_fsf_DOT_org> 0.4.0 * Feature: Any budget item that produces an error when saving will have the error message displayed below that budget item.
--- a/INSTALL Wed Nov 02 19:00:49 2022 +0100 +++ b/INSTALL Thu Nov 03 17:27:52 2022 +0100 @@ -32,7 +32,7 @@ - Version: 0.5+ - Source: https://source.schneiderman.me/pecunia/ 4) Qt Mocks Library (Optional) - - Version: 0.4+ + - Version: 0.5+ - http://source.schneiderman.me/qt-mocks/ 5) API Key from Open Exchange Rates (Optional) - https://openexchangerates.org/
--- a/src/banking/external/banking/BankAccount.cpp Wed Nov 02 19:00:49 2022 +0100 +++ b/src/banking/external/banking/BankAccount.cpp Thu Nov 03 17:27:52 2022 +0100 @@ -20,6 +20,7 @@ #include "BankAccount.h" using drn::banking::BankAccount; using drn::banking::presentationText; +using drn::foundation::LocaleAware; #include <QString> using ::QString; @@ -50,9 +51,9 @@ return out << "Bank (" << ba.bank_ << "), Account (" << ba.account_ << ')'; } -QString drn::banking::presentationText(const BankAccount& ba) +QString drn::banking::presentationText(const BankAccount& ba, const LocaleAware isLocaleAware) { - return QStringLiteral("%1 %2") + return QStringLiteral("%1 %2") // TODO: "%1 %2" this will make it look nicer when it's bank->account_.type' .arg(presentationText(ba.bank_)) - .arg(presentationText(ba.account_)); + .arg(presentationText(ba.account_, isLocaleAware)); }
--- a/src/banking/external/banking/BankAccount.h Wed Nov 02 19:00:49 2022 +0100 +++ b/src/banking/external/banking/BankAccount.h Thu Nov 03 17:27:52 2022 +0100 @@ -25,6 +25,7 @@ #include "BankName.h" #include "BankAccountType.h" #include "banking_export.h" +#include <foundation/PresentationTags.hpp> class QString; @@ -44,7 +45,10 @@ DRN_BANKING_EXPORT bool operator==(const BankAccount& lhs, const BankAccount& rhs); DRN_BANKING_EXPORT bool operator!=(const BankAccount& lhs, const BankAccount& rhs); DRN_BANKING_EXPORT std::ostream& operator<<(std::ostream& out, const BankAccount& ba); -DRN_BANKING_EXPORT ::QString presentationText(const BankAccount& ba); +DRN_BANKING_EXPORT ::QString presentationText( + const BankAccount& ba, + const foundation::LocaleAware isLocaleAware = foundation::LocaleAware{true} +); }}
--- a/src/banking/external/banking/BankAccountType.cpp Wed Nov 02 19:00:49 2022 +0100 +++ b/src/banking/external/banking/BankAccountType.cpp Thu Nov 03 17:27:52 2022 +0100 @@ -22,6 +22,7 @@ using drn::banking::numberOfSupportedAccountTypes; using drn::banking::presentationText; using drn::banking::SupportedAccountTypes; +using drn::foundation::LocaleAware; #include <QObject> using ::QObject; @@ -54,6 +55,18 @@ END_OTHER_TO_ENUMERATION(bankAccountType, SupportedAccountTypes); } +QString drn::banking::toWeak(const SupportedAccountTypes& sat) +{ + BEGIN_ENUMERATION_TO_OTHER(sat) + MAP_ENUMERATION_TO_OTHER(SupportedAccountTypes::Chequeing, QStringLiteral("Chequeing")); + MAP_ENUMERATION_TO_OTHER(SupportedAccountTypes::Goal, QStringLiteral("Goal")); + MAP_ENUMERATION_TO_OTHER(SupportedAccountTypes::CreditCard, QStringLiteral("Credit Card")); + MAP_ENUMERATION_TO_OTHER(SupportedAccountTypes::Loan, QStringLiteral("Loan")); + MAP_ENUMERATION_TO_OTHER(SupportedAccountTypes::Savings, QStringLiteral("Savings")); + MAP_ENUMERATION_TO_OTHER(SupportedAccountTypes::Unknown, QStringLiteral("Unknown")); + END_ENUMERATION_TO_OTHER(sat, SupportedAccountTypes) +} + QString drn::banking::presentationText(const SupportedAccountTypes& sat) { BEGIN_ENUMERATION_TO_OTHER(sat) @@ -104,11 +117,11 @@ << ')'; } -QString drn::banking::presentationText(const BankAccountType& bat) +QString drn::banking::presentationText(const BankAccountType& bat, const LocaleAware isLocaleAware) { return QObject::tr("%1 (%2)") .arg(presentationText(bat.code_)) - .arg(presentationText(bat.type_)); + .arg(isLocaleAware ? presentationText(bat.type_) : toWeak(bat.type_)); }
--- a/src/banking/external/banking/BankAccountType.h Wed Nov 02 19:00:49 2022 +0100 +++ b/src/banking/external/banking/BankAccountType.h Thu Nov 03 17:27:52 2022 +0100 @@ -28,6 +28,7 @@ #include <accounting/AccountCode.h> #include <accounting/AccountTypes.h> #include "banking_export.h" +#include <foundation/PresentationTags.hpp> class QString; @@ -75,6 +76,7 @@ }; DRN_BANKING_EXPORT SupportedAccountTypes toSupportedAccountTypes(const ::QString& bankAccountType); +DRN_BANKING_EXPORT ::QString toWeak(const SupportedAccountTypes& sat); DRN_BANKING_EXPORT ::QString presentationText(const SupportedAccountTypes& sat); DRN_BANKING_EXPORT accounting::AccountTypes toAccountTypes(const SupportedAccountTypes& sat); DRN_BANKING_EXPORT std::ostream& operator<<(std::ostream& o, const SupportedAccountTypes& sat); @@ -82,7 +84,10 @@ DRN_BANKING_EXPORT bool operator==(const BankAccountType& lhs, const BankAccountType& rhs); DRN_BANKING_EXPORT bool operator!=(const BankAccountType& lhs, const BankAccountType& rhs); DRN_BANKING_EXPORT std::ostream& operator<<(std::ostream& out, const BankAccountType& bat); -DRN_BANKING_EXPORT ::QString presentationText(const BankAccountType& bat); +DRN_BANKING_EXPORT ::QString presentationText( + const BankAccountType& bat, + const foundation::LocaleAware isLocaleAware = foundation::LocaleAware{true} +); constexpr quint8 numberOfSupportedAccountTypes{6}; extern DRN_BANKING_EXPORT const std::array<
--- a/src/foundation/CMakeLists.txt Wed Nov 02 19:00:49 2022 +0100 +++ b/src/foundation/CMakeLists.txt Thu Nov 03 17:27:52 2022 +0100 @@ -33,6 +33,7 @@ external/${PROJECT_NAME}/Error.h external/${PROJECT_NAME}/ObserverPtr.hpp external/${PROJECT_NAME}/Optional.hpp + external/${PROJECT_NAME}/PresentationTags.hpp external/${PROJECT_NAME}/PresentationText.h external/${PROJECT_NAME}/QtMemory.hpp external/${PROJECT_NAME}/ScopeExecutor.h @@ -46,6 +47,7 @@ external/${PROJECT_NAME}/Error.cpp external/${PROJECT_NAME}/ObserverPtr.hpp external/${PROJECT_NAME}/Optional.hpp + external/${PROJECT_NAME}/PresentationTags.hpp external/${PROJECT_NAME}/PresentationText.cpp external/${PROJECT_NAME}/QtMemory.hpp external/${PROJECT_NAME}/ScopeExecutor.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/foundation/external/foundation/PresentationTags.hpp Thu Nov 03 17:27:52 2022 +0100 @@ -0,0 +1,43 @@ +/******************************************************************************* +*** This file is part of Dux Rei Nummariae. *** +*** *** +*** Copyright (C) 2017, 2018, 2019, 2020, 2021 *** +*** John Schneiderman <Licensing _AT_ Schneiderman _DOT_ me> *** +*** *** +*** This program is free software: you can redistribute it and/or modify it *** +*** under the terms of the GNU Affero General Public License as published *** +*** by the Free Software Foundation, either version 3 of the License, or *** +*** (at your option) any later version. *** +*** *** +*** This program is distributed in the hope that it will be useful, but *** +*** WITHOUT ANY WARRANTY; without even the implied warranty of *** +*** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *** +*** See the GNU Affero General Public License for more details. *** +*** *** +*** You should have received a copy of the GNU Affero General Public License*** +*** along with this program. If not, see <http://www.gnu.org/licenses/>. *** +*******************************************************************************/ +#ifndef DRN_FOUNDATION_PRESENTATIONTAGS_HPP +#define DRN_FOUNDATION_PRESENTATIONTAGS_HPP + +#include "TaggedBoolean.hpp" + + +namespace drn +{ +namespace foundation +{ + +struct LocaleAware : TaggedBoolean<LocaleAware> +{ + using TaggedBoolean<LocaleAware>::TaggedBoolean; +}; + +struct WithCurrency : TaggedBoolean<LocaleAware> +{ + using TaggedBoolean<LocaleAware>::TaggedBoolean; +}; + +}} + +#endif
--- a/src/foundation/external/foundation/PresentationText.h Wed Nov 02 19:00:49 2022 +0100 +++ b/src/foundation/external/foundation/PresentationText.h Thu Nov 03 17:27:52 2022 +0100 @@ -25,7 +25,7 @@ #include <iosfwd> #include "foundation_export.h" -#include "TaggedBoolean.hpp" +#include "PresentationTags.hpp" class QDate; @@ -46,16 +46,6 @@ namespace foundation { -struct LocaleAware : TaggedBoolean<LocaleAware> -{ - using TaggedBoolean<LocaleAware>::TaggedBoolean; -}; - -struct WithCurrency : TaggedBoolean<LocaleAware> -{ - using TaggedBoolean<LocaleAware>::TaggedBoolean; -}; - DRN_FOUNDATION_EXPORT ::QString presentationText(const pecunia::currency::Iso4217Codes& code); DRN_FOUNDATION_EXPORT ::QString presentationText( const pecunia::currency::Money& money,
--- a/src/surveying/external/surveying/ReconciledSurvey.cpp Wed Nov 02 19:00:49 2022 +0100 +++ b/src/surveying/external/surveying/ReconciledSurvey.cpp Thu Nov 03 17:27:52 2022 +0100 @@ -75,10 +75,11 @@ using drn::budgeting::BudgetSource; #include <foundation/Error.h> using drn::foundation::Error; -#include <foundation/PresentationText.h> +#include <foundation/PresentationTags.hpp> using drn::foundation::LocaleAware; +using drn::foundation::WithCurrency; +#include <foundation/PresentationText.h> using drn::foundation::presentationText; -using drn::foundation::WithCurrency; namespace @@ -91,7 +92,7 @@ const map<BudgetItemIdentifier, Money>& distribution ) { - QString value{presentationText(ba)}; + QString value{presentationText(ba, LocaleAware{false})}; value = value % presentationText(balance, LocaleAware{false}, WithCurrency{true}); if (reconciledOn.hasValue())