File indexing completed on 2024-05-12 16:42:34
0001 /* 0002 SPDX-FileCopyrightText: 2012-2016 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 /** 0061 * This method checks if a reference to the given object exists. It returns, 0062 * a @p true if the object is referencing the one requested by the 0063 * parameter @p id. If it does not, this method returns @p false. 0064 * 0065 * @param id id of the object to be checked for references 0066 * @retval true This object references object with id @p id. 0067 * @retval false This object does not reference the object with id @p id. 0068 */ 0069 bool hasReferenceTo(const QString& id) const override; 0070 0071 static MyMoneyCostCenter null; 0072 }; 0073 0074 inline void swap(MyMoneyCostCenter& first, MyMoneyCostCenter& second) // krazy:exclude=inline 0075 { 0076 using std::swap; 0077 swap(first.d_ptr, second.d_ptr); 0078 } 0079 0080 inline MyMoneyCostCenter::MyMoneyCostCenter(MyMoneyCostCenter && other) : MyMoneyCostCenter() // krazy:exclude=inline 0081 { 0082 swap(*this, other); 0083 } 0084 0085 inline MyMoneyCostCenter & MyMoneyCostCenter::operator=(MyMoneyCostCenter other) // krazy:exclude=inline 0086 { 0087 swap(*this, other); 0088 return *this; 0089 } 0090 0091 //inline bool operator==(const MyMoneyCostCenter& lhs, const QString& rhs) 0092 //{ 0093 // return lhs.id() == rhs; 0094 //} 0095 0096 /** 0097 * Make it possible to hold @ref MyMoneyCostCenter objects inside @ref QVariant objects. 0098 */ 0099 Q_DECLARE_METATYPE(MyMoneyCostCenter) 0100 0101 #endif