File indexing completed on 2024-05-12 16:42:37

0001 /*
0002     SPDX-FileCopyrightText: 2000-2001 Michael Edwardes <mte@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2002-2017 Thomas Baumgart <tbaumgart@kde.org>
0004     SPDX-FileCopyrightText: 2003 Kevin Tambascio <ktambascio@users.sourceforge.net>
0005     SPDX-FileCopyrightText: 2004-2006 Ace Jones <acejones@users.sourceforge.net>
0006     SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef MYMONEYINSTITUTION_H
0011 #define MYMONEYINSTITUTION_H
0012 
0013 // ----------------------------------------------------------------------------
0014 // QT Includes
0015 
0016 #include <QMetaType>
0017 
0018 // ----------------------------------------------------------------------------
0019 // Project Includes
0020 
0021 #include "mymoneyobject.h"
0022 #include "mymoneykeyvaluecontainer.h"
0023 #include "kmm_mymoney_export.h"
0024 
0025 class QString;
0026 class QStringList;
0027 class QPixmap;
0028 
0029 /**
0030   * This class represents a Bank contained within a MyMoneyFile object
0031   *
0032   * @author Thomas Baumgart
0033   * @author Łukasz Wojniłowicz
0034   */
0035 class MyMoneyInstitutionPrivate;
0036 class KMM_MYMONEY_EXPORT MyMoneyInstitution : public MyMoneyObject, public MyMoneyKeyValueContainer
0037 {
0038     Q_DECLARE_PRIVATE_D(MyMoneyObject::d_ptr, MyMoneyInstitution)
0039 
0040     KMM_MYMONEY_UNIT_TESTABLE
0041 
0042 public:
0043 
0044     /**
0045       * This is the constructor for a new empty institution description
0046       */
0047     MyMoneyInstitution();
0048     explicit MyMoneyInstitution(const QString &id);
0049 
0050     /**
0051       * This is the constructor used by an application to fill the
0052       * values required for a new institution. This object should then be
0053       * passed to @see MyMoneyFile::addInstitution
0054       */
0055     explicit MyMoneyInstitution(const QString& name,
0056                                 const QString& city,
0057                                 const QString& street,
0058                                 const QString& postcode,
0059                                 const QString& telephone,
0060                                 const QString& manager,
0061                                 const QString& sortCode);
0062 
0063     MyMoneyInstitution(const MyMoneyInstitution & other);
0064     MyMoneyInstitution(MyMoneyInstitution && other);
0065     MyMoneyInstitution & operator=(MyMoneyInstitution other);
0066     friend void swap(MyMoneyInstitution& first, MyMoneyInstitution& second);
0067 
0068     /**
0069       * This is the destructor for any MyMoneyInstitution object
0070       */
0071     ~MyMoneyInstitution();
0072 
0073     /**
0074       * This is the constructor for a new institution known to the current file
0075       *
0076       * @param id id assigned to the new institution object
0077       * @param right institution definition
0078       */
0079     MyMoneyInstitution(const QString& id, const MyMoneyInstitution& other);
0080 
0081     QString manager() const;
0082     void setManager(const QString& manager);
0083 
0084     QString name() const;
0085     void setName(const QString& name);
0086 
0087     QString postcode() const;
0088     void setPostcode(const QString& code);
0089 
0090     QString street() const;
0091     void setStreet(const QString& street);
0092 
0093     QString telephone() const;
0094     void setTelephone(const QString& tel);
0095 
0096     QString town() const;
0097     void setTown(const QString& town);
0098 
0099     QString city() const;
0100     void setCity(const QString& town);
0101 
0102     QString sortcode() const;
0103     void setSortcode(const QString& code);
0104 
0105     /**
0106       * This method adds the id of an account to the account list of
0107       * this institution It is verified, that the account is only
0108       * mentioned once.
0109       *
0110       * @param account id of the account to be added
0111       */
0112     void addAccountId(const QString& account);
0113 
0114     /**
0115       * This method deletes the id of an account from the account list
0116       * of this institution
0117       *
0118       * @param account id of the account to be deleted
0119       * @return id of account deleted, otherwise empty string
0120       */
0121     QString removeAccountId(const QString& account);
0122 
0123     /**
0124       * This method is used to return the set of accounts known to
0125       * this institution
0126       * return QStringList of account ids
0127       */
0128     QStringList accountList() const;
0129 
0130     /**
0131       * This method returns the number of accounts known to
0132       * this institution
0133       * @return number of accounts
0134       */
0135     unsigned int accountCount() const;
0136 
0137     bool operator == (const MyMoneyInstitution&) const;
0138     bool operator < (const MyMoneyInstitution& right) const;
0139 
0140     /**
0141       * This method checks if a reference to the given object exists. It returns,
0142       * a @p true if the object is referencing the one requested by the
0143       * parameter @p id. If it does not, this method returns @p false.
0144       *
0145       * @param id id of the object to be checked for references
0146       * @retval true This object references object with id @p id.
0147       * @retval false This object does not reference the object with id @p id.
0148       */
0149     bool hasReferenceTo(const QString& id) const override;
0150 
0151     static QPixmap pixmap(const int size = 64);
0152 };
0153 
0154 inline void swap(MyMoneyInstitution& first, MyMoneyInstitution& second) // krazy:exclude=inline
0155 {
0156     using std::swap;
0157     swap(first.MyMoneyObject::d_ptr, second.MyMoneyObject::d_ptr);
0158     swap(first.MyMoneyKeyValueContainer::d_ptr, second.MyMoneyKeyValueContainer::d_ptr);
0159 }
0160 
0161 inline MyMoneyInstitution::MyMoneyInstitution(MyMoneyInstitution && other) : MyMoneyInstitution() // krazy:exclude=inline
0162 {
0163     swap(*this, other);
0164 }
0165 
0166 inline MyMoneyInstitution & MyMoneyInstitution::operator=(MyMoneyInstitution other) // krazy:exclude=inline
0167 {
0168     swap(*this, other);
0169     return *this;
0170 }
0171 
0172 /**
0173   * Make it possible to hold @ref MyMoneyInstitution objects inside @ref QVariant objects.
0174   */
0175 Q_DECLARE_METATYPE(MyMoneyInstitution)
0176 
0177 #endif