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

0001 /*
0002     SPDX-FileCopyrightText: 2012-2019 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef MYMONEYCOSTCENTER_H
0007 #define MYMONEYCOSTCENTER_H
0008 
0009 #include "kmm_mymoney_export.h"
0010 
0011 // ----------------------------------------------------------------------------
0012 // QT Includes
0013 
0014 #include <QMetaType>
0015 #include <QHash>
0016 
0017 // ----------------------------------------------------------------------------
0018 // Project Includes
0019 
0020 #include "mymoneyobject.h"
0021 
0022 /**
0023   * This class represents a tag within the MyMoney engine.
0024   */
0025 class MyMoneyCostCenterPrivate;
0026 class KMM_MYMONEY_EXPORT MyMoneyCostCenter : public MyMoneyObject
0027 {
0028     Q_DECLARE_PRIVATE(MyMoneyCostCenter)
0029 
0030     KMM_MYMONEY_UNIT_TESTABLE
0031 
0032 public:
0033     MyMoneyCostCenter();
0034     explicit MyMoneyCostCenter(const QString &id);
0035 
0036     MyMoneyCostCenter(const QString& id,
0037                       const MyMoneyCostCenter& other);
0038     MyMoneyCostCenter(const MyMoneyCostCenter & other);
0039     MyMoneyCostCenter(MyMoneyCostCenter && other);
0040     MyMoneyCostCenter & operator=(MyMoneyCostCenter other);
0041     friend void swap(MyMoneyCostCenter& first, MyMoneyCostCenter& second);
0042 
0043     ~MyMoneyCostCenter();
0044 
0045     QString name() const;
0046     void setName(const QString& val);
0047 
0048     /**
0049      * This member returns a possible number leading the name. If there
0050      * is no number infront of the name, then the full name will be returned
0051      * @sa name()
0052      */
0053     QString shortName() const;
0054 
0055 
0056     // Equality operator
0057     bool operator == (const MyMoneyCostCenter &) const;
0058     bool operator <(const MyMoneyCostCenter& right) const;
0059 
0060     static MyMoneyCostCenter null;
0061 };
0062 
0063 inline void swap(MyMoneyCostCenter& first, MyMoneyCostCenter& second) // krazy:exclude=inline
0064 {
0065     using std::swap;
0066     swap(first.d_ptr, second.d_ptr);
0067 }
0068 
0069 inline MyMoneyCostCenter::MyMoneyCostCenter(MyMoneyCostCenter && other) : MyMoneyCostCenter() // krazy:exclude=inline
0070 {
0071     swap(*this, other);
0072 }
0073 
0074 inline MyMoneyCostCenter & MyMoneyCostCenter::operator=(MyMoneyCostCenter other) // krazy:exclude=inline
0075 {
0076     swap(*this, other);
0077     return *this;
0078 }
0079 
0080 //inline bool operator==(const MyMoneyCostCenter& lhs, const QString& rhs)
0081 //{
0082 //  return lhs.id() == rhs;
0083 //}
0084 
0085 /**
0086   * Make it possible to hold @ref MyMoneyCostCenter objects inside @ref QVariant objects.
0087   */
0088 Q_DECLARE_METATYPE(MyMoneyCostCenter)
0089 
0090 #endif