From c667cf5c8405cb8e2f7b826fe0f7c5d4e2d2cf87 Mon Sep 17 00:00:00 2001 From: Diadlo Date: Fri, 23 Jun 2017 14:11:24 +0300 Subject: [PATCH] refactor(widget): Remove 'chatFormIsSet' 'charFormIsSet' is small static method used in one place, replaced on direct using. --- src/widget/friendwidget.cpp | 10 ---------- src/widget/friendwidget.h | 1 - src/widget/genericchatroomwidget.h | 1 - src/widget/groupwidget.cpp | 10 ---------- src/widget/groupwidget.h | 1 - src/widget/widget.cpp | 13 ++++++++++--- 6 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/widget/friendwidget.cpp b/src/widget/friendwidget.cpp index 53d897b58..0ac104d87 100644 --- a/src/widget/friendwidget.cpp +++ b/src/widget/friendwidget.cpp @@ -363,16 +363,6 @@ void FriendWidget::search(const QString& searchString, bool hide) circleWidget->search(searchString); } -// TODO: Remove -bool FriendWidget::chatFormIsSet(bool focus) const -{ - if (focus) { - ContentDialog::focusFriend(friendId); - } - - return ContentDialog::friendWidgetExists(friendId); -} - void FriendWidget::setChatForm(ContentLayout* contentLayout) { Friend* f = FriendList::findFriend(friendId); diff --git a/src/widget/friendwidget.h b/src/widget/friendwidget.h index f79ce271b..507a00ab3 100644 --- a/src/widget/friendwidget.h +++ b/src/widget/friendwidget.h @@ -32,7 +32,6 @@ public: void setAsActiveChatroom() override final; void setAsInactiveChatroom() override final; void updateStatusLight() override final; - bool chatFormIsSet(bool focus) const override final; void setChatForm(ContentLayout* contentLayout) override final; void resetEventFlags() override final; QString getStatusString() const override final; diff --git a/src/widget/genericchatroomwidget.h b/src/widget/genericchatroomwidget.h index e7c272353..a88455109 100644 --- a/src/widget/genericchatroomwidget.h +++ b/src/widget/genericchatroomwidget.h @@ -39,7 +39,6 @@ public: virtual void setAsActiveChatroom() = 0; virtual void setAsInactiveChatroom() = 0; virtual void updateStatusLight() = 0; - virtual bool chatFormIsSet(bool focus) const = 0; virtual void setChatForm(ContentLayout* contentLayout) = 0; virtual void resetEventFlags() = 0; virtual QString getStatusString() const = 0; diff --git a/src/widget/groupwidget.cpp b/src/widget/groupwidget.cpp index 2a5f808cc..95cfc38d7 100644 --- a/src/widget/groupwidget.cpp +++ b/src/widget/groupwidget.cpp @@ -198,16 +198,6 @@ Group* GroupWidget::getGroup() const return GroupList::findGroup(groupId); } -// TODO: Remove -bool GroupWidget::chatFormIsSet(bool focus) const -{ - if (focus) { - ContentDialog::focusGroup(groupId); - } - - return ContentDialog::groupWidgetExists(groupId); -} - void GroupWidget::setChatForm(ContentLayout* contentLayout) { Group* g = GroupList::findGroup(groupId); diff --git a/src/widget/groupwidget.h b/src/widget/groupwidget.h index 2bf7726a8..4baf139c3 100644 --- a/src/widget/groupwidget.h +++ b/src/widget/groupwidget.h @@ -31,7 +31,6 @@ public: void setAsInactiveChatroom() final override; void setAsActiveChatroom() final override; void updateStatusLight() final override; - bool chatFormIsSet(bool focus) const final override; void setChatForm(ContentLayout* contentLayout) final override; void resetEventFlags() final override; QString getStatusString() const final override; diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 5fd2ac885..fb8f096d6 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1117,14 +1117,21 @@ void Widget::openDialog(GenericChatroomWidget* widget, bool newWindow) widget->resetEventFlags(); widget->updateStatusLight(); + uint32_t id; GenericChatForm* form; if (widget->getFriend()) { - form = widget->getFriend()->getChatForm(); + Friend* f = widget->getFriend(); + form = f->getChatForm(); + id = f->getFriendId(); } else { - form = widget->getGroup()->getChatForm(); + Group* g = widget->getGroup(); + form = g->getChatForm(); + id = g->getGroupId(); } - if ((widget->chatFormIsSet(true) || form->isVisible()) && !newWindow) { + ContentDialog::focusFriend(id); + bool chatFormIsSet = ContentDialog::friendWidgetExists(id); + if ((chatFormIsSet || form->isVisible()) && !newWindow) { return; }