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: | ||
25 | QString field; | 27 | QString field; | ||
26 | Qt::SortOrder order = Qt::AscendingOrder; | 28 | Qt::SortOrder order = Qt::AscendingOrder; | ||
27 | }; | 29 | }; | ||
28 | 30 | | |||
29 | class KReportData::Private | 31 | class KReportData::Private | ||
30 | { | 32 | { | ||
31 | public: | 33 | public: | ||
32 | bool dummy = true; | 34 | bool dummy = true; | ||
33 | }; | 35 | }; | ||
34 | 36 | | |||
35 | //==========KReportData::SortedField========== | 37 | //==========KReportData::SortedField========== | ||
36 | 38 | | |||
37 | KReportData::SortedField::SortedField() | 39 | KReportData::SortedField::SortedField() | ||
38 | : d(new Private()) | 40 | : d(new Private()) | ||
39 | { | 41 | { | ||
40 | } | 42 | } | ||
41 | 43 | | |||
44 | KReportData::SortedField::SortedField(const KReportData::SortedField& other) : d(new Private) | ||||
45 | { | ||||
46 | d->field = other.field(); | ||||
staniek: Since we have `KReportDataSortedFieldPrivateArgs`, it's enough to white `: d(new Private(*other. | |||||
47 | d->order = other.order(); | ||||
48 | } | ||||
49 | | ||||
50 | | ||||
42 | KReportData::SortedField::~SortedField() | 51 | KReportData::SortedField::~SortedField() | ||
43 | { | 52 | { | ||
44 | delete d; | 53 | delete d; | ||
45 | } | 54 | } | ||
46 | 55 | | |||
47 | KReportData::SortedField & KReportData::SortedField::operator=(const KReportData::SortedField& other) | 56 | KReportData::SortedField & KReportData::SortedField::operator=(const KReportData::SortedField& other) | ||
48 | { | 57 | { | ||
49 | if (this != &other) { | 58 | if (this != &other) { | ||
50 | setField(other.field()); | 59 | setField(other.field()); | ||
51 | setOrder(other.order()); | 60 | setOrder(other.order()); | ||
52 | } | 61 | } | ||
53 | return *this; | 62 | return *this; | ||
54 | } | 63 | } | ||
55 | 64 | | |||
65 | bool KReportData::SortedField::operator==(const KReportData::SortedField& other) | ||||
66 | { | ||||
67 | return KReportDataSortedFieldPrivateArgs((*d)) == KReportDataSortedFieldPrivateArgs((*(other.d))); | ||||
staniek: `*(other.d)` -> `*other.d` ? | |||||
68 | } | ||||
69 | | ||||
70 | bool KReportData::SortedField::operator!=(const KReportData::SortedField& other) | ||||
71 | { | ||||
72 | return KReportDataSortedFieldPrivateArgs((*d)) != KReportDataSortedFieldPrivateArgs((*(other.d))); | ||||
staniek: same here | |||||
73 | } | ||||
74 | | ||||
56 | QString KReportData::SortedField::field() const | 75 | QString KReportData::SortedField::field() const | ||
57 | { | 76 | { | ||
58 | return d->field; | 77 | return d->field; | ||
59 | } | 78 | } | ||
60 | 79 | | |||
61 | Qt::SortOrder KReportData::SortedField::order() const | 80 | Qt::SortOrder KReportData::SortedField::order() const | ||
62 | { | 81 | { | ||
63 | return d->order; | 82 | 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)