summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llui/llscrolllistctrl.cpp26
-rw-r--r--indra/llui/llscrolllistctrl.h35
-rw-r--r--indra/newview/llgroupmgr.cpp3
-rw-r--r--indra/newview/llpanelgroupgeneral.cpp16
-rw-r--r--indra/newview/llpanelgroupgeneral.h3
5 files changed, 76 insertions, 7 deletions
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index ac4811210b..77caaaa425 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -71,8 +71,9 @@ static LLDefaultChildRegistry::Register<LLScrollListCtrl> r("scroll_list");
// local structures & classes.
struct SortScrollListItem
{
- SortScrollListItem(const std::vector<std::pair<S32, BOOL> >& sort_orders)
+ SortScrollListItem(const std::vector<std::pair<S32, BOOL> >& sort_orders,const LLScrollListCtrl::sort_signal_t* sort_signal)
: mSortOrders(sort_orders)
+ , mSortSignal(sort_signal)
{}
bool operator()(const LLScrollListItem* i1, const LLScrollListItem* i2)
@@ -85,12 +86,20 @@ struct SortScrollListItem
S32 col_idx = it->first;
BOOL sort_ascending = it->second;
+ S32 order = sort_ascending ? 1 : -1; // ascending or descending sort for this column?
+
const LLScrollListCell *cell1 = i1->getColumn(col_idx);
const LLScrollListCell *cell2 = i2->getColumn(col_idx);
- S32 order = sort_ascending ? 1 : -1; // ascending or descending sort for this column?
if (cell1 && cell2)
{
- sort_result = order * LLStringUtil::compareDict(cell1->getValue().asString(), cell2->getValue().asString());
+ if(mSortSignal)
+ {
+ sort_result = order * (*mSortSignal)(col_idx,i1, i2);
+ }
+ else
+ {
+ sort_result = order * LLStringUtil::compareDict(cell1->getValue().asString(), cell2->getValue().asString());
+ }
if (sort_result != 0)
{
break; // we have a sort order!
@@ -100,8 +109,10 @@ struct SortScrollListItem
return sort_result < 0;
}
+
typedef std::vector<std::pair<S32, BOOL> > sort_order_t;
+ const LLScrollListCtrl::sort_signal_t* mSortSignal;
const sort_order_t& mSortOrders;
};
@@ -169,6 +180,7 @@ LLScrollListCtrl::LLScrollListCtrl(const LLScrollListCtrl::Params& p)
mOnSortChangedCallback( NULL ),
mHighlightedItem(-1),
mBorder(NULL),
+ mSortCallback(NULL),
mPopupMenu(NULL),
mNumDynamicWidthColumns(0),
mTotalStaticColumnWidth(0),
@@ -309,6 +321,8 @@ bool LLScrollListCtrl::preProcessChildNode(LLXMLNodePtr child)
LLScrollListCtrl::~LLScrollListCtrl()
{
+ delete mSortCallback;
+
std::for_each(mItemList.begin(), mItemList.end(), DeletePointer());
if( gEditMenuHandler == this )
@@ -540,7 +554,7 @@ BOOL LLScrollListCtrl::addItem( LLScrollListItem* item, EAddPosition pos, BOOL r
std::stable_sort(
mItemList.begin(),
mItemList.end(),
- SortScrollListItem(single_sort_column));
+ SortScrollListItem(single_sort_column,mSortCallback));
// ADD_SORTED just sorts by first column...
// this might not match user sort criteria, so flag list as being in unsorted state
@@ -2395,7 +2409,7 @@ void LLScrollListCtrl::updateSort() const
std::stable_sort(
mItemList.begin(),
mItemList.end(),
- SortScrollListItem(mSortColumns));
+ SortScrollListItem(mSortColumns,mSortCallback));
mSorted = true;
}
@@ -2411,7 +2425,7 @@ void LLScrollListCtrl::sortOnce(S32 column, BOOL ascending)
std::stable_sort(
mItemList.begin(),
mItemList.end(),
- SortScrollListItem(sort_column));
+ SortScrollListItem(sort_column,mSortCallback));
}
void LLScrollListCtrl::dirtyColumns()
diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h
index d2d2379328..bfff85315d 100644
--- a/indra/llui/llscrolllistctrl.h
+++ b/indra/llui/llscrolllistctrl.h
@@ -73,6 +73,32 @@ public:
// *TODO: Add callbacks to Params
typedef boost::function<void (void)> callback_t;
+
+ template<typename T> struct maximum
+ {
+ typedef T result_type;
+
+ template<typename InputIterator>
+ T operator()(InputIterator first, InputIterator last) const
+ {
+ // If there are no slots to call, just return the
+ // default-constructed value
+ if(first == last ) return T();
+ T max_value = *first++;
+ while (first != last) {
+ if (max_value < *first)
+ max_value = *first;
+ ++first;
+ }
+
+ return max_value;
+ }
+ };
+
+
+ //typedef boost::signals2::signal<void (S32,const LLScrollListItem*,const LLScrollListItem*),maximum<S32>> sort_signal_t;
+ //typedef boost::signals2::signal<void (S32,const LLScrollListItem*,const LLScrollListItem*)> sort_signal_t;
+ typedef boost::signals2::signal<S32 (S32,const LLScrollListItem*,const LLScrollListItem*),maximum<S32>> sort_signal_t;
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
{
@@ -362,6 +388,13 @@ public:
void setNeedsSort(bool val = true) { mSorted = !val; }
void dirtyColumns(); // some operation has potentially affected column layout or ordering
+ boost::signals2::connection setSortCallback(sort_signal_t::slot_type cb )
+ {
+ if (!mSortCallback) mSortCallback = new sort_signal_t();
+ return mSortCallback->connect(cb);
+ }
+
+
protected:
// "Full" interface: use this when you're creating a list that has one or more of the following:
// * contains icons
@@ -474,6 +507,8 @@ private:
typedef std::pair<S32, BOOL> sort_column_t;
std::vector<sort_column_t> mSortColumns;
+
+ sort_signal_t* mSortCallback;
}; // end class LLScrollListCtrl
#endif // LL_SCROLLLISTCTRL_H
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp
index 6e7321f739..ea5462a3e3 100644
--- a/indra/newview/llgroupmgr.cpp
+++ b/indra/newview/llgroupmgr.cpp
@@ -838,7 +838,8 @@ static void formatDateString(std::string &date_string)
std::string day = result[2];
// ISO 8601 date format
- date_string = llformat("%02s/%02s/%04s", month.c_str(), day.c_str(), year.c_str());
+ //date_string = llformat("%02s/%02s/%04s", month.c_str(), day.c_str(), year.c_str());
+ date_string = llformat("%04s/%02s/%04s", year.c_str(), month.c_str(), day.c_str());
}
}
diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index 555e277ce5..517204b232 100644
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -111,6 +111,8 @@ BOOL LLPanelGroupGeneral::postBuild()
{
mListVisibleMembers->setDoubleClickCallback(openProfile, this);
mListVisibleMembers->setContextMenu(LLScrollListCtrl::MENU_AVATAR);
+
+ mListVisibleMembers->setSortCallback(boost::bind(&LLPanelGroupGeneral::sortMembersList,this,_1,_2,_3));
}
// Options
@@ -944,4 +946,18 @@ void LLPanelGroupGeneral::setGroupID(const LLUUID& id)
activate();
}
+S32 LLPanelGroupGeneral::sortMembersList(S32 col_idx,const LLScrollListItem* i1,const LLScrollListItem* i2)
+{
+ const LLScrollListCell *cell1 = i1->getColumn(col_idx);
+ const LLScrollListCell *cell2 = i2->getColumn(col_idx);
+
+ if(col_idx == 2)
+ {
+ if(LLStringUtil::compareDict(cell1->getValue().asString(),"Online") == 0 )
+ return 1;
+ if(LLStringUtil::compareDict(cell2->getValue().asString(),"Online") == 0 )
+ return -1;
+ }
+ return LLStringUtil::compareDict(cell1->getValue().asString(), cell2->getValue().asString());
+}
diff --git a/indra/newview/llpanelgroupgeneral.h b/indra/newview/llpanelgroupgeneral.h
index 7e90e43cf9..cc3101539a 100644
--- a/indra/newview/llpanelgroupgeneral.h
+++ b/indra/newview/llpanelgroupgeneral.h
@@ -83,6 +83,9 @@ private:
static void onReceiveNotices(LLUICtrl* ctrl, void* data);
static void openProfile(void* data);
+ S32 sortMembersList(S32,const LLScrollListItem*,const LLScrollListItem*);
+ //void sortMembersList(S32 column);
+
static bool joinDlgCB(const LLSD& notification, const LLSD& response);
void updateMembers();