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); 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() {} Feed::~Feed() {}
QList<Message> Feed::undeletedMessages() const { QList<Message> Feed::undeletedMessages() const {

View file

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

View file

@ -40,6 +40,17 @@ RootItem::RootItem(RootItem* parent_item)
setupFonts(); 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() { RootItem::~RootItem() {
qDeleteAll(m_childItems); qDeleteAll(m_childItems);
} }

View file

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

View file

@ -54,28 +54,13 @@ StandardFeed::StandardFeed(RootItem* parent_item)
} }
StandardFeed::StandardFeed(const StandardFeed& other) StandardFeed::StandardFeed(const StandardFeed& other)
: Feed(nullptr) { : Feed(other) {
m_passwordProtected = other.passwordProtected(); m_passwordProtected = other.passwordProtected();
m_username = other.username(); m_username = other.username();
m_password = other.password(); m_password = other.password();
m_networkError = other.networkError(); m_networkError = other.networkError();
m_type = other.type(); m_type = other.type();
m_encoding = other.encoding(); 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() { StandardFeed::~StandardFeed() {