Skip to content
Snippets Groups Projects
Commit d1751df1 authored by Sergei Litovchuk's avatar Sergei Litovchuk
Browse files

EXT-7610 FIXED Added sorting outfit tabs by name (case insensitive).

Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/523/.

--HG--
branch : product-engine
parent 65f8d182
No related branches found
No related tags found
No related merge requests found
...@@ -66,6 +66,7 @@ LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params) ...@@ -66,6 +66,7 @@ LLAccordionCtrl::LLAccordionCtrl(const Params& params):LLPanel(params)
, mAutoScrolling( false ) , mAutoScrolling( false )
, mAutoScrollRate( 0.f ) , mAutoScrollRate( 0.f )
, mSelectedTab( NULL ) , mSelectedTab( NULL )
, mTabComparator( NULL )
, mNoVisibleTabsHelpText(NULL) , mNoVisibleTabsHelpText(NULL)
{ {
initNoTabsWidget(params.empty_accordion_text); initNoTabsWidget(params.empty_accordion_text);
...@@ -799,6 +800,18 @@ void LLAccordionCtrl::reset () ...@@ -799,6 +800,18 @@ void LLAccordionCtrl::reset ()
mScrollbar->setDocPos(0); mScrollbar->setDocPos(0);
} }
void LLAccordionCtrl::sort()
{
if (!mTabComparator)
{
llwarns << "No comparator specified for sorting accordion tabs." << llendl;
return;
}
std::sort(mAccordionTabs.begin(), mAccordionTabs.end(), LLComparatorAdaptor(*mTabComparator));
arrange();
}
void LLAccordionCtrl::setFilterSubString(const std::string& filter_string) void LLAccordionCtrl::setFilterSubString(const std::string& filter_string)
{ {
LLStringUtil::format_map_t args; LLStringUtil::format_map_t args;
......
...@@ -57,6 +57,19 @@ class LLAccordionCtrl: public LLPanel ...@@ -57,6 +57,19 @@ class LLAccordionCtrl: public LLPanel
public: public:
/**
* Abstract comparator for accordion tabs.
*/
class LLTabComparator
{
public:
LLTabComparator() {};
virtual ~LLTabComparator() {};
/** Returns true if tab1 < tab2, false otherwise */
virtual bool compare(const LLAccordionCtrlTab* tab1, const LLAccordionCtrlTab* tab2) const = 0;
};
struct Params struct Params
: public LLInitParam::Block<Params, LLPanel::Params> : public LLInitParam::Block<Params, LLPanel::Params>
{ {
...@@ -108,6 +121,9 @@ class LLAccordionCtrl: public LLPanel ...@@ -108,6 +121,9 @@ class LLAccordionCtrl: public LLPanel
void reset (); void reset ();
void setComparator(const LLTabComparator* comp) { mTabComparator = comp; }
void sort();
/** /**
* Sets filter substring as a search_term for help text when there are no any visible tabs. * Sets filter substring as a search_term for help text when there are no any visible tabs.
*/ */
...@@ -134,6 +150,21 @@ class LLAccordionCtrl: public LLPanel ...@@ -134,6 +150,21 @@ class LLAccordionCtrl: public LLPanel
BOOL autoScroll (S32 x, S32 y); BOOL autoScroll (S32 x, S32 y);
/**
* An adaptor for LLTabComparator
*/
struct LLComparatorAdaptor
{
LLComparatorAdaptor(const LLTabComparator& comparator) : mComparator(comparator) {};
bool operator()(const LLAccordionCtrlTab* tab1, const LLAccordionCtrlTab* tab2)
{
return mComparator.compare(tab1, tab2);
}
const LLTabComparator& mComparator;
};
private: private:
LLRect mInnerRect; LLRect mInnerRect;
LLScrollbar* mScrollbar; LLScrollbar* mScrollbar;
...@@ -141,9 +172,11 @@ class LLAccordionCtrl: public LLPanel ...@@ -141,9 +172,11 @@ class LLAccordionCtrl: public LLPanel
bool mFitParent; bool mFitParent;
bool mAutoScrolling; bool mAutoScrolling;
F32 mAutoScrollRate; F32 mAutoScrollRate;
LLAccordionCtrlTab* mSelectedTab;
LLTextBox* mNoVisibleTabsHelpText; LLTextBox* mNoVisibleTabsHelpText;
std::string mNoVisibleTabsOrigString; std::string mNoVisibleTabsOrigString;
LLAccordionCtrlTab* mSelectedTab;
const LLTabComparator* mTabComparator;
}; };
......
...@@ -473,7 +473,7 @@ void LLAccordionCtrlTab::setAccordionView(LLView* panel) ...@@ -473,7 +473,7 @@ void LLAccordionCtrlTab::setAccordionView(LLView* panel)
addChild(panel,0); addChild(panel,0);
} }
std::string LLAccordionCtrlTab::getTitle() std::string LLAccordionCtrlTab::getTitle() const
{ {
LLAccordionCtrlTabHeader* header = findChild<LLAccordionCtrlTabHeader>(DD_HEADER_NAME); LLAccordionCtrlTabHeader* header = findChild<LLAccordionCtrlTabHeader>(DD_HEADER_NAME);
if (header) if (header)
......
...@@ -115,7 +115,7 @@ class LLAccordionCtrlTab : public LLUICtrl ...@@ -115,7 +115,7 @@ class LLAccordionCtrlTab : public LLUICtrl
void setAccordionView(LLView* panel); void setAccordionView(LLView* panel);
LLView* getAccordionView() { return mContainerPanel; }; LLView* getAccordionView() { return mContainerPanel; };
std::string getTitle(); std::string getTitle() const;
// Set text and highlight substring in LLAccordionCtrlTabHeader // Set text and highlight substring in LLAccordionCtrlTabHeader
void setTitle(const std::string& title, const std::string& hl = LLStringUtil::null); void setTitle(const std::string& title, const std::string& hl = LLStringUtil::null);
......
...@@ -53,6 +53,20 @@ ...@@ -53,6 +53,20 @@
static bool is_tab_header_clicked(LLAccordionCtrlTab* tab, S32 y); static bool is_tab_header_clicked(LLAccordionCtrlTab* tab, S32 y);
static const LLOutfitTabNameComparator OUTFIT_TAB_NAME_COMPARATOR;
/*virtual*/
bool LLOutfitTabNameComparator::compare(const LLAccordionCtrlTab* tab1, const LLAccordionCtrlTab* tab2) const
{
std::string name1 = tab1->getTitle();
std::string name2 = tab2->getTitle();
LLStringUtil::toUpper(name1);
LLStringUtil::toUpper(name2);
return name1 < name2;
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class OutfitContextMenu : public LLListContextMenu class OutfitContextMenu : public LLListContextMenu
...@@ -158,6 +172,7 @@ LLOutfitsList::~LLOutfitsList() ...@@ -158,6 +172,7 @@ LLOutfitsList::~LLOutfitsList()
BOOL LLOutfitsList::postBuild() BOOL LLOutfitsList::postBuild()
{ {
mAccordion = getChild<LLAccordionCtrl>("outfits_accordion"); mAccordion = getChild<LLAccordionCtrl>("outfits_accordion");
mAccordion->setComparator(&OUTFIT_TAB_NAME_COMPARATOR);
return TRUE; return TRUE;
} }
...@@ -328,7 +343,7 @@ void LLOutfitsList::refreshList(const LLUUID& category_id) ...@@ -328,7 +343,7 @@ void LLOutfitsList::refreshList(const LLUUID& category_id)
updateOutfitTab(*items_iter); updateOutfitTab(*items_iter);
} }
mAccordion->arrange(); mAccordion->sort();
} }
void LLOutfitsList::onSelectionChange(LLUICtrl* ctrl) void LLOutfitsList::onSelectionChange(LLUICtrl* ctrl)
......
...@@ -32,17 +32,33 @@ ...@@ -32,17 +32,33 @@
#ifndef LL_LLOUTFITSLIST_H #ifndef LL_LLOUTFITSLIST_H
#define LL_LLOUTFITSLIST_H #define LL_LLOUTFITSLIST_H
#include "llaccordionctrl.h"
#include "llpanel.h" #include "llpanel.h"
// newview // newview
#include "llinventorymodel.h" #include "llinventorymodel.h"
#include "llinventoryobserver.h" #include "llinventoryobserver.h"
class LLAccordionCtrl;
class LLAccordionCtrlTab; class LLAccordionCtrlTab;
class LLWearableItemsList; class LLWearableItemsList;
class LLListContextMenu; class LLListContextMenu;
/**
* @class LLOutfitTabNameComparator
*
* Comparator of outfit tabs.
*/
class LLOutfitTabNameComparator : public LLAccordionCtrl::LLTabComparator
{
LOG_CLASS(LLOutfitTabNameComparator);
public:
LLOutfitTabNameComparator() {};
virtual ~LLOutfitTabNameComparator() {};
/*virtual*/ bool compare(const LLAccordionCtrlTab* tab1, const LLAccordionCtrlTab* tab2) const;
};
/** /**
* @class LLOutfitsList * @class LLOutfitsList
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment