From bb9ed14fc1bf7dc20f1e951e67bb359c273033a3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 18 May 2014 12:18:44 +0300 Subject: fix code style. --- src/gui/widgets/tabs/socialfriendstab.h | 37 ++++++--------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) (limited to 'src/gui/widgets/tabs/socialfriendstab.h') diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h index 3d65e2678..0a43c6e2f 100644 --- a/src/gui/widgets/tabs/socialfriendstab.h +++ b/src/gui/widgets/tabs/socialfriendstab.h @@ -24,15 +24,15 @@ #include "gui/widgets/tabs/socialtab.h" #include "actormanager.h" -#include "avatar.h" -#include "being/actortype.h" #include "being/playerrelations.h" #include "gui/models/beingslistmodel.h" #include "gui/windows/whoisonline.h" +#include "gui/widgets/tabs/socialfriendsfunctor.h" + #include "utils/delete2.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -41,33 +41,6 @@ #include "localconsts.h" -namespace -{ - static class SortFriendsFunctor final - { - public: - bool operator() (const Avatar *const m1, - const Avatar *const m2) const - { - if (!m1 || !m2) - return false; - - if (m1->getOnline() != m2->getOnline()) - return m1->getOnline() > m2->getOnline(); - - if (m1->getName() != m2->getName()) - { - std::string s1 = m1->getName(); - std::string s2 = m2->getName(); - toLower(s1); - toLower(s2); - return s1 < s2; - } - return false; - } - } friendSorter; -} // namespace - class SocialFriendsTab final : public SocialTab { public: @@ -75,7 +48,8 @@ class SocialFriendsTab final : public SocialTab std::string name, const bool showBackground) : SocialTab(widget), - mBeings(new BeingsListModel) + mBeings(new BeingsListModel), + mFriendSorter() { createControls(mBeings, showBackground); @@ -139,7 +113,7 @@ class SocialFriendsTab final : public SocialTab total ++; avatars->push_back(ava); } - std::sort(avatars->begin(), avatars->end(), friendSorter); + std::sort(avatars->begin(), avatars->end(), mFriendSorter); delete players; // TRANSLATORS: social window label @@ -151,6 +125,7 @@ class SocialFriendsTab final : public SocialTab private: BeingsListModel *mBeings; + SortFriendsFunctor mFriendSorter; }; #endif // GUI_WIDGETS_TABS_SOCIALFRIENDSTAB_H -- cgit v1.2.3-70-g09d2