Make area search column configuration persistant

Ansariel 2014-09-26 22:55:06 +02:00
parent c36ccdc6bb
commit fe0ceb7b94
4 changed files with 189 additions and 222 deletions

View File

@ -22743,6 +22743,17 @@ Change of this parameter will affect the layout of buttons in notification toast
<key>Value</key>
<integer>1</integer>
</map>
<key>FSAreaSearchColumnConfig</key>
<map>
<key>Comment</key>
<string>Stores the column visibility for the area search</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>U32</string>
<key>Value</key>
<integer>1023</integer>
</map>
</map>
</llsd>

View File

@ -121,16 +121,6 @@ FSAreaSearch::FSAreaSearch(const LLSD& key) :
mExcludePhysics(true),
mExcludeChildPrims(true),
mExcludeNeighborRegions(true),
mColumnDistance(true),
mColumnName(true),
mColumnDescription(true),
mColumnPrice(true),
mColumnLandImpact(true),
mColumnPrimCount(true),
mColumnOwner(true),
mColumnGroup(true),
mColumnCreator(true),
mColumnLastOwner(true),
mRequestQueuePause(false),
mRequestNeedsSent(false)
{
@ -951,91 +941,61 @@ void FSAreaSearch::matchObject(FSObjectProperties& details, LLViewerObject* obje
LLScrollListItem::Params row_params;
row_params.value = object_id.asString();
if (mColumnDistance)
{
cell_params.column = "distance";
cell_params.value = llformat("%1.0f m", dist_vec(mPanelList->getAgentLastPosition(), objectp->getPositionGlobal())); // used mAgentLastPosition instead of gAgent->getPositionGlobal for performace
row_params.columns.add(cell_params);
}
if (mColumnName)
{
cell_params.column = "name";
cell_params.value = details.name;
row_params.columns.add(cell_params);
}
cell_params.column = "distance";
cell_params.value = llformat("%1.0f m", dist_vec(mPanelList->getAgentLastPosition(), objectp->getPositionGlobal())); // used mAgentLastPosition instead of gAgent->getPositionGlobal for performace
row_params.columns.add(cell_params);
if (mColumnDescription)
{
cell_params.column = "description";
cell_params.value = details.description;
row_params.columns.add(cell_params);
}
cell_params.column = "name";
cell_params.value = details.name;
row_params.columns.add(cell_params);
if (mColumnPrice)
{
cell_params.column = "price";
if (details.sale_info.isForSale())
{
S32 price = details.sale_info.getSalePrice();
cell_params.value = price > 0 ? llformat("%s%d", "L$", details.sale_info.getSalePrice()) : LLTrans::getString("free");
}
else
{
cell_params.value = " ";
}
row_params.columns.add(cell_params);
}
cell_params.column = "description";
cell_params.value = details.description;
row_params.columns.add(cell_params);
if (mColumnLandImpact)
cell_params.column = "price";
if (details.sale_info.isForSale())
{
cell_params.column = "land_impact";
F32 cost = objectp->getLinksetCost();
if (cost > 0.001)
{
cell_params.value = cost;
}
else
{
cell_params.value = "...";
}
row_params.columns.add(cell_params);
S32 price = details.sale_info.getSalePrice();
cell_params.value = price > 0 ? llformat("%s%d", "L$", details.sale_info.getSalePrice()) : LLTrans::getString("free");
}
else
{
cell_params.value = " ";
}
row_params.columns.add(cell_params);
if (mColumnPrimCount)
cell_params.column = "land_impact";
F32 cost = objectp->getLinksetCost();
if (cost > 0.001)
{
cell_params.column = "prim_count";
cell_params.value = objectp->numChildren() + 1;
row_params.columns.add(cell_params);
cell_params.value = cost;
}
else
{
cell_params.value = "...";
}
row_params.columns.add(cell_params);
if (mColumnOwner)
{
cell_params.column = "owner";
cell_params.value = owner_name;
row_params.columns.add(cell_params);
}
cell_params.column = "prim_count";
cell_params.value = objectp->numChildren() + 1;
row_params.columns.add(cell_params);
if (mColumnGroup)
{
cell_params.column = "group";
cell_params.value = group_name;
row_params.columns.add(cell_params);
}
cell_params.column = "owner";
cell_params.value = owner_name;
row_params.columns.add(cell_params);
if (mColumnCreator)
{
cell_params.column = "creator";
cell_params.value = creator_name;
row_params.columns.add(cell_params);
}
cell_params.column = "group";
cell_params.value = group_name;
row_params.columns.add(cell_params);
if (mColumnLastOwner)
{
cell_params.column = "last_owner";
cell_params.value = last_owner_name;
row_params.columns.add(cell_params);
}
cell_params.column = "creator";
cell_params.value = creator_name;
row_params.columns.add(cell_params);
cell_params.column = "last_owner";
cell_params.value = last_owner_name;
row_params.columns.add(cell_params);
LLScrollListItem* list_row = mPanelList->getResultList()->addRow(row_params);
@ -1301,8 +1261,19 @@ FSPanelAreaSearchList::FSPanelAreaSearchList(FSAreaSearch* pointer)
: LLPanel(),
mCounterText(0),
mResultList(0),
mFSAreaSearch(pointer)
mFSAreaSearch(pointer),
mFSRadarColumnConfigConnection()
{
mColumnBits["distance"] = 1;
mColumnBits["name"] = 2;
mColumnBits["description"] = 4;
mColumnBits["price"] = 8;
mColumnBits["land_impact"] = 16;
mColumnBits["prim_count"] = 32;
mColumnBits["owner"] = 64;
mColumnBits["group"] = 128;
mColumnBits["creator"] = 256;
mColumnBits["last_owner"] = 512;
}
BOOL FSPanelAreaSearchList::postBuild()
@ -1322,12 +1293,20 @@ BOOL FSPanelAreaSearchList::postBuild()
mAgentLastPosition = gAgent.getPositionGlobal();
updateResultListColumns();
mFSRadarColumnConfigConnection = gSavedSettings.getControl("FSAreaSearchColumnConfig")->getSignal()->connect(boost::bind(&FSPanelAreaSearchList::updateResultListColumns, this));
return LLPanel::postBuild();
}
// virtual
FSPanelAreaSearchList::~FSPanelAreaSearchList()
{ }
{
if (mFSRadarColumnConfigConnection.connected())
{
mFSRadarColumnConfigConnection.disconnect();
}
}
void FSPanelAreaSearchList::onClickRefresh()
{
@ -1422,6 +1401,75 @@ void FSPanelAreaSearchList::updateScrollList()
}
}
void FSPanelAreaSearchList::updateResultListColumns()
{
U32 column_config = gSavedSettings.getU32("FSAreaSearchColumnConfig");
std::vector<LLScrollListColumn::Params> column_params = mResultList->getColumnInitParams();
std::string current_sort_col = mResultList->getSortColumnName();
BOOL current_sort_asc = mResultList->getSortAscending();
mResultList->clearColumns();
mResultList->updateLayout();
std::vector<LLScrollListColumn::Params>::iterator param_it;
for (param_it = column_params.begin(); param_it != column_params.end(); ++param_it)
{
LLScrollListColumn::Params p = *param_it;
LLScrollListColumn::Params params;
params.header = p.header;
params.name = p.name;
params.halign = p.halign;
params.sort_direction = p.sort_direction;
params.sort_column = p.sort_column;
params.tool_tip = p.tool_tip;
if (column_config & mColumnBits[p.name.getValue()])
{
params.width = p.width;
}
else
{
params.width.pixel_width.set(-1, true);
}
mResultList->addColumn(params);
}
mResultList->sortByColumn(current_sort_col, current_sort_asc);
mResultList->dirtyColumns();
mResultList->updateColumns(true);
}
void FSPanelAreaSearchList::onColumnVisibilityChecked(const LLSD& userdata)
{
std::string column = userdata.asString();
U32 column_config = gSavedSettings.getU32("FSAreaSearchColumnConfig");
U32 new_value;
U32 enabled = (mColumnBits[column] & column_config);
if (enabled)
{
new_value = (column_config & ~mColumnBits[column]);
}
else
{
new_value = (column_config | mColumnBits[column]);
}
gSavedSettings.setU32("FSAreaSearchColumnConfig", new_value);
updateResultListColumns();
}
bool FSPanelAreaSearchList::onEnableColumnVisibilityChecked(const LLSD& userdata)
{
std::string column = userdata.asString();
U32 column_config = gSavedSettings.getU32("FSAreaSearchColumnConfig");
return (mColumnBits[column] & column_config);
}
void FSPanelAreaSearchList::updateName(LLUUID id, std::string name)
{
LLScrollListColumn* creator_column = mResultList->getColumn("creator");
@ -2101,6 +2149,7 @@ FSPanelAreaSearchOptions::FSPanelAreaSearchOptions(FSAreaSearch* pointer)
mFSAreaSearch(pointer)
{
mCommitCallbackRegistrar.add("AreaSearch.DisplayColumn", boost::bind(&FSPanelAreaSearchOptions::onCommitCheckboxDisplayColumn, this, _2));
mEnableCallbackRegistrar.add("AreaSearch.EnableColumn", boost::bind(&FSPanelAreaSearchOptions::onEnableColumnVisibilityChecked, this, _2));
}
// virtual
@ -2116,122 +2165,12 @@ void FSPanelAreaSearchOptions::onCommitCheckboxDisplayColumn(const LLSD& userdat
return;
}
FSAreaSearchListCtrl* result_list = mFSAreaSearch->getPanelList()->getResultList();
result_list->deleteAllItems();
mFSAreaSearch->getPanelList()->onColumnVisibilityChecked(userdata);
}
std::vector<LLScrollListColumn::Params> params = result_list->getColumnInitParams();
result_list->clearColumns();
const child_list_t* children = getChildList();
for (child_list_t::const_reverse_iterator it = children->rbegin(); it != children->rend(); ++it)
{
LLCheckBoxCtrl* ctrl = dynamic_cast<LLCheckBoxCtrl*>(*it);
if (ctrl && ctrl->getName().find("show_") != std::string::npos && ctrl->get())
{
std::string col_name = ctrl->getName().substr(5);
for (std::vector<LLScrollListColumn::Params>::iterator pit = params.begin(); pit != params.end(); ++pit)
{
if ((*pit).name.getValue() == col_name)
{
result_list->addColumn(*pit);
break;
}
}
}
}
/// until C++ supports variable within a variable name, have to do this instead.
/// used switch instead of a huge if then else if then else...
// Please keep in alphabetical order. Provides both optimizations and ease of updating as the list grows.
LLCheckBoxCtrl* checkboxctrl = getChild<LLCheckBoxCtrl>("show_" + column_name);
char c = column_name.at(0);
switch(c)
{
case 'c':
{
mFSAreaSearch->setColumnCreator(checkboxctrl->get());
break;
}
case 'd':
{
char d = column_name.at(1);
switch (d)
{
case 'i':
{
mFSAreaSearch->setColumnDistance(checkboxctrl->get());
break;
}
case 'e':
{
mFSAreaSearch->setColumnDescription(checkboxctrl->get());
break;
}
default:
break;
}
break;
}
case 'g':
{
mFSAreaSearch->setColumnGroup(checkboxctrl->get());
break;
}
case 'l':
{
char d = column_name.at(2);
switch (d)
{
case 'n':
{
mFSAreaSearch->setColumnLandImpact(checkboxctrl->get());
break;
}
case 's':
{
mFSAreaSearch->setColumnLastOwner(checkboxctrl->get());
break;
}
default:
break;
}
break;
}
case 'n':
{
mFSAreaSearch->setColumnName(checkboxctrl->get());
break;
}
case 'o':
{
mFSAreaSearch->setColumnOwner(checkboxctrl->get());
break;
}
case 'p':
{
char d = column_name.at(3);
switch (d)
{
case 'c':
{
mFSAreaSearch->setColumnPrice(checkboxctrl->get());
break;
}
case 'm':
{
mFSAreaSearch->setColumnPrimCount(checkboxctrl->get());
break;
}
default:
break;
}
break;
}
default:
break;
}
result_list->dirtyColumns();
bool FSPanelAreaSearchOptions::onEnableColumnVisibilityChecked(const LLSD& userdata)
{
return mFSAreaSearch->getPanelList()->onEnableColumnVisibilityChecked(userdata);
}

View File

@ -158,17 +158,6 @@ public:
void setFilterDistanceMin(S32 s) { mFilterDistanceMin = s; }
void setFilterDistanceMax(S32 s) { mFilterDistanceMax = s; }
void setColumnDistance(bool b) { mColumnDistance = b; }
void setColumnName(bool b) { mColumnName = b; }
void setColumnDescription(bool b) { mColumnDescription = b; }
void setColumnPrice(bool b) { mColumnPrice = b; }
void setColumnLandImpact(bool b) { mColumnLandImpact = b; }
void setColumnPrimCount(bool b) { mColumnPrimCount = b; }
void setColumnOwner(bool b) { mColumnOwner = b; }
void setColumnGroup(bool b) { mColumnGroup = b; }
void setColumnCreator(bool b) { mColumnCreator = b; }
void setColumnLastOwner(bool b) { mColumnLastOwner = b; }
bool isActive() { return mActive; }
private:
@ -253,17 +242,6 @@ private:
bool mFilterClickAction;
U8 mFilterClickActionType;
bool mColumnDistance;
bool mColumnName;
bool mColumnDescription;
bool mColumnPrice;
bool mColumnLandImpact;
bool mColumnPrimCount;
bool mColumnOwner;
bool mColumnGroup;
bool mColumnCreator;
bool mColumnLastOwner;
protected:
static void* createPanelList(void* data);
@ -283,6 +261,7 @@ class FSPanelAreaSearchList
{
LOG_CLASS(FSPanelAreaSearchList);
friend class FSAreaSearchMenu;
friend class FSPanelAreaSearchOptions;
public:
FSPanelAreaSearchList(FSAreaSearch* pointer);
@ -297,6 +276,7 @@ public:
void touchObject(LLViewerObject* objectp);
FSAreaSearchListCtrl* getResultList() { return mResultList; }
void updateResultListColumns();
void setAgentLastPosition(LLVector3d d) { mAgentLastPosition = d; }
LLVector3d getAgentLastPosition() { return mAgentLastPosition; }
@ -310,6 +290,9 @@ private:
bool onContextMenuItemClick(const LLSD& userdata);
bool onContextMenuItemEnable(const LLSD& userdata);
void onColumnVisibilityChecked(const LLSD& userdata);
bool onEnableColumnVisibilityChecked(const LLSD& userdata);
F32 getBBoxAspectRatio(const LLBBox& bbox, const LLVector3& normal, F32* height, F32* width, F32* depth);
LLVector3d mAgentLastPosition;
@ -319,6 +302,9 @@ private:
FSAreaSearchListCtrl* mResultList;
LLCheckBoxCtrl* mCheckboxBeacons;
LLTextBox* mCounterText;
std::map<std::string, U32> mColumnBits;
boost::signals2::connection mFSRadarColumnConfigConnection;
};
@ -413,6 +399,7 @@ public:
private:
void onCommitCheckboxDisplayColumn(const LLSD& userdata);
bool onEnableColumnVisibilityChecked(const LLSD& userdata);
FSAreaSearch* mFSAreaSearch;

View File

@ -590,6 +590,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="distance"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="distance"/>
</check_box>
<check_box
follows="top|left"
@ -603,6 +606,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="name"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="name"/>
</check_box>
<check_box
follows="top|left"
@ -616,6 +622,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="description"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="description"/>
</check_box>
<check_box
follows="top|left"
@ -629,6 +638,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="price"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="price"/>
</check_box>
<check_box
follows="top|left"
@ -642,6 +654,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="land_impact"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="land_impact"/>
</check_box>
<check_box
follows="top|left"
@ -655,6 +670,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="prim_count"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="prim_count"/>
</check_box>
<check_box
follows="top|left"
@ -668,6 +686,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="owner"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="owner"/>
</check_box>
<check_box
follows="top|left"
@ -681,6 +702,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="group"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="group"/>
</check_box>
<check_box
follows="top|left"
@ -694,6 +718,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="creator"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="creator"/>
</check_box>
<check_box
follows="top|left"
@ -707,6 +734,9 @@
<check_box.commit_callback
function="AreaSearch.DisplayColumn"
parameter="last_owner"/>
<check_box.on_check
function="AreaSearch.EnableColumn"
parameter="last_owner"/>
</check_box>
</panel>
<panel