Verified Commit 16f0ba83 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Make entities movable

parent cc6eafa4
......@@ -100,9 +100,9 @@ Collection::Collection(const Collection &other)
assignCollectionPrivate(d_ptr, other.d_ptr);
}
Collection::~Collection()
{
}
Collection::Collection(Collection &&) = default;
Collection::~Collection() = default;
void Collection::setId(Collection::Id identifier)
{
......
......@@ -126,6 +126,11 @@ public:
*/
Collection(const Collection &other);
/**
* Move constructor.
*/
Collection(Collection &&other);
/**
* Creates a collection from the given @p url.
*/
......
......@@ -158,14 +158,11 @@ Item::Item(const QString &mimeType)
d_ptr->mMimeType = mimeType;
}
Item::Item(const Item &other)
: d_ptr(other.d_ptr)
{
}
Item::Item(const Item &other) = default;
Item::~Item()
{
}
Item::Item(Item &&other) = default;
Item::~Item() = default;
void Item::setId(Item::Id identifier)
{
......
......@@ -164,6 +164,11 @@ public:
*/
Item(const Item &other);
/**
* Move constructor.
*/
Item(Item &&);
/**
* Destroys the item.
*/
......
......@@ -25,7 +25,7 @@ using namespace Akonadi;
const char *Akonadi::Relation::GENERIC = "GENERIC";
struct Q_DECL_HIDDEN Relation::Private {
struct Q_DECL_HIDDEN Relation::Private : public QSharedData {
Item left;
Item right;
QByteArray type;
......@@ -35,7 +35,6 @@ struct Q_DECL_HIDDEN Relation::Private {
Relation::Relation()
: d(new Private)
{
}
Relation::Relation(const QByteArray &type, const Item &left, const Item &right)
......@@ -46,24 +45,15 @@ Relation::Relation(const QByteArray &type, const Item &left, const Item &right)
d->type = type;
}
Relation::Relation(const Relation &other)
: d(new Private)
{
operator=(other);
}
Relation::Relation(const Relation &other) = default;
Relation::~Relation()
{
}
Relation::Relation(Relation &&) noexcept = default;
Relation &Relation::operator=(const Relation &other)
{
d->left = other.d->left;
d->right = other.d->right;
d->type = other.d->type;
d->remoteId = other.d->remoteId;
return *this;
}
Relation::~Relation() = default;
Relation &Relation::operator=(const Relation &) = default;
Relation &Relation::operator=(Relation &&) noexcept = default;
bool Relation::operator==(const Relation &other) const
{
......
......@@ -29,7 +29,7 @@ class Relation;
AKONADICORE_EXPORT unsigned int qHash(const Akonadi::Relation &);
}
#include <QSharedPointer>
#include <QSharedDataPointer>
#include <QByteArray>
#include <QDebug>
......@@ -69,10 +69,13 @@ public:
*/
explicit Relation(const QByteArray &type, const Item &left, const Item &right);
Relation(const Relation &other);
Relation(const Relation &);
Relation(Relation &&) noexcept;
~Relation();
Relation &operator=(const Relation &);
Relation &operator=(Relation &&) noexcept;
bool operator==(const Relation &) const;
bool operator!=(const Relation &) const;
......@@ -120,7 +123,7 @@ public:
private:
struct Private;
QSharedPointer<Private> d;
QSharedDataPointer<Private> d;
};
}
......
......@@ -38,7 +38,6 @@ uint Akonadi::qHash(const Tag &tag)
Tag::Tag()
: d_ptr(new TagPrivate)
{
}
Tag::Tag(Tag::Id id)
......@@ -54,23 +53,12 @@ Tag::Tag(const QString &name)
d_ptr->type = PLAIN;
}
Tag::Tag(const Tag &other)
: d_ptr(other.d_ptr)
{
}
Tag::~Tag()
{
}
Tag &Tag::operator=(const Tag &other)
{
if (this != &other) {
d_ptr = other.d_ptr;
}
Tag::Tag(const Tag &) = default;
Tag::Tag(Tag &&) noexcept = default;
Tag::~Tag() = default;
return *this;
}
Tag &Tag::operator=(const Tag &) = default;
Tag &Tag::operator=(Tag &&) noexcept = default;
bool Tag::operator==(const Tag &other) const
{
......
......@@ -69,11 +69,14 @@ public:
*/
explicit Tag(const QString &name);
Tag(const Tag &other);
Tag(const Tag &);
Tag(Tag &&) noexcept;
~Tag();
Tag &operator=(const Tag &);
Tag &operator=(Tag &&) noexcept;
//Avoid slicing
bool operator==(const Tag &) const;
bool operator!=(const Tag &) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment