Mover copy constructors the right way.

This commit is contained in:
Martin Rotter 2017-09-21 06:55:09 +02:00
parent 17d04b8bde
commit 6c09eb2e8d
5 changed files with 24 additions and 16 deletions

View File

@ -37,6 +37,16 @@ Feed::Feed(RootItem* parent)
setAutoDelete(false);
}
Feed::Feed(const Feed& other) : RootItem(other) {
setCountOfAllMessages(other.countOfAllMessages());
setCountOfUnreadMessages(other.countOfUnreadMessages());
setUrl(other.url());
setStatus(other.status());
setAutoUpdateType(other.autoUpdateType());
setAutoUpdateInitialInterval(other.autoUpdateInitialInterval());
setAutoUpdateRemainingInterval(other.autoUpdateRemainingInterval());
}
Feed::~Feed() {}
QList<Message> Feed::undeletedMessages() const {

View File

@ -52,6 +52,7 @@ class Feed : public RootItem, public QRunnable {
// Constructors.
explicit Feed(RootItem* parent = nullptr);
explicit Feed(const Feed& other);
virtual ~Feed();
QList<Message> undeletedMessages() const;

View File

@ -40,6 +40,17 @@ RootItem::RootItem(RootItem* parent_item)
setupFonts();
}
RootItem::RootItem(const RootItem& other) {
setTitle(other.title());
setId(other.id());
setCustomId(other.customId());
setIcon(other.icon());
setChildItems(other.childItems());
setParent(other.parent());
setCreationDate(other.creationDate());
setDescription(other.description());
}
RootItem::~RootItem() {
qDeleteAll(m_childItems);
}

View File

@ -70,6 +70,7 @@ class RootItem : public QObject {
// Constructors and destructors.
explicit RootItem(RootItem* parent_item = nullptr);
explicit RootItem(const RootItem& other);
virtual ~RootItem();
virtual QString hashCode() const;

View File

@ -54,28 +54,13 @@ StandardFeed::StandardFeed(RootItem* parent_item)
}
StandardFeed::StandardFeed(const StandardFeed& other)
: Feed(nullptr) {
: Feed(other) {
m_passwordProtected = other.passwordProtected();
m_username = other.username();
m_password = other.password();
m_networkError = other.networkError();
m_type = other.type();
m_encoding = other.encoding();
setCountOfAllMessages(other.countOfAllMessages());
setCountOfUnreadMessages(other.countOfUnreadMessages());
setUrl(other.url());
setStatus(other.status());
setAutoUpdateType(other.autoUpdateType());
setAutoUpdateInitialInterval(other.autoUpdateInitialInterval());
setAutoUpdateRemainingInterval(other.autoUpdateRemainingInterval());
setTitle(other.title());
setId(other.id());
setCustomId(other.customId());
setIcon(other.icon());
setChildItems(other.childItems());
setParent(other.parent());
setCreationDate(other.creationDate());
setDescription(other.description());
}
StandardFeed::~StandardFeed() {