From 6c09eb2e8d0333c4e169210c85801cb74faabafe Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 21 Sep 2017 06:55:09 +0200 Subject: [PATCH] Mover copy constructors the right way. --- src/services/abstract/feed.cpp | 10 ++++++++++ src/services/abstract/feed.h | 1 + src/services/abstract/rootitem.cpp | 11 +++++++++++ src/services/abstract/rootitem.h | 1 + src/services/standard/standardfeed.cpp | 17 +---------------- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/services/abstract/feed.cpp b/src/services/abstract/feed.cpp index 7793f7ffb..e938168b3 100755 --- a/src/services/abstract/feed.cpp +++ b/src/services/abstract/feed.cpp @@ -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 Feed::undeletedMessages() const { diff --git a/src/services/abstract/feed.h b/src/services/abstract/feed.h index 394b61ddd..2a78cd151 100755 --- a/src/services/abstract/feed.h +++ b/src/services/abstract/feed.h @@ -52,6 +52,7 @@ class Feed : public RootItem, public QRunnable { // Constructors. explicit Feed(RootItem* parent = nullptr); + explicit Feed(const Feed& other); virtual ~Feed(); QList undeletedMessages() const; diff --git a/src/services/abstract/rootitem.cpp b/src/services/abstract/rootitem.cpp index 5198d2161..f83f8255f 100755 --- a/src/services/abstract/rootitem.cpp +++ b/src/services/abstract/rootitem.cpp @@ -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); } diff --git a/src/services/abstract/rootitem.h b/src/services/abstract/rootitem.h index 59f16e113..60aab841d 100755 --- a/src/services/abstract/rootitem.h +++ b/src/services/abstract/rootitem.h @@ -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; diff --git a/src/services/standard/standardfeed.cpp b/src/services/standard/standardfeed.cpp index 470e65f65..935690d24 100755 --- a/src/services/standard/standardfeed.cpp +++ b/src/services/standard/standardfeed.cpp @@ -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() {