deprecated ADD_SORTED due to n^2 behavior, set the sort order on the scroll list instead

master
Richard Nelson 2010-08-04 19:01:18 -07:00
parent bd20eddd4e
commit 5062351a0a
16 changed files with 36 additions and 41 deletions

View File

@ -119,8 +119,8 @@ enum EObjectPropertiesExtraID
enum EAddPosition
{
ADD_TOP,
ADD_SORTED,
ADD_BOTTOM
ADD_BOTTOM,
ADD_DEFAULT
};
enum LLGroupChange

View File

@ -541,23 +541,7 @@ BOOL LLScrollListCtrl::addItem( LLScrollListItem* item, EAddPosition pos, BOOL r
setNeedsSort();
break;
case ADD_SORTED:
{
// sort by column 0, in ascending order
std::vector<sort_column_t> single_sort_column;
single_sort_column.push_back(std::make_pair(0, TRUE));
mItemList.push_back(item);
std::stable_sort(
mItemList.begin(),
mItemList.end(),
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
setNeedsSort();
break;
}
case ADD_DEFAULT:
case ADD_BOTTOM:
mItemList.push_back(item);
setNeedsSort();
@ -2762,9 +2746,10 @@ LLScrollListColumn* LLScrollListCtrl::getColumn(const std::string& name)
return NULL;
}
LLFastTimer::DeclareTimer FTM_ADD_SCROLLLIST_ELEMENT("Add Scroll List Item");
LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition pos, void* userdata)
{
LLFastTimer _(FTM_ADD_SCROLLLIST_ELEMENT);
LLScrollListItem::Params item_params;
LLParamSDParser::instance().readSD(element, item_params);
item_params.userdata = userdata;
@ -2773,12 +2758,14 @@ LLScrollListItem* LLScrollListCtrl::addElement(const LLSD& element, EAddPosition
LLScrollListItem* LLScrollListCtrl::addRow(const LLScrollListItem::Params& item_p, EAddPosition pos)
{
LLFastTimer _(FTM_ADD_SCROLLLIST_ELEMENT);
LLScrollListItem *new_item = new LLScrollListItem(item_p);
return addRow(new_item, item_p, pos);
}
LLScrollListItem* LLScrollListCtrl::addRow(LLScrollListItem *new_item, const LLScrollListItem::Params& item_p, EAddPosition pos)
{
LLFastTimer _(FTM_ADD_SCROLLLIST_ELEMENT);
if (!item_p.validateBlock() || !new_item) return NULL;
new_item->setNumColumns(mColumns.size());

View File

@ -347,11 +347,10 @@ void LLPanelGroups::onGroupList(LLUICtrl* ctrl, void* userdata)
if(self) self->enableButtons();
}
void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 powers_mask)
void init_group_list(LLScrollListCtrl* group_list, const LLUUID& highlight_id, U64 powers_mask)
{
S32 count = gAgent.mGroups.count();
LLUUID id;
LLCtrlListInterface *group_list = ctrl->getListInterface();
if (!group_list) return;
group_list->operateOnAll(LLCtrlListInterface::OP_DELETE);
@ -375,10 +374,12 @@ void init_group_list(LLScrollListCtrl* ctrl, const LLUUID& highlight_id, U64 pow
element["columns"][0]["font"]["name"] = "SANSSERIF";
element["columns"][0]["font"]["style"] = style;
group_list->addElement(element, ADD_SORTED);
group_list->addElement(element);
}
}
group_list->sortOnce(0, TRUE);
// add "none" to list at top
{
std::string style = "NORMAL";

View File

@ -2440,7 +2440,7 @@ void LLPanelLandAccess::refresh()
suffix.append(" " + parent_floater->getString("Remaining") + ")");
}
if (mListAccess)
mListAccess->addNameItem(entry.mID, ADD_SORTED, TRUE, suffix);
mListAccess->addNameItem(entry.mID, ADD_DEFAULT, TRUE, suffix);
}
}
@ -2481,7 +2481,7 @@ void LLPanelLandAccess::refresh()
}
suffix.append(" " + parent_floater->getString("Remaining") + ")");
}
mListBanned->addNameItem(entry.mID, ADD_SORTED, TRUE, suffix);
mListBanned->addNameItem(entry.mID, ADD_DEFAULT, TRUE, suffix);
}
}

View File

@ -75,10 +75,9 @@ BOOL LLFloaterLandHoldings::postBuild()
childSetAction("Show on Map", onClickMap, this);
// Grant list
getChild<LLScrollListCtrl>("grant list")->setDoubleClickCallback(onGrantList, this);
LLCtrlListInterface *list = childGetListInterface("grant list");
if (!list) return TRUE;
LLScrollListCtrl* grant_list = getChild<LLScrollListCtrl>("grant list");
grant_list->sortByColumnIndex(0, TRUE);
grant_list->setDoubleClickCallback(onGrantList, this);
S32 count = gAgent.mGroups.count();
for(S32 i = 0; i < count; ++i)
@ -97,7 +96,7 @@ BOOL LLFloaterLandHoldings::postBuild()
element["columns"][1]["value"] = areastr;
element["columns"][1]["font"] = "SANSSERIF";
list->addElement(element, ADD_SORTED);
grant_list->addElement(element);
}
center();

View File

@ -105,6 +105,7 @@ BOOL LLFloaterMediaBrowser::postBuild()
mAddressCombo = getChild<LLComboBox>("address");
mAddressCombo->setCommitCallback(onEnterAddress, this);
mAddressCombo->sortByName();
childSetAction("back", onClickBack, this);
childSetAction("forward", onClickForward, this);
@ -185,7 +186,7 @@ void LLFloaterMediaBrowser::setCurrentURL(const std::string& url)
if (mCurrentURL != "about:blank")
{
mAddressCombo->remove(mCurrentURL);
mAddressCombo->add(mCurrentURL, ADD_SORTED);
mAddressCombo->add(mCurrentURL);
mAddressCombo->selectByValue(mCurrentURL);
// Serialize url history

View File

@ -826,13 +826,11 @@ void LLFloaterPreference::buildPopupLists()
row["columns"][1]["font"] = "SANSSERIF_SMALL";
row["columns"][1]["width"] = 360;
}
item = disabled_popups.addElement(row,
ADD_SORTED);
item = disabled_popups.addElement(row);
}
else
{
item = enabled_popups.addElement(row,
ADD_SORTED);
item = enabled_popups.addElement(row);
}
if (item)

View File

@ -741,7 +741,7 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content)
}
element["columns"][5]["font"] = "SANSSERIF";
list->addElement(element, ADD_SORTED);
list->addElement(element);
element["owner_id"] = owner_id;
element["local_id"] = local_id;

View File

@ -746,7 +746,7 @@ void LLPanelGroupGeneral::updateMembers()
sSDTime += sd_timer.getElapsedTimeF32();
element_timer.reset();
LLScrollListItem* member_row = mListVisibleMembers->addElement(row);//, ADD_SORTED);
LLScrollListItem* member_row = mListVisibleMembers->addElement(row);
if ( member->isOwner() )
{

View File

@ -528,7 +528,7 @@ void LLPanelGroupLandMoney::impl::processGroupLand(LLMessageSystem* msg)
row["columns"][4]["column"] = "hidden";
row["columns"][4]["value"] = hidden;
mGroupParcelsp->addElement(row, ADD_SORTED);
mGroupParcelsp->addElement(row);
}
}
}

View File

@ -1631,7 +1631,7 @@ void LLPanelGroupMembersSubTab::updateMembers()
row["columns"][2]["value"] = mMemberProgress->second->getOnlineStatus();
row["columns"][2]["font"] = "SANSSERIF_SMALL";
LLScrollListItem* member = mMembersList->addElement(row);//, ADD_SORTED);
LLScrollListItem* member = mMembersList->addElement(row);
LLUUID id = member->getUUID();
mHasMatch = TRUE;

View File

@ -1110,9 +1110,10 @@ void LLPanelLogin::updateServerCombo()
{
if (!grid_choice->first.empty())
{
server_choice_combo->add(grid_choice->second, grid_choice->first, ADD_SORTED);
server_choice_combo->add(grid_choice->second, grid_choice->first);
}
}
server_choice_combo->sortByName();
server_choice_combo->addSeparator(ADD_TOP);

View File

@ -1171,7 +1171,7 @@ void LLPanelPrimMediaControls::setCurrentURL()
// if (media_address_combo && mCurrentURL != "about:blank")
// {
// media_address_combo->remove(mCurrentURL);
// media_address_combo->add(mCurrentURL, ADD_SORTED);
// media_address_combo->add(mCurrentURL);
// media_address_combo->selectByValue(mCurrentURL);
// }
#else // USE_COMBO_BOX_FOR_MEDIA_URL

View File

@ -60,6 +60,8 @@
left="0"
right="-1"
top="0"
sort_column="0"
sort_ascending="true"
name="group_parcel_list"
width="313">
<scroll_list.columns

View File

@ -57,6 +57,8 @@
left="10"
multi_select="true"
name="enabled_popups"
sort_column="0"
sort_ascending="true"
width="495" />
<button
enabled_control="FirstSelectedDisabledPopups"
@ -103,6 +105,8 @@
height="140"
layout="topleft"
left="10"
sort_column="0"
sort_ascending="true"
multi_select="true"
name="disabled_popups"
width="495" />

View File

@ -79,6 +79,8 @@
layout="topleft"
left_delta="0"
multi_select="true"
sort_column="0"
sort_ascending="true"
name="scripts_list"
top_delta="16"
width="460">