diff --git a/kmymoney/dialogs/transactionmatcher.cpp b/kmymoney/dialogs/transactionmatcher.cpp --- a/kmymoney/dialogs/transactionmatcher.cpp +++ b/kmymoney/dialogs/transactionmatcher.cpp @@ -25,6 +25,7 @@ #include "mymoneyaccount.h" #include "mymoneymoney.h" +#include "mymoneysecurity.h" #include "mymoneysplit.h" #include "mymoneytransaction.h" #include "mymoneyutils.h" @@ -60,7 +61,7 @@ void TransactionMatcher::match(MyMoneyTransaction tm, MyMoneySplit sm, MyMoneyTransaction ti, MyMoneySplit si, bool allowImportedTransactions) { Q_D(TransactionMatcher); - const MyMoneySecurity& sec = MyMoneyFile::instance()->security(d->m_account.currencyId()); + auto sec = MyMoneyFile::instance()->security(d->m_account.currencyId()); // Now match the transactions. // diff --git a/kmymoney/kmymoney.h b/kmymoney/kmymoney.h --- a/kmymoney/kmymoney.h +++ b/kmymoney/kmymoney.h @@ -645,7 +645,7 @@ * is returned. The @a key - @a value pair can be in the account's kvp * container or the account's online settings kvp container. */ - const MyMoneyAccount& account(const QString& key, const QString& value) const; + MyMoneyAccount account(const QString& key, const QString& value) const; /** * This method set the online parameters stored in @a kvps with the diff --git a/kmymoney/kmymoney.cpp b/kmymoney/kmymoney.cpp --- a/kmymoney/kmymoney.cpp +++ b/kmymoney/kmymoney.cpp @@ -7111,7 +7111,7 @@ d->m_myMoneyView->slotRefreshViews(); } -const MyMoneyAccount& KMyMoneyApp::account(const QString& key, const QString& value) const +MyMoneyAccount KMyMoneyApp::account(const QString& key, const QString& value) const { QList list; QList::const_iterator it_a; diff --git a/kmymoney/models/accountsmodel.cpp b/kmymoney/models/accountsmodel.cpp --- a/kmymoney/models/accountsmodel.cpp +++ b/kmymoney/models/accountsmodel.cpp @@ -979,17 +979,17 @@ auto isTopLevel = false; // it could be top-level but we don't know it yet while (itParent && !isTopLevel) { // loop in which we set total values and balances from the bottom to the top auto itCurrent = itParent; - auto accCurrent = &d->m_file->account(itCurrent->data((int)Role::Account).value().id()); - if (accCurrent->id().isEmpty()) { // this is institution + const auto accCurrent = d->m_file->account(itCurrent->data((int)Role::Account).value().id()); + if (accCurrent.id().isEmpty()) { // this is institution d->setInstitutionTotalValue(invisibleRootItem(), itCurrent->row()); break; // it's top-level node so nothing above that; } itParent = itCurrent->parent(); if (!itParent) { itParent = this->invisibleRootItem(); isTopLevel = true; } - d->setAccountBalanceAndValue(itParent, itCurrent->row(), *accCurrent, d->m_columns); + d->setAccountBalanceAndValue(itParent, itCurrent->row(), accCurrent, d->m_columns); } checkNetWorth(); checkProfit(); diff --git a/kmymoney/models/equitiesmodel.cpp b/kmymoney/models/equitiesmodel.cpp --- a/kmymoney/models/equitiesmodel.cpp +++ b/kmymoney/models/equitiesmodel.cpp @@ -259,16 +259,16 @@ */ void EquitiesModel::slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj) { - const MyMoneyAccount *acc; + MyMoneyAccount acc; QStandardItem *itAcc; switch (objType) { case eMyMoney::File::Object::Account: { auto tmpAcc = dynamic_cast(obj); if (!tmpAcc || tmpAcc->accountType() != eMyMoney::Account::Type::Stock) return; - acc = tmpAcc; - itAcc = d->itemFromId(this, acc->id(), Role::EquityID); + acc = MyMoneyAccount(*tmpAcc); + itAcc = d->itemFromId(this, acc.id(), Role::EquityID); break; } case eMyMoney::File::Object::Security: @@ -278,20 +278,20 @@ if (!itAcc) return; const auto idAcc = itAcc->data(Role::EquityID).toString(); - acc = &d->m_file->account(idAcc); + acc = d->m_file->account(idAcc); break; } default: return; } - auto itParentAcc = d->itemFromId(this, acc->parentAccountId(), Role::InvestmentID); + auto itParentAcc = d->itemFromId(this, acc.parentAccountId(), Role::InvestmentID); auto modelID = itParentAcc->data(Role::InvestmentID).toString(); // get parent account from model - if (modelID == acc->parentAccountId()) { // and if it matches with those from file then modify only - d->setAccountData(itParentAcc, itAcc->row(), *acc, d->m_columns); + if (modelID == acc.parentAccountId()) { // and if it matches with those from file then modify only + d->setAccountData(itParentAcc, itAcc->row(), acc, d->m_columns); } else { // and if not then reparent - slotObjectRemoved(eMyMoney::File::Object::Account, acc->id()); + slotObjectRemoved(eMyMoney::File::Object::Account, acc.id()); slotObjectAdded(eMyMoney::File::Object::Account, obj); } } diff --git a/kmymoney/mymoney/mymoneyfile.h b/kmymoney/mymoney/mymoneyfile.h --- a/kmymoney/mymoney/mymoneyfile.h +++ b/kmymoney/mymoney/mymoneyfile.h @@ -162,9 +162,7 @@ * This is the function to access the MyMoneyFile object. * It returns a pointer to the single instance of the object. */ - static inline MyMoneyFile* instance() { - return &file; - } + static MyMoneyFile* instance(); /** * This is the destructor for any MyMoneyFile object @@ -181,7 +179,7 @@ explicit MyMoneyFile(IMyMoneyStorage *storage); // general get functions - const MyMoneyPayee& user() const; + MyMoneyPayee user() const; // general set functions void setUser(const MyMoneyPayee& user); @@ -265,31 +263,31 @@ * This method is used to return the standard liability account * @return MyMoneyAccount liability account(group) */ - const MyMoneyAccount& liability() const; + MyMoneyAccount liability() const; /** * This method is used to return the standard asset account * @return MyMoneyAccount asset account(group) */ - const MyMoneyAccount& asset() const; + MyMoneyAccount asset() const; /** * This method is used to return the standard expense account * @return MyMoneyAccount expense account(group) */ - const MyMoneyAccount& expense() const; + MyMoneyAccount expense() const; /** * This method is used to return the standard income account * @return MyMoneyAccount income account(group) */ - const MyMoneyAccount& income() const; + MyMoneyAccount income() const; /** * This method is used to return the standard equity account * @return MyMoneyAccount equity account(group) */ - const MyMoneyAccount& equity() const; + MyMoneyAccount equity() const; /** * This method returns the account information for the opening @@ -305,7 +303,7 @@ * * @note No notifications will be sent! */ - const MyMoneyAccount openingBalanceAccount(const MyMoneySecurity& security); + MyMoneyAccount openingBalanceAccount(const MyMoneySecurity& security); /** * This method is essentially the same as the above, except it works on @@ -318,7 +316,7 @@ * * @note No notifications will be sent! */ - const MyMoneyAccount openingBalanceAccount(const MyMoneySecurity& security) const; + MyMoneyAccount openingBalanceAccount(const MyMoneySecurity& security) const; /** * Create an opening balance transaction for the account @p acc @@ -566,7 +564,7 @@ * @param id id of transaction as QString. * @return reference to the requested transaction */ - const MyMoneyTransaction transaction(const QString& id) const; + MyMoneyTransaction transaction(const QString& id) const; /** * This method is used to extract a transaction from the file global @@ -576,7 +574,7 @@ * @param idx number of transaction in this account * @return reference to MyMoneyTransaction object */ - const MyMoneyTransaction transaction(const QString& account, const int idx) const; + MyMoneyTransaction transaction(const QString& account, const int idx) const; /** * This method is used to pull a list of transactions from the file @@ -591,7 +589,7 @@ * * @return set of transactions in form of a QList */ - const QList transactionList(MyMoneyTransactionFilter& filter) const; + QList transactionList(MyMoneyTransactionFilter& filter) const; void transactionList(QList& list, MyMoneyTransactionFilter& filter) const; @@ -616,8 +614,8 @@ * @param date return balance for specific date (default = QDate()) * @return balance of the account as MyMoneyMoney object */ - const MyMoneyMoney balance(const QString& id, const QDate& date) const; - const MyMoneyMoney balance(const QString& id) const; + MyMoneyMoney balance(const QString& id, const QDate& date) const; + MyMoneyMoney balance(const QString& id) const; /** * This method is used to return the cleared balance of an account @@ -629,7 +627,7 @@ * @param date return cleared balance for specific date * @return balance of the account as MyMoneyMoney object */ - const MyMoneyMoney clearedBalance(const QString& id, const QDate& date) const; + MyMoneyMoney clearedBalance(const QString& id, const QDate& date) const; /** @@ -643,8 +641,8 @@ * @param date return balance for specific date (default = QDate()) * @return balance of the account as MyMoneyMoney object */ - const MyMoneyMoney totalBalance(const QString& id, const QDate& date) const; - const MyMoneyMoney totalBalance(const QString& id) const; + MyMoneyMoney totalBalance(const QString& id, const QDate& date) const; + MyMoneyMoney totalBalance(const QString& id) const; /** * This method returns the number of transactions currently known to file @@ -669,7 +667,7 @@ * * @return QMap with numbers of transactions per account */ - const QMap transactionCountMap() const; + QMap transactionCountMap() const; /** * This method returns the number of institutions currently known to file @@ -694,7 +692,7 @@ * @return MyMoneyInstitution object filled with data. If the institution * could not be found, an exception will be thrown */ - const MyMoneyInstitution& institution(const QString& id) const; + MyMoneyInstitution institution(const QString& id) const; /** * This method returns a list of the institutions @@ -711,25 +709,25 @@ * * @return QList containing the institution objects */ - const QList institutionList() const; + QList institutionList() const; /** * Returns the account addressed by its id. * * @param id id of the account to locate. * @return MyMoneyAccount object carrying the @p id. An exception is thrown * if the id is unknown */ - const MyMoneyAccount& account(const QString& id) const; + MyMoneyAccount account(const QString& id) const; /** * Returns the account addressed by its name. * * @param name name of the account to locate. * @return First MyMoneyAccount object found carrying the @p name. * An empty MyMoneyAccount object will be returned if the name is not found. */ - const MyMoneyAccount& accountByName(const QString& name) const; + MyMoneyAccount accountByName(const QString& name) const; /** * Returns the sub-account addressed by its name. @@ -739,7 +737,7 @@ * @return First MyMoneyAccount object found carrying the @p name. * An empty MyMoneyAccount object will be returned if the name is not found. */ - const MyMoneyAccount& subAccountByName(const MyMoneyAccount& acc, const QString& name) const; + MyMoneyAccount subAccountByName(const MyMoneyAccount& acc, const QString& name) const; /** * This method returns a list of accounts inside a MyMoneyFile object. @@ -824,7 +822,7 @@ * * @return MyMoneyPayee object of payee */ - const MyMoneyPayee& payee(const QString& id) const; + MyMoneyPayee payee(const QString& id) const; /** * This method is used to retrieve the id to a corresponding @@ -835,7 +833,7 @@ * * @return MyMoneyPayee object of payee */ - const MyMoneyPayee& payeeByName(const QString& payee) const; + MyMoneyPayee payeeByName(const QString& payee) const; /** * This method is used to modify an existing payee @@ -863,7 +861,7 @@ * * @return QList containing the payee information */ - const QList payeeList() const; + QList payeeList() const; /** * This method is used to create a new tag @@ -882,7 +880,7 @@ * * @return MyMoneyTag object of tag */ - const MyMoneyTag& tag(const QString& id) const; + MyMoneyTag tag(const QString& id) const; /** * This method is used to retrieve the id to a corresponding @@ -893,7 +891,7 @@ * * @return MyMoneyTag object of tag */ - const MyMoneyTag& tagByName(const QString& tag) const; + MyMoneyTag tagByName(const QString& tag) const; /** * This method is used to modify an existing tag @@ -921,7 +919,7 @@ * * @return QList containing the tag information */ - const QList tagList() const; + QList tagList() const; /** * This method returns a list of the cost centers @@ -1015,7 +1013,7 @@ * @param id QString containing the id of the MyMoneySchedule object * @return MyMoneySchedule object */ - const MyMoneySchedule schedule(const QString& id) const; + MyMoneySchedule schedule(const QString& id) const; /** * This method is used to extract a list of scheduled transactions @@ -1043,24 +1041,24 @@ * * @return const QList list of schedule objects. */ - const QList scheduleList(const QString& accountId, + QList scheduleList(const QString& accountId, const eMyMoney::Schedule::Type type, const eMyMoney::Schedule::Occurrence occurrence, const eMyMoney::Schedule::PaymentType paymentType, const QDate& startDate, const QDate& endDate, const bool overdue) const; - const QList scheduleList(const QString& accountId) const; - const QList scheduleList() const; + QList scheduleList(const QString& accountId) const; + QList scheduleList() const; - const QStringList consistencyCheck(); + QStringList consistencyCheck(); /** * MyMoneyFile::openingBalancesPrefix() is a special string used * to generate the name for opening balances accounts. See openingBalanceAccount() * for details. */ - static const QString openingBalancesPrefix(); + static QString openingBalancesPrefix(); /** * MyMoneyFile::AccountSeperator is used as the separator @@ -1104,12 +1102,6 @@ */ QString checkCategory(const QString& name, const MyMoneyMoney& value, const MyMoneyMoney& value2); - const QList scheduleListEx(int scheduleTypes, - int scheduleOcurrences, - int schedulePaymentTypes, - QDate startDate, - const QStringList& accounts = QStringList()) const; - /** * This method is used to add a new security object to the engine. * The ID of the object is the trading symbol, so there is no need for an additional @@ -1152,12 +1144,12 @@ * @param id QString containing the id of the MyMoneySecurity object * @return MyMoneySecurity object */ - const MyMoneySecurity& security(const QString& id) const; + MyMoneySecurity security(const QString& id) const; /** * This method is used to retrieve a list of all MyMoneySecurity objects. */ - const QList securityList() const; + QList securityList() const; /** * This method is used to add a new currency object to the engine. @@ -1200,7 +1192,7 @@ * @param id QString containing the id of the MyMoneySchedule object * @return MyMoneySchedule object */ - const MyMoneySecurity& currency(const QString& id) const; + MyMoneySecurity currency(const QString& id) const; /** * This method is used to retrieve the map of ancient currencies (together with their last prices) @@ -1210,7 +1202,7 @@ * * @return QMap of all MyMoneySecurity and MyMoneyPrice objects. */ - const QMap ancientCurrencies() const; + QMap ancientCurrencies() const; /** * This method is used to retrieve the list of available currencies @@ -1220,7 +1212,7 @@ * * @return QList of all MyMoneySecurity objects. */ - const QList availableCurrencyList() const; + QList availableCurrencyList() const; /** * This method is used to retrieve the list of stored currencies @@ -1230,7 +1222,7 @@ * * @return QList of all MyMoneySecurity objects. */ - const QList currencyList() const; + QList currencyList() const; /** * This method retrieves a MyMoneySecurity object representing @@ -1243,14 +1235,14 @@ * * @return MyMoneySecurity describing base currency */ - const MyMoneySecurity& baseCurrency() const; + MyMoneySecurity baseCurrency() const; /** * This method returns the foreign currency of the given two * currency ids. If second is the base currency id then @a first * is returned otherwise @a second is returned. */ - const QString& foreignCurrency(const QString& first, const QString& second) const; + QString foreignCurrency(const QString& first, const QString& second) const; /** * This method allows to select the base currency. It does @@ -1298,7 +1290,7 @@ * * @return MyMoneyPriceList of all MyMoneyPrice objects. */ - const MyMoneyPriceList priceList() const; + MyMoneyPriceList priceList() const; /** * This method allows to interrogate the engine, if a known account @@ -1319,7 +1311,7 @@ * * @return QList of all MyMoneyReport objects. */ - const QList reportList() const; + QList reportList() const; /** * Adds a report to the file-global institution pool. A @@ -1360,7 +1352,7 @@ * @param id QString containing the id of the MyMoneyReport object * @return MyMoneyReport object */ - const MyMoneyReport report(const QString& id) const; + MyMoneyReport report(const QString& id) const; /** * This method is used to remove an existing MyMoneyReport object @@ -1380,7 +1372,7 @@ * * @return QList of all MyMoneyBudget objects. */ - const QList budgetList() const; + QList budgetList() const; /** * Adds a budget to the file-global institution pool. A @@ -1392,7 +1384,7 @@ * @param budget The complete budget information in a * MyMoneyBudget object */ - void addBudget(MyMoneyBudget& budget); + void addBudget(MyMoneyBudget &budget); /** @@ -1404,7 +1396,7 @@ * * @return MyMoneyBudget refernce to object of budget */ - const MyMoneyBudget budgetByName(const QString& budget) const; + MyMoneyBudget budgetByName(const QString& budget) const; /** @@ -1434,7 +1426,7 @@ * @param id QString containing the id of the MyMoneyBudget object * @return MyMoneyBudget object */ - const MyMoneyBudget budget(const QString& id) const; + MyMoneyBudget budget(const QString& id) const; /** * This method is used to remove an existing MyMoneyBudget object @@ -1522,9 +1514,7 @@ */ void clearCache(); - void forceDataChanged() { - emit dataChanged(); - } + void forceDataChanged(); void preloadCache(); @@ -1564,13 +1554,13 @@ * @param jobId * @return */ - const onlineJob getOnlineJob(const QString &jobId) const; + onlineJob getOnlineJob(const QString &jobId) const; /** * @brief Returns all onlineJobs * @return all online jobs, caller gains ownership */ - const QList onlineJobList() const; + QList onlineJobList() const; /** * @brief Returns the number of onlineJobs @@ -1675,9 +1665,9 @@ * * @param security Security for which the account is searched */ - const MyMoneyAccount createOpeningBalanceAccount(const MyMoneySecurity& security); + MyMoneyAccount createOpeningBalanceAccount(const MyMoneySecurity& security); - const MyMoneyAccount openingBalanceAccount_internal(const MyMoneySecurity& security) const; + MyMoneyAccount openingBalanceAccount_internal(const MyMoneySecurity& security) const; /** * Make sure that the splits value has the precision of the corresponding account diff --git a/kmymoney/mymoney/mymoneyfile.cpp b/kmymoney/mymoney/mymoneyfile.cpp --- a/kmymoney/mymoney/mymoneyfile.cpp +++ b/kmymoney/mymoney/mymoneyfile.cpp @@ -342,6 +342,11 @@ attachStorage(storage); } +MyMoneyFile* MyMoneyFile::instance() +{ + return &file; +} + void MyMoneyFile::attachStorage(IMyMoneyStorage* const storage) { if (d->m_storage != 0) @@ -459,14 +464,14 @@ // if we notify about balance change we don't need to notify about value change // for the same account since a balance change implies a value change d->m_valueChangedSet.remove(id); - const MyMoneyAccount& acc = d->m_cache.account(id); + const auto acc = d->m_cache.account(id); emit balanceChanged(acc); } d->m_balanceChangedSet.clear(); // now notify about the remaining value changes foreach (const QString& id, d->m_valueChangedSet) { - const MyMoneyAccount& acc = d->m_cache.account(id); + const auto acc = d->m_cache.account(id); emit valueChanged(acc); } d->m_valueChangedSet.clear(); @@ -541,7 +546,7 @@ for (it_s = transaction.splits().constBegin(); it_s != transaction.splits().constEnd(); ++it_s) { // the following line will throw an exception if the // account does not exist - MyMoneyAccount acc = MyMoneyFile::account((*it_s).accountId()); + auto acc = MyMoneyFile::account((*it_s).accountId()); if (acc.id().isEmpty()) throw MYMONEYEXCEPTION("Cannot store split with no account assigned"); if (isStandardAccount((*it_s).accountId())) @@ -556,7 +561,7 @@ QList list = transaction.splits(); for (it_s = list.constBegin(); it_s != list.constEnd(); ++it_s) { if ((*it_s).action() == MyMoneySplit::ActionTransfer) { - MyMoneyAccount acc = MyMoneyFile::account((*it_s).accountId()); + auto acc = MyMoneyFile::account((*it_s).accountId()); if (acc.isAssetLiability()) { MyMoneySplit s = (*it_s); @@ -603,7 +608,7 @@ MyMoneyAccount account(_account); - MyMoneyAccount acc = MyMoneyFile::account(account.id()); + auto acc = MyMoneyFile::account(account.id()); // check that for standard accounts only specific parameters are changed if (isStandardAccount(account.id())) { @@ -692,30 +697,30 @@ throw MYMONEYEXCEPTION("Unable to reparent to different account type"); } -const MyMoneyInstitution& MyMoneyFile::institution(const QString& id) const +MyMoneyInstitution MyMoneyFile::institution(const QString& id) const { return d->m_cache.institution(id); } -const MyMoneyAccount& MyMoneyFile::account(const QString& id) const +MyMoneyAccount MyMoneyFile::account(const QString& id) const { return d->m_cache.account(id); } -const MyMoneyAccount& MyMoneyFile::subAccountByName(const MyMoneyAccount& acc, const QString& name) const +MyMoneyAccount MyMoneyFile::subAccountByName(const MyMoneyAccount& acc, const QString& name) const { static MyMoneyAccount nullAccount; QList::const_iterator it_a; for (it_a = acc.accountList().constBegin(); it_a != acc.accountList().constEnd(); ++it_a) { - const MyMoneyAccount& sacc = account(*it_a); + const auto sacc = account(*it_a); if (sacc.name() == name) return sacc; } return nullAccount; } -const MyMoneyAccount& MyMoneyFile::accountByName(const QString& name) const +MyMoneyAccount MyMoneyFile::accountByName(const QString& name) const { return d->m_cache.accountByName(name); } @@ -733,7 +738,7 @@ // scan the splits again to update notification list for (it_s = tr.splits().constBegin(); it_s != tr.splits().constEnd(); ++it_s) { - MyMoneyAccount acc = account((*it_s).accountId()); + auto acc = account((*it_s).accountId()); if (acc.isClosed()) throw MYMONEYEXCEPTION(i18n("Cannot remove transaction that references a closed account.")); d->addCacheNotification((*it_s).accountId(), tr.postDate()); @@ -777,7 +782,7 @@ MyMoneyNotifier notifier(d); - MyMoneyAccount acc = account(id); + auto acc = account(id); d->m_storage->setAccountName(id, name); d->addCacheNotification(id); @@ -813,7 +818,7 @@ // collect all sub-ordinate accounts for notification foreach (const QString& id, acc.accountList()) { d->addCacheNotification(id); - const MyMoneyAccount& acc = MyMoneyFile::account(id); + const auto acc = MyMoneyFile::account(id); d->m_changeSet += MyMoneyNotification(File::Mode::Modify, acc); } // don't forget the parent and a possible institution @@ -900,7 +905,7 @@ bool blocked = signalsBlocked(); blockSignals(true); for (it_a = inst.accountList().constBegin(); it_a != inst.accountList().constEnd(); ++it_a) { - MyMoneyAccount acc = account(*it_a); + auto acc = account(*it_a); acc.setInstitutionId(QString()); modifyAccount(acc); d->m_changeSet += MyMoneyNotification(File::Mode::Modify, acc); @@ -1022,7 +1027,7 @@ // make sure, that the parent account exists // if not, an exception is thrown. If it exists, // get a copy of the current data - MyMoneyAccount acc = MyMoneyFile::account(parent.id()); + auto acc = MyMoneyFile::account(parent.id()); #if 0 // TODO: remove the following code as we now can have multiple accounts @@ -1180,7 +1185,7 @@ return result; } -const MyMoneyAccount MyMoneyFile::openingBalanceAccount(const MyMoneySecurity& security) +MyMoneyAccount MyMoneyFile::openingBalanceAccount(const MyMoneySecurity& security) { if (!security.isCurrency()) throw MYMONEYEXCEPTION("Opening balance for non currencies not supported"); @@ -1202,12 +1207,12 @@ } } -const MyMoneyAccount MyMoneyFile::openingBalanceAccount(const MyMoneySecurity& security) const +MyMoneyAccount MyMoneyFile::openingBalanceAccount(const MyMoneySecurity& security) const { return openingBalanceAccount_internal(security); } -const MyMoneyAccount MyMoneyFile::openingBalanceAccount_internal(const MyMoneySecurity& security) const +MyMoneyAccount MyMoneyFile::openingBalanceAccount_internal(const MyMoneySecurity& security) const { if (!security.isCurrency()) throw MYMONEYEXCEPTION("Opening balance for non currencies not supported"); @@ -1243,7 +1248,7 @@ return acc; } -const MyMoneyAccount MyMoneyFile::createOpeningBalanceAccount(const MyMoneySecurity& security) +MyMoneyAccount MyMoneyFile::createOpeningBalanceAccount(const MyMoneySecurity& security) { d->checkTransaction(Q_FUNC_INFO); @@ -1307,7 +1312,7 @@ for (it_s = transaction.splits().constBegin(); it_s != transaction.splits().constEnd(); ++it_s) { // the following line will throw an exception if the // account does not exist or is one of the standard accounts - MyMoneyAccount acc = MyMoneyFile::account((*it_s).accountId()); + auto acc = MyMoneyFile::account((*it_s).accountId()); if (acc.id().isEmpty()) throw MYMONEYEXCEPTION("Cannot add split with no account assigned"); if (acc.isLoan()) @@ -1322,7 +1327,7 @@ QList list = transaction.splits(); for (it_s = list.constBegin(); it_s != list.constEnd(); ++it_s) { if ((*it_s).action() == MyMoneySplit::ActionTransfer) { - MyMoneyAccount acc = MyMoneyFile::account((*it_s).accountId()); + auto acc = MyMoneyFile::account((*it_s).accountId()); if (acc.isAssetLiability()) { MyMoneySplit s = (*it_s); @@ -1354,14 +1359,14 @@ d->m_changeSet += MyMoneyNotification(File::Mode::Add, transaction); } -const MyMoneyTransaction MyMoneyFile::transaction(const QString& id) const +MyMoneyTransaction MyMoneyFile::transaction(const QString& id) const { d->checkStorage(); return d->m_storage->transaction(id); } -const MyMoneyTransaction MyMoneyFile::transaction(const QString& account, const int idx) const +MyMoneyTransaction MyMoneyFile::transaction(const QString& account, const int idx) const { d->checkStorage(); @@ -1384,12 +1389,12 @@ d->m_changeSet += MyMoneyNotification(File::Mode::Add, payee); } -const MyMoneyPayee& MyMoneyFile::payee(const QString& id) const +MyMoneyPayee MyMoneyFile::payee(const QString& id) const { return d->m_cache.payee(id); } -const MyMoneyPayee& MyMoneyFile::payeeByName(const QString& name) const +MyMoneyPayee MyMoneyFile::payeeByName(const QString& name) const { d->checkStorage(); @@ -1442,12 +1447,12 @@ d->m_changeSet += MyMoneyNotification(File::Mode::Add, tag); } -const MyMoneyTag& MyMoneyFile::tag(const QString& id) const +MyMoneyTag MyMoneyFile::tag(const QString& id) const { return d->m_cache.tag(id); } -const MyMoneyTag& MyMoneyFile::tagByName(const QString& name) const +MyMoneyTag MyMoneyFile::tagByName(const QString& name) const { d->checkStorage(); @@ -1529,15 +1534,15 @@ d->m_cache.institution(list); } -const QList MyMoneyFile::institutionList() const +QList MyMoneyFile::institutionList() const { QList list; institutionList(list); return list; } // general get functions -const MyMoneyPayee& MyMoneyFile::user() const +MyMoneyPayee MyMoneyFile::user() const { d->checkStorage(); return d->m_storage->user(); @@ -1584,35 +1589,35 @@ } } -const MyMoneyAccount& MyMoneyFile::liability() const +MyMoneyAccount MyMoneyFile::liability() const { d->checkStorage(); return d->m_cache.account(STD_ACC_LIABILITY); } -const MyMoneyAccount& MyMoneyFile::asset() const +MyMoneyAccount MyMoneyFile::asset() const { d->checkStorage(); return d->m_cache.account(STD_ACC_ASSET); } -const MyMoneyAccount& MyMoneyFile::expense() const +MyMoneyAccount MyMoneyFile::expense() const { d->checkStorage(); return d->m_cache.account(STD_ACC_EXPENSE); } -const MyMoneyAccount& MyMoneyFile::income() const +MyMoneyAccount MyMoneyFile::income() const { d->checkStorage(); return d->m_cache.account(STD_ACC_INCOME); } -const MyMoneyAccount& MyMoneyFile::equity() const +MyMoneyAccount MyMoneyFile::equity() const { d->checkStorage(); @@ -1625,12 +1630,13 @@ return d->m_storage->transactionCount(account); } + unsigned int MyMoneyFile::transactionCount() const { return transactionCount(QString()); } -const QMap MyMoneyFile::transactionCountMap() const +QMap MyMoneyFile::transactionCountMap() const { d->checkStorage(); @@ -1644,7 +1650,7 @@ return d->m_storage->institutionCount(); } -const MyMoneyMoney MyMoneyFile::balance(const QString& id, const QDate& date) const +MyMoneyMoney MyMoneyFile::balance(const QString& id, const QDate& date) const { if (date.isValid()) { MyMoneyBalanceCacheItem bal = d->m_balanceCache.balance(id, date); @@ -1662,12 +1668,13 @@ return returnValue; } -const MyMoneyMoney MyMoneyFile::balance(const QString& id) const + +MyMoneyMoney MyMoneyFile::balance(const QString& id) const { return balance(id, QDate()); } -const MyMoneyMoney MyMoneyFile::clearedBalance(const QString &id, const QDate& date) const +MyMoneyMoney MyMoneyFile::clearedBalance(const QString &id, const QDate& date) const { MyMoneyMoney cleared; QList list; @@ -1698,14 +1705,14 @@ return cleared * factor; } -const MyMoneyMoney MyMoneyFile::totalBalance(const QString& id, const QDate& date) const +MyMoneyMoney MyMoneyFile::totalBalance(const QString& id, const QDate& date) const { d->checkStorage(); return d->m_storage->totalBalance(id, date); } -const MyMoneyMoney MyMoneyFile::totalBalance(const QString& id) const +MyMoneyMoney MyMoneyFile::totalBalance(const QString& id) const { return totalBalance(id, QDate()); } @@ -1735,21 +1742,21 @@ d->m_storage->transactionList(list, filter); } -const QList MyMoneyFile::transactionList(MyMoneyTransactionFilter& filter) const +QList MyMoneyFile::transactionList(MyMoneyTransactionFilter& filter) const { QList list; transactionList(list, filter); return list; } -const QList MyMoneyFile::payeeList() const +QList MyMoneyFile::payeeList() const { QList list; d->m_cache.payee(list); return list; } -const QList MyMoneyFile::tagList() const +QList MyMoneyFile::tagList() const { QList list; d->m_cache.tag(list); @@ -1873,7 +1880,7 @@ for (it_s = transaction.splits().constBegin(); it_s != transaction.splits().constEnd(); ++it_s) { // the following line will throw an exception if the // account does not exist or is one of the standard accounts - MyMoneyAccount acc = MyMoneyFile::account((*it_s).accountId()); + auto acc = MyMoneyFile::account((*it_s).accountId()); if (acc.id().isEmpty()) throw MYMONEYEXCEPTION("Cannot add split with no account assigned"); if (isStandardAccount((*it_s).accountId())) @@ -1901,7 +1908,7 @@ for (it_s = transaction.splits().constBegin(); it_s != transaction.splits().constEnd(); ++it_s) { // the following line will throw an exception if the // account does not exist or is one of the standard accounts - MyMoneyAccount acc = MyMoneyFile::account((*it_s).accountId()); + auto acc = MyMoneyFile::account((*it_s).accountId()); if (acc.id().isEmpty()) throw MYMONEYEXCEPTION("Cannot store split with no account assigned"); if (isStandardAccount((*it_s).accountId())) @@ -1930,12 +1937,12 @@ d->m_changeSet += MyMoneyNotification(File::Mode::Remove, sched); } -const MyMoneySchedule MyMoneyFile::schedule(const QString& id) const +MyMoneySchedule MyMoneyFile::schedule(const QString& id) const { return d->m_cache.schedule(id); } -const QList MyMoneyFile::scheduleList( +QList MyMoneyFile::scheduleList( const QString& accountId, const Schedule::Type type, const Schedule::Occurrence occurrence, @@ -1949,20 +1956,20 @@ return d->m_storage->scheduleList(accountId, type, occurrence, paymentType, startDate, endDate, overdue); } -const QList MyMoneyFile::scheduleList( +QList MyMoneyFile::scheduleList( const QString& accountId) const { return scheduleList(accountId, Schedule::Type::Any, Schedule::Occurrence::Any, Schedule::PaymentType::Any, QDate(), QDate(), false); } -const QList MyMoneyFile::scheduleList() const +QList MyMoneyFile::scheduleList() const { return scheduleList(QString(), Schedule::Type::Any, Schedule::Occurrence::Any, Schedule::PaymentType::Any, QDate(), QDate(), false); } -const QStringList MyMoneyFile::consistencyCheck() +QStringList MyMoneyFile::consistencyCheck() { QList list; QList::Iterator it_a; @@ -2287,7 +2294,7 @@ } try { - const MyMoneyAccount& acc = this->account(s.accountId()); + const auto acc = this->account(s.accountId()); // compute the newest opening date of all accounts involved in the transaction // in case the newest opening date is newer than the transaction post date, do one // of the following: @@ -2386,7 +2393,7 @@ continue; } QString id = (*it_t).accountId(); - MyMoneyAccount acc = this->account(id); + auto acc = this->account(id); MyMoneySecurity sec = this->security(acc.currencyId()); MyMoneyPrice price(acc.currencyId(), sec.tradingCurrency(), @@ -2443,7 +2450,7 @@ // make sure, that shares and value have the same number if they // represent the same currency. try { - const MyMoneyAccount& acc = this->account(s.accountId()); + const auto acc = this->account(s.accountId()); if (t.commodity() == acc.currencyId() && s.shares().reduce() != s.value().reduce()) { // use the value as master if the transaction is balanced @@ -2733,17 +2740,6 @@ return accountId; } -const QList MyMoneyFile::scheduleListEx(int scheduleTypes, - int scheduleOcurrences, - int schedulePaymentTypes, - QDate startDate, - const QStringList& accounts) const -{ - d->checkStorage(); - - return d->m_storage->scheduleListEx(scheduleTypes, scheduleOcurrences, schedulePaymentTypes, startDate, accounts); -} - void MyMoneyFile::addSecurity(MyMoneySecurity& security) { d->checkTransaction(Q_FUNC_INFO); @@ -2790,15 +2786,15 @@ d->m_changeSet += MyMoneyNotification(File::Mode::Remove, security); } -const MyMoneySecurity& MyMoneyFile::security(const QString& id) const +MyMoneySecurity MyMoneyFile::security(const QString& id) const { if (id.isEmpty()) return baseCurrency(); return d->m_cache.security(id); } -const QList MyMoneyFile::securityList() const +QList MyMoneyFile::securityList() const { d->checkStorage(); @@ -2859,7 +2855,7 @@ d->m_changeSet += MyMoneyNotification(File::Mode::Remove, currency); } -const MyMoneySecurity& MyMoneyFile::currency(const QString& id) const +MyMoneySecurity MyMoneyFile::currency(const QString& id) const { if (id.isEmpty()) return baseCurrency(); @@ -2873,7 +2869,7 @@ return curr; } -const QMap MyMoneyFile::ancientCurrencies() const +QMap MyMoneyFile::ancientCurrencies() const { QMap ancientCurrencies; @@ -2923,7 +2919,7 @@ return ancientCurrencies; } -const QList MyMoneyFile::availableCurrencyList() const +QList MyMoneyFile::availableCurrencyList() const { QList currencyList; currencyList.append(MyMoneySecurity("AFA", i18n("Afghanistan Afghani"))); @@ -3095,21 +3091,21 @@ return currencyList; } -const QList MyMoneyFile::currencyList() const +QList MyMoneyFile::currencyList() const { d->checkStorage(); return d->m_storage->currencyList(); } -const QString& MyMoneyFile::foreignCurrency(const QString& first, const QString& second) const +QString MyMoneyFile::foreignCurrency(const QString& first, const QString& second) const { if (baseCurrency().id() == second) return first; return second; } -const MyMoneySecurity& MyMoneyFile::baseCurrency() const +MyMoneySecurity MyMoneyFile::baseCurrency() const { if (d->m_baseCurrency.id().isEmpty()) { QString id = QString(value("kmm-baseCurrency")); @@ -3223,16 +3219,16 @@ return price(fromId, QString(), QDate::currentDate(), false); } -const MyMoneyPriceList MyMoneyFile::priceList() const +MyMoneyPriceList MyMoneyFile::priceList() const { d->checkStorage(); return d->m_storage->priceList(); } bool MyMoneyFile::hasAccount(const QString& id, const QString& name) const { - MyMoneyAccount acc = d->m_cache.account(id); + auto acc = d->m_cache.account(id); QStringList list = acc.accountList(); QStringList::ConstIterator it; bool rc = false; @@ -3244,7 +3240,7 @@ return rc; } -const QList MyMoneyFile::reportList() const +QList MyMoneyFile::reportList() const { d->checkStorage(); @@ -3280,7 +3276,7 @@ return d->m_storage->countReports(); } -const MyMoneyReport MyMoneyFile::report(const QString& id) const +MyMoneyReport MyMoneyFile::report(const QString& id) const { d->checkStorage(); @@ -3298,14 +3294,14 @@ } -const QList MyMoneyFile::budgetList() const +QList MyMoneyFile::budgetList() const { d->checkStorage(); return d->m_storage->budgetList(); } -void MyMoneyFile::addBudget(MyMoneyBudget& budget) +void MyMoneyFile::addBudget(MyMoneyBudget &budget) { d->checkTransaction(Q_FUNC_INFO); @@ -3315,7 +3311,7 @@ d->m_storage->addBudget(budget); } -const MyMoneyBudget MyMoneyFile::budgetByName(const QString& name) const +MyMoneyBudget MyMoneyFile::budgetByName(const QString& name) const { d->checkStorage(); @@ -3341,7 +3337,7 @@ return d->m_storage->countBudgets(); } -const MyMoneyBudget MyMoneyFile::budget(const QString& id) const +MyMoneyBudget MyMoneyFile::budget(const QString& id) const { d->checkStorage(); @@ -3379,13 +3375,13 @@ d->addCacheNotification(job.id()); } -const onlineJob MyMoneyFile::getOnlineJob(const QString &jobId) const +onlineJob MyMoneyFile::getOnlineJob(const QString &jobId) const { d->checkStorage(); return d->m_storage->getOnlineJob(jobId); } -const QList MyMoneyFile::onlineJobList() const +QList MyMoneyFile::onlineJobList() const { d->checkStorage(); return d->m_storage->onlineJobList(); @@ -3567,6 +3563,11 @@ d->m_balanceCache.clear(); } +void MyMoneyFile::forceDataChanged() +{ + emit dataChanged(); +} + void MyMoneyFile::preloadCache() { d->checkStorage(); @@ -3590,7 +3591,7 @@ if (t.splitCount() == 2) { QList::const_iterator it_s; for (it_s = t.splits().begin(); it_s != t.splits().end(); ++it_s) { - MyMoneyAccount acc = account((*it_s).accountId()); + auto acc = account((*it_s).accountId()); if (acc.isIncomeExpense()) break; } @@ -3640,15 +3641,15 @@ return id; } -const QString MyMoneyFile::openingBalancesPrefix() +QString MyMoneyFile::openingBalancesPrefix() { return i18n("Opening Balances"); } bool MyMoneyFile::hasMatchingOnlineBalance(const MyMoneyAccount& _acc) const { // get current values - MyMoneyAccount acc = account(_acc.id()); + auto acc = account(_acc.id()); // if there's no last transaction import data we are done if (acc.value("lastImportedTransactionDate").isEmpty() @@ -3680,7 +3681,7 @@ int transactionFraction = transactionSecurity.smallestAccountFraction(); for(its = t.splits().begin(); its != t.splits().end(); ++its) { - MyMoneyAccount acc = account((*its).accountId()); + auto acc = account((*its).accountId()); int fraction = acc.fraction(); if(fraction == -1) { MyMoneySecurity sec = security(acc.currencyId()); diff --git a/kmymoney/mymoney/mymoneytransactionfilter.cpp b/kmymoney/mymoney/mymoneytransactionfilter.cpp --- a/kmymoney/mymoney/mymoneytransactionfilter.cpp +++ b/kmymoney/mymoney/mymoneytransactionfilter.cpp @@ -37,6 +37,7 @@ #include "mymoneymoney.h" #include "mymoneyfile.h" #include "mymoneyaccount.h" +#include "mymoneysecurity.h" #include "mymoneypayee.h" #include "mymoneytag.h" #include "mymoneytransaction.h" @@ -301,8 +302,8 @@ // memo, value, number, payee, tag, account, date if (d->m_filterSet.singleFilter.textFilter) { MyMoneyFile* file = MyMoneyFile::instance(); - const MyMoneyAccount& acc = file->account(sp->accountId()); - const MyMoneySecurity& sec = file->security(acc.currencyId()); + const auto acc = file->account(sp->accountId()); + const auto sec = file->security(acc.currencyId()); if (sp->memo().contains(d->m_text) || sp->shares().formatMoney(acc.fraction(sec)).contains(d->m_text) || sp->value().formatMoney(acc.fraction(sec)).contains(d->m_text) @@ -314,16 +315,16 @@ return !d->m_invertText; if (!sp->payeeId().isEmpty()) { - const MyMoneyPayee& payee = file->payee(sp->payeeId()); + const auto payee = file->payee(sp->payeeId()); if (payee.name().contains(d->m_text)) return !d->m_invertText; } if (!sp->tagIdList().isEmpty()) { QList::ConstIterator it_s; QList t = sp->tagIdList(); for (it_s = t.constBegin(); it_s != t.constEnd(); ++it_s) { - const MyMoneyTag& tag = file->tag((*it_s)); + const auto tag = file->tag((*it_s)); if (tag.name().contains(d->m_text)) return !d->m_invertText; } diff --git a/kmymoney/plugins/icalendarexport/schedulestoicalendar.cpp b/kmymoney/plugins/icalendarexport/schedulestoicalendar.cpp --- a/kmymoney/plugins/icalendarexport/schedulestoicalendar.cpp +++ b/kmymoney/plugins/icalendarexport/schedulestoicalendar.cpp @@ -35,6 +35,7 @@ // KMyMoney includes #include "mymoneymoney.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" #include "mymoneyutils.h" #include "mymoneyschedule.h" #include "mymoneyaccount.h" diff --git a/kmymoney/plugins/interfaces/kmmstatementinterface.h b/kmymoney/plugins/interfaces/kmmstatementinterface.h --- a/kmymoney/plugins/interfaces/kmmstatementinterface.h +++ b/kmymoney/plugins/interfaces/kmmstatementinterface.h @@ -58,7 +58,7 @@ * If the account is not found in the list of accounts, MyMoneyAccount() * is returned. */ - const MyMoneyAccount& account(const QString& key, const QString& value) const; + MyMoneyAccount account(const QString& key, const QString& value) const; /** * This method stores the online parameters in @a kvps used by the plugin diff --git a/kmymoney/plugins/interfaces/kmmstatementinterface.cpp b/kmymoney/plugins/interfaces/kmmstatementinterface.cpp --- a/kmymoney/plugins/interfaces/kmmstatementinterface.cpp +++ b/kmymoney/plugins/interfaces/kmmstatementinterface.cpp @@ -44,7 +44,7 @@ return m_app->slotStatementImport(s, silent); } -const MyMoneyAccount& KMyMoneyPlugin::KMMStatementInterface::account(const QString& key, const QString& value) const +MyMoneyAccount KMyMoneyPlugin::KMMStatementInterface::account(const QString& key, const QString& value) const { return m_app->account(key, value); } diff --git a/kmymoney/plugins/kbanking/mymoneybanking.h b/kmymoney/plugins/kbanking/mymoneybanking.h --- a/kmymoney/plugins/kbanking/mymoneybanking.h +++ b/kmymoney/plugins/kbanking/mymoneybanking.h @@ -73,7 +73,7 @@ bool importStatement(const MyMoneyStatement& s); - const MyMoneyAccount& account(const QString& key, const QString& value) const; + MyMoneyAccount account(const QString& key, const QString& value) const; void setAccountOnlineParameters(const MyMoneyAccount& acc, const MyMoneyKeyValueContainer& kvps) const; diff --git a/kmymoney/plugins/kbanking/mymoneybanking.cpp b/kmymoney/plugins/kbanking/mymoneybanking.cpp --- a/kmymoney/plugins/kbanking/mymoneybanking.cpp +++ b/kmymoney/plugins/kbanking/mymoneybanking.cpp @@ -818,7 +818,7 @@ } -const MyMoneyAccount& KBankingPlugin::account(const QString& key, const QString& value) const +MyMoneyAccount KBankingPlugin::account(const QString& key, const QString& value) const { return statementInterface()->account(key, value); } diff --git a/kmymoney/plugins/ofximport/ofximporterplugin.h b/kmymoney/plugins/ofximport/ofximporterplugin.h --- a/kmymoney/plugins/ofximport/ofximporterplugin.h +++ b/kmymoney/plugins/ofximport/ofximporterplugin.h @@ -109,7 +109,7 @@ */ MyMoneyKeyValueContainer onlineBankingSettings(const MyMoneyKeyValueContainer& current); - const MyMoneyAccount& account(const QString& key, const QString& value) const; + MyMoneyAccount account(const QString& key, const QString& value) const; void protocols(QStringList& protocolList) const; diff --git a/kmymoney/plugins/ofximport/ofximporterplugin.cpp b/kmymoney/plugins/ofximport/ofximporterplugin.cpp --- a/kmymoney/plugins/ofximport/ofximporterplugin.cpp +++ b/kmymoney/plugins/ofximport/ofximporterplugin.cpp @@ -628,7 +628,7 @@ return statementInterface()->import(s); } -const MyMoneyAccount& OfxImporterPlugin::account(const QString& key, const QString& value) const +MyMoneyAccount OfxImporterPlugin::account(const QString& key, const QString& value) const { return statementInterface()->account(key, value); } diff --git a/kmymoney/plugins/qif/import/mymoneyqifreader.h b/kmymoney/plugins/qif/import/mymoneyqifreader.h --- a/kmymoney/plugins/qif/import/mymoneyqifreader.h +++ b/kmymoney/plugins/qif/import/mymoneyqifreader.h @@ -271,7 +271,7 @@ * @retval found MyMoneyAccount account instance * @retval MyMoneyAccount() if not found */ - const MyMoneyAccount& findAccount(const MyMoneyAccount& acc, const MyMoneyAccount& parent) const; + MyMoneyAccount findAccount(const MyMoneyAccount& acc, const MyMoneyAccount& parent) const; /** * This method returns the account id for a given account @a name. In diff --git a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp --- a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp +++ b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp @@ -848,7 +848,7 @@ } } -const MyMoneyAccount& MyMoneyQifReader::findAccount(const MyMoneyAccount& acc, const MyMoneyAccount& parent) const +MyMoneyAccount MyMoneyQifReader::findAccount(const MyMoneyAccount& acc, const MyMoneyAccount& parent) const { static MyMoneyAccount nullAccount; @@ -880,7 +880,7 @@ while ((pos = name.indexOf(MyMoneyFile::AccountSeperator)) != -1) { QString part = name.left(pos); QString remainder = name.mid(pos + 1); - const MyMoneyAccount& existingAccount = file->subAccountByName(parentAccount, part); + const auto existingAccount = file->subAccountByName(parentAccount, part); // if account has not been found, continue with next top level parent if (existingAccount.id().isEmpty()) { notFound = true; @@ -891,7 +891,7 @@ } if (notFound) continue; - const MyMoneyAccount& existingAccount = file->subAccountByName(parentAccount, name); + const auto existingAccount = file->subAccountByName(parentAccount, name); if (!existingAccount.id().isEmpty()) { if (acc.accountType() != eMyMoney::Account::Type::Unknown) { if (acc.accountType() != existingAccount.accountType()) diff --git a/kmymoney/plugins/statementinterface.h b/kmymoney/plugins/statementinterface.h --- a/kmymoney/plugins/statementinterface.h +++ b/kmymoney/plugins/statementinterface.h @@ -60,7 +60,7 @@ * If the account is not found in the list of accounts, MyMoneyAccount() * is returned. */ - virtual const MyMoneyAccount& account(const QString& key, const QString& value) const = 0; + virtual MyMoneyAccount account(const QString& key, const QString& value) const = 0; /** */ diff --git a/kmymoney/widgets/transaction.cpp b/kmymoney/widgets/transaction.cpp --- a/kmymoney/widgets/transaction.cpp +++ b/kmymoney/widgets/transaction.cpp @@ -43,6 +43,7 @@ #include "mymoneytransaction.h" #include "mymoneysplit.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" #include "mymoneypayee.h" #include "mymoneytag.h" #include "register.h" @@ -680,7 +681,7 @@ if (d->m_transaction.splits().count() < 2) { msg = QString("%1").arg(i18n("Transaction is missing a category assignment.")); } else { - const MyMoneySecurity& sec = MyMoneyFile::instance()->security(d->m_account.currencyId()); + const auto sec = MyMoneyFile::instance()->security(d->m_account.currencyId()); msg = QString("%1").arg(i18n("The transaction has a missing assignment of %1.", MyMoneyUtils::formatMoney(d->m_transaction.splitSum().abs(), d->m_account, sec))); } return true; @@ -692,7 +693,7 @@ auto file = MyMoneyFile::instance(); QList::const_iterator it_s; QString txt; - const MyMoneySecurity& sec = file->security(d->m_transaction.commodity()); + const auto sec = file->security(d->m_transaction.commodity()); MyMoneyMoney factor(1, 1); if (!d->m_split.value().isNegative()) factor = -factor; diff --git a/kmymoney/wizards/newaccountwizard/kaccounttypepage.h b/kmymoney/wizards/newaccountwizard/kaccounttypepage.h --- a/kmymoney/wizards/newaccountwizard/kaccounttypepage.h +++ b/kmymoney/wizards/newaccountwizard/kaccounttypepage.h @@ -56,7 +56,7 @@ QWidget* initialFocusWidget() const override; eMyMoney::Account::Type accountType() const; - const MyMoneyAccount& parentAccount(); + MyMoneyAccount parentAccount(); bool allowsParentAccount() const; const MyMoneySecurity& currency() const; diff --git a/kmymoney/wizards/newaccountwizard/kaccounttypepage.cpp b/kmymoney/wizards/newaccountwizard/kaccounttypepage.cpp --- a/kmymoney/wizards/newaccountwizard/kaccounttypepage.cpp +++ b/kmymoney/wizards/newaccountwizard/kaccounttypepage.cpp @@ -249,7 +249,7 @@ d->ui->m_accountName->setText(acc.name()); } - const MyMoneyAccount& AccountTypePage::parentAccount() + MyMoneyAccount AccountTypePage::parentAccount() { switch (accountType()) { case Account::Type::CreditCard: diff --git a/kmymoney/wizards/newaccountwizard/kgeneralloaninfopage.h b/kmymoney/wizards/newaccountwizard/kgeneralloaninfopage.h --- a/kmymoney/wizards/newaccountwizard/kgeneralloaninfopage.h +++ b/kmymoney/wizards/newaccountwizard/kgeneralloaninfopage.h @@ -50,7 +50,7 @@ KMyMoneyWizardPage* nextPage() const override; virtual bool isComplete() const override; void enterPage() override; - const MyMoneyAccount& parentAccount(); + MyMoneyAccount parentAccount(); QWidget* initialFocusWidget() const override; diff --git a/kmymoney/wizards/newaccountwizard/kgeneralloaninfopage.cpp b/kmymoney/wizards/newaccountwizard/kgeneralloaninfopage.cpp --- a/kmymoney/wizards/newaccountwizard/kgeneralloaninfopage.cpp +++ b/kmymoney/wizards/newaccountwizard/kgeneralloaninfopage.cpp @@ -152,7 +152,7 @@ return rc; } - const MyMoneyAccount& GeneralLoanInfoPage::parentAccount() + MyMoneyAccount GeneralLoanInfoPage::parentAccount() { Q_D(GeneralLoanInfoPage); return (d->ui->m_loanDirection->currentIndex() == 0) diff --git a/kmymoney/wizards/newaccountwizard/knewaccountwizard.h b/kmymoney/wizards/newaccountwizard/knewaccountwizard.h --- a/kmymoney/wizards/newaccountwizard/knewaccountwizard.h +++ b/kmymoney/wizards/newaccountwizard/knewaccountwizard.h @@ -97,7 +97,7 @@ * @note For now it's either fixed as Asset or Liability. We will provide * user selected parent accounts later. */ - const MyMoneyAccount& parentAccount(); + MyMoneyAccount parentAccount(); /** * Returns information about the schedule. If the returned value diff --git a/kmymoney/wizards/newaccountwizard/knewaccountwizard.cpp b/kmymoney/wizards/newaccountwizard/knewaccountwizard.cpp --- a/kmymoney/wizards/newaccountwizard/knewaccountwizard.cpp +++ b/kmymoney/wizards/newaccountwizard/knewaccountwizard.cpp @@ -203,7 +203,7 @@ return t; } - const MyMoneyAccount& Wizard::parentAccount() + MyMoneyAccount Wizard::parentAccount() { Q_D(Wizard); return d->m_accountTypePage->allowsParentAccount() diff --git a/kmymoney/wizards/newloanwizard/additionalfeeswizardpage.cpp b/kmymoney/wizards/newloanwizard/additionalfeeswizardpage.cpp --- a/kmymoney/wizards/newloanwizard/additionalfeeswizardpage.cpp +++ b/kmymoney/wizards/newloanwizard/additionalfeeswizardpage.cpp @@ -37,6 +37,7 @@ #include "knewloanwizard_p.h" #include "ksplittransactiondlg.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" #include "mymoneyaccount.h" #include "mymoneymoney.h" diff --git a/kmymoney/wizards/newloanwizard/knewloanwizard_p.h b/kmymoney/wizards/newloanwizard/knewloanwizard_p.h --- a/kmymoney/wizards/newloanwizard/knewloanwizard_p.h +++ b/kmymoney/wizards/newloanwizard/knewloanwizard_p.h @@ -51,6 +51,7 @@ #include "mymoneyfinancialcalculator.h" #include "mymoneyfile.h" +#include "mymoneysecurity.h" #include "mymoneyaccountloan.h" #include "mymoneyschedule.h" #include "mymoneysplit.h"