Changeset View
Changeset View
Standalone View
Standalone View
src/common/KReportData.cpp
Show All 12 Lines | |||||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | 14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | 16 | */ | ||
17 | 17 | | |||
18 | #include "KReportData.h" | 18 | #include "KReportData.h" | ||
19 | #include <QVariant> | 19 | #include <QVariant> | ||
20 | 20 | | |||
21 | #define KReportDataSortedFieldPrivateArgs(o) std::tie(o.field, o.order) | ||||
22 | | ||||
21 | class KReportData::SortedField::Private | 23 | class KReportData::SortedField::Private | ||
22 | { | 24 | { | ||
23 | 25 | | |||
24 | public: | 26 | public: | ||
27 | Private() {} | ||||
28 | Private(const Private& other) { | ||||
29 | KReportDataSortedFieldPrivateArgs((*this)) = KReportDataSortedFieldPrivateArgs(other); | ||||
30 | } | ||||
25 | QString field; | 31 | QString field; | ||
26 | Qt::SortOrder order = Qt::AscendingOrder; | 32 | Qt::SortOrder order = Qt::AscendingOrder; | ||
27 | }; | 33 | }; | ||
28 | 34 | | |||
29 | class KReportData::Private | 35 | class KReportData::Private | ||
30 | { | 36 | { | ||
31 | public: | 37 | public: | ||
32 | bool dummy = true; | 38 | bool dummy = true; | ||
33 | }; | 39 | }; | ||
34 | 40 | | |||
35 | //==========KReportData::SortedField========== | 41 | //==========KReportData::SortedField========== | ||
36 | 42 | | |||
37 | KReportData::SortedField::SortedField() | 43 | KReportData::SortedField::SortedField() | ||
38 | : d(new Private()) | 44 | : d(new Private) | ||
45 | { | ||||
46 | } | ||||
47 | | ||||
48 | KReportData::SortedField::SortedField(const KReportData::SortedField& other) : d(new Private(*other.d)) | ||||
39 | { | 49 | { | ||
40 | } | 50 | } | ||
41 | 51 | | |||
52 | | ||||
42 | KReportData::SortedField::~SortedField() | 53 | KReportData::SortedField::~SortedField() | ||
43 | { | 54 | { | ||
staniek: Since we have `KReportDataSortedFieldPrivateArgs`, it's enough to white `: d(new Private(*other. | |||||
44 | delete d; | 55 | delete d; | ||
45 | } | 56 | } | ||
46 | 57 | | |||
47 | KReportData::SortedField & KReportData::SortedField::operator=(const KReportData::SortedField& other) | 58 | KReportData::SortedField & KReportData::SortedField::operator=(const KReportData::SortedField& other) | ||
48 | { | 59 | { | ||
49 | if (this != &other) { | 60 | if (this != &other) { | ||
50 | setField(other.field()); | 61 | setField(other.field()); | ||
51 | setOrder(other.order()); | 62 | setOrder(other.order()); | ||
52 | } | 63 | } | ||
53 | return *this; | 64 | return *this; | ||
54 | } | 65 | } | ||
55 | 66 | | |||
67 | bool KReportData::SortedField::operator==(const KReportData::SortedField& other) | ||||
68 | { | ||||
69 | return KReportDataSortedFieldPrivateArgs((*d)) == KReportDataSortedFieldPrivateArgs((*other.d)); | ||||
staniek: `*(other.d)` -> `*other.d` ? | |||||
70 | } | ||||
71 | | ||||
72 | bool KReportData::SortedField::operator!=(const KReportData::SortedField& other) | ||||
73 | { | ||||
74 | return KReportDataSortedFieldPrivateArgs((*d)) != KReportDataSortedFieldPrivateArgs((*other.d)); | ||||
staniek: same here | |||||
75 | } | ||||
76 | | ||||
56 | QString KReportData::SortedField::field() const | 77 | QString KReportData::SortedField::field() const | ||
57 | { | 78 | { | ||
58 | return d->field; | 79 | return d->field; | ||
59 | } | 80 | } | ||
60 | 81 | | |||
61 | Qt::SortOrder KReportData::SortedField::order() const | 82 | Qt::SortOrder KReportData::SortedField::order() const | ||
62 | { | 83 | { | ||
63 | return d->order; | 84 | return d->order; | ||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |
Since we have KReportDataSortedFieldPrivateArgs, it's enough to white : d(new Private(*other.d)) and add a Private copy ctor:
KReportDataSortedFieldPrivateArgs((*this)) = KReportDataSortedFieldPrivateArgs(other)
(Private copy ctor to avoid coverity warnings)