summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelexperiences.cpp
diff options
context:
space:
mode:
authorCho <cho@lindenlab.com>2014-06-27 01:02:44 +0100
committerCho <cho@lindenlab.com>2014-06-27 01:02:44 +0100
commitf80a41cf36f023aa0b5a7368d81dd237dafc8d4a (patch)
tree1a4882da38a185fee1b13b2c207eef7147a0d458 /indra/newview/llpanelexperiences.cpp
parent8ab5a25b12cb059c7408721ff5cf9556b47fb94a (diff)
Sort experiences in list alphabetically by name for ACME-1537
Diffstat (limited to 'indra/newview/llpanelexperiences.cpp')
-rw-r--r--indra/newview/llpanelexperiences.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/indra/newview/llpanelexperiences.cpp b/indra/newview/llpanelexperiences.cpp
index 0d67dbf916..2885ef9305 100644
--- a/indra/newview/llpanelexperiences.cpp
+++ b/indra/newview/llpanelexperiences.cpp
@@ -38,9 +38,13 @@
#include "lllayoutstack.h"
+
static LLPanelInjector<LLPanelExperiences> register_experiences_panel("experiences_panel");
+//comparators
+static const LLExperienceItemComparator NAME_COMPARATOR;
+
LLPanelExperiences::LLPanelExperiences( )
: mExperiencesList(NULL)
{
@@ -54,6 +58,7 @@ BOOL LLPanelExperiences::postBuild( void )
{
mExperiencesList->setNoItemsCommentText(getString("no_experiences"));
}
+ mExperiencesList->setComparator(&NAME_COMPARATOR);
return TRUE;
}
@@ -81,6 +86,8 @@ void LLPanelExperiences::setExperienceList( const LLSD& experiences )
item->init(public_key);
mExperiencesList->addItem(item, public_key);
}
+
+ mExperiencesList->sort();
}
LLPanelExperiences* LLPanelExperiences::create(const std::string& name)
@@ -112,6 +119,7 @@ void LLPanelExperiences::addExperience( const LLUUID& id )
item->init(id);
mExperiencesList->addItem(item, id);
+ mExperiencesList->sort();
}
}
@@ -137,21 +145,32 @@ void LLPanelExperiences::enableButton( bool enable )
LLExperienceItem::LLExperienceItem()
+ : mName(NULL)
{
buildFromFile("panel_experience_list_item.xml");
}
void LLExperienceItem::init( const LLUUID& id)
{
- getChild<LLUICtrl>("experience_name")->setValue(LLSLURL("experience", id, "profile").getSLURLString());
+ mName = getChild<LLUICtrl>("experience_name");
+ mName->setValue(LLSLURL("experience", id, "profile").getSLURLString());
}
-
LLExperienceItem::~LLExperienceItem()
{
}
+std::string LLExperienceItem::getExperienceName() const
+{
+ if (mName)
+ {
+ return mName->getValue();
+ }
+
+ return "";
+}
+
void LLPanelSearchExperiences::doSearch()
{
@@ -169,3 +188,23 @@ BOOL LLPanelSearchExperiences::postBuild( void )
childSetAction("search_button", boost::bind(&LLPanelSearchExperiences::doSearch, this));
return TRUE;
}
+
+bool LLExperienceItemComparator::compare(const LLPanel* item1, const LLPanel* item2) const
+{
+ const LLExperienceItem* experience_item1 = dynamic_cast<const LLExperienceItem*>(item1);
+ const LLExperienceItem* experience_item2 = dynamic_cast<const LLExperienceItem*>(item2);
+
+ if (!experience_item1 || !experience_item2)
+ {
+ LL_ERRS() << "item1 and item2 cannot be null" << LL_ENDL;
+ return true;
+ }
+
+ std::string name1 = experience_item1->getExperienceName();
+ std::string name2 = experience_item2->getExperienceName();
+
+ LLStringUtil::toUpper(name1);
+ LLStringUtil::toUpper(name2);
+
+ return name1 < name2;
+}