File indexing completed on 2024-05-19 05:07:24
0001 /* 0002 SPDX-FileCopyrightText: 2012 Alessandro Russo <axela74@yahoo.it> 0003 SPDX-FileCopyrightText: 2017-2018 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com> 0004 SPDX-FileCopyrightText: 2019 Thomas Baumgart <tbaumgart@kde.org> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef MYMONEYTAG_H 0009 #define MYMONEYTAG_H 0010 0011 // ---------------------------------------------------------------------------- 0012 // QT Includes 0013 0014 #include <QMetaType> 0015 0016 // ---------------------------------------------------------------------------- 0017 // Project Includes 0018 0019 #include "kmm_mymoney_export.h" 0020 #include "mymoneyobject.h" 0021 0022 class QString; 0023 class QColor; 0024 0025 /** 0026 * This class represents a tag within the MyMoney engine. 0027 */ 0028 class MyMoneyTagPrivate; 0029 class KMM_MYMONEY_EXPORT MyMoneyTag : public MyMoneyObject 0030 { 0031 Q_DECLARE_PRIVATE(MyMoneyTag) 0032 0033 KMM_MYMONEY_UNIT_TESTABLE 0034 0035 public: 0036 MyMoneyTag(); 0037 explicit MyMoneyTag(const QString &id); 0038 0039 explicit MyMoneyTag(const QString& name, 0040 const QColor& tagColor 0041 ); 0042 0043 MyMoneyTag(const QString& id, 0044 const MyMoneyTag& tag); 0045 0046 MyMoneyTag(const MyMoneyTag & other); 0047 MyMoneyTag(MyMoneyTag && other); 0048 MyMoneyTag & operator=(MyMoneyTag other); 0049 friend void swap(MyMoneyTag& first, MyMoneyTag& second); 0050 0051 ~MyMoneyTag(); 0052 0053 QString name() const; 0054 void setName(const QString& val); 0055 0056 bool isClosed() const; 0057 void setClosed(bool val); 0058 0059 QColor tagColor() const; 0060 void setTagColor(const QColor& val); 0061 void setNamedTagColor(const QString &val); 0062 0063 QString notes() const; 0064 void setNotes(const QString& val); 0065 0066 // Equality operator 0067 bool operator == (const MyMoneyTag &) const; 0068 bool operator <(const MyMoneyTag& right) const; 0069 0070 static MyMoneyTag null; 0071 }; 0072 0073 inline void swap(MyMoneyTag& first, MyMoneyTag& second) // krazy:exclude=inline 0074 { 0075 using std::swap; 0076 swap(first.d_ptr, second.d_ptr); 0077 } 0078 0079 inline MyMoneyTag::MyMoneyTag(MyMoneyTag && other) : MyMoneyTag() // krazy:exclude=inline 0080 { 0081 swap(*this, other); 0082 } 0083 0084 inline MyMoneyTag & MyMoneyTag::operator=(MyMoneyTag other) // krazy:exclude=inline 0085 { 0086 swap(*this, other); 0087 return *this; 0088 } 0089 0090 //inline bool operator==(const MyMoneyTag& lhs, const QString& rhs) 0091 //{ 0092 // return lhs.id() == rhs; 0093 //} 0094 0095 /** 0096 * Make it possible to hold @ref MyMoneyTag objects inside @ref QVariant objects. 0097 */ 0098 Q_DECLARE_METATYPE(MyMoneyTag) 0099 0100 #endif