Changeset View
Changeset View
Standalone View
Standalone View
src/musicartist.cpp
Show All 14 Lines | |||||
15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "musicartist.h" | 18 | #include "musicartist.h" | ||
19 | 19 | | |||
20 | #include <QtGlobal> | 20 | #include <QtGlobal> | ||
21 | #include <QString> | 21 | #include <QString> | ||
22 | #include <QStringList> | 22 | #include <QStringList> | ||
23 | #include <QSharedData> | ||||
24 | | ||||
23 | #include <QDebug> | 25 | #include <QDebug> | ||
24 | 26 | | |||
25 | class MusicArtistPrivate | 27 | class MusicArtistPrivate : public QSharedData | ||
26 | { | 28 | { | ||
27 | public: | 29 | public: | ||
28 | 30 | | |||
29 | QString mName; | 31 | QString mName; | ||
30 | 32 | | |||
31 | QStringList mGenres; | 33 | QStringList mGenres; | ||
32 | 34 | | |||
33 | qulonglong mDatabaseId = 0; | 35 | qulonglong mDatabaseId = 0; | ||
34 | 36 | | |||
35 | int mAlbumsCount = 0; | 37 | int mAlbumsCount = 0; | ||
36 | 38 | | |||
37 | bool mIsValid = false; | 39 | bool mIsValid = false; | ||
38 | 40 | | |||
39 | }; | 41 | }; | ||
40 | 42 | | |||
41 | MusicArtist::MusicArtist() : d(std::make_unique<MusicArtistPrivate>()) | 43 | MusicArtist::MusicArtist() : d(new MusicArtistPrivate()) | ||
42 | { | 44 | { | ||
43 | } | 45 | } | ||
44 | 46 | | |||
45 | MusicArtist::MusicArtist(MusicArtist &&other) | 47 | MusicArtist::MusicArtist(MusicArtist &&other) noexcept = default; | ||
46 | { | | |||
47 | d.swap(other.d); | | |||
48 | } | | |||
49 | 48 | | |||
50 | MusicArtist::MusicArtist(const MusicArtist &other) : d(std::make_unique<MusicArtistPrivate>(*other.d)) | 49 | MusicArtist::MusicArtist(const MusicArtist &other) = default; | ||
51 | { | | |||
52 | } | | |||
53 | 50 | | |||
54 | MusicArtist& MusicArtist::operator=(MusicArtist &&other) | 51 | MusicArtist& MusicArtist::operator=(MusicArtist &&other) noexcept = default; | ||
55 | { | | |||
56 | if (&other != this) { | | |||
57 | d.reset(); | | |||
58 | d.swap(other.d); | | |||
59 | } | | |||
60 | 52 | | |||
61 | return *this; | 53 | MusicArtist &MusicArtist::operator=(const MusicArtist &other) = default; | ||
62 | } | | |||
63 | | ||||
64 | MusicArtist &MusicArtist::operator=(const MusicArtist &other) | | |||
65 | { | | |||
66 | if (&other != this) { | | |||
67 | (*d) = (*other.d); | | |||
68 | } | | |||
69 | | ||||
70 | return *this; | | |||
71 | } | | |||
72 | 54 | | |||
73 | MusicArtist::~MusicArtist() | 55 | MusicArtist::~MusicArtist() | ||
74 | = default; | 56 | = default; | ||
75 | 57 | | |||
76 | void MusicArtist::setValid(bool value) | 58 | void MusicArtist::setValid(bool value) | ||
77 | { | 59 | { | ||
78 | d->mIsValid = value; | 60 | d->mIsValid = value; | ||
79 | } | 61 | } | ||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |