From db00dcd9658a253eecb2653d72da37a48870796b Mon Sep 17 00:00:00 2001 From: Ansariel Date: Fri, 3 Mar 2017 21:15:02 +0100 Subject: [PATCH] Get rid of magic numbers --- indra/newview/fspanelblocklist.cpp | 20 ++++++++++---------- indra/newview/fspanelblocklist.h | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/indra/newview/fspanelblocklist.cpp b/indra/newview/fspanelblocklist.cpp index 76a2d96369..adc1c8cc73 100644 --- a/indra/newview/fspanelblocklist.cpp +++ b/indra/newview/fspanelblocklist.cpp @@ -93,7 +93,7 @@ BOOL FSPanelBlockList::postBuild() mBlockedList->setDoubleClickCallback(boost::bind(&FSPanelBlockList::showProfile, this)); mBlockedList->setSearchColumn(mBlockedList->getColumn("item_name")->mIndex); mBlockedList->setContextMenu(&gFSBlockListMenu); - mBlockedList->setFilterColumn(0); + mBlockedList->setFilterColumn(COL_NAME); mBlockedList->setSortChangedCallback(boost::bind(&FSPanelBlockList::onSortChanged, this)); getChild("unblock_btn")->setCommitCallback(boost::bind(&FSPanelBlockList::removeMutes, this)); @@ -211,8 +211,8 @@ void FSPanelBlockList::removeMutes() std::vector selected_items = mBlockedList->getAllSelected(); for (std::vector::iterator it = selected_items.begin(); it != selected_items.end(); it++) { - std::string name = (*it)->getColumn(0)->getValue().asString(); - LLUUID id = (*it)->getColumn(3)->getValue().asUUID(); + std::string name = (*it)->getColumn(COL_NAME)->getValue().asString(); + LLUUID id = (*it)->getColumn(COL_UUID)->getValue().asUUID(); LLMute mute(id, name); LLMuteList::getInstance()->remove(mute); } @@ -320,7 +320,7 @@ bool FSPanelBlockList::isActionChecked(const LLSD& userdata) return false; } - LLUUID blocked_id = mBlockedList->getFirstSelected()->getColumn(3)->getValue().asUUID(); + LLUUID blocked_id = mBlockedList->getFirstSelected()->getColumn(COL_UUID)->getValue().asUUID(); if ("block_voice" == command_name) { @@ -357,7 +357,7 @@ bool FSPanelBlockList::isActionEnabled(const LLSD& userdata) || "block_obj_sounds" == command_name) { return (mBlockedList->getNumSelected() == 1 && - (LLMute::EType)mBlockedList->getFirstSelected()->getColumn(2)->getValue().asInteger() == LLMute::AGENT); + (LLMute::EType)mBlockedList->getFirstSelected()->getColumn(COL_TYPE)->getValue().asInteger() == LLMute::AGENT); } return false; @@ -372,7 +372,7 @@ bool FSPanelBlockList::isActionVisible(const LLSD& userdata) || "block_particles" == command_name || "block_obj_sounds" == command_name) { - return mBlockedList->getNumSelected() == 1 && (LLMute::AGENT == (LLMute::EType)mBlockedList->getFirstSelected()->getColumn(2)->getValue().asInteger()); + return mBlockedList->getNumSelected() == 1 && (LLMute::AGENT == (LLMute::EType)mBlockedList->getFirstSelected()->getColumn(COL_TYPE)->getValue().asInteger()); } return false; @@ -386,9 +386,9 @@ void FSPanelBlockList::toggleMute(U32 flags) return; } - LLMute mute(item->getColumn(3)->getValue().asUUID(), item->getColumn(0)->getValue().asString(), (LLMute::EType)item->getColumn(2)->getValue().asInteger()); + LLMute mute(item->getColumn(COL_UUID)->getValue().asUUID(), item->getColumn(COL_NAME)->getValue().asString(), (LLMute::EType)item->getColumn(COL_TYPE)->getValue().asInteger()); - if (!LLMuteList::getInstance()->isMuted(item->getColumn(3)->getValue().asUUID(), flags)) + if (!LLMuteList::getInstance()->isMuted(item->getColumn(COL_UUID)->getValue().asUUID(), flags)) { LLMuteList::getInstance()->add(mute, flags); } @@ -431,9 +431,9 @@ void FSPanelBlockList::onSelectionChanged() void FSPanelBlockList::showProfile() { if (mBlockedList->getNumSelected() == 1 && - (LLMute::EType)mBlockedList->getFirstSelected()->getColumn(2)->getValue().asInteger() == LLMute::AGENT) + (LLMute::EType)mBlockedList->getFirstSelected()->getColumn(COL_TYPE)->getValue().asInteger() == LLMute::AGENT) { - LLAvatarActions::showProfile(mBlockedList->getFirstSelected()->getColumn(3)->getValue().asUUID()); + LLAvatarActions::showProfile(mBlockedList->getFirstSelected()->getColumn(COL_UUID)->getValue().asUUID()); } } diff --git a/indra/newview/fspanelblocklist.h b/indra/newview/fspanelblocklist.h index 288d9da7f8..2910132236 100644 --- a/indra/newview/fspanelblocklist.h +++ b/indra/newview/fspanelblocklist.h @@ -65,13 +65,24 @@ public: /* virtual */ void onChange() { refreshBlockedList();} private: - typedef enum e_sort_oder{ + typedef enum e_sort_oder + { E_SORT_BY_NAME_ASC = 0, E_SORT_BY_TYPE_ASC = 1, E_SORT_BY_NAME_DESC = 2, E_SORT_BY_TYPE_DESC = 3 } ESortOrder; + + typedef enum e_column_names + { + COL_NAME = 0, + COL_TYPENAME, + COL_TYPE, + COL_UUID + } EColumnNames; + + void refreshBlockedList(); void updateButtons(); void removePicker(); @@ -82,7 +93,7 @@ private: void blockResidentByName(); void blockObjectByName(); void showProfile(); - void toggleMute(U32 flags); + void toggleMute(U32 flags); void onSelectionChanged(); void onFilterEdit(std::string search_string); @@ -91,7 +102,7 @@ private: void onCustomAction(const LLSD& userdata); bool isActionChecked(const LLSD& userdata); bool isActionEnabled(const LLSD& userdata); - bool isActionVisible(const LLSD& userdata); + bool isActionVisible(const LLSD& userdata); void callbackBlockPicked(const uuid_vec_t& ids, const std::vector names); void callbackBlockByName(const std::string& text);