From 0adf026b4ba73cb4c51e9878626ec30ef76407b8 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Sat, 29 Jul 2017 21:10:14 +0300 Subject: [PATCH] refactor: Make Contact parent of Friend and Group --- src/model/friend.cpp | 5 +++++ src/model/friend.h | 17 +++++++++-------- src/model/group.cpp | 10 ++++++++++ src/model/group.h | 13 ++++++++----- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/model/friend.cpp b/src/model/friend.cpp index 479b98e9d..efc74040a 100644 --- a/src/model/friend.cpp +++ b/src/model/friend.cpp @@ -114,6 +114,11 @@ uint32_t Friend::getFriendId() const return friendId; } +uint32_t Friend::getId() const +{ + return getFriendId(); +} + void Friend::setEventFlag(bool flag) { hasNewEvents = flag; diff --git a/src/model/friend.h b/src/model/friend.h index fe8954cb1..0eaef5610 100644 --- a/src/model/friend.h +++ b/src/model/friend.h @@ -20,38 +20,39 @@ #ifndef FRIEND_H #define FRIEND_H +#include "contact.h" #include "src/core/toxid.h" #include "src/core/corestructs.h" #include #include -class FriendWidget; class ChatForm; -class Friend : public QObject +class Friend : public Contact { Q_OBJECT public: - Friend(uint32_t FriendId, const ToxPk& FriendPk, const QString& userAlias); + Friend(uint32_t friendId, const ToxPk& friendPk, const QString& userAlias); Friend(const Friend& other) = delete; - ~Friend(); + ~Friend() override; Friend& operator=(const Friend& other) = delete; void loadHistory(); - void setName(const QString& name); + void setName(const QString& name) override; void setAlias(const QString& name); - QString getDisplayedName() const; + QString getDisplayedName() const override; bool hasAlias() const; void setStatusMessage(const QString& message); QString getStatusMessage() const; - void setEventFlag(bool f); - bool getEventFlag() const; + void setEventFlag(bool f) override; + bool getEventFlag() const override; const ToxPk& getPublicKey() const; uint32_t getFriendId() const; + uint32_t getId() const override; void setStatus(Status s); Status getStatus() const; diff --git a/src/model/group.cpp b/src/model/group.cpp index 78a8754f6..4c8e698cd 100644 --- a/src/model/group.cpp +++ b/src/model/group.cpp @@ -83,6 +83,11 @@ QString Group::getName() const return widget->getName(); } +QString Group::getDisplayedName() const +{ + return getName(); +} + void Group::regeneratePeerList() { const Core* core = Core::getInstance(); @@ -123,6 +128,11 @@ int Group::getGroupId() const return groupId; } +uint32_t Group::getId() const +{ + return getGroupId(); +} + int Group::getPeersCount() const { return nPeers; diff --git a/src/model/group.h b/src/model/group.h index bd18852ce..f2195253f 100644 --- a/src/model/group.h +++ b/src/model/group.h @@ -20,6 +20,7 @@ #ifndef GROUP_H #define GROUP_H +#include "contact.h" #include #include #include @@ -31,15 +32,16 @@ class GroupWidget; class GroupChatForm; class ToxPk; -class Group : public QObject +class Group : public Contact { Q_OBJECT public: Group(int GroupId, QString Name, bool IsAvGroupchat); - virtual ~Group(); + ~Group() override; bool isAvGroupchat() const; int getGroupId() const; + uint32_t getId() const override; int getPeersCount() const; void regeneratePeerList(); QStringList getPeerList() const; @@ -48,15 +50,16 @@ public: GroupChatForm* getChatForm(); GroupWidget* getGroupWidget(); - void setEventFlag(bool f); - bool getEventFlag() const; + void setEventFlag(bool f) override; + bool getEventFlag() const override; void setMentionedFlag(bool f); bool getMentionedFlag() const; void updatePeer(int peerId, QString newName); - void setName(const QString& name); + void setName(const QString& name) override; QString getName() const; + QString getDisplayedName() const override; QString resolveToxId(const ToxPk& id) const;