From 3f921251eec6e2560f3f539c8314442ef280d3d0 Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Thu, 18 Jul 2019 18:55:52 -0400 Subject: [PATCH] Add getAllIDs to LLScrollListCtrl, and make getSelectedIDs a little better --- indra/llui/llscrolllistctrl.cpp | 19 +++++++++++++++---- indra/llui/llscrolllistctrl.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 2d84791b1..04c635f2a 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -312,12 +312,12 @@ std::vector LLScrollListCtrl::getAllSelected() const uuid_vec_t LLScrollListCtrl::getSelectedIDs() { - LLUUID selected_id; uuid_vec_t ids; - std::vector selected = this->getAllSelected(); - for(std::vector::iterator itr = selected.begin(); itr != selected.end(); ++itr) + if (!getCanSelect()) return ids; + + for(const auto& item : mItemList) { - ids.push_back((*itr)->getUUID()); + if (item->getSelected()) ids.push_back(item->getUUID()); } return ids; } @@ -400,6 +400,17 @@ std::vector LLScrollListCtrl::getAllData() const return ret; } +uuid_vec_t LLScrollListCtrl::getAllIDs() const +{ + uuid_vec_t ret; + ret.reserve(mItemList.size()); //Optimization + for(const auto& item : mItemList) + { + ret.push_back(item->getUUID()); + } + return ret; +} + // returns first matching item LLScrollListItem* LLScrollListCtrl::getItem(const LLSD& sd) const { diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index 3a2adf5c6..d5ffb9df9 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -207,6 +207,7 @@ public: LLScrollListItem* getFirstData() const; LLScrollListItem* getLastData() const; std::vector getAllData() const; + uuid_vec_t getAllIDs() const; //Helper. Much like getAllData, but just provides a LLUUID vec LLScrollListItem* getItem(const LLSD& sd) const;