summaryrefslogtreecommitdiff
path: root/src/gui/widgets/tabs
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-17 21:20:31 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-17 21:20:31 +0300
commit9de5161f9d55e4e2ece1653e6cb7decf5b3f0b9b (patch)
tree10333c1d37059db2ced3bcaf3a4d515616b4d815 /src/gui/widgets/tabs
parentb59b62516e22d599e0532e6e0f777769ccaadf4a (diff)
downloadManaVerse-9de5161f9d55e4e2ece1653e6cb7decf5b3f0b9b.tar.gz
ManaVerse-9de5161f9d55e4e2ece1653e6cb7decf5b3f0b9b.tar.bz2
ManaVerse-9de5161f9d55e4e2ece1653e6cb7decf5b3f0b9b.tar.xz
ManaVerse-9de5161f9d55e4e2ece1653e6cb7decf5b3f0b9b.zip
Simplify social tabs code.
Diffstat (limited to 'src/gui/widgets/tabs')
-rw-r--r--src/gui/widgets/tabs/skilltab.h2
-rw-r--r--src/gui/widgets/tabs/socialattacktab.h10
-rw-r--r--src/gui/widgets/tabs/socialfriendstab.h8
-rw-r--r--src/gui/widgets/tabs/socialguildtab.h8
-rw-r--r--src/gui/widgets/tabs/socialguildtab2.h8
-rw-r--r--src/gui/widgets/tabs/socialnavigationtab.h8
-rw-r--r--src/gui/widgets/tabs/socialpartytab.h8
-rw-r--r--src/gui/widgets/tabs/socialpickuptab.h8
-rw-r--r--src/gui/widgets/tabs/socialplayerstab.h8
-rw-r--r--src/gui/widgets/tabs/socialtab.h19
10 files changed, 31 insertions, 56 deletions
diff --git a/src/gui/widgets/tabs/skilltab.h b/src/gui/widgets/tabs/skilltab.h
index 5dc6fb14a..330485c40 100644
--- a/src/gui/widgets/tabs/skilltab.h
+++ b/src/gui/widgets/tabs/skilltab.h
@@ -31,6 +31,8 @@
#include "localconsts.h"
+class SkillListBox;
+
class SkillTab final : public Tab
{
public:
diff --git a/src/gui/widgets/tabs/socialattacktab.h b/src/gui/widgets/tabs/socialattacktab.h
index 6c0b6ea68..0f902caaf 100644
--- a/src/gui/widgets/tabs/socialattacktab.h
+++ b/src/gui/widgets/tabs/socialattacktab.h
@@ -28,6 +28,8 @@
#include "localconsts.h"
+class BeingsListModel;
+
#define addAvatars(mob, str, type) \
{\
ava = new Avatar(str);\
@@ -88,13 +90,7 @@ class SocialAttackTab final : public SocialTab
SocialTab(widget),
mBeings(new BeingsListModel)
{
- mList = new AvatarListBox(this, mBeings);
- mList->postInit();
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
+ createControls(mBeings, showBackground);
// TRANSLATORS: Attack filter tab name in social window.
// TRANSLATORS: Should be small
diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h
index 776fd6f4b..35d5c4215 100644
--- a/src/gui/widgets/tabs/socialfriendstab.h
+++ b/src/gui/widgets/tabs/socialfriendstab.h
@@ -64,13 +64,7 @@ class SocialFriendsTab final : public SocialTab
SocialTab(widget),
mBeings(new BeingsListModel)
{
- mList = new AvatarListBox(this, mBeings);
- mList->postInit();
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
+ createControls(mBeings, showBackground);
getPlayersAvatars();
setCaption(name);
diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h
index d88387930..4647f5f07 100644
--- a/src/gui/widgets/tabs/socialguildtab.h
+++ b/src/gui/widgets/tabs/socialguildtab.h
@@ -54,13 +54,7 @@ class SocialGuildTab final : public SocialTab,
setSelectedTabColor(&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED),
&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED_OUTLINE));
- mList = new AvatarListBox(this, guild);
- mList->postInit();
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
+ createControls(guild, showBackground);
}
A_DELETE_COPY(SocialGuildTab)
diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h
index 0ac832f6c..62d55982a 100644
--- a/src/gui/widgets/tabs/socialguildtab2.h
+++ b/src/gui/widgets/tabs/socialguildtab2.h
@@ -50,13 +50,7 @@ class SocialGuildTab2 final : public SocialTab,
setSelectedTabColor(&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED),
&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED_OUTLINE));
- mList = new AvatarListBox(this, guild);
- mList->postInit();
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
+ createControls(guild, showBackground);
}
A_DELETE_COPY(SocialGuildTab2)
diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h
index 70c92790c..1d0fbfa33 100644
--- a/src/gui/widgets/tabs/socialnavigationtab.h
+++ b/src/gui/widgets/tabs/socialnavigationtab.h
@@ -36,13 +36,7 @@ class SocialNavigationTab final : public SocialTab
SocialTab(widget),
mBeings(new BeingsListModel)
{
- mList = new AvatarListBox(this, mBeings);
- mList->postInit();
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
+ createControls(mBeings, showBackground);
// TRANSLATORS: Navigation tab name in social window.
// TRANSLATORS: Should be small
diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h
index 79209ac06..dc86fb958 100644
--- a/src/gui/widgets/tabs/socialpartytab.h
+++ b/src/gui/widgets/tabs/socialpartytab.h
@@ -54,13 +54,7 @@ class SocialPartyTab final : public SocialTab,
setSelectedTabColor(&getThemeColor(Theme::PARTY_SOCIAL_TAB_SELECTED),
&getThemeColor(Theme::PARTY_SOCIAL_TAB_SELECTED_OUTLINE));
- mList = new AvatarListBox(this, party);
- mList->postInit();
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
+ createControls(party, showBackground);
}
A_DELETE_COPY(SocialPartyTab)
diff --git a/src/gui/widgets/tabs/socialpickuptab.h b/src/gui/widgets/tabs/socialpickuptab.h
index 28a83ed0b..ddf9924b1 100644
--- a/src/gui/widgets/tabs/socialpickuptab.h
+++ b/src/gui/widgets/tabs/socialpickuptab.h
@@ -36,13 +36,7 @@ class SocialPickupTab final : public SocialTab
SocialTab(widget),
mBeings(new BeingsListModel)
{
- mList = new AvatarListBox(this, mBeings);
- mList->postInit();
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
+ createControls(mBeings, showBackground);
// TRANSLATORS: Pickup filter tab name in social window. Should be small
setCaption(_("Pik"));
diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h
index 5e625b06e..2026a6346 100644
--- a/src/gui/widgets/tabs/socialplayerstab.h
+++ b/src/gui/widgets/tabs/socialplayerstab.h
@@ -34,13 +34,7 @@ class SocialPlayersTab final : public SocialTab
SocialTab(widget),
mBeings(new BeingsListModel)
{
- mList = new AvatarListBox(this, mBeings);
- mList->postInit();
- mScroll = new ScrollArea(this, mList, showBackground,
- "social_background.xml");
-
- mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
- mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
+ createControls(mBeings, showBackground);
getPlayersAvatars();
setCaption(name);
diff --git a/src/gui/widgets/tabs/socialtab.h b/src/gui/widgets/tabs/socialtab.h
index 433655c9d..5ba8e9884 100644
--- a/src/gui/widgets/tabs/socialtab.h
+++ b/src/gui/widgets/tabs/socialtab.h
@@ -24,10 +24,17 @@
#include "gui/windows/socialwindow.h"
+#include "gui/widgets/avatarlistbox.h"
+#include "gui/widgets/scrollarea.h"
+
#include "gui/widgets/tabs/tab.h"
#include "localconsts.h"
+class AvatarListModel;
+class ConfirmDialog;
+class TextDialog;
+
class SocialTab : public Tab
{
public:
@@ -93,6 +100,18 @@ class SocialTab : public Tab
}
}
+ void createControls(AvatarListModel *const listModel,
+ const bool showBackground)
+ {
+ mList = new AvatarListBox(this, listModel);
+ mList->postInit();
+ mScroll = new ScrollArea(this, mList, showBackground,
+ "social_background.xml");
+
+ mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO);
+ mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
+ }
+
void setCurrent() override final
{
updateCounter();