File indexing completed on 2024-05-19 05:07:19

0001 /*
0002     SPDX-FileCopyrightText: 2000-2001 Michael Edwardes <mte@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2002-2019 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 "qcontainerfwd.h"
0017 #include <QMetaType>
0018 
0019 // ----------------------------------------------------------------------------
0020 // Project Includes
0021 
0022 #include "mymoneyobject.h"
0023 #include "mymoneykeyvaluecontainer.h"
0024 #include "kmm_mymoney_export.h"
0025 
0026 class QString;
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& bankcode);
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 bankcode() const;
0103     void setBankCode(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     static QPixmap pixmap(const int size = 64);
0141 };
0142 
0143 inline void swap(MyMoneyInstitution& first, MyMoneyInstitution& second) // krazy:exclude=inline
0144 {
0145     using std::swap;
0146     swap(first.MyMoneyObject::d_ptr, second.MyMoneyObject::d_ptr);
0147     swap(first.MyMoneyKeyValueContainer::d_ptr, second.MyMoneyKeyValueContainer::d_ptr);
0148 }
0149 
0150 inline MyMoneyInstitution::MyMoneyInstitution(MyMoneyInstitution && other) : MyMoneyInstitution() // krazy:exclude=inline
0151 {
0152     swap(*this, other);
0153 }
0154 
0155 inline MyMoneyInstitution & MyMoneyInstitution::operator=(MyMoneyInstitution other) // krazy:exclude=inline
0156 {
0157     swap(*this, other);
0158     return *this;
0159 }
0160 
0161 /**
0162   * Make it possible to hold @ref MyMoneyInstitution objects inside @ref QVariant objects.
0163   */
0164 Q_DECLARE_METATYPE(MyMoneyInstitution)
0165 
0166 #endif